Skip to content

Commit

Permalink
Merge branch 'MDL-59447-34' of https://github.com/nwp90/moodle into M…
Browse files Browse the repository at this point in the history
…OODLE_34_STABLE
  • Loading branch information
David Monllao committed Jul 17, 2018
2 parents c0a2bba + a29d421 commit 9c48f36
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 4 additions & 0 deletions question/format/gift/format.php
Expand Up @@ -338,6 +338,10 @@ public function readquestion($lines) {
return $question;

case 'multichoice':
// "Temporary" solution to enable choice of answernumbering on GIFT import
// by respecting default set for multichoice questions (MDL-59447)
$question->answernumbering = get_config('qtype_multichoice', 'answernumbering');

if (strpos($answertext, "=") === false) {
$question->single = 0; // Multiple answers are enabled if no single answer is 100% correct.
} else {
Expand Down
32 changes: 30 additions & 2 deletions question/format/gift/tests/giftformat_test.php
Expand Up @@ -267,7 +267,18 @@ public function test_export_match() {
$this->assert_same_gift($expectedgift, $gift);
}

public function test_import_multichoice() {
/**
* Test import of multichoice question in GIFT format
*
* @dataProvider numberingstyle_provider
*
* @param string $numberingstyle multichoice numbering style to set for qtype_multichoice
*
*/
public function test_import_multichoice($numberingstyle) {
$this->resetAfterTest(true);

set_config('answernumbering', $numberingstyle, 'qtype_multichoice');
$gift = "
// multiple choice with specified feedback for right and wrong answers
::Q2:: What's between orange and green in the spectrum?
Expand All @@ -293,7 +304,7 @@ public function test_import_multichoice() {
'length' => 1,
'single' => 1,
'shuffleanswers' => '1',
'answernumbering' => 'abc',
'answernumbering' => $numberingstyle,
'correctfeedback' => array(
'text' => '',
'format' => FORMAT_MOODLE,
Expand Down Expand Up @@ -352,6 +363,23 @@ public function test_import_multichoice() {
$this->assert(new question_check_specified_fields_expectation($expectedq), $q);
}

/**
* Return a list of numbering styles (see question/type/multichoice/questiontype.php
* for valid choices)
*
* @return array Array of 1-element arrays of qtype_multichoice numbering styles
*/
public function numberingstyle_provider() {
return [
['abc'],
['ABCD'],
['123'],
['iii'],
['IIII'],
['none']
];
}

public function test_import_multichoice_multi() {
$gift = "
// multiple choice, multiple response with specified feedback for right and wrong answers
Expand Down

0 comments on commit 9c48f36

Please sign in to comment.