Skip to content

Commit

Permalink
Fix codechecker warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Oct 22, 2023
1 parent c3c07d8 commit 86a3096
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 181 deletions.
7 changes: 4 additions & 3 deletions backup/moodle2/backup_qtype_crossword_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ 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',
'incorrectfeedback', 'incorrectfeedbackformat', 'shownumcorrect']);

// 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);
Expand All @@ -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',
];
}
}
2 changes: 1 addition & 1 deletion backup/moodle2/restore_qtype_crossword_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion classes/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.

namespace qtype_crossword;

use Normalizer;
use \qtype_crossword_question;

/**
* Static utilities.
*
Expand Down
9 changes: 7 additions & 2 deletions edit_crossword_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ 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,
'rowsNum' => $question->numrows + 3,
'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) {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions tests/answer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
],
];
}

Expand Down
24 changes: 12 additions & 12 deletions tests/backup_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
Expand All @@ -122,22 +122,22 @@ public function test_cw_backup_data_provider(): array {
'clueformat' => FORMAT_HTML,
'feedback' => '<p dir="ltr" style="text-align: left;">You are correct.</p>',
'feedbackformat' => FORMAT_HTML,
'answer' => 'BRAZIL'
'answer' => 'BRAZIL',
],
[
'clue' => '<p>Eiffel Tower is located in?</p>',
'clueformat' => FORMAT_HTML,
'feedback' => '<p dir="ltr" style="text-align: left;">You are correct.<br></p>',
'feedbackformat' => FORMAT_HTML,
'answer' => 'PARIS'
'answer' => 'PARIS',
],
[
'clue' => '<p>Where is the Leaning Tower of Pisa?</p>',
'clueformat' => FORMAT_HTML,
'feedback' => '<p dir="ltr" style="text-align: left;">You are correct.<br></p>',
'feedbackformat' => FORMAT_HTML,
'answer' => 'ITALY'
]
'answer' => 'ITALY',
],
],
'version' => 4,
],
Expand All @@ -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,
],
Expand Down
Loading

0 comments on commit 86a3096

Please sign in to comment.