Merge branch 'MDL-62533-master' of git://github.com/zig-moodle/moodle
authorDavid Monllao <davidm@moodle.com>
Tue, 10 Jul 2018 05:37:19 +0000 (07:37 +0200)
committerDavid Monllao <davidm@moodle.com>
Tue, 10 Jul 2018 05:37:19 +0000 (07:37 +0200)
mod/assign/locallib.php
mod/assign/renderable.php
mod/assign/renderer.php
mod/assign/tests/behat/assign_hidden.feature [new file with mode: 0644]

index 0a13324..55f734c 100644 (file)
@@ -5326,12 +5326,14 @@ class assign {
     public function get_assign_grading_summary_renderable($activitygroup = null) {
 
         $instance = $this->get_instance();
+        $cm = $this->get_course_module();
 
         $draft = ASSIGN_SUBMISSION_STATUS_DRAFT;
         $submitted = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
+        $isvisible = $cm->visible;
 
         if ($activitygroup === null) {
-            $activitygroup = groups_get_activity_group($this->get_course_module());
+            $activitygroup = groups_get_activity_group($cm);
         }
 
         if ($instance->teamsubmission) {
@@ -5349,7 +5351,8 @@ class assign {
                                                   $this->count_submissions_need_grading($activitygroup),
                                                   $instance->teamsubmission,
                                                   $warnofungroupedusers,
-                                                  $this->can_grade());
+                                                  $this->can_grade(),
+                                                  $isvisible);
         } else {
             // The active group has already been updated in groups_print_activity_menu().
             $countparticipants = $this->count_participants($activitygroup);
@@ -5364,8 +5367,8 @@ class assign {
                                                   $this->count_submissions_need_grading($activitygroup),
                                                   $instance->teamsubmission,
                                                   false,
-                                                  $this->can_grade());
-
+                                                  $this->can_grade(),
+                                                  $isvisible);
         }
 
         return $summary;
index 7e550a3..604f11c 100644 (file)
@@ -750,6 +750,8 @@ class assign_grading_summary implements renderable {
     public $warnofungroupedusers = false;
     /** @var boolean cangrade - Can the current user grade students? */
     public $cangrade = false;
+    /** @var boolean isvisible - Is the assignment's context module visible to students? */
+    public $isvisible = true;
 
     /**
      * constructor
@@ -765,6 +767,7 @@ class assign_grading_summary implements renderable {
      * @param int $submissionsneedgradingcount
      * @param bool $teamsubmission
      * @param bool $cangrade
+     * @param bool $isvisible
      */
     public function __construct($participantcount,
                                 $submissiondraftsenabled,
@@ -777,7 +780,8 @@ class assign_grading_summary implements renderable {
                                 $submissionsneedgradingcount,
                                 $teamsubmission,
                                 $warnofungroupedusers,
-                                $cangrade = true) {
+                                $cangrade = true,
+                                $isvisible = true) {
         $this->participantcount = $participantcount;
         $this->submissiondraftsenabled = $submissiondraftsenabled;
         $this->submissiondraftscount = $submissiondraftscount;
@@ -790,6 +794,7 @@ class assign_grading_summary implements renderable {
         $this->teamsubmission = $teamsubmission;
         $this->warnofungroupedusers = $warnofungroupedusers;
         $this->cangrade = $cangrade;
+        $this->isvisible = $isvisible;
     }
 }
 
index f461e21..6a1b81a 100644 (file)
@@ -267,6 +267,10 @@ class mod_assign_renderer extends plugin_renderer_base {
         $o .= $this->output->box_start('boxaligncenter gradingsummarytable');
         $t = new html_table();
 
+        // Visibility Status.
+        $this->add_table_row_tuple($t, get_string('hiddenfromstudents'),
+            (!$summary->isvisible) ? get_string('yes') : get_string('no'));
+
         // Status.
         if ($summary->teamsubmission) {
             if ($summary->warnofungroupedusers) {
diff --git a/mod/assign/tests/behat/assign_hidden.feature b/mod/assign/tests/behat/assign_hidden.feature
new file mode 100644 (file)
index 0000000..378867e
--- /dev/null
@@ -0,0 +1,38 @@
+@mod @mod_assign @javascript
+Feature: When a Teacher hides an assignment from view for students it should consistently indicate it is hidden.
+
+  Scenario: Grade multiple students on one page
+    Given the following "courses" exist:
+      | fullname | shortname | category | groupmode |
+      | Course 1 | C1 | 0 | 1 |
+    And the following "users" exist:
+      | username | firstname | lastname | email |
+      | teacher1 | Teacher | 1 | teacher1@example.com |
+      | student1 | Student | 1 | student1@example.com |
+    And the following "course enrolments" exist:
+      | user | course | role |
+      | teacher1 | C1 | editingteacher |
+      | student1 | C1 | student |
+    When I log in as "teacher1"
+    And I am on "Course 1" course homepage with editing mode on
+    And I add a "Assignment" to section "1" and I fill the form with:
+      | Assignment name | Test hidden assignment |
+    And I open "Test hidden assignment" actions menu
+    And I choose "Hide" in the open action menu
+    And I follow "Test hidden assignment"
+    And I should see "Test hidden assignment"
+    And I should see "Yes" in the "Hidden from students" "table_row"
+    And I log out
+    And I log in as "teacher1"
+    And I am on "Course 1" course homepage with editing mode on
+    And I add a "Assignment" to section "2" and I fill the form with:
+      | Assignment name | Test visible assignment |
+    And I follow "Test visible assignment"
+    And I should see "Test visible assignment"
+    And I should see "No" in the "Hidden from students" "table_row"
+    And I log out
+    And I log in as "student1"
+    And I am on "Course 1" course homepage
+    And I should not see "Test hidden assignment"
+    And I should see "Test visible assignment"
+    And I log out