Index: mod/quiz/reviewquestion.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/reviewquestion.php,v retrieving revision 1.16.10.7 diff -u -r1.16.10.7 reviewquestion.php --- mod/quiz/reviewquestion.php 10 Dec 2008 06:22:04 -0000 1.16.10.7 +++ mod/quiz/reviewquestion.php 15 Dec 2008 08:33:44 -0000 @@ -63,6 +63,8 @@ if (!$attempt->timefinish) { redirect('attempt.php?q='.$quiz->id); } + // Must have review capability. + require_capability('mod/quiz:reviewmyattempts', $context); // If not even responses are to be shown in review then we // don't allow any review if (!($quiz->review & QUIZ_REVIEW_RESPONSES)) { Index: mod/quiz/index.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/index.php,v retrieving revision 1.46.2.11 diff -u -r1.46.2.11 index.php --- mod/quiz/index.php 23 Apr 2008 10:54:57 -0000 1.46.2.11 +++ mod/quiz/index.php 15 Dec 2008 08:33:43 -0000 @@ -53,15 +53,16 @@ } array_unshift($align, 'center'); - $showing = 'scores'; // default + $showing = ''; // default if (has_capability('mod/quiz:viewreports', $coursecontext)) { array_push($headings, get_string('attempts', 'quiz')); array_push($align, 'left'); $showing = 'stats'; - } else if (has_capability('mod/quiz:attempt', $coursecontext)) { + } else if (has_any_capability(array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), $coursecontext)) { array_push($headings, get_string('bestgrade', 'quiz'), get_string('feedback', 'quiz')); array_push($align, 'left', 'left'); + $showing = 'scores'; // default } $table->head = $headings; Index: mod/quiz/version.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/version.php,v retrieving revision 1.128.2.3 diff -u -r1.128.2.3 version.php --- mod/quiz/version.php 19 Aug 2008 21:39:05 -0000 1.128.2.3 +++ mod/quiz/version.php 15 Dec 2008 08:33:44 -0000 @@ -5,7 +5,7 @@ // This fragment is called by moodle_needs_upgrading() and /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2007101510; // The (date) version of this module +$module->version = 2007101511; // The (date) version of this module $module->requires = 2007101509; // Requires this Moodle version $module->cron = 0; // How often should cron check this module (seconds)? Index: mod/quiz/view.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/view.php,v retrieving revision 1.124.2.14 diff -u -r1.124.2.14 view.php --- mod/quiz/view.php 12 Dec 2008 07:24:41 -0000 1.124.2.14 +++ mod/quiz/view.php 15 Dec 2008 08:33:44 -0000 @@ -103,7 +103,8 @@ // Print information about timings. $timenow = time(); - $available = ($quiz->timeopen < $timenow and ($timenow < $quiz->timeclose or !$quiz->timeclose)); + $available = ($quiz->timeopen < $timenow and ($timenow < $quiz->timeclose or !$quiz->timeclose)) && + has_capability('mod/quiz:attempt', $context); if ($available) { if ($quiz->timelimit) { echo "
".get_string("quiztimelimit","quiz", format_time($quiz->timelimit * 60))."
"; @@ -144,7 +145,7 @@ finish_page($course); } - if (!(has_capability('mod/quiz:attempt', $context) || has_capability('mod/quiz:preview', $context))) { + if (!has_any_capability(array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt', 'mod/quiz:preview'), $context)) { print_box('' . get_string('youneedtoenrol', 'quiz') . '
' . print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id, true) . '
', 'generalbox', 'notice'); @@ -229,9 +230,9 @@ // Add the attempt number, making it a link, if appropriate. if ($attempt->preview) { - $row[] = make_review_link(get_string('preview', 'quiz'), $quiz, $attempt); + $row[] = make_review_link(get_string('preview', 'quiz'), $quiz, $attempt, $context); } else { - $row[] = make_review_link($attempt->attempt, $quiz, $attempt); + $row[] = make_review_link($attempt->attempt, $quiz, $attempt, $context); } // prepare strings for time taken and date completed @@ -258,7 +259,7 @@ if ($markcolumn && $attempt->timefinish > 0) { if ($attemptoptions->scores) { - $row[] = make_review_link(round($attempt->sumgrades, $quiz->decimalpoints), $quiz, $attempt); + $row[] = make_review_link(round($attempt->sumgrades, $quiz->decimalpoints), $quiz, $attempt, $context); } else { $row[] = ''; } @@ -275,7 +276,7 @@ $table->rowclass[$attempt->attempt] = 'bestrow'; } - $row[] = make_review_link($formattedgrade, $quiz, $attempt); + $row[] = make_review_link($formattedgrade, $quiz, $attempt, $context); } else { $row[] = ''; } @@ -453,9 +454,13 @@ } /** Make some text into a link to review the quiz, if that is appropriate. */ -function make_review_link($linktext, $quiz, $attempt) { - // If not even responses are to be shown in review then we don't allow any review - if (!($quiz->review & QUIZ_REVIEW_RESPONSES)) { +function make_review_link($linktext, $quiz, $attempt, $context) { + static $canreview = null; + if (is_null($canreview)) { + $canreview = has_capability('mod/quiz:reviewmyattempts', $context); + } + // If not even responses are to be shown in review then we don't allow any review, or does not have review capability. + if (!$canreview || !($quiz->review & QUIZ_REVIEW_RESPONSES)) { return $linktext; } Index: mod/quiz/review.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/review.php,v retrieving revision 1.59.2.8 diff -u -r1.59.2.8 review.php --- mod/quiz/review.php 10 Dec 2008 06:22:04 -0000 1.59.2.8 +++ mod/quiz/review.php 15 Dec 2008 08:33:44 -0000 @@ -55,11 +55,17 @@ // Can't review if Student's may review ... Responses is turned on. if (!$options->responses) { if ($options->quizstate == QUIZ_STATE_IMMEDIATELY) { + // Must have review capability. + require_capability('mod/quiz:attempt', $context); $message = ''; } else if ($options->quizstate == QUIZ_STATE_OPEN && $quiz->timeclose && ($quiz->review & QUIZ_REVIEW_CLOSED & QUIZ_REVIEW_RESPONSES)) { + // Must have review capability. + require_capability('mod/quiz:reviewmyattempts', $context); $message = get_string('noreviewuntil', 'quiz', userdate($quiz->timeclose)); } else { + // Must have review capability. + require_capability('mod/quiz:reviewmyattempts', $context); $message = get_string('noreview', 'quiz'); } if (empty($popup)) { Index: mod/quiz/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/lib.php,v retrieving revision 1.282.2.17 diff -u -r1.282.2.17 lib.php --- mod/quiz/lib.php 10 Dec 2008 02:11:24 -0000 1.282.2.17 +++ mod/quiz/lib.php 15 Dec 2008 08:33:44 -0000 @@ -1106,7 +1106,7 @@ // The $quiz objects returned by get_all_instances_in_course have the necessary $cm // fields set to make the following call work. $str .= '