diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index f4fde92cdff..1697137bb1b 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -3586,9 +3586,9 @@ class assign { } $cangrade = has_capability('mod/assign:grade', $this->get_context()); - // If there is feedback or a visible grade, show the summary. - if ((!empty($gradebookgrade->grade) && ($cangrade || !$gradebookgrade->hidden) && $gradereleased) || - !$emptyplugins) { + // If there is a visible grade, show the summary. + if ((!empty($gradebookgrade->grade) || !$emptyplugins) + && ($cangrade || !$gradebookgrade->hidden)) { $gradefordisplay = null; $gradeddate = null; diff --git a/mod/assign/tests/locallib_test.php b/mod/assign/tests/locallib_test.php index ef32825bc98..b0a9a53402b 100644 --- a/mod/assign/tests/locallib_test.php +++ b/mod/assign/tests/locallib_test.php @@ -645,9 +645,25 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase { // Should have feedback but no grade. $this->setUser($this->students[0]); $output = $assign->view_student_summary($this->students[0], true); - $this->assertNotEquals(false, strpos($output, 'Tomato sauce'), 'Show feedback even if there is no grade'); + $this->assertNotEquals(false, strpos($output, 'Feedback'), 'Show feedback even if there is no grade'); $this->assertEquals(false, strpos($output, 'Grade'), 'Do not show grade when there is no grade.'); $this->assertEquals(false, strpos($output, 'Graded on'), 'Do not show graded date when there is no grade.'); + + // Now hide the grade in gradebook. + $this->setUser($this->teachers[0]); + $gradeitem = new grade_item(array( + 'itemtype' => 'mod', + 'itemmodule' => 'assign', + 'iteminstance' => $assign->get_instance()->id, + 'courseid' => $this->course->id)); + + $gradeitem->set_hidden(1, false); + + // No feedback should be available because the grade is hidden. + $this->setUser($this->students[0]); + $output = $assign->view_student_summary($this->students[0], true); + $this->assertEquals(false, strpos($output, 'Feedback'), 'Do not show feedback if the grade is hidden in the gradebook'); + } public function test_attempt_reopen_method_manual() {