Index: mod/quiz/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 --- mod/quiz/view.php 30 Sep 2009 10:58:04 -0000 1.124.2.19 +++ mod/quiz/view.php 5 Aug 2010 14:35:39 -0000 @@ -403,7 +403,11 @@ } // Determine the URL to use. $attempturl = "attempt.php?id=$cm->id"; - + $buttonparams = array('id'=>$cm->id); + if (has_capability('mod/quiz:preview', $context)) { + $attempturl .= '&previewasstudent=1'; + $buttonparams['previewasstudent'] = 1; + } // Prepare options depending on whether the quiz should be a popup. if ($quiz->popup == 1) { $window = 'quizpopup'; @@ -424,7 +428,7 @@ } else if ($quiz->popup == 2 && !quiz_check_safe_browser()) { notify(get_string('safebrowsererror', 'quiz')); }else { - print_single_button("attempt.php", array('id'=>$cm->id), $buttontext, 'get', '', false, '', false, $strconfirmstartattempt); + print_single_button('attempt.php', $buttonparams, $buttontext, 'get', '', false, '', false, $strconfirmstartattempt); } Index: mod/quiz/attempt.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/attempt.php,v retrieving revision 1.131.2.18 diff -u -r1.131.2.18 attempt.php --- mod/quiz/attempt.php 5 Jul 2010 21:55:25 -0000 1.131.2.18 +++ mod/quiz/attempt.php 5 Aug 2010 14:35:39 -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', false, PARAM_BOOL); // Teacher has requested preview as student if ($id) { if (! $cm = get_coursemodule_from_id('quiz', $id)) { @@ -58,6 +59,9 @@ $coursecontext = get_context_instance(CONTEXT_COURSE, $cm->course); // course context $context = get_context_instance(CONTEXT_MODULE, $cm->id); $ispreviewing = has_capability('mod/quiz:preview', $context); + if (!$ispreviewing) { + $previewasstudent = false; + } // if no questions have been set up yet redirect to edit.php if (!$quiz->questions and has_capability('mod/quiz:manage', $context)) { @@ -77,7 +81,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 +421,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 +438,7 @@ echo ''; // for overlib // Print the quiz name heading and tabs for teacher, etc. - if ($ispreviewing) { + if ($ispreviewing && !$previewasstudent) { $currenttab = 'preview'; include('tabs.php'); @@ -467,6 +471,9 @@ // Start the form $quiz->thispageurl = $CFG->wwwroot . '/mod/quiz/attempt.php?q=' . s($quiz->id) . '&page=' . s($page); + if ($previewasstudent) { + $quiz->thispageurl .= '&previewasstudent=1'; + } $quiz->cmid = $cm->id; echo '
', "\n"; Index: mod/quiz/review.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/review.php,v retrieving revision 1.59.2.12 diff -u -r1.59.2.12 review.php --- mod/quiz/review.php 4 Nov 2009 14:07:13 -0000 1.59.2.12 +++ mod/quiz/review.php 5 Aug 2010 14:35:39 -0000 @@ -127,7 +127,7 @@ if (!$isteacher && $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 && !$isteacher) { include('protect_js.php'); } } else {