Skip to content

Commit

Permalink
Merge pull request #1 from ucl-isd/CTP-3558-coding-standards-2
Browse files Browse the repository at this point in the history
CTP-3558: Moodle Coding Standards part 1
  • Loading branch information
aspark21 authored Aug 19, 2024
2 parents d879920 + fa1db75 commit 0d6965b
Show file tree
Hide file tree
Showing 289 changed files with 7,762 additions and 5,275 deletions.
23 changes: 22 additions & 1 deletion actions/ajax/datatable/grading.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package mod_coursework
* @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

ob_start();
require_once(dirname(__FILE__) . '/../../../../../config.php');

Expand All @@ -14,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
22 changes: 21 additions & 1 deletion actions/ajax/deadline_extension/edit.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package mod_coursework
* @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

Expand Down Expand Up @@ -29,4 +49,4 @@
$params['submissionid'] = $submissionid;
$params['name'] = $name;

$controller->ajax_edit_mitigation($params);
$controller->ajax_edit_mitigation($params);
22 changes: 21 additions & 1 deletion actions/ajax/deadline_extension/new.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package mod_coursework
* @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

Expand Down Expand Up @@ -29,4 +49,4 @@
$params['submissionid'] = $submissionid;
$params['name'] = $name;

$controller->ajax_new_mitigation($params);
$controller->ajax_new_mitigation($params);
20 changes: 20 additions & 0 deletions actions/ajax/deadline_extension/submit.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package mod_coursework
* @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

Expand Down
54 changes: 16 additions & 38 deletions actions/allocate.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
* Page that prints a table of all students and all markers so that first marker, second marker, moderators
* etc can be allocated manually or automatically.
*
* @package mod
* @subpackage coursework
* @package mod_coursework
* @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

use \mod_coursework\models\coursework;
use \mod_coursework\allocation\widget;
use mod_coursework\models\coursework;
use mod_coursework\allocation\widget;

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

Expand All @@ -46,12 +45,12 @@
$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).
if (isset($SESSION->allocate_perpage[$coursemoduleid]) && (isset($SESSION->perpage[$coursemoduleid]) && optional_param('per_page', 0, PARAM_INT) != $SESSION->perpage[$coursemoduleid])
&& optional_param('per_page', 0, PARAM_INT) != 0){ // prevent blank pages if not in correct page
&& optional_param('per_page', 0, PARAM_INT) != 0) { // prevent blank pages if not in correct page
$page = 0;
$SESSION->allocate_page[$coursemoduleid] = $page;
} else if (!(isset($SESSION->allocate_page[$coursemoduleid]))) {
Expand All @@ -74,10 +73,10 @@
// SQL sort for allocation table.
$sortby = optional_param('sortby', '', PARAM_ALPHA);
$sorthow = optional_param('sorthow', '', PARAM_ALPHA);
$options = compact('sortby', 'sorthow','perpage','page');
$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'] : [];

require_login($course, true, $coursemodule);

Expand All @@ -102,18 +101,16 @@
'node-base')
);
$PAGE->requires->js_init_call('M.mod_coursework.init_allocate_page',
array('wwwroot'=>$CFG->wwwroot,'coursemoduleid'=>$coursemoduleid),
array('wwwroot' => $CFG->wwwroot, 'coursemoduleid' => $coursemoduleid),
false,
$jsmodule);

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



$allocationsmanager = $coursework->get_allocation_manager();
$allocationtable = new mod_coursework\allocation\table\builder($coursework, $options);
$allocationtable = new mod_coursework_allocation_table($allocationtable);
$pageurl = $PAGE->url;
$pageurl = $PAGE->url;

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

Expand All @@ -129,8 +126,7 @@
$coursework->save();
}


if ($samplingformsavebutton) {
if ($samplingformsavebutton) {
if ($coursework->sampling_enabled()) {
$allocationsmanager->save_sample();
}
Expand All @@ -147,8 +143,6 @@
}
}



// 2. Process the manual allocations

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


// 3. Process the auto allocations to fill in the gaps.





// Get the data to render as a moderation set widget.
$allocationwidget = new widget($coursework);
$allocationwidget = new \mod_coursework_allocation_widget($allocationwidget);
Expand All @@ -179,22 +168,21 @@
*/
$page_renderer = $PAGE->get_renderer('mod_coursework', 'page');


$warnings = new \mod_coursework\warnings($coursework);

