Skip to content

Commit 0d6965b

Browse files
authored
Merge pull request #1 from ucl-isd/CTP-3558-coding-standards-2
CTP-3558: Moodle Coding Standards part 1
2 parents d879920 + fa1db75 commit 0d6965b

File tree

289 files changed

+7762
-5275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+7762
-5275
lines changed

actions/ajax/datatable/grading.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* @package mod_coursework
19+
* @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk}
20+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21+
*/
22+
223
ob_start();
324
require_once(dirname(__FILE__) . '/../../../../../config.php');
425

@@ -14,7 +35,7 @@
1435
$unallocated = optional_param('unallocated', false, PARAM_BOOL);
1536

1637
// Grading report display options.
17-
$report_options = array();
38+
$report_options = [];
1839
if ($unallocated) {
1940
$report_options['unallocated'] = true;
2041
}

actions/ajax/deadline_extension/edit.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* @package mod_coursework
19+
* @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk}
20+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21+
*/
222

323
require_once(dirname(__FILE__) . '/../../../../../config.php');
424

@@ -29,4 +49,4 @@
2949
$params['submissionid'] = $submissionid;
3050
$params['name'] = $name;
3151

32-
$controller->ajax_edit_mitigation($params);
52+
$controller->ajax_edit_mitigation($params);

actions/ajax/deadline_extension/new.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* @package mod_coursework
19+
* @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk}
20+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21+
*/
222

323
require_once(dirname(__FILE__) . '/../../../../../config.php');
424

@@ -29,4 +49,4 @@
2949
$params['submissionid'] = $submissionid;
3050
$params['name'] = $name;
3151

32-
$controller->ajax_new_mitigation($params);
52+
$controller->ajax_new_mitigation($params);

actions/ajax/deadline_extension/submit.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* @package mod_coursework
19+
* @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk}
20+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21+
*/
222

323
require_once(dirname(__FILE__) . '/../../../../../config.php');
424

actions/allocate.php

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818
* Page that prints a table of all students and all markers so that first marker, second marker, moderators
1919
* etc can be allocated manually or automatically.
2020
*
21-
* @package mod
22-
* @subpackage coursework
21+
* @package mod_coursework
2322
* @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk}
2423
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2524
*/
2625

27-
use \mod_coursework\models\coursework;
28-
use \mod_coursework\allocation\widget;
26+
use mod_coursework\models\coursework;
27+
use mod_coursework\allocation\widget;
2928

3029
require_once(dirname(__FILE__).'/../../../config.php');
3130

@@ -46,12 +45,12 @@
4645
$assessorallocationstrategy = optional_param('assessorallocationstrategy', false, PARAM_TEXT);
4746

4847
$moderationruletype = optional_param('addmodsetruletype', 0, PARAM_ALPHAEXT);
49-
$deletemodsetrule = optional_param('delete-mod-set-rule', array(), PARAM_RAW) ;
48+
$deletemodsetrule = optional_param('delete-mod-set-rule', [], PARAM_RAW);
5049

5150
// options used for pagination
5251
// If a session variable holding page preference for the specific coursework is not set, set default value (0).
5352
if (isset($SESSION->allocate_perpage[$coursemoduleid]) && (isset($SESSION->perpage[$coursemoduleid]) && optional_param('per_page', 0, PARAM_INT) != $SESSION->perpage[$coursemoduleid])
54-
&& optional_param('per_page', 0, PARAM_INT) != 0){ // prevent blank pages if not in correct page
53+
&& optional_param('per_page', 0, PARAM_INT) != 0) { // prevent blank pages if not in correct page
5554
$page = 0;
5655
$SESSION->allocate_page[$coursemoduleid] = $page;
5756
} else if (!(isset($SESSION->allocate_page[$coursemoduleid]))) {
@@ -74,10 +73,10 @@
7473
// SQL sort for allocation table.
7574
$sortby = optional_param('sortby', '', PARAM_ALPHA);
7675
$sorthow = optional_param('sorthow', '', PARAM_ALPHA);
77-
$options = compact('sortby', 'sorthow','perpage','page');
76+
$options = compact('sortby', 'sorthow', 'perpage', 'page');
7877

7978
// $_POST['allocatables'] comes as array of arrays which is not supported by optional_param_array, however we clean this later in process_data() function
80-
$formdataarray = isset($_POST['allocatables']) ? $_POST['allocatables'] : array();
79+
$formdataarray = isset($_POST['allocatables']) ? $_POST['allocatables'] : [];
8180

8281
require_login($course, true, $coursemodule);
8382

@@ -102,18 +101,16 @@
102101
'node-base')
103102
);
104103
$PAGE->requires->js_init_call('M.mod_coursework.init_allocate_page',
105-
array('wwwroot'=>$CFG->wwwroot,'coursemoduleid'=>$coursemoduleid),
104+
array('wwwroot' => $CFG->wwwroot, 'coursemoduleid' => $coursemoduleid),
106105
false,
107106
$jsmodule);
108107

