From a8547c406146929b24ee9b3a607e83f5aaec070b Mon Sep 17 00:00:00 2001 From: mkassaei Date: Mon, 23 Oct 2023 10:54:53 +0100 Subject: [PATCH] Fixing the codechecker issues --- edit_oumatrix_form.php | 2 +- tests/edit_oumatrix_form_test.php | 10 +++++----- tests/questiontype_test.php | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/edit_oumatrix_form.php b/edit_oumatrix_form.php index 81377ba..5abed6e 100644 --- a/edit_oumatrix_form.php +++ b/edit_oumatrix_form.php @@ -392,7 +392,7 @@ public function validation($data, $files) { $a->answerlabelshort = get_string('answerlabelshort', 'qtype_oumatrix', $colkey + 1); if ($data['inputtype'] == 'single') { foreach ($nonemptyrows as $key => $rowname) { - if (('a' . $colkey + 1) === $data['rowanswers'][$key]) { + if ('a' . ($colkey + 1) === $data['rowanswers'][$key]) { $errors['rowoptions[' . $key . ']'] = get_string('correctanswererror', 'qtype_oumatrix', $a); } diff --git a/tests/edit_oumatrix_form_test.php b/tests/edit_oumatrix_form_test.php index e6dd860..0348ede 100644 --- a/tests/edit_oumatrix_form_test.php +++ b/tests/edit_oumatrix_form_test.php @@ -82,7 +82,7 @@ protected function get_form($classname) { /** * Test the form correctly validates minimum requirements of rows and columns. */ - public function test_validation_cols_rows_minimum() { + public function test_validation_cols_rows_minimum(): void { [$form, $category] = $this->get_form('qtype_oumatrix_edit_form'); $helper = new qtype_oumatrix_test_helper(); $formdata = $helper->get_test_question_form_data('animals_single'); @@ -114,7 +114,7 @@ public function test_validation_cols_rows_minimum() { /** * Test the form correctly validates duplicates of rows and columns. */ - public function test_validation_cols_rows_duplicates() { + public function test_validation_cols_rows_duplicates(): void { [$form, $category] = $this->get_form('qtype_oumatrix_edit_form'); $helper = new qtype_oumatrix_test_helper(); $formdata = $helper->get_test_question_form_data('animals_single'); @@ -142,7 +142,7 @@ public function test_validation_cols_rows_duplicates() { /** * Test the form correctly validates if there are empty columns in between. */ - public function test_validation_column_names_empty() { + public function test_validation_column_names_empty(): void { [$form, $category] = $this->get_form('qtype_oumatrix_edit_form'); $helper = new qtype_oumatrix_test_helper(); $formdata = $helper->get_test_question_form_data('animals_single'); @@ -166,7 +166,7 @@ public function test_validation_column_names_empty() { /** * Test the form correctly validates if correct answers have been input. */ - public function test_validation_rowanswers() { + public function test_validation_rowanswers(): void { [$form, $category] = $this->get_form('qtype_oumatrix_edit_form'); $helper = new qtype_oumatrix_test_helper(); $formdata = $helper->get_test_question_form_data('animals_single'); @@ -186,7 +186,7 @@ public function test_validation_rowanswers() { /** * Test the form correctly validates if correct answers have been input. */ - public function test_validation_rowanswers_on_empty_columns() { + public function test_validation_rowanswers_on_empty_columns(): void { [$form, $category] = $this->get_form('qtype_oumatrix_edit_form'); $helper = new qtype_oumatrix_test_helper(); diff --git a/tests/questiontype_test.php b/tests/questiontype_test.php index 5597105..20637f6 100644 --- a/tests/questiontype_test.php +++ b/tests/questiontype_test.php @@ -48,7 +48,7 @@ protected function tearDown(): void { $this->qtype = null; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'oumatrix'); } @@ -71,14 +71,14 @@ public function todo_test_initialise_question_instance() { $this->assertEquals($expected, $q); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $helper = new qtype_oumatrix_test_helper(); $qdata = $helper->get_test_question_data('animals_single'); $expected = $this->qtype->get_num_correct_choices($qdata) / $this->qtype->get_total_number_of_choices($qdata); $this->assertEquals($expected, $this->qtype->get_random_guess_score($qdata)); } - public function test_get_random_guess_score_broken_question() { + public function test_get_random_guess_score_broken_question(): void { $helper = new qtype_oumatrix_test_helper(); $q = $helper->get_test_question_data('animals_single'); $q->columns = []; @@ -226,7 +226,7 @@ public function todo_test_get_question_options() { $this->assertCount(0, $options->answers); } - public function test_load_question() { + public function test_load_question(): void { $this->resetAfterTest(); /** @var \core_question_generator $generator */