diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 670dbac335d..85e5f2c5722 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -4927,6 +4927,19 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); $dbman->add_field($table, $field); } + /// Upgrading the text formats in some question types depends on the + /// questiontextformat field, but the question type upgrade only runs + /// after the code below has messed around with the questiontextformat + /// value. Therefore, we need to create a new column to store the old value. + /// The column should be dropped in Moodle 2.1. + /// Define field oldquestiontextformat to be added to question + $field = new xmldb_field('oldquestiontextformat', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'generalfeedback'); + + /// Conditionally launch add field oldquestiontextformat + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + /// Define field infoformat to be added to question_categories $table = new xmldb_table('question_categories'); $field = new xmldb_field('infoformat', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'info'); @@ -5039,44 +5052,72 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); $dbman->drop_field($table, $field); } - // fix fieldformat - $sql = 'SELECT a.*, q.qtype FROM {question_answers} a, {question} q WHERE a.question = q.id'; - $rs = $DB->get_recordset_sql($sql); + // Update question_answers. + // In question_answers.feedback was previously always treated as + // FORMAT_HTML in calculated, multianswer, multichoice, numerical, + // shortanswer and truefalse; and + // FORMAT_MOODLE in essay (despite being edited using the HTML editor) + // So essay feedback needs to be converted to HTML unless $CFG->texteditors == 'textarea'. + // For all question types except multichoice, + // question_answers.answer is FORMAT_PLAIN and does not need to be changed. + // For multichoice, question_answers.answer is FORMAT_MOODLE, and should + // stay that way, at least for now. + $rs = $DB->get_recordset_sql(' + SELECT qa.*, q.qtype + FROM {question_answers} qa + JOIN {question} q ON a.question = q.id'); foreach ($rs as $record) { - // generalfeedback should use questiontext format + // Convert question_answers.answer + if ($record->qtype !== 'multichoice') { + $record->answerformat = FORMAT_PLAIN; + } else { + $record->answerformat = FORMAT_MOODLE; + } + + // Convert question_answers.feedback if ($CFG->texteditors !== 'textarea') { - if (!empty($record->feedback)) { - $record->feedback = text_to_html($record->feedback); + if ($record->qtype == 'essay') { + $record->feedback = text_to_html($record->feedback, false, false, true); } $record->feedbackformat = FORMAT_HTML; } else { $record->feedbackformat = FORMAT_MOODLE; - $record->answerformat = FORMAT_MOODLE; } - unset($record->qtype); + $DB->update_record('question_answers', $record); } $rs->close(); - $rs = $DB->get_recordset('question'); - foreach ($rs as $record) { - if ($CFG->texteditors !== 'textarea') { - if (!empty($record->questiontext)) { - $record->questiontext = text_to_html($record->questiontext); - } + // In the question table, the code previously used questiontextformat + // for both question text and general feedback. We need to copy the + // values into the new column. + // Then we need to convert FORMAT_MOODLE to FORMAT_HTML (depending on + // $CFG->texteditors). + $DB->execute(' + UPDATE {question} + SET generalfeedbackformat = questiontextformat'); + // Also save the old questiontextformat, so that plugins that need it + // can access it. + $DB->execute(' + UPDATE {question} + SET oldquestiontextformat = questiontextformat'); + // Now covert FORMAT_MOODLE content, if necssary. + if ($CFG->texteditors !== 'textarea') { + $rs = $DB->get_recordset('question', 'questiontextformat', FORMAT_MOODLE); + foreach ($rs as $record) { + $record->questiontext = text_to_html($record->questiontext, false, false, true); $record->questiontextformat = FORMAT_HTML; - // conver generalfeedback text to html - if (!empty($record->generalfeedback)) { - $record->generalfeedback = text_to_html($record->generalfeedback); - } - } else { - $record->questiontextformat = FORMAT_MOODLE; + $record->generalfeedback = text_to_html($record->generalfeedback, false, false, true); + $record->generalfeedbackformat = FORMAT_HTML; + $DB->update_record('question', $record); } - // generalfeedbackformat should be the save as questiontext format - $record->generalfeedbackformat = $record->questiontextformat; - $DB->update_record('question', $record); + $rs->close(); } - $rs->close(); + + // In the past, question_sessions.manualcommentformat was always treated + // as FORMAT_HTML. + $DB->set_field('question_sessions', 'manualcommentformat', FORMAT_HTML); + // Main savepoint reached upgrade_main_savepoint(true, 2010080901); } diff --git a/lib/questionlib.php b/lib/questionlib.php index f861f921648..389270109f2 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -1027,7 +1027,8 @@ function question_preload_states($attemptid) { // array index in the array returned by $DB->get_records_sql $statefields = 'n.questionid as question, s.id, s.attempt, ' . 's.seq_number, s.answer, s.timestamp, s.event, s.grade, s.raw_grade, ' . - 's.penalty, n.sumpenalty, n.manualcomment, n.flagged, n.id as questionsessionid'; + 's.penalty, n.sumpenalty, n.manualcomment, n.manualcommentformat, ' . + 'n.flagged, n.id as questionsessionid'; // Load the newest states for the questions $sql = "SELECT $statefields @@ -1131,6 +1132,7 @@ function question_load_states(&$questions, &$states, $cmoptions, $attempt, $last $states[$qid]->penalty = 0; $states[$qid]->sumpenalty = 0; $states[$qid]->manualcomment = ''; + $states[$qid]->manualcommentformat = FORMAT_HTML; $states[$qid]->flagged = 0; // Prevent further changes to the session from incrementing the @@ -1217,7 +1219,8 @@ function question_load_specific_state($question, $cmoptions, $attempt, $stateid) global $DB; // Load specified states for the question. // sess.sumpenalty is probably wrong here shoul really be a sum of penalties from before the one we are asking for. - $sql = 'SELECT st.*, sess.sumpenalty, sess.manualcomment, sess.flagged, sess.id as questionsessionid + $sql = 'SELECT st.*, sess.sumpenalty, sess.manualcomment, sess.manualcommentformat, + sess.flagged, sess.id as questionsessionid FROM {question_states} st, {question_sessions} sess WHERE st.id = ? AND st.attempt = ? @@ -1231,7 +1234,8 @@ function question_load_specific_state($question, $cmoptions, $attempt, $stateid) restore_question_state($question, $state); // Load the most recent graded states for the questions before the specified one. - $sql = 'SELECT st.*, sess.sumpenalty, sess.manualcomment, sess.flagged, sess.id as questionsessionid + $sql = 'SELECT st.*, sess.sumpenalty, sess.manualcomment, sess.manualcommentformat, + sess.flagged, sess.id as questionsessionid FROM {question_states} st, {question_sessions} sess WHERE st.seq_number <= ? AND st.attempt = ? @@ -1267,8 +1271,6 @@ function restore_question_state(&$question, &$state) { // initialise response to the value in the answer field $state->responses = array('' => $state->answer); - unset($state->answer); - $state->manualcomment = isset($state->manualcomment) ? $state->manualcomment : ''; // Set the changed field to false; any code which changes the // question session must set this to true and must increment @@ -1278,8 +1280,7 @@ function restore_question_state(&$question, &$state) { $state->changed = false; // Load the question type specific data - return $QTYPES[$question->qtype] - ->restore_session_and_responses($question, $state); + return $QTYPES[$question->qtype]->restore_session_and_responses($question, $state); } @@ -1332,6 +1333,7 @@ function save_question_session($question, $state) { $session->newgraded = $state->id; $session->sumpenalty = $state->sumpenalty; $session->manualcomment = $state->manualcomment; + $session->manualcommentformat = $state->manualcommentformat; $session->flagged = !empty($state->newflaggedstate); $DB->insert_record('question_sessions', $session); } else { @@ -1341,8 +1343,7 @@ function save_question_session($question, $state) { $session->newgraded = $state->id; $session->sumpenalty = $state->sumpenalty; $session->manualcomment = $state->manualcomment; - } else { - $session->manualcomment = $session->manualcomment; + $session->manualcommentformat = $state->manualcommentformat; } $session->flagged = !empty($state->newflaggedstate); $DB->update_record('question_sessions', $session); @@ -1554,7 +1555,7 @@ function regrade_question_in_attempt($question, $attempt, $cmoptions, $verbose=f } if (!$dryrun){ $error = question_process_comment($question, $replaystate, $attempt, - $replaystate->manualcomment, $states[$j]->grade); + $replaystate->manualcomment, $replaystate->manualcommentformat, $states[$j]->grade); if (is_string($error)) { echo $OUTPUT->notification($error); } @@ -1939,7 +1940,7 @@ function question_print_comment_fields($question, $state, $prefix, $cmoptions, $ * @return mixed true on success, a string error message if a problem is detected * (for example score out of range). */ -function question_process_comment($question, &$state, &$attempt, $comment, $grade) { +function question_process_comment($question, &$state, &$attempt, $comment, $commentformat, $grade) { global $DB; $grade = trim($grade); @@ -1954,6 +1955,7 @@ function question_process_comment($question, &$state, &$attempt, $comment, $grad // Update the comment and save it in the database $comment = trim($comment); $state->manualcomment = $comment; + $state->manualcommentformat = $commentformat; $state->newflaggedstate = $state->flagged; $DB->set_field('question_sessions', 'manualcomment', $comment, array('attemptid'=>$attempt->uniqueid, 'questionid'=>$question->id)); diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index 97f5d218cb4..7580482a41d 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -895,7 +895,7 @@ class quiz_attempt extends quiz { * @return mixed true on success, a string error message if a problem is detected * (for example score out of range). */ - public function process_comment($questionid, $comment, $grade) { + public function process_comment($questionid, $comment, $commentformat, $grade) { // I am not sure it is a good idea to have update methods here - this // class is only about getting data out of the question engine, and // helping to display it, apart from this. @@ -904,7 +904,7 @@ class quiz_attempt extends quiz { $state = $this->states[$questionid]; $error = question_process_comment($this->questions[$questionid], - $state, $this->attempt, $comment, $grade); + $state, $this->attempt, $comment, $commentformat, $grade); // If the state was update (successfully), save the changes. if (!is_string($error) && $state->changed) { diff --git a/mod/quiz/comment.php b/mod/quiz/comment.php index 02a31d60b97..66b1d9403db 100644 --- a/mod/quiz/comment.php +++ b/mod/quiz/comment.php @@ -44,7 +44,7 @@ /// Process any data that was submitted. if ($data = data_submitted() and confirm_sesskey()) { $error = $attemptobj->process_comment($questionid, - $data->response['comment'], $data->response['grade']); + $data->response['comment'], FORMAT_HTML, $data->response['grade']); /// If success, notify and print a close button. if (!is_string($error)) { diff --git a/mod/quiz/db/upgrade.php b/mod/quiz/db/upgrade.php index ca78ed81fe3..a38e4c9850f 100644 --- a/mod/quiz/db/upgrade.php +++ b/mod/quiz/db/upgrade.php @@ -282,7 +282,7 @@ function xmldb_quiz_upgrade($oldversion) { // conditionally migrate to html format in intro if ($CFG->texteditors !== 'textarea') { - $rs = $DB->get_recordset('quiz', array('introformat'=>FORMAT_MOODLE), '', 'id,intro,introformat'); + $rs = $DB->get_recordset('quiz', array('introformat' => FORMAT_MOODLE), '', 'id,intro,introformat'); foreach ($rs as $q) { $q->intro = text_to_html($q->intro, false, false, true); $q->introformat = FORMAT_HTML; @@ -352,6 +352,8 @@ function xmldb_quiz_upgrade($oldversion) { $dbman->add_field($table, $field); } + // This column defaults to FORMAT_MOODLE, which is correct. + // quiz savepoint reached upgrade_mod_savepoint(true, 2010080600, 'quiz'); } diff --git a/mod/quiz/report/grading/report.php b/mod/quiz/report/grading/report.php index f956b209ec6..4cf45499e32 100644 --- a/mod/quiz/report/grading/report.php +++ b/mod/quiz/report/grading/report.php @@ -130,7 +130,8 @@ class quiz_grading_report extends quiz_default_report { $state = &$states[$question->id]; // the following will update the state and attempt - $error = question_process_comment($question, $state, $attempt, $response['comment'], $response['grade']); + $error = question_process_comment($question, $state, $attempt, + $response['comment'], FORMAT_HTML, $response['grade']); if (is_string($error)) { echo $OUTPUT->notification($error); $allok = false; diff --git a/question/type/calculated/db/upgrade.php b/question/type/calculated/db/upgrade.php index ce05a3ac657..d7360737ffc 100644 --- a/question/type/calculated/db/upgrade.php +++ b/question/type/calculated/db/upgrade.php @@ -165,26 +165,26 @@ function xmldb_qtype_calculated_upgrade($oldversion) { $dbman->add_field($table, $field); } - // fix fieldformat - $rs = $DB->get_recordset('question_calculated_options'); + // In the past, the correctfeedback, partiallycorrectfeedback, + // incorrectfeedback columns were assumed to contain content of the same + // form as questiontextformat. If we are using the HTML editor, then + // convert FORMAT_MOODLE content to FORMAT_HTML. + $rs = $DB->get_recordset_sql(' + SELECT qco.*, q.oldquestiontextformat + FROM {question_calculated_options} qco + JOIN {question} q ON qco.question = q.id'); foreach ($rs as $record) { - if ($CFG->texteditors !== 'textarea') { - if (!empty($record->correctfeedback)) { - $record->correctfeedback = text_to_html($record->correctfeedback); - } + if ($CFG->texteditors !== 'textarea' && $record->oldquestiontextformat == FORMAT_MOODLE) { + $record->correctfeedback = text_to_html($record->correctfeedback, false, false, true); $record->correctfeedbackformat = FORMAT_HTML; - if (!empty($record->partiallycorrectfeedback)) { - $record->partiallycorrectfeedback = text_to_html($record->partiallycorrectfeedback); - } + $record->partiallycorrectfeedback = text_to_html($record->partiallycorrectfeedback, false, false, true); $record->partiallycorrectfeedbackformat = FORMAT_HTML; - if (!empty($record->incorrectfeedback)) { - $record->incorrectfeedback = text_to_html($record->incorrectfeedback); - } + $record->incorrectfeedback = text_to_html($record->incorrectfeedback, false, false, true); $record->incorrectfeedbackformat = FORMAT_HTML; } else { - $record->correctfeedbackformat = FORMAT_MOODLE; - $record->partiallycorrectfeedbackformat = FORMAT_MOODLE; - $record->incorrectfeedbackformat = FORMAT_MOODLE; + $record->correctfeedbackformat = $record->oldquestiontextformat; + $record->partiallycorrectfeedback = $record->oldquestiontextformat; + $record->incorrectfeedbackformat = $record->oldquestiontextformat; } $DB->update_record('question_calculated_options', $record); } diff --git a/question/type/description/questiontype.php b/question/type/description/questiontype.php index c3e8fb812c0..ecb3b38cfbf 100644 --- a/question/type/description/questiontype.php +++ b/question/type/description/questiontype.php @@ -72,7 +72,7 @@ class description_qtype extends default_questiontype { $generalfeedback = ''; if ($isfinished && $options->generalfeedback) { $generalfeedback = $this->format_text($question->generalfeedback, - $question->questiontextformat, $cmoptions); + $question->generalfeedbackformat, $cmoptions); } include "$CFG->dirroot/question/type/description/question.html"; diff --git a/question/type/essay/questiontype.php b/question/type/essay/questiontype.php index 7c8395159aa..8fb9a8c871b 100644 --- a/question/type/essay/questiontype.php +++ b/question/type/essay/questiontype.php @@ -105,7 +105,7 @@ class question_essay_qtype extends default_questiontype { if (isset($state->responses[''])) { $value = $state->responses['']; } else { - $value = ""; + $value = ''; } // answer diff --git a/question/type/match/db/upgrade.php b/question/type/match/db/upgrade.php index f634514b455..99cb72ee1fa 100644 --- a/question/type/match/db/upgrade.php +++ b/question/type/match/db/upgrade.php @@ -36,15 +36,19 @@ function xmldb_qtype_match_upgrade($oldversion) { $dbman->add_field($table, $field); } - $rs = $DB->get_recordset('question_match_sub'); + // In the past, question_match_sub.questiontext assumed to contain + // content of the same form as question.questiontextformat. If we are + // using the HTML editor, then convert FORMAT_MOODLE content to FORMAT_HTML. + $rs = $DB->get_recordset_sql(' + SELECT qms.*, q.oldquestiontextformat + FROM {question_match_sub} qms + JOIN {question} q ON qms.question = q.id'); foreach ($rs as $record) { - if ($CFG->texteditors !== 'textarea') { - if (!empty($record->questiontext)) { - $record->questiontext = text_to_html($record->questiontext); - } + if ($CFG->texteditors !== 'textarea' && $record->oldquestiontextformat == FORMAT_MOODLE) { + $record->questiontext = text_to_html($record->questiontext, false, false, true); $record->questiontextformat = FORMAT_HTML; } else { - $record->questiontextformat = FORMAT_MOODLE; + $record->questiontextformat = $record->oldquestiontextformat; } $DB->update_record('question_match_sub', $record); } diff --git a/question/type/missingtype/questiontype.php b/question/type/missingtype/questiontype.php index d0d450a1538..b728f840b4b 100644 --- a/question/type/missingtype/questiontype.php +++ b/question/type/missingtype/questiontype.php @@ -48,7 +48,7 @@ class question_missingtype_qtype extends default_questiontype { if ($answers) { foreach ($answers as $answer) { $a = new stdClass; - $a->text = format_text("$answer->answer", FORMAT_MOODLE, $formatoptions, $cmoptions->course); + $a->text = format_text($answer->answer, $answer->answerformat, $formatoptions, $cmoptions->course); $anss[] = clone($a); } diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php index 38beac0ac2f..b32cd6105bf 100644 --- a/question/type/multianswer/questiontype.php +++ b/question/type/multianswer/questiontype.php @@ -527,11 +527,11 @@ class embedded_cloze_qtype extends default_questiontype { // Print the answer text: no automatic numbering - $a->text =format_text($mcanswer->answer, FORMAT_MOODLE, $formatoptions, $cmoptions->course); + $a->text = format_text($mcanswer->answer, $mcanswer->answerformat, $formatoptions, $cmoptions->course); // Print feedback if feedback is on if (($options->feedback || $options->correct_responses) && ($checked )) { //|| $options->readonly - $a->feedback = format_text($mcanswer->feedback, true, $formatoptions, $cmoptions->course); + $a->feedback = format_text($mcanswer->feedback, $mcanswer->feedbackformat, $formatoptions, $cmoptions->course); } else { $a->feedback = ''; } diff --git a/question/type/multichoice/db/upgrade.php b/question/type/multichoice/db/upgrade.php index 9d8cda221eb..3c8eed3a33f 100644 --- a/question/type/multichoice/db/upgrade.php +++ b/question/type/multichoice/db/upgrade.php @@ -80,25 +80,26 @@ function xmldb_qtype_multichoice_upgrade($oldversion) { $dbman->add_field($table, $field); } - $rs = $DB->get_recordset('question_multichoice'); + // In the past, the correctfeedback, partiallycorrectfeedback, + // incorrectfeedback columns were assumed to contain content of the same + // form as questiontextformat. If we are using the HTML editor, then + // convert FORMAT_MOODLE content to FORMAT_HTML. + $rs = $DB->get_recordset_sql(' + SELECT qm.*, q.oldquestiontextformat + FROM {question_multichoice} qm + JOIN {question} q ON qm.question = q.id'); foreach ($rs as $record) { - if ($CFG->texteditors !== 'textarea') { - if (!empty($record->correctfeedback)) { - $record->correctfeedback = text_to_html($record->correctfeedback); - } + if ($CFG->texteditors !== 'textarea' && $record->oldquestiontextformat == FORMAT_MOODLE) { + $record->correctfeedback = text_to_html($record->correctfeedback, false, false, true); $record->correctfeedbackformat = FORMAT_HTML; - if (!empty($record->partiallycorrectfeedback)) { - $record->partiallycorrectfeedback = text_to_html($record->partiallycorrectfeedback); - } + $record->partiallycorrectfeedback = text_to_html($record->partiallycorrectfeedback, false, false, true); $record->partiallycorrectfeedbackformat = FORMAT_HTML; - if (!empty($record->incorrectfeedback)) { - $record->incorrectfeedback = text_to_html($record->incorrectfeedback); - } + $record->incorrectfeedback = text_to_html($record->incorrectfeedback, false, false, true); $record->incorrectfeedbackformat = FORMAT_HTML; } else { - $record->correctfeedbackformat = FORMAT_MOODLE; - $record->partiallycorrectfeedbackformat = FORMAT_MOODLE; - $record->incorrectfeedbackformat = FORMAT_MOODLE; + $record->correctfeedbackformat = $record->oldquestiontextformat; + $record->partiallycorrectfeedback = $record->oldquestiontextformat; + $record->incorrectfeedbackformat = $record->oldquestiontextformat; } $DB->update_record('question_multichoice', $record); } diff --git a/question/type/multichoice/questiontype.php b/question/type/multichoice/questiontype.php index 10a2da3a5de..ee3e506f232 100644 --- a/question/type/multichoice/questiontype.php +++ b/question/type/multichoice/questiontype.php @@ -126,25 +126,25 @@ class question_multichoice_qtype extends default_questiontype { foreach (array('correct', 'partiallycorrect', 'incorrect') as $feedbacktype) { $feedbackname = $feedbacktype . 'feedback'; - $feedbackformat = $feedbackname . 'format'; - $feedbackfiles = $feedbackname . 'files'; $feedback = $question->$feedbackname; - $options->$feedbackformat = trim($feedback['format']); + $feedbackformatname = $feedbackname . 'format'; $options->$feedbackname = trim($feedback['text']); + $options->$feedbackformatname = trim($feedback['format']); if (isset($feedback['files'])) { // import foreach ($feedback['files'] as $file) { $this->import_file($context, 'qtype_multichoice', $feedbackname, $question->id, $file); } } else { - $options->$feedbackname = file_save_draft_area_files($feedback['itemid'], $context->id, 'qtype_multichoice', $feedbackname, $question->id, self::$fileoptions, trim($feedback['text'])); + $options->$feedbackname = file_save_draft_area_files( + $feedback['itemid'], $context->id, 'qtype_multichoice', $feedbackname, $question->id, self::$fileoptions, trim($feedback['text'])); } } if ($update) { - $DB->update_record("question_multichoice", $options); + $DB->update_record('question_multichoice', $options); } else { - $DB->insert_record("question_multichoice", $options); + $DB->insert_record('question_multichoice', $options); } // delete old answer records @@ -441,10 +441,6 @@ class question_multichoice_qtype extends default_questiontype { return $responses; } - - function format_response($response, $format){ - return $this->format_text($response, $format); - } /** * @param object $question * @return mixed either a integer score out of 1 that the average random diff --git a/question/type/numerical/db/upgrade.php b/question/type/numerical/db/upgrade.php index 96b547a5993..b679aaae189 100644 --- a/question/type/numerical/db/upgrade.php +++ b/question/type/numerical/db/upgrade.php @@ -62,15 +62,19 @@ function xmldb_qtype_numerical_upgrade($oldversion) { $dbman->add_field($table, $field); } - $rs = $DB->get_recordset('question_numerical_options'); + // In the past, question_match_sub.questiontext assumed to contain + // content of the same form as question.questiontextformat. If we are + // using the HTML editor, then convert FORMAT_MOODLE content to FORMAT_HTML. + $rs = $DB->get_recordset_sql(' + SELECT qno.*, q.oldquestiontextformat + FROM {question_numerical_options} qno + JOIN {question} q ON qno = q.id'); foreach ($rs as $record) { - if ($CFG->texteditors !== 'textarea') { - if (!empty($record->instructions)) { - $record->instructions = text_to_html($record->instructions); - } + if ($CFG->texteditors !== 'textarea' && $record->oldquestiontextformat == FORMAT_MOODLE) { + $record->instructions = text_to_html($record->questiontext, false, false, true); $record->instructionsformat = FORMAT_HTML; } else { - $record->instructionsformat = FORMAT_MOODLE; + $record->instructionsformat = $record->oldquestiontextformat; } $DB->update_record('question_numerical_options', $record); } diff --git a/question/type/numerical/display.html b/question/type/numerical/display.html index 5148b6b5886..12d678d507e 100644 --- a/question/type/numerical/display.html +++ b/question/type/numerical/display.html @@ -41,11 +41,7 @@ ?>
- - value ="" /> + value ="" />
options->showunits == NUMERICALQUESTIONUNITTEXTINPUTDISPLAY ) {// display unit text input @@ -100,27 +96,15 @@ - - /> - options->units[0]->unit ; - - echo '  ' ; - ?> + /> + options->units[0]->unit; echo '  '; ?> options->showunits == NUMERICALQUESTIONUNITMULTICHOICEDISPLAY){?> - - - options->units)){?> @@ -133,7 +117,7 @@ -multiplier is true then @@ -204,9 +188,9 @@ $a->id = $question->name_prefix."unit" ;//. "2" $a->class = '' ; $a->feedbackimg = ''; - + $a->control = ""; - + if ($options->correct_responses && $classunit > 0 ) { //$answer->fraction $a->class = question_get_feedback_class($classunit); } @@ -216,9 +200,8 @@ // Print the control // Print the answer text - $a->text = format_text($unit->unit, FORMAT_MOODLE, $formatoptions, $cmoptions->course); + $a->text = s($unit->unit); $row = 0 ; - ?>
@@ -281,7 +264,7 @@
- options->instructions, $question->options->instructionsformat, $formatoptions, $cmoptions->course);?> + options->instructions, $question->options->instructionsformat, $formatoptions, $cmoptions->course);?>
diff --git a/question/type/numerical/questiontype.php b/question/type/numerical/questiontype.php index eb4b81fcc86..52cc955774f 100644 --- a/question/type/numerical/questiontype.php +++ b/question/type/numerical/questiontype.php @@ -643,24 +643,19 @@ class question_numerical_qtype extends question_shortanswer_qtype { break ; } } - } // else - - // } + } } - } - } + } } if ($answer->feedback) { $answer->feedback = quiz_rewrite_question_urls($answer->feedback, 'pluginfile.php', $context->id, 'question', 'answerfeedback', array($state->attempt, $state->question), $answer->id); - $feedback = format_text($answer->feedback, true, $formatoptions, $cmoptions->course); + $feedback = format_text($answer->feedback, $answer->feedbackformat, $formatoptions, $cmoptions->course); } break; } } - - } $state->options->raw_unitpenalty = 0 ; $raw_unitpenalty = 0 ; diff --git a/question/type/questiontype.php b/question/type/questiontype.php index 7e10310113b..761a572ed5f 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -963,7 +963,7 @@ class default_questiontype { $formatoptions = new stdClass; $formatoptions->para = false; - $comment = format_text($state->manualcomment, FORMAT_HTML, + $comment = format_text($state->manualcomment, $state->manualcommentformat, $formatoptions, $cmoptions->course); $commentlink = ''; diff --git a/question/type/shortanswer/questiontype.php b/question/type/shortanswer/questiontype.php index 412842e9ace..63ebbffe6b0 100644 --- a/question/type/shortanswer/questiontype.php +++ b/question/type/shortanswer/questiontype.php @@ -209,7 +209,7 @@ class question_shortanswer_qtype extends default_questiontype { $feedbackimg = question_get_feedback_image($answer->fraction); if ($answer->feedback) { $answer->feedback = quiz_rewrite_question_urls($answer->feedback, 'pluginfile.php', $context->id, 'question', 'answerfeedback', array($state->attempt, $state->question), $answer->id); - $feedback = format_text($answer->feedback, true, $formatoptions, $cmoptions->course); + $feedback = format_text($answer->feedback, $answer->feedbackformat, $formatoptions, $cmoptions->course); } break; } diff --git a/question/type/truefalse/questiontype.php b/question/type/truefalse/questiontype.php index 1f06e1ae2ad..7663b0ee308 100644 --- a/question/type/truefalse/questiontype.php +++ b/question/type/truefalse/questiontype.php @@ -251,7 +251,7 @@ class question_truefalse_qtype extends default_questiontype { if ($options->feedback and isset($answers[$response])) { $chosenanswer = $answers[$response]; $chosenanswer->feedback = quiz_rewrite_question_urls($chosenanswer->feedback, 'pluginfile.php', $context->id, 'question', 'answerfeedback', array($state->attempt, $state->question), $chosenanswer->id); - $feedback = format_text($chosenanswer->feedback, true, $formatoptions, $cmoptions->course); + $feedback = format_text($chosenanswer->feedback, $chosenanswer->feedbackformat, $formatoptions, $cmoptions->course); } include("$CFG->dirroot/question/type/truefalse/display.html");