diff --git a/stack/input/dropdown/dropdown.class.php b/stack/input/dropdown/dropdown.class.php index 016312a63ba..e1250780931 100644 --- a/stack/input/dropdown/dropdown.class.php +++ b/stack/input/dropdown/dropdown.class.php @@ -90,6 +90,12 @@ protected function internal_construct() { } else { $this->extraoptions[$opt] = $arg; } + // ISS1824 - The extraoptions we're testing against here are just hideanswer and + // allowempty because dropdown does not override base class extraoptions like other + // inputs. This is a bit of a landmine and we should consider a refactor longer term. + // For minimal code change now, continue allows multiple options but doesn't trigger the fall through + // to error in the switch below for hideanswer and allowempty. + continue; } switch ($option) { diff --git a/tests/input_checkbox_test.php b/tests/input_checkbox_test.php index 6c5e4d7a98a..586f7c4d808 100644 --- a/tests/input_checkbox_test.php +++ b/tests/input_checkbox_test.php @@ -641,4 +641,11 @@ public function test_validate_student_response_with_allowempty_nocorrect(): void $this->assertEquals('', $state->errors); $this->assertEquals('A correct answer is: This input can be left blank.', $el->get_teacher_answer_display($state->contentsmodified, $state->contentsdisplayed)); - }} + } + + public function test_validate_extra_options_hideanswer(): void { + $el = stack_input_factory::make('checkbox', 'ans1', $this->make_ta(), null, ['options' => 'hideanswer'], false); + $el->validate_extra_options(); + $this->assertEquals([], $el->get_errors()); + } +} diff --git a/tests/input_dropdown_test.php b/tests/input_dropdown_test.php index 5b91813dfc3..a6c15fcbaed 100644 --- a/tests/input_dropdown_test.php +++ b/tests/input_dropdown_test.php @@ -293,6 +293,8 @@ public function test_render_nonotanswered(): void { public function test_render_hidenonotanswered(): void { $el = $this->make_dropdown(['options' => 'hideanswer,nonotanswered']); + $el->validate_extra_options(); + $this->assertEquals([], $el->get_errors()); $el->adapt_to_model_answer($this->make_ta()); $expected = '