]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed code that relied on globals hack. Fixed bug 5261
authorgustav_delius <gustav_delius>
Thu, 20 Apr 2006 23:10:45 +0000 (23:10 +0000)
committergustav_delius <gustav_delius>
Thu, 20 Apr 2006 23:10:45 +0000 (23:10 +0000)
mod/quiz/edit.php
mod/quiz/editlib.php

index 81a7391ee5a5a89e065f183d50e5cfa140d6db70..b37c47223a37f283634c8989096dec18ce9fbba9 100644 (file)
@@ -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;
index aa007a38f984a0f5794aae2882cfad7ce172088f..ea932577a4a289d2050146cf1775731a21601241 100644 (file)
@@ -183,12 +183,12 @@ function quiz_print_question_list($quiz, $allowdelete=true, $showbreaks=true, $r
     echo "<tr><th colspan=\"3\" nowrap=\"nowrap\" class=\"header\">$strorder</th><th class=\"header\">#</th><th align=\"left\" width=\"100%\" nowrap=\"nowrap\" class=\"header\">$strquestionname</th><th nowrap=\"nowrap\" class=\"header\">$strtype</th><th nowrap=\"nowrap\" class=\"header\">$strgrade</th><th align=\"center\" width=\"60\" nowrap=\"nowrap\" class=\"header\">$straction</th></tr>\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';
         }