Skip to content

Commit

Permalink
MDL-47494 gapselect: Now all the unit tests for the the ddwtos and ga…
Browse files Browse the repository at this point in the history
…pselect qtypes pass.
  • Loading branch information
timhunt committed Feb 1, 2011
1 parent 43df6ca commit 7540fcd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
6 changes: 3 additions & 3 deletions question/type/gapselect/lang/en/qtype_gapselect.php
Expand Up @@ -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
*/
Expand All @@ -30,7 +30,7 @@
$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.';
Expand Down
34 changes: 20 additions & 14 deletions question/type/gapselect/simpletest/testquestiontype.php
Expand Up @@ -66,6 +66,7 @@ protected function get_test_question_data() {
$gapselect->category = 0;
$gapselect->parent = 0;
$gapselect->questiontextformat = FORMAT_HTML;
$gapselect->generalfeedbackformat = FORMAT_HTML;
$gapselect->defaultmark = 1;
$gapselect->penalty = 0.3333333;
$gapselect->length = 1;
Expand Down Expand Up @@ -206,10 +207,10 @@ public function test_xml_import() {
$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),
Expand All @@ -227,31 +228,36 @@ public function test_xml_import() {
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;
$qdata->hidden = 0;

$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();
Expand All @@ -265,20 +271,20 @@ public function test_xml_export() {
<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/>
Expand All @@ -294,11 +300,11 @@ public function test_xml_export() {
<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/>
Expand Down
6 changes: 3 additions & 3 deletions question/type/gapselect/simpletest/testwalkthrough.php
Expand Up @@ -37,10 +37,10 @@ public function test_interactive_behaviour() {
// 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.
Expand Down
4 changes: 2 additions & 2 deletions question/type/gapselect/version.php
Expand Up @@ -26,5 +26,5 @@
*/


$plugin->version = 2010042800;
$plugin->requires = 2007101000;
$plugin->version = 2011020100;
$plugin->requires = 2011011200;

0 comments on commit 7540fcd

Please sign in to comment.