Permalink
Browse files

MDL-38705 qformat_blackboard_six: use qti title as category name

Specifically, the title on the 'assessment' element is used.
  • Loading branch information...
1 parent 373a8e0 commit c8845ca917f0a8b8e3bdef96e04e40ed96a1c717 @jonof jonof committed with jonof Mar 25, 2013
@@ -53,6 +53,10 @@ protected function readquestions($text) {
}
$questions = array();
+
+ // Treat the assessment title as a category title.
+ $this->process_category($xml, $questions);
+
// First step : we are only interested in the <item> tags.
$rawquestions = $this->getpath($xml,
array('questestinterop', '#', 'assessment', 0, '#', 'section', 0, '#', 'item'),
@@ -872,6 +876,21 @@ public function process_matching($quest, &$questions) {
}
/**
+ * 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.
* @param string $string
@@ -51,7 +51,7 @@ public function test_import_match() {
$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 @@ public function test_import_multichoice_single() {
$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 @@ public function test_import_multichoice_multi() {
$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 @@ public function test_import_truefalse() {
$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 @@ public function test_import_fill_in_the_blank() {
$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 @@ public function test_import_essay() {
$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 @@ public function test_import_essay() {
$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);
+ }
}

0 comments on commit c8845ca

Please sign in to comment.