diff --git a/backup/moodle2/backup_qtype_crossword_plugin.class.php b/backup/moodle2/backup_qtype_crossword_plugin.class.php
index 9cd398e..7eb2146 100644
--- a/backup/moodle2/backup_qtype_crossword_plugin.class.php
+++ b/backup/moodle2/backup_qtype_crossword_plugin.class.php
@@ -38,15 +38,17 @@ protected function define_question_plugin_structure(): backup_plugin_element {
$plugin->add_child($pluginwrapper);
// Now create the qtype own structures.
+ // phpcs:disable NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLine
$crossword = new backup_nested_element('crossword', ['id'], ['correctfeedback',
'correctfeedbackformat', 'numrows', 'numcolumns', 'accentgradingtype', 'accentpenalty',
'partiallycorrectfeedback', 'partiallycorrectfeedbackformat',
'incorrectfeedback', 'incorrectfeedbackformat', 'shownumcorrect']);
+ // phpcs:enable
// 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 +63,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..50b035b 100644
--- a/tests/answer_test.php
+++ b/tests/answer_test.php
@@ -33,10 +33,10 @@ class answer_test extends \advanced_testcase {
/**
* Test is_correct function.
*
- * @dataProvider test_is_correct_provider
+ * @dataProvider is_correct_test_provider
* @covers \qtype_crossword_question::is_correct
*/
- public function test_is_correct(array $answerdata) {
+ public function test_is_correct(array $answerdata): void {
// Create a normal crossword question.
$q = \test_question_maker::make_question('crossword', 'normal_with_hyphen_and_space');
foreach ($q->answers as $key => $answer) {
@@ -47,17 +47,16 @@ public function test_is_correct(array $answerdata) {
/**
* Data provider for test_is_correct() test cases.
*
- * @coversNothing
* @return array List of data sets (test cases)
*/
- public function test_is_correct_provider(): array {
+ public static function is_correct_test_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'],
+ ],
];
}
@@ -66,7 +65,7 @@ public function test_is_correct_provider(): array {
*
* @covers \qtype_crossword_question::generate_answer_hint
*/
- public function test_generate_answer_hint() {
+ public function test_generate_answer_hint(): void {
// Create a normal crossword question.
$q = \test_question_maker::make_question('crossword', 'normal_with_hyphen_and_space');
$expecteddata = [
diff --git a/tests/backup_test.php b/tests/backup_test.php
index b906aa0..84e376c 100644
--- a/tests/backup_test.php
+++ b/tests/backup_test.php
@@ -75,10 +75,9 @@ protected function restore_crossword_question_backup_file_to_course_shortname(
/**
* Data provider for test_cw_backup_data().
*
- * @coversNothing
* @return array
*/
- public function test_cw_backup_data_provider(): array {
+ public static function backup_test_data_provider(): array {
return [
'before upgrade feedback column' => [
@@ -92,22 +91,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 +121,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 +151,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,
],
@@ -194,7 +193,7 @@ public function test_cw_backup_data_provider(): array {
/**
* Test crossword old backup data
*
- * @dataProvider test_cw_backup_data_provider
+ * @dataProvider backup_test_data_provider
* @param string $filename file name of the backup file.
* @param string $coursefullname course full name.
* @param string $courseshortname course short name
@@ -250,10 +249,10 @@ public function test_cw_backup_data(string $filename, string $coursefullname, st
/**
* Test backup/restore question type crossword.
*
- * @dataProvider test_backup_restore_course_with_cw_provider
+ * @dataProvider backup_restore_course_with_cw_test_provider
* @param string $crosswordtemplate Crossword template.
*/
- public function test_backup_restore_course_with_cw(string $crosswordtemplate) {
+ public function test_backup_restore_course_with_cw(string $crosswordtemplate): void {
global $DB;
$this->resetAfterTest();
$this->setAdminUser();
@@ -298,10 +297,9 @@ public function test_backup_restore_course_with_cw(string $crosswordtemplate) {
/**
* Data provider for test_backup_restore_course_with_cw().
*
- * @coversNothing
* @return array
*/
- public function test_backup_restore_course_with_cw_provider(): array {
+ public static function backup_restore_course_with_cw_test_provider(): array {
return [
'Normal crossword' => [
diff --git a/tests/form_test.php b/tests/form_test.php
index b58e1db..27e67f4 100644
--- a/tests/form_test.php
+++ b/tests/form_test.php
@@ -46,173 +46,127 @@ class form_test extends \advanced_testcase {
*
* @return array List of data sets (test cases)
*/
- public function form_validation_testcases(): array {
+ public static function form_validation_testcases(): array {
return [
'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')
- ]
+ '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
+ ['text' => '', 'format' => FORMAT_HTML],
],
- ], ['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
- ],
- 'startrow' => [
- 0, 1, 2
+ ['text' => 'Clue C', 'format' => FORMAT_HTML],
],
- '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
+ ['text' => 'Clue C', 'format' => FORMAT_HTML],
],
+ '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'),
- ]
- ]
+ ],
+ ],
];
}
@@ -265,20 +219,20 @@ public function test_form_validation(array $sampledata, array $expectederror): v
'name' => 'Test combined with varnumeric',
'questiontext' => [
'text' => 'Test crossword qtype',
- 'format' => 1
+ 'format' => 1,
],
'generalfeedback' => [
'text' => '',
- 'format' => 1
+ 'format' => 1,
],
'partiallycorrectfeedback' => [
'text' => 'Your answer is partially correct.',
- 'format' => 1
+ 'format' => 1,
],
'shownumcorrect' => 1,
'incorrectfeedback' => [
'text' => 'Your answer is incorrect.',
- 'format' => 1
+ 'format' => 1,
],
'numcolumns' => 5,
'numrows' => 7,
@@ -311,7 +265,7 @@ public function test_form_validation(array $sampledata, array $expectederror): v
*
* @dataProvider generate_alphabet_list_testcases
*/
- public function test_generate_alphabet_list(array $option, array $expected) {
+ public function test_generate_alphabet_list(array $option, array $expected): void {
list ($mform) = $this->prepare_test_data();
list ($start, $end) = $option;
$method = new \ReflectionMethod(\qtype_crossword_edit_form::class,
@@ -327,19 +281,20 @@ public function test_generate_alphabet_list(array $option, array $expected) {
* @return array
*/
public function generate_alphabet_list_testcases(): array {
-
+ // phpcs:disable NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLine
return [
'Alphabet list from 1 to 26' => [
[0, 26],
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
- 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
+ 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
],
'Alphabet list from 1 to 30' => [
[0, 30],
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
- 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD']
+ 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD'],
],
];
+ // phpcs:enable
}
/**
@@ -348,7 +303,7 @@ public function generate_alphabet_list_testcases(): array {
* @param array $data Data from provider.
* @dataProvider validate_answer_testcases
*/
- public function test_validate_answer(array $data) {
+ public function test_validate_answer(array $data): void {
list ($mform) = $this->prepare_test_data();
$method = new \ReflectionMethod(\qtype_crossword_edit_form::class,
'validate_answer');
diff --git a/tests/helper.php b/tests/helper.php
index b935863..2e5156f 100644
--- a/tests/helper.php
+++ b/tests/helper.php
@@ -43,10 +43,12 @@ class qtype_crossword_test_helper extends question_test_helper {
* @return array The test question array.
*/
public function get_test_questions(): array {
+ // phpcs:disable 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',
'accept_wrong_accents_but_not_subtract_point'];
+ // phpcs:enable
}
/**
@@ -153,15 +155,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 +179,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 +307,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 +388,7 @@ public function make_crossword_question_different_codepoint() {
$answer->startcolumn,
$answer->feedback,
$answer->feedbackformat,
- $answer->answernumber
+ $answer->answernumber,
);
}
return $cw;
@@ -402,11 +410,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 +440,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 +451,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 +509,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 +522,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 +535,7 @@ public function make_crossword_question_normal_with_hyphen_and_space() {
'orientation' => 0,
'feedback' => '',
'feedbackformat' => FORMAT_HTML,
- 'answernumber' => 3
+ 'answernumber' => 3,
],
];
@@ -564,15 +572,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 +686,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..754e2d8 100644
--- a/tests/question_test.php
+++ b/tests/question_test.php
@@ -38,7 +38,7 @@ class question_test extends \advanced_testcase {
*
* @covers \qtype_crossword_question::is_complete_response
*/
- public function test_is_complete_response() {
+ public function test_is_complete_response(): void {
$question = \test_question_maker::make_question('crossword');
$this->assertFalse($question->is_complete_response([]));
@@ -62,36 +62,35 @@ public function test_clear_wrong_from_response(array $responses, array $expected
/**
* Data provider for the test_clear_wrong_from_response.
*
- * @coversNothing
* @return array
*/
- public function clear_wrong_from_response_provider(): array {
+ public static 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' => ''],
+ ],
];
}
@@ -112,21 +111,20 @@ public function test_clear_wrong_from_response_with_accent(string $template, arr
/**
* Data provider for the test_clear_wrong_from_response.
*
- * @coversNothing
* @return array
*/
- public function clear_wrong_from_response_with_accent(): array {
+ public static function clear_wrong_from_response_with_accent(): array {
return [
'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' => ''],
],
];
}
@@ -136,7 +134,7 @@ public function clear_wrong_from_response_with_accent(): array {
*
* @covers \qtype_crossword_question::is_gradable_response
*/
- public function test_is_gradable_response() {
+ public function test_is_gradable_response(): void {
$question = \test_question_maker::make_question('crossword');
$this->assertFalse($question->is_gradable_response([]));
@@ -151,7 +149,7 @@ public function test_is_gradable_response() {
* @covers \qtype_crossword_question::grade_response
* @dataProvider grading_provider
*/
- public function test_grading(array $answeroptions) {
+ public function test_grading(array $answeroptions): void {
$question = \test_question_maker::make_question('crossword', 'not_accept_wrong_accents');
$question->accentgradingtype = $answeroptions['options']['accentgradingtype'];
$question->accentpenalty = $answeroptions['options']['accentpenalty'];
@@ -167,7 +165,7 @@ public function test_grading(array $answeroptions) {
*
* @covers \qtype_crossword_question::get_correct_response
*/
- public function test_get_correct_response() {
+ public function test_get_correct_response(): void {
$question = \test_question_maker::make_question('crossword');
$this->assertEquals(['sub0' => 'PARIS', 'sub1' => 'BRAZIL', 'sub2' => 'ITALY'], $question->get_correct_response());
}
@@ -181,7 +179,7 @@ public function test_get_correct_response() {
* @covers \qtype_crossword_question::filter_answers
* @dataProvider remove_blank_words_from_response_testcases
*/
- public function test_filter_answers(array $response, int $expectednumberofwords) {
+ public function test_filter_answers(array $response, int $expectednumberofwords): void {
$this->resetAfterTest();
$crossword = new \qtype_crossword_question();
$method = new \ReflectionMethod(\qtype_crossword_question::class, 'remove_blank_words_from_response');
@@ -194,21 +192,21 @@ public function test_filter_answers(array $response, int $expectednumberofwords)
*
* @return array
*/
- public function remove_blank_words_from_response_testcases(): array {
+ public static 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,
+ ],
];
}
@@ -219,7 +217,7 @@ public function remove_blank_words_from_response_testcases(): array {
* @covers \qtype_crossword_question::get_num_parts_right
* @dataProvider grading_provider
*/
- public function test_get_num_parts_right(array $answeroptions) {
+ public function test_get_num_parts_right(array $answeroptions): void {
$this->resetAfterTest();
$question = \test_question_maker::make_question('crossword', 'not_accept_wrong_accents');
$question->start_attempt(new question_attempt_step(), 1);
@@ -239,7 +237,7 @@ public function test_get_num_parts_right(array $answeroptions) {
* @covers \qtype_crossword_question::get_num_parts_partial
* @dataProvider grading_provider
*/
- public function test_get_num_parts_partial(array $answeroptions) {
+ public function test_get_num_parts_partial(array $answeroptions): void {
$this->resetAfterTest();
$question = \test_question_maker::make_question('crossword', 'not_accept_wrong_accents');
$question->start_attempt(new question_attempt_step(), 1);
@@ -258,7 +256,7 @@ public function test_get_num_parts_partial(array $answeroptions) {
* @covers \qtype_crossword_question::is_full_fraction
* @dataProvider grading_provider
*/
- public function is_full_fraction(array $answeroptions) {
+ public function test_is_full_fraction(array $answeroptions): void {
$this->resetAfterTest();
$question = \test_question_maker::make_question('crossword', 'not_accept_wrong_accents');
$question->start_attempt(new question_attempt_step(), 1);
@@ -273,10 +271,9 @@ public function is_full_fraction(array $answeroptions) {
/**
* Data provider for the get_num_parts_right and grading test.
*
- * @coversNothing
* @return array
*/
- public function grading_provider(): array {
+ public static function grading_provider(): array {
return [
'Answer options not accepts wrong accented' => [
@@ -401,10 +398,9 @@ public function test_calculate_fraction_for_answer(array $inputoptions, array $e
/**
* Data provider for test_calculate_fraction_for_answer_for_answer() test cases.
*
- * @coversNothing
* @return array List of data sets (test cases).
*/
- public function test_calculate_fraction_for_answer_provider(): array {
+ public static function test_calculate_fraction_for_answer_provider(): array {
return [
'Wrong accents are not accepted and the answers are absolutely correct.' => [
'inputoptions' => [
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..57f465d 100644
--- a/tests/util_test.php
+++ b/tests/util_test.php
@@ -42,7 +42,7 @@ class util_test extends \qbehaviour_walkthrough_test_base {
/**
* Test safe_normalize function.
*
- * @dataProvider test_safe_normalize_provider
+ * @dataProvider safe_normalize_test_provider
* @covers \qtype_crossword\util::safe_normalize
*
* @param string $string1 The first string need to compare.
@@ -57,26 +57,25 @@ public function test_safe_normalize(string $string1, string $string2): void {
/**
* Data provider for test_safe_normalize() test cases.
*
- * @coversNothing
* @return array List of data sets (test cases)
*/
- public function test_safe_normalize_provider(): array {
+ public static function safe_normalize_test_provider(): array {
return [
'Normal case' => [
'Hanoi',
- 'Hanoi'
+ 'Hanoi',
],
'Same character but different representation code' => [
'Amélie',
- 'Amélie'
- ]
+ 'Amélie',
+ ],
];
}
/**
* Test remove_accent function.
*
- * @dataProvider test_remove_accent_provider
+ * @dataProvider remove_accent_test_provider
* @covers \qtype_crossword\util::remove_accent
*
* @param string $containaccent The string contain accent characters.
@@ -90,26 +89,25 @@ public function test_remove_accent(string $containaccent, string $missingaccent)
/**
* Data provider for test_remove_accent() test cases.
*
- * @coversNothing
* @return array List of data sets (test cases)
*/
- public function test_remove_accent_provider(): array {
+ public static function remove_accent_test_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',
],
];
}
@@ -134,7 +132,7 @@ public function test_remove_break_characters(string $text, string $expected): vo
* @coversNothing
* @return array List of data sets (test cases)
*/
- public function remove_break_characters_testcases(): array {
+ public static function remove_break_characters_testcases(): array {
return [
'Text with space' => [
'Los angeles',
@@ -196,7 +194,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:
@@ -237,10 +235,9 @@ public function test_update_answer_list(array $orderedanswers): void {
/**
* Data provider return ordered answer list.
*
- * @coversNothing
* @return array Ordered answer list.
*/
- public function ordered_answers_provider(): array {
+ public static function ordered_answers_provider(): array {
return [
'Ordered answer list' => [
[
@@ -276,9 +273,9 @@ public function ordered_answers_provider(): array {
'startcolumn' => 1,
'feedback' => 'Feedback',
'feedbackformat' => 1,
- ]
- ]
- ]
+ ],
+ ],
+ ],
];
}
}