From: tjhunt Date: Fri, 11 Aug 2006 14:59:18 +0000 (+0000) Subject: Bug 6239 - Allow questions to have some teacher-supplied commentary. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=1b8a7434e28f5508a3f7ae116192a3ac7234543d;p=moodle.git Bug 6239 - Allow questions to have some teacher-supplied commentary. 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. --- diff --git a/lang/en_utf8/help/quiz/commentary.html b/lang/en_utf8/help/quiz/commentary.html new file mode 100644 index 0000000000..46e0b178f5 --- /dev/null +++ b/lang/en_utf8/help/quiz/commentary.html @@ -0,0 +1,14 @@ +

Question commentary

+ +

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.

+ +

You can control when commentary is shown to students using +the "Students may review:" check-boxes on the quiz editing form.

+ +

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.

\ No newline at end of file diff --git a/lang/en_utf8/help/quiz/questiontext.html b/lang/en_utf8/help/quiz/questiontext.html new file mode 100644 index 0000000000..caa794a77b --- /dev/null +++ b/lang/en_utf8/help/quiz/questiontext.html @@ -0,0 +1,7 @@ +

Question text

+ +

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.

\ No newline at end of file diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php index 7f2233c7a5..38162bca45 100644 --- a/lang/en_utf8/quiz.php +++ b/lang/en_utf8/quiz.php @@ -83,6 +83,7 @@ $string['close'] = 'Close window'; $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.'; @@ -257,6 +258,7 @@ $string['markall'] = 'Submit page'; $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'; @@ -345,9 +347,11 @@ $string['questiondeleted'] = 'This question has been deleted. Please contact you $string['questioninuse'] = 'The question \'$a->questionname\' is currently being used in:
$a->quiznames
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'; diff --git a/lib/questionlib.php b/lib/questionlib.php index 2d2496e85c..f772f04432 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -59,6 +59,10 @@ define("ESSAY", "essay"); */ 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 @@ -1560,4 +1564,4 @@ function default_export_filename($course,$category) { return $export_name; } -?> +?> \ No newline at end of file diff --git a/mod/quiz/db/mysql.php b/mod/quiz/db/mysql.php index 7c805511d5..e801cec6df 100644 --- a/mod/quiz/db/mysql.php +++ b/mod/quiz/db/mysql.php @@ -5,6 +5,8 @@ function quiz_upgrade($oldversion) { // older versions to match current functionality global $CFG, $QTYPES, $db; + $success = true; + require_once("$CFG->dirroot/mod/quiz/locallib.php"); if ($oldversion < 2002101800) { @@ -1097,8 +1099,21 @@ function quiz_upgrade($oldversion) { 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; } ?> diff --git a/mod/quiz/db/mysql.sql b/mod/quiz/db/mysql.sql index daff1d028a..9f14122b3d 100644 --- a/mod/quiz/db/mysql.sql +++ b/mod/quiz/db/mysql.sql @@ -250,6 +250,7 @@ CREATE TABLE prefix_question ( 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 '', diff --git a/mod/quiz/db/postgres7.php b/mod/quiz/db/postgres7.php index d2793f8df0..b02028342e 100644 --- a/mod/quiz/db/postgres7.php +++ b/mod/quiz/db/postgres7.php @@ -5,6 +5,8 @@ function quiz_upgrade($oldversion) { // older versions to match current functionality global $CFG, $db; + $success = true; + include_once("$CFG->dirroot/mod/quiz/locallib.php"); if ($oldversion < 2003010100) { @@ -1419,8 +1421,22 @@ function quiz_upgrade($oldversion) { } + 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; } ?> diff --git a/mod/quiz/db/postgres7.sql b/mod/quiz/db/postgres7.sql index 483d330faa..4570aa5d49 100644 --- a/mod/quiz/db/postgres7.sql +++ b/mod/quiz/db/postgres7.sql @@ -244,6 +244,7 @@ CREATE TABLE prefix_question ( 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', diff --git a/mod/quiz/defaults.php b/mod/quiz/defaults.php index cc865d2065..cb80ab3b84 100644 --- a/mod/quiz/defaults.php +++ b/mod/quiz/defaults.php @@ -4,7 +4,7 @@ // 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' => '', diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php index ab7b9b0d27..8c5c428e51 100644 --- a/mod/quiz/editlib.php +++ b/mod/quiz/editlib.php @@ -267,15 +267,16 @@ function quiz_print_question_list($quiz, $allowdelete=true, $showbreaks=true, $r $context = $quiz->id ? '&contextquiz='.$quiz->id : ''; $quiz_id = $quiz->id ? '&quizid=' . $quiz->id : ''; - echo " - pixpath/t/preview.gif\" border=\"0\" alt=\"$strpreview\" />"; + echo " + pixpath/t/preview.gif\" border=\"0\" alt=\"$strpreview\" />"; if ($canedit) { echo "wwwroot/question/question.php?id=$qnum$context\"> - pixpath/t/edit.gif\" border=\"0\" alt=\"$stredit\" />"; + pixpath/t/edit.gif\" border=\"0\" alt=\"$stredit\" />"; } if ($allowdelete) { echo "id&sesskey=$USER->sesskey\"> - pixpath/t/removeright.gif\" border=\"0\" alt=\"$strremove\" />"; + pixpath/t/removeright.gif\" border=\"0\" alt=\"$strremove\" />"; } echo ""; diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 34f6a0238f..866416891e 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -22,25 +22,25 @@ require_once($CFG->libdir.'/questionlib.php'); /** * 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 /**#@-*/ /** @@ -671,6 +671,19 @@ function quiz_process_options(&$form) { 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; diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index 19deb52eb6..241f1f31eb 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -459,6 +459,7 @@ function quiz_upgrade_states($attempt) { $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; @@ -474,8 +475,9 @@ function quiz_get_question_review($quiz, $question) { $strpreview = get_string('previewquestion', 'quiz'); $context = $quiz->id ? '&contextquiz='.$quiz->id : ''; $quiz_id = $quiz->id ? '&quizid=' . $quiz->id : ''; - return " - \"$strpreview\""; + return " + \"$strpreview\""; } @@ -486,6 +488,8 @@ function quiz_get_question_review($quiz, $question) { * @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); @@ -499,6 +503,9 @@ function quiz_get_renderoptions($reviewoptions, $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; @@ -511,6 +518,8 @@ function quiz_get_renderoptions($reviewoptions, $state) { * 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'; @@ -523,32 +532,28 @@ function quiz_get_reviewoptions($quiz, $attempt, $isteacher=false) { $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; } //////////////////////////////////////////////////////////////////////////////// diff --git a/mod/quiz/reviewoptions.html b/mod/quiz/reviewoptions.html index fabd755b89..ac3f5fc0f5 100644 --- a/mod/quiz/reviewoptions.html +++ b/mod/quiz/reviewoptions.html @@ -16,6 +16,7 @@ + @@ -38,6 +39,9 @@ review & QUIZ_REVIEW_SOLUTIONS & QUIZ_REVIEW_IMMEDIATELY) ? 'checked="checked"' : '' ?> /> --> + + review & QUIZ_REVIEW_COMMENTARY & QUIZ_REVIEW_IMMEDIATELY) ? 'checked="checked"' : '' ?> /> + @@ -57,6 +61,9 @@ review & QUIZ_REVIEW_SOLUTIONS & QUIZ_REVIEW_OPEN) ? 'checked="checked"' : '' ?> /> --> + + review & QUIZ_REVIEW_COMMENTARY & QUIZ_REVIEW_OPEN) ? 'checked="checked"' : '' ?> /> + @@ -76,6 +83,9 @@ review & QUIZ_REVIEW_SOLUTIONS & QUIZ_REVIEW_CLOSED) ? 'checked="checked"' : '' ?> /> --> + + review & QUIZ_REVIEW_COMMENTARY & QUIZ_REVIEW_CLOSED) ? 'checked="checked"' : '' ?> /> + diff --git a/mod/quiz/version.php b/mod/quiz/version.php index 3791e7b2c7..eefc0afbfc 100644 --- a/mod/quiz/version.php +++ b/mod/quiz/version.php @@ -5,7 +5,7 @@ // 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)? diff --git a/question/backuplib.php b/question/backuplib.php index 0127db089e..f4d9eedf6e 100644 --- a/question/backuplib.php +++ b/question/backuplib.php @@ -142,6 +142,7 @@ 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)); diff --git a/question/editlib.php b/question/editlib.php index 33b3aefa39..61cd688faa 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -339,18 +339,19 @@ function question_list($course, $categoryid, $quizid=0, echo "id&quizid=$quizid&sesskey=$USER->sesskey\">pixpath/t/moveleft.gif\" border=\"0\" alt=\"$straddtoquiz\" /> "; } - echo "id&quizid=$quizid','$strpreview','scrollbars=yes,resizable=yes,width=700,height=480', false)\">pixpath/t/preview.gif\" border=\"0\" alt=\"$strpreview\" /> "; + echo "id&quizid=$quizid','$strpreview', " . + QUESTION_PREVIEW_POPUP_OPTIONS . ", false)\">pixpath/t/preview.gif\" border=\"0\" alt=\"$strpreview\" /> "; if ($canedit) { echo "wwwroot/question/question.php?id=$question->id\">pixpath/t/edit.gif\" border=\"0\" alt=\"$stredit\" /> "; + src=\"$CFG->pixpath/t/edit.gif\" border=\"0\" alt=\"$stredit\" /> "; // hide-feature if($question->hidden) { echo "id&unhide=$question->id&sesskey=$USER->sesskey\">pixpath/t/restore.gif\" border=\"0\" alt=\"$strrestore\" />"; + src=\"$CFG->pixpath/t/restore.gif\" border=\"0\" alt=\"$strrestore\" />"; } else { echo "id&deleteselected=$question->id&q$question->id=1\">pixpath/t/delete.gif\" border=\"0\" alt=\"$strdelete\" />"; + src=\"$CFG->pixpath/t/delete.gif\" border=\"0\" alt=\"$strdelete\" />"; } } echo " id\" value=\"1\" />"; diff --git a/question/format/xml/format.php b/question/format/xml/format.php index a756bd7bca..3897db14c5 100755 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -82,6 +82,11 @@ class qformat_xml extends qformat_default { $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(); @@ -89,6 +94,7 @@ class qformat_xml extends qformat_default { $qo->questiontext = $qtext; $qo->questiontextformat = $this->trans_format( $qformat ); $qo->image = ((!empty($image)) ? $image : ''); + $qo->commentarytext = $commentarytext; $qo->penalty = $penalty; return $qo; @@ -603,6 +609,7 @@ class qformat_xml extends qformat_default { $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 .= " \n"; $expout .= " $name_text\n"; $expout .= " \n"; @@ -610,6 +617,9 @@ class qformat_xml extends qformat_default { $expout .= " \n"; $expout .= " {$question->image}\n"; $expout .= $this->writeimage($question->image); + $expout .= " \n"; + $expout .= $commentary_text; + $expout .= " \n"; $expout .= " {$question->penalty}\n"; $expout .= " {$question->hidden}\n"; } diff --git a/question/question.php b/question/question.php index 81c7aaceb9..2e669deee1 100644 --- a/question/question.php +++ b/question/question.php @@ -261,14 +261,6 @@ } - 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)) { @@ -289,6 +281,9 @@ 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()) { diff --git a/question/restorelib.php b/question/restorelib.php index 33249ed197..a094e43217 100644 --- a/question/restorelib.php +++ b/question/restorelib.php @@ -189,6 +189,11 @@ $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']['#']); diff --git a/question/type/calculated/editquestion.html b/question/type/calculated/editquestion.html index 71b9c0b26d..22306d2df7 100644 --- a/question/type/calculated/editquestion.html +++ b/question/type/calculated/editquestion.html @@ -1,85 +1,6 @@ -
-
- - - - - - - - - - - - - - - - - - - - - - - - - +qtype]->print_question_form_start($question, array(), $course, $usehtmleditor); +?>
: - id, true, true, $question->category); ?> -
: - " /> - -
: -
-
-
- - - -
- "; - } - - print_textarea($usehtmleditor, 20, 60, 630, 300, "questiontext", $question->questiontext); - - if ($usehtmleditor) { /// Trying this out for a while - echo ''; - } else { - echo '
'; - 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 "
"; - } - ?> -
: - image", get_string("none"),"",""); - } - ?> -
: - " /> - - -
: - " /> - - -
: @@ -157,15 +78,12 @@ for ($i=1; $i qtype]->print_replacement_options($question, $course, $contextquiz); +$QTYPES[$question->qtype]->print_question_form_end($question, + 'onclick="return determineMinAndMax();"', + ''); ?> -
- - - - -" /> -
-