Skip to content

Commit

Permalink
CTP-3558 coding std short array syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
watson8 committed Aug 12, 2024
1 parent c11a298 commit 90ea671
Show file tree
Hide file tree
Showing 96 changed files with 207 additions and 207 deletions.
2 changes: 1 addition & 1 deletion actions/ajax/datatable/grading.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$unallocated = optional_param('unallocated', false, PARAM_BOOL);

// Grading report display options.
$report_options = array();
$report_options = [];
if ($unallocated) {
$report_options['unallocated'] = true;
}
Expand Down
4 changes: 2 additions & 2 deletions actions/allocate.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
$assessorallocationstrategy = optional_param('assessorallocationstrategy', false, PARAM_TEXT);

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

// options used for pagination
// If a session variable holding page preference for the specific coursework is not set, set default value (0).
Expand Down Expand Up @@ -76,7 +76,7 @@
$options = compact('sortby', 'sorthow', 'perpage', 'page');

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

This comment has been minimized.

Copy link
@watson8

watson8 Aug 13, 2024

Author Contributor

Correct in commit 5b0fdf9


require_login($course, true, $coursemodule);

Expand Down
16 changes: 8 additions & 8 deletions actions/allocationsession.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@

$assesorselect = required_param_array('assesorselect', PARAM_RAW);
$assesorselectvalue = required_param_array('assesorselectvalue', PARAM_RAW);
$pinnedchk = optional_param_array('pinned', array(), PARAM_RAW);
$pinnedchkval = optional_param_array('pinnedvalue', array(), PARAM_RAW);
$moderatorselect = optional_param_array('moderatorselect', array(), PARAM_RAW);
$moderatorselectvalue = optional_param_array('moderatorselectvalue', array(), PARAM_RAW);
$samplechk = optional_param_array('sample', array(), PARAM_RAW);
$samplechkvalue = optional_param_array('samplevalue', array(), PARAM_RAW);
$pinnedchk = optional_param_array('pinned', [], PARAM_RAW);
$pinnedchkval = optional_param_array('pinnedvalue', [], PARAM_RAW);
$moderatorselect = optional_param_array('moderatorselect', [], PARAM_RAW);
$moderatorselectvalue = optional_param_array('moderatorselectvalue', [], PARAM_RAW);
$samplechk = optional_param_array('sample', [], PARAM_RAW);
$samplechkvalue = optional_param_array('samplevalue', [], PARAM_RAW);
$coursemoduleid = required_param('coursemoduleid', PARAM_INT);

if (!isset($SESSION->coursework_allocationsessions)) {
$SESSION->coursework_allocationsessions = array();
$SESSION->coursework_allocationsessions = [];
}

if (!isset($SESSION->coursework_allocationsessions[$coursemoduleid])) {
$SESSION->coursework_allocationsessions[$coursemoduleid] = array();
$SESSION->coursework_allocationsessions[$coursemoduleid] = [];
}

for ($i = 0; $i < count($assesorselect); $i++) {
Expand Down
2 changes: 1 addition & 1 deletion actions/set_personal_deadlines.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
'node-base')
);
$PAGE->requires->js_init_call('M.mod_coursework.init_personal_deadlines_page',
array(),
[],
false,
$jsmodule);

