From a8f7818beb885e0febaf60759c663ba435e1376b Mon Sep 17 00:00:00 2001 From: Zig Tan Date: Wed, 27 Jun 2018 12:17:39 +0800 Subject: [PATCH] MDL-62533 assign: Show assign hidden status on grading summary page --- mod/assign/locallib.php | 11 +++--- mod/assign/renderable.php | 7 +++- mod/assign/renderer.php | 4 +++ mod/assign/tests/behat/assign_hidden.feature | 38 ++++++++++++++++++++ 4 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 mod/assign/tests/behat/assign_hidden.feature diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 75f4ccd9d9b..f974ceda4da 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -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; diff --git a/mod/assign/renderable.php b/mod/assign/renderable.php index 7e550a3ecf0..604f11cc2a4 100644 --- a/mod/assign/renderable.php +++ b/mod/assign/renderable.php @@ -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; } } diff --git a/mod/assign/renderer.php b/mod/assign/renderer.php index f461e213f4c..6a1b81abb26 100644 --- a/mod/assign/renderer.php +++ b/mod/assign/renderer.php @@ -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 index 00000000000..378867e9563 --- /dev/null +++ b/mod/assign/tests/behat/assign_hidden.feature @@ -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