]> git.mjollnir.org Git - moodle.git/commitdiff
Quiz questions now have proper formatting controls.
authormoodler <moodler>
Fri, 13 Feb 2004 14:01:27 +0000 (14:01 +0000)
committermoodler <moodler>
Fri, 13 Feb 2004 14:01:27 +0000 (14:01 +0000)
Any format can be used.  This fixes a number of problems at once,
but the latest one is Bug #1047

14 files changed:
mod/quiz/db/mysql.php
mod/quiz/db/mysql.sql
mod/quiz/db/postgres7.php
mod/quiz/db/postgres7.sql
mod/quiz/description.html
mod/quiz/lib.php
mod/quiz/match.html
mod/quiz/multichoice.html
mod/quiz/numerical.html
mod/quiz/question.php
mod/quiz/randomsamatch.html
mod/quiz/shortanswer.html
mod/quiz/truefalse.html
mod/quiz/version.php

index a0819761105cc75c3a03713d85e770687812700b..3acd83986cb336df8886b5ae7b47d97ce46786f5 100644 (file)
@@ -181,6 +181,10 @@ function quiz_upgrade($oldversion) {
         }
     }
 
+    if ($oldversion < 2004021300) {
+        table_column("quiz_questions", "", "questiontextformat", "integer", "2", "", "0", "not null", "questiontext");
+    }
+
 
     return true;
 }
index 664bd7a2db309a0982797ff78bd0b9727745b9de..5d7b6ca88a6eed11cebc5c7c8c8504f64b379551 100644 (file)
@@ -168,6 +168,7 @@ CREATE TABLE `prefix_quiz_questions` (
   `category` int(10) NOT NULL default '0',
   `name` varchar(255) NOT NULL default '',
   `questiontext` text NOT NULL,
+  `questiontextformat` tinyint(2) NOT NULL default '0',
   `image` varchar(255) NOT NULL default '',
   `defaultgrade` INT UNSIGNED DEFAULT '1' NOT NULL,
   `qtype` smallint(6) NOT NULL default '0',
index 6997247cd0857f588c8fc99e7fe6f27e46a5fdac..7a51e5baa9e23f5f4467dfba069fe0314acd8741 100644 (file)
@@ -136,6 +136,10 @@ function quiz_upgrade($oldversion) {
         }
     }
 
+    if ($oldversion < 2004021300) {
+        table_column("quiz_questions", "", "questiontextformat", "integer", "2", "", "0", "not null", "questiontext");
+    }
+
     return true;
 }
 
index b83cbd122d6d4575c02536e1d4de3e0850fd6e2f..4a065901276fd162a71a5e4bb5cd6f21dd386890 100644 (file)
@@ -181,6 +181,7 @@ CREATE TABLE prefix_quiz_questions (
   category integer NOT NULL default '0',
   name varchar(255) NOT NULL default '',
   questiontext text NOT NULL default '',
+  questiontextformat integer NOT NULL default '0',
   image varchar(255) NOT NULL default '',
   defaultgrade integer NOT NULL default '1',
   qtype integer NOT NULL default '0',
index 050d12f32142ef184c4b59afd791044bcfc208cf..5e1382d0452d9984456c895a83c6807cbc82f487 100644 (file)
         <?php  if (isset($err["name"])) formerr($err["name"]); ?>\r
     </TD>\r
 </TR>\r
-<TR valign=top>\r
-    <TD align=right><P><B><?php  print_string("question", "quiz") ?>:</B></P></TD>\r
-    <TD>\r
+<tr valign=top>\r
+    <td align="right"><p><b><?php  print_string("question", "quiz") ?>:</b></p>\r
+    <br />\r
+    <br />\r
+    <br />\r
+    <p><font SIZE="1">\r
+    <?php\r
+           if ($usehtmleditor) {\r
+               helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);\r
+           } else {\r
+               helpbutton("text", get_string("helptext"), "moodle", true, true);\r
+           }\r
+    ?>\r
+    </font></p>\r
+    </td>\r
+    <td>\r
         <?php  if (isset($err["questiontext"])) {\r
                formerr($err["questiontext"]); \r
-               echo "<BR />";\r
+               echo "<br />";\r
            }\r
+\r
            print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);\r
