diff --git a/question/type/ddwtos/edit_ddwtos_form.php b/question/type/ddwtos/edit_ddwtos_form.php
index dec87f43e86..e04351c8e14 100644
--- a/question/type/ddwtos/edit_ddwtos_form.php
+++ b/question/type/ddwtos/edit_ddwtos_form.php
@@ -24,7 +24,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-require_once($CFG->dirroot . '/question/type/sddl/edit_form_base.php');
+require_once($CFG->dirroot . '/question/type/gapselect/edit_form_base.php');
/**
diff --git a/question/type/ddwtos/questiontype.php b/question/type/ddwtos/questiontype.php
index b72e89a2414..94d121a634b 100644
--- a/question/type/ddwtos/questiontype.php
+++ b/question/type/ddwtos/questiontype.php
@@ -38,30 +38,29 @@ require_once($CFG->dirroot . '/question/type/gapselect/questiontypebase.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddwtos extends qtype_gapselect_base {
- protected function feedback_serialization($choice){
+ protected function choice_group_key(){
+ return 'draggroup';
+ }
+
+ public function requires_qtypes() {
+ return array('gapselect');
+ }
+
+ protected function choice_options_to_feedback($choice){
$output = new stdClass;
$output->draggroup = $choice['draggroup'];
$output->infinite = !empty($choice['infinite']);
return serialize($output);
}
- protected function feedback_unserialization($choicedata){
- $options = unserialize($choicedata->feedback);
- return new qtype_ddwtos_choice($choicedata->answer, $options->draggroup, $options->infinite);
- }
-
-
- protected function feedback_unserialize_as_array($feedback){
+ protected function feedback_to_choice_options($feedback){
$feedbackobj = unserialize($feedback);
return array('draggroup'=> $feedbackobj->draggroup, 'infinite'=> $feedbackobj->infinite);
}
- protected function choice_group_key(){
- return 'draggroup';
- }
-
- public function requires_qtypes() {
- return array('sddl');
+ protected function make_choice($choicedata){
+ $options = unserialize($choicedata->feedback);
+ return new qtype_ddwtos_choice($choicedata->answer, $options->draggroup, $options->infinite);
}
public function import_from_xml($data, $question, $format, $extra=null) {
@@ -94,7 +93,7 @@ class qtype_ddwtos extends qtype_gapselect_base {
// Legacy format containing PHP serialisation.
foreach ($data['#']['answer'] as $answerxml) {
$ans = $format->import_answer($answerxml);
- $options = unserialize(stripslashes($ans->feedback));
+ $options = unserialize(stripslashes($ans->feedback['text']));
$question->choices[] = array(
'answer' => $ans->answer,
'draggroup' => $options->draggroup,
diff --git a/question/type/ddwtos/simpletest/testquestiontype.php b/question/type/ddwtos/simpletest/testquestiontype.php
index 0acfa17b174..f8bfa87e9c6 100644
--- a/question/type/ddwtos/simpletest/testquestiontype.php
+++ b/question/type/ddwtos/simpletest/testquestiontype.php
@@ -64,6 +64,7 @@ class qtype_ddwtos_test extends UnitTestCase {
$dd->category = 0;
$dd->parent = 0;
$dd->questiontextformat = FORMAT_HTML;
+ $dd->generalfeedbackformat = FORMAT_HTML;
$dd->defaultmark = 1;
$dd->penalty = 0.3333333;
$dd->length = 1;
@@ -205,10 +206,10 @@ class qtype_ddwtos_test extends UnitTestCase {
$expectedq->penalty = 0.3333333;
$expectedq->shuffleanswers = 1;
- $expectedq->correctfeedback = '
Your answer is correct.
';
- $expectedq->partiallycorrectfeedback = 'Your answer is partially correct.
';
+ $expectedq->correctfeedback = array('text' => 'Your answer is correct.
', 'format' => FORMAT_MOODLE, 'files' => array());
+ $expectedq->partiallycorrectfeedback = array('text' => 'Your answer is partially correct.
', 'format' => FORMAT_MOODLE, 'files' => array());
$expectedq->shownumcorrect = true;
- $expectedq->incorrectfeedback = 'Your answer is incorrect.
';
+ $expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.
', 'format' => FORMAT_MOODLE, 'files' => array());
$expectedq->choices = array(
array('answer' => 'Alpha', 'draggroup' => 1, 'infinite' => false),
@@ -348,32 +349,32 @@ class qtype_ddwtos_test extends UnitTestCase {
$expectedq->name = 'QDandD1 Base definition';
$expectedq->questiontext = 'Drag and drop the words from the list below to fill the blank spaces and correctly complete the sentence.
At 25°C all aqueous basic solutions have [[1]] ion concentrations less than [[8]]
mol litre-1 and pH values [[9]] than [[6]].
';
$expectedq->questiontextformat = FORMAT_HTML;
- $expectedq->generalfeedback = 'At 25 °C all aqueous basic solutions have hydrogen ion concentrations less than 10−7 mol litre−1 and pH values greater than 7.
See Section 9 of S103 Discovering Science Block 8.
';
+ $expectedq->generalfeedback = 'At 25 °C all aqueous basic solutions have hydrogen ion concentrations less than 10−7 mol litre−1 and pH values greater than 7.
See Section 9 of S103 Discovering Science Block 8.
';
$expectedq->defaultmark = 1;
$expectedq->length = 1;
$expectedq->penalty = 0.3333333;
$expectedq->shuffleanswers = 0;
- $expectedq->correctfeedback = 'Your answer is correct.';
- $expectedq->partiallycorrectfeedback = 'Your answer is partially correct.';
+ $expectedq->correctfeedback = array('text' => 'Your answer is correct.', 'format' => FORMAT_MOODLE, 'files' => array());
+ $expectedq->partiallycorrectfeedback = array('text' => 'Your answer is partially correct.', 'format' => FORMAT_MOODLE, 'files' => array());
$expectedq->shownumcorrect = true;
- $expectedq->incorrectfeedback = 'Your answer is incorrect.';
+ $expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.', 'format' => FORMAT_MOODLE, 'files' => array());
$expectedq->choices = array(
- array('answer' => 'hydrogen', 'draggroup' => 1, 'infinite' => false),
- array('answer' => 'positive', 'draggroup' => 1, 'infinite' => false),
- array('answer' => 'hydroxide', 'draggroup' => 1, 'infinite' => false),
- array('answer' => 'negative', 'draggroup' => 1, 'infinite' => false),
- array('answer' => '107', 'draggroup' => 2, 'infinite' => false),
- array('answer' => '7', 'draggroup' => 2, 'infinite' => false),
- array('answer' => '1', 'draggroup' => 2, 'infinite' => false),
- array('answer' => '10-7', 'draggroup' => 2, 'infinite' => false),
- array('answer' => 'greater', 'draggroup' => 3, 'infinite' => false),
- array('answer' => 'less', 'draggroup' => 3, 'infinite' => false),
+ array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_MOODLE, 'files' => array()), 'draggroup' => 1, 'infinite' => false),
+ array('answer' => array('text' => 'positive', 'format' => FORMAT_MOODLE, 'files' => array()), 'draggroup' => 1, 'infinite' => false),
+ array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_MOODLE, 'files' => array()), 'draggroup' => 1, 'infinite' => false),
+ array('answer' => array('text' => 'negative', 'format' => FORMAT_MOODLE, 'files' => array()), 'draggroup' => 1, 'infinite' => false),
+ array('answer' => array('text' => '107', 'format' => FORMAT_MOODLE, 'files' => array()), 'draggroup' => 2, 'infinite' => false),
+ array('answer' => array('text' => '7', 'format' => FORMAT_MOODLE, 'files' => array()), 'draggroup' => 2, 'infinite' => false),
+ array('answer' => array('text' => '1', 'format' => FORMAT_MOODLE, 'files' => array()), 'draggroup' => 2, 'infinite' => false),
+ array('answer' => array('text' => '10-7', 'format' => FORMAT_MOODLE, 'files' => array()), 'draggroup' => 2, 'infinite' => false),
+ array('answer' => array('text' => 'greater', 'format' => FORMAT_MOODLE, 'files' => array()), 'draggroup' => 3, 'infinite' => false),
+ array('answer' => array('text' => 'less', 'format' => FORMAT_MOODLE, 'files' => array()), 'draggroup' => 3, 'infinite' => false),
);
$expectedq->hint = array(
- 'You may wish to read Section 9 of Discovering Science Block 8.',
+ 'You may wish to read Section 9 of Discovering Science Block 8.',
'Any incorrect choices will be removed before your final try.'
);
$expectedq->hintshownumcorrect = array(true, true);
@@ -385,11 +386,13 @@ class qtype_ddwtos_test extends UnitTestCase {
public function test_xml_export() {
$qdata = new stdClass;
$qdata->id = 123;
+ $qdata->contextid = 0;
$qdata->qtype = 'ddwtos';
$qdata->name = 'A drag-and-drop 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;
@@ -397,19 +400,22 @@ class qtype_ddwtos_test extends UnitTestCase {
$qdata->options->shuffleanswers = 1;
$qdata->options->correctfeedback = 'Your answer is correct.
';
+ $qdata->options->correctfeedbackformat = FORMAT_MOODLE;
$qdata->options->partiallycorrectfeedback = 'Your answer is partially correct.
';
- $qdata->options->shownumcorrect = true;
+ $qdata->options->partiallycorrectfeedbackformat = FORMAT_MOODLE;
+ $qdata->options->shownumcorrect = 1;
$qdata->options->incorrectfeedback = 'Your answer is incorrect.
';
+ $qdata->options->incorrectfeedbackformat = FORMAT_MOODLE;
$qdata->options->answers = array(
- new question_answer('Alpha', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}'),
- new question_answer('Beta', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}'),
- new question_answer('Gamma', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:1;}'),
+ 13 => new question_answer(13, 'Alpha', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}', FORMAT_MOODLE),
+ 14 => new question_answer(14, 'Beta', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}', FORMAT_MOODLE),
+ 15 => new question_answer(15, 'Gamma', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b: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();
@@ -423,20 +429,20 @@ class qtype_ddwtos_test extends UnitTestCase {
Put these in order: [[1]], [[2]], [[3]].
-
+
The answer is Alpha, Beta, Gamma.
3
0.3333333
0
1
-
+
Your answer is correct.]]>
-
+
Your answer is partially correct.]]>
-
+
Your answer is incorrect.]]>
@@ -453,11 +459,11 @@ class qtype_ddwtos_test extends UnitTestCase {
1
-
+
Try again.
-
+
These are the first three letters of the Greek alphabet.
diff --git a/question/type/ddwtos/simpletest/testwalkthrough.php b/question/type/ddwtos/simpletest/testwalkthrough.php
index 4a0f2820fc9..9b6f42549f7 100644
--- a/question/type/ddwtos/simpletest/testwalkthrough.php
+++ b/question/type/ddwtos/simpletest/testwalkthrough.php
@@ -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(
- new question_hint_with_parts('This is the first hint.', false, false),
- new question_hint_with_parts('This is the second hint.', true, true),
+ 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),
);
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'interactive', 3);
diff --git a/question/type/gapselect/questionbase.php b/question/type/gapselect/questionbase.php
index 21fbf3b81a0..52857eeb45a 100644
--- a/question/type/gapselect/questionbase.php
+++ b/question/type/gapselect/questionbase.php
@@ -17,8 +17,8 @@
/**
- * Definition class for embedded element in question text question. Parent of drag and drop and select from
- * drop down list and ?others? *
+ * Definition class for embedded element in question text question. Parent of
+ * gap-select, drag and drop and possibly others.
*
* @package qtype
* @subpackage gapselect
@@ -34,7 +34,7 @@
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_gapselect_question_base extends question_graded_automatically_with_countback {
+abstract class qtype_gapselect_question_base extends question_graded_automatically_with_countback {
/** @var boolean Whether the question stems should be shuffled. */
public $shufflechoices;
@@ -89,12 +89,12 @@ class qtype_gapselect_question_base extends question_graded_automatically_with_c
}
public function get_question_summary() {
- $question = html_to_text($this->format_questiontext(), 0, false);
+ $question = $this->html_to_text($this->questiontext);
$groups = array();
foreach ($this->choices as $group => $choices) {
$cs = array();
foreach ($choices as $choice) {
- $cs[] = html_to_text($this->format_text($choice->text), 0, false);
+ $cs[] = $this->html_to_text($choice->text);
}
$groups[] = '[[' . $group . ']] -> {' . implode(' / ', $cs) . '}';
}
@@ -112,8 +112,8 @@ class qtype_gapselect_question_base extends question_graded_automatically_with_c
foreach ($this->places as $place => $group) {
if (array_key_exists($this->field($place), $response) &&
$response[$this->field($place)]) {
- $choices[] = '{' . html_to_text($this->format_text($this->get_selected_choice(
- $group, $response[$this->field($place)])->text), 0, false) . '}';
+ $choices[] = '{' . $this->html_to_text($this->get_selected_choice(
+ $group, $response[$this->field($place)])->text) . '}';
$allblank = false;
} else {
$choices[] = '{}';
@@ -278,7 +278,7 @@ class qtype_gapselect_question_base extends question_graded_automatically_with_c
$choiceno = $this->choiceorder[$group][$response[$fieldname]];
$choice = $this->choices[$group][$choiceno];
$parts[$place] = new question_classified_response(
- $choiceno, html_to_text($this->format_text($choice->text), 0, false),
+ $choiceno, $this->html_to_text($choice->text),
$this->get_right_choice_for($place) == $response[$fieldname]);
}
return $parts;
diff --git a/question/type/gapselect/questiontypebase.php b/question/type/gapselect/questiontypebase.php
index e0cc3d97841..7b3b336c63f 100644
--- a/question/type/gapselect/questiontypebase.php
+++ b/question/type/gapselect/questiontypebase.php
@@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/question/format/xml/format.php');
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_gapselect_base extends question_type {
+abstract class qtype_gapselect_base extends question_type {
/**
* Choices are stored in the question_answers table, and any options need to
* be put into the feedback field somehow. This method is responsible for
@@ -93,7 +93,7 @@ class qtype_gapselect_base extends question_type {
}
$update = true;
- $options = get_record('question_'.$this->name(), 'questionid', $question->id);
+ $options = get_record('question_' . $this->name(), 'questionid', $question->id);
if (!$options) {
$update = false;
$options = new stdClass;
@@ -152,10 +152,7 @@ class qtype_gapselect_base extends question_type {
$question->shufflechoices = $questiondata->options->shuffleanswers;
- $question->correctfeedback = $questiondata->options->correctfeedback;
- $question->partiallycorrectfeedback = $questiondata->options->partiallycorrectfeedback;
- $question->incorrectfeedback = $questiondata->options->incorrectfeedback;
- $question->shownumcorrect = $questiondata->options->shownumcorrect;
+ $this->initialise_combined_feedback($question, $questiondata, true);
$question->choices = array();
$choiceindexmap= array();
@@ -235,7 +232,8 @@ class qtype_gapselect_base extends question_type {
return $answers;
}
- /* This method gets the choices (answers) and sort them by groups
+ /**
+ * This method gets the choices (answers) and sort them by groups
* in a 2 dimentional array.
*
* @param object $question
@@ -244,10 +242,10 @@ class qtype_gapselect_base extends question_type {
protected function get_array_of_groups($question, $state) {
$answers = $this->get_array_of_choices($question);
$arr = array();
- for($group=1;$groupget_group_of_players ($question, $state, $answers, $group);
- if($players) {
- $arr [$group]= $players;
+ for ($group=1; $group < count($answers); $group++) {
+ $players = $this->get_group_of_players($question, $state, $answers, $group);
+ if ($players) {
+ $arr[$group]= $players;
}
}
return $arr;
@@ -322,7 +320,7 @@ class qtype_gapselect_base extends question_type {
foreach ($question->choices[$group] as $i => $choice) {
$choices[$i] = new question_possible_response(
- html_to_text($question->format_text($choice->text), 0, false),
+ $question->html_to_text($choice->text),
$question->rightchoices[$place] == $i);
}
$choices[null] = question_possible_response::no_response();
diff --git a/question/type/gapselect/renderer.php b/question/type/gapselect/renderer.php
index 62f14470ab5..c5b8a7e623c 100644
--- a/question/type/gapselect/renderer.php
+++ b/question/type/gapselect/renderer.php
@@ -45,8 +45,8 @@ class qtype_gapselect_renderer extends qtype_elements_embedded_in_question_text_
$attributes = array(
'id' => $this->box_id($qa, 'p' . $place, $group),
- 'class' => 'group' . $group
);
+ $groupclass = 'group' . $group;
if ($options->readonly) {
$attributes['disabled'] = 'disabled';
@@ -68,7 +68,8 @@ class qtype_gapselect_renderer extends qtype_elements_embedded_in_question_text_
}
}
- return html_writer::select($selectoptions, $qa->get_qt_field_name($fieldname), $value, ' ', $attributes) . ' ' . $feedbackimage;
+ $selecthtml = html_writer::select($selectoptions, $qa->get_qt_field_name($fieldname), $value, ' ', $attributes) . ' ' . $feedbackimage;
+ return html_writer::tag('span', $selecthtml, array('class' => 'control '.$groupclass));
}
}
diff --git a/question/type/gapselect/rendererbase.php b/question/type/gapselect/rendererbase.php
index 283b5b5ece5..9d9170d0117 100644
--- a/question/type/gapselect/rendererbase.php
+++ b/question/type/gapselect/rendererbase.php
@@ -3,7 +3,7 @@
* Generates the output for question types where the question includes embedded interactive elements in the
* question text.
*
- * @copyright 2010 The Open University
+ * @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class qtype_elements_embedded_in_question_text_renderer extends qtype_with_combined_feedback_renderer {
@@ -20,9 +20,9 @@ abstract class qtype_elements_embedded_in_question_text_renderer extends qtype_w
$questiontext .= $fragment;
}
-
$result = '';
- $result .= html_writer::tag('div', $question->format_text($questiontext),
+ $result .= html_writer::tag('div', $question->format_text($questiontext,
+ $qa, 'question', 'questiontext', $question->id),
array('class' => $this->qtext_classname(), 'id' => $qa->get_qt_field_name('')));
$result .= $this->post_qtext_elements($qa, $options);
diff --git a/question/type/gapselect/simpletest/testquestiontype.php b/question/type/gapselect/simpletest/testquestiontype.php
index 1cfcfcbb76e..dc8b364c313 100644
--- a/question/type/gapselect/simpletest/testquestiontype.php
+++ b/question/type/gapselect/simpletest/testquestiontype.php
@@ -20,7 +20,7 @@
* Unit tests for the select missing words question question definition class.
*
* @package qtype_gapselect
- * @copyright 2010 The Open University
+ * @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
diff --git a/question/type/gapselect/simpletest/testwalkthrough.php b/question/type/gapselect/simpletest/testwalkthrough.php
index 26b0cc681ed..e3dc5d0864c 100644
--- a/question/type/gapselect/simpletest/testwalkthrough.php
+++ b/question/type/gapselect/simpletest/testwalkthrough.php
@@ -32,6 +32,111 @@ require_once($CFG->dirroot . '/question/type/gapselect/simpletest/helper.php');
class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base {
+ 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),
+ );
+ $ql->shufflechoices = false;
+ $this->start_attempt_at_question($q, 'interactive', 3);
+ // Check the initial state.
+ $this->check_current_state(question_state::$todo);
+ $this->check_current_mark(null);
+ $this->check_current_output(
+ $this->get_contains_select_expectation('p1',
+ array('' => ' ', '1' => 'quick', '2' => 'slow'), null, true),
+ $this->get_contains_select_expectation('p2',
+ array('' => ' ', '1' => 'fox', '2' => 'dog'), null, true),
+ $this->get_contains_select_expectation('p3',
+ array('' => ' ', '1' => 'lazy', '2' => 'assiduous'), null, true),
+ $this->get_contains_submit_button_expectation(true),
+ $this->get_does_not_contain_feedback_expectation(),
+ $this->get_tries_remaining_expectation(3),
+ $this->get_no_hint_visible_expectation());
+
+ // Save the wrong answer.
+ $this->process_submission(array('p1' => '2', 'p2' => '2', 'p3' => '2'));
+
+ // Verify.
+ $this->check_current_state(question_state::$todo);
+ $this->check_current_mark(null);
+ $this->check_current_output(
+ $this->get_contains_select_expectation('p1',
+ array('' => ' ', '1' => 'quick', '2' => 'slow'), 2, true),
+ $this->get_contains_select_expectation('p2',
+ array('' => ' ', '1' => 'fox', '2' => 'dog'), 2, true),
+ $this->get_contains_select_expectation('p3',
+ array('' => ' ', '1' => 'lazy', '2' => 'assiduous'), 2, true),
+ $this->get_contains_submit_button_expectation(true),
+ $this->get_does_not_contain_correctness_expectation(),
+ $this->get_does_not_contain_feedback_expectation(),
+ $this->get_tries_remaining_expectation(3),
+ $this->get_no_hint_visible_expectation());
+
+ // Submit the wrong answer.
+ $this->process_submission(array('p1' => '2', 'p2' => '2', 'p3' => '2', '-submit' => 1));
+
+ // Verify.
+ $this->check_current_state(question_state::$todo);
+ $this->check_current_mark(null);
+ $this->check_current_output(
+ $this->get_contains_select_expectation('p1',
+ array('' => ' ', '1' => 'quick', '2' => 'slow'), 2, false),
+ $this->get_contains_select_expectation('p2',
+ array('' => ' ', '1' => 'fox', '2' => 'dog'), 2, false),
+ $this->get_contains_select_expectation('p3',
+ array('' => ' ', '1' => 'lazy', '2' => 'assiduous'), 2, false),
+ $this->get_contains_submit_button_expectation(false),
+ $this->get_contains_try_again_button_expectation(true),
+ $this->get_does_not_contain_correctness_expectation(),
+ new PatternExpectation('/' . preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'),
+ $this->get_contains_hint_expectation('This is the first hint'));
+
+ // Do try again.
+ $this->process_submission(array('-tryagain' => 1));
+
+ // Verify.
+ $this->check_current_state(question_state::$todo);
+ $this->check_current_mark(null);
+ $this->check_current_output(
+ $this->get_contains_select_expectation('p1',
+ array('' => ' ', '1' => 'quick', '2' => 'slow'), 2, true),
+ $this->get_contains_select_expectation('p2',
+ array('' => ' ', '1' => 'fox', '2' => 'dog'), 2, true),
+ $this->get_contains_select_expectation('p3',
+ array('' => ' ', '1' => 'lazy', '2' => 'assiduous'), 2, true),
+ $this->get_contains_submit_button_expectation(true),
+ $this->get_does_not_contain_correctness_expectation(),
+ $this->get_does_not_contain_feedback_expectation(),
+ $this->get_tries_remaining_expectation(2),
+ $this->get_no_hint_visible_expectation());
+
+ // Submit the right answer.
+ $this->process_submission(array('p1' => '1', 'p2' => '1', 'p3' => '1', '-submit' => 1));
+
+ // Verify.
+ $this->check_current_state(question_state::$gradedright);
+ $this->check_current_mark(2);
+ $this->check_current_output(
+ $this->get_contains_select_expectation('p1',
+ array('' => ' ', '1' => 'quick', '2' => 'slow'), 1, false),
+ $this->get_contains_select_expectation('p2',
+ array('' => ' ', '1' => 'fox', '2' => 'dog'), 1, false),
+ $this->get_contains_select_expectation('p3',
+ array('' => ' ', '1' => 'lazy', '2' => 'assiduous'), 1, false),
+ $this->get_contains_submit_button_expectation(false),
+ $this->get_contains_correct_expectation(),
+ $this->get_no_hint_visible_expectation());
+
+ // Check regrading does not mess anything up.
+ $this->quba->regrade_all_questions();
+
+ // Verify.
+ $this->check_current_state(question_state::$gradedright);
+ $this->check_current_mark(2);
+ }
}
diff --git a/question/type/gapselect/styles.css b/question/type/gapselect/styles.css
index 09f1c147503..309b3b2508e 100644
--- a/question/type/gapselect/styles.css
+++ b/question/type/gapselect/styles.css
@@ -39,3 +39,6 @@
.que.gapselect .group8 {
background-color: #F0E68C;
}
+.que.sddl .control {
+ padding: 0.2em;
+}