MDL-38376 mod_assign: Feedback displayed when Grade set to hidden

This commit is contained in:
Amanda Doughty 2013-06-07 20:33:30 +01:00 committed by Sam Hemelryk
parent 0b20ce2841
commit ea698284cf
2 changed files with 20 additions and 4 deletions

View File

@ -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;

View File

@ -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() {