* correct_responses, solutions and general feedback
*/
function quiz_get_reviewoptions($quiz, $attempt, $context=null) {
+
+ global $CFG;
$options = new stdClass;
$options->readonly = true;
// The teacher should be shown everything except during preview when the teachers
// wants to see just what the students see
$options->responses = true;
- $options->scores = true;
+
+ // MDL-11580, hide quiz report for teachers when they have no viewhidden capability
+ // need to check for other calls when context is not supplied
+ if (empty($CFG->openuniversityhacks) || ($context && has_capability('moodle/grade:viewhidden', $context))) {
+ $options->scores = true;
+ } else {
+ $options->scores = ($quiz->review & $quiz_state_mask & QUIZ_REVIEW_SCORES) ? 1 : 0;
+ }
+
$options->feedback = true;
$options->correct_responses = true;
$options->solutions = false;
$this->print_header_and_tabs($cm, $course, $quiz, $reportmode="overview");
}
+ // MDL-11580, make a fake attempt object
+ // so that we can check whehter this user can view scores or not
+ $attempt->preview = false;
+ $attempt->timefinish = $quiz->timeopen;
+ $attemptoptions = quiz_get_reviewoptions($quiz, $attempt, $context);
+
// Deal with actions
$action = optional_param('action', '', PARAM_ACTION);
}
if ($quiz->grade and $quiz->sumgrades) {
+ // MDL-11580, hide grades for OU teachers with no view hidden capability in open quiz
if (!$download) {
- $row[] = $attempt->sumgrades === NULL ? '-' : '<a href="review.php?q='.$quiz->id.'&attempt='.$attempt->attempt.'">'.round($attempt->sumgrades / $quiz->sumgrades * $quiz->grade,$quiz->decimalpoints).'</a>';
+ $row[] = ($attempt->sumgrades === NULL || !$attemptoptions->scores)? '-' : '<a href="review.php?q='.$quiz->id.'&attempt='.$attempt->attempt.'">'.round($attempt->sumgrades / $quiz->sumgrades * $quiz->grade,$quiz->decimalpoints).'</a>';
} else {
- $row[] = $attempt->sumgrades === NULL ? '-' : round($attempt->sumgrades / $quiz->sumgrades * $quiz->grade,$quiz->decimalpoints);
+ $row[] = ($attempt->sumgrades === NULL || !$attemptoptions->scores) ? '-' : round($attempt->sumgrades / $quiz->sumgrades * $quiz->grade,$quiz->decimalpoints);
}
}
if($detailedmarks) {
}
} else {
foreach($questionids as $questionid) {
- if ($gradedstateid = get_field('question_sessions', 'newgraded', 'attemptid', $attempt->attemptuniqueid, 'questionid', $questionid)) {
+ // MDL-11580
+ if (!$attemptoptions->scores && ($gradedstateid = get_field('question_sessions', 'newgraded', 'attemptid', $attempt->attemptuniqueid, 'questionid', $questionid))) {
$grade = round(get_field('question_states', 'grade', 'id', $gradedstateid), $quiz->decimalpoints);
} else {
$grade = '--';
if (!$download) {
$row[] = link_to_popup_window ('/mod/quiz/reviewquestion.php?state='.$gradedstateid.'&number='.$questions[$questionid]->number, 'reviewquestion', $grade, 450, 650, $strreviewquestion, 'none', true);
} else {
- $row[] = $grade;
+ $row[] = $grade;
}
}
}