--- /dev/null
+<P ALIGN=CENTER><B>Description</B></P>\r
+\r
+<P>This type of question is not really a question. </p>\r
+\r
+<p>All it does is print some text without requiring any answers.</p>\r
+\r
+<P>It can be used to print a descriptive text to be used by a following group of questions.</p>\r
$string['activityiscurrentlyhidden'] = "Sorry, this activity is currently hidden";
$string['activitymodule'] = "Activity module";
$string['activityreport'] = "Activity report";
+$string['activitysince'] = "Activity since \$a";
$string['add'] = "Add";
$string['added'] = "Added \$a";
$string['addinganew'] = "Adding a new \$a";
$string['defaultgrade'] = "Default question grade";
$string['defaultinfo'] = "The default category for questions.";
$string['deletequestioncheck'] = "Are you absolutely sure you want to delete '\$a'?";
+$string['description'] = "Description";
$string['editcategories'] = "Edit categories";
+$string['editingdescription'] = "Editing a Description";
$string['editingmatch'] = "Editing a Matching Question";
$string['editingmultichoice'] = "Editing a Multiple Choice question";
$string['editingquiz'] = "Editing quiz";
--- /dev/null
+<FORM name="theform" method="post" <?=$onsubmit ?> action="question.php">\r
+<CENTER>\r
+<TABLE cellpadding=5>\r
+<TR valign=top>\r
+ <TD align=right><P><B><? print_string("category", "quiz") ?>:</B></P></TD>\r
+ <TD>\r
+ <? choose_from_menu($categories, "category", "$question->category", ""); ?>\r
+ </TD>\r
+</TR>\r
+<TR valign=top>\r
+ <TD align=right><P><B><? print_string("questionname", "quiz") ?>:</B></P></TD>\r
+ <TD>\r
+ <INPUT type="text" name="name" size=40 value="<? p($question->name) ?>">\r
+ <? if (isset($err["name"])) formerr($err["name"]); ?>\r
+ </TD>\r
+</TR>\r
+<TR valign=top>\r
+ <TD align=right><P><B><? print_string("question", "quiz") ?>:</B></P></TD>\r
+ <TD>\r
+ <? if (isset($err["questiontext"])) {\r
+ formerr($err["questiontext"]); \r
+ echo "<BR \>";\r
+ }\r
+ print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);\r
+ if ($usehtmleditor) {\r
+ helpbutton("richtext", get_string("helprichtext"), "moodle");\r
+ } else {\r
+ helpbutton("text", get_string("helptext"), "moodle");\r
+ }\r
+ ?>\r
+ </TD>\r
+</TR>\r
+<TR valign=top>\r
+ <TD align=right><P><B><? print_string("imagedisplay", "quiz") ?>:</B></P></TD>\r
+ <TD>\r
+ <? if (empty($images)) {\r
+ print_string("noimagesyet");\r
+ } else {\r
+ choose_from_menu($images, "image", "$question->image", get_string("none"),"","");\r
+ }\r
+ ?>\r
+ </TD>\r
+</TR>\r
+</TABLE>\r
+\r
+<INPUT type="hidden" name=id value="<? p($question->id) ?>">\r
+<INPUT type="hidden" name=qtype value="<? p($question->qtype) ?>">\r
+<INPUT type="hidden" name=defaultgrade value="0">\r
+<INPUT type="submit" value="<? print_string("savechanges") ?>">\r
+\r
+</CENTER>\r
+</FORM>\r
+<? \r
+ if ($usehtmleditor) { \r
+ print_richedit_javascript("theform", "questiontext", "no");\r
+ }\r
+?>\r
$questions[] = $key;
$questionrecord = get_record("quiz_questions", "id", $key);
+
if (!empty($questionrecord->defaultgrade)) {
$modform->grades[$key] = $questionrecord->defaultgrade;
+ } else if ($questionrecord->qtype == DESCRIPTION){
+ $modform->grades[$key] = 0;
} else {
$modform->grades[$key] = 1;
}
define("RANDOM", "4");
define("MATCH", "5");
define("RANDOMSAMATCH", "6");
+define("DESCRIPTION", "7");
$QUIZ_QUESTION_TYPE = array ( MULTICHOICE => get_string("multichoice", "quiz"),
TRUEFALSE => get_string("truefalse", "quiz"),
SHORTANSWER => get_string("shortanswer", "quiz"),
MATCH => get_string("match", "quiz"),
RANDOM => get_string("random", "quiz"),
- RANDOMSAMATCH => get_string("randomsamatch", "quiz") );
+ RANDOMSAMATCH => get_string("randomsamatch", "quiz"),
+ DESCRIPTION => get_string("description", "quiz") );
$QUIZ_FILE_FORMAT = array ( "custom" => get_string("custom", "quiz"),
"missingword" => get_string("missingword", "quiz"),
// The grades for every question in this quiz are stored in an array
if ($quiz->grades) {
foreach ($quiz->grades as $question => $grade) {
- if ($question and $grade) {
+ if ($question) {
unset($questiongrade);
$questiongrade->quiz = $quiz->id;
$questiongrade->question = $question;
if ($quiz->grades) {
foreach ($quiz->grades as $question => $grade) {
- if ($question and $grade) {
+ if ($question) {
unset($questiongrade);
$questiongrade->quiz = $quiz->id;
$questiongrade->question = $question;
case RANDOMSAMATCH:
echo "<IMG BORDER=0 HEIGHT=16 WIDTH=16 SRC=\"pix/rm.gif\">";
break;
+ case DESCRIPTION:
+ echo "<IMG BORDER=0 HEIGHT=16 WIDTH=16 SRC=\"pix/de.gif\">";
+ break;
}
if ($editlink) {
echo "</A>\n";
/// Prints a quiz question, any format
/// $question is provided as an object
+ if ($question->qtype == DESCRIPTION) { // Special case question - has no answers etc
+ echo '<p align="center">';
+ echo text_to_html($question->questiontext);
+ if ($question->image) {
+ print_file_picture($question->image, $courseid);
+ }
+ echo '</p>';
+ return true;
+ }
+
if (empty($actualgrade)) {
$actualgrade = 0;
}
$questionorder = array();
foreach ($questions as $question) {
- $count++;
+
+ if ($question->qtype != DESCRIPTION) { // Description questions are not counted
+ $count++;
+ }
$questionorder[] = $question->id;
$question->grade = $grades[$question->id];
}
- if (!$answers = quiz_get_answers($question)) {
- error("No answers defined for question id $question->id!");
+ if ($question->qtype != DESCRIPTION) { // All real questions need answers defined
+ if (!$answers = quiz_get_answers($question)) {
+ error("No answers defined for question id $question->id!");
+ }
}
$grade = 0; // default
case RANDOM:
break;
+ case DESCRIPTION:
+ break;
+
default:
$result->error = "Unsupported question type ($question->qtype)!";
return $result;
$question->image = $form->image;
}
+ if (isset($form->defaultgrade)) {
+ $question->defaultgrade = $form->defaultgrade;
+ }
+
if ($err = formcheck($question)) {
notify(get_string("someerrorswerefound"));
require("random.html");
break;
+ case DESCRIPTION:
+ print_heading(get_string("editingdescription", "quiz"));
+ require("description.html");
+ break;
+
default:
error("Invalid question type");
break;