MDL-20636 Review and fix the format parameter to all calls to format_text.

This commit is contained in:
Tim Hunt 2011-02-24 20:18:16 +00:00
parent a18fda20c4
commit 22cebed503
20 changed files with 100 additions and 69 deletions

View file

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

View file

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