Quiz questions now have proper formatting controls.

Any format can be used.  This fixes a number of problems at once,
but the latest one is Bug #1047
This commit is contained in:
moodler
2004-02-13 14:01:27 +00:00
parent 016bfc83bc
commit 5cdb8a856a
14 changed files with 245 additions and 73 deletions
+4
View 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;
}
+1
View 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',
+4
View 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;
}
+1
View 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',
+32 -9
View File
@@ -14,22 +14,45 @@
<?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>
+7 -7
View 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)) {
+32 -9
View File
@@ -14,22 +14,45 @@
<?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>
+32 -9
View File
@@ -14,22 +14,45 @@
<?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>
+32 -9
View File
@@ -14,22 +14,45 @@
<?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>
+3 -2
View File
@@ -102,8 +102,9 @@
// 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 = "";
+32 -9
View File
@@ -20,25 +20,48 @@
<?php if (isset($err["name"])) formerr($err["name"]); ?>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string("introduction", "quiz") ?>:</B></P></TD>
<TD>
<tr valign=top>
<td align=right><p><b><?php print_string("introduction", "quiz") ?>:</b></p></td>
<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 />";
}
if (empty($question->questiontext)) {
$question->questiontext = get_string("randomsamatchintro", "quiz");
}
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("randomsamatchnumber", "quiz") ?>:</B></P></TD>
<TD>
+32 -9
View File
@@ -14,22 +14,45 @@
<?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>
+32 -9
View File
@@ -14,22 +14,45 @@
<?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>
+1 -1
View 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)?