Skip to content
Permalink
Browse files

MDL-53304 question behaviour: don't show useless Check buttons

Previously, the Check button was often shown disabled when it
could not be used (e.g. when the question was finished, or when an
interactive question was in the try-again state). Eventually we
realised it was better usability to hide it in these cases.

Note that when a teacher reviews an in-progress quiz attempt, they will
see a disabled Check button if the student doing the quiz can see the
button.
  • Loading branch information...
timhunt committed Mar 1, 2016
1 parent 7adc7ef commit 81e47a35e8bb98a94ea88e45eee63dcda1b46f74
@@ -232,7 +232,7 @@ public function test_adaptive_multichoice2() {
$this->check_current_mark(2);
$this->check_current_output(
$this->get_contains_mark_summary(2),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation());
}
@@ -310,7 +310,7 @@ public function test_adaptive_shortanswer_partially_right() {
$this->check_current_mark(0.8);
$this->check_current_output(
$this->get_contains_mark_summary(0.8),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation(),
$this->get_does_not_contain_validation_error_expectation());
}
@@ -393,7 +393,7 @@ public function test_adaptive_shortanswer_wrong_right_wrong() {
$this->check_current_mark(4.00);
$this->check_current_output(
$this->get_contains_mark_summary(4.00),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_incorrect_expectation(),
$this->get_does_not_contain_validation_error_expectation());
}
@@ -475,7 +475,7 @@ public function test_adaptive_shortanswer_invalid_after_complete() {
$this->check_current_mark(0.66666667);
$this->check_current_output(
$this->get_contains_mark_summary(0.67),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_incorrect_expectation(),
$this->get_does_not_contain_validation_error_expectation());
}
@@ -532,7 +532,7 @@ public function test_adaptive_shortanswer_zero_penalty() {
$this->check_current_mark(1.0);
$this->check_current_output(
$this->get_contains_mark_summary(1.0),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation(),
$this->get_does_not_contain_validation_error_expectation());
}
@@ -646,7 +646,7 @@ public function test_adaptive_numerical() {
$this->check_current_mark(1);
$this->check_current_output(
$this->get_contains_mark_summary(1),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_incorrect_expectation(),
$this->get_does_not_contain_validation_error_expectation());
}
@@ -749,7 +749,7 @@ public function test_adaptive_numerical_invalid() {
$this->check_current_mark(0.9);
$this->check_current_output(
$this->get_contains_mark_summary(0.9),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_incorrect_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_does_not_contain_disregarded_info_expectation());
@@ -848,7 +848,7 @@ public function test_adaptive_multianswer() {
$this->check_output_contains_text_input_with_class('sub1_answer', 'correct');
$this->check_current_output(
$this->get_contains_mark_summary(8.00),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation(),
$this->get_does_not_contain_validation_error_expectation());
}
@@ -213,7 +213,7 @@ public function test_multichoice2() {
$this->check_current_mark(2);
$this->check_current_output(
$this->get_contains_mark_summary(2),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation());
}
@@ -305,7 +305,7 @@ public function test_numerical_invalid() {
$this->check_current_mark(1.0);
$this->check_current_output(
$this->get_contains_mark_summary(1.0),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_incorrect_expectation(),
$this->get_does_not_contain_validation_error_expectation());
}
@@ -36,6 +36,9 @@
*/
class qbehaviour_interactive_renderer extends qbehaviour_renderer {
public function controls(question_attempt $qa, question_display_options $options) {
if ($options->readonly === qbehaviour_interactive::READONLY_EXCEPT_TRY_AGAIN) {
return '';
}
return $this->submit_button($qa, $options);
}
@@ -95,7 +95,7 @@ public function test_interactive_feedback_multichoice_right() {
$this->get_contains_mc_radio_expectation($wrongindex, false, true),
$this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, false, false),
$this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, false, false),
$this->get_contains_submit_button_expectation(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/'),
@@ -135,7 +135,7 @@ public function test_interactive_feedback_multichoice_right() {
$this->get_contains_mc_radio_expectation($rightindex, false, true),
$this->get_contains_mc_radio_expectation(($rightindex + 1) % 3, false, false),
$this->get_contains_mc_radio_expectation(($rightindex + 1) % 3, false, false),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation(),
$this->get_no_hint_visible_expectation());
@@ -219,7 +219,7 @@ public function test_interactive_finish_when_try_again_showing() {
$this->get_contains_mc_radio_expectation($wrongindex, false, true),
$this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, false, false),
$this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, false, false),
$this->get_contains_submit_button_expectation(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: 1/'),
@@ -283,7 +283,7 @@ public function test_interactive_shortanswer_try_to_submit_blank() {
$this->check_current_mark(null);
$this->check_current_output(
$this->get_contains_marked_out_of_summary(),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_contains_try_again_button_expectation(true),
new question_pattern_expectation('/Tries remaining: 2/'),
@@ -327,7 +327,7 @@ public function test_interactive_shortanswer_try_to_submit_blank() {
$this->check_current_mark(0.6666667);
$this->check_current_output(
$this->get_contains_mark_summary(0.6666667),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_no_hint_visible_expectation());
@@ -380,7 +380,7 @@ public function test_interactive_feedback_multichoice_multiple_reset() {
$this->get_contains_mc_checkbox_expectation($right[1], false, false),
$this->get_contains_mc_checkbox_expectation($wrong[0], false, true),
$this->get_contains_mc_checkbox_expectation($wrong[1], false, false),
$this->get_contains_submit_button_expectation(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/'),
@@ -87,7 +87,7 @@ public function test_interactive_feedback_match_reset() {
$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_contains_submit_button_expectation(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/'),
@@ -139,7 +139,7 @@ public function test_interactive_feedback_match_reset() {
$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_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(),
@@ -208,6 +208,9 @@ public function manual_comment(question_attempt $qa, question_display_options $o
* @return string HTML fragment.
*/
protected function submit_button(question_attempt $qa, question_display_options $options) {
if (!$qa->get_state()->is_active()) {
return '';
}
$attributes = array(
'type' => 'submit',
'id' => $qa->get_behaviour_field_name('submit'),
@@ -1,5 +1,15 @@
This files describes API changes for question behaviour plugins.

=== 3.1 ===

1) The standard behaviours that use a 'Check' button have all been changed so
that they only show the button when the question is active. Your behaviour
may interit this behaviour, because the change was made in the base class,
and this is probably good for consistency. However, if your question behaviour
uses the Check button, your probably want to test it carefully, and you will
probably have to update your unit tests. See MDL-53304 for more details.


=== 2.9 ===

1) There are new methods question_behaviour::can_finish_during_attempt and
@@ -1103,11 +1103,27 @@ protected function get_contains_button_expectation($name, $value = null, $enable
return new question_contains_tag_with_attributes('input', $expectedattributes, $forbiddenattributes);
}
/**
* Returns an epectation that a string contains the HTML of a button with
* name {question-attempt prefix}-submit, and eiter enabled or not.
* @param bool $enabled if not null, check the enabled/disabled state of the button. True = enabled.
* @return question_contains_tag_with_attributes an expectation for use with check_current_output.
*/
protected function get_contains_submit_button_expectation($enabled = null) {
return $this->get_contains_button_expectation(
$this->quba->get_field_prefix($this->slot) . '-submit', null, $enabled);
}
/**
* Returns an epectation that a string does not contain the HTML of a button with
* name {question-attempt prefix}-submit.
* @return question_contains_tag_with_attributes an expectation for use with check_current_output.
*/
protected function get_does_not_contain_submit_button_expectation() {
return new question_no_pattern_expectation('/name="' .
$this->quba->get_field_prefix($this->slot) . '-submit"/');
}
protected function get_tries_remaining_expectation($n) {
return new question_pattern_expectation('/' .
preg_quote(get_string('triesremaining', 'qbehaviour_interactive', $n), '/') . '/');
@@ -98,7 +98,7 @@ public function test_interactive() {
$this->check_current_mark(3);
$this->check_current_output(
$this->get_contains_mark_summary(3),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_no_hint_visible_expectation());
@@ -98,7 +98,7 @@ public function test_interactive() {
$this->check_current_mark(3);
$this->check_current_output(
$this->get_contains_mark_summary(3),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_no_hint_visible_expectation());
@@ -97,7 +97,7 @@ public function test_interactive() {
$this->check_current_mark(3);
$this->check_current_output(
$this->get_contains_mark_summary(3),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_no_hint_visible_expectation());
@@ -180,7 +180,7 @@ public function test_interactive_behaviour() {
$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_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation(),
$this->get_no_hint_visible_expectation());
@@ -469,7 +469,7 @@ public function test_interactive_grading() {
$this->get_contains_drag_image_home_expectation(2, 2, 1),
$this->get_contains_drag_image_home_expectation(3, 1, 2),
$this->get_contains_drag_image_home_expectation(4, 2, 2),
$this->get_contains_submit_button_expectation(false),
$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'),
@@ -530,7 +530,7 @@ public function test_interactive_grading() {
$this->get_contains_drag_image_home_expectation(2, 2, 1),
$this->get_contains_drag_image_home_expectation(3, 1, 2),
$this->get_contains_drag_image_home_expectation(4, 2, 2),
$this->get_contains_submit_button_expectation(false),
$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 second hint'),
@@ -592,7 +592,7 @@ public function test_interactive_grading() {
$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_submit_button_expectation(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_no_hint_visible_expectation(),
@@ -648,7 +648,7 @@ public function test_interactive_correct_no_submit() {
$this->get_contains_drag_image_home_expectation(2, 2, 1),
$this->get_contains_drag_image_home_expectation(3, 1, 2),
$this->get_contains_drag_image_home_expectation(4, 2, 2),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_correct_expectation(),
$this->get_no_hint_visible_expectation());
@@ -710,7 +710,7 @@ public function test_interactive_partial_no_submit() {
$this->get_contains_drag_image_home_expectation(2, 2, 1),
$this->get_contains_drag_image_home_expectation(3, 1, 2),
$this->get_contains_drag_image_home_expectation(4, 2, 2),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_partcorrect_expectation(),
$this->get_no_hint_visible_expectation());
@@ -769,7 +769,7 @@ public function test_interactive_no_right_clears() {
$this->get_contains_drag_image_home_expectation(2, 2, 1),
$this->get_contains_drag_image_home_expectation(3, 1, 2),
$this->get_contains_drag_image_home_expectation(4, 2, 2),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_submit_button_expectation(),
$this->get_contains_hint_expectation('This is the first hint'));
// Do try again.
Oops, something went wrong.

0 comments on commit 81e47a3

Please sign in to comment.
You can’t perform that action at this time.