109108
$PAGE->requires->string_for_js('sameassessorerror', 'coursework');
110109

111-
112-
113110
$allocationsmanager = $coursework->get_allocation_manager();
114111
$allocationtable = new mod_coursework\allocation\table\builder($coursework, $options);
115112
$allocationtable = new mod_coursework_allocation_table($allocationtable);
116-
$pageurl = $PAGE->url;
113+
$pageurl = $PAGE->url;
117114

118115
// 1. Save the rules and settings from the config bits.
119116

@@ -129,8 +126,7 @@
129126
$coursework->save();
130127
}
131128

132-
133-
if ($samplingformsavebutton) {
129+
if ($samplingformsavebutton) {
134130
if ($coursework->sampling_enabled()) {
135131
$allocationsmanager->save_sample();
136132
}
@@ -147,8 +143,6 @@
147143
}
148144
}
149145

150-
151-
152146
// 2. Process the manual allocations
153147

154148
// Did we just get the form submitted to us?
@@ -159,13 +153,8 @@
159153
$allocationsmanager->auto_generate_sample_set();
160154
}
161155

162-
163156
// 3. Process the auto allocations to fill in the gaps.
164157

165-
166-
167-
168-
169158
// Get the data to render as a moderation set widget.
170159
$allocationwidget = new widget($coursework);
171160
$allocationwidget = new \mod_coursework_allocation_widget($allocationwidget);
@@ -179,22 +168,21 @@
179168
*/
180169
$page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
181170

182-
183171
$warnings = new \mod_coursework\warnings($coursework);
184172

