MDL-47494 ddwtos: Fix unit tests
This commit is contained in:
@@ -52,12 +52,12 @@ class qtype_ddwtos_question extends qtype_gapselect_question_base {
|
||||
class qtype_ddwtos_choice {
|
||||
public $text;
|
||||
public $draggroup;
|
||||
public $isinfinite;
|
||||
public $infinite;
|
||||
|
||||
public function __construct($text, $draggroup = 1, $isinfinite = false) {
|
||||
public function __construct($text, $draggroup = 1, $infinite = false) {
|
||||
$this->text = $text;
|
||||
$this->draggroup = $draggroup;
|
||||
$this->isinfinite = $isinfinite;
|
||||
$this->infinite = $infinite;
|
||||
}
|
||||
|
||||
public function choice_group() {
|
||||
|
||||
@@ -105,7 +105,8 @@ class qtype_ddwtos extends qtype_gapselect_base {
|
||||
}
|
||||
|
||||
$format->import_combined_feedback($question, $data, true);
|
||||
$format->import_hints($question, $data, true);
|
||||
$format->import_hints($question, $data, true, false,
|
||||
$format->get_format($question->questiontextformat));
|
||||
|
||||
return $question;
|
||||
}
|
||||
@@ -116,7 +117,9 @@ class qtype_ddwtos extends qtype_gapselect_base {
|
||||
$output .= ' <shuffleanswers>' . $question->options->shuffleanswers .
|
||||
"</shuffleanswers>\n";
|
||||
|
||||
$output .= $format->write_combined_feedback($question->options);
|
||||
$output .= $format->write_combined_feedback($question->options,
|
||||
$question->id,
|
||||
$question->contextid);
|
||||
|
||||
foreach ($question->options->answers as $answer) {
|
||||
$options = unserialize($answer->feedback);
|
||||
|
||||
@@ -141,7 +141,7 @@ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_ren
|
||||
$content = str_replace(' ', ' ', $content);
|
||||
|
||||
$infinite = '';
|
||||
if ($choice->isinfinite) {
|
||||
if ($choice->infinite) {
|
||||
$infinite = ' infinite';
|
||||
}
|
||||
|
||||
|
||||
@@ -237,6 +237,7 @@ class qtype_ddwtos_test extends UnitTestCase {
|
||||
$expectedq->hintclearwrong = array(false, true);
|
||||
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($expectedq), $q);
|
||||
$this->assertEqual($expectedq->hint, $q->hint);
|
||||
}
|
||||
|
||||
public function test_xml_import_legacy() {
|
||||
@@ -387,34 +388,34 @@ class qtype_ddwtos_test extends UnitTestCase {
|
||||
|
||||
$expectedq->shuffleanswers = 0;
|
||||
$expectedq->correctfeedback = array('text' => 'Your answer is correct.',
|
||||
'format' => FORMAT_MOODLE, 'files' => array());
|
||||
'format' => FORMAT_HTML, 'files' => array());
|
||||
$expectedq->partiallycorrectfeedback = array(
|
||||
'text' => 'Your answer is partially correct.',
|
||||
'format' => FORMAT_MOODLE, 'files' => array());
|
||||
'format' => FORMAT_HTML, 'files' => array());
|
||||
$expectedq->shownumcorrect = true;
|
||||
$expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.',
|
||||
'format' => FORMAT_MOODLE, 'files' => array());
|
||||
'format' => FORMAT_HTML, 'files' => array());
|
||||
|
||||
$expectedq->choices = array(
|
||||
array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_MOODLE),
|
||||
array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_PLAIN),
|
||||
'choicegroup' => 1, 'infinite' => false),
|
||||
array('answer' => array('text' => 'positive', 'format' => FORMAT_MOODLE),
|
||||
array('answer' => array('text' => 'positive', 'format' => FORMAT_PLAIN),
|
||||
'choicegroup' => 1, 'infinite' => false),
|
||||
array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_MOODLE),
|
||||
array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_PLAIN),
|
||||
'choicegroup' => 1, 'infinite' => false),
|
||||
array('answer' => array('text' => 'negative', 'format' => FORMAT_MOODLE),
|
||||
array('answer' => array('text' => 'negative', 'format' => FORMAT_PLAIN),
|
||||
'choicegroup' => 1, 'infinite' => false),
|
||||
array('answer' => array('text' => '10<sup>7</sup>', 'format' => FORMAT_MOODLE),
|
||||
array('answer' => array('text' => '10<sup>7</sup>', 'format' => FORMAT_PLAIN),
|
||||
'choicegroup' => 2, 'infinite' => false),
|
||||
array('answer' => array('text' => '7', 'format' => FORMAT_MOODLE),
|
||||
array('answer' => array('text' => '7', 'format' => FORMAT_PLAIN),
|
||||
'choicegroup' => 2, 'infinite' => false),
|
||||
array('answer' => array('text' => '1', 'format' => FORMAT_MOODLE),
|
||||
array('answer' => array('text' => '1', 'format' => FORMAT_PLAIN),
|
||||
'choicegroup' => 2, 'infinite' => false),
|
||||
array('answer' => array('text' => '10<sup>-7</sup>', 'format' => FORMAT_MOODLE),
|
||||
array('answer' => array('text' => '10<sup>-7</sup>', 'format' => FORMAT_PLAIN),
|
||||
'choicegroup' => 2, 'infinite' => false),
|
||||
array('answer' => array('text' => 'greater', 'format' => FORMAT_MOODLE),
|
||||
array('answer' => array('text' => 'greater', 'format' => FORMAT_PLAIN),
|
||||
'choicegroup' => 3, 'infinite' => false),
|
||||
array('answer' => array('text' => 'less', 'format' => FORMAT_MOODLE),
|
||||
array('answer' => array('text' => 'less', 'format' => FORMAT_PLAIN),
|
||||
'choicegroup' => 3, 'infinite' => false),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user