MDL-20636 Now all the unit tests for the the ddwtos and gapselect qtypes pass.
This commit is contained in:
@@ -1,10 +1,35 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* Language strings for the select missing words question type.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage gapselect
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
$string['addingddwtos'] = 'Adding drag and drop: words in text';
|
||||
$string['addmorechoiceblanks'] = 'Blanks for {no} More Choices';
|
||||
$string['answer'] = 'Answer';
|
||||
$string['correctansweris'] = 'The correct answer is: $a';
|
||||
$string['correctansweris'] = 'The correct answer is: {$a}';
|
||||
$string['ddwtos'] = 'Drag and drop: words in text';
|
||||
$string['ddwtos_help'] = 'Type in some question text like "The [[1]] jumped over the [[2]]", then enter the possible words to go in gaps 1 and 2 underneath.';
|
||||
$string['ddwtossummary'] = 'Missing words in some text are filled in using drag-and-drop.';
|
||||
|
||||
@@ -57,8 +57,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
// Create a drag-and-drop question.
|
||||
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
|
||||
$dd->hints = array(
|
||||
13 => new question_hint_with_parts(13, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
14 => new question_hint_with_parts(14, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
new question_hint_with_parts(13, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
new question_hint_with_parts(14, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
);
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'interactive', 3);
|
||||
@@ -332,8 +332,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
// Create a drag-and-drop question.
|
||||
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts('This is the first hint.', true, true),
|
||||
new question_hint_with_parts('This is the second hint.', true, true),
|
||||
new question_hint_with_parts(1, 'This is the first hint.', FORMAT_MOODLE, true, true),
|
||||
new question_hint_with_parts(2, 'This is the second hint.', FORMAT_MOODLE, true, true),
|
||||
);
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'interactive', 9);
|
||||
@@ -469,8 +469,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
// Create a drag-and-drop question.
|
||||
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts('This is the first hint.', false, false),
|
||||
new question_hint_with_parts('This is the second hint.', true, true),
|
||||
new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, false),
|
||||
new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
|
||||
);
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'interactive', 3);
|
||||
@@ -520,8 +520,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
// Create a drag-and-drop question.
|
||||
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts('This is the first hint.', false, false),
|
||||
new question_hint_with_parts('This is the second hint.', true, true),
|
||||
new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, false),
|
||||
new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
|
||||
);
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'interactive', 3);
|
||||
@@ -571,8 +571,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
// Create a drag-and-drop question.
|
||||
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts('This is the first hint.', false, true),
|
||||
new question_hint_with_parts('This is the second hint.', true, true),
|
||||
new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, true),
|
||||
new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
|
||||
);
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'interactive', 3);
|
||||
@@ -675,6 +675,5 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->get_contains_drop_box_expectation('p3', 3, true, 'correct'),
|
||||
$this->get_contains_correct_expectation(),
|
||||
new PatternExpectation('/' . preg_quote('The [quick] brown [fox] jumped over the [lazy] dog.') . '/'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
|
||||
$plugin->version = 2010042800;
|
||||
$plugin->requires = 2007101000;
|
||||
$plugin->version = 2011020100;
|
||||
$plugin->requires = 2011011200;
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
|
||||
/**
|
||||
* Language strings for the select missing words question type.
|
||||
* Language strings for the sdrag-and-drop words into sentences question type.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage gapselect
|
||||
* @subpackage ddwtos
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ $string['addinggapselect'] = 'Adding a select missing words question';
|
||||
$string['addmorechoiceblanks'] = 'Blanks for {no} more choices';
|
||||
$string['answer'] = 'Answer';
|
||||
$string['choices'] = 'Choices';
|
||||
$string['correctansweris'] = 'The correct answer is: $a';
|
||||
$string['correctansweris'] = 'The correct answer is: {$a}';
|
||||
$string['gapselect'] = 'Select missing words';
|
||||
$string['gapselect_help'] = 'Type in some question text like "The [[1]] jumped over the [[2]]", then enter the possible words to go in gaps 1 and 2 underneath.';
|
||||
$string['gapselectsummary'] = 'Missing words in some text are filled in using dropdown menus.';
|
||||
|
||||
@@ -66,6 +66,7 @@ class qtype_gapselect_test extends UnitTestCase {
|
||||
$gapselect->category = 0;
|
||||
$gapselect->parent = 0;
|
||||
$gapselect->questiontextformat = FORMAT_HTML;
|
||||
$gapselect->generalfeedbackformat = FORMAT_HTML;
|
||||
$gapselect->defaultmark = 1;
|
||||
$gapselect->penalty = 0.3333333;
|
||||
$gapselect->length = 1;
|
||||
@@ -206,10 +207,10 @@ class qtype_gapselect_test extends UnitTestCase {
|
||||
$expectedq->penalty = 0.3333333;
|
||||
|
||||
$expectedq->shuffleanswers = 1;
|
||||
$expectedq->correctfeedback = '<p>Your answer is correct.</p>';
|
||||
$expectedq->partiallycorrectfeedback = '<p>Your answer is partially correct.</p>';
|
||||
$expectedq->correctfeedback = array('text' => '<p>Your answer is correct.</p>', 'format' => FORMAT_MOODLE, 'files' => array());
|
||||
$expectedq->partiallycorrectfeedback = array('text' => '<p>Your answer is partially correct.</p>', 'format' => FORMAT_MOODLE, 'files' => array());
|
||||
$expectedq->shownumcorrect = true;
|
||||
$expectedq->incorrectfeedback = '<p>Your answer is incorrect.</p>';
|
||||
$expectedq->incorrectfeedback = array('text' => '<p>Your answer is incorrect.</p>', 'format' => FORMAT_MOODLE, 'files' => array());
|
||||
|
||||
$expectedq->choices = array(
|
||||
array('answer' => 'Alpha', 'selectgroup' => 1),
|
||||
@@ -227,11 +228,13 @@ class qtype_gapselect_test extends UnitTestCase {
|
||||
public function test_xml_export() {
|
||||
$qdata = new stdClass;
|
||||
$qdata->id = 123;
|
||||
$qdata->contextid = 0;
|
||||
$qdata->qtype = 'gapselect';
|
||||
$qdata->name = 'A select missing words question';
|
||||
$qdata->questiontext = 'Put these in order: [[1]], [[2]], [[3]].';
|
||||
$qdata->questiontextformat = FORMAT_MOODLE;
|
||||
$qdata->generalfeedback = 'The answer is Alpha, Beta, Gamma.';
|
||||
$qdata->generalfeedbackformat = FORMAT_MOODLE;
|
||||
$qdata->defaultmark = 3;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 0.3333333;
|
||||
@@ -239,19 +242,22 @@ class qtype_gapselect_test extends UnitTestCase {
|
||||
|
||||
$qdata->options->shuffleanswers = 1;
|
||||
$qdata->options->correctfeedback = '<p>Your answer is correct.</p>';
|
||||
$qdata->options->correctfeedbackformat = FORMAT_MOODLE;
|
||||
$qdata->options->partiallycorrectfeedback = '<p>Your answer is partially correct.</p>';
|
||||
$qdata->options->partiallycorrectfeedbackformat = FORMAT_MOODLE;
|
||||
$qdata->options->shownumcorrect = true;
|
||||
$qdata->options->incorrectfeedback = '<p>Your answer is incorrect.</p>';
|
||||
$qdata->options->incorrectfeedbackformat = FORMAT_MOODLE;
|
||||
|
||||
$qdata->options->answers = array(
|
||||
new question_answer('Alpha', 0, '1'),
|
||||
new question_answer('Beta', 0, '1'),
|
||||
new question_answer('Gamma', 0, '1'),
|
||||
13 => new question_answer(13, 'Alpha', 0, '1', FORMAT_MOODLE),
|
||||
14 => new question_answer(14, 'Beta', 0, '1', FORMAT_MOODLE),
|
||||
15 => new question_answer(15, 'Gamma', 0, '1', FORMAT_MOODLE),
|
||||
);
|
||||
|
||||
$qdata->hints = array(
|
||||
new question_hint_with_parts('Try again.', true, false),
|
||||
new question_hint_with_parts('These are the first three letters of the Greek alphabet.', true, true),
|
||||
1 => new question_hint_with_parts(1, 'Try again.', FORMAT_MOODLE, true, false),
|
||||
2 => new question_hint_with_parts(2, 'These are the first three letters of the Greek alphabet.', FORMAT_MOODLE, true, true),
|
||||
);
|
||||
|
||||
$exporter = new qformat_xml();
|
||||
@@ -265,20 +271,20 @@ class qtype_gapselect_test extends UnitTestCase {
|
||||
<questiontext format="moodle_auto_format">
|
||||
<text>Put these in order: [[1]], [[2]], [[3]].</text>
|
||||
</questiontext>
|
||||
<generalfeedback>
|
||||
<generalfeedback format="moodle_auto_format">
|
||||
<text>The answer is Alpha, Beta, Gamma.</text>
|
||||
</generalfeedback>
|
||||
<defaultgrade>3</defaultgrade>
|
||||
<penalty>0.3333333</penalty>
|
||||
<hidden>0</hidden>
|
||||
<shuffleanswers>1</shuffleanswers>
|
||||
<correctfeedback>
|
||||
<correctfeedback format="moodle_auto_format">
|
||||
<text><![CDATA[<p>Your answer is correct.</p>]]></text>
|
||||
</correctfeedback>
|
||||
<partiallycorrectfeedback>
|
||||
<partiallycorrectfeedback format="moodle_auto_format">
|
||||
<text><![CDATA[<p>Your answer is partially correct.</p>]]></text>
|
||||
</partiallycorrectfeedback>
|
||||
<incorrectfeedback>
|
||||
<incorrectfeedback format="moodle_auto_format">
|
||||
<text><![CDATA[<p>Your answer is incorrect.</p>]]></text>
|
||||
</incorrectfeedback>
|
||||
<shownumcorrect/>
|
||||
@@ -294,11 +300,11 @@ class qtype_gapselect_test extends UnitTestCase {
|
||||
<text>Gamma</text>
|
||||
<group>1</group>
|
||||
</selectoption>
|
||||
<hint>
|
||||
<hint format="moodle_auto_format">
|
||||
<text>Try again.</text>
|
||||
<shownumcorrect/>
|
||||
</hint>
|
||||
<hint>
|
||||
<hint format="moodle_auto_format">
|
||||
<text>These are the first three letters of the Greek alphabet.</text>
|
||||
<shownumcorrect/>
|
||||
<clearwrong/>
|
||||
|
||||
@@ -37,10 +37,10 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
// Create a gapselect question.
|
||||
$q = qtype_gapselect_test_helper::make_a_gapselect_question();
|
||||
$q->hints = array(
|
||||
new question_hint_with_parts('This is the first hint.', false, false),
|
||||
new question_hint_with_parts('This is the second hint.', true, true),
|
||||
new question_hint_with_parts(1, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
new question_hint_with_parts(2, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
);
|
||||
$ql->shufflechoices = false;
|
||||
$q->shufflechoices = false;
|
||||
$this->start_attempt_at_question($q, 'interactive', 3);
|
||||
|
||||
// Check the initial state.
|
||||
|
||||
@@ -26,5 +26,5 @@
|
||||
*/
|
||||
|
||||
|
||||
$plugin->version = 2010042800;
|
||||
$plugin->requires = 2007101000;
|
||||
$plugin->version = 2011020100;
|
||||
$plugin->requires = 2011011200;
|
||||
|
||||
Reference in New Issue
Block a user