diff --git a/question/type/ddmarker/simpletest/testwalkthrough.php b/question/type/ddmarker/simpletest/testwalkthrough.php index a5049119605..eb6d493f083 100644 --- a/question/type/ddmarker/simpletest/testwalkthrough.php +++ b/question/type/ddmarker/simpletest/testwalkthrough.php @@ -38,14 +38,26 @@ require_once($CFG->dirroot . '/question/type/ddmarker/simpletest/helper.php'); */ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { - protected function get_contains_drag_image_home_expectation($dragitemno, $choice, $group) { - $class = 'group' . $group; - $class .= ' draghome dragitemhomes' . $dragitemno. ' choice'.$choice.' yui3-cssfonts'; + protected function get_contains_draggable_marker_home_expectation($choice, $infinite) { + $class = 'draghome choice'.$choice; + if ($infinite) { + $class .= ' infinite'; + } $expectedattrs = array(); $expectedattrs['class'] = $class; - return new ContainsTagWithAttributes('div', $expectedattrs); + return new ContainsTagWithAttributes('span', $expectedattrs); + } + + protected function get_contains_hidden_expectation($choiceno, $value = null) { + $name = $this->quba->get_field_prefix($this->slot) .'c'. $choiceno; + $expectedattributes = array('type' => 'hidden', 'name' => s($name)); + $expectedattributes['class'] = "choices choice{$choiceno}"; + if (!is_null($value)) { + $expectedattributes['value'] = s($value); + } + return new ContainsTagWithAttributes('input', $expectedattributes); } public function test_interactive_behaviour() { @@ -53,8 +65,10 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Create a drag-and-drop question. $dd = test_question_maker::make_question('ddmarker'); $dd->hints = array( - new question_hint_with_parts(13, 'This is the first hint.', FORMAT_HTML, false, false), - new question_hint_with_parts(14, 'This is the second hint.', FORMAT_HTML, true, true), + new question_hint_ddmarker(13, 'This is the first hint.', + FORMAT_HTML, false, false, false), + new question_hint_ddmarker(14, 'This is the second hint.', + FORMAT_HTML, true, true, false), ); $dd->shufflechoices = false; $this->start_attempt_at_question($dd, 'interactive', 12); @@ -64,66 +78,48 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4'), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1), + $this->get_contains_hidden_expectation(2), + $this->get_contains_hidden_expectation(3), $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()); + $completelywrong = array('c1' => '0,250', 'c2' => '100,250', 'c3' => '150,250'); // Save the wrong answer. - $this->process_submission(array('p1' => '2', 'p2' => '1', 'p3' => '2', 'p4' => '1')); + $this->process_submission($completelywrong); // Verify. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', 1), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, '0,250'), + $this->get_contains_hidden_expectation(2, '100,250'), + $this->get_contains_hidden_expectation(3, '150,250'), $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()); // Submit the wrong answer. - $this->process_submission( - array('p1' => '2', 'p2' => '1', 'p3' => '2', 'p4' => '1', '-submit' => 1)); + $this->process_submission($completelywrong + array('-submit' => 1)); // Verify. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', 1), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, '0,250'), + $this->get_contains_hidden_expectation(2, '100,250'), + $this->get_contains_hidden_expectation(3, '150,250'), $this->get_contains_try_again_button_expectation(true), new PatternExpectation('/' . preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'), @@ -137,18 +133,12 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', '2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', '1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', '2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', '1'), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, '0,250'), + $this->get_contains_hidden_expectation(2, '100,250'), + $this->get_contains_hidden_expectation(3, '150,250'), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation(), @@ -157,24 +147,18 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Submit the right answer. $this->process_submission( - array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2', '-submit' => 1)); + array('c1' => '50,50', 'c2' => '150,50', 'c3' => '100,150', '-submit' => 1)); // Verify. $this->check_current_state(question_state::$gradedright); $this->check_current_mark(8); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', '1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', '2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', '1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', '2'), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, '50,50'), + $this->get_contains_hidden_expectation(2, '150,50'), + $this->get_contains_hidden_expectation(3, '100,150'), $this->get_contains_submit_button_expectation(false), $this->get_contains_correct_expectation(), $this->get_no_hint_visible_expectation()); @@ -199,61 +183,43 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4'), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1), + $this->get_contains_hidden_expectation(2), + $this->get_contains_hidden_expectation(3), $this->get_does_not_contain_feedback_expectation()); // Save a partial answer. - $this->process_submission(array('p1' => '2', 'p2' => '1')); + $this->process_submission(array('c1' => '150,50', 'c2' => '50,50')); // Verify. - $this->check_current_state(question_state::$invalid); + $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', ''), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', ''), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, '150,50'), + $this->get_contains_hidden_expectation(2, '50,50'), + $this->get_contains_hidden_expectation(3, ''), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); // Save the right answer. $this->process_submission( - array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2')); + array('c1' => '50,50', 'c2' => '150,50', 'c3' => '100,150')); // Verify. $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', 2), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, '50,50'), + $this->get_contains_hidden_expectation(2, '150,50'), + $this->get_contains_hidden_expectation(3, '100,150'), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); @@ -265,18 +231,12 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->check_current_mark(12); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', 2), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, '50,50'), + $this->get_contains_hidden_expectation(2, '150,50'), + $this->get_contains_hidden_expectation(3, '100,150'), $this->get_contains_correct_expectation()); // Change the right answer a bit. @@ -287,7 +247,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Verify. $this->check_current_state(question_state::$gradedpartial); - $this->check_current_mark(9); + $this->check_current_mark(8); } public function test_deferred_feedback_unanswered() { @@ -301,41 +261,29 @@ class qtype_ddmarker_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_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4'), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1), + $this->get_contains_hidden_expectation(2), + $this->get_contains_hidden_expectation(3), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); $this->check_step_count(1); // Save a blank response. - $this->process_submission(array('p1' => '', 'p2' => '', 'p3' => '', 'p4' => '')); + $this->process_submission(array('c1' => '', 'c2' => '', 'c3' => '')); // Verify. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', ''), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', ''), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', ''), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', ''), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, ''), + $this->get_contains_hidden_expectation(2, ''), + $this->get_contains_hidden_expectation(3, ''), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); $this->check_step_count(1); @@ -347,10 +295,9 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->check_current_state(question_state::$gaveup); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2)); + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false)); } public function test_deferred_feedback_partial_answer() { @@ -364,40 +311,27 @@ class qtype_ddmarker_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_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4'), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1), + $this->get_contains_hidden_expectation(2), + $this->get_contains_hidden_expectation(3), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); - // Save a partial response. - $this->process_submission(array('p1' => '1', 'p2' => '2', 'p3' => '', 'p4' => '')); + $this->process_submission(array('c1' => '50,50', 'c2' => '150,50', 'c3' => '')); // Verify. - $this->check_current_state(question_state::$invalid); + $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', ''), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', ''), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, '50,50'), + $this->get_contains_hidden_expectation(2, '150,50'), + $this->get_contains_hidden_expectation(3, ''), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); @@ -406,12 +340,11 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Verify. $this->check_current_state(question_state::$gradedpartial); - $this->check_current_mark(1.5); + $this->check_current_mark(2); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), $this->get_contains_partcorrect_expectation()); } @@ -420,10 +353,10 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Create a drag-and-drop question. $dd = test_question_maker::make_question('ddmarker'); $dd->hints = array( - new question_hint_with_parts(1, 'This is the first hint.', - FORMAT_MOODLE, true, true), - new question_hint_with_parts(2, 'This is the second hint.', - FORMAT_MOODLE, true, true), + new question_hint_ddmarker(1, 'This is the first hint.', + FORMAT_MOODLE, true, true, false), + new question_hint_ddmarker(2, 'This is the second hint.', + FORMAT_MOODLE, true, true, false), ); $dd->shufflechoices = false; $this->start_attempt_at_question($dd, 'interactive', 12); @@ -434,18 +367,12 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->assertEqual('interactivecountback', $this->quba->get_question_attempt($this->slot)->get_behaviour_name()); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4'), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1), + $this->get_contains_hidden_expectation(2), + $this->get_contains_hidden_expectation(3), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(3), @@ -454,16 +381,15 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Submit an response with the first two parts right. $this->process_submission( - array('p1' => '1', 'p2' => '2', 'p3' => '2', 'p4' => '1', '-submit' => 1)); + array('c1' => '50,50', 'c2' => '150,50', 'c3' => '150,50', '-submit' => 1)); // Verify. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), $this->get_contains_submit_button_expectation(false), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), @@ -472,42 +398,31 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_hint_expectation('This is the first hint'), $this->get_contains_num_parts_correct(2), $this->get_contains_standard_partiallycorrect_combined_feedback_expectation(), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', 1)); + $this->get_contains_hidden_expectation(1, '50,50'), + $this->get_contains_hidden_expectation(2, '150,50'), + $this->get_contains_hidden_expectation(3, '150,50')); // Check that extract responses will return the reset data. $prefix = $this->quba->get_field_prefix($this->slot); - $this->assertEqual(array('p1' => '1', 'p2' => '2'), + $this->assertEqual(array('c1' => '50,50', 'c2' => '150,50'), $this->quba->extract_responses($this->slot, - array($prefix . 'p1' => '1', $prefix . 'p2' => '2', '-tryagain' => 1))); + array($prefix . 'c1' => '50,50', $prefix . 'c2' => '150,50', '-tryagain' => 1))); // Do try again. - // keys p3 and p4 are extra hidden fields to clear data. + // keys c3 is an extra hidden fields to clear data. $this->process_submission( - array('p1' => '1', 'p2' => '2', 'p3' => '', 'p4' => '', '-tryagain' => 1)); + array('c1' => '50,50', 'c2' => '150,50', 'c3' => '', '-tryagain' => 1)); // Verify. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', ''), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', ''), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, '50,50'), + $this->get_contains_hidden_expectation(2, '150,50'), + $this->get_contains_hidden_expectation(3, ''), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_try_again_button_expectation(), $this->get_does_not_contain_correctness_expectation(), @@ -517,16 +432,15 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Submit an response with the first and last parts right. $this->process_submission( - array('p1' => '1', 'p2' => '1', 'p3' => '2', 'p4' => '2', '-submit' => 1)); + array('c1' => '50,50', 'c2' => '150,150', 'c3' => '100,150', '-submit' => 1)); // Verify. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), $this->get_contains_submit_button_expectation(false), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), @@ -535,35 +449,24 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_hint_expectation('This is the second hint'), $this->get_contains_num_parts_correct(2), $this->get_contains_standard_partiallycorrect_combined_feedback_expectation(), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', 2)); + $this->get_contains_hidden_expectation(1, '50,50'), + $this->get_contains_hidden_expectation(2, '150,150'), + $this->get_contains_hidden_expectation(3, '100,150')); // Do try again. $this->process_submission( - array('p1' => '1', 'p2' => '', 'p3' => '', 'p4' => '2', '-tryagain' => 1)); + array('c1' => '50,50', 'c2' => '', 'c3' => '', '-tryagain' => 1)); // Verify. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', ''), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', ''), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', 2), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, '50,50'), + $this->get_contains_hidden_expectation(2, ''), + $this->get_contains_hidden_expectation(3, ''), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_try_again_button_expectation(), $this->get_does_not_contain_correctness_expectation(), @@ -573,24 +476,18 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Submit the right answer. $this->process_submission( - array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2', '-submit' => 1)); + array('c1' => '50,50', 'c2' => '150,50', 'c3' => '100,150', '-submit' => 1)); // Verify. $this->check_current_state(question_state::$gradedright); - $this->check_current_mark(7); + $this->check_current_mark(8); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', 1), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', 2), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, '50,50'), + $this->get_contains_hidden_expectation(2, '150,50'), + $this->get_contains_hidden_expectation(3, '100,150'), $this->get_contains_submit_button_expectation(false), $this->get_does_not_contain_try_again_button_expectation(), $this->get_contains_correct_expectation(), @@ -604,10 +501,10 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Create a drag-and-drop question. $dd = test_question_maker::make_question('ddmarker'); $dd->hints = array( - new question_hint_with_parts(23, 'This is the first hint.', - FORMAT_MOODLE, false, false), - new question_hint_with_parts(24, 'This is the second hint.', - FORMAT_MOODLE, true, true), + new question_hint_ddmarker(23, 'This is the first hint.', + FORMAT_MOODLE, false, false, false), + new question_hint_ddmarker(24, 'This is the second hint.', + FORMAT_MOODLE, true, true, false), ); $dd->shufflechoices = false; $this->start_attempt_at_question($dd, 'interactive', 3); @@ -616,25 +513,19 @@ class qtype_ddmarker_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_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4'), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1), + $this->get_contains_hidden_expectation(2), + $this->get_contains_hidden_expectation(3), $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 right answer. - $this->process_submission(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2')); + $this->process_submission(array('c1' => '50,50', 'c2' => '150,50', 'c3' => '100,150')); // Finish the attempt without clicking check. $this->quba->finish_all_questions(); @@ -643,10 +534,9 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->check_current_state(question_state::$gradedright); $this->check_current_mark(3); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), $this->get_contains_submit_button_expectation(false), $this->get_contains_correct_expectation(), $this->get_no_hint_visible_expectation()); @@ -664,51 +554,44 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Create a drag-and-drop question. $dd = test_question_maker::make_question('ddmarker'); $dd->hints = array( - new question_hint_with_parts(23, 'This is the first hint.', - FORMAT_MOODLE, false, false), - new question_hint_with_parts(24, 'This is the second hint.', - FORMAT_MOODLE, true, true), + new question_hint_ddmarker(23, 'This is the first hint.', + FORMAT_MOODLE, false, false, false), + new question_hint_ddmarker(24, 'This is the second hint.', + FORMAT_MOODLE, true, true, false), ); $dd->shufflechoices = false; - $this->start_attempt_at_question($dd, 'interactive', 4); + $this->start_attempt_at_question($dd, '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_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4'), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1), + $this->get_contains_hidden_expectation(2), + $this->get_contains_hidden_expectation(3), $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 a partially right answer. - $this->process_submission(array('p1' => '1', 'p2' => '1', 'p3' => '2', 'p4' => '1')); + $this->process_submission(array('c1' => '50,50', 'c2' => '50,50', 'c3' => '100,150')); // Finish the attempt without clicking check. $this->quba->finish_all_questions(); // Verify. $this->check_current_state(question_state::$gradedpartial); - $this->check_current_mark(1); + $this->check_current_mark(2); $this->check_current_output( - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), $this->get_contains_submit_button_expectation(false), $this->get_contains_partcorrect_expectation(), $this->get_no_hint_visible_expectation()); @@ -718,7 +601,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Verify. $this->check_current_state(question_state::$gradedpartial); - $this->check_current_mark(1); + $this->check_current_mark(2); } public function test_interactive_no_right_clears() { @@ -726,8 +609,10 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Create a drag-and-drop question. $dd = test_question_maker::make_question('ddmarker'); $dd->hints = array( - new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, true), - new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true), + new question_hint_ddmarker(23, 'This is the first hint.', + FORMAT_MOODLE, false, true, false), + new question_hint_ddmarker(24, 'This is the second hint.', + FORMAT_MOODLE, true, true, false), ); $dd->shufflechoices = false; $this->start_attempt_at_question($dd, 'interactive', 3); @@ -738,18 +623,12 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->check_current_output( $this->get_contains_marked_out_of_summary(), - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4'), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1), + $this->get_contains_hidden_expectation(2), + $this->get_contains_hidden_expectation(3), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(3), @@ -757,41 +636,34 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Save the a completely wrong answer. $this->process_submission( - array('p1' => '2', 'p2' => '1', 'p3' => '2', 'p4' => '1', '-submit' => 1)); + array('c1' => '100,150', 'c2' => '100,150', 'c3' => '50,50', '-submit' => 1)); // Verify. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output( $this->get_contains_marked_out_of_summary(), - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), $this->get_contains_submit_button_expectation(false), $this->get_contains_hint_expectation('This is the first hint')); // Do try again. $this->process_submission( - array('p1' => '', 'p2' => '', 'p3' => '', 'p4' => '', '-tryagain' => 1)); + array('c1' => '', 'c2' => '', 'c3' => '', '-tryagain' => 1)); // Check that all the wrong answers have been cleared. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output( $this->get_contains_marked_out_of_summary(), - $this->get_contains_drag_image_home_expectation(1, 1, 1), - $this->get_contains_drag_image_home_expectation(2, 2, 1), - $this->get_contains_drag_image_home_expectation(1, 1, 2), - $this->get_contains_drag_image_home_expectation(2, 2, 2), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', ''), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', ''), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', ''), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', ''), + $this->get_contains_draggable_marker_home_expectation(1, false), + $this->get_contains_draggable_marker_home_expectation(2, false), + $this->get_contains_draggable_marker_home_expectation(3, false), + $this->get_contains_hidden_expectation(1, ''), + $this->get_contains_hidden_expectation(2, ''), + $this->get_contains_hidden_expectation(3, ''), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(2), @@ -809,14 +681,9 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3'), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4'), + $this->get_contains_hidden_expectation(1), + $this->get_contains_hidden_expectation(2), + $this->get_contains_hidden_expectation(3), $this->get_does_not_contain_feedback_expectation()); // Save a partial answer. @@ -825,31 +692,24 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base { // Verify. $this->check_current_state(question_state::$complete); $this->check_current_mark(null); + $rightanswer = array($dd->get_right_choice_for(1)=>'50,50', + $dd->get_right_choice_for(2) =>'150,50', + $dd->get_right_choice_for(3) => '100,150'); $this->check_current_output( - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p1', - $dd->get_right_choice_for(1)), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p2', - $dd->get_right_choice_for(2)), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p3', - $dd->get_right_choice_for(3)), - $this->get_contains_hidden_expectation( - $this->quba->get_field_prefix($this->slot) . 'p4', - $dd->get_right_choice_for(4)), - $this->get_does_not_contain_correctness_expectation(), - $this->get_does_not_contain_feedback_expectation()); + $this->get_contains_hidden_expectation(1, $rightanswer[1]), + $this->get_contains_hidden_expectation(2, $rightanswer[2]), + $this->get_contains_hidden_expectation(3, $rightanswer[3]), + $this->get_does_not_contain_correctness_expectation(), + $this->get_does_not_contain_feedback_expectation()); // Finish the attempt. $this->quba->finish_all_questions(); // Verify. $this->displayoptions->rightanswer = question_display_options::VISIBLE; - $this->assertEqual('Drop zone 1 -> {1. quick} '. - 'Drop zone 2 -> {2. fox} '. - 'Drop zone 3 -> {1. lazy} '. - 'Drop zone 4 -> {2. dog}', + $this->assertEqual('{Drop zone 1 -> quick}, '. + '{Drop zone 2 -> fox}, '. + '{Drop zone 3 -> lazy}', $dd->get_right_answer_summary()); $this->check_current_state(question_state::$gradedright); $this->check_current_mark(3);