From: gustav_delius Date: Thu, 20 Apr 2006 23:10:45 +0000 (+0000) Subject: Fixed code that relied on globals hack. Fixed bug 5261 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6037288eebf3a7e383af6072282b788b497c7b96;p=moodle.git Fixed code that relied on globals hack. Fixed bug 5261 --- diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 81a7391ee5..b37c47223a 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -38,7 +38,7 @@ require_login(); - $quizid = optional_param('quizid'); + $quizid = optional_param('quizid', 0, PARAM_INT); $strquizzes = get_string('modulenameplural', 'quiz'); $strquiz = get_string('modulename', 'quiz'); @@ -120,6 +120,7 @@ if (self.name == 'editquestion') { /// Now, check for commands on this page and modify variables as necessary if (isset($_REQUEST['up']) and confirm_sesskey()) { /// Move the given question up a slot + $up = optional_param('up', 0, PARAM_INT); $questions = explode(",", $modform->questions); if ($up > 0 and isset($questions[$up])) { $prevkey = ($questions[$up-1] == 0) ? $up-2 : $up-1; @@ -138,6 +139,7 @@ if (self.name == 'editquestion') { } if (isset($_REQUEST['down']) and confirm_sesskey()) { /// Move the given question down a slot + $down = optional_param('down', 0, PARAM_INT); $questions = explode(",", $modform->questions); if ($down < count($questions)) { $nextkey = ($questions[$down+1] == 0) ? $down+2 : $down+1; diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php index aa007a38f9..ea932577a4 100644 --- a/mod/quiz/editlib.php +++ b/mod/quiz/editlib.php @@ -183,12 +183,12 @@ function quiz_print_question_list($quiz, $allowdelete=true, $showbreaks=true, $r echo "$strorder#$strquestionname$strtype$strgrade$straction\n"; foreach ($order as $i => $qnum) { - if (!$qnum or empty($questions[$qnum])) { + if ($qnum and empty($questions[$qnum])) { continue; } // If the questiontype is missing change the question type - if (!array_key_exists($questions[$qnum]->qtype, $QTYPES)) { + if ($qnum and !array_key_exists($questions[$qnum]->qtype, $QTYPES)) { $questions[$qnum]->qtype = 'missingtype'; }