mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-47990 qtype_multichoice: fix test response import/export
This commit is contained in:
parent
ebbf039d07
commit
749606288e
@ -212,7 +212,8 @@ class qtype_multichoice_single_question extends qtype_multichoice_base {
|
||||
if (!isset($postdata['answer'])) {
|
||||
return array();
|
||||
} else {
|
||||
return array('answer' => $this->answers[$this->order[$postdata['answer']]]->answer);
|
||||
$answer = $this->answers[$this->order[$postdata['answer']]];
|
||||
return array('answer' => clean_param($answer->answer, PARAM_NOTAGS));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,4 +165,21 @@ class qtype_multichoice_single_question_test extends advanced_testcase {
|
||||
$this->assertEquals('Frog', $mc->make_html_inline('<p>Frog</p><p></p>'));
|
||||
$this->assertEquals('Frog<br />†', $mc->make_html_inline('<p>Frog</p><p>†</p>'));
|
||||
}
|
||||
|
||||
public function test_simulated_post_data() {
|
||||
$mc = test_question_maker::make_a_multichoice_single_question();
|
||||
$mc->shuffleanswers = false;
|
||||
$mc->answers[13]->answer = '<p>A</p>';
|
||||
$mc->answers[14]->answer = '<p>B</p>';
|
||||
$mc->answers[15]->answer = '<p>C</p>';
|
||||
$mc->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$originalresponse = array('answer' => 1);
|
||||
|
||||
$simulated = $mc->get_student_response_values_for_simulation($originalresponse);
|
||||
$this->assertEquals(array('answer' => 'B'), $simulated);
|
||||
|
||||
$reconstucted = $mc->prepare_simulated_post_data($simulated);
|
||||
$this->assertEquals($originalresponse, $reconstucted);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user