Skip to content

Commit 41f27cc

Browse files
GRADEME-153: PHPCS/CBF syntax cleanup.
1 parent 222d9b8 commit 41f27cc

12 files changed

+109
-104
lines changed

block_grade_me.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function get_content() {
4343
return $this->content;
4444
}
4545

46-
require_once($CFG->dirroot.'/blocks/grade_me/lib.php');
46+
require_once($CFG->dirroot . '/blocks/grade_me/lib.php');
4747
$PAGE->requires->jquery();
4848
$PAGE->requires->js('/blocks/grade_me/javascript/grademe.js');
4949

@@ -101,11 +101,11 @@ public function get_content() {
101101

102102
foreach ($enabledplugins as $plugin => $a) {
103103
if (has_capability($a['capability'], $context)) {
104-
$fn = 'block_grade_me_query_'.$plugin;
104+
$fn = 'block_grade_me_query_' . $plugin;
105105
$pluginfn = $fn($gradebookusers);
106106
if ($pluginfn !== false) {
107107
list($sql, $inparams) = $fn($gradebookusers);
108-
$query = block_grade_me_query_prefix().$sql.block_grade_me_query_suffix($plugin);
108+
$query = block_grade_me_query_prefix() . $sql . block_grade_me_query_suffix($plugin);
109109
$values = array_merge($inparams, $params);
110110
$rs = $DB->get_recordset_sql($query, $values);
111111

@@ -115,8 +115,8 @@ public function get_content() {
115115
$iteminstance = $r->iteminstance;
116116
$userid = $r->userid;
117117
$attemptnumber = $r->attemptnumber;
118-
$sql = 'select MAX(attemptnumber) from {assign_submission} where assignment = '.$iteminstance .
119-
' and userid = '.$userid;
118+
$sql = 'select MAX(attemptnumber) from {assign_submission} where assignment = ' . $iteminstance .
119+
' and userid = ' . $userid;
120120
$maxattempt = $DB->get_field_sql($sql);
121121
if ($maxattempt == $attemptnumber) {
122122
$gradeables = block_grade_me_array($gradeables, $r);
@@ -157,11 +157,11 @@ public function get_content() {
157157
if (!empty($this->content->text)) {
158158
// Expand/Collapse button.
159159
$expand = '<button class="btn btn-sm btn-outline-secondary" type="button" onclick="togglecollapseall();">' .
160-
get_string('expand', 'block_grade_me').'</button>';
160+
get_string('expand', 'block_grade_me') . '</button>';
161161

162-
$this->content->text = $expand.'<dl>'.$this->content->text.'</dl><div class="excess">'.$additional.'</div>';
162+
$this->content->text = $expand . '<dl>' . $this->content->text . '</dl><div class="excess">' . $additional . '</div>';
163163
} else if (empty($this->content->text) && $showempty) {
164-
$this->content->text .= '<div class="excess">'.get_string('nothing', 'block_grade_me').'</div>'."\n";
164+
$this->content->text .= '<div class="excess">' . get_string('nothing', 'block_grade_me') . '</div>' . "\n";
165165
}
166166

167167
return $this->content;

db/access.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@
4848

4949
'clonepermissionsfrom' => 'moodle/site:manageblocks'
5050
)
51-
);
51+
);

db/upgrade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function xmldb_block_grade_me_upgrade($oldversion, $block) {
7979

8080
if ($oldversion < 2015102402) {
8181
if (!$dbman->table_exists('block_grade_me_quiz_ngrade')) {
82-
$dbman->install_one_table_from_xmldb_file(__DIR__.'/install.xml', 'block_grade_me_quiz_ngrade');
82+
$dbman->install_one_table_from_xmldb_file(__DIR__ . '/install.xml', 'block_grade_me_quiz_ngrade');
8383
}
8484
$DB->delete_records('block_grade_me_quiz_ngrade');
8585
// Pre populate block_grade_me_quiz_ngrade table.

lib.php

+53-50
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ function block_grade_me_query_suffix($mod) {
5454
$query = " AND bgm.courseid = ? AND bgm.itemmodule = '$mod') allitems";
5555
$maxage = get_config(null, 'block_grade_me_maxage');
5656
if (!empty($maxage) && is_numeric($maxage)) {
57-
$maxtimesubmitted = time()-((int)$maxage * DAYSECS);
58-
$query .= " WHERE allitems.timesubmitted >= ".$maxtimesubmitted;
57+
$maxtimesubmitted = time() - ((int)$maxage * DAYSECS);
58+
$query .= " WHERE allitems.timesubmitted >= " . $maxtimesubmitted;
5959
}
6060
return $query;
6161
}
@@ -69,12 +69,12 @@ function block_grade_me_enabled_plugins() {
6969
$enabledplugins = array();
7070
$plugins = get_list_of_plugins('blocks/grade_me/plugins');
7171
foreach ($plugins as $plugin) {
72-
$pluginfile = $CFG->dirroot.'/blocks/grade_me/plugins/'.$plugin.'/'.$plugin.'_plugin.php';
72+
$pluginfile = $CFG->dirroot . '/blocks/grade_me/plugins/' . $plugin . '/' . $plugin . '_plugin.php';
7373
if (file_exists($pluginfile)) {
74-
$enablekey = 'block_grade_me_enable'.$plugin;
74+
$enablekey = 'block_grade_me_enable' . $plugin;
7575
if (isset($CFG->$enablekey) && $CFG->$enablekey == true) {
7676
include_once($pluginfile);
77-
$requiredcapabilityfunc = 'block_grade_me_required_capability_'.$plugin;
77+
$requiredcapabilityfunc = 'block_grade_me_required_capability_' . $plugin;
7878
if (function_exists($requiredcapabilityfunc)) {
7979
$enabledplugins = array_merge($enabledplugins, $requiredcapabilityfunc());
8080
}
@@ -115,29 +115,29 @@ function block_grade_me_tree($course) {
115115
// Get time format string.
116116
$datetimestring = get_string('datetime', 'block_grade_me', array());
117117
// Grading image.
118-
$gradeimg = $CFG->wwwroot.'/blocks/grade_me/pix/check_mark.png';
118+
$gradeimg = $CFG->wwwroot . '/blocks/grade_me/pix/check_mark.png';
119119
// Define text variable.
120120
$text = '';
121121

122122
$courseid = $course['meta']['courseid'];
123123
$coursename = $course['meta']['coursename'];
124124
unset($course['meta']);
125125

126-
$gradebooklink = $CFG->wwwroot.'/grade/report/index.php?id='.$courseid.'" title="'.
126+
$gradebooklink = $CFG->wwwroot . '/grade/report/index.php?id=' . $courseid . '" title="' .
127127
get_string('link_gradebook_icon', 'block_grade_me', array('course_name' => $coursename));
128128
$altgradebook = get_string('alt_gradebook', 'block_grade_me', array('course_name' => $coursename));
129129
$gradebookicon = $OUTPUT->pix_icon('i/grades', $altgradebook, null, array('class' => 'gm_icon'));
130-
$courselink = $CFG->wwwroot.'/course/view.php?id='.$courseid;
130+
$courselink = $CFG->wwwroot . '/course/view.php?id=' . $courseid;
131131
$coursetitle = get_string('link_gradebook', 'block_grade_me', array('course_name' => $coursename));
132-
$text .= '<div><dt id="courseid'.$courseid.'" class="cmod">
132+
$text .= '<div><dt id="courseid' . $courseid . '" class="cmod">
133133
<div tabindex=0 class="toggle open fa fa-caret-right" aria-hidden="true"
134-
onclick="$(\'dt#courseid'.$courseid.' > div.toggle\')
135-
.toggleClass(\'open\');$(\'dt#courseid'.$courseid.' ~ dd\')
134+
onclick="$(\'dt#courseid' . $courseid . ' > div.toggle\')
135+
.toggleClass(\'open\');$(\'dt#courseid' . $courseid . ' ~ dd\')
136136
.toggleClass(\'block_grade_me_hide\');">
137137
<span class="sr-only">Toggle Section</span>
138138
</div>
139-
<a href="'.$courselink.'" class="grademe-course-name"'.$coursetitle.'">'.$coursename.'</a>
140-
</dt>'."\n";
139+
<a href="' . $courselink . '" class="grademe-course-name"' . $coursetitle . '">' . $coursename . '</a>
140+
</dt>' . "\n";
141141
$text .= "\n";
142142

143143
ksort($course);
@@ -148,31 +148,32 @@ function block_grade_me_tree($course) {
148148
$coursemoduleid = $item['meta']['coursemoduleid'];
149149
unset($item['meta']);
150150

151-
$modulelink = $CFG->wwwroot.'/mod/'.$itemmodule.'/view.php?id='.$coursemoduleid;
151+
$modulelink = $CFG->wwwroot . '/mod/' . $itemmodule . '/view.php?id=' . $coursemoduleid;
152152
$gradelink = $CFG->wwwroot;
153153
if ($itemmodule == 'assignment') {
154-
$gradelink .= '/mod/assignment/submissions.php?id='.$coursemoduleid;
154+
$gradelink .= '/mod/assignment/submissions.php?id=' . $coursemoduleid;
155155
} else if ($itemmodule == 'quiz') {
156-
$gradelink .= '/mod/quiz/report.php?id='.$coursemoduleid;
156+
$gradelink .= '/mod/quiz/report.php?id=' . $coursemoduleid;
157157
} else {
158158
$gradelink = $modulelink;
159159
}
160160
$moduletitle = get_string('link_mod', 'block_grade_me', array('mod_name' => $itemmodule));
161161
$moduleicon = $OUTPUT->pix_icon('icon', $moduletitle, $itemmodule, array('class' => 'gm_icon'));
162162

163-
$text .= '<dd id="cmid'.$coursemoduleid.'" class="module">'."\n"; // Open module.
164-
$text .= '<div class="dd-wrap">'."\n";
163+
$text .= '<dd id="cmid' . $coursemoduleid . '" class="module">' . "\n"; // Open module.
164+
$text .= '<div class="dd-wrap">' . "\n";
165165
$text .= '<div tabindex=0 class="toggle fa fa-caret-right" aria-hidden="true"
166-
onclick="$(\'dd#cmid'.$coursemoduleid.' > div div.toggle\')
167-
.toggleClass(\'open\');$(\'dd#cmid'.$coursemoduleid.' > ul\')
166+
onclick="$(\'dd#cmid' . $coursemoduleid . ' > div div.toggle\')
167+
.toggleClass(\'open\');$(\'dd#cmid' . $coursemoduleid . ' > ul\')
168168
.toggleClass(\'block_grade_me_hide\');">
169169
<span class="sr-only">Toggle Section</span>
170-
</div>'."\n";
171-
$text .= '<a href="'.$gradelink.'" class="grademe-course-icon" title="'.$moduletitle.'">'.$moduleicon.'</a>'."\n";
172-
$text .= '<a href="'.$modulelink.'" class="grademe-mod-name" title="'.$moduletitle.'">'.$itemname.'</a>'."\n";
173-
$text .= '<span class="badge badge-pill badge-primary">'.count($item).'</span>'."\n";
174-
$text .= '</div>'."\n";
175-
$text .= '<ul class="gradable-list block_grade_me_hide">'."\n";
170+
</div>' . "\n";
171+
$text .= '<a href="' . $gradelink . '" class="grademe-course-icon" title="'
172+
. $moduletitle . '">' . $moduleicon . '</a>' . "\n";
173+
$text .= '<a href="' . $modulelink . '" class="grademe-mod-name" title="' . $moduletitle . '">' . $itemname . '</a>' . "\n";
174+
$text .= '<span class="badge badge-pill badge-primary">' . count($item) . '</span>' . "\n";
175+
$text .= '</div>' . "\n";
176+
$text .= '<ul class="gradable-list block_grade_me_hide">' . "\n";
176177

177178
ksort($item);
178179

@@ -183,21 +184,22 @@ function block_grade_me_tree($course) {
183184

184185
$submissionlink = $CFG->wwwroot;
185186
if ($itemmodule == 'assignment') {
186-
$submissionlink .= '/mod/assignment/submissions.php?id='.$coursemoduleid.'&amp;userid=' . $userid .
187+
$submissionlink .= '/mod/assignment/submissions.php?id=' . $coursemoduleid . '&amp;userid=' . $userid .
187188
'&amp;mode=single&amp;filter=0&amp;offset=0';
188189
} else if ($itemmodule == 'assign') {
189190
$submissionlink .= "/mod/assign/view.php?id=$coursemoduleid&action=grade&userid=$userid";
190191
} else if ($itemmodule == 'data') {
191-
$submissionlink .= '/mod/data/view.php?rid='.$submissionid.'&amp;mode=single';
192+
$submissionlink .= '/mod/data/view.php?rid=' . $submissionid . '&amp;mode=single';
192193
} else if ($itemmodule == 'forum') {
193194
$forumdiscussionid = $submission['meta']['forum_discussion_id'];
194-
$submissionlink .= '/mod/forum/discuss.php?d='.$forumdiscussionid.'#p'.$submissionid;
195+
$submissionlink .= '/mod/forum/discuss.php?d=' . $forumdiscussionid . '#p' . $submissionid;
195196
} else if ($itemmodule == 'glossary') {
196-
$submissionlink .= '/mod/glossary/view.php?id='.$coursemoduleid.'#postrating'.$submissionid;
197+
$submissionlink .= '/mod/glossary/view.php?id=' . $coursemoduleid . '#postrating' . $submissionid;
197198
} else if ($itemmodule == 'quiz') {
198-
$submissionlink .= '/mod/quiz/review.php?attempt='.$submissionid;
199+
$submissionlink .= '/mod/quiz/review.php?attempt=' . $submissionid;
199200
} else if ($itemmodule == 'lesson') {
200-
$submissionlink .= '/mod/lesson/essay.php?id='.$coursemoduleid.'&mode=grade&attemptid='.$submissionid.'&sesskey='.sesskey();
201+
$submissionlink .= '/mod/lesson/essay.php?id=' . $coursemoduleid . '&mode=grade&attemptid='
202+
. $submissionid . '&sesskey=' . sesskey();
201203
}
202204

203205
unset($submission['meta']);
@@ -208,28 +210,29 @@ function block_grade_me_tree($course) {
208210
$user = $DB->get_record('user', array('id' => $userid));
209211

210212
$userfirst = $user->firstname;
211-
$userfirstlast = $user->firstname.' '.$user->lastname;
213+
$userfirstlast = $user->firstname . ' ' . $user->lastname;
212214
$userprofiletitle = get_string('link_user_profile', 'block_grade_me', array('first_name' => $userfirst));
213215

214216
$text .= '<li class="gradable">'; // Open gradable.
215-
$text .= '<a class="gradable-icon" href="'.$submissionlink.'" title="'.$submissiontitle.'">
217+
$text .= '<a class="gradable-icon" href="' . $submissionlink . '" title="' . $submissiontitle . '">
216218
<i class="fa fa-check" aria-hidden="true"></i>
217-
<span class="sr-only">'.$submissiontitle.'</span>
219+
<span class="sr-only">' . $submissiontitle . '</span>
218220
</a>';
219221
$text .= '<div class="gradable-wrap">';
220-
$text .= '<a class="gradable-user" href="'.$CFG->wwwroot.'/user/view.php?id='.$userid.'&amp;course='.$courseid.'" title="'.$userprofiletitle.'">';
222+
$text .= '<a class="gradable-user" href="' . $CFG->wwwroot . '/user/view.php?id=' . $userid
223+
. '&amp;course=' . $courseid . '" title="' . $userprofiletitle . '">';
221224
$text .= $userfirstlast;
222225
$text .= '</a>';
223-
$text .= '<div class="gradable-date">'.userdate($timesubmitted, $datetimestring).'</div>';
226+
$text .= '<div class="gradable-date">' . userdate($timesubmitted, $datetimestring) . '</div>';
224227
$text .= '</div>';
225-
$text .= '</li>'."\n"; // End gradable.
228+
$text .= '</li>' . "\n"; // End gradable.
226229
}
227230

228-
$text .= '</ul>'."\n";
229-
$text .= '</dd>'."\n"; // Close module.
231+
$text .= '</ul>' . "\n";
232+
$text .= '</dd>' . "\n"; // Close module.
230233
}
231234

232-
$text .= '</div>'."\n";
235+
$text .= '</div>' . "\n";
233236

234237
return $text;
235238
}
@@ -260,7 +263,7 @@ function block_grade_me_cache_grade_data() {
260263
$lastrun = '0';
261264
}
262265

263-
// See if the block has been added course wide
266+
// See if the block has been added course wide.
264267
$paramsystem = array('site-index', 'my-index', '*');
265268
$sqlsystem = "SELECT count(b.id) bcount
266269
FROM {block_instances} b
@@ -312,7 +315,7 @@ function block_grade_me_cache_grade_data() {
312315
AND u.deleted = 0";
313316
$validcourse = $DB->count_records_sql($sqlcourse, array('courseid' => $cid));
314317
if ($validcourse > '0') {
315-
$paramscourse =array();
318+
$paramscourse = array();
316319
$paramscourse['itemtype'] = 'mod';
317320

318321
$paramscourse['id'] = $cid;
@@ -339,7 +342,7 @@ function block_grade_me_cache_grade_data() {
339342
'iteminstance' => $rec->iteminstance,
340343
'courseid' => $rec->courseid
341344
);
342-
$fragment = 'itemtype = :itemtype AND itemmodule = :itemmodule AND '.
345+
$fragment = 'itemtype = :itemtype AND itemmodule = :itemmodule AND ' .
343346
'iteminstance = :iteminstance AND courseid = :courseid';
344347
$params = array(
345348
'itemname' => $rec->itemname,
@@ -362,12 +365,12 @@ function block_grade_me_cache_grade_data() {
362365
$DB->update_record('block_grade_me', $params);
363366
}
364367
}
365-
/**
366-
* Build the quiz table per course. Cannot do this in bulk
367-
* because temp tables can cause large disk usage.
368-
* First get the list of quiz attempts for a course with manualgraded questions,
369-
* and that have active students in them.
370-
**/
368+
//
369+
// Build the quiz table per course. Cannot do this in bulk
370+
// because temp tables can cause large disk usage.
371+
// First get the list of quiz attempts for a course with manualgraded questions,
372+
// and that have active students in them.
373+
//
371374

372375
$sqlquizlist = "SELECT mq.id quizid, mqa.id quiattemptid, mqa.userid, mq.course, mqa.uniqueid,
373376
qna.id questionattemptid

plugins/data/data_plugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ function block_grade_me_query_data($gradebookusers) {
5757
)";
5858

5959
return array($query, $inparams);
60-
}
60+
}

plugins/lesson/lesson_plugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ function block_grade_me_query_lesson($gradebookusers) {
5252
WHERE la.userid $insql AND l.grade > 0 AND la.useranswer LIKE ?";
5353
$inparams[] = '%s:6:"graded";i:0%';
5454
return array($query, $inparams);
55-
}
55+
}

plugins/quiz/quiz_plugin.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

17+
defined('MOODLE_INTERNAL') || die();
18+
1719
global $CFG;
18-
require_once($CFG->dirroot.'/question/engine/states.php');
20+
require_once($CFG->dirroot . '/question/engine/states.php');
1921

2022
require_once($CFG->dirroot . '/question/engine/lib.php');
2123

plugins/turnitintooltwo/turnitintooltwo_plugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ function block_grade_me_query_turnitintooltwo($gradebookusers) {
4848
LEFT JOIN {block_grade_me} bgm ON bgm.courseid = t.course AND bgm.iteminstance = t.id
4949
WHERE ts.userid $insql AND t.grade > 0 AND ts.submission_grade IS NOT NULL";
5050
return array($query, $inparams);
51-
}
51+
}

quiz_update_ngrade.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
* @copyright (C) 2016 Remote Learner.net Inc http://www.remote-learner.net
2424
*/
2525

26-
require_once(__DIR__.'/../../config.php');
26+
require_once(__DIR__ . '/../../config.php');
2727

28-
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/blocks/grade_me/quiz_update_ngrade.php'));
28+
$PAGE->set_url(new moodle_url($CFG->wwwroot . '/blocks/grade_me/quiz_update_ngrade.php'));
2929
$PAGE->set_pagelayout('admin');
3030
$PAGE->set_context(context_system::instance());
3131
$title = get_string("quiz_update_ngrade_complete", "block_grade_me");
@@ -41,4 +41,4 @@
4141
$record = $DB->get_record_sql("SELECT COUNT(DISTINCT questionattemptstepid) count FROM {block_grade_me_quiz_ngrade}");
4242
echo \html_writer::tag('h2', $title);
4343
echo \html_writer::tag('p', get_string("quiz_update_ngrade_success", "block_grade_me", $record->count));
44-
echo $OUTPUT->footer();
44+
echo $OUTPUT->footer();

0 commit comments

Comments
 (0)