Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions stack/input/dropdown/dropdown.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion tests/input_checkbox_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
8 changes: 8 additions & 0 deletions tests/input_dropdown_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<select data-stack-input-type="dropdown" id="menustack1__ans1" class="select'
. self::$moodleclass . ' menustack1__ans1" '
Expand All @@ -310,6 +312,12 @@ public function test_render_hidenonotanswered(): void {
), 'stack1__ans1', false, null));
}

public function test_validate_extra_options_hideanswer(): void {
$el = stack_input_factory::make('dropdown', 'ans1', $this->make_ta(), null, ['options' => 'hideanswer'], false);
$el->validate_extra_options();
$this->assertEquals([], $el->get_errors());
}

public function test_render_latex(): void {

$el = $this->make_dropdown(['options' => 'LaTeX']);
Expand Down
Loading