Index: accessrules.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/accessrules.php,v retrieving revision 1.45 diff -u -r1.45 accessrules.php --- accessrules.php 6 Aug 2010 11:41:50 -0000 1.45 +++ accessrules.php 8 Aug 2010 23:22:39 -0000 @@ -210,7 +210,11 @@ public function print_start_attempt_button($canpreview, $buttontext, $unfinished) { global $OUTPUT; - $button = new single_button($this->_quizobj->start_attempt_url(), $buttontext); + $url=clone($this->_quizobj->start_attempt_url()); + if ($canpreview) { + $url->param('previewasstudent',1); + } + $button = new single_button($url, $buttontext); $button->class .= ' quizstartbuttondiv'; if (!$unfinished) { @@ -222,7 +226,7 @@ $warning = ''; - if ($this->securewindow_required($canpreview)) { + if ($this->securewindow_required(false)) { //preview from button always require secure window to do preview as student $button->class .= ' quizsecuremoderequired'; $popupoptions = array( @@ -238,7 +242,7 @@ 'status' => false, 'menubar' => false, ); - $button->popup_action(new popup_action('click', $url, 'quizpopup', $popupoptions)); + $button->add_action(new popup_action('click', $url, 'quizpopup', $popupoptions)); $warning = html_writer::tag('noscript', $OUTPUT->heading(get_string('noscript', 'quiz'))); @@ -743,7 +747,7 @@ */ public function make_review_link($linktext, $attemptid) { global $OUTPUT; - $button = new single_button($this->_quizobj->review_url($attemptid), $linktext); + $button = new single_button(new moodle_url($this->_quizobj->review_url($attemptid)), $linktext); $button->add_action(new popup_action('click', $form->url, 'quizpopup', $this->windowoptions)); return $OUTPUT->render($button); } Index: attempt.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/attempt.php,v retrieving revision 1.187 diff -u -r1.187 attempt.php --- attempt.php 6 Aug 2010 05:49:48 -0000 1.187 +++ attempt.php 8 Aug 2010 23:16:35 -0000 @@ -26,6 +26,7 @@ /// Get submitted parameters. $attemptid = required_param('attempt', PARAM_INT); $page = optional_param('page', 0, PARAM_INT); + $previewasstudent = optional_param('previewasstudent',0,PARAM_INT); $url = new moodle_url('/mod/quiz/attempt.php', array('attempt'=>$attemptid)); if ($page !== 0) { @@ -103,7 +104,7 @@ // Print the page header $title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number()); $PAGE->set_heading($attemptobj->get_course()->fullname); - if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { + if ($accessmanager->securewindow_required($attemptobj->is_preview_user() && !$previewasstudent)) { $accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' . format_string($attemptobj->get_quiz_name()), $headtags); } elseif ($accessmanager->safebrowser_required($attemptobj->is_preview_user())) { Index: attemptlib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/attemptlib.php,v retrieving revision 1.62 diff -u -r1.62 attemptlib.php --- attemptlib.php 5 Aug 2010 18:15:17 -0000 1.62 +++ attemptlib.php 8 Aug 2010 23:15:55 -0000 @@ -64,6 +64,7 @@ protected $context; protected $questionids; // All question ids in order that they appear in the quiz. protected $pagequestionids; // array page no => array of questionids on the page in order. + protected $previewasstudent;// set to 1 if we are doing preview as student, needed to pass on another pages of this attempt // Fields set later if that data is needed. protected $questions = null; @@ -88,6 +89,7 @@ $this->context = get_context_instance(CONTEXT_MODULE, $cm->id); } $this->determine_layout(); + $this->previewasstudent = optional_param('previewasstudent',0,PARAM_INT); } /** @@ -320,15 +322,22 @@ */ public function attempt_url($attemptid) { global $CFG; - return $CFG->wwwroot . '/mod/quiz/attempt.php?attempt=' . $attemptid; + $url = $CFG->wwwroot . '/mod/quiz/attempt.php?attempt=' . $attemptid; + if ($this->previewasstudent) { + $url .= '&previewasstudent=1'; + } + return $url; } /** * @return string the URL of this quiz's edit page. Needs to be POSTed to with a cmid parameter. */ public function start_attempt_url() { - return new moodle_url('/mod/quiz/startattempt.php', - array('cmid' => $this->cm->id, 'sesskey' => sesskey())); + $urlparams = array('cmid' => $this->cm->id, 'sesskey' => sesskey()); + if ($this->previewasstudent) { + $urlparams['previewasstudent'] = 1; + } + return new moodle_url('/mod/quiz/startattempt.php', $urlparams); } /** @@ -337,7 +346,11 @@ */ public function review_url($attemptid) { global $CFG; - return $CFG->wwwroot . '/mod/quiz/review.php?attempt=' . $attemptid; + $url = $CFG->wwwroot . '/mod/quiz/review.php?attempt=' . $attemptid; + if ($this->previewasstudent) { + $url .= '&previewasstudent=1'; + } + return $url; } // Bits of content ===================================================================== @@ -730,7 +743,11 @@ */ public function summary_url() { global $CFG; - return $CFG->wwwroot . '/mod/quiz/summary.php?attempt=' . $this->attempt->id; + $url = $CFG->wwwroot . '/mod/quiz/summary.php?attempt=' . $this->attempt->id; + if ($this->previewasstudent) { + $url .= '&previewasstudent=1'; + } + return $url; } /** @@ -738,7 +755,11 @@ */ public function processattempt_url() { global $CFG; - return $CFG->wwwroot . '/mod/quiz/processattempt.php'; + $url = $CFG->wwwroot . '/mod/quiz/processattempt.php'; + if ($this->previewasstudent) { + $url .= '?previewasstudent=1'; + } + return $url; } /** @@ -781,6 +802,9 @@ global $CFG, $OUTPUT; echo $OUTPUT->container_start('controls'); $url = new moodle_url($this->start_attempt_url(), array('forcenew' => true)); + if ($this->previewasstudent) { + $url->param('previewasstudent',1); + } echo $OUTPUT->single_button($url, get_string('startagain', 'quiz')); echo $OUTPUT->container_end(); } @@ -974,6 +998,11 @@ } } + //Add previewasstudent if needed + if ($this->previewasstudent) { + $url .= '&previewasstudent=1'; + } + // Add a fragment to scroll down ot the question. if ($questionid) { if ($questionid == reset($this->pagequestionids[$page])) { Index: review.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/review.php,v retrieving revision 1.118 diff -u -r1.118 review.php --- review.php 6 Aug 2010 05:49:47 -0000 1.118 +++ review.php 8 Aug 2010 23:16:53 -0000 @@ -14,6 +14,7 @@ $attemptid = required_param('attempt', PARAM_INT); $page = optional_param('page', 0, PARAM_INT); $showall = optional_param('showall', 0, PARAM_BOOL); + $previewasstudent = optional_param('previewasstudent',0,PARAM_INT); $url = new moodle_url('/mod/quiz/review.php', array('attempt'=>$attemptid)); if ($page !== 0) { @@ -97,7 +98,7 @@ /// Print the page header $headtags = $attemptobj->get_html_head_contributions($page); - if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { + if ($accessmanager->securewindow_required($attemptobj->is_preview_user() && !$previewasstudent)) { $accessmanager->setup_secure_page($attemptobj->get_course()->shortname.': '.format_string($attemptobj->get_quiz_name()), $headtags); } elseif ($accessmanager->safebrowser_required($attemptobj->is_preview_user())) { $PAGE->set_title($attemptobj->get_course()->shortname . ': '.format_string($attemptobj->get_quiz_name())); @@ -247,7 +248,7 @@ /// Print a link to the next page. echo '