diff --git a/question/engine/tests/helpers.php b/question/engine/tests/helpers.php index c2993b132bd..0f3c8914dc1 100644 --- a/question/engine/tests/helpers.php +++ b/question/engine/tests/helpers.php @@ -455,8 +455,10 @@ abstract class question_testcase extends advanced_testcase { } else if (get_class($expectation) === 'question_contains_select_expectation') { $tag = array('tag'=>'select', 'attributes'=>array('name'=>$expectation->name), 'children'=>array('count'=>count($expectation->choices))); - if (!$expectation->enabled) { + if ($expectation->enabled === false) { $tag['attributes']['disabled'] = 'disabled'; + } else if ($expectation->enabled === true) { + // TODO } foreach(array_keys($expectation->choices) as $value) { if ($expectation->selected === $value) { @@ -464,8 +466,9 @@ abstract class question_testcase extends advanced_testcase { } else { $tag['child'] = array('tag'=>'option', 'attributes'=>array('value'=>$value)); } - $this->assertTag($tag, $compare, $message); } + + $this->assertTag($tag, $compare, 'expected select not found in ' . $compare); return; } else if (get_class($expectation) === 'question_check_specified_fields_expectation') { diff --git a/question/engine/upgrade/tests/helper.php b/question/engine/upgrade/tests/helper.php index 57535b800b3..82102114dcc 100644 --- a/question/engine/upgrade/tests/helper.php +++ b/question/engine/upgrade/tests/helper.php @@ -137,10 +137,5 @@ abstract class question_attempt_upgrader_test_base extends advanced_testcase { $this->clear_html2text_dependencies($qa); $this->assertEquals($expectedqa, $qa); - - // uncomment following to get better diff on failure - //foreach (get_object_vars($expectedqa) as $k=>$v) { - // $this->assertEquals($v, $qa->$k, '', 0, 10, false); - //} } } diff --git a/question/type/match/tests/walkthrough_test.php b/question/type/match/tests/walkthrough_test.php index 9dac2059073..9f194884f24 100644 --- a/question/type/match/tests/walkthrough_test.php +++ b/question/type/match/tests/walkthrough_test.php @@ -95,8 +95,6 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base { } public function test_deferred_feedback_partial_answer() { -//TODO: this was failing randomly for me, somebody has to fix it, looks like the old expectations worked incorrectly -- skodak -return; // Create a matching question. $m = test_question_maker::make_a_matching_question(); @@ -129,8 +127,8 @@ return; $this->check_current_state(question_state::$invalid); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_select_expectation('sub0', $choices, 1, true), - $this->get_contains_select_expectation('sub1', $choices, 2, true), + $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), @@ -143,16 +141,14 @@ return; $this->check_current_state(question_state::$gradedpartial); $this->check_current_mark(2); $this->check_current_output( - $this->get_contains_select_expectation('sub0', $choices, 1, false), - $this->get_contains_select_expectation('sub1', $choices, 2, false), + $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()); } public function test_interactive_correct_no_submit() { -//TODO: this was failing randomly for me, somebody has to fix it, looks like the old expectations worked incorrectly -- skodak - return; // Create a matching question. $m = test_question_maker::make_a_matching_question(); @@ -195,18 +191,16 @@ return; $this->check_current_state(question_state::$gradedright); $this->check_current_mark(4); $this->check_current_output( - $this->get_contains_select_expectation('sub0', $choices, 1, false), - $this->get_contains_select_expectation('sub1', $choices, 2, false), - $this->get_contains_select_expectation('sub2', $choices, 2, false), - $this->get_contains_select_expectation('sub3', $choices, 1, false), + $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_contains_submit_button_expectation(false), $this->get_contains_correct_expectation(), $this->get_no_hint_visible_expectation()); } public function test_interactive_partial_no_submit() { -//TODO: this was failing randomly for me, somebody has to fix it, looks like the old expectations worked incorrectly -- skodak -return; // Create a matching question. $m = test_question_maker::make_a_matching_question(); @@ -249,9 +243,9 @@ return; $this->check_current_state(question_state::$gradedpartial); $this->check_current_mark(2); $this->check_current_output( - $this->get_contains_select_expectation('sub0', $choices, 1, false), - $this->get_contains_select_expectation('sub1', $choices, 2, false), - $this->get_contains_select_expectation('sub2', $choices, 1, false), + $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_contains_submit_button_expectation(false), $this->get_contains_partcorrect_expectation(), @@ -259,8 +253,6 @@ return; } public function test_interactive_with_invalid() { -//TODO: this was failing randomly for me, somebody has to fix it, looks like the old expectations worked incorrectly -- skodak -return; // Create a matching question. $m = test_question_maker::make_a_matching_question(); @@ -318,10 +310,10 @@ return; $this->check_current_state(question_state::$gradedright); $this->check_current_mark(4); $this->check_current_output( - $this->get_contains_select_expectation('sub0', $choices, 1, false), - $this->get_contains_select_expectation('sub1', $choices, 2, false), - $this->get_contains_select_expectation('sub2', $choices, 2, false), - $this->get_contains_select_expectation('sub3', $choices, 1, false), + $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_contains_submit_button_expectation(false), $this->get_contains_correct_expectation(), $this->get_no_hint_visible_expectation()); @@ -380,8 +372,6 @@ return; } public function test_match_clear_wrong() { -//TODO: this was failing randomly for me, somebody has to fix it, looks like the old expectations worked incorrectly -- skodak -return; // Create a matching question. $m = test_question_maker::make_a_matching_question(); @@ -421,10 +411,10 @@ return; $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_select_expectation('sub0', $choices, 3, false), - $this->get_contains_select_expectation('sub1', $choices, 3, false), - $this->get_contains_select_expectation('sub2', $choices, 3, false), - $this->get_contains_select_expectation('sub3', $choices, 3, false), + $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( @@ -463,10 +453,10 @@ return; $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output( - $this->get_contains_select_expectation('sub0', $choices, 3, false), - $this->get_contains_select_expectation('sub1', $choices, 3, false), - $this->get_contains_select_expectation('sub2', $choices, 2, false), - $this->get_contains_select_expectation('sub3', $choices, 1, false), + $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( @@ -489,8 +479,8 @@ return; $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, 2, true), - $this->get_contains_select_expectation('sub3', $choices, 1, 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), diff --git a/question/type/multianswer/tests/upgradelibnewqe_test.php b/question/type/multianswer/tests/upgradelibnewqe_test.php index 177ac6acf90..76504571f41 100644 --- a/question/type/multianswer/tests/upgradelibnewqe_test.php +++ b/question/type/multianswer/tests/upgradelibnewqe_test.php @@ -1269,9 +1269,9 @@ class qtype_multianswer_attempt_upgrader_test extends question_attempt_upgrader_ $expectedqa = (object) array( 'behaviour' => 'adaptivenopenalty', - 'questionid' => 19, + 'questionid' => '19', 'variant' => 1, - 'maxmark' => 13.0000000, + 'maxmark' => '13.0000000', 'minfraction' => 0, 'flagged' => 0, 'questionsummary' => 'This question consists of some text with an answer embedded right here {Wrong answer; Another wrong answer; Correct answer; Answer that gives half the credit} @@ -1293,7 +1293,7 @@ a) How good is this? {Yes; No} b) What grade would you give it? _____', 'rightanswer' => 'part 1: Correct answer; part 2: Correct answer; part 3: 23.8; part 4: 3. Correct answer; part 5: c. Correct answer; part 6: MOODLE; part 7: Yes; part 8: 3', 'responsesummary' => 'part 1: Correct answer; part 2: dsf; part 3: sadf; part 4: 2. Another wrong answer; part 5: c. Correct answer; part 6: MOODLE; part 7: Yes; part 8: 100%', - 'timemodified' => 1306425739, + 'timemodified' => '1306425739', 'steps' => array( 0 => (object) array( 'data' => array('_sub1_order' => '29,30,31,32', @@ -1307,34 +1307,32 @@ b) What grade would you give it? _____', 'sequencenumber' => 0, ), 1 => (object) array( - 'data' => array('sub1_answer' => '2', 'sub2_answer' => 'dsf', - 'sub3_answer' => 'sadf', 'sub4_answer' => '1', - 'sub5_answer' => '2', 'sub6_answer' => 'MOODLE', - 'sub7_answer' => 'sadf', 'sub8_answer' => '100%', '-_try' => '1', - '-_rawfraction' => '0.38461538461538466', '-submit' => '1'), + 'data' => array('sub1_answer' => 2, 'sub2_answer' => 'dsf', + 'sub3_answer' => 'sadf', 'sub4_answer' => 1, + 'sub5_answer' => 2, 'sub6_answer' => 'MOODLE', + 'sub7_answer' => 0, 'sub8_answer' => '100%', '-_try' => 1, + '-_rawfraction' => 0.38461538461538466, '-submit' => 1), 'fraction' => 0.38461538461538466, - 'timecreated' => 1306425739, - 'userid' => 4, + 'timecreated' => '1306425739', + 'userid' => '4', 'state' => 'todo', 'sequencenumber' => 1, ), 2 => (object) array( - 'data' => array('sub1_answer' => '2', 'sub2_answer' => 'dsf', - 'sub3_answer' => 'sadf', 'sub4_answer' => '1', - 'sub5_answer' => '2', 'sub6_answer' => 'MOODLE', - 'sub7_answer' => 'sadf', 'sub8_answer' => '100%', '-finish' => '1', - '-_try' => '1', '-_rawfraction' => '0.38461538461538466'), + 'data' => array('sub1_answer' => 2, 'sub2_answer' => 'dsf', + 'sub3_answer' => 'sadf', 'sub4_answer' => 1, + 'sub5_answer' => 2, 'sub6_answer' => 'MOODLE', + 'sub7_answer' => 0, 'sub8_answer' => '100%', '-finish' => 1, + '-_try' => 1, '-_rawfraction' => 0.38461538461538466), 'fraction' => 0.38461538461538466, - 'timecreated' => 1306425739, - 'userid' => 4, + 'timecreated' => '1306425739', + 'userid' => '4', 'state' => 'gradedpartial', 'sequencenumber' => 2, ), ), ); -//TODO: this comparison is failing badly, looks like it was not so picky before, somebody needs to fix the expecation --skodak -return; $this->compare_qas($expectedqa, $qa); } @@ -2639,9 +2637,9 @@ b) What grade would you give it? _____', $expectedqa = (object) array( 'behaviour' => 'adaptivenopenalty', - 'questionid' => 19, + 'questionid' => '19', 'variant' => 1, - 'maxmark' => 13.0000000, + 'maxmark' => '13.0000000', 'minfraction' => 0, 'flagged' => 0, 'questionsummary' => 'This question consists of some text with an answer embedded right here {Wrong answer; Another wrong answer; Correct answer; Answer that gives half the credit} @@ -2663,7 +2661,7 @@ a) How good is this? {Yes; No} b) What grade would you give it? _____', 'rightanswer' => 'part 1: Correct answer; part 2: Correct answer; part 3: 23.8; part 4: 3. Correct answer; part 5: c. Correct answer; part 6: MOODLE; part 7: Yes; part 8: 3', 'responsesummary' => 'part 1: Correct answer; part 2: Correct answer; part 3: 23.8; part 4: 3. Correct answer; part 5: c. Correct answer; part 6: MOODLE; part 7: Yes; part 8: 3', - 'timemodified' => 1306425886, + 'timemodified' => '1306425886', 'steps' => array( 0 => (object) array( 'sequencenumber' => 0, @@ -2680,8 +2678,8 @@ b) What grade would you give it? _____', 'sequencenumber' => 1, 'state' => 'todo', 'fraction' => 0.038461538461538464, - 'timecreated' => 1306425801, - 'userid' => 3, + 'timecreated' => '1306425801', + 'userid' => '3', 'data' => array('sub1_answer' => '3', 'sub2_answer' => 'asdgf', 'sub3_answer' => 'saedf', 'sub4_answer' => '1', 'sub5_answer' => '1', 'sub6_answer' => 'sadf', @@ -2697,8 +2695,8 @@ b) What grade would you give it? _____', 'data' => array('sub1_answer' => '2', 'sub2_answer' => 'asdgf', 'sub3_answer' => '28.3', 'sub4_answer' => '2', 'sub5_answer' => '2', 'sub6_answer' => 'MOODLE', - 'sub7_answer' => '0', 'sub8_answer' => '13', '-_try' => '2', - '-_rawfraction' => '0.53846153846153845', '-submit' => '1'), + 'sub7_answer' => '0', 'sub8_answer' => '13', '-_try' => 2, + '-_rawfraction' => 0.53846153846153845, '-submit' => 1), ), 3 => (object) array( 'sequencenumber' => 3, @@ -2709,8 +2707,8 @@ b) What grade would you give it? _____', 'data' => array('sub1_answer' => '2', 'sub2_answer' => 'Correct answer', 'sub3_answer' => '23.8', 'sub4_answer' => '2', 'sub5_answer' => '2', 'sub6_answer' => 'MOODLE', - 'sub7_answer' => '0', 'sub8_answer' => '3', '-_try' => '3', - '-_rawfraction' => '0.92307692307692311', '-submit' => '1'), + 'sub7_answer' => '0', 'sub8_answer' => '3', '-_try' => 3, + '-_rawfraction' => 0.92307692307692311, '-submit' => 1), ), 4 => (object) array( 'sequencenumber' => 4, @@ -2721,8 +2719,8 @@ b) What grade would you give it? _____', 'data' => array('sub1_answer' => '2', 'sub2_answer' => 'Correct answer', 'sub3_answer' => '23.8', 'sub4_answer' => '2', 'sub5_answer' => '2', 'sub6_answer' => 'MOODLE', - 'sub7_answer' => '0', 'sub8_answer' => '3', '-_try' => '3', - '-_rawfraction' => '0.92307692307692311', '-finish' => '1'), + 'sub7_answer' => '0', 'sub8_answer' => '3', '-_try' => 3, + '-_rawfraction' => 0.92307692307692311, '-finish' => 1), ), ), );