mirror of
https://github.com/moodle/moodle.git
synced 2025-04-17 06:25:33 +02:00
MDL-64420 qtype: gapselect unit tests unsafe
This commit is contained in:
parent
694513e2fe
commit
0d3be6d648
@ -761,7 +761,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$q = test_question_maker::make_question('multianswer', 'twosubq');
|
||||
// To simplify testing, multichoice subquestion's answers are not shuffled.
|
||||
$q->subquestions[2]->shuffleanswers = 0;
|
||||
$choices = array('' => '', '0' => 'Bow-wow', '1' => 'Wiggly worm', '2' => 'Pussy-cat');
|
||||
$choices = array('0' => 'Bow-wow', '1' => 'Wiggly worm', '2' => 'Pussy-cat');
|
||||
|
||||
$this->start_attempt_at_question($q, 'adaptive', 12);
|
||||
|
||||
@ -777,10 +777,11 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_output_does_not_contain_text_input_with_class('sub1_answer', 'incorrect');
|
||||
$this->check_current_output(
|
||||
$this->get_contains_marked_out_of_summary(),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, null, true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_validation_error_expectation(),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, null, true));
|
||||
|
||||
// Submit an invalid response.
|
||||
$this->process_submission(array('sub1_answer' => '', 'sub2_answer' => 1, '-submit' => 1));
|
||||
@ -790,11 +791,12 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_mark(null);
|
||||
$this->check_output_contains_text_input('sub1_answer', '', true);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 1, true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_penalty_info_expectation(),
|
||||
$this->get_does_not_contain_total_penalty_expectation(),
|
||||
$this->get_contains_disregarded_info_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 1, true));
|
||||
|
||||
// Check that extract responses will return the reset data.
|
||||
$prefix = $this->quba->get_field_prefix($this->slot);
|
||||
@ -813,11 +815,12 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_output_contains_text_input_with_class('sub1_answer', 'incorrect');
|
||||
$this->check_current_output(
|
||||
$this->get_contains_mark_summary(0),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 1, true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_contains_incorrect_expectation(),
|
||||
$this->get_contains_penalty_info_expectation(4.00),
|
||||
$this->get_does_not_contain_validation_error_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 1, true));
|
||||
|
||||
// Submit the right answer.
|
||||
$this->process_submission(array('sub1_answer' => 'Owl', 'sub2_answer' => 2, '-submit' => 1));
|
||||
@ -829,13 +832,14 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_output_contains_text_input('sub1_answer', 'Owl', true);
|
||||
$this->check_output_contains_text_input_with_class('sub1_answer', 'correct');
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, '2', true),
|
||||
$this->get_contains_mark_summary(8.00),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_contains_correct_expectation(),
|
||||
$this->get_does_not_contain_penalty_info_expectation(),
|
||||
$this->get_does_not_contain_total_penalty_expectation(),
|
||||
$this->get_does_not_contain_validation_error_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, '2', true));
|
||||
|
||||
// Finish the attempt.
|
||||
$this->quba->finish_all_questions();
|
||||
|
@ -52,7 +52,7 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
|
||||
|
||||
$choiceorder = $m->get_choice_order();
|
||||
$orderforchoice = array_combine(array_values($choiceorder), array_keys($choiceorder));
|
||||
$choices = array(0 => get_string('choose') . '...');
|
||||
$choices = [];
|
||||
foreach ($choiceorder as $key => $choice) {
|
||||
$choices[$key] = $m->choices[$choice];
|
||||
}
|
||||
@ -63,16 +63,17 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
|
||||
$this->assertEquals('interactivecountback',
|
||||
$this->quba->get_question_attempt($this->slot)->get_behaviour_name());
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_tries_remaining_expectation(3),
|
||||
$this->get_does_not_contain_num_parts_correct(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Submit an answer with two right, and two wrong.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[1],
|
||||
@ -83,10 +84,6 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_try_again_button_expectation(true),
|
||||
$this->get_does_not_contain_correctness_expectation(),
|
||||
@ -102,6 +99,11 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub2', '0'),
|
||||
$this->get_contains_hidden_expectation(
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub3', $orderforchoice[1]));
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false));
|
||||
|
||||
// Check that extract responses will return the reset data.
|
||||
$prefix = $this->quba->get_field_prefix($this->slot);
|
||||
@ -116,15 +118,16 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], 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());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], true));
|
||||
|
||||
// Submit the right answer.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[1],
|
||||
@ -135,14 +138,15 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
|
||||
$this->check_current_state(question_state::$gradedright);
|
||||
$this->check_current_mark(10);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_contains_correct_expectation(),
|
||||
$this->get_contains_standard_correct_combined_feedback_expectation(),
|
||||
new question_no_pattern_expectation('/class="control\b[^"]*\bpartiallycorrect"/'));
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false));
|
||||
}
|
||||
}
|
||||
|
@ -574,6 +574,48 @@ abstract class question_testcase extends advanced_testcase {
|
||||
|
||||
throw new coding_exception('Unknown expectiontion:'.get_class($expectation));
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this function rather than assert when checking the value of options within a select element.
|
||||
*
|
||||
* @param question_contains_select_expectation $expectation The select expectation class
|
||||
* @param string $html The rendered output to check against
|
||||
*/
|
||||
public function assert_select_options($expectation, $html) {
|
||||
if (get_class($expectation) !== 'question_contains_select_expectation') {
|
||||
throw new coding_exception('Unsuitable expectiontion: '.get_class($expectation));
|
||||
}
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadHTML($html);
|
||||
$selects = $dom->getElementsByTagName('select');
|
||||
foreach ($selects as $select) {
|
||||
if ($select->getAttribute('name') == $expectation->name) {
|
||||
$options = $select->getElementsByTagName('option');
|
||||
foreach ($options as $key => $option) {
|
||||
if ($key == 0) {
|
||||
// Check the value of the first option. This is often 'Choose...' or a nbsp.
|
||||
// Note it is necessary to pass a nbsp character in the test here and not just ' '.
|
||||
// Many tests do not require checking of this option.
|
||||
if (isset($expectation->choices[$option->getAttribute('value')])) {
|
||||
$this->assertEquals($expectation->choices[$option->getAttribute('value')], $option->textContent);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Check the value of the options in the select.
|
||||
$this->assertEquals($expectation->choices[$option->getAttribute('value')], $option->textContent);
|
||||
if ($expectation->selected && $option->getAttribute('value') == $expectation->selected) {
|
||||
// Check the right option is selected.
|
||||
$this->assertTrue(!empty($option->getAttribute('selected')));
|
||||
}
|
||||
}
|
||||
if ($expectation->enabled) {
|
||||
// Check the select element is enabled.
|
||||
$this->assertTrue(!$select->getAttribute('disabled'));
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -913,6 +955,20 @@ abstract class qbehaviour_walkthrough_test_base extends question_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this function rather than check_current_output for select expectations where
|
||||
* checking the value of the options is required. check_current_output only checks
|
||||
* that the right number of options are available.
|
||||
*
|
||||
* @param question_contains_select_expectation $expectations One or more expectations.
|
||||
*/
|
||||
protected function check_output_contains_selectoptions(...$expectations) {
|
||||
$html = $this->quba->render_question($this->slot, $this->displayoptions);
|
||||
foreach ($expectations as $expectation) {
|
||||
$this->assert_select_options($expectation, $html);
|
||||
}
|
||||
}
|
||||
|
||||
protected function get_question_attempt() {
|
||||
return $this->quba->get_question_attempt($this->slot);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class qtype_gapselect_renderer extends qtype_elements_embedded_in_question_text_
|
||||
$orderedchoices = $question->get_ordered_choices($group);
|
||||
$selectoptions = array();
|
||||
foreach ($orderedchoices as $orderedchoicevalue => $orderedchoice) {
|
||||
$selectoptions[$orderedchoicevalue] = $orderedchoice->text;
|
||||
$selectoptions[$orderedchoicevalue] = format_string($orderedchoice->text);
|
||||
}
|
||||
|
||||
$feedbackimage = '';
|
||||
|
@ -52,16 +52,19 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('p1',
|
||||
array('' => get_string('choosedots'), '1' => 'quick', '2' => 'slow'), null, true),
|
||||
$this->get_contains_select_expectation('p2',
|
||||
array('' => get_string('choosedots'), '1' => 'fox', '2' => 'dog'), null, true),
|
||||
$this->get_contains_select_expectation('p3',
|
||||
array('' => get_string('choosedots'), '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());
|
||||
// Note it is possible to check the first select option as below, but it is not required.
|
||||
// Also note the ' ' in the p2 example below is a nbsp (used when names are short).
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('p1',
|
||||
['' => get_string('choosedots'), '1' => 'quick', '2' => 'slow'], null, true),
|
||||
$this->get_contains_select_expectation('p2',
|
||||
['' => ' ', '1' => 'fox', '2' => 'dog'], null, true),
|
||||
$this->get_contains_select_expectation('p3',
|
||||
['1' => 'lazy', '2' => 'assiduous'], null, true));
|
||||
|
||||
// Save the wrong answer.
|
||||
$this->process_submission(array('p1' => '2', 'p2' => '2', 'p3' => '2'));
|
||||
@ -70,17 +73,18 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('p1',
|
||||
array('' => get_string('choosedots'), '1' => 'quick', '2' => 'slow'), 2, true),
|
||||
$this->get_contains_select_expectation('p2',
|
||||
array('' => get_string('choosedots'), '1' => 'fox', '2' => 'dog'), 2, true),
|
||||
$this->get_contains_select_expectation('p3',
|
||||
array('' => get_string('choosedots'), '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());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('p1',
|
||||
['1' => 'quick', '2' => 'slow'], 2, true),
|
||||
$this->get_contains_select_expectation('p2',
|
||||
['1' => 'fox', '2' => 'dog'], 2, true),
|
||||
$this->get_contains_select_expectation('p3',
|
||||
['1' => 'lazy', '2' => 'assiduous'], 2, true));
|
||||
|
||||
// Submit the wrong answer.
|
||||
$this->process_submission(array('p1' => '2', 'p2' => '2', 'p3' => '2', '-submit' => 1));
|
||||
@ -89,16 +93,17 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('p1',
|
||||
array('' => get_string('choosedots'), '1' => 'quick', '2' => 'slow'), 2, false),
|
||||
$this->get_contains_select_expectation('p2',
|
||||
array('' => get_string('choosedots'), '1' => 'fox', '2' => 'dog'), 2, false),
|
||||
$this->get_contains_select_expectation('p3',
|
||||
array('' => get_string('choosedots'), '1' => 'lazy', '2' => 'assiduous'), 2, false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_try_again_button_expectation(true),
|
||||
$this->get_does_not_contain_correctness_expectation(),
|
||||
$this->get_contains_hint_expectation('This is the first hint'));
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('p1',
|
||||
['1' => 'quick', '2' => 'slow'], 2, false),
|
||||
$this->get_contains_select_expectation('p2',
|
||||
['1' => 'fox', '2' => 'dog'], 2, false),
|
||||
$this->get_contains_select_expectation('p3',
|
||||
['1' => 'lazy', '2' => 'assiduous'], 2, false));
|
||||
|
||||
// Do try again.
|
||||
$this->process_submission(array('-tryagain' => 1));
|
||||
@ -107,17 +112,18 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('p1',
|
||||
array('' => get_string('choosedots'), '1' => 'quick', '2' => 'slow'), 2, true),
|
||||
$this->get_contains_select_expectation('p2',
|
||||
array('' => get_string('choosedots'), '1' => 'fox', '2' => 'dog'), 2, true),
|
||||
$this->get_contains_select_expectation('p3',
|
||||
array('' => get_string('choosedots'), '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());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('p1',
|
||||
['1' => 'quick', '2' => 'slow'], 2, true),
|
||||
$this->get_contains_select_expectation('p2',
|
||||
['1' => 'fox', '2' => 'dog'], 2, true),
|
||||
$this->get_contains_select_expectation('p3',
|
||||
['1' => 'lazy', '2' => 'assiduous'], 2, true));
|
||||
|
||||
// Submit the right answer.
|
||||
$this->process_submission(array('p1' => '1', 'p2' => '1', 'p3' => '1', '-submit' => 1));
|
||||
@ -126,15 +132,16 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->check_current_state(question_state::$gradedright);
|
||||
$this->check_current_mark(2);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('p1',
|
||||
array('' => get_string('choosedots'), '1' => 'quick', '2' => 'slow'), 1, false),
|
||||
$this->get_contains_select_expectation('p2',
|
||||
array('' => get_string('choosedots'), '1' => 'fox', '2' => 'dog'), 1, false),
|
||||
$this->get_contains_select_expectation('p3',
|
||||
array('' => get_string('choosedots'), '1' => 'lazy', '2' => 'assiduous'), 1, false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_correct_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('p1',
|
||||
['1' => 'quick', '2' => 'slow'], 1, false),
|
||||
$this->get_contains_select_expectation('p2',
|
||||
['1' => 'fox', '2' => 'dog'], 1, false),
|
||||
$this->get_contains_select_expectation('p3',
|
||||
['1' => 'lazy', '2' => 'assiduous'], 1, false));
|
||||
|
||||
// Check regrading does not mess anything up.
|
||||
$this->quba->regrade_all_questions();
|
||||
@ -160,11 +167,11 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
// Check the initial state.
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('p1',
|
||||
array('' => get_string('choosedots'), '1' => 'cat', '2' => 'dog'), null, true),
|
||||
['1' => 'cat', '2' => 'dog'], null, true),
|
||||
$this->get_contains_select_expectation('p2',
|
||||
array('' => get_string('choosedots'), '1' => 'mat', '2' => 'bat'), null, true));
|
||||
['1' => 'mat', '2' => 'bat'], null, true));
|
||||
}
|
||||
|
||||
public function test_choices_containing_dollars() {
|
||||
|
@ -56,12 +56,13 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
$this->check_step_count(1);
|
||||
|
||||
// Save a blank response.
|
||||
@ -72,12 +73,13 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
$this->check_step_count(1);
|
||||
|
||||
// Finish the attempt.
|
||||
@ -86,7 +88,7 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
// Verify.
|
||||
$this->check_current_state(question_state::$gaveup);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, false),
|
||||
@ -111,12 +113,13 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Save a partial response.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[1],
|
||||
@ -126,12 +129,13 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$invalid);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Finish the attempt.
|
||||
$this->quba->finish_all_questions();
|
||||
@ -140,11 +144,12 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$gradedpartial);
|
||||
$this->check_current_mark(2);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_partcorrect_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, false),
|
||||
$this->get_contains_partcorrect_expectation());
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, false));
|
||||
}
|
||||
|
||||
public function test_interactive_correct_no_submit() {
|
||||
@ -169,14 +174,15 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, 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());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Save the right answer.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[1],
|
||||
@ -190,13 +196,14 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$gradedright);
|
||||
$this->check_current_mark(4);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_correct_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false));
|
||||
}
|
||||
|
||||
public function test_interactive_partial_no_submit() {
|
||||
@ -221,14 +228,15 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, 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());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Save the right answer.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[1],
|
||||
@ -242,13 +250,14 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$gradedpartial);
|
||||
$this->check_current_mark(2);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_partcorrect_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, false));
|
||||
}
|
||||
|
||||
public function test_interactive_with_invalid() {
|
||||
@ -273,14 +282,15 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, 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());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Try to submit an invalid answer.
|
||||
$this->process_submission(array('sub0' => '0',
|
||||
@ -291,14 +301,15 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$invalid);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_invalid_answer_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Now submit the right answer.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[1],
|
||||
@ -309,13 +320,14 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$gradedright);
|
||||
$this->check_current_mark(4);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_correct_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false));
|
||||
}
|
||||
|
||||
public function test_match_with_tricky_html_choices() {
|
||||
@ -346,6 +358,8 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
// Check the initial state.
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
// Do not use check_output_contains_selectoptions as there are multibyte characters ('1 ≤ x ≤ 2') that
|
||||
// seem to be read as ascii ('1 ⤠x ⤠2') in this test.
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
@ -392,14 +406,15 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, 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());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Submit a completely wrong response.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[3],
|
||||
@ -410,10 +425,6 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[3], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[3], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[3], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[3], false),
|
||||
$this->get_contains_hidden_expectation(
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub0', '0'),
|
||||
$this->get_contains_hidden_expectation(
|
||||
@ -424,6 +435,11 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub3', '0'),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_hint_expectation('This is the first hint.'));
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[3], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[3], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[3], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[3], false));
|
||||
|
||||
// Try again.
|
||||
$this->process_submission(array('sub0' => 0,
|
||||
@ -434,14 +450,15 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_tries_remaining_expectation(2),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Submit a partially wrong response.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[3],
|
||||
@ -452,10 +469,6 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[3], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[3], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false),
|
||||
$this->get_contains_hidden_expectation(
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub0', '0'),
|
||||
$this->get_contains_hidden_expectation(
|
||||
@ -466,6 +479,11 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub3', $orderforchoice[1]),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_hint_expectation('This is the second hint.'));
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[3], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[3], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false));
|
||||
|
||||
// Try again.
|
||||
$this->process_submission(array('sub0' => 0,
|
||||
@ -476,13 +494,15 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_tries_remaining_expectation(1),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], true));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, true),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
);
|
||||
$choices = array('' => '', '0' => 'California', '1' => 'Arizona');
|
||||
$choices = array('0' => 'California', '1' => 'Arizona');
|
||||
|
||||
$this->start_attempt_at_question($q, 'interactive', 4);
|
||||
|
||||
@ -218,16 +218,17 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->quba->get_question_attempt($this->slot)->get_behaviour_name());
|
||||
$this->check_current_output(
|
||||
$this->get_contains_marked_out_of_summary(),
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, null, true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_validation_error_expectation(),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_tries_remaining_expectation(3),
|
||||
$this->get_does_not_contain_num_parts_correct(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, null, true));
|
||||
|
||||
// Submit a completely wrong response.
|
||||
$this->process_submission(array('sub1_answer' => '1', 'sub2_answer' => '0',
|
||||
@ -237,10 +238,6 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 0, false),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, 0, false),
|
||||
$this->get_does_not_contain_num_parts_correct(),
|
||||
$this->get_contains_hidden_expectation(
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub1_answer', ''),
|
||||
@ -254,6 +251,11 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->get_contains_try_again_button_expectation(true),
|
||||
$this->get_does_not_contain_correctness_expectation(),
|
||||
$this->get_contains_hint_expectation('This is the first hint.'));
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 0, false),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, 0, false));
|
||||
|
||||
// Check that, if we review in this state, the try again button is disabled.
|
||||
$displayoptions = new question_display_options();
|
||||
@ -270,14 +272,15 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, null, true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_tries_remaining_expectation(2),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, null, true));
|
||||
|
||||
// Submit a partially wrong response.
|
||||
$this->process_submission(array('sub1_answer' => '1', 'sub2_answer' => '1',
|
||||
@ -287,10 +290,6 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, 1, false),
|
||||
$this->get_contains_num_parts_correct(2),
|
||||
$this->get_contains_hidden_expectation(
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub1_answer', ''),
|
||||
@ -302,6 +301,11 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub4_answer', '1'),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_hint_expectation('This is the second hint.'));
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, 1, false));
|
||||
|
||||
// Try again.
|
||||
$this->process_submission(array('sub1_answer' => '',
|
||||
@ -312,14 +316,15 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, '', true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, '1', true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, '', true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, '1', true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_tries_remaining_expectation(1),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, '', true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, '1', true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, '', true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, '1', true));
|
||||
}
|
||||
|
||||
public function test_interactive_partial_response_does_not_reveal_answer() {
|
||||
@ -330,7 +335,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, true),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
);
|
||||
$choices = array('' => '', '0' => 'California', '1' => 'Arizona');
|
||||
$choices = array('0' => 'California', '1' => 'Arizona');
|
||||
|
||||
$this->start_attempt_at_question($q, 'interactive', 4);
|
||||
|
||||
@ -341,16 +346,17 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->quba->get_question_attempt($this->slot)->get_behaviour_name());
|
||||
$this->check_current_output(
|
||||
$this->get_contains_marked_out_of_summary(),
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, null, true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_validation_error_expectation(),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_tries_remaining_expectation(3),
|
||||
$this->get_does_not_contain_num_parts_correct(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, null, true));
|
||||
|
||||
// Submit an incomplete response response.
|
||||
$this->process_submission(array('sub1_answer' => '1', 'sub2_answer' => '1', '-submit' => 1));
|
||||
@ -359,16 +365,17 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->check_current_state(question_state::$invalid);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, 1, true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 1, true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, null, true),
|
||||
$this->get_does_not_contain_num_parts_correct(),
|
||||
$this->get_contains_validation_error_expectation(),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_does_not_contain_correctness_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, 1, true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 1, true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, null, true));
|
||||
$this->render();
|
||||
$a = array('mark' => '0.00', 'max' => '1.00');
|
||||
$this->assertNotRegExp('~' . preg_quote(get_string('markoutofmax', 'question', $a), '~') . '~',
|
||||
@ -386,7 +393,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, true, true),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
);
|
||||
$choices = array('' => '', '0' => 'California', '1' => 'Arizona');
|
||||
$choices = array('0' => 'California', '1' => 'Arizona');
|
||||
|
||||
$this->start_attempt_at_question($q, 'interactive', 12);
|
||||
|
||||
@ -397,15 +404,16 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->quba->get_question_attempt($this->slot)->get_behaviour_name());
|
||||
$this->check_current_output(
|
||||
$this->get_contains_marked_out_of_summary(),
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, null, true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_validation_error_expectation(),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_tries_remaining_expectation(3),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, null, true));
|
||||
|
||||
// Submit an answer with two right, and two wrong.
|
||||
$this->process_submission(array('sub1_answer' => '1', 'sub2_answer' => '1',
|
||||
@ -415,15 +423,16 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, 1, false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_try_again_button_expectation(true),
|
||||
$this->get_does_not_contain_correctness_expectation(),
|
||||
new question_pattern_expectation('/Tries remaining: 2/'),
|
||||
$this->get_contains_hint_expectation('This is the first hint.'));
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, 1, false),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, 1, false));
|
||||
|
||||
// Check that extract responses will return the reset data.
|
||||
$prefix = $this->quba->get_field_prefix($this->slot);
|
||||
@ -439,14 +448,15 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, '', true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, '1', true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, '', true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, '1', true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_tries_remaining_expectation(2),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, '', true),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, '1', true),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, '', true),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, '1', true));
|
||||
|
||||
// Submit the right answer.
|
||||
$this->process_submission(array('sub1_answer' => '0', 'sub2_answer' => '1',
|
||||
@ -456,14 +466,15 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->check_current_state(question_state::$gradedright);
|
||||
$this->check_current_mark(10);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, '0', false),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, '1', false),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, '0', false),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, '1', false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_contains_correct_expectation(),
|
||||
new question_no_pattern_expectation('/class="control\b[^"]*\bpartiallycorrect"/'));
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, '0', false),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, '1', false),
|
||||
$this->get_contains_select_expectation('sub3_answer', $choices, '0', false),
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, '1', false));
|
||||
}
|
||||
|
||||
public function test_deferred_feedback_multiple() {
|
||||
|
@ -186,7 +186,6 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 1);
|
||||
|
||||
$unitchoices = array(
|
||||
'' => get_string('choosedots'),
|
||||
'm' => 'm',
|
||||
'cm' => 'cm',
|
||||
);
|
||||
@ -198,9 +197,10 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_marked_out_of_summary(),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_does_not_contain_validation_error_expectation(),
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, null, true),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, null, true));
|
||||
|
||||
// Submit blank.
|
||||
$this->process_submission(array('answer' => ''));
|
||||
@ -212,9 +212,10 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_marked_out_of_summary(),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_does_not_contain_validation_error_expectation(),
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, null, true),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, null, true));
|
||||
|
||||
// Sumit something that does not look like a number, but with a unit.
|
||||
$this->process_submission(array('answer' => 'newt', 'unit' => 'cm'));
|
||||
@ -228,9 +229,10 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_validation_error_expectation(),
|
||||
new question_pattern_expectation('/' .
|
||||
preg_quote(get_string('invalidnumber', 'qtype_numerical'), '/') . '/'),
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, 'cm', true),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, 'cm', true));
|
||||
|
||||
// Now put in the right answer but without a unit.
|
||||
$this->process_submission(array('answer' => '1.25', 'unit' => ''));
|
||||
@ -243,9 +245,10 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_validation_error_expectation(),
|
||||
new question_pattern_expectation('/' .
|
||||
preg_quote(get_string('unitnotselected', 'qtype_numerical'), '/') . '/'),
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, '', true),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, '', true));
|
||||
|
||||
// Now put in the right answer with a unit.
|
||||
$this->process_submission(array('answer' => '1.25', 'unit' => 'm'));
|
||||
@ -256,9 +259,10 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_marked_out_of_summary(),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_does_not_contain_validation_error_expectation(),
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, 'm', true),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, 'm', true));
|
||||
|
||||
// Submit all and finish.
|
||||
$this->finish();
|
||||
@ -270,8 +274,9 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_mark_summary(1),
|
||||
$this->get_contains_correct_expectation(),
|
||||
$this->get_does_not_contain_validation_error_expectation(),
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, 'm', false),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('unit', $unitchoices, 'm', false));
|
||||
$this->assertEquals('1.25 m',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
|
||||
$choiceorder = $m->get_choice_order();
|
||||
$orderforchoice = array_combine(array_values($choiceorder), array_keys($choiceorder));
|
||||
$choices = array(0 => get_string('choose') . '...');
|
||||
$choices = [];
|
||||
foreach ($choiceorder as $key => $choice) {
|
||||
$choices[$key] = $m->choices[$choice];
|
||||
}
|
||||
@ -55,12 +55,13 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
$this->check_step_count(1);
|
||||
|
||||
// Save a blank response.
|
||||
@ -71,12 +72,13 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
$this->check_step_count(1);
|
||||
|
||||
// Finish the attempt.
|
||||
@ -85,7 +87,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
// Verify.
|
||||
$this->check_current_state(question_state::$gaveup);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, false),
|
||||
@ -101,7 +103,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
|
||||
$choiceorder = $m->get_choice_order();
|
||||
$orderforchoice = array_combine(array_values($choiceorder), array_keys($choiceorder));
|
||||
$choices = array(0 => get_string('choose') . '...');
|
||||
$choices = [];
|
||||
foreach ($choiceorder as $key => $choice) {
|
||||
$choices[$key] = $m->choices[$choice];
|
||||
}
|
||||
@ -110,12 +112,13 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Save a partial response.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[13],
|
||||
@ -125,12 +128,13 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$invalid);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[13], true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[16], true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_question_text_expectation($m),
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Finish the attempt.
|
||||
$this->quba->finish_all_questions();
|
||||
@ -139,11 +143,12 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$gradedpartial);
|
||||
$this->check_current_mark(2);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_partcorrect_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, false),
|
||||
$this->get_contains_partcorrect_expectation());
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, false));
|
||||
}
|
||||
|
||||
public function test_interactive_correct_no_submit() {
|
||||
@ -159,7 +164,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
|
||||
$choiceorder = $m->get_choice_order();
|
||||
$orderforchoice = array_combine(array_values($choiceorder), array_keys($choiceorder));
|
||||
$choices = array(0 => get_string('choose') . '...');
|
||||
$choices = [];
|
||||
foreach ($choiceorder as $key => $choice) {
|
||||
$choices[$key] = $m->choices[$choice];
|
||||
}
|
||||
@ -168,14 +173,15 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, 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());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Save the right answer.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[13],
|
||||
@ -189,13 +195,14 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$gradedright);
|
||||
$this->check_current_mark(4);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_correct_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], false));
|
||||
}
|
||||
|
||||
public function test_interactive_partial_no_submit() {
|
||||
@ -211,7 +218,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
|
||||
$choiceorder = $m->get_choice_order();
|
||||
$orderforchoice = array_combine(array_values($choiceorder), array_keys($choiceorder));
|
||||
$choices = array(0 => get_string('choose') . '...');
|
||||
$choices = [];
|
||||
foreach ($choiceorder as $key => $choice) {
|
||||
$choices[$key] = $m->choices[$choice];
|
||||
}
|
||||
@ -220,14 +227,15 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, 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());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Save the right answer.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[13],
|
||||
@ -241,13 +249,14 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$gradedpartial);
|
||||
$this->check_current_mark(2);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_partcorrect_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, false));
|
||||
}
|
||||
|
||||
public function test_interactive_with_invalid() {
|
||||
@ -263,7 +272,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
|
||||
$choiceorder = $m->get_choice_order();
|
||||
$orderforchoice = array_combine(array_values($choiceorder), array_keys($choiceorder));
|
||||
$choices = array(0 => get_string('choose') . '...');
|
||||
$choices = [];
|
||||
foreach ($choiceorder as $key => $choice) {
|
||||
$choices[$key] = $m->choices[$choice];
|
||||
}
|
||||
@ -272,14 +281,15 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, 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());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Try to submit an invalid answer.
|
||||
$this->process_submission(array('sub0' => '0',
|
||||
@ -290,14 +300,15 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$invalid);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_invalid_answer_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Now submit the right answer.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[13],
|
||||
@ -308,13 +319,14 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$gradedright);
|
||||
$this->check_current_mark(4);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], false),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_correct_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], false));
|
||||
}
|
||||
|
||||
public function test_randomsamatch_clear_wrong() {
|
||||
@ -330,7 +342,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
|
||||
$choiceorder = $m->get_choice_order();
|
||||
$orderforchoice = array_combine(array_values($choiceorder), array_keys($choiceorder));
|
||||
$choices = array(0 => get_string('choose') . '...');
|
||||
$choices = [];
|
||||
foreach ($choiceorder as $key => $choice) {
|
||||
$choices[$key] = $m->choices[$choice];
|
||||
}
|
||||
@ -339,14 +351,15 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, 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());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Submit a completely wrong response.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[16],
|
||||
@ -357,10 +370,6 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_hidden_expectation(
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub0', '0'),
|
||||
$this->get_contains_hidden_expectation(
|
||||
@ -371,6 +380,11 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub3', '0'),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_hint_expectation('This is the first hint.'));
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[16], false));
|
||||
|
||||
// Try again.
|
||||
$this->process_submission(array('sub0' => 0,
|
||||
@ -381,14 +395,15 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_tries_remaining_expectation(2),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, null, true));
|
||||
|
||||
// Submit a partially wrong response.
|
||||
$this->process_submission(array('sub0' => $orderforchoice[16],
|
||||
@ -399,10 +414,6 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_hidden_expectation(
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub0', '0'),
|
||||
$this->get_contains_hidden_expectation(
|
||||
@ -413,6 +424,11 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->quba->get_field_prefix($this->slot) . 'sub3', $orderforchoice[13]),
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_contains_hint_expectation('This is the second hint.'));
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub1', $choices, $orderforchoice[13], false),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[16], false),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], false));
|
||||
|
||||
// Try again.
|
||||
$this->process_submission(array('sub0' => 0,
|
||||
@ -423,13 +439,14 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[16], true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], true),
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_tries_remaining_expectation(1),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
$this->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub0', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub1', $choices, null, true),
|
||||
$this->get_contains_select_expectation('sub2', $choices, $orderforchoice[16], true),
|
||||
$this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], true));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user