Skip to content

Commit 7ade0d5

Browse files
committed
Fix: warnings in code checker
1 parent 29f7b75 commit 7ade0d5

9 files changed

Lines changed: 330 additions & 352 deletions

File tree

bookquiz/play.php

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ function game_bookquiz_play($cm, $game, $attempt, $bookquiz, $chapterid, $contex
151151
$chnavigation = '';
152152

153153
if ($previd) {
154-
$chnavigation .= '<a title="'.get_string('navprev', 'book').'" href="attempt.php?id='.$cm->id.
155-
'&chapterid='.$previd.'"><img src="'.game_pix_url('bookquiz/nav_prev', 'mod_game').
156-
'" class="bigicon" alt="'.get_string('navprev', 'book').'"/></a>';
154+
$chnavigation .= '<a title="' . get_string('navprev', 'book') . '" href="attempt.php?id=' . $cm->id .
155+
'&chapterid=' . $previd . '"><img src="' . game_pix_url('bookquiz/nav_prev', 'mod_game') .
156+
'" class="bigicon" alt="' . get_string('navprev', 'book') . '"/></a>';
157157
} else {
158-
$chnavigation .= '<img src="'.game_pix_url('bookquiz/nav_prev_dis', 'mod_game').'" class="bigicon" alt="" />';
158+
$chnavigation .= '<img src="'.game_pix_url('bookquiz/nav_prev_dis', 'mod_game') . '" class="bigicon" alt="" />';
159159
}
160160

161161
$nextbutton = '';
@@ -166,8 +166,8 @@ function game_bookquiz_play($cm, $game, $attempt, $bookquiz, $chapterid, $contex
166166
game_pix_url('bookquiz/nav_next', 'mod_game') . '" class="bigicon" alt="'.get_string('navnext', 'book') . '" ></a>';
167167
$nextbutton = '<center>';
168168
$nextbutton .= '<form name="form" method="get" action="attempt.php">';
169-
$nextbutton .= '<input type="hidden" name="id" value="'.$cm->id.'" >' . "\r\n";
170-
$nextbutton .= '<input type="hidden" name="chapterid" value="'.$nextid . '" >' . "\r\n";
169+
$nextbutton .= '<input type="hidden" name="id" value="' . $cm->id . '" >' . "\r\n";
170+
$nextbutton .= '<input type="hidden" name="chapterid" value="' . $nextid . '" >' . "\r\n";
171171
$nextbutton .= '<input type="submit" value="' . get_string('continue') . '">';
172172
$nextbutton .= '</center>';
173173
game_updateattempts_maxgrade($game, $attempt, $scoreattempt, 0, $cm, $course);
@@ -176,8 +176,8 @@ function game_bookquiz_play($cm, $game, $attempt, $bookquiz, $chapterid, $contex
176176
game_updateattempts_maxgrade($game, $attempt, 1, 0, $cm, $course);
177177

178178
$chnavigation .= '<a title="'.get_string('navexit', 'book') . '" href="attempt.php?id=' .
179-
$cm->id.'&chapterid='.$lastid.'><img src="' . game_pix_url('bookquiz/nav_exit', 'mod_game') .
180-
'" class="bigicon" alt="'.get_string('navexit', 'book').'" /></a>';
179+
$cm->id . '&chapterid=' . $lastid . '><img src="' . game_pix_url('bookquiz/nav_exit', 'mod_game') .
180+
'" class="bigicon" alt="' . get_string('navexit', 'book') . '" /></a>';
181181
}
182182

183183
require('toc.php');
@@ -229,7 +229,7 @@ function game_bookquiz_play($cm, $game, $attempt, $bookquiz, $chapterid, $contex
229229
$modcontext = game_get_context_module_instance($cmbook->id);
230230
$content .= game_filterbook($chapter->content, $chapter->id, $modcontext->id, $game->course);
231231

232-
$nocleanoption = new stdClass;
232+
$nocleanoption = new stdClass();
233233
$nocleanoption->noclean = true;
234234
echo '<div>';
235235
if ($nextbutton != '') {
@@ -243,7 +243,7 @@ function game_bookquiz_play($cm, $game, $attempt, $bookquiz, $chapterid, $contex
243243
echo '</div>';
244244
echo $OUTPUT->box_end();
245245
// Lower navigation.
246-
echo '<p align="right">'.$chnavigation.'</p>';
246+
echo '<p align="right">' . $chnavigation . '</p>';
247247
?>
248248
</td>
249249
</tr>
@@ -260,6 +260,8 @@ function game_bookquiz_play($cm, $game, $attempt, $bookquiz, $chapterid, $contex
260260
/**
261261
* Computes the last chapter.
262262
*
263+
* @package mod_game
264+
*
263265
* @param stdClass $game
264266
* @param stdClass $bookquiz
265267
*/
@@ -279,8 +281,11 @@ function game_bookquiz_play_computelastchapter($game, &$bookquiz) {
279281
// Update the data in table game_bookquiz.
280282
if (($DB->set_field('game_bookquiz', 'lastchapterid', $bookquiz->lastchapterid,
281283
['id' => $bookquiz->id])) == false) {
282-
throw new moodle_exception('bookquiz_error', 'game',
283-
"Can't update table game_bookquiz with lastchapterid to $bookquiz->lastchapterid");
284+
throw new moodle_exception(
285+
'bookquiz_error',
286+
'game',
287+
"Can't update table game_bookquiz with lastchapterid to $bookquiz->lastchapterid"
288+
);
284289
}
285290
}
286291
}
@@ -289,6 +294,8 @@ function game_bookquiz_play_computelastchapter($game, &$bookquiz) {
289294
/**
290295
* Shows questions.
291296
*
297+
* @package mod_game
298+
*
292299
* @param int $id
293300
* @param int $questionid
294301
* @param int $chapterid
@@ -307,7 +314,7 @@ function game_bookquiz_showquestions($id, $questionid, $chapterid, $nextchapteri
307314
global $CFG;
308315

309316
// Start the form.
310-
echo "<form id=\"responseform\" method=\"post\" action=\"{$CFG->wwwroot}/mod/game/attempt.php\" ".
317+
echo "<form id=\"responseform\" method=\"post\" action=\"{$CFG->wwwroot}/mod/game/attempt.php\" " .
311318
" onclick=\"this.autocomplete='off'\">\n";
312319
if (($onlyshow === false) && ($showsolution === false)) {
313320
echo "<center><input type=\"submit\" name=\"finishattempt\" value=\"".get_string('sudoku_submit', 'game')."\"></center>\n";
@@ -317,14 +324,14 @@ function game_bookquiz_showquestions($id, $questionid, $chapterid, $nextchapteri
317324
echo '<div>';
318325
echo '<input type="hidden" name="id" value="' . $id . "\" />\n";
319326
echo '<input type="hidden" name="action" value="bookquizcheck" />';
320-
echo '<input type="hidden" name="chapterid" value="'.$chapterid.'" />';
321-
echo '<input type="hidden" name="scoreattempt" value="'.$scoreattempt.'" />';
322-
echo '<input type="hidden" name="nextchapterid" value="'.$nextchapterid.'" />';
327+
echo '<input type="hidden" name="chapterid" value="' . $chapterid . '" />';
328+
echo '<input type="hidden" name="scoreattempt" value="' . $scoreattempt . '" />';
329+
echo '<input type="hidden" name="nextchapterid" value="' . $nextchapterid . '" />';
323330

324331
// Print all the questions.
325332

326333
// Add a hidden field with questionids.
327-
echo '<input type="hidden" name="questionids" value="'.$questionlist."\" />\n";
334+
echo '<input type="hidden" name="questionids" value="'.$questionlist . "\" />\n";
328335

329336
$number = 0;
330337
foreach ($questions as $question) {
@@ -335,7 +342,7 @@ function game_bookquiz_showquestions($id, $questionid, $chapterid, $nextchapteri
335342
// Finish the form.
336343
echo '</div>';
337344
if (($onlyshow === false) && ($showsolution === false)) {
338-
echo "<center><input type=\"submit\" name=\"finishattempt\" value=\"".get_string('sudoku_submit', 'game')."\"></center>\n";
345+
echo "<center><input type=\"submit\" name=\"finishattempt\" value=\"" . get_string('sudoku_submit', 'game') . "\"></center>\n";
339346
}
340347

341348
echo "</form>\n";
@@ -344,9 +351,11 @@ function game_bookquiz_showquestions($id, $questionid, $chapterid, $nextchapteri
344351
/**
345352
* Selects random one question from the input list.
346353
*
354+
* @package mod_game
355+
*
347356
* @param array $questions
348357
*
349-
* @return the position of the random question.
358+
* @return int: the position of the random question.
350359
*/
351360
function game_bookquiz_selectrandomquestion($questions) {
352361
global $DB;
@@ -378,6 +387,8 @@ function game_bookquiz_selectrandomquestion($questions) {
378387
/**
379388
* Check if the answers are correct.
380389
*
390+
* @package mod_game
391+
*
381392
* @param stdClass $cm
382393
* @param stdClass $game
383394
* @param stdClass $attempt
@@ -388,7 +399,7 @@ function game_bookquiz_selectrandomquestion($questions) {
388399
function game_bookquiz_check_questions($cm, $game, $attempt, $bookquiz, $context, $course) {
389400
global $USER, $DB;
390401

391-
$scoreattempt = optional_param('scoreattempt', 0, PARAM_INT);
402+
$scoreattempt = optional_param('scoreattempt', 0, PARAM_INT);
392403
$responses = data_submitted();
393404

394405
$questionlist = $responses->questionids;

bookquiz/questions.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,35 +78,35 @@
7878
echo '<form name="form" method="post" action="questions.php">';
7979
echo '<table border=1>';
8080
echo '<tr>';
81-
echo '<td><center>'.get_string('bookquiz_chapters', 'game') . '</td>';
82-
echo '<td><center>'.get_string('bookquiz_categories', 'game') . '</td>';
83-
echo '<td><center>'.get_string('bookquiz_numquestions', 'game') . '</td>';
81+
echo '<td><center>' . get_string('bookquiz_chapters', 'game') . '</td>';
82+
echo '<td><center>' . get_string('bookquiz_categories', 'game') . '</td>';
83+
echo '<td><center>' . get_string('bookquiz_numquestions', 'game') . '</td>';
8484
echo "</tr>\r\n";
8585
$ids = '';
8686
if (($recs = $DB->get_records('book_chapters', ['bookid' => $game->bookid], 'pagenum', 'id,title')) != false) {
8787
foreach ($recs as $rec) {
8888
echo '<tr>';
89-
echo '<td>'.$rec->title.'</td>';
89+
echo '<td>' . $rec->title . '</td>';
9090
echo '<td>';
9191
if (array_key_exists($rec->id, $categories)) {
9292
$categoryid = $categories[$rec->id];
9393
} else {
9494
$categoryid = 0;
9595
}
96-
echo game_showselectcontrol('categoryid_'.$rec->id, $a, $categoryid, '');
96+
echo game_showselectcontrol('categoryid_' . $rec->id, $a, $categoryid, '');
9797
echo '</td>';
9898

9999
echo '<td>';
100100
if (array_key_exists($rec->id, $numbers)) {
101-
echo '<center>'.$numbers[$rec->id].'</center>';
101+
echo '<center>' . $numbers[$rec->id] . '</center>';
102102
} else {
103103
echo '&nbsp;';
104104
}
105105
echo '</td>';
106106

107107
echo "</tr>\r\n";
108108

109-
$ids .= ','.$rec->id;
109+
$ids .= ',' . $rec->id;
110110
}
111111
}
112112
?>
@@ -128,6 +128,8 @@
128128
/**
129129
* Save infos to database.
130130
*
131+
* @package mod_game
132+
*
131133
* @param int $gameid
132134
* @param int $bookid
133135
* @param array $ids
@@ -140,19 +142,19 @@ function game_bookquiz_save($gameid, $bookid, $ids, $form) {
140142

141143
$questions = $recids = [];
142144
if (($recs = $DB->get_records(
143-
'game_bookquiz_questions',
144-
['gameid' => $gameid],
145-
'',
146-
'id,chapterid,questioncategoryid')
147-
) != false) {
145+
'game_bookquiz_questions',
146+
['gameid' => $gameid],
147+
'',
148+
'id,chapterid,questioncategoryid')
149+
) != false) {
148150
foreach ($recs as $rec) {
149151
$questions[$rec->chapterid] = $rec->questioncategoryid;
150152
$recids[$rec->chapterid] = $rec->id;
151153
}
152154
}
153155

154156
foreach ($ids as $chapterid) {
155-
$name = 'categoryid_'.$chapterid;
157+
$name = 'categoryid_' . $chapterid;
156158
$categoryid = $form->$name;
157159

158160
if (!array_key_exists($chapterid, $questions)) {
@@ -182,7 +184,7 @@ function game_bookquiz_save($gameid, $bookid, $ids, $form) {
182184
throw new moodle_exception('bookquiz_error', 'game', 'Can\'t delete game_bookquiz_questions');
183185
}
184186
} else {
185-
$updrec = new StdClass;
187+
$updrec = new StdClass();
186188
$updrec->id = $recids[$chapterid];
187189
$updrec->questioncategoryid = $categoryid;
188190
if (($DB->update_record('game_bookquiz_questions', $updrec)) == false) {

bookquiz/toc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
defined('MOODLE_INTERNAL') || die();
2626

2727
define('NUM_NONE', '0');
28-
define('NUM_NUMBERS','1');
28+
define('NUM_NUMBERS', '1');
2929
define('NUM_BULLETS', '2');
3030
define('NUM_INDENTED', '3');
3131

@@ -86,7 +86,7 @@
8686
}
8787
}
8888
$titles[$ch->id] = $title;
89-
$toc .= '<a title="'.htmlspecialchars($title).'" href="#ch'.$ch->id.'">'.$title.'</a>';
89+
$toc .= '<a title="' . htmlspecialchars($title) . '" href="#ch' . $ch->id . '">' . $title . '</a>';
9090
$toc .= (!$ch->subchapter) ? '<ul>' : '</li>';
9191
$first = 0;
9292
}
@@ -114,7 +114,7 @@
114114
}
115115
}
116116
if ($ch->id == $chapter->id) {
117-
$toc .= '<strong>'.$title.'</strong>';
117+
$toc .= '<strong>' . $title . '</strong>';
118118
if ($ch->subchapter) {
119119
$currtitle = $prevtitle;
120120
$currsubtitle = $title;

bookquiz/view.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@
145145
if ($section = $DB->get_record('course_sections', ['id' => $cm->section])) {
146146
$sec = $section->section;
147147
}
148-
$chnavigation .= '<a title="'.get_string('navexit', 'book').'" href="../../course/view.php?id='.
149-
$course->id.'#section-'.$sec.'"><img src="'.
150-
$OUTPUT->pix_url('bookquiz/nav_exit', 'mod_game').'" class="bigicon" alt="'.get_string('navexit', 'book').
148+
$chnavigation .= '<a title="'.get_string('navexit', 'book') . '" href="../../course/view.php?id=' .
149+
$course->id.'#section-'.$sec.'"><img src="' .
150+
$OUTPUT->pix_url('bookquiz/nav_exit', 'mod_game') . '" class="bigicon" alt="' . get_string('navexit', 'book') .
151151
'" /></a>';
152152
}
153153

@@ -163,10 +163,10 @@
163163
$OUTPUT->pix_url('bookquiz/print_book', 'mod_game') .
164164
'" class="bigicon" alt="' . get_string('printbook', 'book') . '"/></a>';
165165
$printchapter = '<a title="' . get_string('printchapter', 'book') . '" href="print.php?id=' .
166-
$cm->id.'&amp;chapterid=' . $chapter->id.
167-
'" onclick="this.target=\'_blank\'"><img src="'.
166+
$cm->id.'&amp;chapterid=' . $chapter->id .
167+
'" onclick="this.target=\'_blank\'"><img src="' .
168168
$OUTPUT->pix_url('bookquiz/print_chapter', 'mod_game') . '" class="bigicon" alt="' .
169-
get_string('printchapter', 'book').'"/></a>';
169+
get_string('printchapter', 'book') . '"/></a>';
170170
}
171171

172172

@@ -185,7 +185,7 @@
185185
<td valign="top">
186186
<table border="0" cellspacing="0" width="100%" valign="top" cellpadding="0">
187187
<tr>
188-
<td align="right"><?php echo 'help'.$chnavigation ?></td>
188+
<td align="right"><?php echo 'help' . $chnavigation ?></td>
189189
</tr>
190190
</table>
191191
</td>
@@ -211,22 +211,22 @@
211211
$content = '';
212212
if (!$book->customtitles) {
213213
if ($currsubtitle == '&nbsp;') {
214-
$content .= '<p class="book_chapter_title">'.$currtitle.'</p>';
214+
$content .= '<p class="book_chapter_title">' . $currtitle . '</p>';
215215
} else {
216-
$content .= '<p class="book_chapter_title">'.$currtitle.'<br />'.$currsubtitle.'</p>';
216+
$content .= '<p class="book_chapter_title">' . $currtitle . '<br />' . $currsubtitle . '</p>';
217217
}
218218
}
219219

220220
$content .= $chapter->content;
221221

222-
$nocleanoption = new stdClass;
222+
$nocleanoption = new stdClass();
223223
$nocleanoption->noclean = true;
224224
echo '<div class="book_content">';
225225
echo format_text($content, FORMAT_HTML, $nocleanoption, $course->id);
226226
echo '</div>';
227227
echo $OUTPUT->box_end();
228228
// Lower navigation.
229-
echo '<p>'.$chnavigation.'</p>';
229+
echo '<p>' . $chnavigation . '</p>';
230230
?>
231231
</td>
232232
</tr>

0 commit comments

Comments
 (0)