Permalink
Browse files

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

  • Loading branch information...
frogprincess authored and Sam Hemelryk committed Jun 7, 2013
1 parent 0b20ce2 commit ea698284cf7bd655b6afd4152c18890fbfadc180
Showing with 20 additions and 4 deletions.
  1. +3 −3 mod/assign/locallib.php
  2. +17 −1 mod/assign/tests/locallib_test.php
View
@@ -3586,9 +3586,9 @@ public function view_student_summary($user, $showlinks) {
}
$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;
@@ -645,9 +645,25 @@ public function test_show_student_summary() {
// 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() {

0 comments on commit ea69828

Please sign in to comment.