-           if ($usehtmleditor) {\r
-               helpbutton("richtext", get_string("helprichtext"), "moodle");\r
+\r
+           if ($usehtmleditor) {   /// Trying this out for a while\r
+               echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'">';\r
            } else {\r
-               helpbutton("text", get_string("helptext"), "moodle");\r
+               echo "<div align=right>";\r
+               print_string("formattexttype");\r
+               echo ":&nbsp;";\r
+               if (!$question->questiontextformat) {\r
+                   $question->questiontextformat = FORMAT_MOODLE;\r
+               }\r
+               choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");\r
+               helpbutton("textformat", get_string("helpformatting"));\r
+               echo "</div>";\r
            }\r
         ?>\r
-    </TD>\r
-</TR>\r
+    </td>\r
+</tr>\r
 <TR valign=top>\r
     <TD align=right><P><B><?php  print_string("imagedisplay", "quiz") ?>:</B></P></TD>\r
     <TD>\r
index a97679abb082f550aa98996d0cab6b83f86aa5f0..8be5f2c2eb1e9bd4d2486aee375b53593f3aa603 100644 (file)
@@ -515,7 +515,7 @@ function quiz_print_question($number, $question, $grade, $quizid,
 
     if ($question->qtype == DESCRIPTION) {  // Special case question - has no answers etc
         echo '<p align="center">';
-        echo format_text($question->questiontext, FORMAT_HTML, NULL, $courseid);
+        echo format_text($question->questiontext, $question->questiontextformat, NULL, $courseid);
         quiz_print_possible_question_image($quizid, $question);
         echo '</p>';
         return true;
@@ -563,7 +563,7 @@ function quiz_print_question($number, $question, $grade, $quizid,
 
        case SHORTANSWER: 
        case NUMERICAL:
-           echo format_text($question->questiontext, FORMAT_HTML, NULL, $courseid);
+           echo format_text($question->questiontext, $question->questiontextformat, NULL, $courseid);
            quiz_print_possible_question_image($quizid, $question);
            if ($response) {
                $value = "value=\"$response[0]\"";
@@ -596,7 +596,7 @@ function quiz_print_question($number, $question, $grade, $quizid,
            if (!$false->answer) {
                $false->answer = get_string("false", "quiz");
            }
-           echo format_text($question->questiontext, FORMAT_HTML, NULL, $courseid);
+           echo format_text($question->questiontext, $question->questiontextformat, NULL, $courseid);
            quiz_print_possible_question_image($quizid, $question);
 
            $truechecked = "";
@@ -639,7 +639,7 @@ function quiz_print_question($number, $question, $grade, $quizid,
            if (!$answers = get_records_list("quiz_answers", "id", $options->answers)) {
                notify("Error: Missing question answers!");
            }
-           echo format_text($question->questiontext, FORMAT_HTML, NULL, $courseid);
+           echo format_text($question->questiontext, $question->questiontextformat, NULL, $courseid);
            quiz_print_possible_question_image($quizid, $question);
            echo "<table align=\"right\">";
            echo "<tr><td valign=\"top\">$stranswer:&nbsp;&nbsp;</td><td>";
@@ -692,7 +692,7 @@ function quiz_print_question($number, $question, $grade, $quizid,
                notify("Error: Missing subquestions for this question!");
            }
            if (!empty($question->questiontext)) {
-               echo format_text($question->questiontext, FORMAT_HTML, NULL, $courseid);
+               echo format_text($question->questiontext, $question->questiontextformat, NULL, $courseid);
            }
            quiz_print_possible_question_image($quizid, $question);
 
@@ -741,7 +741,7 @@ function quiz_print_question($number, $question, $grade, $quizid,
            if (!$options = get_record("quiz_randomsamatch", "question", $question->id)) {
                notify("Error: Missing question options!");
            }
-           echo format_text($question->questiontext, FORMAT_HTML, NULL, $courseid);
+           echo format_text($question->questiontext, $question->questiontextformat, NULL, $courseid);
            quiz_print_possible_question_image($quizid, $question);
 
            /// First, get all the questions available
@@ -826,7 +826,7 @@ function quiz_print_question($number, $question, $grade, $quizid,
            // For this question type, we better print the image on top:
            quiz_print_possible_question_image($quizid, $question);
 
-            $qtextremaining = format_text($question->questiontext, FORMAT_HTML, NULL, $courseid);
+            $qtextremaining = format_text($question->questiontext, $question->questiontextformat, NULL, $courseid);
             // The regex will recognize text snippets of type {#X} where the X can be any text not containg } or white-space characters.
             while (ereg('\{#([^[:space:]}]*)}', $qtextremaining, $regs)) {
 
index 69ecfcf011c2ffd93f52b70ddf6339d1fb1da3a6..39723701f2f05728ddb79faaf0e71aec3e3e26f2 100644 (file)
         <?php  if (isset($err["name"])) formerr($err["name"]); ?>\r
     </TD>\r
 </TR>\r
-<TR valign=top>\r
-    <TD align=right><P><B><?php  print_string("question", "quiz") ?>:</B></P></TD>\r
-    <TD>\r
+<tr valign=top>\r
+    <td align="right"><p><b><?php  print_string("question", "quiz") ?>:</b></p>\r
+    <br />\r
+    <br />\r
+    <br />\r
+    <p><font SIZE="1">\r
+    <?php\r
+           if ($usehtmleditor) {\r
+               helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);\r
+           } else {\r
+               helpbutton("text", get_string("helptext"), "moodle", true, true);\r
+           }\r
+    ?>\r
+    </font></p>\r
+    </td>\r
+    <td>\r
         <?php  if (isset($err["questiontext"])) {\r
                formerr($err["questiontext"]); \r
-               echo "<BR />";\r
+               echo "<br />";\r
            }\r
+\r
            print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);\r
-           if ($usehtmleditor) {\r
-               helpbutton("richtext", get_string("helprichtext"), "moodle");\r
+\r
+           if ($usehtmleditor) {   /// Trying this out for a while\r
+               echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'">';\r
            } else {\r
-               helpbutton("text", get_string("helptext"), "moodle");\r
+               echo "<div align=right>";\r
+               print_string("formattexttype");\r
+               echo ":&nbsp;";\r
+               if (!$question->questiontextformat) {\r
+                   $question->questiontextformat = FORMAT_MOODLE;\r
+               }\r
+               choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");\r
+               helpbutton("textformat", get_string("helpformatting"));\r
+               echo "</div>";\r
            }\r
         ?>\r
-    </TD>\r
-</TR>\r
+    </td>\r
+</tr>\r
 <TR valign=top>\r
     <TD align=right><P><B><?php  print_string("imagedisplay", "quiz") ?>:</B></P></TD>\r
     <TD>\r
index 379ab092dacc52b770bdf44938da385324f4d718..29ec71bce2675314f8ddbfc33a194c3bf537ea7d 100644 (file)
         <?php  if (isset($err["name"])) formerr($err["name"]); ?>\r
     </TD>\r
 </TR>\r
-<TR valign=top>\r
-    <TD align=right><P><B><?php  print_string("question", "quiz") ?>:</B></P></TD>\r
-    <TD>\r
+<tr valign=top>\r
+    <td align="right"><p><b><?php  print_string("question", "quiz") ?>:</b></p>\r
+    <br />\r
+    <br />\r
+    <br />\r
+    <p><font SIZE="1">\r
+    <?php\r
+           if ($usehtmleditor) {\r
+               helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);\r
+           } else {\r
+               helpbutton("text", get_string("helptext"), "moodle", true, true);\r
+           }\r
+    ?>\r
+    </font></p>\r
+    </td>\r
+    <td>\r
         <?php  if (isset($err["questiontext"])) {\r
                formerr($err["questiontext"]); \r
-               echo "<BR />";\r
+               echo "<br />";\r
            }\r
+\r
            print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);\r
-           if ($usehtmleditor) {\r
-               helpbutton("richtext", get_string("helprichtext"), "moodle");\r
+\r
+           if ($usehtmleditor) {   /// Trying this out for a while\r
+               echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'">';\r
            } else {\r
-               helpbutton("text", get_string("helptext"), "moodle");\r
+               echo "<div align=right>";\r
+               print_string("formattexttype");\r
+               echo ":&nbsp;";\r
+               if (!$question->questiontextformat) {\r
+                   $question->questiontextformat = FORMAT_MOODLE;\r
+               }\r
+               choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");\r
+               helpbutton("textformat", get_string("helpformatting"));\r
+               echo "</div>";\r
            }\r
         ?>\r
-    </TD>\r
-</TR>\r
+    </td>\r
+</tr>\r
 <TR valign=top>\r
     <TD align=right><P><B><?php  print_string("imagedisplay", "quiz") ?>:</B></P></TD>\r
     <TD>\r
index 393f126c4f7afad99ac23b1bb475618e37d52876..6a9b4f41daa6b19d66a1e01c5d5d7f33917f717c 100644 (file)
         <?php  if (isset($err["name"])) formerr($err["name"]); ?>
     </TD>
 </TR>
-<TR valign=top>
-    <TD align=right><P><B><?php  print_string("question", "quiz") ?>:</B></P></TD>
-    <TD>
+<tr valign=top>
+    <td align="right"><p><b><?php  print_string("question", "quiz") ?>:</b></p>
+    <br />
+    <br />
+    <br />
+    <p><font SIZE="1">
+    <?php
+           if ($usehtmleditor) {
+               helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
+           } else {
+               helpbutton("text", get_string("helptext"), "moodle", true, true);
+           }
+    ?>
+    </font></p>
+    </td>
+    <td>
         <?php  if (isset($err["questiontext"])) {
                formerr($err["questiontext"]); 
-               echo "<BR />";
+               echo "<br />";
            }
+
            print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
-           if ($usehtmleditor) {
-               helpbutton("richtext", get_string("helprichtext"), "moodle");
+
+           if ($usehtmleditor) {   /// Trying this out for a while
+               echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'">';
            } else {
-               helpbutton("text", get_string("helptext"), "moodle");
+               echo "<div align=right>";
+               print_string("formattexttype");
+               echo ":&nbsp;";
+               if (!$question->questiontextformat) {
+                   $question->questiontextformat = FORMAT_MOODLE;
+               }
+               choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
+               helpbutton("textformat", get_string("helpformatting"));
+               echo "</div>";
            }
         ?>
-    </TD>
-</TR>
+    </td>
+</tr>
 <TR valign=top>
     <TD align=right><P><B><?php  print_string("imagedisplay", "quiz") ?>:</B></P></TD>
     <TD>
index d367411a85b16fce2fec25ebf0db8f6ddaf99107..6af541209bbd59bc477ee90f8dd34f01ca6917af 100644 (file)
 
         // First, save the basic question itself
 
-        $question->name         = $form->name;
-        $question->questiontext = $form->questiontext;
+        $question->name               = $form->name;
+        $question->questiontext       = $form->questiontext;
+        $question->questiontextformat = $form->questiontextformat;
 
         if (empty($form->image)) {
             $question->image = "";
index 5cb2c4bd7aca41903f8f6aaf5548d50132bd3b51..e763e604cf54b1d39cf834e0052bd8536e8db4ce 100644 (file)
         <?php  if (isset($err["name"])) formerr($err["name"]); ?>\r
     </TD>\r
 </TR>\r
-<TR valign=top>\r
-    <TD align=right><P><B><?php  print_string("introduction", "quiz") ?>:</B></P></TD>\r
-    <TD>\r
+<tr valign=top>\r
+    <td align=right><p><b><?php  print_string("introduction", "quiz") ?>:</b></p></td>\r
+    <br />\r
+    <br />\r
+    <br />\r
+    <p><font SIZE="1">\r
+    <?php\r
+           if ($usehtmleditor) {\r
+               helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);\r
+           } else {\r
+               helpbutton("text", get_string("helptext"), "moodle", true, true);\r
+           }\r
+    ?>\r
+    </font></p>\r
+    </td>\r
+    <td>\r
         <?php  if (isset($err["questiontext"])) {\r
                formerr($err["questiontext"]); \r
-               echo "<BR />";\r
+               echo "<br />";\r
            }\r
+\r
            if (empty($question->questiontext)) {\r
                $question->questiontext =  get_string("randomsamatchintro", "quiz");\r
            }\r
            print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);\r
-           if ($usehtmleditor) {\r
-               helpbutton("richtext", get_string("helprichtext"), "moodle");\r
+\r
+           if ($usehtmleditor) {   /// Trying this out for a while\r
+               echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'">';\r
            } else {\r
-               helpbutton("text", get_string("helptext"), "moodle");\r
+               echo "<div align=right>";\r
+               print_string("formattexttype");\r
+               echo ":&nbsp;";\r
+               if (!$question->questiontextformat) {\r
+                   $question->questiontextformat = FORMAT_MOODLE;\r
+               }\r
+               choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");\r
+               helpbutton("textformat", get_string("helpformatting"));\r
+               echo "</div>";\r
            }\r
         ?>\r
-    </TD>\r
-</TR>\r
+    </td>\r
+</tr>\r
 <TR valign=top>\r
     <TD align=right><P><B><?php  print_string("randomsamatchnumber", "quiz") ?>:</B></P></TD>\r
     <TD>\r
index 1f799b3740370c158d558e76f0268c8c0dc4c0b5..b17a15b6546368f1dc2be3c3a0cc1e81325b0cd5 100644 (file)
         <?php  if (isset($err["name"])) formerr($err["name"]); ?>\r
     </TD>\r
 </TR>\r
-<TR valign=top>\r
-    <TD align=right><P><B><?php  print_string("question", "quiz") ?>:</B></P></TD>\r
-    <TD>\r
+<tr valign=top>\r
+    <td align="right"><p><b><?php  print_string("question", "quiz") ?>:</b></p>\r
+    <br />\r
+    <br />\r
+    <br />\r
+    <p><font SIZE="1">\r
+    <?php\r
+           if ($usehtmleditor) {\r
+               helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);\r
+           } else {\r
+               helpbutton("text", get_string("helptext"), "moodle", true, true);\r
+           }\r
+    ?>\r
+    </font></p>\r
+    </td>\r
+    <td>\r
         <?php  if (isset($err["questiontext"])) {\r
                formerr($err["questiontext"]); \r
-               echo "<BR />";\r
+               echo "<br />";\r
            }\r
+\r
            print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);\r
-           if ($usehtmleditor) {\r
-               helpbutton("richtext", get_string("helprichtext"), "moodle");\r
+\r
+           if ($usehtmleditor) {   /// Trying this out for a while\r
+               echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'">';\r
            } else {\r
-               helpbutton("text", get_string("helptext"), "moodle");\r
+               echo "<div align=right>";\r
+               print_string("formattexttype");\r
+               echo ":&nbsp;";\r
+               if (!$question->questiontextformat) {\r
+                   $question->questiontextformat = FORMAT_MOODLE;\r
+               }\r
+               choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");\r
+               helpbutton("textformat", get_string("helpformatting"));\r
+               echo "</div>";\r
            }\r
         ?>\r
-    </TD>\r
-</TR>\r
+    </td>\r
+</tr>\r
 <TR valign=top>\r
     <TD align=right><P><B><?php  print_string("imagedisplay", "quiz") ?>:</B></P></TD>\r
     <TD>\r
index 9ccef4b1748ebaf3eb19fc920a198924c1111fbe..614bb3c62bb65b93aa8093ac15bb6fff93761ef6 100644 (file)
         <?php  if (isset($err["name"])) formerr($err["name"]); ?>\r
     </TD>\r
 </TR>\r
-<TR valign=top>\r
-    <TD align=right><P><B><?php  print_string("question", "quiz") ?>:</B></P></TD>\r
-    <TD>\r
+<tr valign=top>\r
+    <td align="right"><p><b><?php  print_string("question", "quiz") ?>:</b></p>\r
+    <br />\r
+    <br />\r
+    <br />\r
+    <p><font SIZE="1">\r
+    <?php\r
+           if ($usehtmleditor) {\r
+               helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);\r
+           } else {\r
+               helpbutton("text", get_string("helptext"), "moodle", true, true);\r
+           }\r
+    ?>\r
+    </font></p>\r
+    </td>\r
+    <td>\r
         <?php  if (isset($err["questiontext"])) {\r
                formerr($err["questiontext"]); \r
-               echo "<BR />";\r
+               echo "<br />";\r
            }\r
+\r
            print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);\r
-           if ($usehtmleditor) {\r
-               helpbutton("richtext", get_string("helprichtext"), "moodle");\r
+\r
+           if ($usehtmleditor) {   /// Trying this out for a while\r
+               echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'">';\r
            } else {\r
-               helpbutton("text", get_string("helptext"), "moodle");\r
+               echo "<div align=right>";\r
+               print_string("formattexttype");\r
+               echo ":&nbsp;";\r
+               if (!$question->questiontextformat) {\r
+                   $question->questiontextformat = FORMAT_MOODLE;\r
+               }\r
+               choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");\r
+               helpbutton("textformat", get_string("helpformatting"));\r
+               echo "</div>";\r
            }\r
         ?>\r
-    </TD>\r
-</TR>\r
+    </td>\r
+</tr>\r
 <TR valign=top>\r
     <TD align=right><P><B><?php  print_string("imagedisplay", "quiz") ?>:</B></P></TD>\r
     <TD>\r
index 81810f6cca6fc523843bafc542c134050291afb4..fab4cb0ee7ad0f8d39f111735604e9b8b498543a 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2004020500;   // The (date) version of this module
+$module->version  = 2004021300;   // The (date) version of this module
 $module->requires = 2004013101;   // Requires this Moodle version
 $module->cron     = 0;            // How often should cron check this module (seconds)?