mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-11580, hide quiz grades when user has no grade:viewhidden capability and quiz is still open, need $CFG->openuniversityhacks flag set
This commit is contained in:
parent
5961dbfb10
commit
fb72e817d9
@ -708,6 +708,8 @@ function quiz_get_renderoptions($reviewoptions, $state) {
|
||||
*/
|
||||
function quiz_get_reviewoptions($quiz, $attempt, $context=null) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$options = new stdClass;
|
||||
$options->readonly = true;
|
||||
// Provide the links to the question review and comment script
|
||||
@ -717,7 +719,15 @@ function quiz_get_reviewoptions($quiz, $attempt, $context=null) {
|
||||
// The teacher should be shown everything except during preview when the teachers
|
||||
// wants to see just what the students see
|
||||
$options->responses = 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;
|
||||
|
@ -30,6 +30,12 @@ class quiz_report extends quiz_default_report {
|
||||
$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);
|
||||
|
||||
@ -443,10 +449,11 @@ class quiz_report extends quiz_default_report {
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -456,7 +463,8 @@ class quiz_report extends quiz_default_report {
|
||||
}
|
||||
} 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 = '--';
|
||||
|
Loading…
x
Reference in New Issue
Block a user