From 3af05ae35b627bc35c01c81fb16395d7e7f3d588 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Sun, 31 May 2015 21:09:55 +0100 Subject: [PATCH] MDL-29771 interactive behaviour: better state text in try again state Before it just said 'Not complete'. It is more helpful to show the number of tries remaining in this state as well. --- question/behaviour/interactive/behaviour.php | 8 ++------ .../interactive/lang/en/qbehaviour_interactive.php | 1 - .../behaviour/interactive/tests/walkthrough_test.php | 12 ++++-------- .../interactivecountback/tests/walkthrough_test.php | 3 +-- question/type/multianswer/tests/walkthrough_test.php | 3 +-- 5 files changed, 8 insertions(+), 19 deletions(-) diff --git a/question/behaviour/interactive/behaviour.php b/question/behaviour/interactive/behaviour.php index 53ede5b8cc853..6f534d6d0908a 100644 --- a/question/behaviour/interactive/behaviour.php +++ b/question/behaviour/interactive/behaviour.php @@ -136,12 +136,8 @@ public function get_state_string($showcorrectness) { return parent::get_state_string($showcorrectness); } - if ($this->is_try_again_state()) { - return get_string('notcomplete', 'qbehaviour_interactive'); - } else { - return get_string('triesremaining', 'qbehaviour_interactive', - $this->qa->get_last_behaviour_var('_triesleft')); - } + return get_string('triesremaining', 'qbehaviour_interactive', + $this->qa->get_last_behaviour_var('_triesleft')); } public function init_first_step(question_attempt_step $step, $variant) { diff --git a/question/behaviour/interactive/lang/en/qbehaviour_interactive.php b/question/behaviour/interactive/lang/en/qbehaviour_interactive.php index b6fe2e8de092d..8a4ebf63246eb 100644 --- a/question/behaviour/interactive/lang/en/qbehaviour_interactive.php +++ b/question/behaviour/interactive/lang/en/qbehaviour_interactive.php @@ -23,7 +23,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['notcomplete'] = 'Not complete'; $string['pluginname'] = 'Interactive with multiple tries'; $string['triesremaining'] = 'Tries remaining: {$a}'; $string['tryagain'] = 'Try again'; diff --git a/question/behaviour/interactive/tests/walkthrough_test.php b/question/behaviour/interactive/tests/walkthrough_test.php index 7e11e48cc272f..1e2d839138cbf 100644 --- a/question/behaviour/interactive/tests/walkthrough_test.php +++ b/question/behaviour/interactive/tests/walkthrough_test.php @@ -98,8 +98,7 @@ public function test_interactive_feedback_multichoice_right() { $this->get_contains_submit_button_expectation(false), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new question_pattern_expectation('/' . - preg_quote(get_string('notcomplete', 'qbehaviour_interactive'), '/') . '/'), + new question_pattern_expectation('/Tries remaining: 2/'), $this->get_contains_hint_expectation('This is the first hint')); // Check that, if we review in this state, the try again button is disabled. @@ -223,8 +222,7 @@ public function test_interactive_finish_when_try_again_showing() { $this->get_contains_submit_button_expectation(false), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new question_pattern_expectation('/' . - preg_quote(get_string('notcomplete', 'qbehaviour_interactive'), '/') . '/'), + new question_pattern_expectation('/Tries remaining: 1/'), $this->get_contains_hint_expectation('This is the first hint')); // Finish the attempt. @@ -288,8 +286,7 @@ public function test_interactive_shortanswer_try_to_submit_blank() { $this->get_contains_submit_button_expectation(false), $this->get_does_not_contain_validation_error_expectation(), $this->get_contains_try_again_button_expectation(true), - new question_pattern_expectation('/' . - preg_quote(get_string('notcomplete', 'qbehaviour_interactive'), '/') . '/'), + new question_pattern_expectation('/Tries remaining: 2/'), $this->get_contains_hint_expectation('This is the first hint')); $this->assertEquals('newt', $this->quba->get_response_summary($this->slot)); @@ -386,8 +383,7 @@ public function test_interactive_feedback_multichoice_multiple_reset() { $this->get_contains_submit_button_expectation(false), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new question_pattern_expectation('/' . - preg_quote(get_string('notcomplete', 'qbehaviour_interactive'), '/') . '/'), + new question_pattern_expectation('/Tries remaining: 2/'), $this->get_contains_hint_expectation('This is the first hint'), $this->get_contains_num_parts_correct(1), $this->get_contains_standard_incorrect_combined_feedback_expectation(), diff --git a/question/behaviour/interactivecountback/tests/walkthrough_test.php b/question/behaviour/interactivecountback/tests/walkthrough_test.php index aa577b8154598..8c87b3d2bc3b2 100644 --- a/question/behaviour/interactivecountback/tests/walkthrough_test.php +++ b/question/behaviour/interactivecountback/tests/walkthrough_test.php @@ -90,8 +90,7 @@ public function test_interactive_feedback_match_reset() { $this->get_contains_submit_button_expectation(false), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new question_pattern_expectation('/' . - preg_quote(get_string('notcomplete', 'qbehaviour_interactive'), '/') . '/'), + new question_pattern_expectation('/Tries remaining: 2/'), $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(), diff --git a/question/type/multianswer/tests/walkthrough_test.php b/question/type/multianswer/tests/walkthrough_test.php index 80e707d0f43e8..cb07b3f678697 100644 --- a/question/type/multianswer/tests/walkthrough_test.php +++ b/question/type/multianswer/tests/walkthrough_test.php @@ -422,8 +422,7 @@ public function test_interactivecountback_feedback() { $this->get_contains_submit_button_expectation(false), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new question_pattern_expectation('/' . - preg_quote(get_string('notcomplete', 'qbehaviour_interactive'), '/') . '/'), + new question_pattern_expectation('/Tries remaining: 2/'), $this->get_contains_hint_expectation('This is the first hint.')); // Check that extract responses will return the reset data.