MDL-41600: qformat_blackboard_six Fix test_import_match fail w/ddmatch

With qtype_ddmatch installed, the unit tests for qformat_blackboard_six
fail as they generate ddmatch questions instead of match ones. This
patch checks for ddmatch and changes the test to expect that instead if
its installed.
This commit is contained in:
Adam Olley
2013-09-10 09:13:31 +09:30
parent 6acbecf531
commit e8c41b0a5f
2 changed files with 30 additions and 4 deletions
@@ -56,8 +56,12 @@ class qformat_blackboard_six_pool_test extends question_testcase {
$q = $questions[5];
// If qtype_ddmatch is installed, the formatter produces ddmatch
// qtypes, not match ones.
$ddmatchisinstalled = question_bank::is_qtype_installed('ddmatch');
$expectedq = new stdClass();
$expectedq->qtype = 'match';
$expectedq->qtype = $ddmatchisinstalled ? 'ddmatch' : 'match';
$expectedq->name = 'Classify the animals.';
$expectedq->questiontext = '<i>Classify the animals.</i>';
$expectedq->questiontextformat = FORMAT_HTML;
@@ -78,8 +82,17 @@ class qformat_blackboard_six_pool_test extends question_testcase {
array('text' => '', 'format' => FORMAT_HTML),
array('text' => 'frog', 'format' => FORMAT_HTML),
array('text' => 'newt', 'format' => FORMAT_HTML));
$expectedq->subanswers = array('mammal', 'insect', 'amphibian', 'amphibian');
if ($ddmatchisinstalled) {
$expectedq->subanswers = array(
array('text' => 'mammal', 'format' => FORMAT_HTML),
array('text' => 'insect', 'format' => FORMAT_HTML),
array('text' => 'amphibian', 'format' => FORMAT_HTML),
array('text' => 'amphibian', 'format' => FORMAT_HTML),
);
} else {
$expectedq->subanswers = array('mammal', 'insect', 'amphibian', 'amphibian');
}
$this->assert(new question_check_specified_fields_expectation($expectedq), $q);
}
@@ -53,8 +53,12 @@ class qformat_blackboard_six_qti_test extends question_testcase {
$questions = $importer->readquestions($xml);
$q = $questions[4];
// If qtype_ddmatch is installed, the formatter produces ddmatch
// qtypes, not match ones.
$ddmatchisinstalled = question_bank::is_qtype_installed('ddmatch');
$expectedq = new stdClass();
$expectedq->qtype = 'match';
$expectedq->qtype = $ddmatchisinstalled ? 'ddmatch' : 'match';
$expectedq->name = 'Classify the animals.';
$expectedq->questiontext = 'Classify the animals.';
$expectedq->questiontextformat = FORMAT_HTML;
@@ -75,7 +79,16 @@ class qformat_blackboard_six_qti_test extends question_testcase {
array('text' => 'cat', 'format' => FORMAT_HTML),
array('text' => 'frog', 'format' => FORMAT_HTML),
array('text' => 'newt', 'format' => FORMAT_HTML));
$expectedq->subanswers = array('insect', 'mammal', 'amphibian', 'amphibian');
if ($ddmatchisinstalled) {
$expectedq->subanswers = array(
array('text' => 'insect', 'format' => FORMAT_HTML),
array('text' => 'mammal', 'format' => FORMAT_HTML),
array('text' => 'amphibian', 'format' => FORMAT_HTML),
array('text' => 'amphibian', 'format' => FORMAT_HTML),
);
} else {
$expectedq->subanswers = array('insect', 'mammal', 'amphibian', 'amphibian');
}
$this->assert(new question_check_specified_fields_expectation($expectedq), $q);
}