MDL-11274, hide grades in the grader report if the current grades has no viewhidden capability

This commit is contained in:
toyomoyo 2007-09-14 08:43:10 +00:00
parent 098042baea
commit 00374cc5f0
3 changed files with 21 additions and 2 deletions

View File

@ -591,6 +591,8 @@ class grade_report_grader extends grade_report {
$scales_list = substr($scales_list, 0, -1);
$scales_array = get_records_list('scale', 'id', $scales_list);
}
$canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->course->id));
foreach ($this->users as $userid => $user) {
$columncount = 0;
@ -620,6 +622,16 @@ class grade_report_grader extends grade_report {
$grade->feedback = '';
}
// MDL-11274
// Hide grades in the grader report if the current grader doesn't have 'moodle/grade:viewhidden'
if ($grade->is_hidden() && !$canviewhidden) {
if (isset($grade->finalgrade)) {
$studentshtml .= '<td class="cell c'.$columncount++.'">'.userdate($grade->timecreated,get_string('strftimedatetimeshort')).'</td>'; } else {
$studentshtml .= '<td class="cell c'.$columncount++.'">-</td>';
}
continue;
}
$grade->courseid = $this->courseid;
$grade->grade_item =& $this->items[$itemid]; // this speedsup is_hidden() and other grade_grade methods

View File

@ -328,7 +328,7 @@ class grade_report {
}
$coursemodule = get_coursemodule_from_instance($itemmodule, $iteminstance, $this->course->id);
$dir = $CFG->dirroot . "/mod/$itemmodule/";
$url = $CFG->wwwroot . "/mod/$itemmodule/";
@ -339,7 +339,13 @@ class grade_report {
}
$url .= "?id=$coursemodule->id";
return '<a href="' . $url . '">' . $modulename . '</a>';
// MDL-11274, Hide grades in the grader report if the current grader doesn't have 'moodle/grade:viewhidden'
if (has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $coursemodule->course))) {
return '<a href="' . $url . '">' . $modulename . '</a>';
} else {
return $modulename;
}
}
return $modulename;

View File

@ -1381,6 +1381,7 @@ $string['status'] = 'Status';
$string['strftimedate'] = '%%d %%B %%Y';
$string['strftimedateshort'] = '%%d %%B';
$string['strftimedatetime'] = '%%d %%B %%Y, %%I:%%M %%p';
$string['strftimedatetimeshort'] = '%%d/%%m/%%Y %%H:%%M';
$string['strftimedaydate'] = '%%A, %%d %%B %%Y';
$string['strftimedaydatetime'] = '%%A, %%d %%B %%Y, %%I:%%M %%p';
$string['strftimedayshort'] = '%%A, %%d %%B';