185173
$percentage_allocation_not_complete = $warnings->percentage_allocations_not_complete();
186174
$manual_allocation_not_complete = '';
187175
$students_in_multiple_groups = '';
188-
if ($coursework->allocation_enabled()){
176+
if ($coursework->allocation_enabled()) {
189177
$manual_allocation_not_complete = $warnings->manual_allocation_not_completed();
190178
if ($coursework->use_groups == 1 || $coursework->assessorallocationstrategy == 'group_assessor') {
191179
$students_in_multiple_groups = $warnings->students_in_mutiple_grouos();
192180
}
193181
}
194182

195-
if ($formsavebutton && $percentage_allocation_not_complete == '' && $manual_allocation_not_complete == ''){
196-
redirect($CFG->wwwroot.'/mod/coursework/view.php?id='.$coursemoduleid, get_string('changessaved','mod_coursework'));
197-
} elseif ($formsavebutton) {
183+
if ($formsavebutton && $percentage_allocation_not_complete == '' && $manual_allocation_not_complete == '') {
184+
redirect($CFG->wwwroot.'/mod/coursework/view.php?id='.$coursemoduleid, get_string('changessaved', 'mod_coursework'));
185+
} else if ($formsavebutton) {
198186
redirect($PAGE->url);
199187
}
200188

@@ -208,26 +196,19 @@
208196
// Add coursework id etc.
209197
echo \html_writer::input_hidden_params($PAGE->url);
210198

211-
212-
213-
if ($coursework->sampling_enabled()) { // Do not delete yet - refactoring...
199+
if ($coursework->sampling_enabled()) { // Do not delete yet - refactoring...
214200
echo \html_writer::start_tag('form', array('id' => 'sampling_form',
215201
'method' => 'post'));
216202
$samplesetwidget = $allocationsmanager->get_sampling_set_widget();
217203
echo $object_renderer->render($samplesetwidget);
218204
echo html_writer::end_tag('form');
219205
}
220206

221-
222-
223-
224-
225207
// Start form. The page has now been broken into two forms sampling section and allocation section
226208
// Open form tag.
227209
echo \html_writer::start_tag('form', array('id' => 'allocation_form',
228210
'method' => 'post'));
229211

230-
231212
if ($coursework->allocation_enabled()) {
232213
echo $object_renderer->render($allocationwidget);
233214
}
@@ -239,9 +220,8 @@
239220
echo html_writer::start_tag('div', $attributes);
240221
echo html_writer::end_tag('div');
241222

242-
243223
echo html_writer::tag('h3', get_string('assessormoderatorgrades', 'mod_coursework'));
244-
echo html_writer::tag('div', get_string('pininfo', 'mod_coursework'), array('class'=>'pininfo'));
224+
echo html_writer::tag('div', get_string('pininfo', 'mod_coursework'), array('class' => 'pininfo'));
245225

246226
// Start the form with save button.
247227
/*
@@ -256,6 +236,4 @@
256236

257237
echo html_writer::end_tag('form');
258238

259-
260-
261239
echo $OUTPUT->footer();

actions/allocationsession.php

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,60 @@
11
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* @package mod_coursework
19+
* @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk}
20+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21+
*/
22+
223
require_once("../../../config.php");
324

425
global $SESSION;
526

6-
7-
$assesorselect = required_param_array('assesorselect',PARAM_RAW);
8-
$assesorselectvalue = required_param_array('assesorselectvalue',PARAM_RAW);
9-
$pinnedchk = optional_param_array('pinned',array(),PARAM_RAW);
10-
$pinnedchkval = optional_param_array('pinnedvalue',array(),PARAM_RAW);
11-
$moderatorselect = optional_param_array('moderatorselect',array(),PARAM_RAW);
12-
$moderatorselectvalue = optional_param_array('moderatorselectvalue',array(),PARAM_RAW);
13-
$samplechk = optional_param_array('sample',array(),PARAM_RAW);
14-
$samplechkvalue = optional_param_array('samplevalue',array(),PARAM_RAW);
15-
$coursemoduleid = required_param('coursemoduleid', PARAM_INT);
16-
17-
if (!isset($SESSION->coursework_allocationsessions)) {
18-
$SESSION->coursework_allocationsessions = array();
27+
$assesorselect = required_param_array('assesorselect', PARAM_RAW);
28+
$assesorselectvalue = required_param_array('assesorselectvalue', PARAM_RAW);
29+
$pinnedchk = optional_param_array('pinned', [], PARAM_RAW);
30+
$pinnedchkval = optional_param_array('pinnedvalue', [], PARAM_RAW);
31+
$moderatorselect = optional_param_array('moderatorselect', [], PARAM_RAW);
32+
$moderatorselectvalue = optional_param_array('moderatorselectvalue', [], PARAM_RAW);
33+
$samplechk = optional_param_array('sample', [], PARAM_RAW);
34+
$samplechkvalue = optional_param_array('samplevalue', [], PARAM_RAW);
35+
$coursemoduleid = required_param('coursemoduleid', PARAM_INT);
36+
37+
if (!isset($SESSION->coursework_allocationsessions)) {
38+
$SESSION->coursework_allocationsessions = [];
1939
}
2040

21-
if (!isset($SESSION->coursework_allocationsessions[$coursemoduleid])) {
22-
$SESSION->coursework_allocationsessions[$coursemoduleid] = array();
41+
if (!isset($SESSION->coursework_allocationsessions[$coursemoduleid])) {
42+
$SESSION->coursework_allocationsessions[$coursemoduleid] = [];
2343
}
2444

25-
26-
27-
for($i = 0; $i < count($assesorselect); $i++) {
28-
$SESSION->coursework_allocationsessions[$coursemoduleid][$assesorselect[$i]] = $assesorselectvalue[$i];
45+
for ($i = 0; $i < count($assesorselect); $i++) {
46+
$SESSION->coursework_allocationsessions[$coursemoduleid][$assesorselect[$i]] = $assesorselectvalue[$i];
2947
}
3048

31-
for($i = 0; $i < count($pinnedchk); $i++) {
32-
$SESSION->coursework_allocationsessions[$coursemoduleid][$pinnedchk[$i]] = $pinnedchkval[$i];
49+
for ($i = 0; $i < count($pinnedchk); $i++) {
50+
$SESSION->coursework_allocationsessions[$coursemoduleid][$pinnedchk[$i]] = $pinnedchkval[$i];
3351
}
3452

35-
for($i = 0; $i < count($moderatorselect); $i++) {
36-
$SESSION->coursework_allocationsessions[$coursemoduleid][$moderatorselect[$i]] = $moderatorselectvalue[$i];
53+
for ($i = 0; $i < count($moderatorselect); $i++) {
54+
$SESSION->coursework_allocationsessions[$coursemoduleid][$moderatorselect[$i]] = $moderatorselectvalue[$i];
3755
}
3856

39-
for($i = 0; $i < count($samplechk); $i++) {
40-
$SESSION->coursework_allocationsessions[$coursemoduleid][$samplechk[$i]] = $samplechkvalue[$i];
57+
for ($i = 0; $i < count($samplechk); $i++) {
58+
$SESSION->coursework_allocationsessions[$coursemoduleid][$samplechk[$i]] = $samplechkvalue[$i];
4159
}
4260

0 commit comments

Comments
 (0)