MDL-29771 interactive behaviour: better state text in try again state
authorTim Hunt <T.J.Hunt@open.ac.uk>
Sun, 31 May 2015 20:09:55 +0000 (21:09 +0100)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Sun, 31 May 2015 20:09:55 +0000 (21:09 +0100)
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
question/behaviour/interactive/lang/en/qbehaviour_interactive.php
question/behaviour/interactive/tests/walkthrough_test.php
question/behaviour/interactivecountback/tests/walkthrough_test.php
question/type/multianswer/tests/walkthrough_test.php

index 53ede5b..6f534d6 100644 (file)
@@ -136,12 +136,8 @@ class qbehaviour_interactive extends question_behaviour_with_multiple_tries {
             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) {
index b6fe2e8..8a4ebf6 100644 (file)
@@ -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';
index 7e11e48..1e2d839 100644 (file)
@@ -98,8 +98,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes
                 $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 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes
                 $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 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes
                 $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 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes
                 $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(),
index aa577b8..8c87b3d 100644 (file)
@@ -90,8 +90,7 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
                 $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(),
index 80e707d..cb07b3f 100644 (file)
@@ -422,8 +422,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
                 $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.