]> git.mjollnir.org Git - moodle.git/commitdiff
Missingtype now also works without notices when the missing question has no answers.
authorgustav_delius <gustav_delius>
Sun, 30 Apr 2006 17:30:22 +0000 (17:30 +0000)
committergustav_delius <gustav_delius>
Sun, 30 Apr 2006 17:30:22 +0000 (17:30 +0000)
question/type/missingtype/display.html
question/type/missingtype/questiontype.php

index 31e01f590743730d2c3aefd92da0812c97245d64..e4ebf658935086c9e07e8f90a2381980deed7ef5 100644 (file)
@@ -1,4 +1,3 @@
-<?php notify('This question is of a type that has not been installed on your Moodle yet.<br />Please alert your Moodle administrator.'); ?>
 <div class="qtext">
   <?php echo $questiontext; ?>
 </div>
@@ -7,18 +6,19 @@
   <img class="qimage" src="<?php echo $image; ?>" alt="" />
 <?php } ?>
 
-<div class="ablock clearfix">
-  <div class="prompt">
-    <?php print_string('answers', 'quiz'); ?>
+<?php if ($anss) { ?>
+  <div class="ablock clearfix">
+    <div class="prompt">
+      <?php print_string('answers', 'quiz'); ?>
+    </div>
+    <table class="answer">
+      <?php $row = 1; foreach ($anss as $answer) { ?>
+        <tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>">
+          <td class="c1 text">
+            <?php echo $answer->text; ?>
+          </td>
+        </tr>
+      <?php } ?>
+    </table>
   </div>
-
-  <table class="answer">
-    <?php $row = 1; foreach ($anss as $answer) { ?>
-      <tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>">
-        <td class="c1 text">
-          <?php echo $answer->text; ?>
-        </td>
-      </tr>
-    <?php } ?>
-  </table>
-</div>
+<?php } ?>
\ No newline at end of file
index f759bbd6e291b9046daac422dadb293dffb30a1e..45764e2d7e3925c2550ee938cb102463c9566715 100644 (file)
@@ -34,11 +34,14 @@ class question_missingtype_qtype extends default_questiontype {
                          $formatoptions, $cmoptions->course);
         $image = get_question_image($question, $cmoptions->course);
 
-        // Print each answer in a separate row
-        foreach ($answers as $answer) {
-            $a->text = format_text("$answer->answer", FORMAT_MOODLE, $formatoptions, $cmoptions->course);
-
-            $anss[] = clone($a);
+        // Print each answer in a separate row if there are any
+        $anss = array();
+        if ($answers) {
+            foreach ($answers as $answer) {
+                $a->text = format_text("$answer->answer", FORMAT_MOODLE, $formatoptions, $cmoptions->course);
+    
+                $anss[] = clone($a);
+            }
         }
         include("$CFG->dirroot/question/type/missingtype/display.html");
     }