mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-38390 qformat_blackboard_six: use pool title as category name
If the category title is empty, generate a sequentially-numbered title to use instead.
This commit is contained in:
parent
373a8e052c
commit
8bcefa699d
@ -185,6 +185,14 @@ class qformat_blackboard_six extends qformat_blackboard_six_base {
|
||||
$questions = array_merge($questions, $importer->readquestions($fileobj->text));
|
||||
}
|
||||
|
||||
// Give any unnamed categories generated names.
|
||||
$unnamedcount = 0;
|
||||
foreach ($questions as $question) {
|
||||
if ($question->qtype == 'category' && $question->category == '') {
|
||||
$question->category = get_string('importedcategory', 'qformat_blackboard_six', ++$unnamedcount);
|
||||
}
|
||||
}
|
||||
|
||||
return $questions;
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,8 @@ class qformat_blackboard_six_pool extends qformat_blackboard_six_base {
|
||||
|
||||
$questions = array();
|
||||
|
||||
$this->process_category($xml, $questions);
|
||||
|
||||
$this->process_tf($xml, $questions);
|
||||
$this->process_mc($xml, $questions);
|
||||
$this->process_ma($xml, $questions);
|
||||
@ -109,6 +111,21 @@ class qformat_blackboard_six_pool extends qformat_blackboard_six_base {
|
||||
return $question;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a category question entry based on the pool file 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('POOL', '#', 'TITLE', 0, '@', 'value'), '', true);
|
||||
|
||||
$dummyquestion = new stdClass();
|
||||
$dummyquestion->qtype = 'category';
|
||||
$dummyquestion->category = $this->cleaninput($this->clean_question_name($title));
|
||||
|
||||
$questions[] = $dummyquestion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Essay Questions
|
||||
* @param array xml the xml tree
|
||||
|
@ -27,6 +27,7 @@ $string['errormanifest'] = 'Error while parsing the IMS manifest document';
|
||||
$string['importnotext'] = 'Missing question text in XML file';
|
||||
$string['filenothandled'] = 'This archive contains reference to a file material {$a} which is not currently handled by import';
|
||||
$string['imagenotfound'] = 'Image file with path {$a} was not found in the import.';
|
||||
$string['importedcategory'] = 'Imported category {$a}';
|
||||
$string['notenoughtsubans'] = 'Unable to import matching question \'{$a}\' because a matching question must comprise at least two questions and three answers.';
|
||||
$string['pluginname'] = 'Blackboard';
|
||||
$string['pluginname_help'] = 'Blackboard format enables questions saved in all Blackboard export formats to be imported via a dat or zip file. For zip files, images import is supported.';
|
||||
|
@ -54,7 +54,7 @@ class qformat_blackboard_six_pool_test extends question_testcase {
|
||||
$importer = new qformat_blackboard_six();
|
||||
$questions = $importer->readquestions($xml);
|
||||
|
||||
$q = $questions[4];
|
||||
$q = $questions[5];
|
||||
|
||||
$expectedq = new stdClass();
|
||||
$expectedq->qtype = 'match';
|
||||
@ -89,7 +89,7 @@ class qformat_blackboard_six_pool_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';
|
||||
@ -148,7 +148,7 @@ class qformat_blackboard_six_pool_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';
|
||||
@ -221,7 +221,7 @@ class qformat_blackboard_six_pool_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_pool_test extends question_testcase {
|
||||
|
||||
$importer = new qformat_blackboard_six();
|
||||
$questions = $importer->readquestions($xml);
|
||||
$q = $questions[3];
|
||||
$q = $questions[4];
|
||||
|
||||
$expectedq = new stdClass();
|
||||
$expectedq->qtype = 'shortanswer';
|
||||
@ -284,7 +284,7 @@ class qformat_blackboard_six_pool_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_pool_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 = 'exam 3 2008-9';
|
||||
|
||||
$this->assert(new question_check_specified_fields_expectation($expectedq), $q);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user