Expand Down
4 changes: 2 additions & 2 deletions backup/moodle2/restore_coursework_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class restore_coursework_activity_task extends restore_activity_task
* @return array of restore_decode_rule
*/
static public function define_decode_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_decode_rule('COURSEWORKBYID',
'/mod/coursework/view.php?id=$1',
Expand All @@ -53,7 +53,7 @@ static public function define_decode_rules() {
* @return array
*/
static public function define_decode_contents() {
$contents = array();
$contents = [];

$contents[] = new restore_decode_content('coursework', array('intro'), 'assign');

Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/restore_coursework_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static function cheaplog($thing, $append = true) {
* @return restore_path_element $structure
*/
protected function define_structure() {
$paths = array();
$paths = [];

$paths[] = new restore_path_element('coursework', '/activity/coursework');
$paths[] = new restore_path_element('coursework_sample_set_rule', '/activity/coursework/coursework_sample_set_rules/coursework_sample_set_rule');
Expand Down
10 changes: 5 additions & 5 deletions classes/allocation/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(coursework $coursework) {
$this->coursework = $coursework;

// Instantiate the allocation strategies so we can use them.
$strategytypes = array();
$strategytypes = [];
if (!empty($this->coursework->assessorallocationstrategy)) {
$strategytypes[] = coursework::ASSESSOR;
}
Expand Down Expand Up @@ -110,7 +110,7 @@ public static function get_allocation_classnames($type = coursework::ASSESSOR) {

$classdir = $CFG->dirroot . '/mod/coursework/classes/allocation/strategy';
$fullclassnames = glob($classdir . '/*.php');
$options = array();
$options = [];
foreach ($fullclassnames as $fullclassname) {
if (strpos($fullclassname, 'base') !== false) {
continue;
Expand Down Expand Up @@ -169,7 +169,7 @@ public function auto_generate_moderation_set() {
}

// These are the ones we will actually moderate (or which have already been moderated).
$moderation_set = array();
$moderation_set = [];

// Move all the already marked ones into the set. These have to stay in it and ought to
// be taken into account so that the other rules just add to them.
Expand Down Expand Up @@ -289,7 +289,7 @@ public function auto_generate_sample_set() {
$sampleplugins = $DB->get_records('coursework_sample_set_plugin', null, 'pluginorder');
$order = 0;

$sample_set = array();
$sample_set = [];

$allocatables = $this->get_coursework()->get_allocatables();

Expand Down Expand Up @@ -331,7 +331,7 @@ public function auto_generate_sample_set() {
if (!isset($manual_sample_set[$k])) $manual_sample_set[$k] = $v;
}

$auto_sample_set = array();
$auto_sample_set = [];

foreach ($sampleplugins as $plugin) {
$classname = '\mod_coursework\sample_set_rule\\' . $plugin->rulename;
Expand Down
2 changes: 1 addition & 1 deletion classes/allocation/strategy/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ abstract class base {
*
* @var array
*/
private $settings = array();
private $settings = [];

/**
* @var stage_base
Expand Down
2 changes: 1 addition & 1 deletion classes/allocation/strategy/equal.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function save_allocation_strategy_options() {
* @return mixed
*/
protected function list_of_allocatable_teachers_and_their_current_number_of_allocations($teachers, $student) {
$teacherids = array();
$teacherids = [];

foreach ($teachers as $id => $teacher) {
if ($this->teacher_already_has_an_allocation_for_this_allocatable($student, $teacher)) {
Expand Down
2 changes: 1 addition & 1 deletion classes/allocation/strategy/group_assessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ public function save_allocation_strategy_options() {
* @return mixed
*/
protected function list_of_allocatable_teachers_and_their_current_number_of_allocations($teachers, $student) {
return array();
return = [];

This comment has been minimized.

Copy link
@watson8

watson8 Aug 13, 2024

Author Contributor

This and similar instances corrected in commit 5b0fdf9

}
}
2 changes: 1 addition & 1 deletion classes/allocation/strategy/none.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ public function save_allocation_strategy_options() {
* @return mixed
*/
protected function list_of_allocatable_teachers_and_their_current_number_of_allocations($teachers, $student) {
return array();
return = [];
}
}
4 changes: 2 additions & 2 deletions classes/allocation/strategy/percentages.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function save_allocation_strategy_options() {

// Get the data from the form.
$name = $this->get_name();
$data = optional_param_array('assessorstrategy'.$name, array(), PARAM_RAW); // Array[teacherid] => value.
$data = optional_param_array('assessorstrategy'.$name, [], PARAM_RAW); // Array[teacherid] => value.

if (!is_array($data)) {
return true;
Expand Down Expand Up @@ -244,7 +244,7 @@ private function teacher_already_has_maximum_allocations($teacher) {
* @return array
*/
protected function list_of_allocatable_teachers_and_their_current_number_of_allocations($teachers, $student) {
$teacherids = array();
$teacherids = [];
foreach ($teachers as $teacher) {

if ($this->teacher_already_has_an_allocation_for_this_allocatable($student, $teacher)) {
Expand Down
4 changes: 2 additions & 2 deletions classes/allocation/table/builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct($coursework, array $options) {
public function get_rows() {
$allocatables = $this->get_coursework()->get_allocatables();

$rows = array();
$rows = [];
foreach ($allocatables as $allocatable) {
$rows[] = new row_builder($this, $allocatable);
}
Expand Down Expand Up @@ -106,7 +106,7 @@ public function get_table_rows_for_page() {

$allocatables = $this->get_coursework()->get_allocatables();

$rows = array();
$rows = [];
foreach ($allocatables as $allocatable) {
$rows[] = new row_builder($this, $allocatable);
}
Expand Down
2 changes: 1 addition & 1 deletion classes/allocation/table/cell/builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class builder {
* @param stage_base $stage
* @param array $data_array incoming data from the allocation form
*/
public function __construct($coursework, $allocatable, $stage, $data_array = array()) {
public function __construct($coursework, $allocatable, $stage, $data_array = []) {
$this->coursework = $coursework;
$this->allocatable = $allocatable;
$this->stage = $stage;
Expand Down
2 changes: 1 addition & 1 deletion classes/allocation/table/cell/data.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class data {
* @param stage_base $stage
* @param array $data
*/
public function __construct($stage, $data = array()) {
public function __construct($stage, $data = []) {
$this->data = $data;
$this->stage = $stage;
$this->preprocess_data();
Expand Down
2 changes: 1 addition & 1 deletion classes/allocation/table/cell/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class processor {
* @param stage_base $stage
* @param array $data_array incoming data from the allocation form
*/
public function __construct($coursework, $allocatable, $stage, $data_array = array()) {
public function __construct($coursework, $allocatable, $stage, $data_array = []) {
$this->coursework = $coursework;
$this->allocatable = $allocatable;
$this->stage = $stage;
Expand Down
8 changes: 4 additions & 4 deletions classes/allocation/table/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public function __construct($coursework) {
/**
* @param array $table_data
*/
public function process_data($table_data = array()) {
public function process_data($table_data = []) {
$clean_data = $this->clean_data($table_data);
$allocatables = $this->coursework->get_allocatables();

foreach ($allocatables as $allocatable) {
if (array_key_exists($allocatable->id(), $clean_data)) {
$row_data = $clean_data[$allocatable->id()];
} else {
$row_data = array();
$row_data = [];
}

$allocatable = $this->get_allocatable_from_id($allocatable->id());
Expand Down Expand Up @@ -101,14 +101,14 @@ private function clean_data($raw_data) {
// )
// );

$clean_data = array();
$clean_data = [];
foreach ($raw_data as $allocatable_id => $datarrays) {

if (!$this->allocatable_id_is_valid($allocatable_id)) { // Should be the id of a student.
continue;
}

$clean_data[$allocatable_id] = array();
$clean_data[$allocatable_id] = [];

foreach ($this->coursework->marking_stages() as $stage) {

Expand Down
6 changes: 3 additions & 3 deletions classes/allocation/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function validate_csv($content, $encoding, $delimeter) {

$csvreader->init();

$errors = array();
$errors = [];
$s = 0;
// find out if this is a group or individual coursework
$allocatabletype = $this->coursework->get_allocatable_type();
Expand All @@ -79,7 +79,7 @@ public function validate_csv($content, $encoding, $delimeter) {
// find all assessors for this coursework
$assessors = get_enrolled_users($this->coursework->get_context(), 'mod/coursework:addinitialgrade');
$assessors = array_keys($assessors); // keep only assessors' ids
$allocatablesinfile = array();
$allocatablesinfile = [];

$csv_cells = array('allocatable');
$stages = $this->coursework->get_max_markers();
Expand All @@ -90,7 +90,7 @@ public function validate_csv($content, $encoding, $delimeter) {
while ($line = $csvreader->next()) {

$cells = $csv_cells;
$assessorsinfile = array();
$assessorsinfile = [];

if (sizeof($line) != sizeof($csv_cells)) {$errors = get_string('incorrectfileformat', 'coursework'); break;}
foreach ($line as $keynum => $value) {
Expand Down
2 changes: 1 addition & 1 deletion classes/assessor_feedback_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function get_renderable_feedback_rows() {
// Makes a new result set every time, so we can modify this array without worrying about
// messing up the cache.

$feedbackobjects = array();
$feedbackobjects = [];
foreach ($this->coursework->get_assessor_marking_stages() as $stage) {
$renderable_row = new assessor_feedback_row($stage, $this->get_allocatable(), $this->coursework);
$feedbackobjects[] = $renderable_row;
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/feedback_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected function new_feedback() {

$this->check_stage_permissions($this->params['stage_identifier']);

$urlparams = array();
$urlparams = [];
$urlparams['submissionid'] = $teacherfeedback->submissionid;
$urlparams['assessorid'] = $teacherfeedback->assessorid;
$urlparams['isfinalgrade'] = $teacherfeedback->isfinalgrade;
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/moderations_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function new_moderation() {

$this->check_stage_permissions($this->params['stage_identifier']);

$urlparams = array();
$urlparams = [];
$urlparams['submissionid'] = $moderator_agreement->submissionid;
$urlparams['moderatorid'] = $moderator_agreement->moderatorid;
$urlparams['stage_identifier'] = $moderator_agreement->stage_identifier;
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/plagiarism_flagging_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function new_plagiarism_flag() {
$ability = new ability(user::find($USER), $this->coursework);
$ability->require_can('new', $plagiarismflag);

$urlparams = array();
$urlparams = [];
$urlparams['submissionid'] = $plagiarismflag->submissionid;

$PAGE->set_url('/mod/coursework/actions/moderations/new.php', $urlparams);
Expand Down
6 changes: 3 additions & 3 deletions classes/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static function send_reminders_to_students() {
'users' => 0
);

$userswhoneedreminding = array();
$userswhoneedreminding = [];

$raw_courseworks = $DB->get_records('coursework');
foreach ($raw_courseworks as $raw_coursework) {
Expand Down Expand Up @@ -278,7 +278,7 @@ private static function send_first_reminders_to_admins() {
* @global $CFG
* @return string
*/
public static function coursework_debuggable_query($query, $params = array()) {
public static function coursework_debuggable_query($query, $params = []) {

global $CFG;

Expand Down Expand Up @@ -310,7 +310,7 @@ private static function send_email_reminders_to_students(array $users, array &$c
global $DB;

$emailcounter = 0;
$usercounter = array();
$usercounter = [];

foreach ($users as $user) {

Expand Down
2 changes: 1 addition & 1 deletion classes/event/assessable_uploaded.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class assessable_uploaded extends \core\event\assessable_uploaded {
*
* @var array
*/
protected $legacyfiles = array();
protected $legacyfiles = [];

/**
* Returns description of what happened.
Expand Down
Loading

0 comments on commit 90ea671

Please sign in to comment.