Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit e8c41b0a5f59954eb55b839f1106fc0f3c0657f5 1 parent 6acbecf
@aolley aolley authored
View
17 question/format/blackboard_six/tests/blackboardformatpool_test.php
@@ -56,8 +56,12 @@ public function test_import_match() {
$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 @@ public function test_import_match() {
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);
}
View
17 question/format/blackboard_six/tests/blackboardsixformatqti_test.php
@@ -53,8 +53,12 @@ public function test_import_match() {
$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 @@ public function test_import_match() {
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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.