question upgrade MDL-16094 fix up earlier mistakes in the text format upgrade.

There was a mistake in the text format upgrade in the question bank. The wrong conversions were performed, and the wrong arguments were passed to text_to_html in the conversions that were done.

Also, not all the calls to format_text had been updated to use the values in the new format columns.

I think this change fixes everything, but I have only had very limited time to test it. I am committing it anyway, because that seems to me to be the best way to maximise testing. I think that the new code is certainly better than the old code was.
This commit is contained in:
Tim Hunt 2010-11-11 17:32:25 +00:00
parent d39c651378
commit a9efae50e3
20 changed files with 161 additions and 132 deletions

View File

@ -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);
}

View File

@ -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));

View File

@ -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) {

View File

@ -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)) {

View File

@ -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');
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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";

View File

@ -105,7 +105,7 @@ class question_essay_qtype extends default_questiontype {
if (isset($state->responses[''])) {
$value = $state->responses[''];
} else {
$value = "";
$value = '';
}
// answer

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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 = '';
}

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -41,11 +41,7 @@
?>
<div class="answer">
<input type="hidden"
<?php
echo $nameunit;
?>
value ="" />
<input type="hidden" <?php echo $nameunit; ?> value ="" />
</div>
<?php
} else if ($question->options->showunits == NUMERICALQUESTIONUNITTEXTINPUTDISPLAY ) {// display unit text input
@ -100,27 +96,15 @@
<?php echo get_string('unit', 'quiz');
?>
</legend>
<input type="hidden"
<?php
echo $nameunit; echo $valueunit ;
?>
/>
<?php echo $question->options->units[0]->unit ;
echo '&nbsp; ' ;
?>
<input type="hidden" <?php echo $nameunit; echo $valueunit; ?> />
<?php echo $question->options->units[0]->unit; echo '&nbsp; '; ?>
</fieldset>
</div>
<?php
//display the units as choice
} else if ($question->options->showunits == NUMERICALQUESTIONUNITMULTICHOICEDISPLAY){?>
<?php
//display the units as choice
if ( isset($question->options->units)){?>
@ -133,7 +117,7 @@
</legend>
<table >
<?php
<?php
// the order is not shuffled
//however the unitvalue is related to the number value
// if the response/unit->multiplier is true then
@ -204,9 +188,9 @@
$a->id = $question->name_prefix."unit" ;//. "2"
$a->class = '' ;
$a->feedbackimg = '';
$a->control = "<input $readonly $nameunit $checked $type value=\"$key\" />";
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 ;
?>
<tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>">
<td class="c0 control " style=" ">
@ -281,7 +264,7 @@
<?php echo get_string('instructions', 'auth'); ?>
</legend>
<div>
<?php echo format_text($question->options->instructions, $question->options->instructionsformat, $formatoptions, $cmoptions->course);?>
<?php echo format_text($question->options->instructions, $question->options->instructionsformat, $formatoptions, $cmoptions->course);?>
</div>
</fieldset>
</div>

View File

@ -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 ;

View File

@ -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 = '';

View File

@ -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;
}

View File

@ -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");