diff --git a/question/format/blackboard_six/formatqti.php b/question/format/blackboard_six/formatqti.php index 744456c4723..2c7b7200de4 100644 --- a/question/format/blackboard_six/formatqti.php +++ b/question/format/blackboard_six/formatqti.php @@ -53,6 +53,10 @@ class qformat_blackboard_six_qti extends qformat_blackboard_six_base { } $questions = array(); + + // Treat the assessment title as a category title. + $this->process_category($xml, $questions); + // First step : we are only interested in the tags. $rawquestions = $this->getpath($xml, array('questestinterop', '#', 'assessment', 0, '#', 'section', 0, '#', 'item'), @@ -871,6 +875,21 @@ class qformat_blackboard_six_qti extends qformat_blackboard_six_base { } } + /** + * Add a category question entry based on the assessment title + * @param array $xml the xml tree + * @param array $questions the questions already parsed + */ + public function process_category($xml, &$questions) { + $title = $this->getpath($xml, array('questestinterop', '#', 'assessment', 0, '@', 'title'), '', true); + + $dummyquestion = new stdClass(); + $dummyquestion->qtype = 'category'; + $dummyquestion->category = $this->cleaninput($this->clean_question_name($title)); + + $questions[] = $dummyquestion; + } + /** * Strip the applet tag used by Blackboard to render mathml formulas, * keeping the mathml tag. diff --git a/question/format/blackboard_six/tests/blackboardsixformatqti_test.php b/question/format/blackboard_six/tests/blackboardsixformatqti_test.php index f7627c0d58e..46a2d05ed06 100644 --- a/question/format/blackboard_six/tests/blackboardsixformatqti_test.php +++ b/question/format/blackboard_six/tests/blackboardsixformatqti_test.php @@ -51,7 +51,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $importer = new qformat_blackboard_six(); $questions = $importer->readquestions($xml); - $q = $questions[3]; + $q = $questions[4]; $expectedq = new stdClass(); $expectedq->qtype = 'match'; @@ -85,7 +85,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $importer = new qformat_blackboard_six(); $questions = $importer->readquestions($xml); - $q = $questions[1]; + $q = $questions[2]; $expectedq = new stdClass(); $expectedq->qtype = 'multichoice'; @@ -144,7 +144,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $importer = new qformat_blackboard_six(); $questions = $importer->readquestions($xml); - $q = $questions[2]; + $q = $questions[3]; $expectedq = new stdClass(); $expectedq->qtype = 'multichoice'; @@ -220,7 +220,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $importer = new qformat_blackboard_six(); $questions = $importer->readquestions($xml); - $q = $questions[0]; + $q = $questions[1]; $expectedq = new stdClass(); $expectedq->qtype = 'truefalse'; @@ -250,7 +250,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $importer = new qformat_blackboard_six(); $questions = $importer->readquestions($xml); - $q = $questions[4]; + $q = $questions[5]; $expectedq = new stdClass(); $expectedq->qtype = 'shortanswer'; @@ -284,7 +284,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $importer = new qformat_blackboard_six(); $questions = $importer->readquestions($xml); - $q = $questions[5]; + $q = $questions[6]; $expectedq = new stdClass(); $expectedq->qtype = 'essay'; @@ -305,4 +305,19 @@ class qformat_blackboard_six_qti_test extends question_testcase { $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } + + public function test_import_category() { + + $xml = $this->make_test_xml(); + + $importer = new qformat_blackboard_six(); + $questions = $importer->readquestions($xml); + $q = $questions[0]; + + $expectedq = new stdClass(); + $expectedq->qtype = 'category'; + $expectedq->category = 'sample_blackboard_six'; + + $this->assert(new question_check_specified_fields_expectation($expectedq), $q); + } }