Merge branch 'MDL-36897_23' of git://github.com/timhunt/moodle into MOODLE_23_STABLE
authorDan Poltawski <dan@moodle.com>
Tue, 11 Dec 2012 05:54:23 +0000 (13:54 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 11 Dec 2012 05:54:23 +0000 (13:54 +0800)
mod/quiz/summary.php

index 303638f..cf6068d 100644 (file)
@@ -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.