From 86a309686900a1fd0c1ed3a063cc40963f599824 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Sun, 22 Oct 2023 20:07:45 +0100 Subject: [PATCH] Fix codechecker warnings --- .../backup_qtype_crossword_plugin.class.php | 7 +- .../restore_qtype_crossword_plugin.class.php | 2 +- classes/util.php | 3 +- edit_crossword_form.php | 9 +- renderer.php | 6 +- tests/answer_test.php | 6 +- tests/backup_test.php | 24 +-- tests/form_test.php | 146 ++++++------------ tests/helper.php | 65 ++++---- tests/question_test.php | 26 ++-- tests/question_type_test.php | 14 +- tests/util_test.php | 22 +-- 12 files changed, 149 insertions(+), 181 deletions(-) diff --git a/backup/moodle2/backup_qtype_crossword_plugin.class.php b/backup/moodle2/backup_qtype_crossword_plugin.class.php index 9cd398e..c8abeaa 100644 --- a/backup/moodle2/backup_qtype_crossword_plugin.class.php +++ b/backup/moodle2/backup_qtype_crossword_plugin.class.php @@ -38,6 +38,7 @@ protected function define_question_plugin_structure(): backup_plugin_element { $plugin->add_child($pluginwrapper); // Now create the qtype own structures. + // phpcs:ignore NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLine $crossword = new backup_nested_element('crossword', ['id'], ['correctfeedback', 'correctfeedbackformat', 'numrows', 'numcolumns', 'accentgradingtype', 'accentpenalty', 'partiallycorrectfeedback', 'partiallycorrectfeedbackformat', @@ -45,8 +46,8 @@ protected function define_question_plugin_structure(): backup_plugin_element { // Define the elements. $words = new backup_nested_element('words'); - $word = new backup_nested_element('word', ['id'], ['answer', 'clue', 'clueformat', 'orientation', 'startrow', - 'startcolumn', 'feedback', 'feedbackformat']); + $word = new backup_nested_element('word', ['id'], + ['answer', 'clue', 'clueformat', 'orientation', 'startrow', 'startcolumn', 'feedback', 'feedbackformat']); $words->add_child($word); $pluginwrapper->add_child($crossword); $pluginwrapper->add_child($words); @@ -61,7 +62,7 @@ protected function define_question_plugin_structure(): backup_plugin_element { public static function get_qtype_fileareas() { return [ 'clue' => 'qtype_crossword_words', - 'feedback' => 'qtype_crossword_words' + 'feedback' => 'qtype_crossword_words', ]; } } diff --git a/backup/moodle2/restore_qtype_crossword_plugin.class.php b/backup/moodle2/restore_qtype_crossword_plugin.class.php index 057dd80..c8e01b8 100644 --- a/backup/moodle2/restore_qtype_crossword_plugin.class.php +++ b/backup/moodle2/restore_qtype_crossword_plugin.class.php @@ -33,7 +33,7 @@ protected function define_question_plugin_structure(): array { // We used get_recommended_name() so this works. $elements = [ 'qtype_crossword' => '/crossword', - 'qtype_crossword_word' => '/words/word' + 'qtype_crossword_word' => '/words/word', ]; foreach ($elements as $elename => $path) { diff --git a/classes/util.php b/classes/util.php index 4e885d5..67ae068 100644 --- a/classes/util.php +++ b/classes/util.php @@ -15,8 +15,9 @@ // along with Moodle. If not, see . namespace qtype_crossword; + use Normalizer; -use \qtype_crossword_question; + /** * Static utilities. * diff --git a/edit_crossword_form.php b/edit_crossword_form.php index fbc8c56..3d3f088 100644 --- a/edit_crossword_form.php +++ b/edit_crossword_form.php @@ -81,7 +81,7 @@ protected function get_per_answer_fields($mform, $label, $gradeoptions, get_string('orientation', 'qtype_crossword'), [ get_string('across', 'qtype_crossword'), - get_string('down', 'qtype_crossword') + get_string('down', 'qtype_crossword'), ], null ); @@ -526,7 +526,12 @@ protected function find_conflicting_overlapping_letters(array $data, int $index, * * @return array The coordinate of the start and end of the word, [x1, y1, x2, y2]. */ - protected function calculate_word_coordinates(string $startrow, string $startcolumn, string $answer, string $orientation): array { + protected function calculate_word_coordinates( + string $startrow, + string $startcolumn, + string $answer, + string $orientation + ): array { $x1 = (int) $startcolumn; $y1 = (int) $startrow; // Get answer length. diff --git a/renderer.php b/renderer.php index 5793bba..8445c8f 100644 --- a/renderer.php +++ b/renderer.php @@ -39,7 +39,7 @@ public function formulation_and_controls(question_attempt $qa, $data = []; $orientationvalue = [ get_string('across', 'qtype_crossword'), - get_string('down', 'qtype_crossword') + get_string('down', 'qtype_crossword'), ]; $binddata = [ 'colsNum' => $question->numcolumns + 3, @@ -47,7 +47,7 @@ public function formulation_and_controls(question_attempt $qa, 'isPreview' => false, 'title' => get_string('celltitle', 'qtype_crossword'), 'orientation' => $orientationvalue, - 'readonly' => false + 'readonly' => false, ]; $data['questiontext'] = $question->format_questiontext($qa); foreach ($question->answers as $key => $answer) { @@ -91,7 +91,7 @@ public function formulation_and_controls(question_attempt $qa, 'startRow' => (int) $answer->startrow, 'startColumn' => (int) $answer->startcolumn, 'ignoreIndexes' => json_encode($ignoreindex), - 'wordNumber' => $answer->answernumber + 'wordNumber' => $answer->answernumber, ]; if ($options->readonly) { diff --git a/tests/answer_test.php b/tests/answer_test.php index df65124..7471c06 100644 --- a/tests/answer_test.php +++ b/tests/answer_test.php @@ -53,11 +53,11 @@ public function test_is_correct(array $answerdata) { public function test_is_correct_provider(): array { return [ 'Normal case' => [ - ['TIM BERNERS-LEE', 'GORDON BROWN', 'DAVID ATTENBOROUGH'] + ['TIM BERNERS-LEE', 'GORDON BROWN', 'DAVID ATTENBOROUGH'], ], 'With Underscore' => [ - ['TIM_BERNERS-LEE', 'GORDON_BROWN', 'DAVID_ATTENBOROUGH'] - ] + ['TIM_BERNERS-LEE', 'GORDON_BROWN', 'DAVID_ATTENBOROUGH'], + ], ]; } diff --git a/tests/backup_test.php b/tests/backup_test.php index b906aa0..fa18819 100644 --- a/tests/backup_test.php +++ b/tests/backup_test.php @@ -92,22 +92,22 @@ public function test_cw_backup_data_provider(): array { 'clueformat' => FORMAT_HTML, 'feedback' => null, 'feedbackformat' => FORMAT_HTML, - 'answer' => 'BRAZIL' + 'answer' => 'BRAZIL', ], [ 'clue' => 'Eiffel Tower is located in?', 'clueformat' => FORMAT_HTML, 'feedback' => null, 'feedbackformat' => FORMAT_HTML, - 'answer' => 'PARIS' + 'answer' => 'PARIS', ], [ 'clue' => 'Where is the Leaning Tower of Pisa?', 'clueformat' => FORMAT_HTML, 'feedback' => null, 'feedbackformat' => FORMAT_HTML, - 'answer' => 'ITALY' - ] + 'answer' => 'ITALY', + ], ], 'version' => 4, ], @@ -122,22 +122,22 @@ public function test_cw_backup_data_provider(): array { 'clueformat' => FORMAT_HTML, 'feedback' => '

You are correct.

', 'feedbackformat' => FORMAT_HTML, - 'answer' => 'BRAZIL' + 'answer' => 'BRAZIL', ], [ 'clue' => '

Eiffel Tower is located in?

', 'clueformat' => FORMAT_HTML, 'feedback' => '

You are correct.

', 'feedbackformat' => FORMAT_HTML, - 'answer' => 'PARIS' + 'answer' => 'PARIS', ], [ 'clue' => '

Where is the Leaning Tower of Pisa?

', 'clueformat' => FORMAT_HTML, 'feedback' => '

You are correct.

', 'feedbackformat' => FORMAT_HTML, - 'answer' => 'ITALY' - ] + 'answer' => 'ITALY', + ], ], 'version' => 4, ], @@ -152,22 +152,22 @@ public function test_cw_backup_data_provider(): array { 'clueformat' => FORMAT_HTML, 'feedback' => null, 'feedbackformat' => FORMAT_HTML, - 'answer' => 'BRAZIL' + 'answer' => 'BRAZIL', ], [ 'clue' => 'Eiffel Tower is located in?', 'clueformat' => FORMAT_HTML, 'feedback' => null, 'feedbackformat' => FORMAT_HTML, - 'answer' => 'PARIS' + 'answer' => 'PARIS', ], [ 'clue' => 'Where is the Leaning Tower of Pisa?', 'clueformat' => FORMAT_HTML, 'feedback' => null, 'feedbackformat' => FORMAT_HTML, - 'answer' => 'ITALY' - ] + 'answer' => 'ITALY', + ], ], 'version' => 3, ], diff --git a/tests/form_test.php b/tests/form_test.php index b58e1db..fb195f6 100644 --- a/tests/form_test.php +++ b/tests/form_test.php @@ -51,167 +51,121 @@ public function form_validation_testcases(): array { 'Normal case' => [ [ 'noanswers' => 3, - 'answer' => [ - 'BRAZIL', 'PARIS', 'ITALY' - ], + 'answer' => ['BRAZIL', 'PARIS', 'ITALY'], 'clue' => [ ['text' => 'where is the Christ the Redeemer statue located in?', 'format' => FORMAT_HTML], ['text' => 'Eiffel Tower is located in?', 'format' => FORMAT_HTML], - ['text' => 'Where is the Leaning Tower of Pisa?', 'format' => FORMAT_HTML] - ], - 'orientation' => [ - 0, 1, 0 - ], - 'startrow' => [ - 1, 0, 3 + ['text' => 'Where is the Leaning Tower of Pisa?', 'format' => FORMAT_HTML], ], - 'startcolumn' => [ - 0, 2, 2 - ], - ], [] + 'orientation' => [0, 1, 0], + 'startrow' => [1, 0, 3], + 'startcolumn' => [0, 2, 2], + ], + [], ], 'The letter at the intersection of two words do not match' => [ [ 'noanswers' => 3, - 'answer' => [ - 'AAA', 'BBB', 'CCC' - ], + 'answer' => ['AAA', 'BBB', 'CCC'], 'clue' => [ ['text' => 'Clue A', 'format' => FORMAT_HTML], ['text' => 'Clue B', 'format' => FORMAT_HTML], - ['text' => 'Clue C', 'format' => FORMAT_HTML] - ], - 'orientation' => [ - 0, 0, 0 - ], - 'startrow' => [ - 0, 0, 0 - ], - 'startcolumn' => [ - 0, 0, 0 + ['text' => 'Clue C', 'format' => FORMAT_HTML], ], + 'orientation' => [0, 0, 0], + 'startrow' => [0, 0, 0], + 'startcolumn' => [0, 0, 0], ], [ 'answer[1]' => get_string('wrongintersection', 'qtype_crossword'), 'answer[2]' => get_string('wrongintersection', 'qtype_crossword') - ] + ], ], 'Requires at least 1 word' => [ [ 'noanswers' => 3, - 'answer' => [ - '', '', '' - ], + 'answer' => ['', '', ''], 'clue' => [ ['text' => '', 'format' => FORMAT_HTML], ['text' => '', 'format' => FORMAT_HTML], ['text' => '', 'format' => FORMAT_HTML] ], - 'orientation' => [ - 0, 0, 0 - ], - 'startrow' => [ - 0, 0, 0 - ], - 'startcolumn' => [ - 0, 0, 0 - ], - ], ['answer[0]' => get_string('notenoughwords', 'qtype_crossword', 1)] + 'orientation' => [0, 0, 0], + 'startrow' => [0, 0, 0], + 'startcolumn' => [0, 0, 0], + ], + [ + 'answer[0]' => get_string('notenoughwords', 'qtype_crossword', 1), + ], ], 'The word start or end position is outside the defined grid size' => [ [ 'noanswers' => 3, - 'answer' => [ - 'Toolongtext', 'BBB', 'CCC' - ], + 'answer' => ['Toolongtext', 'BBB', 'CCC'], 'clue' => [ ['text' => 'Clue A', 'format' => FORMAT_HTML], ['text' => 'Clue B', 'format' => FORMAT_HTML], - ['text' => 'Clue C', 'format' => FORMAT_HTML] - ], - 'orientation' => [ - 0, 0, 0 - ], - 'startrow' => [ - 0, 1, 2 - ], - 'startcolumn' => [ - 0, 0, 0 + ['text' => 'Clue C', 'format' => FORMAT_HTML], ], - ], ['answer[0]' => get_string('overflowposition', 'qtype_crossword')] + 'orientation' => [0, 0, 0], + 'startrow' => [0, 1, 2], + 'startcolumn' => [0, 0, 0], + ], + [ + 'answer[0]' => get_string('overflowposition', 'qtype_crossword'), + ], ], 'The answer must be alphanumeric characters only' => [ [ 'noanswers' => 3, - 'answer' => [ - 'Speci@al char*', 'BBB', 'CCC' - ], + 'answer' => ['Speci@al char*', 'BBB', 'CCC'], 'clue' => [ ['text' => 'Clue A', 'format' => FORMAT_HTML], ['text' => 'Clue B', 'format' => FORMAT_HTML], - ['text' => 'Clue C', 'format' => FORMAT_HTML] - ], - 'orientation' => [ - 0, 0, 0 + ['text' => 'Clue C', 'format' => FORMAT_HTML], ], - 'startrow' => [ - 0, 1, 2 - ], - 'startcolumn' => [ - 0, 0, 0 - ], - ], ['answer[0]' => get_string('mustbealphanumeric', 'qtype_crossword')] + 'orientation' => [0, 0, 0], + 'startrow' => [0, 1, 2], + 'startcolumn' => [0, 0, 0], + ], + [ + 'answer[0]' => get_string('mustbealphanumeric', 'qtype_crossword'), + ], ], 'The word must have both clues and answers' => [ [ 'noanswers' => 3, - 'answer' => [ - 'AAA', '', 'CCC' - ], + 'answer' => ['AAA', '', 'CCC'], 'clue' => [ ['text' => '', 'format' => FORMAT_HTML], ['text' => 'Clue B', 'format' => FORMAT_HTML], ['text' => 'Clue C', 'format' => FORMAT_HTML] ], - 'orientation' => [ - 0, 0, 0 - ], - 'startrow' => [ - 0, 1, 2 - ], - 'startcolumn' => [ - 0, 0, 0 - ], + 'orientation' => [0, 0, 0], + 'startrow' => [0, 1, 2], + 'startcolumn' => [0, 0, 0], ], [ 'answer[1]' => get_string('pleaseenterclueandanswer', 'qtype_crossword', 2), 'clue[0]' => get_string('pleaseenterclueandanswer', 'qtype_crossword', 1), - ] + ], ], 'Ensure a unique answer number for each orientation.' => [ [ 'noanswers' => 3, - 'answer' => [ - 'ABC', 'ACB', 'ABC' - ], + 'answer' => ['ABC', 'ACB', 'ABC'], 'clue' => [ ['text' => 'Clue A', 'format' => FORMAT_HTML], ['text' => 'Clue B', 'format' => FORMAT_HTML], - ['text' => 'Clue C', 'format' => FORMAT_HTML] - ], - 'orientation' => [ - 0, 1, 0 - ], - 'startrow' => [ - 0, 0, 0 - ], - 'startcolumn' => [ - 0, 0, 0 + ['text' => 'Clue C', 'format' => FORMAT_HTML], ], + 'orientation' => [0, 1, 0], + 'startrow' => [0, 0, 0], + 'startcolumn' => [0, 0, 0], ], [ 'answer[2]' => get_string('wrongoverlappingwords', 'qtype_crossword', 'ABC'), - ] + ], ] ]; } diff --git a/tests/helper.php b/tests/helper.php index b935863..1945e2e 100644 --- a/tests/helper.php +++ b/tests/helper.php @@ -43,6 +43,7 @@ class qtype_crossword_test_helper extends question_test_helper { * @return array The test question array. */ public function get_test_questions(): array { + // phpcs:ignore NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLine return ['normal', 'unicode', 'different_codepoint', 'sampleimage', 'clear_incorrect_response', 'normal_with_hyphen_and_space', 'not_accept_wrong_accents', 'accept_wrong_accents_but_subtract_point', @@ -153,15 +154,15 @@ public function get_crossword_question_form_data_normal() { $fromform->clue = [ [ 'text' => 'Eiffel Tower is located in?', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], [ 'text' => 'where is the Christ the Redeemer statue located in?', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], [ 'text' => 'Where is the Leaning Tower of Pisa?', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], ]; $fromform->orientation = [1, 0, 0]; @@ -177,24 +178,30 @@ public function get_crossword_question_form_data_normal() { /** * Makes a normal crossword question with a sample image in question text. * - * @return qtype_crossword_question + * @return stdClass */ - public function get_crossword_question_form_data_sampleimage() { + public function get_crossword_question_form_data_sampleimage(): stdClass { $fromform = $this->get_crossword_question_form_data_normal(); - $fromform->correctfeedback = ['text' => 'Correct feedback ', - 'format' => FORMAT_HTML]; - $fromform->partiallycorrectfeedback = ['text' => 'Partially correct feedback. FORMAT_HTML]; - $fromform->incorrectfeedback = ['text' => 'Incorrect feedback. FORMAT_HTML]; + $fromform->correctfeedback = [ + 'text' => 'Correct feedback ', + 'format' => FORMAT_HTML, + ]; + $fromform->partiallycorrectfeedback = [ + 'text' => 'Partially correct feedback. FORMAT_HTML, + ]; + $fromform->incorrectfeedback = [ + 'text' => 'Incorrect feedback. FORMAT_HTML, + ]; $fromform->questiontext = [ 'text' => 'Cross word question text with sample image ', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ]; $fromform->feedback = [ [ 'text' => 'where is the Christ the Redeemer statue located in? ', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], ]; $fromform->clue[0]['text'] = 'Eiffel Tower is located in?' . @@ -299,15 +306,15 @@ public function get_crossword_question_form_data_unicode() { $fromform->clue = [ [ 'text' => '线索 1', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], [ 'text' => '线索 2', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], [ 'text' => '线索 3', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], ]; $fromform->orientation = [1, 0, 1]; @@ -380,7 +387,7 @@ public function make_crossword_question_different_codepoint() { $answer->startcolumn, $answer->feedback, $answer->feedbackformat, - $answer->answernumber + $answer->answernumber, ); } return $cw; @@ -402,11 +409,11 @@ public function get_crossword_question_form_data_different_codepoint() { $fromform->clue = [ [ 'text' => 'Answer contains letter é has codepoint \u00e9', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], [ 'text' => 'Answer contains letter é has codepoint \u0065\u0301', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], ]; $fromform->orientation = [0, 1]; @@ -432,7 +439,7 @@ public function make_crossword_question_clear_incorrect_response() { /** * Get a crossword with the clear incorrect response options. * - * @return qtype_crossword_question + * @return stdClass */ public function get_crossword_question_form_data_clear_incorrect_response() { $fromform = $this->get_crossword_question_form_data_normal(); @@ -443,7 +450,7 @@ public function get_crossword_question_form_data_clear_incorrect_response() { * Retrieve the context object. * @param \context $context the current context. * - * @return object The context object. + * @return question_edit_contexts The context object. */ public static function question_edit_contexts(\context $context): object { if (class_exists('\core_question\local\bank\question_edit_contexts')) { @@ -501,7 +508,7 @@ public function make_crossword_question_normal_with_hyphen_and_space() { 'orientation' => 1, 'feedback' => '', 'feedbackformat' => FORMAT_HTML, - 'answernumber' => 1 + 'answernumber' => 1, ], (object) [ 'id' => 2, @@ -514,7 +521,7 @@ public function make_crossword_question_normal_with_hyphen_and_space() { 'orientation' => 1, 'feedback' => '', 'feedbackformat' => FORMAT_HTML, - 'answernumber' => 2 + 'answernumber' => 2, ], (object) [ 'id' => 3, @@ -527,7 +534,7 @@ public function make_crossword_question_normal_with_hyphen_and_space() { 'orientation' => 0, 'feedback' => '', 'feedbackformat' => FORMAT_HTML, - 'answernumber' => 3 + 'answernumber' => 3, ], ]; @@ -564,15 +571,15 @@ public function get_crossword_question_form_data_normal_with_hyphen_and_space() $fromform->clue = [ [ 'text' => 'Engineer, computer scientist and inventor of the World Wide Web?', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], [ 'text' => 'Former Prime Minister of the United Kingdom?', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], [ 'text' => 'British broadcaster and naturalist, famous for his voice-overs of nature programmes?', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], ]; $fromform->orientation = [1, 1, 0]; @@ -678,11 +685,11 @@ public function get_crossword_question_form_data_not_accept_wrong_accents() { $fromform->clue = [ [ 'text' => 'Des accompagnements à base de foie animal ?', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], [ 'text' => 'Appareil utilisé pour passer des appels ?', - 'format' => FORMAT_HTML + 'format' => FORMAT_HTML, ], ]; $fromform->orientation = [0, 1]; diff --git a/tests/question_test.php b/tests/question_test.php index ba28e9e..cb8769f 100644 --- a/tests/question_test.php +++ b/tests/question_test.php @@ -70,28 +70,28 @@ public function clear_wrong_from_response_provider(): array { return [ 'Empty answer' => [ [], - [] + [], ], 'Partial correct answers' => [ ['sub0' => 'PARI', 'sub1' => 'BRZIL', 'sub2' => 'ITALY'], - ['sub2' => 'ITALY', 'sub0' => '', 'sub1' => ''] + ['sub2' => 'ITALY', 'sub0' => '', 'sub1' => ''], ], 'Correct answers is not in ordered' => [ ['sub1' => 'BRAZIL', 'sub0' => 'PARIS', 'sub2' => 'ITALY'], - ['sub1' => 'BRAZIL', 'sub0' => 'PARIS', 'sub2' => 'ITALY'] + ['sub1' => 'BRAZIL', 'sub0' => 'PARIS', 'sub2' => 'ITALY'], ], 'Correct answers is in ordered' => [ ['sub0' => 'PARIS', 'sub1' => 'BRAZIL', 'sub2' => 'ITALY'], - ['sub0' => 'PARIS', 'sub1' => 'BRAZIL', 'sub2' => 'ITALY'] + ['sub0' => 'PARIS', 'sub1' => 'BRAZIL', 'sub2' => 'ITALY'], ], 'Not completed answers' => [ ['sub1' => 'BRAZIL', 'sub2' => 'ITALY'], - ['sub1' => 'BRAZIL', 'sub2' => 'ITALY'] + ['sub1' => 'BRAZIL', 'sub2' => 'ITALY'], ], 'Not completed and incorrect answer' => [ ['sub1' => 'BRAZIL', 'sub2' => 'ITALI'], - ['sub1' => 'BRAZIL', 'sub2' => ''] - ] + ['sub1' => 'BRAZIL', 'sub2' => ''], + ], ]; } @@ -121,12 +121,12 @@ public function clear_wrong_from_response_with_accent(): array { 'Ignore accent' => [ 'accept_wrong_accents_but_not_subtract_point', ['sub0' => 'PATE', 'sub1' => 'TELEPHONE'], - ['sub0' => 'PATE', 'sub1' => 'TELEPHONE'] + ['sub0' => 'PATE', 'sub1' => 'TELEPHONE'], ], 'Partial correct answers with accent' => [ 'accept_wrong_accents_but_subtract_point', ['sub0' => 'PÂTÉ', 'sub1' => 'TELEPHONE'], - ['sub0' => 'PÂTÉ', 'sub1' => ''] + ['sub0' => 'PÂTÉ', 'sub1' => ''], ], ]; } @@ -199,16 +199,16 @@ public function remove_blank_words_from_response_testcases(): array { return [ 'answer_valid_list' => [ ['sub0' => 'BRAZIL', 'sub1' => 'PARIS', 'sub2' => 'ITALY'], - 3 + 3, ], 'answer_invalid_list_with_underscore' => [ ['sub0' => 'BRAZIL', 'sub1' => '____', 'sub2' => 'IT_LY'], - 2 + 2, ], 'answer_invalid_list_with_empty_string' => [ ['sub0' => '', 'sub1' => '', 'sub2' => ''], - 0 - ] + 0, + ], ]; } diff --git a/tests/question_type_test.php b/tests/question_type_test.php index c69074b..b2aecf3 100644 --- a/tests/question_type_test.php +++ b/tests/question_type_test.php @@ -100,7 +100,7 @@ public function test_export_to_xml(): void { 'startcolumn' => 0, 'feedback' => 'Feedback data', 'feedbackformat' => FORMAT_PLAIN, - ] , + ], (object)[ 'id' => 2, 'questionid' => 8862, @@ -110,7 +110,7 @@ public function test_export_to_xml(): void { 'orientation' => 0, 'startrow' => 1, 'startcolumn' => 0, - ] , + ], (object)[ 'id' => 2, 'questionid' => 8862, @@ -120,8 +120,8 @@ public function test_export_to_xml(): void { 'orientation' => 0, 'startrow' => 2, 'startcolumn' => 0, - ] , - ] + ], + ], ], 'hints' => [ (object)[ @@ -130,7 +130,7 @@ public function test_export_to_xml(): void { 'hint' => 'Hint 1', 'hintformat' => FORMAT_HTML, 'shownumcorrect' => 0, - 'clearwrong' => 0 + 'clearwrong' => 0, ], (object)[ 'id' => 2, @@ -138,14 +138,14 @@ public function test_export_to_xml(): void { 'hint' => 'Hint 2', 'hintformat' => FORMAT_HTML, 'shownumcorrect' => 1, - 'clearwrong' => 1 + 'clearwrong' => 1, ], ], 'returnurl' => '/question/edit.php?courseid=35&cat=1299%2C2005&recurse=1&showhidden=1&qbshowtext=0', 'makecopy' => 0, 'courseid' => '35', 'inpopup' => 0, - 'contextid' => 91 + 'contextid' => 91, ]; $exporter = new \qformat_xml(); diff --git a/tests/util_test.php b/tests/util_test.php index 3eac019..f00fa5c 100644 --- a/tests/util_test.php +++ b/tests/util_test.php @@ -64,12 +64,12 @@ public function test_safe_normalize_provider(): array { return [ 'Normal case' => [ 'Hanoi', - 'Hanoi' + 'Hanoi', ], 'Same character but different representation code' => [ 'Amélie', - 'Amélie' - ] + 'Amélie', + ], ]; } @@ -97,19 +97,19 @@ public function test_remove_accent_provider(): array { return [ 'Normal case' => [ 'Hanoi', - 'Hanoi' + 'Hanoi', ], 'One wrong accent' => [ 'médecin', - 'medecin' + 'medecin', ], 'Two wrong accent' => [ 'pâté', - 'pate' + 'pate', ], 'Three wrong accent' => [ 'téléphoné', - 'telephone' + 'telephone', ], ]; } @@ -196,7 +196,7 @@ public function test_rearrange_answers(array $orderedanswers): void { 'startcolumn' => 0, 'feedback' => 'Feedback', 'feedbackformat' => 1, - ] + ], ]; // We will order the answer based on startcolumn and startrow. So, the order list will be: @@ -276,9 +276,9 @@ public function ordered_answers_provider(): array { 'startcolumn' => 1, 'feedback' => 'Feedback', 'feedbackformat' => 1, - ] - ] - ] + ], + ], + ], ]; } }