Skip to content
Snippets Groups Projects
Commit 937c0aec authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Use the method correct_response from render.php.

parent cbea8642
No related branches found
No related tags found
No related merge requests found
...@@ -365,34 +365,35 @@ class qtype_stack_question extends question_graded_automatically_with_countback ...@@ -365,34 +365,35 @@ class qtype_stack_question extends question_graded_automatically_with_countback
} }
public function format_generalfeedback($qa) { public function format_generalfeedback($qa) {
if (empty($this->generalfeedback)) {
return '';
}
$gftext = new stack_cas_text($this->generalfeedback, $this->session, $this->seed, 't', false, true);
if ($gftext->get_errors()) {
throw new stack_exception('Error rendering the general feedback text: ' . $gftext->get_errors());
}
return $this->format_text(stack_maths::process_display_castext($gftext->get_display_castext()),
$this->generalfeedbackformat, $qa, 'question', 'generalfeedback', $this->id);
}
$feedback = '<hr>'; public function format_correct_response($qa) {
// We need to make sure the inputs are displayed in the order in which they // We need to make sure the inputs are displayed in the order in which they
// occur in the question text. This is not necessarily the order in which they // occur in the question text. This is not necessarily the order in which they
// are listed in the array $this->inputs // are listed in the array $this->inputs
$feedback = '';
$inputs = stack_utils::extract_placeholders($this->questiontextinstantiated, 'input'); $inputs = stack_utils::extract_placeholders($this->questiontextinstantiated, 'input');
foreach ($inputs as $name) { foreach ($inputs as $name) {
$input = $this->inputs[$name]; $input = $this->inputs[$name];
$feedback .= html_writer::tag('p', $input->get_teacher_answer_display($this->session->get_value_key($name), $this->session->get_display_key($name))); $feedback .= html_writer::tag('p', $input->get_teacher_answer_display($this->session->get_value_key($name), $this->session->get_display_key($name)));
} }
if (empty($this->generalfeedback)) {
return $feedback; return $feedback;
} }
$feedback .= '<hr/>';
$gftext = new stack_cas_text($this->generalfeedback, $this->session, $this->seed, 't', false, true);
if ($gftext->get_errors()) {
throw new stack_exception('Error rendering the general feedback text: ' . $gftext->get_errors());
}
return $this->format_text(stack_maths::process_display_castext($feedback.$gftext->get_display_castext()),
$this->generalfeedbackformat, $qa, 'question', 'generalfeedback', $this->id);
}
public function get_expected_data() { public function get_expected_data() {
$expected = array(); $expected = array();
foreach ($this->inputs as $input) { foreach ($this->inputs as $input) {
......
...@@ -430,4 +430,9 @@ class qtype_stack_renderer extends qtype_renderer { ...@@ -430,4 +430,9 @@ class qtype_stack_renderer extends qtype_renderer {
$result = new stack_potentialresponse_tree_state(1, true, $fraction); $result = new stack_potentialresponse_tree_state(1, true, $fraction);
return $this->standard_prt_feedback($qa, $qa->get_question(), $result); return $this->standard_prt_feedback($qa, $qa->get_question(), $result);
} }
public function correct_response(question_attempt $qa) {
$question = $qa->get_question();
return '<hr />'.$question->format_correct_response($qa);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment