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 .= '
' . quiz_num_attempt_summary($quiz, $quiz, true) . '
'; - } else if (has_capability('mod/quiz:attempt', $context)){ // Student + } else if (has_any_capability(array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), $context)) { // Student /// For student-like people, tell them how many attempts they have made. if (isset($USER->id) && ($attempts = quiz_get_user_attempts($quiz->id, $USER->id))) { $numattempts = count($attempts); Index: lang/en_utf8/quiz.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/quiz.php,v retrieving revision 1.83.2.10 diff -u -r1.83.2.10 quiz.php --- lang/en_utf8/quiz.php 15 May 2008 16:02:15 -0000 1.83.2.10 +++ lang/en_utf8/quiz.php 15 Dec 2008 08:33:43 -0000 @@ -430,6 +430,7 @@ $string['quiz:ignoretimelimits'] = 'Ignores time limit on quizzes'; $string['quiz:manage'] = 'Manage quizzes'; $string['quiz:preview'] = 'Preview quizzes'; +$string['quiz:reviewmyattempts'] = 'Review your own attempts'; $string['quiz:view'] = 'View quiz information'; $string['quiz:viewreports'] = 'View quiz reports'; $string['quizavailable'] = 'The quiz is available until: $a'; Index: mod/quiz/report/overview/report.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/report/overview/report.php,v retrieving revision 1.98.2.45 diff -u -r1.98.2.45 report.php --- mod/quiz/report/overview/report.php 10 Nov 2008 02:43:35 -0000 1.98.2.45 +++ mod/quiz/report/overview/report.php 15 Dec 2008 08:33:45 -0000 @@ -119,7 +119,7 @@ } } $nostudents = false; - if (!$students = get_users_by_capability($context, 'mod/quiz:attempt','','','','','','',false)){ + if (!$students = get_users_by_capability($context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),'','','','','','',false)){ notify(get_string('nostudentsyet')); $nostudents = true; $studentslist = ''; Index: mod/quiz/report/overview/overviewgraph.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/report/overview/overviewgraph.php,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 overviewgraph.php --- mod/quiz/report/overview/overviewgraph.php 19 Jun 2008 12:31:29 -0000 1.1.2.5 +++ mod/quiz/report/overview/overviewgraph.php 15 Dec 2008 08:33:45 -0000 @@ -87,7 +87,7 @@ $line->y_order = array('allusers'); if ($groups){ foreach (array_keys($groups) as $group){ - $useridingroup = get_users_by_capability($modcontext, 'mod/quiz:attempt','','','','',$group,'',false); + $useridingroup = get_users_by_capability($modcontext, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),'','','','',$group,'',false); if ($useridingroup){ $useridingrouplist = join(',',array_keys($useridingroup)); $groupdata = quiz_report_grade_bands($bandwidth, $bands, $quizid, $useridingrouplist); Index: mod/quiz/report/grading/report.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/report/grading/report.php,v retrieving revision 1.25.2.16 diff -u -r1.25.2.16 report.php --- mod/quiz/report/grading/report.php 12 Dec 2008 09:00:03 -0000 1.25.2.16 +++ mod/quiz/report/grading/report.php 15 Dec 2008 08:33:45 -0000 @@ -83,8 +83,8 @@ } $currentgroup = groups_get_activity_group($this->cm, true); - $this->users = get_users_by_capability($this->context, 'mod/quiz:attempt','','','','',$currentgroup,'',false); - $this->userids = implode(',', array_keys($this->users)); + $this->users = get_users_by_capability($this->context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),'','','','',$currentgroup,'',false); + $this->userids = implode(',', array_keys($this->users)); if (!empty($questionid)) { Index: mod/quiz/db/access.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/db/access.php,v retrieving revision 1.8.2.1 diff -u -r1.8.2.1 access.php --- mod/quiz/db/access.php 13 Aug 2008 07:05:58 -0000 1.8.2.1 +++ mod/quiz/db/access.php 15 Dec 2008 08:33:44 -0000 @@ -22,6 +22,7 @@ // Ability to do the quiz as a 'student'. 'mod/quiz:attempt' => array( + 'riskbitmask' => RISK_SPAM, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( @@ -29,6 +30,17 @@ ) ), + // Ability for a 'Student' to review their previous attempts. Review by + // 'Teachers' is controlled by mod/quiz:viewreports. + 'mod/quiz:reviewmyattempts' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_MODULE, + 'legacy' => array( + 'student' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/quiz:attempt' + ), + // Edit the quiz settings, add and remove questions. 'mod/quiz:manage' => array( 'riskbitmask' => RISK_SPAM,