]> git.mjollnir.org Git - moodle.git/commitdiff
XHTML Strrrrrrict! on quiz module config page.
authortjhunt <tjhunt>
Wed, 28 Feb 2007 12:24:54 +0000 (12:24 +0000)
committertjhunt <tjhunt>
Wed, 28 Feb 2007 12:24:54 +0000 (12:24 +0000)
Fix errors when config changes are saved.

Merged from MOODLE_18_STABLE.

mod/quiz/config.html
mod/quiz/lib.php

index 29f61bc4a907eaa39748ea628982b85b91853b04..d5a10190013d9587b411ca0abc0af23bc7057c1d 100644 (file)
@@ -88,7 +88,6 @@
 </script>
 
 <form method="post" action="module.php" id="form">
-<fieldset class="invisiblefieldset">
 <input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
 
 <!-- Table of default values -->
     </td>
   <td align="center">
     <input type="hidden" name="fix_timelimit" value="0" />
-    <input type="checkbox" name="fix_timelimit" value="1" <?php p($CFG->quiz_fix_timelimit ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_timelimit" value="1" <?php echo $CFG->quiz_fix_timelimit ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
     </td>
   <td align="center">
     <input type="hidden" name="fix_questionsperpage" value="0" />
-    <input type="checkbox" name="fix_questionsperpage" value="1" <?php p($CFG->quiz_fix_questionsperpage ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_questionsperpage" value="1" <?php echo $CFG->quiz_fix_questionsperpage ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
   </td>
   <td align="center">
     <input type="hidden" name="fix_shufflequestions" value="0" />
-    <input type="checkbox" name="fix_shufflequestions" value="1" <?php p($CFG->quiz_fix_shufflequestions ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_shufflequestions" value="1" <?php echo $CFG->quiz_fix_shufflequestions ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
   </td>
   <td align="center">
     <input type="hidden" name="fix_shuffleanswers" value="0" />
-    <input type="checkbox" name="fix_shuffleanswers" value="1" <?php p($CFG->quiz_fix_shuffleanswers ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_shuffleanswers" value="1" <?php echo $CFG->quiz_fix_shuffleanswers ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
   </td>
   <td align="center">
     <input type="hidden" name="fix_attempts" value="0" />
-    <input type="checkbox" name="fix_attempts" value="1" <?php p($CFG->quiz_fix_attempts ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_attempts" value="1" <?php echo $CFG->quiz_fix_attempts ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
   </td>
   <td align="center">
     <input type="hidden" name="fix_attemptonlast" value="0" />
-    <input type="checkbox" name="fix_attemptonlast" value="1" <?php p($CFG->quiz_fix_attemptonlast ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_attemptonlast" value="1" <?php echo $CFG->quiz_fix_attemptonlast ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
   </td>
   <td align="center">
     <input type="hidden" name="fix_grademethod" value="0" />
-    <input type="checkbox" name="fix_grademethod" value="1" <?php p($CFG->quiz_fix_grademethod ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_grademethod" value="1" <?php echo $CFG->quiz_fix_grademethod ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
   </td>
   <td align="center">
     <input type="hidden" name="fix_adaptive" value="0" />
-    <input type="checkbox" name="fix_adaptive" value="1" <?php p($CFG->quiz_fix_adaptive ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_adaptive" value="1" <?php echo $CFG->quiz_fix_adaptive ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
   </td>
   <td align="center">
     <input type="hidden" name="fix_penaltyscheme" value="0" />
-    <input type="checkbox" name="fix_penaltyscheme" value="1" <?php p($CFG->quiz_fix_penaltyscheme ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_penaltyscheme" value="1" <?php echo $CFG->quiz_fix_penaltyscheme ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
   </td>
   <td align="center">
     <input type="hidden" name="fix_decimalpoints" value="0" />
-    <input type="checkbox" name="fix_decimalpoints" value="1" <?php p($CFG->quiz_fix_decimalpoints ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_decimalpoints" value="1" <?php echo $CFG->quiz_fix_decimalpoints ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
   <?php include($CFG->dirroot . '/mod/quiz/reviewoptions.html'); ?>
   <td align="center">
     <input type="hidden" name="fix_review" value="0" />
-    <input type="checkbox" name="fix_review" value="1" <?php p($CFG->quiz_fix_review ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_review" value="1" <?php echo $CFG->quiz_fix_review ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
   </td>
   <td align="center">
     <input type="hidden" name="fix_popup" value="0" />
-    <input type="checkbox" name="fix_popup" value="1" <?php p($CFG->quiz_fix_popup ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_popup" value="1" <?php echo $CFG->quiz_fix_popup ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
     </td>
     <td align="center">
         <input type="hidden" name="fix_delay1" value="0" />
-        <input type="checkbox" name="fix_delay1" value="1" <?php p($CFG->quiz_fix_delay1 ? "checked" : "") ?> />
+        <input type="checkbox" name="fix_delay1" value="1" <?php echo $CFG->quiz_fix_delay1 ? 'checked="checked"' : ''; ?> />
     </td>
 </tr>
 
     </td>
     <td align="center">
          <input type="hidden" name="fix_delay2" value="0" />
-         <input type="checkbox" name="fix_delay2" value="1" <?php p($CFG->quiz_fix_delay2 ? "checked" : "") ?> />        
+         <input type="checkbox" name="fix_delay2" value="1" <?php echo $CFG->quiz_fix_delay2 ? 'checked="checked"' : ''; ?> />        
     </td>
 </tr>
 
   </td>
   <td align="center">
     <input type="hidden" name="fix_password" value="0" />
-    <input type="checkbox" name="fix_password" value="1" <?php p($CFG->quiz_fix_password ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_password" value="1" <?php echo $CFG->quiz_fix_password ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
   </td>
   <td align="center">
     <input type="hidden" name="fix_subnet" value="0" />
-    <input type="checkbox" name="fix_subnet" value="1" <?php p($CFG->quiz_fix_subnet ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_subnet" value="1" <?php echo $CFG->quiz_fix_subnet ? 'checked="checked"' : ''; ?> />
   </td>
 </tr>
 
 <!-- Can't hide this setting, it always shows up on edit.php
   <td align="center">
     <input type="hidden" name="fix_maximumgrade" value="0" />
-    <input type="checkbox" name="fix_maximumgrade" value="1" <?php p($CFG->quiz_fix_maximumgrade ? "checked" : "") ?> />
+    <input type="checkbox" name="fix_maximumgrade" value="1" <?php echo $CFG->quiz_fix_maximumgrade ? 'checked="checked"' : ''; ?> />
   </td>
 -->
 </tr>
 
 </table>
 
-</fieldset>
 </form>
 
 <script type="text/javascript">
index 3015effca6e1229bd57fbaca6b5606d5990d695f..f9aba2922b697d89cfba9c22c829da87d96ad014 100644 (file)
@@ -457,7 +457,8 @@ function quiz_print_recent_mod_activity($activity, $course, $detail=false) {
 
 /**
  * Pre-process the quiz options form data, making any necessary adjustments.
- *
+ * Called by add/update instance in this file, and the save code in admin/module.php.
+ * 
  * @param object $quiz The variables set on the form.
  */
 function quiz_process_options(&$quiz) {
@@ -485,55 +486,56 @@ function quiz_process_options(&$quiz) {
     $quiz->timelimit = round($quiz->timelimit);
 
     // Quiz feedback
-
-    // Clean up the boundary text.
-    for ($i = 0; $i < count($quiz->feedbacktext); $i += 1) {
-        if (empty($quiz->feedbacktext[$i])) {
-            $quiz->feedbacktext[$i] = '';
-        } else {
-            $quiz->feedbacktext[$i] = trim($quiz->feedbacktext[$i]);
+    if (isset($quiz->feedbacktext)) {
+        // Clean up the boundary text.
+        for ($i = 0; $i < count($quiz->feedbacktext); $i += 1) {
+            if (empty($quiz->feedbacktext[$i])) {
+                $quiz->feedbacktext[$i] = '';
+            } else {
+                $quiz->feedbacktext[$i] = trim($quiz->feedbacktext[$i]);
+            }
         }
-    }
-
-    // Check the boundary value is a number or a percentage, and in range.
-    $i = 0;
-    while (!empty($quiz->feedbackboundaries[$i])) {
-        $boundary = trim($quiz->feedbackboundaries[$i]);
-        if (!is_numeric($boundary)) {
-            if (strlen($boundary) > 0 && $boundary[strlen($boundary) - 1] == '%') {
-                $boundary = trim(substr($boundary, 0, -1));
-                if (is_numeric($boundary)) {
-                    $boundary = $boundary * $quiz->grade / 100.0;
-                } else {
-                    return get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
+    
+        // Check the boundary value is a number or a percentage, and in range.
+        $i = 0;
+        while (!empty($quiz->feedbackboundaries[$i])) {
+            $boundary = trim($quiz->feedbackboundaries[$i]);
+            if (!is_numeric($boundary)) {
+                if (strlen($boundary) > 0 && $boundary[strlen($boundary) - 1] == '%') {
+                    $boundary = trim(substr($boundary, 0, -1));
+                    if (is_numeric($boundary)) {
+                        $boundary = $boundary * $quiz->grade / 100.0;
+                    } else {
+                        return get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
+                    }
                 }
             }
+            if ($boundary <= 0 || $boundary >= $quiz->grade) {
+                return get_string('feedbackerrorboundaryoutofrange', 'quiz', $i + 1);
+            }
+            if ($i > 0 && $boundary >= $quiz->feedbackboundaries[$i - 1]) {
+                return get_string('feedbackerrororder', 'quiz', $i + 1);
+            }
+            $quiz->feedbackboundaries[$i] = $boundary;
+            $i += 1;
         }
-        if ($boundary <= 0 || $boundary >= $quiz->grade) {
-            return get_string('feedbackerrorboundaryoutofrange', 'quiz', $i + 1);
-        }
-        if ($i > 0 && $boundary >= $quiz->feedbackboundaries[$i - 1]) {
-            return get_string('feedbackerrororder', 'quiz', $i + 1);
-        }
-        $quiz->feedbackboundaries[$i] = $boundary;
-        $i += 1;
-    }
-    $numboundaries = $i;
-
-    // Check there is nothing in the remaining unused fields.
-    for ($i = $numboundaries; $i < count($quiz->feedbackboundaries); $i += 1) {
-        if (!empty($quiz->feedbackboundaries[$i]) && trim($quiz->feedbackboundaries[$i]) != '') {
-            return get_string('feedbackerrorjunkinboundary', 'quiz', $i + 1);
+        $numboundaries = $i;
+    
+        // Check there is nothing in the remaining unused fields.
+        for ($i = $numboundaries; $i < count($quiz->feedbackboundaries); $i += 1) {
+            if (!empty($quiz->feedbackboundaries[$i]) && trim($quiz->feedbackboundaries[$i]) != '') {
+                return get_string('feedbackerrorjunkinboundary', 'quiz', $i + 1);
+            }
         }
-    }
-    for ($i = $numboundaries + 1; $i < count($quiz->feedbacktext); $i += 1) {
-        if (!empty($quiz->feedbacktext[$i]) && trim($quiz->feedbacktext[$i]) != '') {
-            return get_string('feedbackerrorjunkinfeedback', 'quiz', $i + 1);
+        for ($i = $numboundaries + 1; $i < count($quiz->feedbacktext); $i += 1) {
+            if (!empty($quiz->feedbacktext[$i]) && trim($quiz->feedbacktext[$i]) != '') {
+                return get_string('feedbackerrorjunkinfeedback', 'quiz', $i + 1);
+            }
         }
+        $quiz->feedbackboundaries[-1] = $quiz->grade + 1; // Needs to be bigger than $quiz->grade because of '<' test in quiz_feedback_for_grade().
+        $quiz->feedbackboundaries[$numboundaries] = 0;
+        $quiz->feedbackboundarycount = $numboundaries;
     }
-    $quiz->feedbackboundaries[-1] = $quiz->grade + 1; // Needs to be bigger than $quiz->grade because of '<' test in quiz_feedback_for_grade().
-    $quiz->feedbackboundaries[$numboundaries] = 0;
-    $quiz->feedbackboundarycount = $numboundaries;
 
     // Settings that get combined to go into the optionflags column.
     $quiz->optionflags = 0;