Index: accessrules.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/accessrules.php,v retrieving revision 1.48 diff -u -r1.48 accessrules.php --- accessrules.php 11 Aug 2010 20:25:32 -0000 1.48 +++ accessrules.php 12 Aug 2010 16:34:57 -0000 @@ -210,7 +210,10 @@ public function print_start_attempt_button($canpreview, $buttontext, $unfinished) { global $OUTPUT; - $url = $this->_quizobj->start_attempt_url(); + $url=clone($this->_quizobj->start_attempt_url()); + if ($canpreview) { + $url->param('previewasstudent',1); + } $button = new single_button($url, $buttontext); $button->class .= ' quizstartbuttondiv'; @@ -223,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'; $button->add_action(new popup_action('click', $url, 'quizpopup', Index: attempt.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/attempt.php,v retrieving revision 1.189 diff -u -r1.189 attempt.php --- attempt.php 11 Aug 2010 20:15:18 -0000 1.189 +++ attempt.php 12 Aug 2010 16:08:08 -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())); } else if ($accessmanager->safebrowser_required($attemptobj->is_preview_user())) { Index: attemptlib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/attemptlib.php,v retrieving revision 1.67 diff -u -r1.67 attemptlib.php --- attemptlib.php 11 Aug 2010 17:20:05 -0000 1.67 +++ attemptlib.php 12 Aug 2010 16:37:47 -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); } /** @@ -324,15 +326,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); } /** @@ -340,7 +349,11 @@ * @return string the URL of the review of that attempt. */ public function review_url($attemptid) { - return new moodle_url('/quiz/review.php', array('attempt' => $attemptid)); + $url = new moodle_url('/quiz/review.php', array('attempt' => $attemptid)); + if ($this->previewasstudent) { + $url->param('previewasstudent',1); + } + return $url; } // Bits of content ===================================================================== @@ -734,7 +747,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; } /** @@ -742,7 +759,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; } /** @@ -785,6 +806,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(); } @@ -992,6 +1016,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.119 diff -u -r1.119 review.php --- review.php 10 Aug 2010 09:56:50 -0000 1.119 +++ review.php 12 Aug 2010 16:08:08 -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 '
'; if ($lastpage) { - $accessmanager->print_finish_review_link($attemptobj->is_preview_user()); + $accessmanager->print_finish_review_link($attemptobj->is_preview_user() && !$previewasstudent); } else { echo link_arrow_right(get_string('next'), s($attemptobj->review_url(0, $page + 1))); }