While implementing this, I removed the ~100 lines of very similar code from the top of each question type's editquestion.html template, and moved this to a the function print_question_form_start() in the base class, which uses the template question/type/editquestionstart.html. This is described in more detail here: http://moodle.org/mod/forum/discuss.php?d=51590, and is why this patch makes the codebase 523 lines smaller.
--- /dev/null
+<p align="center"><b>Question commentary</b></p>
+
+<p>Question commentary is some text that gets shown to the
+student after they have attempted the question. Unlike feedback,
+which depends on the question type and what response the student gave,
+the same commentary text is shown to all students.</p>
+
+<p>You can control when commentary is shown to students using
+the "Students may review:" check-boxes on the quiz editing form.</p>
+
+<p>You can use the commentary to give students some background
+to what knownledge the question was testing. Or to give them a
+link to more information they can use if they did not understand the
+questions.</p>
\ No newline at end of file
--- /dev/null
+<p align="center"><b>Question text</b></p>
+
+<p>Different question types all display differently,
+but they all start with some text which is entered here.
+Depending on the question type, there may be more
+settings to control the rest of the question display
+lower down this form.</p>
\ No newline at end of file
$string['closepreview'] = 'Close preview';
$string['closereview'] = 'Close review';
$string['comment'] = 'Comment';
+$string['commentary'] = 'Commentary';
$string['commentorgrade'] = 'Make comment or override grade';
$string['completedon'] = 'Completed on';
$string['confirmclose'] = 'You are about to close this attempt. Once you close the attempt you will no longer be able to change your answers.';
$string['marks'] = 'Marks';
$string['match'] = 'Matching';
$string['matchanswer'] = 'Matching answer';
+$string['matchanswerno'] = 'Matching answer $a';
$string['matcherror'] = 'Grades do not match grade options - question skipped';
$string['matchgrades'] = 'Match grades';
$string['matchgradeserror'] = 'Error if grade not listed';
$string['questioninuse'] = 'The question \'$a->questionname\' is currently being used in: <br />$a->quiznames<br />The question will not be deleted from these quizzes but only from the category list.';
$string['questionname'] = 'Question name';
$string['questionnametoolong'] = 'Question name too long at line $a (255 char. max). It has been truncated.';
+$string['questionno'] = 'Question $a';
$string['questions'] = 'Questions';
$string['questionsinuse'] = '(* Questions marked by an asterisk are already in use in some quizzes. These question will not be deleted from these quizzes but only from the category list.)';
$string['questionsperpage'] = 'Questions per page';
+$string['questiontext'] = 'Question text';
$string['questiontype'] = 'Question type $a';
$string['questiontypesetupoptions'] = 'Setup options for question types:';
$string['quizavailable'] = 'The quiz is available until: $a';
*/
define("QUESTION_NUMANS", "10");
+/**
+ * The options used when popping up a question preview window in Javascript.
+ */
+define('QUESTION_PREVIEW_POPUP_OPTIONS', "'scrollbars=yes,resizable=yes,width=700,height=540'");
/**#@+
* Option flags for ->optionflags
return $export_name;
}
-?>
+?>
\ No newline at end of file
// older versions to match current functionality
global $CFG, $QTYPES, $db;
+ $success = true;
+
require_once("$CFG->dirroot/mod/quiz/locallib.php");
if ($oldversion < 2002101800) {
execute_sql('DROP TABLE '.$CFG->prefix.'quiz_attemptonlast_datasets', false);
}
+ if ($oldversion < 2006081000) {
+ // Add a column to the the question table to store the question commentary.
+ $success = $success && table_column('question', '', 'commentarytext', 'text', '', '', '', 'not null', 'image');
+
+ // Adjust the quiz review options so that commentary is displayed whenever feedback is.
+ $success = $success && execute_sql('UPDATE ' . $CFG->prefix . 'quiz SET review = ' .
+ '(review & ~' . QUIZ_REVIEW_COMMENTARY . ') | ' . // Clear any existing junk from the commenary bits.
+ '((review & ' . QUIZ_REVIEW_FEEDBACK . ') * 8)'); // Set the commentary bits to be the same as the feedback ones.
- return true;
+ // Same adjustment to the defaults for new quizzes.
+ $success = $success && set_config('quiz_review', ($CFG->quiz_review & ~QUIZ_REVIEW_COMMENTARY) |
+ (($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK) << 3));
+ }
+
+ return $success;
}
?>
questiontext text NOT NULL,
questiontextformat tinyint(2) NOT NULL default '0',
image varchar(255) NOT NULL default '',
+ commentarytext text NOT NULL,
defaultgrade int(10) unsigned NOT NULL default '1',
penalty float NOT NULL default '0.1',
qtype varchar(20) NOT NULL default '',
// older versions to match current functionality
global $CFG, $db;
+ $success = true;
+
include_once("$CFG->dirroot/mod/quiz/locallib.php");
if ($oldversion < 2003010100) {
}
+ if ($oldversion < 2006081000) {
+ // Add a column to the the question table to store the question commentary.
+ $success = $success && table_column('question', '', 'commentarytext', 'text', '', '', '', 'not null', 'image');
+
+ // Adjust the quiz review options so that commentary is displayed whenever feedback is.
+ $success = $success && execute_sql('UPDATE ' . $CFG->prefix . 'quiz SET review = ' .
+ '(review & ~' . QUIZ_REVIEW_COMMENTARY . ') | ' . // Clear any existing junk from the commenary bits.
+ '((review & ' . QUIZ_REVIEW_FEEDBACK . ') * 8)'); // Set the commentary bits to be the same as the feedback ones.
- return true;
+ // Same adjustment to the defaults for new quizzes.
+ $success = $success && set_config('quiz_review', ($CFG->quiz_review & ~QUIZ_REVIEW_COMMENTARY) |
+ (($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK) << 3));
+ }
+
+
+ return $success;
}
?>
questiontext text NOT NULL default '',
questiontextformat integer NOT NULL default '0',
image varchar(255) NOT NULL default '',
+ commentarytext text NOT NULL default '',
defaultgrade integer NOT NULL default '1',
penalty real NOT NULL default '0.1',
qtype varchar(20) NOT NULL default '0',
// It defines default values for any important configuration variables
$defaults = array (
- 'quiz_review' => hexdec('ffffff'),
+ 'quiz_review' => 0xffffff,
'quiz_attemptonlast' => 0,
'quiz_attempts' => 0,
'quiz_grademethod' => '',
$context = $quiz->id ? '&contextquiz='.$quiz->id : '';
$quiz_id = $quiz->id ? '&quizid=' . $quiz->id : '';
- echo "<a title=\"$strpreview\" href=\"javascript:void(0)\" onClick=\"openpopup('/question/preview.php?id=$qnum$quiz_id','questionpreview','scrollbars=yes,resizable=yes,width=700,height=480', false)\">
- <img src=\"$CFG->pixpath/t/preview.gif\" border=\"0\" alt=\"$strpreview\" /></a>";
+ echo "<a title=\"$strpreview\" href=\"javascript:void(0)\" onClick=\"openpopup('/question/preview.php?id=$qnum$quiz_id','questionpreview', " .
+ QUESTION_PREVIEW_POPUP_OPTIONS . ", false)\">
+ <img src=\"$CFG->pixpath/t/preview.gif\" border=\"0\" alt=\"$strpreview\" /></a>";
if ($canedit) {
echo "<a title=\"$stredit\" href=\"$CFG->wwwroot/question/question.php?id=$qnum$context\">
- <img src=\"$CFG->pixpath/t/edit.gif\" border=\"0\" alt=\"$stredit\" /></a>";
+ <img src=\"$CFG->pixpath/t/edit.gif\" border=\"0\" alt=\"$stredit\" /></a>";
}
if ($allowdelete) {
echo "<a title=\"$strremove\" href=\"edit.php?delete=$count&quizid=$quiz->id&sesskey=$USER->sesskey\">
- <img src=\"$CFG->pixpath/t/removeright.gif\" border=\"0\" alt=\"$strremove\" /></a>";
+ <img src=\"$CFG->pixpath/t/removeright.gif\" border=\"0\" alt=\"$strremove\" /></a>";
}
echo "</td></tr>";
/**
* The first 6 bits refer to the time immediately after the attempt
*/
-define('QUIZ_REVIEW_IMMEDIATELY', 64-1);
+define('QUIZ_REVIEW_IMMEDIATELY', 0x3f);
/**
* the next 6 bits refer to the time after the attempt but while the quiz is open
*/
-define('QUIZ_REVIEW_OPEN', 4096-64);
+define('QUIZ_REVIEW_OPEN', 0xfc0);
/**
* the final 6 bits refer to the time after the quiz closes
*/
-define('QUIZ_REVIEW_CLOSED', 262144-4096);
+define('QUIZ_REVIEW_CLOSED', 0x3f000);
// within each group of 6 bits we determine what should be shown
-define('QUIZ_REVIEW_RESPONSES', 1+64+4096); // Show responses
-define('QUIZ_REVIEW_SCORES', 2*4161); // Show scores
-define('QUIZ_REVIEW_FEEDBACK', 4*4161); // Show feedback
-define('QUIZ_REVIEW_ANSWERS', 8*4161); // Show correct answers
+define('QUIZ_REVIEW_RESPONSES', 1*0x1041); // Show responses
+define('QUIZ_REVIEW_SCORES', 2*0x1041); // Show scores
+define('QUIZ_REVIEW_FEEDBACK', 4*0x1041); // Show feedback
+define('QUIZ_REVIEW_ANSWERS', 8*0x1041); // Show correct answers
// Some handling of worked solutions is already in the code but not yet fully supported
// and not switched on in the user interface.
-define('QUIZ_REVIEW_SOLUTIONS', 16*4161); // Show solutions
-// the 6th bit is as yet unused
+define('QUIZ_REVIEW_SOLUTIONS', 16*0x1041); // Show solutions
+define('QUIZ_REVIEW_COMMENTARY', 32*0x1041); // Show commentary
/**#@-*/
/**
unset($form->solutionsclosed);
}
+ if (isset($form->commentaryimmediately)) {
+ $review += (QUIZ_REVIEW_COMMENTARY & QUIZ_REVIEW_IMMEDIATELY);
+ unset($form->solutionsimmediately);
+ }
+ if (isset($form->commentaryopen)) {
+ $review += (QUIZ_REVIEW_COMMENTARY & QUIZ_REVIEW_OPEN);
+ unset($form->solutionsopen);
+ }
+ if (isset($form->commentaryclosed)) {
+ $review += (QUIZ_REVIEW_COMMENTARY & QUIZ_REVIEW_CLOSED);
+ unset($form->solutionsclosed);
+ }
+
$form->review = $review;
$form->optionflags = $optionflags;
$questionlist = quiz_questions_in_quiz($attempt->layout);
if ($questionlist and $states = get_records_select('question_states', "attempt = '$attempt->uniqueid' AND question IN ($questionlist)")) {
foreach ($states as $state) {
+ $session = new stdClass;
$session->newgraded = $state->id;
$session->newest = $state->id;
$session->questionid = $state->question;
$strpreview = get_string('previewquestion', 'quiz');
$context = $quiz->id ? '&contextquiz='.$quiz->id : '';
$quiz_id = $quiz->id ? '&quizid=' . $quiz->id : '';
- return "<a title=\"$strpreview\" href=\"javascript:void(0)\" onClick=\"openpopup('/question/preview.php?id=$qnum$quiz_id','questionpreview','scrollbars=yes,resizable=yes,width=700,height=480', false)\">
- <img src=\"../../pix/t/preview.gif\" border=\"0\" alt=\"$strpreview\" /></a>";
+ return "<a title=\"$strpreview\" href=\"javascript:void(0)\" onClick=\"openpopup('/question/preview.php?id=$qnum$quiz_id','questionpreview', " .
+ QUESTION_PREVIEW_POPUP_OPTIONS . ", false)\">
+ <img src=\"../../pix/t/preview.gif\" border=\"0\" alt=\"$strpreview\" /></a>";
}
* @param object $state
*/
function quiz_get_renderoptions($reviewoptions, $state) {
+ $options = new stdClass;
+
// Show the question in readonly (review) mode if the question is in
// the closed state
$options->readonly = question_state_is_closed($state);
// Show correct responses in readonly mode if the quiz allows it
$options->correct_responses = $options->readonly && ($reviewoptions & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_IMMEDIATELY);
+ // Show commentary if the question has been graded and the quiz allows it.
+ $options->commentary = question_state_is_graded($state) && ($reviewoptions & QUIZ_REVIEW_COMMENTARY & QUIZ_REVIEW_IMMEDIATELY);
+
// Always show responses and scores
$options->responses = true;
$options->scores = true;
* Determine review options
*/
function quiz_get_reviewoptions($quiz, $attempt, $isteacher=false) {
+
+ $options = new stdClass;
$options->readonly = true;
// Provide the links to the question review and comment script
$options->questionreviewlink = '/mod/quiz/reviewquestion.php';
$options->feedback = true;
$options->correct_responses = true;
$options->solutions = false;
+ $options->commentary = true;
+
// Show a link to the comment box only for closed attempts
if ($attempt->timefinish) {
$options->questioncommentlink = '/mod/quiz/comment.php';
}
- return $options;
- }
- if (((time() - $attempt->timefinish) < 120) || $attempt->timefinish==0) {
- $options->responses = ($quiz->review & QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_RESPONSES) ? 1 : 0;
- $options->scores = ($quiz->review & QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_SCORES) ? 1 : 0;
- $options->feedback = ($quiz->review & QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_FEEDBACK) ? 1 : 0;
- $options->correct_responses = ($quiz->review & QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_ANSWERS) ? 1 : 0;
- $options->solutions = ($quiz->review & QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_SOLUTIONS) ? 1 : 0;
- } else if (!$quiz->timeclose or time() < $quiz->timeclose) {
- $options->responses = ($quiz->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_RESPONSES) ? 1 : 0;
- $options->scores = ($quiz->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_SCORES) ? 1 : 0;
- $options->feedback = ($quiz->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_FEEDBACK) ? 1 : 0;
- $options->correct_responses = ($quiz->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_ANSWERS) ? 1 : 0;
- $options->solutions = ($quiz->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_SOLUTIONS) ? 1 : 0;
} else {
- $options->responses = ($quiz->review & QUIZ_REVIEW_CLOSED & QUIZ_REVIEW_RESPONSES) ? 1 : 0;
- $options->scores = ($quiz->review & QUIZ_REVIEW_CLOSED & QUIZ_REVIEW_SCORES) ? 1 : 0;
- $options->feedback = ($quiz->review & QUIZ_REVIEW_CLOSED & QUIZ_REVIEW_FEEDBACK) ? 1 : 0;
- $options->correct_responses = ($quiz->review & QUIZ_REVIEW_CLOSED & QUIZ_REVIEW_ANSWERS) ? 1 : 0;
- $options->solutions = ($quiz->review & QUIZ_REVIEW_CLOSED & QUIZ_REVIEW_SOLUTIONS) ? 1 : 0;
+ if (((time() - $attempt->timefinish) < 120) || $attempt->timefinish==0) {
+ $quiz_state_mask = QUIZ_REVIEW_IMMEDIATELY;
+ } else if (!$quiz->timeclose or time() < $quiz->timeclose) {
+ $quiz_state_mask = QUIZ_REVIEW_OPEN;
+ } else {
+ $quiz_state_mask = QUIZ_REVIEW_CLOSED;
+ }
+ $options->responses = ($quiz->review & $quiz_state_mask & QUIZ_REVIEW_RESPONSES) ? 1 : 0;
+ $options->scores = ($quiz->review & $quiz_state_mask & QUIZ_REVIEW_SCORES) ? 1 : 0;
+ $options->feedback = ($quiz->review & $quiz_state_mask & QUIZ_REVIEW_FEEDBACK) ? 1 : 0;
+ $options->correct_responses = ($quiz->review & $quiz_state_mask & QUIZ_REVIEW_ANSWERS) ? 1 : 0;
+ $options->solutions = ($quiz->review & $quiz_state_mask & QUIZ_REVIEW_SOLUTIONS) ? 1 : 0;
+ $options->commentary = ($quiz->review & $quiz_state_mask & QUIZ_REVIEW_COMMENTARY) ? 1 : 0;
}
-
+
return $options;
}
////////////////////////////////////////////////////////////////////////////////
<td align="center"><?php print_string('feedback', 'quiz') ?></td>
<td align="center"><?php print_string('answers', 'quiz') ?></td>
<!-- <td align="center"><?php print_string('solutions', 'quiz') ?></td>-->
+ <td align="center"><?php print_string('commentary', 'quiz') ?></td>
<td>
<?php helpbutton("review2", get_string("allowreview","quiz"), "quiz"); ?>
</td>
<input type="checkbox" name="solutionsimmediately" value="Yes" <?php echo ($form->review & QUIZ_REVIEW_SOLUTIONS & QUIZ_REVIEW_IMMEDIATELY) ? 'checked="checked"' : '' ?> />
</td>
-->
+ <td align="center">
+ <input type="checkbox" name="commentaryimmediately" value="Yes" <?php echo ($form->review & QUIZ_REVIEW_COMMENTARY & QUIZ_REVIEW_IMMEDIATELY) ? 'checked="checked"' : '' ?> />
+ </td>
</tr>
<tr>
<td align="center">
<input type="checkbox" name="solutionsopen" value="Yes" <?php echo ($form->review & QUIZ_REVIEW_SOLUTIONS & QUIZ_REVIEW_OPEN) ? 'checked="checked"' : '' ?> />
</td>
-->
+ <td align="center">
+ <input type="checkbox" name="commentaryopen" value="Yes" <?php echo ($form->review & QUIZ_REVIEW_COMMENTARY & QUIZ_REVIEW_OPEN) ? 'checked="checked"' : '' ?> />
+ </td>
</tr>
<tr>
<td align="center">
<input type="checkbox" name="solutionsclosed" value="Yes" <?php echo ($form->review & QUIZ_REVIEW_SOLUTIONS & QUIZ_REVIEW_CLOSED) ? 'checked="checked"' : '' ?> />
</td>
-->
+ <td align="center">
+ <input type="checkbox" name="commentaryclosed" value="Yes" <?php echo ($form->review & QUIZ_REVIEW_COMMENTARY & QUIZ_REVIEW_CLOSED) ? 'checked="checked"' : '' ?> />
+ </td>
</tr>
</table>
</td>
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2006080900; // The (date) version of this module
+$module->version = 2006081000; // The (date) version of this module
$module->requires = 2006080900; // Requires this Moodle version
$module->cron = 0; // How often should cron check this module (seconds)?
fwrite ($bf,full_tag("QUESTIONTEXT",6,false,$question->questiontext));
fwrite ($bf,full_tag("QUESTIONTEXTFORMAT",6,false,$question->questiontextformat));
fwrite ($bf,full_tag("IMAGE",6,false,$question->image));
+ fwrite ($bf,full_tag("COMMENTARYTEXT",6,false,$question->commentarytext));
fwrite ($bf,full_tag("DEFAULTGRADE",6,false,$question->defaultgrade));
fwrite ($bf,full_tag("PENALTY",6,false,$question->penalty));
fwrite ($bf,full_tag("QTYPE",6,false,$question->qtype));
echo "<a title=\"$straddtoquiz\" href=\"edit.php?addquestion=$question->id&quizid=$quizid&sesskey=$USER->sesskey\"><img
src=\"$CFG->pixpath/t/moveleft.gif\" border=\"0\" alt=\"$straddtoquiz\" /></a> ";
}
- echo "<a title=\"$strpreview\" href=\"javascript:void();\" onClick=\"openpopup('/question/preview.php?id=$question->id&quizid=$quizid','$strpreview','scrollbars=yes,resizable=yes,width=700,height=480', false)\"><img
- src=\"$CFG->pixpath/t/preview.gif\" border=\"0\" alt=\"$strpreview\" /></a> ";
+ echo "<a title=\"$strpreview\" href=\"javascript:void();\" onClick=\"openpopup('/question/preview.php?id=$question->id&quizid=$quizid','$strpreview', " .
+ QUESTION_PREVIEW_POPUP_OPTIONS . ", false)\"><img
+ src=\"$CFG->pixpath/t/preview.gif\" border=\"0\" alt=\"$strpreview\" /></a> ";
if ($canedit) {
echo "<a title=\"$stredit\" href=\"$CFG->wwwroot/question/question.php?id=$question->id\"><img
- src=\"$CFG->pixpath/t/edit.gif\" border=\"0\" alt=\"$stredit\" /></a> ";
+ src=\"$CFG->pixpath/t/edit.gif\" border=\"0\" alt=\"$stredit\" /></a> ";
// hide-feature
if($question->hidden) {
echo "<a title=\"$strrestore\" href=\"edit.php?courseid=$course->id&unhide=$question->id&sesskey=$USER->sesskey\"><img
- src=\"$CFG->pixpath/t/restore.gif\" border=\"0\" alt=\"$strrestore\" /></a>";
+ src=\"$CFG->pixpath/t/restore.gif\" border=\"0\" alt=\"$strrestore\" /></a>";
} else {
echo "<a title=\"$strdelete\" href=\"edit.php?courseid=$course->id&deleteselected=$question->id&q$question->id=1\"><img
- src=\"$CFG->pixpath/t/delete.gif\" border=\"0\" alt=\"$strdelete\" /></a>";
+ src=\"$CFG->pixpath/t/delete.gif\" border=\"0\" alt=\"$strdelete\" /></a>";
}
}
echo " <input title=\"$strselect\" type=\"checkbox\" name=\"q$question->id\" value=\"1\" />";
$image_base64 = stripslashes( trim( $question['#']['image_base64'][0]['#'] ) );
$image = $this->importimagefile( $image, $image_base64 );
}
+ if (array_key_exists('commentarytext', $question['#'])) {
+ $commentarytext = $this->import_text( $question['#']['commentarytext'][0]['#']['text'] );
+ } else {
+ $commentarytext = '';
+ }
$penalty = $question['#']['penalty'][0]['#'];
$qo = $this->defaultquestion();
$qo->questiontext = $qtext;
$qo->questiontextformat = $this->trans_format( $qformat );
$qo->image = ((!empty($image)) ? $image : '');
+ $qo->commentarytext = $commentarytext;
$qo->penalty = $penalty;
return $qo;
$name_text = $this->writetext( $question->name );
$qtformat = $this->get_format($question->questiontextformat);
$question_text = $this->writetext( $question->questiontext );
+ $commentary_text = $this->writetext( $question->commentarytext );
$expout .= " <question type=\"$question_type\">\n";
$expout .= " <name>$name_text</name>\n";
$expout .= " <questiontext format=\"$qtformat\">\n";
$expout .= " </questiontext>\n";
$expout .= " <image>{$question->image}</image>\n";
$expout .= $this->writeimage($question->image);
+ $expout .= " <commentarytext>\n";
+ $expout .= $commentary_text;
+ $expout .= " </commentarytext>\n";
$expout .= " <penalty>{$question->penalty}</penalty>\n";
$expout .= " <hidden>{$question->hidden}</hidden>\n";
}
}
- make_upload_directory("$course->id"); // Just in case
- $coursefiles = get_directory_list("$CFG->dataroot/$course->id", $CFG->moddata);
- foreach ($coursefiles as $filename) {
- if (mimeinfo("icon", $filename) == "image.gif") {
- $images["$filename"] = $filename;
- }
- }
-
// Print the question editing form
if (empty($question->id)) {
if (!isset($question->defaultgrade)) {
$question->defaultgrade = 1;
}
+ if (empty($question->commentarytext)) {
+ $question->commentarytext = "";
+ }
// Set up some Richtext editing if necessary
if ($usehtmleditor = can_use_richtext_editor()) {
$question->questiontext = backup_todb($que_info['#']['QUESTIONTEXT']['0']['#']);
$question->questiontextformat = backup_todb($que_info['#']['QUESTIONTEXTFORMAT']['0']['#']);
$question->image = backup_todb($que_info['#']['IMAGE']['0']['#']);
+ if (array_key_exists('COMMENTARYTEXT', $que_info['#'])) {
+ $question->commentarytext = backup_todb($que_info['#']['COMMENTARYTEXT']['0']['#']);
+ } else {
+ $question->commentarytext = '';
+ }
$question->defaultgrade = backup_todb($que_info['#']['DEFAULTGRADE']['0']['#']);
$question->penalty = backup_todb($que_info['#']['PENALTY']['0']['#']);
$question->qtype = backup_todb($que_info['#']['QTYPE']['0']['#']);
-<form name="theform" method="post" action="question.php">
-<center>
-<table cellpadding="5">
-<tr valign="top">
- <td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
- <td align="left">
- <?php question_category_select_menu($course->id, true, true, $question->category); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="name" size="50" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
- <?php if (isset($err["name"])) formerr($err["name"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("question", "quiz") ?>:</b>
- <br />
- <br />
- <br />
- <span class="editorhelptext">
- <?php
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
- } else {
- helpbutton("text", get_string("helptext"), "moodle", true, true);
- }
- ?>
- </span>
- </td>
- <td align="left">
- <?php if (isset($err["questiontext"])) {
- formerr($err["questiontext"]);
- echo "<br />";
- }
-
- print_textarea($usehtmleditor, 20, 60, 630, 300, "questiontext", $question->questiontext);
-
- if ($usehtmleditor) { /// Trying this out for a while
- echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
- } else {
- echo '<div align="right">';
- print_string("formattexttype");
- echo ": ";
- if (!isset($question->questiontextformat)) {
- $question->questiontextformat = FORMAT_MOODLE;
- }
- choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
- helpbutton("textformat", get_string("helpformatting"));
- echo "</div>";
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
- <td align="left">
- <?php if (empty($images)) {
- print_string("noimagesyet");
- } else {
- choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
-
- <?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="penalty" size="3" value="<?php p($question->penalty) ?>" alt="<?php print_string("penaltyfactor", "quiz") ?>" />
- <?php helpbutton('penalty', get_string('penalty', 'quiz'), 'quiz'); ?>
- <?php if (isset($err["penalty"])) formerr($err["penalty"]); ?>
- </td>
-</tr>
+<?php
+$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor);
+?>
<tr valign="top">
<td align="right"><b><?php print_string("correctanswerformula", "quiz") ?>:</b></td>
<td align="left">
</tr>
<?php
} /// END for
+
+$QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
+$QTYPES[$question->qtype]->print_question_form_end($question,
+ 'onclick="return determineMinAndMax();"',
+ '<input type="hidden" name="wizardpage" value="question" />');
?>
-</table>
-<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
-<input type="hidden" name="id" value="<?php p($question->id) ?>" />
-<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
-<input type="hidden" name="wizardpage" value="question" />
-<input type="submit" onclick="return determineMinAndMax();" value="<?php print_string("savechanges") ?>" />
-</center>
-</form>
<script language="javascript" type="text/javascript">
function determineMinAndMax() {
// This client-side script will determine the values for min and max
-<form name="theform" method="post" action="question.php">
-<center>
-<table cellpadding="5">
-<tr valign="top">
- <td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
- <td align="left">
- <?php question_category_select_menu($course->id, true, true, $question->category); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="name" size="40" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
- <?php if (isset($err["name"])) formerr($err["name"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("question", "quiz") ?>:</b>
- <br />
- <br />
- <br />
- <font size="1">
- <?php
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
- } else {
- helpbutton("text", get_string("helptext"), "moodle", true, true);
- }
- ?>
- </font>
- </td>
- <td align="left">
- <?php if (isset($err["questiontext"])) {
- formerr($err["questiontext"]);
- echo "<br />";
- }
- print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
- if ($usehtmleditor) {
- echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
- } else {
- echo "<div align=\"right\">";
- print_string("formattexttype");
- echo ": ";
- if (!isset($question->questiontextformat)) {
- $question->questiontextformat = FORMAT_MOODLE;
- }
- choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
- helpbutton("textformat", get_string("helpformatting"));
- echo "</div>";
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
- <td align="left">
- <?php if (empty($images)) {
- print_string("noimagesyet");
- } else {
- choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
- }
- ?>
- </td>
-</tr>
-</table>
-<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
-<input type="hidden" name="id" value="<?php p($question->id) ?>" />
-<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
-<input type="hidden" name="defaultgrade" value="0" />
-<input type="submit" value="<?php print_string("savechanges") ?>" />
-</center>
-</form>
+<?php
+$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor,
+ array('defaultgrade', 'penalty'));
+$QTYPES[$question->qtype]->print_question_form_end($question);
+?>
--- /dev/null
+ <tr valign="top">
+ <td colspan="2" align="center">
+ <input type="submit" <?php echo $submitscript ?> value="<?php print_string('savechanges') ?>" />
+ <?php
+ if ($question->id) {
+ ?>
+ <input type="submit" name="makecopy" <?php echo $submitscript ?> value="<?php print_string("makecopy", "quiz") ?>" />
+ <?php
+ }
+ ?>
+ <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
+ <input type="hidden" name="sesskey" value="<?php p($USER->sesskey) ?>" />
+ <input type="hidden" name="id" value="<?php p($question->id) ?>" />
+ <input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
+ <?php
+ echo $hiddenfields;
+
+ // The following hidden field indicates that the versioning code should be turned on, i.e.,
+ // that old versions should be kept if necessary
+ ?>
+ <input type="hidden" name="versioning" value="on" />
+ </td>
+ </tr>
+</table>
+</center>
+</form>
--- /dev/null
+<form name="theform" method="post" action="question.php">
+<center>
+<table cellpadding="5">
+
+ <tr valign="top">
+ <td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
+ <td align="left">
+ <?php question_category_select_menu($course->id, true, true, $question->category); ?>
+ </td>
+ </tr>
+
+ <tr valign="top">
+ <td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
+ <td align="left">
+ <input type="text" name="name" size="50" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
+ <?php if (isset($err["name"])) formerr($err["name"]); ?>
+ </td>
+ </tr>
+
+ <tr valign="top">
+ <td align="right"><b><?php print_string("question", "quiz") ?>:</b>
+ <br /><br /><br />
+ <?php
+ helpbutton("questiontext", get_string("questiontext", "quiz"), "quiz", true, true);
+ echo '<br />';
+ if ($usehtmleditor) {
+ helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
+ } else {
+ helpbutton("text", get_string("helptext"), "moodle", true, true);
+ }
+ ?>
+ </td>
+ <td align="left">
+ <?php
+ if (isset($err["questiontext"])) {
+ formerr($err["questiontext"]);
+ echo "<br />";
+ }
+ print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
+ if ($usehtmleditor) {
+ echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
+ } else {
+ echo "<div align=\"right\">";
+ print_string("formattexttype");
+ echo ": ";
+ if (!isset($question->questiontextformat)) {
+ $question->questiontextformat = FORMAT_MOODLE;
+ }
+ choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
+ helpbutton("textformat", get_string("helpformatting"));
+ echo "</div>";
+ }
+ ?>
+ </td>
+ </tr>
+
+ <?php
+ if (!in_array('image', $hidefields)) {
+ ?>
+ <tr valign="top">
+ <td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
+ <td align="left">
+ <?php
+ if (empty($images)) {
+ print_string("noimagesyet");
+ } else {
+ choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
+ }
+ ?>
+ </td>
+ </tr>
+ <?php
+ }
+
+ if (!in_array('defaultgrade', $hidefields)) {
+ ?>
+ <tr valign="top">
+ <td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
+ <td align="left">
+ <input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
+
+ <?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
+ </td>
+ </tr>
+ <?php
+ }
+
+ if (!in_array('penalty', $hidefields)) {
+ ?>
+ <tr valign="top">
+ <td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
+ <td align="left">
+ <input type="text" name="penalty" size="3" value="<?php p($question->penalty) ?>" alt="<?php print_string("penaltyfactor", "quiz") ?>" />
+ <?php helpbutton('penalty', get_string('penalty', 'quiz'), 'quiz'); ?>
+ <?php if (isset($err["penalty"])) formerr($err["penalty"]); ?>
+ </td>
+ </tr>
+ <?php
+ }
+ ?>
+
+ <tr valign="top">
+ <td align="right"><b><?php print_string("commentary", "quiz") ?>:</b>
+ <br /><br /><br />
+ <?php
+ helpbutton("commentary", get_string("commentary", "quiz"), "quiz", true, true);
+ ?>
+ </td>
+ <td align="left">
+ <?php
+ if (isset($err["commentarytext"])) {
+ formerr($err["commentarytext"]);
+ echo "<br />";
+ }
+ print_textarea(false, 10, 60, 630, 200, "commentarytext", $question->commentarytext);
+ ?>
+ </td>
+ </tr>
+
+ <tr valign="top">
+ <td colspan="2"> </td>
+ </tr>
\ No newline at end of file
-<form name="theform" method="post" action="question.php">
-<center>
-<table cellpadding="5">
-<tr valign="top">
- <td align="right">
- <b><?php print_string("category", "quiz") ?>:</b>
- </td>
- <td>
- <?php question_category_select_menu($course->id, true, true, $question->category); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">
- <b><?php print_string("questionname", "quiz") ?>:</b>
- </td>
- <td>
- <input type="text" name="name" size="50" value="<?php p($question->name) ?>" />
- <?php if (isset($err["name"])) formerr($err["name"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">
- <b><?php print_string("question", "quiz") ?>:</b>
- <br />
- <br />
- <br />
- <font size="1">
- <?php
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
- } else {
- helpbutton("text", get_string("helptext"), "moodle", true, true);
- }
- ?>
- </font>
- </td>
- <td>
- <?php
- if (isset($err["questiontext"])) {
- formerr($err["questiontext"]);
- echo "<br />";
- }
-
- print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
-
- if ($usehtmleditor) {
- echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
- } else {
- echo "<div align=\"right\">";
- print_string("formattexttype");
- echo ": ";
- if (!isset($question->questiontextformat)) {
- $question->questiontextformat = FORMAT_MOODLE;
- }
- choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
- helpbutton("textformat", get_string("helpformatting"));
- echo "</div>";
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">
- <b><?php print_string("imagedisplay", "quiz") ?>:</b>
- </td>
- <td>
- <?php
- if (empty($images)) {
- print_string("noimagesyet");
- } else {
- choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
-
- <?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
- </td>
-</tr>
+<?php
+$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor);
+?>
<tr valign="top">
<td align="right">
<b><?php print_string("feedback", "quiz") ?>:</b>
<textarea name="feedback" rows="2" cols="50" wrap="virtual"><?php p($options->answer->feedback) ?></textarea>
</td>
</tr>
-</table>
-<input type="hidden" name="fraction" value="0" /> <?php // dont think there would ever be a different value other than 1... ?>
<?php
- $QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
- $QTYPES[$question->qtype]->print_question_form_end($question);
+$QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
+$QTYPES[$question->qtype]->print_question_form_end($question, '',
+ '<input type="hidden" name="fraction" value="0" />'); // dont think there would ever be a different value other than 1...
?>
-
-</center>
-
-</form>
-
-<form name="theform" method="post" action="question.php">
-<center>
-<table cellpadding="5">
-<tr valign="top">
- <td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
+<?php
+$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor);
+?>
+ <tr valign="top">
+ <td align="right"><b><?php print_string("choices", "quiz") ?></b>:</td>
<td align="left">
- <?php question_category_select_menu($course->id, true, true, $question->category); ?>
+ <div style="width: 30em">
+ <?php print_string("filloutthreequestions", "quiz") ?>
+ </div>
</td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
+ </tr>
+ <tr valign="top">
+ <td align="right"><b><?php print_string("shuffle", "quiz") ?>:</b></td>
<td align="left">
- <input type="text" name="name" size="40" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
- <?php if (isset($err["name"])) formerr($err["name"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("question", "quiz") ?>:</b>
- <br />
- <br />
- <br />
- <font size="1">
<?php
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
- } else {
- helpbutton("text", get_string("helptext"), "moodle", true, true);
- }
+ choose_from_menu($yesnooptions, "shuffleanswers", "$options->shuffleanswers", "");
+ helpbutton("matchshuffle", get_string("shuffle","quiz"), "quiz");
?>
- </font>
- </td>
- <td align="left">
- <?php if (isset($err["questiontext"])) {
- formerr($err["questiontext"]);
- echo "<br />";
- }
- print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
- if ($usehtmleditor) {
- echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
- } else {
- echo "<div align=\"right\">";
- print_string("formattexttype");
- echo ": ";
- if (!isset($question->questiontextformat)) {
- $question->questiontextformat = FORMAT_MOODLE;
- }
- choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
- helpbutton("textformat", get_string("helpformatting"));
- echo "</div>";
- }
- ?>
</td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
- <td align="left">
- <?php if (empty($images)) {
- print_string("noimagesyet");
- } else {
- choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
+ </tr>
+<?php
+for ($i=1; $i <= count($subquestions); $i++) {
+?>
+ <tr valign="top">
+ <td colspan="2"> </td>
+ </tr>
- <?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
+ <tr valign="top">
+ <td align="right"><b><?php print_string("questionno", "quiz", $i) ?>:</b></td>
<td align="left">
- <input type="text" name="penalty" size="3" value="<?php p($question->penalty) ?>" alt="<?php print_string("penaltyfactor", "quiz") ?>" />
- <?php helpbutton('penalty', get_string('penalty', 'quiz'), 'quiz'); ?>
- <?php if (isset($err["penalty"])) formerr($err["penalty"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("choices", "quiz") ?></b>:</td>
- <td align="left"><?php print_string("filloutthreequestions", "quiz") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("shuffle", "quiz") ?>:</b></td>
- <td align="left">
- <?php
- choose_from_menu($yesnooptions, "shuffleanswers", "$options->shuffleanswers", "");
- helpbutton("matchshuffle", get_string("shuffle","quiz"), "quiz");
- ?>
+ <textarea name="subquestions[]" rows="3" cols="50"><?php p($subquestions[$i-1]) ?></textarea>
</td>
-</tr>
-<?php
- for ($i=1; $i <= count($subquestions); $i++) {
-?>
-<tr valign="top">
- <td align="right"><b><?php echo get_string("question", "quiz")." $i"; ?> :</b></td>
+ </tr>
+
+ <tr valign="top">
+ <td align="right"><b><?php print_string("matchanswerno", "quiz", $i) ?>:</b></td>
<td align="left">
- <textarea name="subquestions[]" rows="5" cols="50"><?php p($subquestions[$i-1]) ?></textarea>
- <br />
- <?php echo get_string("matchanswer", "quiz")." $i"; ?>
- <input type="text" name="subanswers[]" size="50" value="<?php p($subanswers[$i-1]) ?>" alt="<?php echo get_string("matchanswer", "quiz")." $i"; ?>" />
+ <input type="text" name="subanswers[]" size="50" value="<?php p($subanswers[$i-1]) ?>" alt="<?php print_string("matchanswerno", "quiz", $i) ?>" />
</td>
-</tr>
+ </tr>
<?php
- }
+}
- $QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
- $QTYPES[$question->qtype]->print_question_form_end($question);
+$QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
+$QTYPES[$question->qtype]->print_question_form_end($question);
?>
-</table>
-
-</center>
-</form>
$answerids = array();
$responses = &$state->responses;
- $formatoptions = new stdClass;
- $formatoptions->noclean = true;
- $formatoptions->para = false;
-
// Prepare a list of answers, removing duplicates.
foreach ($subquestions as $subquestion) {
foreach ($subquestion->options->answers as $ans) {
$answers = draw_rand_array($answers, count($answers));
// Print formulation
- $questiontext = format_text($question->questiontext,
- $question->questiontextformat,
- $formatoptions, $cmoptions->course);
+ $questiontext = $this->format_text($question->questiontext,
+ $question->questiontextformat, $cmoptions);
$image = get_question_image($question, $cmoptions->course);
///// Print the input controls //////
if ($subquestion->questiontext) {
/// Subquestion text:
$a = new stdClass;
- $a->text = format_text($subquestion->questiontext,
- $question->questiontextformat, $formatoptions, $cmoptions->course);
+ $a->text = $this->format_text($subquestion->questiontext,
+ $question->questiontextformat, $cmoptions);
/// Drop-down list:
$menuname = $nameprefix.$subquestion->id;
-<form name="theform" method="post" action="question.php">
-<center>
-<table cellpadding="5">
-
- <tr valign="top">
- <td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
- <td align="left">
- <?php question_category_select_menu($course->id, true, true, $question->category); ?>
- </td>
- </tr>
-
- <tr valign="top">
- <td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="name" size="40" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
- <?php if (isset($err["name"])) formerr($err["name"]); ?>
- </td>
- </tr>
-
- <tr valign="top">
- <td align="right"><b><?php print_string("question", "quiz") ?>:</b>
- <br /><br /><br /><font size="1">
- <?php
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
- } else {
- helpbutton("text", get_string("helptext"), "moodle", true, true);
- }
- ?>
- </font>
- </td>
- <td align="left">
- <?php
- if (isset($err["questiontext"])) {
- formerr($err["questiontext"]);
- echo "<br />";
- }
- print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
- if ($usehtmleditor) {
- echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
- } else {
- echo "<div align=\"right\">";
- print_string("formattexttype");
- echo ": ";
- if (!isset($question->questiontextformat)) {
- $question->questiontextformat = FORMAT_MOODLE;
- }
- choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
- helpbutton("textformat", get_string("helpformatting"));
- echo "</div>";
- }
- ?>
- </td>
- </tr>
-
- <tr valign="top">
- <td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
- <td align="left">
- <?php
- if (empty($images)) {
- print_string("noimagesyet");
- } else {
- choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
- }
- ?>
- </td>
- </tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
-
- <?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="penalty" size="3" value="<?php p($question->penalty) ?>" alt="<?php print_string("penaltyfactor", "quiz") ?>" />
- <?php helpbutton('penalty', get_string('penalty', 'quiz'), 'quiz'); ?>
- <?php if (isset($err["penalty"])) formerr($err["penalty"]); ?>
- </td>
-</tr>
-
<?php
- for ($i=1; $i<=count($answers); $i++) {
- if (!isset($answers[$i-1]->fraction)) {
- $answers[$i-1]->answer = '';
- $answers[$i-1]->fraction = 0;
- $answers[$i-1]->feedback = '';
- }
+$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor);
+
+for ($i=1; $i<=count($answers); $i++) {
+ if (!isset($answers[$i-1]->fraction)) {
+ $answers[$i-1]->answer = '';
+ $answers[$i-1]->fraction = 0;
+ $answers[$i-1]->feedback = '';
+ }
?>
<tr valign="top">
</tr>
<?php
- } /// End of loop, printing answers
- $QTYPES['missingtype']->print_replacement_options($question, $course, $contextquiz);
- $QTYPES['missingtype']->print_question_form_end($question);
-?>
-</table>
-
-</center>
-</form>
+} /// End of loop, printing answers
+$QTYPES['missingtype']->print_replacement_options($question, $course, $contextquiz);
+$QTYPES['missingtype']->print_question_form_end($question);
+?>
-<form name="theform" method="post" action="question.php">
-<center>
-<table cellpadding="5">
-<tr valign="top">
- <td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
- <td align="left">
- <?php question_category_select_menu($course->id, true, true, $question->category); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="name" size="40" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
- <?php if (isset($err["name"])) formerr($err["name"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("question", "quiz") ?>:</b></td>
- <td align="left">
- <?php if (isset($err["questiontext"])) {
- formerr($err["questiontext"]);
- echo "<br />";
- }
- print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle");
- } else {
- helpbutton("text", get_string("helptext"), "moodle");
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
- <td align="left">
- <?php if (empty($images)) {
- print_string("noimagesyet");
- } else {
- choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="penalty" size="3" value="<?php p($question->penalty) ?>" alt="<?php print_string("penaltyfactor", "quiz") ?>" />
- <?php helpbutton('penalty', get_string('penalty', 'quiz'), 'quiz'); ?>
- <?php if (isset($err["penalty"])) formerr($err["penalty"]); ?>
- </td>
-</tr>
<?php
- $QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
- $QTYPES[$question->qtype]->print_question_form_end($question);
+$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor,
+ array('defaultgrade'));
+$QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
+$QTYPES[$question->qtype]->print_question_form_end($question, '',
+ '<input type="hidden" name="defaultgrade" value="' . s($question->defaultgrade) . '" />');
?>
-</table>
-
-<input type="hidden" name="defaultgrade" value="<?php p($question->defaultgrade) ?>" />
-
-</center>
-</form>
-<form name="theform" method="post" action="question.php">
-<center>
-<table cellpadding="5">
-
- <tr valign="top">
- <td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
- <td align="left">
- <?php question_category_select_menu($course->id, true, true, $question->category); ?>
- </td>
- </tr>
-
- <tr valign="top">
- <td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="name" size="40" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
- <?php if (isset($err["name"])) formerr($err["name"]); ?>
- </td>
- </tr>
-
- <tr valign="top">
- <td align="right"><b><?php print_string("question", "quiz") ?>:</b>
- <br /><br /><br /><font size="1">
- <?php
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
- } else {
- helpbutton("text", get_string("helptext"), "moodle", true, true);
- }
- ?>
- </font>
- </td>
- <td align="left">
- <?php
- if (isset($err["questiontext"])) {
- formerr($err["questiontext"]);
- echo "<br />";
- }
- print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
- if ($usehtmleditor) {
- echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
- } else {
- echo "<div align=\"right\">";
- print_string("formattexttype");
- echo ": ";
- if (!isset($question->questiontextformat)) {
- $question->questiontextformat = FORMAT_MOODLE;
- }
- choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
- helpbutton("textformat", get_string("helpformatting"));
- echo "</div>";
- }
- ?>
- </td>
- </tr>
-
- <tr valign="top">
- <td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
- <td align="left">
- <?php
- if (empty($images)) {
- print_string("noimagesyet");
- } else {
- choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
- }
- ?>
- </td>
- </tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
-
- <?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="penalty" size="3" value="<?php p($question->penalty) ?>" alt="<?php print_string("penaltyfactor", "quiz") ?>" />
- <?php helpbutton('penalty', get_string('penalty', 'quiz'), 'quiz'); ?>
- <?php if (isset($err["penalty"])) formerr($err["penalty"]); ?>
- </td>
-</tr>
+<?php
+$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor);
+?>
<tr valign="top">
<td align="right"><b><?php print_string("answerhowmany", "quiz") ?>:</b></td>
<td align="left">
</tr>
<?php
- for ($i=1; $i<=count($answers); $i++) {
- if (!isset($answers[$i-1]->fraction)) {
- $answers[$i-1]->answer = '';
- $answers[$i-1]->fraction = 0;
- $answers[$i-1]->feedback = '';
- }
+for ($i=1; $i<=count($answers); $i++) {
+ if (!isset($answers[$i-1]->fraction)) {
+ $answers[$i-1]->answer = '';
+ $answers[$i-1]->fraction = 0;
+ $answers[$i-1]->feedback = '';
+ }
?>
<tr valign="top">
</tr>
<?php
- } /// End of loop, printing answers
- $QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
- $QTYPES[$question->qtype]->print_question_form_end($question);
-?>
-</table>
-
-</center>
-</form>
+} /// End of loop, printing answers
+$QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
+$QTYPES[$question->qtype]->print_question_form_end($question);
+?>
-<form name="theform" method="post" action="question.php">
-<center>
-<table cellpadding="5">
-<tr valign="top">
- <td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
- <td align="left">
- <?php question_category_select_menu($course->id, true, true, $question->category); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="name" size="50" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
- <?php if (isset($err["name"])) formerr($err["name"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("question", "quiz") ?>:</b>
- <br />
- <br />
- <br />
- <font size="1">
- <?php
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
- } else {
- helpbutton("text", get_string("helptext"), "moodle", true, true);
- }
- ?>
- </font>
- </td>
- <td align="left">
- <?php if (isset($err["questiontext"])) {
- formerr($err["questiontext"]);
- echo "<br />";
- }
-
- print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
-
- if ($usehtmleditor) {
- echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
- } else {
- echo "<div align=\"right\">";
- print_string("formattexttype");
- echo ": ";
- if (!isset($question->questiontextformat)) {
- $question->questiontextformat = FORMAT_MOODLE;
- }
- choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
- helpbutton("textformat", get_string("helpformatting"));
- echo "</div>";
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
- <td align="left">
- <?php
- if (empty($images)) {
- print_string("noimagesyet");
- } else {
- choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
-
- <?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="penalty" size="3" value="<?php p($question->penalty) ?>" alt="<?php print_string("penaltyfactor", "quiz") ?>" />
- <?php helpbutton('penalty', get_string('penalty', 'quiz'), 'quiz'); ?>
- <?php if (isset($err["penalty"])) formerr($err["penalty"]); ?>
- </td>
-</tr>
-<!-- Answers. -->
<?php
+$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor);
+
+// Answers.
for ($i=1; $i<=count($answers); $i++) {
$answer = $answers[$i-1];
?>
</tr>
<?php
}
+// Units.
?>
-<!-- Units. -->
<tr valign="top">
<td align="right"><b><?php print_string("unit", "quiz") ?>:</b></td>
<td align="left"><?php
<?php
} /// END for
- $QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
- $QTYPES[$question->qtype]->print_question_form_end($question);
+$QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
+$QTYPES[$question->qtype]->print_question_form_end($question);
?>
-</table>
-</center>
-</form>
?>
</div>
<?php }
- echo $commentlink;
+ echo $commentlink;
+ if ($commentary) { ?>
+ <div class="commentary">
+ <?php echo $commentary ?>
+ </div>
+ <?php }
if ($history) { ?>
<div class="history">
<?php
$question->image = $form->image;
}
+ if (empty($form->commentarytext)) {
+ $question->commentarytext = '';
+ } else {
+ $question->commentarytext = trim($form->commentarytext);
+ }
+
if (empty($question->name)) {
$question->name = substr(strip_tags($question->questiontext), 0, 15);
if (empty($question->name)) {
/* The default implementation should work for most question types
provided the member functions it calls are overridden where required.
The layout is determined by the template question.html */
+
global $CFG;
+ $isgraded = question_state_is_graded($state->last_graded);
// For editing teachers print a link to an editing popup window
$editlink = '';
$editlink = link_to_popup_window('/question/question.php?id='.$question->id, $stredit, $linktext, 450, 550, $stredit, '', true);
}
+ $commentary = '';
+ if ($isgraded && $options->commentary) {
+ $commentary = $this->format_text($question->commentarytext,
+ $question->questiontextformat, $cmoptions);
+ }
+
$grade = '';
if ($question->maxgrade and $options->scores) {
if ($cmoptions->optionflags & QUESTION_ADAPTIVE) {
- $grade = (!question_state_is_graded($state->last_graded)) ? '--/' : round($state->last_graded->grade, $cmoptions->decimalpoints).'/';
+ $grade = !$isgraded ? '--/' : round($state->last_graded->grade, $cmoptions->decimalpoints).'/';
}
$grade .= $question->maxgrade;
}
}
if (count($states) > 1) {
$strreviewquestion = get_string('reviewresponse', 'quiz');
- unset($table);
+ $table = new stdClass;
$table->width = '100%';
if ($options->scores) {
$table->head = array (
if (!empty($question->maxgrade) && $options->scores) {
if (question_state_is_graded($state->last_graded)) {
// Display the grading details from the last graded state
+ $grade = new stdClass;
$grade->cur = round($state->last_graded->grade, $cmoptions->decimalpoints);
$grade->max = $question->maxgrade;
$grade->raw = round($state->last_graded->raw_grade, $cmoptions->decimalpoints);
echo "</td></tr>\n";
}
- function print_question_form_end($question, $submitscript='') {
- // This function is used at the end of the question edit forms in all question types
- // It prints the submit, copy, and cancel buttons and the standard hidden form fields
- global $USER;
- echo '<tr valign="top">
- <td colspan="2" align="center">
- <input type="submit" '.$submitscript.' value="'.get_string('savechanges').'" /> ';
- if ($question->id) {
- echo '<input type="submit" name="makecopy" '.$submitscript.' value="'.get_string("makecopy", "quiz").'" /> ';
+ /**
+ * Print the start of the question editing form, including the question category,
+ * questionname, questiontext, image, defaultgrade, penalty and commentary fields.
+ *
+ * Three of the fields, image, defaultgrade, penalty, are optional, and
+ * can be removed from the from using the $hidefields argument.
+ *
+ * @param object $question The question object that the form we are printing is for.
+ * @param array $err Array of optional error messages to display by each field.
+ * Used when the form is being redisplayed after validation failed.
+ * @param object $course The course object for the course this question belongs to.
+ * @param boolean $usehtmleditor Whether the html editor should be used.
+ * @param array $hidefields An array which may contain the strings,
+ * 'image', 'defaultgrade' or 'penalty' to remove the corresponding field.
+ */
+ function print_question_form_start($question, $err, $course, $usehtmleditor, $hidefields = array()) {
+ global $CFG;
+
+ // If you edit this function, you also need to edit random/editquestion.html.
+
+ if (!in_array('image', $hidefields)) {
+ make_upload_directory("$course->id"); // Just in case
+ $coursefiles = get_directory_list("$CFG->dataroot/$course->id", $CFG->moddata);
+ foreach ($coursefiles as $filename) {
+ if (mimeinfo("icon", $filename) == "image.gif") {
+ $images["$filename"] = $filename;
+ }
+ }
}
- echo '<input type="submit" name="cancel" value="'.get_string("cancel").'" />
- <input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />
- <input type="hidden" name="id" value="'.$question->id.'" />
- <input type="hidden" name="qtype" value="'.$question->qtype.'" />';
- // The following hidden field indicates that the versioning code should be turned on, i.e.,
- // that old versions should be kept if necessary
- echo '<input type="hidden" name="versioning" value="on" />
- </td></tr>';
+
+ include('editquestionstart.html');
+ }
+
+ /**
+ * Print the end of the question editing form, including the submit, copy,
+ * and cancel button, and the standard hidden fields like the sesskey and
+ * the question type.
+ *
+ * @param object $question The question object that the form we are printing is for.
+ * @param string $submitscript Extra attributes, for example 'onsubmit="myfunction"',
+ * that is added to the HTML of the submit button.
+ * @param string $hiddenfields Extra hidden fields (actually any HTML)
+ * to be added at the end of the form.
+ */
+ function print_question_form_end($question, $submitscript = '', $hiddenfields = '') {
+ global $USER;
+
+ // If you edit this function, you also need to edit random/editquestion.html.
+
+ include('editquestionend.html');
+ }
+
+ /**
+ * Call format_text from weblib.php with the options appropriate to question types.
+ *
+ * @param string $text the text to format.
+ * @param integer $text the type of text. Normally $question->questiontextformat.
+ * @param object $cmoptions the context the string is being displayed in. Only $cmoptions->course is used.
+ * @return string the formatted text.
+ */
+ function format_text($text, $textformat, $cmoptions) {
+ $formatoptions = new stdClass;
+ $formatoptions->noclean = true;
+ $formatoptions->para = false;
+ return format_text($text, $textformat, $formatoptions, $cmoptions->course);
}
/// BACKUP FUNCTIONS ////////////////////////////
-<center>
<form name="theform" method="post" action="question.php">
+<center>
<table cellpadding="5">
+
<tr valign="top">
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
<td align="left">
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
</td>
</tr>
+
<tr valign="top">
<td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
<td align="left">
- <?php if (empty($question->name)) {
- $question->name = get_string("random", "quiz");
- } ?>
- <input type="text" name="name" size="40" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
+ <input type="text" name="name" size="50" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
<?php if (isset($err["name"])) formerr($err["name"]); ?>
</td>
</tr>
+
<tr valign="top">
<td align="right"><b><?php print_string("recurse", "quiz") ?>:</b></td>
<td align="left">
<input type="hidden" name="id" value="<?php p($question->id) ?>" />
<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
-</form>
</center>
+</form>
<?php // $Id$
+ if (empty($question->name)) {
+ $question->name = get_string("random", "quiz");
+ }
+
print_heading_with_help(get_string("editingrandom", "quiz"), "random", "quiz");
require("$CFG->dirroot/question/type/random/editquestion.html");
-
?>
-<form name="theform" method="post" action="question.php">
-<center>
-<table cellpadding="5">
-<tr valign="top">
- <td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
- <td align="left">
- <?php echo $categories[$question->category]; ?>
- <input type="hidden" name="category" value="<?php echo "$question->category"; ?>" />
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
- <td align="left">
- <?php
- if (empty($question->name)) {
- $question->name = get_string("randomsamatch", "quiz");
- }
- ?>
- <input type="text" name="name" size="40" value="<?php p($question->name) ?>" />
- <?php if (isset($err["name"])) formerr($err["name"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("introduction", "quiz") ?>:</b>
- <br />
- <font size="1">
- <?php
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
- } else {
- helpbutton("text", get_string("helptext"), "moodle", true, true);
- }
- ?>
- </font>
- </td>
- <td align="left">
- <?php if (isset($err["questiontext"])) {
- formerr($err["questiontext"]);
- echo "<br />";
- }
- if (empty($question->questiontext)) {
- $question->questiontext = get_string("randomsamatchintro", "quiz");
- }
- print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
- if ($usehtmleditor) {
- echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
- } else {
- echo '<div align="right">';
- print_string("formattexttype");
- echo ": ";
- if (empty($question->questiontextformat)) {
- $question->questiontextformat = FORMAT_MOODLE;
- }
- choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
- helpbutton("textformat", get_string("helpformatting"));
- echo "</div>";
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
-
- <?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="penalty" size="3" value="<?php p($question->penalty) ?>" alt="<?php print_string("penaltyfactor", "quiz") ?>" />
- <?php helpbutton('penalty', get_string('penalty', 'quiz'), 'quiz'); ?>
- <?php if (isset($err["penalty"])) formerr($err["penalty"]); ?>
- </td>
-</tr>
+<?php
+$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor,
+ array('image'));
+?>
<tr valign="top">
<td align="right"><b><?php print_string("randomsamatchnumber", "quiz") ?>:</b></td>
<td align="left">
</td>
</tr>
<?php
- $QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
- $QTYPES[$question->qtype]->print_question_form_end($question);
+$QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
+$QTYPES[$question->qtype]->print_question_form_end($question);
?>
-</table>
-</center>
-</form>
$numberavailable = count($saquestions);
unset($saquestions);
+ if (empty($question->name)) {
+ $question->name = get_string("randomsamatch", "quiz");
+ }
+
+ if (empty($question->questiontext)) {
+ $question->questiontext = get_string("randomsamatchintro", "quiz");
+ }
+
$yesnooptions = array();
$yesnooptions[0] = get_string("no");
$yesnooptions[1] = get_string("yes");
-<form name="theform" method="post" action="question.php">
-<center>
-<table cellpadding="5">
-<tr valign="top">
- <td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
- <td align="left">
- <?php question_category_select_menu($course->id, true, true, $question->category); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="name" size="50" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
- <?php if (isset($err["name"])) formerr($err["name"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("question", "quiz") ?>:</b>
- <br />
- <br />
- <br />
- <font size="1">
- <?php
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
- } else {
- helpbutton("text", get_string("helptext"), "moodle", true, true);
- }
- ?>
- </font>
- </td>
- <td align="left">
- <?php if (isset($err["questiontext"])) {
- formerr($err["questiontext"]);
- echo "<br />";
- }
- print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
- if ($usehtmleditor) {
- echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
- } else {
- echo "<div align=\"right\">";
- print_string("formattexttype");
- echo ": ";
- if (!isset($question->questiontextformat)) {
- $question->questiontextformat = FORMAT_MOODLE;
- }
- choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
- helpbutton("textformat", get_string("helpformatting"));
- echo "</div>";
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
- <td align="left">
- <?php if (empty($images)) {
- print_string("noimagesyet");
- } else {
- choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
- }
- ?>
- </td>
-</tr>
+<?php
+$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor);
+?>
<tr valign="top">
- <td align="right"><b><?php print_string("casesensitive", "quiz") ?>:</b></td>
+ <td align="right"><b><?php print_string("casesensitive", "quiz") ?>:</b></td>
<td align="left">
<?php
unset($menu);
</td>
</tr>
<tr valign="top">
- <td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
-
- <?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="penalty" size="3" value="<?php p($question->penalty) ?>" alt="<?php print_string("penaltyfactor", "quiz") ?>" />
- <?php helpbutton('penalty', get_string('penalty', 'quiz'), 'quiz'); ?>
- <?php if (isset($err["penalty"])) formerr($err["penalty"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("correctanswers", "quiz") ?></b>:</td>
+ <td align="right"><b><?php print_string("correctanswers", "quiz") ?></b>:</td>
<td align="left">
- <?php print_string("filloutoneanswer", "quiz") ?>
+ <div style="width: 35em">
+ <?php print_string("filloutoneanswer", "quiz") ?>
+ </div>
</td>
</tr>
<?php
for ($i=1; $i<=count($answers); $i++) {
?>
<tr valign="top">
- <td align="right"><b><?php echo get_string("answer", "quiz")." $i"; ?>:</b></td>
+ <td align="right"><b><?php echo get_string("answer", "quiz")." $i"; ?>:</b></td>
<td align="left">
<?php
if ($answers[$i-1]->answer === '') {
</td>
</tr>
<tr valign="top">
- <td align="right"><b><?php print_string("feedback", "quiz") ?>:</b></td>
+ <td align="right"><b><?php print_string("feedback", "quiz") ?>:</b></td>
<td align="left">
<textarea name="feedback[]" rows="2" cols="50"><?php p($feedbacktext) ?></textarea>
</td>
</tr>
<?php
}
+
+$QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
+$QTYPES[$question->qtype]->print_question_form_end($question);
?>
-<?php
- $QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
- $QTYPES[$question->qtype]->print_question_form_end($question);
-?>
-</table>
-</center>
-</form>
-<form name="theform" method="post" action="question.php">
-<center>
-<table cellpadding="5">
-<tr valign="top">
- <td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
- <td align="left">
- <?php question_category_select_menu($course->id, true, true, $question->category); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="name" size="50" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>"/>
- <?php if (isset($err["name"])) formerr($err["name"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("question", "quiz") ?>:</b>
- <br />
- <br />
- <br />
- <font size="1">
- <?php
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
- } else {
- helpbutton("text", get_string("helptext"), "moodle", true, true);
- }
- ?>
- </font>
- </td>
- <td align="left">
- <?php if (isset($err["questiontext"])) {
- formerr($err["questiontext"]);
- echo "<br />";
- }
- print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
- if ($usehtmleditor) {
- echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
- } else {
- echo "<div align=\"right\">";
- print_string("formattexttype");
- echo ": ";
- if (!isset($question->questiontextformat)) {
- $question->questiontextformat = FORMAT_MOODLE;
- }
- choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
- helpbutton("textformat", get_string("helpformatting"));
- echo "</div>";
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
- <td align="left">
- <?php if (empty($images)) {
- print_string("noimagesyet");
- } else {
- choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
-
- <?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
- <td align="left">
- <input type="text" name="penalty" size="3" value="<?php p($question->penalty) ?>" alt="<?php print_string("penaltyfactor", "quiz") ?>" />
- <?php helpbutton('penalty', get_string('penalty', 'quiz'), 'quiz'); ?>
- <?php if (isset($err["penalty"])) formerr($err["penalty"]); ?>
- </td>
-</tr>
+<?php
+$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor);
+?>
<tr valign="top">
<td align="right"><b><?php print_string("correctanswer", "quiz") ?>:</b></td>
<td align="left">
</td>
</tr>
<?php
- $QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
- $QTYPES[$question->qtype]->print_question_form_end($question);
+$QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
+$QTYPES[$question->qtype]->print_question_form_end($question);
?>
-</table>
-
-</center>
-</form>
.que .grading,
.que .comment,
.que .commentlink,
+.que .commentary,
.que .history {
float: right;
margin: 5px;