mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-20636 Review and fix the format parameter to all calls to format_text.
This commit is contained in:
parent
a18fda20c4
commit
22cebed503
20 changed files with 100 additions and 69 deletions
|
@ -1123,10 +1123,9 @@ class quiz_question_bank_view extends question_bank_view {
|
|||
echo '<div class="categoryinfo"><div class="categorynamefieldcontainer">' .
|
||||
$strcategory;
|
||||
echo ': <span class="categorynamefield">';
|
||||
echo shorten_text(strip_tags(format_text($category->name, FORMAT_MOODLE,
|
||||
$formatoptions, $this->course->id)), 60);
|
||||
echo shorten_text(strip_tags(format_string($category->name)), 60);
|
||||
echo '</span></div><div class="categoryinfofieldcontainer"><span class="categoryinfofield">';
|
||||
echo shorten_text(strip_tags(format_text($category->info, FORMAT_MOODLE,
|
||||
echo shorten_text(strip_tags(format_text($category->info, $category->infoformat,
|
||||
$formatoptions, $this->course->id)), 200);
|
||||
echo '</span></div></div>';
|
||||
}
|
||||
|
|
|
@ -1220,7 +1220,7 @@ class question_bank_view {
|
|||
$formatoptions->noclean = true;
|
||||
$formatoptions->overflowdiv = true;
|
||||
echo '<div class="boxaligncenter">';
|
||||
echo format_text($category->info, FORMAT_MOODLE, $formatoptions, $this->course->id);
|
||||
echo format_text($category->info, $category->infoformat, $formatoptions, $this->course->id);
|
||||
echo "</div>\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -113,6 +113,8 @@ class test_question_maker {
|
|||
$tf->rightanswer = true;
|
||||
$tf->truefeedback = 'This is the right answer.';
|
||||
$tf->falsefeedback = 'This is the wrong answer.';
|
||||
$tf->truefeedbackformat = FORMAT_HTML;
|
||||
$tf->falsefeedbackformat = FORMAT_HTML;
|
||||
$tf->trueanswerid = 13;
|
||||
$tf->falseanswerid = 14;
|
||||
|
||||
|
@ -193,10 +195,13 @@ class test_question_maker {
|
|||
|
||||
self::set_standard_combined_feedback_fields($match);
|
||||
|
||||
// Using unset to get 1-based arrays.
|
||||
$match->stems = array('', 'Dog', 'Frog', 'Toad', 'Cat');
|
||||
$match->stemformat = array('', FORMAT_HTML, FORMAT_HTML, FORMAT_HTML, FORMAT_HTML);
|
||||
$match->choices = array('', 'Mammal', 'Amphibian', 'Insect');
|
||||
$match->right = array('', 1, 2, 2, 1);
|
||||
unset($match->stems[0]);
|
||||
unset($match->stemformat[0]);
|
||||
unset($match->choices[0]);
|
||||
unset($match->right[0]);
|
||||
|
||||
|
|
|
@ -846,14 +846,8 @@ class qformat_default {
|
|||
global $DB;
|
||||
$formatoptions = new stdClass();
|
||||
$formatoptions->noclean = true;
|
||||
$formatoptions->para = false;
|
||||
if (empty($question->questiontextformat)) {
|
||||
$format = FORMAT_MOODLE;
|
||||
} else {
|
||||
$format = $question->questiontextformat;
|
||||
}
|
||||
$text = $question->questiontext;
|
||||
return format_text(html_to_text($text, 0, false), $format, $formatoptions);
|
||||
return html_to_text(format_text($question->questiontext,
|
||||
$this->questiontextformat, $formatoptions), 0, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,11 +67,9 @@ function writequestion($question) {
|
|||
// add header
|
||||
$expout .= "<h3>$question->name</h3>\n";
|
||||
|
||||
// format and add question text
|
||||
$questiontext = $question->questiontext;
|
||||
$format = $question->questiontextformat;
|
||||
$formatted_text = format_text($questiontext, $format);
|
||||
$expout .= "<p class=\"questiontext\">$formatted_text</p>\n";
|
||||
// Format and add the question text
|
||||
$expout .= '<p class="questiontext">' . format_text($question->questiontext,
|
||||
$question->questiontextformat); . "</p>\n";
|
||||
|
||||
// selection depends on question type
|
||||
switch($question->qtype) {
|
||||
|
|
|
@ -97,12 +97,12 @@ abstract class qtype_gapselect_question_base extends question_graded_automatical
|
|||
}
|
||||
|
||||
public function get_question_summary() {
|
||||
$question = $this->html_to_text($this->questiontext);
|
||||
$question = $this->html_to_text($this->questiontext, $this->questiontextformat);
|
||||
$groups = array();
|
||||
foreach ($this->choices as $group => $choices) {
|
||||
$cs = array();
|
||||
foreach ($choices as $choice) {
|
||||
$cs[] = $this->html_to_text($choice->text);
|
||||
$cs[] = html_to_text($choice->text, 0, false);
|
||||
}
|
||||
$groups[] = '[[' . $group . ']] -> {' . implode(' / ', $cs) . '}';
|
||||
}
|
||||
|
@ -120,8 +120,8 @@ abstract class qtype_gapselect_question_base extends question_graded_automatical
|
|||
foreach ($this->places as $place => $group) {
|
||||
if (array_key_exists($this->field($place), $response) &&
|
||||
$response[$this->field($place)]) {
|
||||
$choices[] = '{' . $this->html_to_text($this->get_selected_choice(
|
||||
$group, $response[$this->field($place)])->text) . '}';
|
||||
$choices[] = '{' . html_to_text($this->get_selected_choice(
|
||||
$group, $response[$this->field($place)])->text, 0, false) . '}';
|
||||
$allblank = false;
|
||||
} else {
|
||||
$choices[] = '{}';
|
||||
|
@ -286,7 +286,7 @@ abstract class qtype_gapselect_question_base extends question_graded_automatical
|
|||
$choiceno = $this->choiceorder[$group][$response[$fieldname]];
|
||||
$choice = $this->choices[$group][$choiceno];
|
||||
$parts[$place] = new question_classified_response(
|
||||
$choiceno, $this->html_to_text($choice->text),
|
||||
$choiceno, html_to_text($choice->text, 0, false),
|
||||
$this->get_right_choice_for($place) == $response[$fieldname]);
|
||||
}
|
||||
return $parts;
|
||||
|
|
|
@ -297,7 +297,7 @@ abstract class qtype_gapselect_base extends question_type {
|
|||
|
||||
foreach ($question->choices[$group] as $i => $choice) {
|
||||
$choices[$i] = new question_possible_response(
|
||||
$question->html_to_text($choice->text),
|
||||
html_to_text($choice->text, 0, false),
|
||||
$question->rightchoices[$place] == $i);
|
||||
}
|
||||
$choices[null] = question_possible_response::no_response();
|
||||
|
|
|
@ -51,7 +51,7 @@ abstract class qtype_elements_embedded_in_question_text_renderer extends qtype_w
|
|||
|
||||
$result = '';
|
||||
$result .= html_writer::tag('div', $question->format_text($questiontext,
|
||||
$qa, 'question', 'questiontext', $question->id),
|
||||
$question->questiontextformat, $qa, 'question', 'questiontext', $question->id),
|
||||
array('class' => $this->qtext_classname(), 'id' => $qa->get_qt_field_name('')));
|
||||
|
||||
$result .= $this->post_qtext_elements($qa, $options);
|
||||
|
|
|
@ -88,10 +88,10 @@ class qtype_match_question extends question_graded_automatically_with_countback
|
|||
}
|
||||
|
||||
public function get_question_summary() {
|
||||
$question = $this->html_to_text($this->questiontext);
|
||||
$question = $this->html_to_text($this->questiontext, $this->questiontextformat);
|
||||
$stems = array();
|
||||
foreach ($this->stemorder as $stemid) {
|
||||
$stems[] = $this->html_to_text($this->stems[$stemid]);
|
||||
$stems[] = $this->html_to_text($this->stems[$stemid], $this->stemformat[$stemid]);
|
||||
}
|
||||
$choices = array();
|
||||
foreach ($this->choiceorder as $choiceid) {
|
||||
|
@ -105,8 +105,8 @@ class qtype_match_question extends question_graded_automatically_with_countback
|
|||
$matches = array();
|
||||
foreach ($this->stemorder as $key => $stemid) {
|
||||
if (array_key_exists($this->field($key), $response) && $response[$this->field($key)]) {
|
||||
$matches[] = $this->html_to_text($this->stems[$stemid]) . ' -> ' .
|
||||
$this->choices[$this->choiceorder[$response[$this->field($key)]]];
|
||||
$matches[] = $this->html_to_text($this->stems[$stemid], $this->stemformat[$stemid]) .
|
||||
' -> ' . $this->choices[$this->choiceorder[$response[$this->field($key)]]];
|
||||
}
|
||||
}
|
||||
if (empty($matches)) {
|
||||
|
|
|
@ -149,6 +149,7 @@ class qtype_match extends question_type {
|
|||
|
||||
if ($matchsub->questiontext !== '') {
|
||||
$question->stems[$matchsub->id] = $matchsub->questiontext;
|
||||
$question->stemformat[$matchsub->id] = $matchsub->questiontextformat;
|
||||
$question->right[$matchsub->id] = $key;
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +182,7 @@ class qtype_match extends question_type {
|
|||
$responses = array();
|
||||
foreach ($q->choices as $choiceid => $choice) {
|
||||
$responses[$choiceid] = new question_possible_response(
|
||||
$q->html_to_text($stem) . ': ' . $q->html_to_text($choice),
|
||||
$q->html_to_text($stem, $q->stemformat[$stemid]) . ': ' . $choice,
|
||||
($choiceid == $q->right[$stemid]) / count($q->stems));
|
||||
}
|
||||
$responses[null] = question_possible_response::no_response();
|
||||
|
|
|
@ -59,7 +59,8 @@ class qtype_match_renderer extends qtype_with_combined_feedback_renderer {
|
|||
$result .= html_writer::start_tag('tr', array('class' => 'r' . $parity));
|
||||
$fieldname = 'sub' . $key;
|
||||
|
||||
$result .= html_writer::tag('td', $question->format_text($question->stems[$stemid],
|
||||
$result .= html_writer::tag('td', $question->format_text(
|
||||
$question->stems[$stemid], $question->stemformat[$stemid],
|
||||
$qa, 'qtype_match', 'subquestion', $stemid),
|
||||
array('class' => 'text'));
|
||||
|
||||
|
@ -120,7 +121,8 @@ class qtype_match_renderer extends qtype_with_combined_feedback_renderer {
|
|||
$choices = $this->format_choices($question);
|
||||
$right = array();
|
||||
foreach ($stemorder as $key => $stemid) {
|
||||
$right[] = $question->format_text($question->stems[$stemid], $qa,
|
||||
$right[] = $question->format_text($question->stems[$stemid],
|
||||
$question->stemformat[$stemid], $qa,
|
||||
'qtype_match', 'subquestion', $stemid) . ' – ' .
|
||||
$choices[$question->get_right_choice_for($stemid)];
|
||||
}
|
||||
|
|
|
@ -76,10 +76,26 @@ class qtype_match_test extends UnitTestCase {
|
|||
test_question_maker::set_standard_combined_feedback_fields($q->options);
|
||||
|
||||
$q->options->subquestions = array(
|
||||
14 => (object) array('id' => 14, 'questiontext' => 'frog', 'answertext' => 'amphibian'),
|
||||
15 => (object) array('id' => 15, 'questiontext' => 'cat', 'answertext' => 'mammal'),
|
||||
16 => (object) array('id' => 16, 'questiontext' => 'newt', 'answertext' => 'amphibian'),
|
||||
17 => (object) array('id' => 17, 'questiontext' => '', 'answertext' => 'insect'),
|
||||
14 => (object) array(
|
||||
'id' => 14,
|
||||
'questiontext' => 'frog',
|
||||
'questiontextformat' => FORMAT_HTML,
|
||||
'answertext' => 'amphibian'),
|
||||
15 => (object) array(
|
||||
'id' => 15,
|
||||
'questiontext' => 'cat',
|
||||
'questiontextformat' => FORMAT_HTML,
|
||||
'answertext' => 'mammal'),
|
||||
16 => (object) array(
|
||||
'id' => 16,
|
||||
'questiontext' => 'newt',
|
||||
'questiontextformat' => FORMAT_HTML,
|
||||
'answertext' => 'amphibian'),
|
||||
17 => (object) array(
|
||||
'id' => 17,
|
||||
'questiontext' => '',
|
||||
'questiontextformat' => FORMAT_HTML,
|
||||
'answertext' => 'insect'),
|
||||
);
|
||||
|
||||
return $q;
|
||||
|
|
|
@ -68,10 +68,11 @@ abstract class qtype_multichoice_base extends question_graded_automatically {
|
|||
}
|
||||
|
||||
public function get_question_summary() {
|
||||
$question = $this->html_to_text($this->questiontext);
|
||||
$question = $this->html_to_text($this->questiontext, $this->questiontextformat);
|
||||
$choices = array();
|
||||
foreach ($this->order as $ansid) {
|
||||
$choices[] = $this->html_to_text($this->answers[$ansid]->answer);
|
||||
$choices[] = $this->html_to_text($this->answers[$ansid]->answer,
|
||||
$this->answers[$ansid]->answerformat);
|
||||
}
|
||||
return $question . ': ' . implode('; ', $choices);
|
||||
}
|
||||
|
@ -157,7 +158,8 @@ class qtype_multichoice_single_question extends qtype_multichoice_base {
|
|||
return null;
|
||||
}
|
||||
$ansid = $this->order[$response['answer']];
|
||||
return $this->html_to_text($this->answers[$ansid]->answer);
|
||||
return $this->html_to_text($this->answers[$ansid]->answer,
|
||||
$this->answers[$ansid]->answerformat);
|
||||
}
|
||||
|
||||
public function classify_response(array $response) {
|
||||
|
@ -168,7 +170,7 @@ class qtype_multichoice_single_question extends qtype_multichoice_base {
|
|||
$choiceid = $this->order[$response['answer']];
|
||||
$ans = $this->answers[$choiceid];
|
||||
return array($this->id => new question_classified_response($choiceid,
|
||||
$this->html_to_text($ans->answer), $ans->fraction));
|
||||
$this->html_to_text($ans->answer, $ans->answerformat), $ans->fraction));
|
||||
}
|
||||
|
||||
public function get_correct_response() {
|
||||
|
@ -283,7 +285,8 @@ class qtype_multichoice_multi_question extends qtype_multichoice_base {
|
|||
foreach ($this->order as $key => $ans) {
|
||||
$fieldname = $this->field($key);
|
||||
if (array_key_exists($fieldname, $response) && $response[$fieldname]) {
|
||||
$selectedchoices[] = $this->html_to_text($this->answers[$ans]->answer);
|
||||
$selectedchoices[] = $this->html_to_text($this->answers[$ans]->answer,
|
||||
$this->answers[$ans]->answerformat);
|
||||
}
|
||||
}
|
||||
if (empty($selectedchoices)) {
|
||||
|
@ -304,7 +307,7 @@ class qtype_multichoice_multi_question extends qtype_multichoice_base {
|
|||
foreach ($this->answers as $ansid => $ans) {
|
||||
if (isset($selectedchoices[$ansid])) {
|
||||
$choices[$ansid] = new question_classified_response($ansid,
|
||||
$this->html_to_text($ans->answer), $ans->fraction);
|
||||
$this->html_to_text($ans->answer, $ans->answerformat), $ans->fraction);
|
||||
}
|
||||
}
|
||||
return $choices;
|
||||
|
|
|
@ -95,8 +95,8 @@ abstract class qtype_multichoice_renderer_base extends qtype_with_combined_feedb
|
|||
}
|
||||
$radiobuttons[] = $hidden . html_writer::empty_tag('input', $inputattributes) .
|
||||
html_writer::tag('label', $this->number_in_style($value, $question->answernumbering) .
|
||||
$question->format_text($ans->answer, $qa,
|
||||
'question', 'answer', $ansid), array('for' => $inputattributes['id']));
|
||||
$question->format_text($ans->answer, $ans->answerformat,
|
||||
$qa, 'question', 'answer', $ansid), array('for' => $inputattributes['id']));
|
||||
|
||||
// $options->suppresschoicefeedback is a hack specific to the
|
||||
// oumultiresponse question type. It would be good to refactor to
|
||||
|
@ -104,7 +104,8 @@ abstract class qtype_multichoice_renderer_base extends qtype_with_combined_feedb
|
|||
if ($options->feedback && empty($options->suppresschoicefeedback) &&
|
||||
$isselected && trim($ans->feedback)) {
|
||||
$feedback[] = html_writer::tag('div',
|
||||
$question->format_text($ans->feedback, $qa, 'question', 'answerfeedback', $ansid),
|
||||
$question->format_text($ans->feedback, $ans->feedbackformat,
|
||||
$qa, 'question', 'answerfeedback', $ansid),
|
||||
array('class' => 'specificfeedback'));
|
||||
} else {
|
||||
$feedback[] = '';
|
||||
|
@ -224,7 +225,8 @@ class qtype_multichoice_single_renderer extends qtype_multichoice_renderer_base
|
|||
if (question_state::graded_state_for_fraction($ans->fraction) ==
|
||||
question_state::$gradedright) {
|
||||
return get_string('correctansweris', 'qtype_multichoice',
|
||||
$question->format_text($ans->answer, $qa, 'question', 'answer', $ansid));
|
||||
$question->format_text($ans->answer, $ans->answerformat,
|
||||
$qa, 'question', 'answer', $ansid));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,7 +276,8 @@ class qtype_multichoice_multi_renderer extends qtype_multichoice_renderer_base {
|
|||
$right = array();
|
||||
foreach ($question->answers as $ansid => $ans) {
|
||||
if ($ans->fraction > 0) {
|
||||
$right[] = $question->format_text($ans->answer, $qa, 'question', 'answer', $ansid);
|
||||
$right[] = $question->format_text($ans->answer, $ans->answerformat,
|
||||
$qa, 'question', 'answer', $ansid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ abstract class question_definition {
|
|||
* @return string|null a plain text summary of this question.
|
||||
*/
|
||||
public function get_question_summary() {
|
||||
return $this->html_to_text($this->questiontext);
|
||||
return $this->html_to_text($this->questiontext, $this->questiontextformat);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -256,6 +256,7 @@ abstract class question_definition {
|
|||
* this question.
|
||||
*
|
||||
* @param string $text some content that needs to be output.
|
||||
* @param int $format the FORMAT_... constant.
|
||||
* @param question_attempt $qa the question attempt.
|
||||
* @param string $component used for rewriting file area URLs.
|
||||
* @param string $filearea used for rewriting file area URLs.
|
||||
|
@ -263,37 +264,37 @@ abstract class question_definition {
|
|||
* parts of the question do not need to be cleaned, and student input does.
|
||||
* @return string the text formatted for output by format_text.
|
||||
*/
|
||||
public function format_text($text, $qa, $component, $filearea, $itemid, $clean = false) {
|
||||
// TODO format.
|
||||
public function format_text($text, $format, $qa, $component, $filearea, $itemid, $clean = false) {
|
||||
$formatoptions = new stdClass();
|
||||
$formatoptions->noclean = !$clean;
|
||||
$formatoptions->para = false;
|
||||
$text = $qa->rewrite_pluginfile_urls($text, $component, $filearea, $itemid);
|
||||
return format_text($text, $this->questiontextformat, $formatoptions);
|
||||
return format_text($text, $format, $formatoptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert some part of the question text to plain text. This might be used,
|
||||
* for example, by get_response_summary().
|
||||
* @param string $text The HTML to reduce to plain text.
|
||||
* @param int $format the FORMAT_... constant.
|
||||
* @return string the equivalent plain text.
|
||||
*/
|
||||
public function html_to_text($text) {
|
||||
public function html_to_text($text, $format) {
|
||||
$formatoptions = new stdClass();
|
||||
$formatoptions->noclean = true;
|
||||
return html_to_text(format_text($text, $this->questiontextformat, $formatoptions),
|
||||
0, false);
|
||||
return html_to_text(format_text($text, $format, $formatoptions), 0, false);
|
||||
}
|
||||
|
||||
/** @return the result of applying {@link format_text()} to the question text. */
|
||||
public function format_questiontext($qa) {
|
||||
return $this->format_text($this->questiontext, $qa,
|
||||
'question', 'questiontext', $this->id);
|
||||
return $this->format_text($this->questiontext, $this->questiontextformat,
|
||||
$qa, 'question', 'questiontext', $this->id);
|
||||
}
|
||||
|
||||
/** @return the result of applying {@link format_text()} to the general feedback. */
|
||||
public function format_generalfeedback($qa) {
|
||||
return $this->format_text($this->generalfeedback, $qa,
|
||||
'question', 'generalfeedback', $this->id);
|
||||
return $this->format_text($this->generalfeedback, $this->generalfeedbackformat,
|
||||
$qa, 'question', 'generalfeedback', $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -600,7 +601,7 @@ abstract class question_graded_automatically extends question_with_responses
|
|||
}
|
||||
|
||||
public function format_hint(question_hint $hint, question_attempt $qa) {
|
||||
return $this->format_text($hint->hint, $qa, 'question', 'hint', $hint->id);
|
||||
return $this->format_text($hint->hint, $hint->hintformat, $qa, 'question', 'hint', $hint->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -707,6 +708,9 @@ class question_answer {
|
|||
/** @var string the answer. */
|
||||
public $answer;
|
||||
|
||||
/** @var integer one of the FORMAT_... constans. */
|
||||
public $answerformat = FORMAT_PLAIN;
|
||||
|
||||
/** @var number the fraction this answer is worth. */
|
||||
public $fraction;
|
||||
|
||||
|
@ -718,9 +722,12 @@ class question_answer {
|
|||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param int $id the answer.
|
||||
* @param string $answer the answer.
|
||||
* @param int $answerformat the format of the answer.
|
||||
* @param number $fraction the fraction this answer is worth.
|
||||
* @param string $feedback the feedback for this answer.
|
||||
* @param int $feedbackformat the format of the feedback.
|
||||
*/
|
||||
public function __construct($id, $answer, $fraction, $feedback, $feedbackformat) {
|
||||
$this->id = $id;
|
||||
|
|
|
@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/question/engine/lib.php');
|
|||
* for, and the circumstances under which you might need to override it.
|
||||
*
|
||||
* Note: the questiontype API should NOT be considered stable yet. Very few
|
||||
* question tyeps have been produced yet, so we do not yet know all the places
|
||||
* question types have been produced yet, so we do not yet know all the places
|
||||
* where the current API is insufficient. I would rather learn from the
|
||||
* experiences of the first few question type implementors, and improve the
|
||||
* interface to meet their needs, rather the freeze the API prematurely and
|
||||
|
|
|
@ -252,10 +252,11 @@ abstract class qtype_with_combined_feedback_renderer extends qtype_renderer {
|
|||
}
|
||||
|
||||
$feedback = '';
|
||||
$feedbackfield = $state->get_feedback_class() . 'feedback';
|
||||
if ($question->$feedbackfield) {
|
||||
$feedback .= $question->format_text($question->$feedbackfield, $qa,
|
||||
'question', $feedbackfield, $question->id);
|
||||
$field = $state->get_feedback_class() . 'feedback';
|
||||
$format = $state->get_feedback_class() . 'feedbackformat';
|
||||
if ($question->$field) {
|
||||
$feedback .= $question->format_text($question->$field, $question->$format,
|
||||
$qa, 'question', $field, $question->id);
|
||||
}
|
||||
|
||||
return $feedback;
|
||||
|
|
|
@ -106,8 +106,8 @@ class qtype_shortanswer_renderer extends qtype_renderer {
|
|||
return '';
|
||||
}
|
||||
|
||||
return $question->format_text($answer->feedback, $qa,
|
||||
'question', 'answerfeedback', $answer->id);
|
||||
return $question->format_text($answer->feedback, $answer->feedbackformat,
|
||||
$qa, 'question', 'answerfeedback', $answer->id);
|
||||
}
|
||||
|
||||
public function correct_response(question_attempt $qa) {
|
||||
|
|
|
@ -137,6 +137,8 @@ class qtype_truefalse extends question_type {
|
|||
}
|
||||
$question->truefeedback = $answers[$questiondata->options->trueanswer]->feedback;
|
||||
$question->falsefeedback = $answers[$questiondata->options->falseanswer]->feedback;
|
||||
$question->truefeedbackformat = $answers[$questiondata->options->trueanswer]->feedbackformat;
|
||||
$question->falsefeedbackformat = $answers[$questiondata->options->falseanswer]->feedbackformat;
|
||||
$question->trueanswerid = $questiondata->options->trueanswer;
|
||||
$question->falseanswerid = $questiondata->options->falseanswer;
|
||||
}
|
||||
|
|
|
@ -127,11 +127,11 @@ class qtype_truefalse_renderer extends qtype_renderer {
|
|||
$response = $qa->get_last_qt_var('answer', '');
|
||||
|
||||
if ($response) {
|
||||
return $question->format_text($question->truefeedback, $qa,
|
||||
'question', 'answerfeedback', $question->trueanswerid);
|
||||
return $question->format_text($question->truefeedback, $question->truefeedbackformat,
|
||||
$qa, 'question', 'answerfeedback', $question->trueanswerid);
|
||||
} else {
|
||||
return $question->format_text($question->falsefeedback, $qa,
|
||||
'question', 'answerfeedback', $question->falseanswerid);
|
||||
return $question->format_text($question->falsefeedback, $question->falsefeedbackformat,
|
||||
$qa, 'question', 'answerfeedback', $question->falseanswerid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue