Skip to content

Commit

Permalink
Fixing the codechecker issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mkassaei committed Oct 23, 2023
1 parent b56f8ed commit a8547c4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion edit_oumatrix_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions tests/edit_oumatrix_form_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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();

Expand Down
8 changes: 4 additions & 4 deletions tests/questiontype_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand All @@ -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 = [];
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit a8547c4

Please sign in to comment.