Index: attempt.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/attempt.php,v retrieving revision 1.131.2.17 diff -u -r1.131.2.17 attempt.php --- attempt.php 30 Sep 2009 10:58:03 -0000 1.131.2.17 +++ attempt.php 3 Dec 2009 18:50:05 -0000 @@ -25,6 +25,7 @@ $finishattempt = optional_param('finishattempt', 0, PARAM_BOOL); $timeup = optional_param('timeup', 0, PARAM_BOOL); // True if form was submitted by timer. $forcenew = optional_param('forcenew', false, PARAM_BOOL); // Teacher has requested new preview + $previewasstudent = optional_param('previewasstudent', 0, PARAM_BOOL); // Teacher has requested preview as student if ($id) { if (! $cm = get_coursemodule_from_id('quiz', $id)) { @@ -77,7 +78,7 @@ $strattemptnum = get_string('attempt', 'quiz', $attemptnumber); $strquizzes = get_string("modulenameplural", "quiz"); - $popup = $quiz->popup && !$ispreviewing; // Controls whether this is shown in a javascript-protected window or with a safe browser. + $popup = $quiz->popup && (!$ispreviewing || $previewasstudent); // Controls whether this is shown in a javascript-protected window or with a safe browser. /// We intentionally do not check open and close times here. Instead we do it lower down. /// This is to deal with what happens when someone submits close to the exact moment when the quiz closes. @@ -417,7 +418,7 @@ require_js($CFG->wwwroot . '/mod/quiz/quiz.js'); $pagequestions = explode(',', $pagelist); $headtags = get_html_head_contributions($pagequestions, $questions, $states); - if (!$ispreviewing && $quiz->popup) { + if ($popup) { define('MESSAGE_WINDOW', true); // This prevents the message window coming up print_header($course->shortname.': '.format_string($quiz->name), '', '', '', $headtags, false, '', '', false, ' class="securewindow"'); if ($quiz->popup == 1) { @@ -434,7 +435,7 @@ echo ''; // for overlib // Print the quiz name heading and tabs for teacher, etc. - if ($ispreviewing) { + if ($ispreviewing && !$previewasstudent) { $currenttab = 'preview'; include('tabs.php'); @@ -468,7 +469,7 @@ // Start the form $quiz->thispageurl = $CFG->wwwroot . '/mod/quiz/attempt.php?q=' . s($quiz->id) . '&page=' . s($page); $quiz->cmid = $cm->id; - echo '
', "\n"; if($quiz->timelimit > 0) { // Make sure javascript is enabled for time limited quizzes Index: review.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/review.php,v retrieving revision 1.59.2.11 diff -u -r1.59.2.11 review.php --- review.php 30 Sep 2009 10:58:03 -0000 1.59.2.11 +++ review.php 3 Dec 2009 06:33:29 -0000 @@ -38,7 +38,7 @@ require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); $coursecontext = get_context_instance(CONTEXT_COURSE, $cm->course); - $isteacher = has_capability('mod/quiz:preview', get_context_instance(CONTEXT_MODULE, $cm->id)); + $isteacher = has_capability('mod/quiz:preview', $context); $options = quiz_get_reviewoptions($quiz, $attempt, $context); $popup = $isteacher ? 0 : $quiz->popup; // Controls whether this is shown in a javascript-protected window or with a safe browser. @@ -127,7 +127,7 @@ if (!$ispreviewing && $quiz->popup) { define('MESSAGE_WINDOW', true); // This prevents the message window coming up print_header($course->shortname.': '.format_string($quiz->name), '', '', '', $headtags, false, '', '', false, ''); - if ($quiz->popup == 1) { + if ($quiz->popup == 1 && !has_capability('mod/quiz:preview', $context)) { include('protect_js.php'); } } else { Index: view.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/view.php,v retrieving revision 1.124.2.19 diff -u -r1.124.2.19 view.php --- view.php 30 Sep 2009 10:58:04 -0000 1.124.2.19 +++ view.php 3 Dec 2009 07:46:12 -0000 @@ -403,7 +403,9 @@ } // Determine the URL to use. $attempturl = "attempt.php?id=$cm->id"; - + if (has_capability('mod/quiz:preview', $context)) { + $attempturl .= '&previewasstudent=1'; + } // Prepare options depending on whether the quiz should be a popup. if ($quiz->popup == 1) { $window = 'quizpopup';