$percentage_allocation_not_complete = $warnings->percentage_allocations_not_complete();
$manual_allocation_not_complete = '';
$students_in_multiple_groups = '';
if ($coursework->allocation_enabled()){
if ($coursework->allocation_enabled()) {
$manual_allocation_not_complete = $warnings->manual_allocation_not_completed();
if ($coursework->use_groups == 1 || $coursework->assessorallocationstrategy == 'group_assessor') {
$students_in_multiple_groups = $warnings->students_in_mutiple_grouos();
}
}

if ($formsavebutton && $percentage_allocation_not_complete == '' && $manual_allocation_not_complete == ''){
redirect($CFG->wwwroot.'/mod/coursework/view.php?id='.$coursemoduleid, get_string('changessaved','mod_coursework'));
} elseif ($formsavebutton) {
if ($formsavebutton && $percentage_allocation_not_complete == '' && $manual_allocation_not_complete == '') {
redirect($CFG->wwwroot.'/mod/coursework/view.php?id='.$coursemoduleid, get_string('changessaved', 'mod_coursework'));
} else if ($formsavebutton) {
redirect($PAGE->url);
}

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



if ($coursework->sampling_enabled()) { // Do not delete yet - refactoring...
if ($coursework->sampling_enabled()) { // Do not delete yet - refactoring...
echo \html_writer::start_tag('form', array('id' => 'sampling_form',
'method' => 'post'));
$samplesetwidget = $allocationsmanager->get_sampling_set_widget();
echo $object_renderer->render($samplesetwidget);
echo html_writer::end_tag('form');
}





// Start form. The page has now been broken into two forms sampling section and allocation section
// Open form tag.
echo \html_writer::start_tag('form', array('id' => 'allocation_form',
'method' => 'post'));


if ($coursework->allocation_enabled()) {
echo $object_renderer->render($allocationwidget);
}
Expand All @@ -239,9 +220,8 @@
echo html_writer::start_tag('div', $attributes);
echo html_writer::end_tag('div');


echo html_writer::tag('h3', get_string('assessormoderatorgrades', 'mod_coursework'));
echo html_writer::tag('div', get_string('pininfo', 'mod_coursework'), array('class'=>'pininfo'));
echo html_writer::tag('div', get_string('pininfo', 'mod_coursework'), array('class' => 'pininfo'));

// Start the form with save button.
/*
Expand All @@ -256,6 +236,4 @@

echo html_writer::end_tag('form');



echo $OUTPUT->footer();
68 changes: 43 additions & 25 deletions actions/allocationsession.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,60 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package mod_coursework
* @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once("../../../config.php");

global $SESSION;


$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);
$coursemoduleid = required_param('coursemoduleid', PARAM_INT);

if (!isset($SESSION->coursework_allocationsessions)) {
$SESSION->coursework_allocationsessions = array();
$assesorselect = required_param_array('assesorselect', PARAM_RAW);
$assesorselectvalue = required_param_array('assesorselectvalue', 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 = [];
}

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



for($i = 0; $i < count($assesorselect); $i++) {
$SESSION->coursework_allocationsessions[$coursemoduleid][$assesorselect[$i]] = $assesorselectvalue[$i];
for ($i = 0; $i < count($assesorselect); $i++) {
$SESSION->coursework_allocationsessions[$coursemoduleid][$assesorselect[$i]] = $assesorselectvalue[$i];
}

for($i = 0; $i < count($pinnedchk); $i++) {
$SESSION->coursework_allocationsessions[$coursemoduleid][$pinnedchk[$i]] = $pinnedchkval[$i];
for ($i = 0; $i < count($pinnedchk); $i++) {
$SESSION->coursework_allocationsessions[$coursemoduleid][$pinnedchk[$i]] = $pinnedchkval[$i];
}

for($i = 0; $i < count($moderatorselect); $i++) {
$SESSION->coursework_allocationsessions[$coursemoduleid][$moderatorselect[$i]] = $moderatorselectvalue[$i];
for ($i = 0; $i < count($moderatorselect); $i++) {
$SESSION->coursework_allocationsessions[$coursemoduleid][$moderatorselect[$i]] = $moderatorselectvalue[$i];
}

for($i = 0; $i < count($samplechk); $i++) {
$SESSION->coursework_allocationsessions[$coursemoduleid][$samplechk[$i]] = $samplechkvalue[$i];
for ($i = 0; $i < count($samplechk); $i++) {
$SESSION->coursework_allocationsessions[$coursemoduleid][$samplechk[$i]] = $samplechkvalue[$i];
}

Loading

0 comments on commit 0d6965b

Please sign in to comment.