From 3a4a9233ce4f8d34a76158d9be78458f3eb3d08f Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Tue, 4 Sep 2007 05:44:14 +0000 Subject: [PATCH] fix for some problems with page params --- question/preview.php | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/question/preview.php b/question/preview.php index 3c8db1f6a2..2076a5fa84 100644 --- a/question/preview.php +++ b/question/preview.php @@ -43,21 +43,20 @@ $continue = false; } - - + $url = new moodle_url($CFG->wwwroot . '/question/preview.php'); + $url->param('id', $id); + if ($quizid) { + $url->param('quizid', $quizid); + } else { + $url->param('courseid', $courseid); + } + $url->param('continue', 1); if (!$continue) { // Start a new attempt; delete the old session unset($SESSION->quizpreview); // Redirect to ourselves but with continue=1; prevents refreshing the page // from restarting an attempt (needed so that random questions don't change) - $url = $CFG->wwwroot . '/question/preview.php?id=' . $id; - if ($quizid) { - $url .= '&quizid=' . $quizid; - } else { - $url .= '&courseid=' . $courseid; - } - $url .= '&continue=1'; - redirect($url); + redirect($url->out()); } // Load the question information if (!$questions = get_records('question', 'id', $id)) { @@ -119,8 +118,7 @@ // Restore the history of question sessions from the moodle session or create // new sessions. Make $states a reference to the states array in the moodle // session. - if (isset($SESSION->quizpreview->states) and $SESSION->quizpreview->questionid - == $id) { + if (isset($SESSION->quizpreview->states) and $SESSION->quizpreview->questionid == $id) { // Reload the question session history from the moodle session $states =& $SESSION->quizpreview->states; $historylength = count($states) - 1; @@ -200,17 +198,14 @@ echo "

\n"; } $number = 1; - echo '
', "\n"; + echo '', "\n"; print_question($questions[$id], $curstate, $number, $quiz, $options); echo '
'; echo '
'; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo $url->hidden_params_out(); // Print the mark and finish attempt buttons echo '