From: Tim Hunt Date: Fri, 30 Nov 2012 11:53:38 +0000 (+0000) Subject: MDL-36897 quiz: redirect teachers from summary to review page. X-Git-Tag: v2.3.4~106^2 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=50c88ad26cffac21754d9e22f7514b35d50c4eec;ds=inline MDL-36897 quiz: redirect teachers from summary to review page. There is already logic like this at the top of attempt.php. If the teacher arrives at one of these pages for a student's attempt, for example by clicking a link in the logs, then they should be redirected to the review page to see the students attempt in its current state. --- diff --git a/mod/quiz/summary.php b/mod/quiz/summary.php index 303638f013c..cf6068dc0fc 100644 --- a/mod/quiz/summary.php +++ b/mod/quiz/summary.php @@ -36,9 +36,13 @@ $attemptobj = quiz_attempt::create($attemptid); // Check login. require_login($attemptobj->get_course(), false, $attemptobj->get_cm()); -// If this is not our own attempt, display an error. +// Check that this attempt belongs to this user. if ($attemptobj->get_userid() != $USER->id) { - print_error('notyourattempt', 'quiz', $attemptobj->view_url()); + if ($attemptobj->has_capability('mod/quiz:viewreports')) { + redirect($attemptobj->review_url(null, $page)); + } else { + throw new moodle_quiz_exception($attemptobj->get_quizobj(), 'notyourattempt'); + } } // Check capabilites.