diff --git a/actions/ajax/datatable/grading.php b/actions/ajax/datatable/grading.php
index f2b25973..25ebaba0 100644
--- a/actions/ajax/datatable/grading.php
+++ b/actions/ajax/datatable/grading.php
@@ -35,26 +35,26 @@
$unallocated = optional_param('unallocated', false, PARAM_BOOL);
// Grading report display options.
-$report_options = [];
+$reportoptions = [];
if ($unallocated) {
- $report_options['unallocated'] = true;
+ $reportoptions['unallocated'] = true;
}
-$report_options['group'] = $group;
-$report_options['perpage'] = $perpage;
-$report_options['sortby'] = $sortby;
-$report_options['sorthow'] = $sorthow;
-$report_options['showsubmissiongrade'] = false;
-$report_options['showgradinggrade'] = false;
-$report_options['courseworkid'] = $courseworkid;
-$report_options['mode'] = \mod_coursework\grading_report::$MODE_GET_REMAIN_RECORDS;
+$reportoptions['group'] = $group;
+$reportoptions['perpage'] = $perpage;
+$reportoptions['sortby'] = $sortby;
+$reportoptions['sorthow'] = $sorthow;
+$reportoptions['showsubmissiongrade'] = false;
+$reportoptions['showgradinggrade'] = false;
+$reportoptions['courseworkid'] = $courseworkid;
+$reportoptions['mode'] = \mod_coursework\grading_report::MODE_GET_REMAIN_RECORDS;
//$controller = new mod_coursework\controllers\grading_controller(['courseworkid' => $report_options, 'allocatableid' => $USER->id, 'allocatabletype' => $USER->id]);
$controller = new mod_coursework\controllers\grading_controller([]);
sleep(10);
-$table_html = $controller->get_remain_rows_grading_table($report_options);
+$tablehtml = $controller->get_remain_rows_grading_table($reportoptions);
if (ob_get_contents()) {
ob_end_clean();
}
-echo $table_html;
+echo $tablehtml;
diff --git a/actions/ajax/deadline_extension/edit.php b/actions/ajax/deadline_extension/edit.php
index 9c66ace6..8d652ce6 100644
--- a/actions/ajax/deadline_extension/edit.php
+++ b/actions/ajax/deadline_extension/edit.php
@@ -28,24 +28,24 @@
$allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT);
$requesttype = optional_param('requesttype', 'new', PARAM_ALPHANUMEXT);
$id = optional_param('id', 0, PARAM_INT);
-$extra_information_text = optional_param('text', '', PARAM_RAW);
-$extra_information_format = optional_param('format', 1, PARAM_ALPHANUMEXT);
-$extended_deadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
-$pre_defined_reason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
+$extrainformationtext = optional_param('text', '', PARAM_RAW);
+$extrainformationformat = optional_param('format', 1, PARAM_ALPHANUMEXT);
+$extendeddeadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
+$predefinedreason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
$submissionid = optional_param('submissionid', 0, PARAM_INT);
$name = optional_param('name', 0, PARAM_ALPHANUMEXT);
-$params = array(
+$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
-);
+];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);
$params['id'] = $id;
-$params['extra_information_text'] = $extra_information_text;
-$params['extra_information_format'] = $extra_information_format;
-$params['extended_deadline'] = strtotime($extended_deadline);
-$params['pre_defined_reason'] = $pre_defined_reason;
+$params['extra_information_text'] = $extrainformationtext;
+$params['extra_information_format'] = $extrainformationformat;
+$params['extended_deadline'] = strtotime($extendeddeadline);
+$params['pre_defined_reason'] = $predefinedreason;
$params['submissionid'] = $submissionid;
$params['name'] = $name;
diff --git a/actions/ajax/deadline_extension/new.php b/actions/ajax/deadline_extension/new.php
index 162f851b..5b8add38 100644
--- a/actions/ajax/deadline_extension/new.php
+++ b/actions/ajax/deadline_extension/new.php
@@ -28,24 +28,24 @@
$allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT);
$requesttype = optional_param('requesttype', 'new', PARAM_ALPHANUMEXT);
$id = optional_param('id', 0, PARAM_INT);
-$extra_information_text = optional_param('text', '', PARAM_RAW);
-$extra_information_format = optional_param('format', 1, PARAM_ALPHANUMEXT);
-$extended_deadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
-$pre_defined_reason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
+$extrainformationtext = optional_param('text', '', PARAM_RAW);
+$extrainformationformat = optional_param('format', 1, PARAM_ALPHANUMEXT);
+$extendeddeadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
+$predefinedreason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
$submissionid = optional_param('submissionid', 0, PARAM_INT);
$name = optional_param('name', 0, PARAM_ALPHANUMEXT);
-$params = array(
+$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
-);
+];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);
$params['id'] = $id;
-$params['extra_information_text'] = $extra_information_text;
-$params['extra_information_format'] = $extra_information_format;
-$params['extended_deadline'] = strtotime($extended_deadline);
-$params['pre_defined_reason'] = $pre_defined_reason;
+$params['extra_information_text'] = $extrainformationtext;
+$params['extra_information_format'] = $extrainformationformat;
+$params['extended_deadline'] = strtotime($extendeddeadline);
+$params['pre_defined_reason'] = $predefinedreason;
$params['submissionid'] = $submissionid;
$params['name'] = $name;
diff --git a/actions/ajax/deadline_extension/submit.php b/actions/ajax/deadline_extension/submit.php
index c4461592..579901a4 100644
--- a/actions/ajax/deadline_extension/submit.php
+++ b/actions/ajax/deadline_extension/submit.php
@@ -28,24 +28,24 @@
$allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT);
$requesttype = optional_param('requesttype', 'new', PARAM_ALPHANUMEXT);
$id = optional_param('id', 0, PARAM_INT);
-$extra_information_text = optional_param('text', '', PARAM_RAW);
-$extra_information_format = optional_param('format', 1, PARAM_ALPHANUMEXT);
-$extended_deadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
-$pre_defined_reason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
+$extrainformationtext = optional_param('text', '', PARAM_RAW);
+$extrainformationformat = optional_param('format', 1, PARAM_ALPHANUMEXT);
+$extendeddeadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
+$predefinedreason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
$submissionid = optional_param('submissionid', 0, PARAM_INT);
$name = optional_param('name', 0, PARAM_ALPHANUMEXT);
-$params = array(
+$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
-);
+];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);
$params['id'] = $id;
-$params['extra_information_text'] = $extra_information_text;
-$params['extra_information_format'] = $extra_information_format;
-$params['extended_deadline'] = strtotime($extended_deadline);
-$params['pre_defined_reason'] = $pre_defined_reason;
+$params['extra_information_text'] = $extrainformationtext;
+$params['extra_information_format'] = $extrainformationformat;
+$params['extended_deadline'] = strtotime($extendeddeadline);
+$params['pre_defined_reason'] = $predefinedreason;
$params['submissionid'] = $submissionid;
$params['name'] = $name;
diff --git a/actions/allocate.php b/actions/allocate.php
index 1b9fc262..154639a6 100644
--- a/actions/allocate.php
+++ b/actions/allocate.php
@@ -34,8 +34,8 @@
$coursemoduleid = required_param('id', PARAM_INT);
$coursemodule = get_coursemodule_from_id('coursework', $coursemoduleid, 0, false, MUST_EXIST);
-$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST);
-$coursework = $DB->get_record('coursework', array('id' => $coursemodule->instance), '*', MUST_EXIST);
+$course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST);
+$coursework = $DB->get_record('coursework', ['id' => $coursemodule->instance], '*', MUST_EXIST);
$coursework = coursework::find($coursework);
$formsavebutton = optional_param('save', 0, PARAM_BOOL);
$samplingformsavebutton = optional_param('save_sampling', 0, PARAM_BOOL);
@@ -83,7 +83,7 @@
require_capability('mod/coursework:allocate', $PAGE->context, null, true, "Can't allocate here - permission denied.");
$url = '/mod/coursework/actions/allocate.php';
-$link = new \moodle_url($url, array('id' => $coursemoduleid));
+$link = new \moodle_url($url, ['id' => $coursemoduleid]);
$PAGE->set_url($link);
$title = get_string('allocatefor', 'mod_coursework', $coursework->name);
$PAGE->set_title($title);
@@ -94,16 +94,17 @@
$PAGE->requires->js('/mod/coursework/loadingoverlay.min.js');
// Will set off the function that adds listeners for onclick/onchange etc.
-$jsmodule = array(
+$jsmodule = [
'name' => 'mod_coursework',
'fullpath' => '/mod/coursework/module.js',
- 'requires' => array('base',
- 'node-base')
+ 'requires' => ['base', 'node-base'],
+];
+$PAGE->requires->js_init_call(
+ 'M.mod_coursework.init_allocate_page',
+ ['wwwroot' => $CFG->wwwroot, 'coursemoduleid' => $coursemoduleid],
+ false,
+ $jsmodule
);
-$PAGE->requires->js_init_call('M.mod_coursework.init_allocate_page',
- array('wwwroot' => $CFG->wwwroot, 'coursemoduleid' => $coursemoduleid),
- false,
- $jsmodule);
$PAGE->requires->string_for_js('sameassessorerror', 'coursework');
@@ -138,7 +139,7 @@
reset($deletemodsetrule);
$deleteruleid = key($deletemodsetrule); // Only one button can be clicked.
if (is_numeric($deleteruleid)) {
- $DB->delete_records('coursework_mod_set_rules', array('id' => $deleteruleid));
+ $DB->delete_records('coursework_mod_set_rules', ['id' => $deleteruleid]);
}
}
}
@@ -162,66 +163,66 @@
/**
* @var mod_coursework_object_renderer $object_renderer
*/
-$object_renderer = $PAGE->get_renderer('mod_coursework', 'object');
+$objectrenderer = $PAGE->get_renderer('mod_coursework', 'object');
/**
* @var mod_coursework_page_renderer $page_renderer
*/
-$page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
+$pagerenderer = $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 = '';
+$percentageallocationnotcomplete = $warnings->percentage_allocations_not_complete();
+$manualallocationnotcomplete = '';
+$studentsinmultiplegroups = '';
if ($coursework->allocation_enabled()) {
- $manual_allocation_not_complete = $warnings->manual_allocation_not_completed();
+ $manualallocationnotcomplete = $warnings->manual_allocation_not_completed();
if ($coursework->use_groups == 1 || $coursework->assessorallocationstrategy == 'group_assessor') {
- $students_in_multiple_groups = $warnings->students_in_mutiple_grouos();
+ $studentsinmultiplegroups = $warnings->students_in_mutiple_grouos();
}
}
-if ($formsavebutton && $percentage_allocation_not_complete == '' && $manual_allocation_not_complete == '') {
+if ($formsavebutton && $percentageallocationnotcomplete == '' && $manualallocationnotcomplete == '') {
redirect($CFG->wwwroot.'/mod/coursework/view.php?id='.$coursemoduleid, get_string('changessaved', 'mod_coursework'));
} else if ($formsavebutton) {
redirect($PAGE->url);
}
echo $OUTPUT->header();
-echo $percentage_allocation_not_complete;
+echo $percentageallocationnotcomplete;
if ($coursework->allocation_enabled()) {
- echo $manual_allocation_not_complete;
- echo $students_in_multiple_groups;
+ echo $manualallocationnotcomplete;
+ echo $studentsinmultiplegroups;
}
// Add coursework id etc.
echo \html_writer::input_hidden_params($PAGE->url);
if ($coursework->sampling_enabled()) { // Do not delete yet - refactoring...
- echo \html_writer::start_tag('form', array('id' => 'sampling_form',
- 'method' => 'post'));
+ echo \html_writer::start_tag('form', ['id' => 'sampling_form',
+ 'method' => 'post']);
$samplesetwidget = $allocationsmanager->get_sampling_set_widget();
- echo $object_renderer->render($samplesetwidget);
+ echo $objectrenderer->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'));
+echo \html_writer::start_tag('form', ['id' => 'allocation_form',
+ 'method' => 'post']);
if ($coursework->allocation_enabled()) {
- echo $object_renderer->render($allocationwidget);
+ echo $objectrenderer->render($allocationwidget);
}
// Spacer so that we can float the headers next to each other.
-$attributes = array(
- 'class' => 'coursework_spacer'
-);
+$attributes = [
+ 'class' => 'coursework_spacer',
+];
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'), ['class' => 'pininfo']);
// Start the form with save button.
/*
@@ -232,7 +233,7 @@
echo html_writer::empty_tag('input', $attributes);
echo $OUTPUT->help_icon('savemanualallocations', 'mod_coursework');
*/
-echo $object_renderer->render($allocationtable);
+echo $objectrenderer->render($allocationtable);
echo html_writer::end_tag('form');
diff --git a/actions/deadline_extensions/create.php b/actions/deadline_extensions/create.php
index 25eb856f..66a863b7 100644
--- a/actions/deadline_extensions/create.php
+++ b/actions/deadline_extensions/create.php
@@ -28,11 +28,11 @@
$allocatableid = optional_param('allocatableid', $USER->id, PARAM_INT);
$allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT);
-$params = array(
+$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
-);
+];
$url = '/mod/coursework/actions/deadline_extensions/create.php';
$link = new \moodle_url($url, $params);
$PAGE->set_url($link);
diff --git a/actions/deadline_extensions/edit.php b/actions/deadline_extensions/edit.php
index 947d01dc..21130743 100644
--- a/actions/deadline_extensions/edit.php
+++ b/actions/deadline_extensions/edit.php
@@ -26,8 +26,8 @@
$id = required_param('id', PARAM_INT);
-$params = array(
+$params = [
'id' => $id,
-);
+];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);
$controller->edit_deadline_extension();
diff --git a/actions/deadline_extensions/new.php b/actions/deadline_extensions/new.php
index aa55f47d..e8ff7eb6 100644
--- a/actions/deadline_extensions/new.php
+++ b/actions/deadline_extensions/new.php
@@ -28,10 +28,10 @@
$allocatableid = optional_param('allocatableid', $USER->id, PARAM_INT);
$allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT);
-$params = array(
+$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
-);
+];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);
$controller->new_deadline_extension();
diff --git a/actions/deadline_extensions/show.php b/actions/deadline_extensions/show.php
index 8a872a0a..94b428f1 100644
--- a/actions/deadline_extensions/show.php
+++ b/actions/deadline_extensions/show.php
@@ -26,8 +26,8 @@
$id = required_param('id', PARAM_INT);
-$params = array(
+$params = [
'id' => $id,
-);
+];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);
$controller->show_deadline_extension();
diff --git a/actions/deadline_extensions/update.php b/actions/deadline_extensions/update.php
index c25265ad..13b6dc42 100644
--- a/actions/deadline_extensions/update.php
+++ b/actions/deadline_extensions/update.php
@@ -26,9 +26,9 @@
$id = required_param('id', PARAM_INT);
-$params = array(
+$params = [
'id' => $id,
-);
+];
$url = '/mod/coursework/actions/deadline_extensions/create.php';
$link = new \moodle_url($url, $params);
$PAGE->set_url($link);
diff --git a/actions/feedbacks/create.php b/actions/feedbacks/create.php
index 045f9f51..b6f91502 100644
--- a/actions/feedbacks/create.php
+++ b/actions/feedbacks/create.php
@@ -31,18 +31,18 @@
$submissionid = required_param('submissionid', PARAM_INT);
$isfinalgrade = optional_param('isfinalgrade', 0, PARAM_INT);
$assessorid = optional_param('assessorid', $USER->id, PARAM_INT);
-$stage_identifier = optional_param('stage_identifier', '', PARAM_ALPHANUMEXT);
+$stageidentifier = optional_param('stage_identifier', '', PARAM_ALPHANUMEXT);
$finalised = !!optional_param('submitbutton', 0, PARAM_TEXT);
$ajax = optional_param('ajax', 0, PARAM_INT);
-$params = array(
+$params = [
'submissionid' => $submissionid,
'isfinalgrade' => $isfinalgrade,
'assessorid' => $assessorid,
- 'stage_identifier' => $stage_identifier,
+ 'stage_identifier' => $stageidentifier,
'finalised' => $finalised,
'ajax' => $ajax,
-);
+];
if ($ajax) {
$params['cell_type'] = required_param('cell_type', PARAM_TEXT);
diff --git a/actions/feedbacks/edit.php b/actions/feedbacks/edit.php
index 57ebd485..d94343a7 100644
--- a/actions/feedbacks/edit.php
+++ b/actions/feedbacks/edit.php
@@ -27,9 +27,9 @@
$feedbackid = optional_param('feedbackid', 0, PARAM_INT);
$ajax = optional_param('ajax', 0, PARAM_INT);
-$params = array(
+$params = [
'feedbackid' => $feedbackid,
- 'ajax' => $ajax
-);
+ 'ajax' => $ajax,
+];
$controller = new mod_coursework\controllers\feedback_controller($params);
$controller->edit_feedback();
diff --git a/actions/feedbacks/new.php b/actions/feedbacks/new.php
index 701a9ea5..529a3114 100644
--- a/actions/feedbacks/new.php
+++ b/actions/feedbacks/new.php
@@ -28,16 +28,16 @@
$cmid = optional_param('cmid', 0, PARAM_INT);
$feedbackid = optional_param('feedbackid', 0, PARAM_INT);
$assessorid = optional_param('assessorid', $USER->id, PARAM_INT);
-$stage_identifier = optional_param('stage_identifier', 'uh-oh', PARAM_RAW);
+$stageidentifier = optional_param('stage_identifier', 'uh-oh', PARAM_RAW);
$ajax = optional_param('ajax', 0, PARAM_INT);
-$params = array(
+$params = [
'submissionid' => $submissionid,
'cmid' => $cmid,
'feedbackid' => $feedbackid,
'assessorid' => $assessorid,
- 'stage_identifier' => $stage_identifier,
+ 'stage_identifier' => $stageidentifier,
'ajax' => $ajax,
-);
+];
$controller = new mod_coursework\controllers\feedback_controller($params);
$controller->new_feedback();
diff --git a/actions/feedbacks/show.php b/actions/feedbacks/show.php
index b74fd868..b3949dab 100644
--- a/actions/feedbacks/show.php
+++ b/actions/feedbacks/show.php
@@ -27,10 +27,10 @@
$feedbackid = optional_param('feedbackid', 0, PARAM_INT);
$ajax = optional_param('ajax', 0, PARAM_INT);
-$params = array(
+$params = [
'feedbackid' => $feedbackid,
- 'ajax' => $ajax
+ 'ajax' => $ajax,
-);
+];
$controller = new mod_coursework\controllers\feedback_controller($params);
$controller->show_feedback();
diff --git a/actions/feedbacks/update.php b/actions/feedbacks/update.php
index ab1bafad..7d696cb5 100644
--- a/actions/feedbacks/update.php
+++ b/actions/feedbacks/update.php
@@ -34,13 +34,13 @@
$remove = !!optional_param('removefeedbackbutton', 0, PARAM_TEXT);
$confirm = optional_param('confirm', 0, PARAM_INT);
-$params = array(
+$params = [
'feedbackid' => $feedbackid,
'finalised' => $finalised,
'remove' => $remove,
'confirm' => $confirm,
- 'ajax' => $ajax
-);
+ 'ajax' => $ajax,
+];
if ($ajax) {
$params['cell_type'] = required_param('cell_type', PARAM_TEXT);
diff --git a/actions/finalgrade.php b/actions/finalgrade.php
index 03dbdec0..7440d862 100644
--- a/actions/finalgrade.php
+++ b/actions/finalgrade.php
@@ -33,7 +33,7 @@
require_once($CFG->dirroot.'/lib/formslib.php');
require_once($CFG->dirroot.'/mod/coursework/renderer.php');
-$submission_id = optional_param('submissionid', 0, PARAM_INT);
+$submissionid = optional_param('submissionid', 0, PARAM_INT);
$assessorid = optional_param('assessorid', $USER->id, PARAM_INT);
$feedbackid = optional_param('feedbackid', 0, PARAM_INT);
$cmid = optional_param('cmid', 0, PARAM_INT);
@@ -43,12 +43,12 @@
$gradeowner = true;
$coursemodule = get_coursemodule_from_id('coursework', $cmid, 0, false, MUST_EXIST);
-$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST);
+$course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST);
require_login($course, false, $coursemodule);
$coursework = mod_coursework\models\coursework::find($coursemodule->instance);
-$submission = submission::find($submission_id);
-$teacherfeedback = $DB->get_record('coursework_feedbacks', array('id' => $feedbackid));
+$submission = submission::find($submissionid);
+$teacherfeedback = $DB->get_record('coursework_feedbacks', ['id' => $feedbackid]);
// This is where stuff used to construct the dynamic form is fed in.
@@ -56,7 +56,7 @@
$canfinalgrade = has_capability('mod/coursework:addagreedgrade', $PAGE->context);
// TODO shift into custom data and set via somewhere else.
-$coursework->submissionid = $submission_id;
+$coursework->submissionid = $submissionid;
$coursework->cmid = $cmid;
$gradeform = new assessor_feedback_mform();
@@ -90,17 +90,17 @@
}
}
-$params = array('submissionid' => $submission_id,
+$params = ['submissionid' => $submissionid,
'assessorid' => $assessorid,
- 'isfinalgrade' => $isfinalgrade);
+ 'isfinalgrade' => $isfinalgrade];
$oldfinalgrade = $DB->get_record('coursework_feedbacks', $params);
// If the no old final grade exists and the current user is a manager lets see if another user has created
// a final grade.
if (empty($oldfinalgrade) && $canfinalgrade) {
- $params = array('submissionid' => $submission_id,
- 'isfinalgrade' => $isfinalgrade);
+ $params = ['submissionid' => $submissionid,
+ 'isfinalgrade' => $isfinalgrade];
$oldfinalgrade = $DB->get_record('coursework_feedbacks', $params);
if ($oldfinalgrade) {
$gradeowner = false;
@@ -132,14 +132,14 @@
echo $OUTPUT->header();
echo $OUTPUT->heading($gradingstring);
-$assessor = $DB->get_record('user', array('id' => $assessorid));
+$assessor = $DB->get_record('user', ['id' => $assessorid]);
echo html_writer::tag('p', get_string('assessor', 'coursework').' '.fullname($assessor));
echo html_writer::tag('p', get_string('gradingoutof', 'coursework', round($coursework->grade)));
// In case we have an editor come along, we want to show that this has happened.
if (!empty($teacherfeedback)) { // May not have been marked yet.
- if ($submission_id && !empty($teacherfeedback->lasteditedbyuser)) {
- $editor = $DB->get_record('user', array('id' => $teacherfeedback->lasteditedbyuser));
+ if ($submissionid && !empty($teacherfeedback->lasteditedbyuser)) {
+ $editor = $DB->get_record('user', ['id' => $teacherfeedback->lasteditedbyuser]);
} else {
$editor = $assessor;
}
@@ -150,18 +150,18 @@
}
$files = $submission->get_submission_files();
-$files_string = $files->has_multiple_files() ? 'submissionfiles' : 'submissionfile';
+$filesstring = $files->has_multiple_files() ? 'submissionfiles' : 'submissionfile';
echo html_writer::start_tag('h1');
-echo get_string($files_string, 'coursework');
+echo get_string($filesstring, 'coursework');
echo html_writer::end_tag('h1');
/**
* @var mod_coursework_object_renderer $object_renderer
*/
-$object_renderer = $PAGE->get_renderer('mod_coursework', 'object');
+$objectrenderer = $PAGE->get_renderer('mod_coursework', 'object');
-echo $object_renderer->render_submission_files_with_plagiarism_links(new mod_coursework_submission_files($files));
+echo $objectrenderer->render_submission_files_with_plagiarism_links(new mod_coursework_submission_files($files));
$gradeform->display();
diff --git a/actions/general_feedback.php b/actions/general_feedback.php
index 4246d4d7..e3b6d3ba 100644
--- a/actions/general_feedback.php
+++ b/actions/general_feedback.php
@@ -30,17 +30,17 @@
$ajax = optional_param('ajax', false, PARAM_BOOL);
$cm = get_coursemodule_from_instance('coursework', $cmid);
-$course = $DB->get_record('course', array('id' => $cm->course));
+$course = $DB->get_record('course', ['id' => $cm->course]);
require_login($course, false, $cm);
-$coursework = $DB->get_record('coursework', array('id' => $cm->instance));
+$coursework = $DB->get_record('coursework', ['id' => $cm->instance]);
if (!has_capability('mod/coursework:addinitialgrade', $PAGE->context)) {
throw new \moodle_exception('access_denied', 'coursework');
}
$url = '/mod/coursework/actions/general_feedback.php';
-$link = new moodle_url($url, array('cmid' => $cmid));
+$link = new moodle_url($url, ['cmid' => $cmid]);
$PAGE->set_url($link);
$title = get_string('generalfeedback', 'mod_coursework');
$PAGE->set_title($title);
@@ -55,13 +55,13 @@
$returneddata = $gradingform->get_data();
if ($gradingform->is_cancelled()) {
- redirect(new moodle_url('/mod/coursework/view.php', array('id' => $cmid)));
+ redirect(new moodle_url('/mod/coursework/view.php', ['id' => $cmid]));
} else if ($returneddata) {
$gradingform->process_data($returneddata);
// TODO should not echo before header.
echo 'General feedback updated..';
if (!$ajax) {
- redirect(new moodle_url('/mod/coursework/view.php', array('id' => $cmid)),
+ redirect(new moodle_url('/mod/coursework/view.php', ['id' => $cmid]),
get_string('changessaved'));
}
} else {
diff --git a/actions/moderations/create.php b/actions/moderations/create.php
index 9b11c938..8245f251 100644
--- a/actions/moderations/create.php
+++ b/actions/moderations/create.php
@@ -31,13 +31,13 @@
$submissionid = required_param('submissionid', PARAM_INT);
$feedbackid = required_param('feedbackid', PARAM_INT);
$moderatorid = optional_param('moderatorid', $USER->id, PARAM_INT);
-$stage_identifier = optional_param('stage_identifier', '', PARAM_ALPHANUMEXT);
+$stageidentifier = optional_param('stage_identifier', '', PARAM_ALPHANUMEXT);
-$params = array(
+$params = [
'submissionid' => $submissionid,
'feedbackid' => $feedbackid,
'moderatorid' => $moderatorid,
- 'stage_identifier' => $stage_identifier,
-);
+ 'stage_identifier' => $stageidentifier,
+];
$controller = new mod_coursework\controllers\moderations_controller($params);
$controller->create_moderation();
diff --git a/actions/moderations/edit.php b/actions/moderations/edit.php
index 8028b076..7cd51812 100644
--- a/actions/moderations/edit.php
+++ b/actions/moderations/edit.php
@@ -26,8 +26,8 @@
$moderationid = optional_param('moderationid', 0, PARAM_INT);
-$params = array(
+$params = [
'moderationid' => $moderationid,
-);
+];
$controller = new mod_coursework\controllers\moderations_controller($params);
$controller->edit_moderation();
diff --git a/actions/moderations/new.php b/actions/moderations/new.php
index ba7a7004..67da180e 100644
--- a/actions/moderations/new.php
+++ b/actions/moderations/new.php
@@ -28,14 +28,14 @@
$cmid = optional_param('cmid', 0, PARAM_INT);
$feedbackid = required_param('feedbackid', PARAM_INT);
$moderatorid = optional_param('moderatorid', $USER->id, PARAM_INT);
-$stage_identifier = optional_param('stage_identifier', 'uh-oh', PARAM_RAW);
+$stageidentifier = optional_param('stage_identifier', 'uh-oh', PARAM_RAW);
-$params = array(
+$params = [
'submissionid' => $submissionid,
'cmid' => $cmid,
'feedbackid' => $feedbackid,
'moderatorid' => $moderatorid,
- 'stage_identifier' => $stage_identifier,
-);
+ 'stage_identifier' => $stageidentifier,
+];
$controller = new mod_coursework\controllers\moderations_controller($params);
$controller->new_moderation();
diff --git a/actions/moderations/show.php b/actions/moderations/show.php
index 171473ba..8c6946e7 100644
--- a/actions/moderations/show.php
+++ b/actions/moderations/show.php
@@ -26,8 +26,8 @@
$moderationid = optional_param('moderationid', 0, PARAM_INT);
-$params = array(
+$params = [
'moderationid' => $moderationid,
-);
+];
$controller = new mod_coursework\controllers\moderations_controller($params);
$controller->show_moderation();
diff --git a/actions/moderations/update.php b/actions/moderations/update.php
index 627e82ba..d8ebd219 100644
--- a/actions/moderations/update.php
+++ b/actions/moderations/update.php
@@ -30,8 +30,8 @@
$moderationid = required_param('moderationid', PARAM_INT);
-$params = array(
+$params = [
'moderationid' => $moderationid,
-);
+];
$controller = new mod_coursework\controllers\moderations_controller($params);
$controller->update_moderation();
diff --git a/actions/personal_deadline.php b/actions/personal_deadline.php
index e4ed63cc..11240661 100644
--- a/actions/personal_deadline.php
+++ b/actions/personal_deadline.php
@@ -25,35 +25,35 @@
global $CFG, $USER, $PAGE, $DB;
$courseworkid = required_param('courseworkid', PARAM_INT);
-$allocatableid_arr = optional_param_array('allocatableid_arr', false, PARAM_RAW);
+$allocatableidarr = optional_param_array('allocatableid_arr', false, PARAM_RAW);
$allocatableid = optional_param('allocatableid', $USER->id, PARAM_RAW);
$allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT);
$setpersonaldeadlinespage = optional_param('setpersonaldeadlinespage', 0, PARAM_INT);
$multipleuserdeadlines = optional_param('multipleuserdeadlines', 0, PARAM_INT);
$selectedtype = optional_param('selectedtype', 'date', PARAM_RAW);
-$personal_deadline_time = optional_param('personal_deadline_time', null, PARAM_RAW);
+$personaldeadlinetime = optional_param('personal_deadline_time', null, PARAM_RAW);
-$allocatableid = (!empty($allocatableid_arr)) ? $allocatableid_arr : $allocatableid;
+$allocatableid = (!empty($allocatableidarr)) ? $allocatableidarr : $allocatableid;
-$coursework_db = $DB->get_record('coursework', array('id' => $courseworkid));
+$courseworkdb = $DB->get_record('coursework', ['id' => $courseworkid]);
-$coursework = \mod_coursework\models\coursework::find($coursework_db);
+$coursework = \mod_coursework\models\coursework::find($courseworkdb);
require_login($coursework->get_course(), false, $coursework->get_course_module());
-$params = array(
+$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
'setpersonaldeadlinespage' => $setpersonaldeadlinespage,
- 'multipleuserdeadlines' => $multipleuserdeadlines
-);
+ 'multipleuserdeadlines' => $multipleuserdeadlines,
+];
if ($selectedtype != 'unfinalise') {
$controller = new mod_coursework\controllers\personal_deadlines_controller($params);
- if (!empty($personal_deadline_time)) {
- $result = $controller->insert_update($personal_deadline_time);
+ if (!empty($personaldeadlinetime)) {
+ $result = $controller->insert_update($personaldeadlinetime);
echo json_encode($result);
} else {
$controller->new_personal_deadline();
diff --git a/actions/plagiarism_flagging/create.php b/actions/plagiarism_flagging/create.php
index 1afc831c..2ca0f950 100644
--- a/actions/plagiarism_flagging/create.php
+++ b/actions/plagiarism_flagging/create.php
@@ -30,9 +30,9 @@
$submissionid = required_param('submissionid', PARAM_INT);
-$params = array(
- 'submissionid' => $submissionid
-);
+$params = [
+ 'submissionid' => $submissionid,
+];
$controller = new mod_coursework\controllers\plagiarism_flagging_controller($params);
$controller->create_plagiarism_flag();
diff --git a/actions/plagiarism_flagging/edit.php b/actions/plagiarism_flagging/edit.php
index be4b7507..f3270d57 100644
--- a/actions/plagiarism_flagging/edit.php
+++ b/actions/plagiarism_flagging/edit.php
@@ -26,9 +26,9 @@
$flagid = optional_param('flagid', 0, PARAM_INT);
-$params = array(
- 'flagid' => $flagid
-);
+$params = [
+ 'flagid' => $flagid,
+];
$controller = new mod_coursework\controllers\plagiarism_flagging_controller($params);
$controller->edit_plagiarism_flag();
diff --git a/actions/plagiarism_flagging/new.php b/actions/plagiarism_flagging/new.php
index d1b3a388..1bf0f6e8 100644
--- a/actions/plagiarism_flagging/new.php
+++ b/actions/plagiarism_flagging/new.php
@@ -26,9 +26,9 @@
$submissionid = required_param('submissionid', PARAM_INT);
-$params = array(
- 'submissionid' => $submissionid
-);
+$params = [
+ 'submissionid' => $submissionid,
+];
$controller = new mod_coursework\controllers\plagiarism_flagging_controller($params);
$controller->new_plagiarism_flag();
diff --git a/actions/plagiarism_flagging/update.php b/actions/plagiarism_flagging/update.php
index 903d7245..bee0ed85 100644
--- a/actions/plagiarism_flagging/update.php
+++ b/actions/plagiarism_flagging/update.php
@@ -30,9 +30,9 @@
$flagid = required_param('flagid', PARAM_INT);
-$params = array(
- 'flagid' => $flagid
-);
+$params = [
+ 'flagid' => $flagid,
+];
$controller = new mod_coursework\controllers\plagiarism_flagging_controller($params);
$controller->update_plagiarism_flag();
diff --git a/actions/processallocation.php b/actions/processallocation.php
index bbed5f0d..690d4cb0 100644
--- a/actions/processallocation.php
+++ b/actions/processallocation.php
@@ -37,8 +37,8 @@
$coursemoduleid = required_param('coursemoduleid', PARAM_INT);
$coursemodule = get_coursemodule_from_id('coursework', $coursemoduleid, 0, false, MUST_EXIST);
-$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST);
-$coursework = $DB->get_record('coursework', array('id' => $coursemodule->instance), '*', MUST_EXIST);
+$course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST);
+$coursework = $DB->get_record('coursework', ['id' => $coursemodule->instance], '*', MUST_EXIST);
$coursework = coursework::find($coursework);
$assessorallocationstrategy = optional_param('assessorallocationstrategy', false, PARAM_TEXT);
diff --git a/actions/revert.php b/actions/revert.php
index 78aff861..ea71ff12 100644
--- a/actions/revert.php
+++ b/actions/revert.php
@@ -31,16 +31,16 @@
global $DB, $PAGE, $CFG;
$cmid = required_param('cmid', PARAM_INT);
-$submission_id = required_param('submissionid', PARAM_INT);
+$submissionid = required_param('submissionid', PARAM_INT);
-$cm = $DB->get_record('course_modules', array('id' => $cmid));
+$cm = $DB->get_record('course_modules', ['id' => $cmid]);
$coursework = coursework::find($cm->instance);
-$course = $DB->get_record('course', array('id' => $cm->course));
-$submission_db = $DB->get_record('coursework_submissions', array('id' => $submission_id));
-$submission = submission::find($submission_db);
+$course = $DB->get_record('course', ['id' => $cm->course]);
+$submissiondb = $DB->get_record('coursework_submissions', ['id' => $submissionid]);
+$submission = submission::find($submissiondb);
require_login($course, false, $cm);
-$url = new moodle_url('/mod/coursework/view.php', array('id' => $cm->id));
+$url = new moodle_url('/mod/coursework/view.php', ['id' => $cm->id]);
// Bounce anyone who shouldn't be here.
if (!has_capability('mod/coursework:revertfinalised', $PAGE->context)) {
diff --git a/actions/selectallallocatables.php b/actions/selectallallocatables.php
index e241d770..75aa14f6 100644
--- a/actions/selectallallocatables.php
+++ b/actions/selectallallocatables.php
@@ -32,8 +32,8 @@
$coursemoduleid = required_param('coursemoduleid', PARAM_INT);
$stagenumber = required_param('stage', PARAM_INT);
$coursemodule = get_coursemodule_from_id('coursework', $coursemoduleid, 0, false, MUST_EXIST);
-$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST);
-$coursework = $DB->get_record('coursework', array('id' => $coursemodule->instance), '*', MUST_EXIST);
+$course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST);
+$coursework = $DB->get_record('coursework', ['id' => $coursemodule->instance], '*', MUST_EXIST);
$coursework = coursework::find($coursework);
$assessorallocationstrategy = optional_param('assessorallocationstrategy', false, PARAM_TEXT);
diff --git a/actions/set_personal_deadlines.php b/actions/set_personal_deadlines.php
index c6d42bf4..20df84e1 100644
--- a/actions/set_personal_deadlines.php
+++ b/actions/set_personal_deadlines.php
@@ -33,8 +33,8 @@
$coursemoduleid = required_param('id', PARAM_INT);
$coursemodule = get_coursemodule_from_id('coursework', $coursemoduleid, 0, false, MUST_EXIST);
-$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST);
-$coursework = $DB->get_record('coursework', array('id' => $coursemodule->instance), '*', MUST_EXIST);
+$course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST);
+$coursework = $DB->get_record('coursework', ['id' => $coursemodule->instance], '*', MUST_EXIST);
$coursework = coursework::find($coursework);
// SQL sort for allocation table.
@@ -46,7 +46,7 @@
require_capability('mod/coursework:editpersonaldeadline', $PAGE->context, null, true, "Can't change personal deadlines here - permission denied.");
$url = '/mod/coursework/actions/set_personal_deadlines.php';
-$link = new \moodle_url($url, array('id' => $coursemoduleid));
+$link = new \moodle_url($url, ['id' => $coursemoduleid]);
$PAGE->set_url($link);
$title = get_string('setpersonaldeadlinesfor', 'mod_coursework', $coursework->name);
$PAGE->set_title($title);
@@ -55,12 +55,12 @@
$PAGE->requires->jquery();
// Will set off the function that adds listeners for onclick/onchange etc.
-$jsmodule = array(
+$jsmodule = [
'name' => 'mod_coursework',
'fullpath' => '/mod/coursework/module.js',
- 'requires' => array('base',
- 'node-base')
-);
+ 'requires' => ['base',
+ 'node-base'],
+];
$PAGE->requires->js_init_call('M.mod_coursework.init_personal_deadlines_page',
[],
false,
@@ -69,11 +69,11 @@
/**
* @var mod_coursework_object_renderer $object_renderer
*/
-$object_renderer = $PAGE->get_renderer('mod_coursework', 'object');
-$personal_deadlines_table = new mod_coursework\personal_deadline\table\builder($coursework, $options);
-$personal_deadlines_table = new mod_coursework_personal_deadlines_table($personal_deadlines_table);
+$objectrenderer = $PAGE->get_renderer('mod_coursework', 'object');
+$personaldeadlinestable = new mod_coursework\personal_deadline\table\builder($coursework, $options);
+$personaldeadlinestable = new mod_coursework_personal_deadlines_table($personaldeadlinestable);
echo $OUTPUT->header();
-echo $object_renderer->render($personal_deadlines_table);
+echo $objectrenderer->render($personaldeadlinestable);
echo $OUTPUT->footer();
diff --git a/actions/submissions/create.php b/actions/submissions/create.php
index 336fbf68..360cf73a 100644
--- a/actions/submissions/create.php
+++ b/actions/submissions/create.php
@@ -34,17 +34,17 @@
$submissionid = optional_param('submissionid', 0, PARAM_INT);
$finalised = !!optional_param('finalisebutton', 0, PARAM_TEXT);
-if (!in_array($allocatabletype, array('user', 'group'))) {
+if (!in_array($allocatabletype, ['user', 'group'])) {
throw new \mod_coursework\exceptions\access_denied(\mod_coursework\models\coursework::find($courseworkid),
'Bad alloctable type');
}
-$params = array(
+$params = [
'courseworkid' => $courseworkid,
'finalised' => $finalised,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
-);
+];
if ($submissionid) {
$params['submissionid'] = $submissionid;
}
diff --git a/actions/submissions/edit.php b/actions/submissions/edit.php
index 061d591c..af5f2fe9 100644
--- a/actions/submissions/edit.php
+++ b/actions/submissions/edit.php
@@ -28,8 +28,8 @@
$submissionid = required_param('submissionid', PARAM_INT);
-$params = array(
+$params = [
'submissionid' => $submissionid,
-);
+];
$controller = new mod_coursework\controllers\submissions_controller($params);
$controller->edit_submission();
diff --git a/actions/submissions/finalise.php b/actions/submissions/finalise.php
index 0695511b..d27505aa 100644
--- a/actions/submissions/finalise.php
+++ b/actions/submissions/finalise.php
@@ -28,8 +28,8 @@
$submissionid = required_param('submissionid', PARAM_INT);
-$params = array(
+$params = [
'submissionid' => $submissionid,
-);
+];
$controller = new mod_coursework\controllers\submissions_controller($params);
$controller->finalise_submission();
diff --git a/actions/submissions/new.php b/actions/submissions/new.php
index 20a33ba6..125fc919 100644
--- a/actions/submissions/new.php
+++ b/actions/submissions/new.php
@@ -32,10 +32,10 @@
$allocatableid = optional_param('allocatableid', $USER->id, PARAM_INT);
$allocatabletype = optional_param('allocatabletype', 'user', PARAM_ALPHANUMEXT);
-$params = array(
+$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
-);
+];
$controller = new mod_coursework\controllers\submissions_controller($params);
$controller->new_submission();
diff --git a/actions/submissions/update.php b/actions/submissions/update.php
index 02bc61b3..0b974f8d 100644
--- a/actions/submissions/update.php
+++ b/actions/submissions/update.php
@@ -29,9 +29,9 @@
$submissionid = required_param('submissionid', PARAM_INT);
$finalised = !!optional_param('finalisebutton', 0, PARAM_TEXT);
-$params = array(
+$params = [
'submissionid' => $submissionid,
'finalised' => $finalised,
-);
+];
$controller = new mod_coursework\controllers\submissions_controller($params);
$controller->update_submission();
diff --git a/actions/submitonbehalfofstudent.php b/actions/submitonbehalfofstudent.php
index 39d23809..198f8c44 100644
--- a/actions/submitonbehalfofstudent.php
+++ b/actions/submitonbehalfofstudent.php
@@ -31,9 +31,9 @@
global $CFG, $DB, $PAGE, $OUTPUT;
$coursemoduleid = required_param('cmid', PARAM_INT);
-$coursemodule = $DB->get_record('course_modules', array('id' => $coursemoduleid));
+$coursemodule = $DB->get_record('course_modules', ['id' => $coursemoduleid]);
$coursework = coursework::find($coursemodule->instance);
-$course = $DB->get_record('course', array('id' => $coursemodule->course));
+$course = $DB->get_record('course', ['id' => $coursemodule->course]);
$studentid = optional_param('userid', 0, PARAM_INT);
$student = \mod_coursework\models\user::find($studentid);
@@ -48,7 +48,7 @@
require_capability('mod/coursework:submitonbehalfof', $PAGE->context);
-$params = array('cmid' => $coursemoduleid);
+$params = ['cmid' => $coursemoduleid];
$url = new moodle_url('/mod/coursework/actions/submitonbehalfofstudent.php', $params);
$PAGE->set_url($url, $params);
@@ -57,12 +57,12 @@
$customdata->coursework = $coursework;
$chooseform = new \mod_coursework\forms\choose_student_for_submission_mform($PAGE->url->out(), $customdata);
if ($chooseform->is_cancelled()) {
- redirect(new moodle_url('mod/coursework/view.php', array('id' => $coursemoduleid)));
+ redirect(new moodle_url('mod/coursework/view.php', ['id' => $coursemoduleid]));
}
$student = false;
if ($studentid) {
- $student = $DB->get_record('user', array('id' => $studentid));
+ $student = $DB->get_record('user', ['id' => $studentid]);
$title = get_string('submitonbehalfofstudent', 'mod_coursework', fullname($student));
} else {
$title = get_string('submitonbehalfof', 'mod_coursework');
@@ -72,10 +72,10 @@
$html = '';
-$customdata = array(
+$customdata = [
'coursework' => $coursework,
'submission' => $submission,
-);
+];
$submitform = new mod_coursework\forms\student_submission_form($url->out(), $customdata);
// Save any data that's there and redirect if successful.
@@ -93,10 +93,10 @@
/**
* @var mod_coursework_page_renderer $page_renderer
*/
-$page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
+$pagerenderer = $PAGE->get_renderer('mod_coursework', 'page');
if (!$studentid) {
- echo $page_renderer->choose_student_to_submit_for($coursemoduleid, $chooseform);
+ echo $pagerenderer->choose_student_to_submit_for($coursemoduleid, $chooseform);
} else {
- echo $page_renderer->submit_on_behalf_of_student_interface($student, $submitform);
+ echo $pagerenderer->submit_on_behalf_of_student_interface($student, $submitform);
}
diff --git a/actions/upload_allocations.php b/actions/upload_allocations.php
index 20842086..96f156dc 100644
--- a/actions/upload_allocations.php
+++ b/actions/upload_allocations.php
@@ -33,9 +33,9 @@
$coursemoduleid = required_param('cmid', PARAM_INT);
-$coursemodule = $DB->get_record('course_modules', array('id' => $coursemoduleid));
+$coursemodule = $DB->get_record('course_modules', ['id' => $coursemoduleid]);
$coursework = coursework::find($coursemodule->instance);
-$course = $DB->get_record('course', array('id' => $coursemodule->course));
+$course = $DB->get_record('course', ['id' => $coursemodule->course]);
require_login($course, false, $coursemodule);
$csvtype = 'allocationsupload';
@@ -44,10 +44,10 @@
$PAGE->set_title($title);
$PAGE->set_heading($title);
-$grading_sheet_capabilities = array('mod/coursework:allocate');
+$gradingsheetcapabilities = ['mod/coursework:allocate'];
// Bounce anyone who shouldn't be here.
-if (!has_any_capability($grading_sheet_capabilities, $PAGE->context)) {
+if (!has_any_capability($gradingsheetcapabilities, $PAGE->context)) {
$message = 'You do not have permission to upload allocations';
redirect(new moodle_url('mod/coursework/view.php'), $message);
}
@@ -70,13 +70,13 @@
// Process
$csvimport->process_csv($content, $data->encoding, $data->delimiter_name, $procsessingresults);
- $page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
- echo $page_renderer->process_csv_upload($procsessingresults, $content, $csvtype);
+ $pagerenderer = $PAGE->get_renderer('mod_coursework', 'page');
+ echo $pagerenderer->process_csv_upload($procsessingresults, $content, $csvtype);
$cache = \cache::make('mod_coursework', 'courseworkdata', ['id' => $coursework->id]);
$cache->purge();
} else {
- $page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
- echo $page_renderer->csv_upload($allocationsuploadform, $csvtype);
+ $pagerenderer = $PAGE->get_renderer('mod_coursework', 'page');
+ echo $pagerenderer->csv_upload($allocationsuploadform, $csvtype);
}
diff --git a/actions/upload_feedback.php b/actions/upload_feedback.php
index fd59f960..37983df8 100644
--- a/actions/upload_feedback.php
+++ b/actions/upload_feedback.php
@@ -33,9 +33,9 @@
$coursemoduleid = required_param('cmid', PARAM_INT);
-$coursemodule = $DB->get_record('course_modules', array('id' => $coursemoduleid));
+$coursemodule = $DB->get_record('course_modules', ['id' => $coursemoduleid]);
$coursework = coursework::find($coursemodule->instance);
-$course = $DB->get_record('course', array('id' => $coursemodule->course));
+$course = $DB->get_record('course', ['id' => $coursemodule->course]);
require_login($course, false, $coursemodule);
@@ -44,10 +44,10 @@
$PAGE->set_title($title);
$PAGE->set_heading($title);
-$grading_sheet_capabilities = array('mod/coursework:addinitialgrade', 'mod/coursework:addagreedgrade', 'mod/coursework:administergrades');
+$gradingsheetcapabilities = ['mod/coursework:addinitialgrade', 'mod/coursework:addagreedgrade', 'mod/coursework:administergrades'];
// Bounce anyone who shouldn't be here.
-if (!has_any_capability($grading_sheet_capabilities, $PAGE->context)) {
+if (!has_any_capability($gradingsheetcapabilities, $PAGE->context)) {
$message = 'You do not have permission to upload feedback sheets';
redirect(new moodle_url('mod/coursework/view.php'), $message);
}
@@ -55,7 +55,7 @@
$feedbackform = new upload_feedback_form($coursework, $coursemoduleid);
if ($feedbackform->is_cancelled()) {
- redirect(new moodle_url("$CFG->wwwroot/mod/coursework/view.php", array('id' => $coursemoduleid)));
+ redirect(new moodle_url("$CFG->wwwroot/mod/coursework/view.php", ['id' => $coursemoduleid]));
}
if ($data = $feedbackform->get_data()) {
@@ -80,10 +80,10 @@
$updateresults = $fileimporter->import_zip_files($coursework, $stageidentifier, $data->overwrite);
- $page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
- echo $page_renderer->process_feedback_upload($updateresults);
+ $pagerenderer = $PAGE->get_renderer('mod_coursework', 'page');
+ echo $pagerenderer->process_feedback_upload($updateresults);
} else {
- $page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
- echo $page_renderer->feedback_upload($feedbackform);
+ $pagerenderer = $PAGE->get_renderer('mod_coursework', 'page');
+ echo $pagerenderer->feedback_upload($feedbackform);
}
diff --git a/actions/upload_grading_sheet.php b/actions/upload_grading_sheet.php
index 9a43230f..d4a8a959 100644
--- a/actions/upload_grading_sheet.php
+++ b/actions/upload_grading_sheet.php
@@ -33,9 +33,9 @@
$coursemoduleid = required_param('cmid', PARAM_INT);
-$coursemodule = $DB->get_record('course_modules', array('id' => $coursemoduleid));
+$coursemodule = $DB->get_record('course_modules', ['id' => $coursemoduleid]);
$coursework = coursework::find($coursemodule->instance);
-$course = $DB->get_record('course', array('id' => $coursemodule->course));
+$course = $DB->get_record('course', ['id' => $coursemodule->course]);
require_login($course, false, $coursemodule);
@@ -45,10 +45,10 @@
$PAGE->set_url(new moodle_url('/mod/coursework/actions/upload_grading_sheet.php'));
$PAGE->set_title($title);
$PAGE->set_heading($title);
-$grading_sheet_capabilities = array('mod/coursework:addinitialgrade', 'mod/coursework:addagreedgrade', 'mod/coursework:administergrades');
+$gradingsheetcapabilities = ['mod/coursework:addinitialgrade', 'mod/coursework:addagreedgrade', 'mod/coursework:administergrades'];
// Bounce anyone who shouldn't be here.
-if (!has_any_capability($grading_sheet_capabilities, $PAGE->context)) {
+if (!has_any_capability($gradingsheetcapabilities, $PAGE->context)) {
$message = 'You do not have permission to upload grading sheets';
redirect(new moodle_url('mod/coursework/view.php'), $message);
}
@@ -65,25 +65,25 @@
$content = $gradinguploadform->get_file_content('gradingdata');
- $csv_cells = \mod_coursework\export\grading_sheet::cells_array($coursework);
+ $csvcells = \mod_coursework\export\grading_sheet::cells_array($coursework);
$csvimport = new \mod_coursework\export\import($coursework, false, false);
- // $csv_cells = $csvimport->csv_columns(); //all columns from spreadsheet
+ // $csv_cells = $csvimport->csv_columns(); //all columns from spreadsheet
- $procsessingresults = $csvimport->validate_csv($content, $data->encoding, $data->delimiter_name, $csv_cells);
+ $procsessingresults = $csvimport->validate_csv($content, $data->encoding, $data->delimiter_name, $csvcells);
// Process
// If (!empty($procsessingresults)) {
- $csvimport->process_csv($content, $data->encoding, $data->delimiter_name, $csv_cells, $procsessingresults);
- $page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
- echo $page_renderer->process_csv_upload($procsessingresults, $content, $csvtype);
+ $csvimport->process_csv($content, $data->encoding, $data->delimiter_name, $csvcells, $procsessingresults);
+ $pagerenderer = $PAGE->get_renderer('mod_coursework', 'page');
+ echo $pagerenderer->process_csv_upload($procsessingresults, $content, $csvtype);
//} else {
//
//}
} else {
- $page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
- echo $page_renderer->csv_upload($gradinguploadform, $csvtype);
+ $pagerenderer = $PAGE->get_renderer('mod_coursework', 'page');
+ echo $pagerenderer->csv_upload($gradinguploadform, $csvtype);
}
diff --git a/backup/moodle2/backup_coursework_activity_task.class.php b/backup/moodle2/backup_coursework_activity_task.class.php
index 78a19a15..13ecfa76 100644
--- a/backup/moodle2/backup_coursework_activity_task.class.php
+++ b/backup/moodle2/backup_coursework_activity_task.class.php
@@ -24,25 +24,25 @@
class backup_coursework_activity_task extends backup_activity_task {
- static public function encode_content_links($content) {
- global $CFG;
+ public static function encode_content_links($content) {
+ global $CFG;
- $base = preg_quote($CFG->wwwroot, "/");
+ $base = preg_quote($CFG->wwwroot, "/");
- // These have to be picked up by the restore code COURSEWORK... are arbitrary
- $search = "/(".$base."\/mod\/coursework\/index.php\?id\=)([0-9]+)/";
- $content = preg_replace($search, '$@COURSEWORKINDEX*$2@$', $content);
+ // These have to be picked up by the restore code COURSEWORK... are arbitrary
+ $search = "/(".$base."\/mod\/coursework\/index.php\?id\=)([0-9]+)/";
+ $content = preg_replace($search, '$@COURSEWORKINDEX*$2@$', $content);
- $search = "/(".$base."\/mod\/coursework\/view.php\?id\=)([0-9]+)/";
- $content = preg_replace($search, '$@COURSEWORKBYID*$2@$', $content);
+ $search = "/(".$base."\/mod\/coursework\/view.php\?id\=)([0-9]+)/";
+ $content = preg_replace($search, '$@COURSEWORKBYID*$2@$', $content);
- return $content;
- }
+ return $content;
+ }
- protected function define_my_settings() {
- }
+ protected function define_my_settings() {
+ }
- protected function define_my_steps() {
- $this->add_step(new backup_coursework_activity_structure_step('coursework_structure', 'coursework.xml'));
- }
+ protected function define_my_steps() {
+ $this->add_step(new backup_coursework_activity_structure_step('coursework_structure', 'coursework.xml'));
+ }
}
diff --git a/backup/moodle2/backup_coursework_stepslib.php b/backup/moodle2/backup_coursework_stepslib.php
index 104b12e9..e2a1eb9d 100644
--- a/backup/moodle2/backup_coursework_stepslib.php
+++ b/backup/moodle2/backup_coursework_stepslib.php
@@ -24,12 +24,12 @@ class backup_coursework_activity_structure_step extends backup_activity_structur
protected function define_structure() {
global $DB;
- foreach (array('coursework_submissions',
+ foreach (['coursework_submissions',
'coursework_allocation_pairs',
'coursework_mod_set_members',
'coursework_sample_set_mbrs',
'coursework_extensions',
- 'coursework_person_deadlines') as $tablename) {
+ 'coursework_person_deadlines'] as $tablename) {
$DB->execute("update {{$tablename}} set allocatableuser=0, allocatablegroup=0");
$DB->execute("update {{$tablename}} set allocatableuser=allocatableid where allocatabletype='user'");
$DB->execute("update {{$tablename}} set allocatablegroup=allocatableid where allocatabletype='group'");
@@ -37,8 +37,8 @@ protected function define_structure() {
$userinfo = $this->get_setting_value('userinfo');
- $coursework = new backup_nested_element('coursework', array('id'),
- array('formid',
+ $coursework = new backup_nested_element('coursework', ['id'],
+ ['formid',
'course',
'name',
'intro',
@@ -105,33 +105,33 @@ protected function define_structure() {
'draftfeedbackenabled',
'processenrol',
'processunenrol',
- 'plagiarismflagenabled'
- ));
+ 'plagiarismflagenabled',
+ ]);
- $sample_strategies = new backup_nested_element('coursework_sample_set_rules');
+ $samplestrategies = new backup_nested_element('coursework_sample_set_rules');
- $sample_strategy = new backup_nested_element('coursework_sample_set_rule', array('id'),
- array('courseworkid',
+ $samplestrategy = new backup_nested_element('coursework_sample_set_rule', ['id'],
+ ['courseworkid',
'sample_set_plugin_id',
'ruleorder',
'ruletype',
'upperlimit',
'lowerlimit',
- 'stage_identifier'));
+ 'stage_identifier']);
- $coursework->add_child($sample_strategies);
+ $coursework->add_child($samplestrategies);
- $sample_strategies->add_child($sample_strategy);
+ $samplestrategies->add_child($samplestrategy);
- $sample_strategy->set_source_table('coursework_sample_set_rules',
- array('courseworkid' => backup::VAR_PARENTID));
+ $samplestrategy->set_source_table('coursework_sample_set_rules',
+ ['courseworkid' => backup::VAR_PARENTID]);
if ($userinfo) {
- $plagiarism_flags = new backup_nested_element('coursework_plagiarism_flags');
+ $plagiarismflags = new backup_nested_element('coursework_plagiarism_flags');
- $plagiarism_flag = new backup_nested_element('coursework_plagiarism_flag', array('id'),
- array(
+ $plagiarismflag = new backup_nested_element('coursework_plagiarism_flag', ['id'],
+ [
"courseworkid",
"submissiond",
"status",
@@ -140,13 +140,13 @@ protected function define_structure() {
"createdby",
"timecreated",
"lastmodifiedby",
- "timemodified"
- ));
+ "timemodified",
+ ]);
- $moderation_agreements = new backup_nested_element('coursework_mod_agreements');
+ $moderationagreements = new backup_nested_element('coursework_mod_agreements');
- $moderation_agreement = new backup_nested_element('coursework_mod_agreement', array('id'),
- array(
+ $moderationagreement = new backup_nested_element('coursework_mod_agreement', ['id'],
+ [
"feedbackid",
"moderatorid",
"agreement",
@@ -154,13 +154,13 @@ protected function define_structure() {
"timemodified",
"lasteditedby",
"modcomment",
- "modecommentformat"
- ));
+ "modecommentformat",
+ ]);
$feedbacks = new backup_nested_element('coursework_feedbacks');
- $feedback = new backup_nested_element('coursework_feedback', array('id'),
- array(
+ $feedback = new backup_nested_element('coursework_feedback', ['id'],
+ [
"submissionid",
"assessorid",
"timecreated",
@@ -176,13 +176,13 @@ protected function define_structure() {
"entry_id",
"markernumber",
"stage_identifier",
- "finalised"
- ));
+ "finalised",
+ ]);
$submissions = new backup_nested_element('coursework_submissions');
- $submission = new backup_nested_element('coursework_submission', array('id'),
- array(
+ $submission = new backup_nested_element('coursework_submission', ['id'],
+ [
"courseworkid",
"userid",
"authorid",
@@ -198,22 +198,22 @@ protected function define_structure() {
'allocatablegroup',
"firstpublished",
"lastpublished",
- "timesubmitted"
- ));
+ "timesubmitted",
+ ]);
$reminders = new backup_nested_element('coursework_reminders');
- $reminder = new backup_nested_element('coursework_reminder', array('id'),
- array(
+ $reminder = new backup_nested_element('coursework_reminder', ['id'],
+ [
"userid",
"coursework_id",
"remindernumber",
- "extension"
- ));
+ "extension",
+ ]);
$pairs = new backup_nested_element('coursework_allocation_pairs');
- $pair = new backup_nested_element('coursework_allocation_pair', array('id'),
- array(
+ $pair = new backup_nested_element('coursework_allocation_pair', ['id'],
+ [
"courseworkid",
"assessorid",
"manual",
@@ -223,48 +223,48 @@ protected function define_structure() {
"allocatableid",
"allocatabletype",
'allocatableuser',
- 'allocatablegroup'
- ));
+ 'allocatablegroup',
+ ]);
$modsetrules = new backup_nested_element('coursework_mod_set_rules');
- $modsetrule = new backup_nested_element('coursework_mod_set_rule', array('id'),
- array(
+ $modsetrule = new backup_nested_element('coursework_mod_set_rule', ['id'],
+ [
"courseworkid",
"rulename",
"ruleorder",
"upperlimit",
"lowerlimit",
- "minimum"
- ));
+ "minimum",
+ ]);
- $allocation_configs = new backup_nested_element('coursework_allocation_configs');
+ $allocationconfigs = new backup_nested_element('coursework_allocation_configs');
- $allocation_config = new backup_nested_element('coursework_allocation_config', array('id'),
- array(
+ $allocationconfig = new backup_nested_element('coursework_allocation_config', ['id'],
+ [
"courseworkid",
"allocationstrategy",
"assessorid",
"value",
- "purpose"
- ));
+ "purpose",
+ ]);
$modsetmembers = new backup_nested_element('coursework_mod_set_members');
- $modsetmember = new backup_nested_element('coursework_mod_set_member', array('id'),
- array(
+ $modsetmember = new backup_nested_element('coursework_mod_set_member', ['id'],
+ [
"courseworkid",
"allocatableid",
"allocatabletype",
'allocatableuser',
'allocatablegroup',
- "stage_identifier"
- ));
+ "stage_identifier",
+ ]);
$extensions = new backup_nested_element('coursework_extensions');
- $extension = new backup_nested_element('coursework_extension', array('id'),
- array(
+ $extension = new backup_nested_element('coursework_extension', ['id'],
+ [
"allocatableid",
"allocatabletype",
'allocatableuser',
@@ -274,13 +274,13 @@ protected function define_structure() {
"pre_defined_reason",
"createdbyid",
"extra_information_text",
- "extra_information_format"
- ));
+ "extra_information_format",
+ ]);
- $personal_deadlines = new backup_nested_element('coursework_person_deadlines');
+ $personaldeadlines = new backup_nested_element('coursework_person_deadlines');
- $personal_deadline = new backup_nested_element('coursework_person_deadline', array('id'),
- array(
+ $personaldeadline = new backup_nested_element('coursework_person_deadline', ['id'],
+ [
"allocatableid",
'allocatableuser',
'allocatablegroup',
@@ -290,21 +290,21 @@ protected function define_structure() {
"createdbyid",
"timecreated",
"timemodified",
- "lastmodifiedbyid"
- ));
+ "lastmodifiedbyid",
+ ]);
- $sample_members = new backup_nested_element('coursework_sample_set_mbrs');
+ $samplemembers = new backup_nested_element('coursework_sample_set_mbrs');
- $sample_member = new backup_nested_element('coursework_sample_set_mbr', array('id'),
- array(
+ $samplemember = new backup_nested_element('coursework_sample_set_mbr', ['id'],
+ [
"courseworkid",
"allocatableid",
"allocatabletype",
'allocatableuser',
'allocatablegroup',
"stage_identifier",
- "selectiontype"
- ));
+ "selectiontype",
+ ]);
// A coursework instance has submissions.
$coursework->add_child($submissions);
@@ -317,13 +317,13 @@ protected function define_structure() {
// And a set of extensionsenabled
$coursework->add_child($extensions);
// And a set of personaldeadlines
- $coursework->add_child($personal_deadlines);
+ $coursework->add_child($personaldeadlines);
// And a set of moderation rule sets
$coursework->add_child($modsetmembers);
// And allocation configs
- $coursework->add_child($allocation_configs);
+ $coursework->add_child($allocationconfigs);
// And sample members
- $coursework->add_child($sample_members);
+ $coursework->add_child($samplemembers);
// And submissions are made up from individual submission instances
$submissions->add_child($submission);
@@ -333,58 +333,58 @@ protected function define_structure() {
// Feedbacks is a set of individual items
$feedbacks->add_child($feedback);
- $feedback->add_child($moderation_agreements);
- $moderation_agreements->add_child($moderation_agreement);
+ $feedback->add_child($moderationagreements);
+ $moderationagreements->add_child($moderationagreement);
- $submission->add_child($plagiarism_flags);
- $plagiarism_flags->add_child($plagiarism_flag);
+ $submission->add_child($plagiarismflags);
+ $plagiarismflags->add_child($plagiarismflag);
// as are reminders, pairs, extensions, modsets and modsetrules,
// and allocation configs
$reminders->add_child($reminder);
$pairs->add_child($pair);
$extensions->add_child($extension);
- $personal_deadlines->add_child($personal_deadline);
+ $personaldeadlines->add_child($personaldeadline);
$modsetrules->add_child($modsetrule);
$modsetmembers->add_child($modsetmember);
- $sample_members->add_child($sample_member);
- $allocation_configs->add_child($allocation_config);
+ $samplemembers->add_child($samplemember);
+ $allocationconfigs->add_child($allocationconfig);
$submission->set_source_table('coursework_submissions',
- array('courseworkid' => backup::VAR_PARENTID));
+ ['courseworkid' => backup::VAR_PARENTID]);
$feedback->set_source_table('coursework_feedbacks',
- array('submissionid' => backup::VAR_PARENTID));
+ ['submissionid' => backup::VAR_PARENTID]);
- $plagiarism_flag->set_source_table('coursework_plagiarism_flags',
- array('submissionid' => backup::VAR_PARENTID));
+ $plagiarismflag->set_source_table('coursework_plagiarism_flags',
+ ['submissionid' => backup::VAR_PARENTID]);
- $moderation_agreement->set_source_table('coursework_mod_agreements',
- array('feedbackid' => backup::VAR_PARENTID));
+ $moderationagreement->set_source_table('coursework_mod_agreements',
+ ['feedbackid' => backup::VAR_PARENTID]);
$reminder->set_source_table('coursework_reminder',
- array('coursework_id' => backup::VAR_PARENTID));
+ ['coursework_id' => backup::VAR_PARENTID]);
$pair->set_source_table('coursework_allocation_pairs',
- array('courseworkid' => backup::VAR_PARENTID));
+ ['courseworkid' => backup::VAR_PARENTID]);
$modsetrule->set_source_table('coursework_mod_set_rules',
- array('courseworkid' => backup::VAR_PARENTID));
+ ['courseworkid' => backup::VAR_PARENTID]);
$extension->set_source_table('coursework_extensions',
- array('courseworkid' => backup::VAR_PARENTID));
+ ['courseworkid' => backup::VAR_PARENTID]);
- $personal_deadline->set_source_table('coursework_person_deadlines',
- array('courseworkid' => backup::VAR_PARENTID));
+ $personaldeadline->set_source_table('coursework_person_deadlines',
+ ['courseworkid' => backup::VAR_PARENTID]);
$modsetmember->set_source_table('coursework_mod_set_members',
- array('courseworkid' => backup::VAR_PARENTID));
+ ['courseworkid' => backup::VAR_PARENTID]);
- $sample_member->set_source_table('coursework_sample_set_mbrs',
- array('courseworkid' => backup::VAR_PARENTID));
+ $samplemember->set_source_table('coursework_sample_set_mbrs',
+ ['courseworkid' => backup::VAR_PARENTID]);
- $allocation_config->set_source_table('coursework_allocation_config',
- array('courseworkid' => backup::VAR_PARENTID));
+ $allocationconfig->set_source_table('coursework_allocation_config',
+ ['courseworkid' => backup::VAR_PARENTID]);
// Mark important foreign keys
$feedback->annotate_ids('user', 'assessorid');
@@ -403,7 +403,7 @@ protected function define_structure() {
$pair->annotate_ids('user', 'allocatableuser');
$pair->annotate_ids('group', 'allocatablegroup');
- $allocation_config->annotate_ids('user', 'assessorid');
+ $allocationconfig->annotate_ids('user', 'assessorid');
$modsetmember->annotate_ids('user', 'allocatableuser');
$modsetmember->annotate_ids('group', 'allocatablegroup');
@@ -411,17 +411,17 @@ protected function define_structure() {
$extension->annotate_ids('user', 'allocatableuser');
$extension->annotate_ids('group', 'allocatablegroup');
- $personal_deadline->annotate_ids('user', 'allocatableuser');
- $personal_deadline->annotate_ids('group', 'allocatablegroup');
+ $personaldeadline->annotate_ids('user', 'allocatableuser');
+ $personaldeadline->annotate_ids('group', 'allocatablegroup');
- $sample_member->annotate_ids('user', 'allocatableuser');
- $sample_member->annotate_ids('group', 'allocatablegroup');
+ $samplemember->annotate_ids('user', 'allocatableuser');
+ $samplemember->annotate_ids('group', 'allocatablegroup');
- $moderation_agreement->annotate_ids('user', 'moderatorid');
- $moderation_agreement->annotate_ids('user', 'lasteditedby');
+ $moderationagreement->annotate_ids('user', 'moderatorid');
+ $moderationagreement->annotate_ids('user', 'lasteditedby');
- $plagiarism_flag->annotate_ids('user', 'createdby');
- $plagiarism_flag->annotate_ids('user', 'lastmodifiedby');
+ $plagiarismflag->annotate_ids('user', 'createdby');
+ $plagiarismflag->annotate_ids('user', 'lastmodifiedby');
$coursework->annotate_files('mod_coursework', 'feedback', null);
$coursework->annotate_files('mod_coursework', 'submission', null);
@@ -430,7 +430,7 @@ protected function define_structure() {
$coursework->annotate_ids('grouping', 'grouping_id');
- $coursework->set_source_table('coursework', array('id' => backup::VAR_ACTIVITYID));
+ $coursework->set_source_table('coursework', ['id' => backup::VAR_ACTIVITYID]);
return $this->prepare_activity_structure($coursework);
diff --git a/backup/moodle2/restore_coursework_activity_task.class.php b/backup/moodle2/restore_coursework_activity_task.class.php
index ef1f4528..7f974a07 100644
--- a/backup/moodle2/restore_coursework_activity_task.class.php
+++ b/backup/moodle2/restore_coursework_activity_task.class.php
@@ -32,7 +32,7 @@ class restore_coursework_activity_task extends restore_activity_task {
*
* @return array of restore_decode_rule
*/
- static public function define_decode_rules() {
+ public static function define_decode_rules() {
$rules = [];
$rules[] = new restore_decode_rule('COURSEWORKBYID',
@@ -52,10 +52,10 @@ static public function define_decode_rules() {
*
* @return array
*/
- static public function define_decode_contents() {
+ public static function define_decode_contents() {
$contents = [];
- $contents[] = new restore_decode_content('coursework', array('intro'), 'assign');
+ $contents[] = new restore_decode_content('coursework', ['intro'], 'assign');
return $contents;
}
diff --git a/backup/moodle2/restore_coursework_stepslib.php b/backup/moodle2/restore_coursework_stepslib.php
index 4413c35a..928fc79f 100644
--- a/backup/moodle2/restore_coursework_stepslib.php
+++ b/backup/moodle2/restore_coursework_stepslib.php
@@ -30,7 +30,7 @@ static function cheaplog($thing, $append = true) {
$append = FILE_APPEND;
}
- file_put_contents('/tmp/cheap.log',print_r($thing, true)."\n---------------\n", $append);
+ file_put_contents('/tmp/cheap.log', print_r($thing, true)."\n---------------\n", $append);
}
/**
@@ -53,7 +53,7 @@ protected function define_structure() {
// and that the coursework_ prefix is not needed.
// It would be nice to go back and take these out here and in backup.
// But not essential
- $bits = array('submission' => 'coursework_submissions',
+ $bits = ['submission' => 'coursework_submissions',
'feedback' => 'coursework_submissions/coursework_submission/coursework_feedbacks',
'reminder' => 'coursework_reminders',
'allocation_pair' => 'coursework_allocation_pairs',
@@ -64,7 +64,7 @@ protected function define_structure() {
'extension' => 'coursework_extensions',
'person_deadline' => 'coursework_person_deadlines',
'mod_agreement' => 'coursework_submissions/coursework_submission/coursework_feedbacks/coursework_feedback/coursework_mod_agreements',
- 'plagiarism_flag' => 'coursework_submissions/coursework_submission/coursework_plagiarism_flags');
+ 'plagiarism_flag' => 'coursework_submissions/coursework_submission/coursework_plagiarism_flags'];
foreach ($bits as $bit => $bitpath) {
$p = new restore_path_element("coursework_$bit", "/activity/coursework/{$bitpath}/coursework_$bit");
@@ -97,23 +97,23 @@ protected function process_coursework_submission($data) {
$this->fixallocatable($data);
- $this->updatedate(array('timemodified',
+ $this->updatedate(['timemodified',
'timecreated',
'timesubmitted',
'firstpublished',
- 'lastpublished',), $data);
+ 'lastpublished', ], $data);
$now = time();
- $this->set_defaults(array('timecreated' => $now,
+ $this->set_defaults(['timecreated' => $now,
'timemodified' => $now,
'firstpublished' => null,
'lastpublished' => null,
'timesubmitted' => null,
'finalised' => 0,
- 'manualsrscode' => ''),
+ 'manualsrscode' => ''],
$data);
- if (!$DB->record_exists('coursework_submissions', array('courseworkid' => $data->courseworkid, 'allocatableid' => $data->allocatableid, 'allocatabletype' => $data->allocatabletype))) {
+ if (!$DB->record_exists('coursework_submissions', ['courseworkid' => $data->courseworkid, 'allocatableid' => $data->allocatableid, 'allocatabletype' => $data->allocatabletype])) {
$newitemid = $DB->insert_record('coursework_submissions', $data);
$this->set_mapping('coursework_submission', $oldid, $newitemid);
@@ -135,15 +135,15 @@ protected function process_coursework_feedback($data) {
$data->lasteditedbyuser = $this->get_mappingid('user', $data->lasteditedbyuser);
$data->markernumber = $this->get_mappingid('user', $data->markernumber);
- $this->updatedate(array('timemodified',
+ $this->updatedate(['timemodified',
'timecreated',
- 'timepublished'), $data);
+ 'timepublished'], $data);
$this->check_grade('grade', $data);
$this->check_grade('cappedgrade', $data);
$now = time();
- $this->set_defaults(array('assessorid' => 0,
+ $this->set_defaults(['assessorid' => 0,
'timecreated' => $now,
'timemodified' => $now,
'grade' => '',
@@ -157,7 +157,7 @@ protected function process_coursework_feedback($data) {
'entry_id' => 0,
'markernumber' => 0,
'stage_identifier' => '',
- 'finalised' => 0), $data);
+ 'finalised' => 0], $data);
$newitemid = $DB->insert_record('coursework_feedbacks', $data);
@@ -171,7 +171,7 @@ protected function process_coursework_reminder($data) {
$data->coursework_id = $this->get_new_parentid('coursework');
$data->userid = $this->get_mappingid('user', $data->userid);
- $this->set_defaults(array('remindernumber' => 0), $data);
+ $this->set_defaults(['remindernumber' => 0], $data);
global $DB;
$newitemid = $DB->insert_record('coursework_reminder', $data);
@@ -183,15 +183,15 @@ protected function process_coursework_allocation_pair($data) {
$data->courseworkid = $this->get_new_parentid('coursework');
$data->assessorid = $this->get_mappingid('user', $data->assessorid);
- $this->updatedate(array('timelocked'), $data);
+ $this->updatedate(['timelocked'], $data);
$this->fixallocatable($data);
- $this->set_defaults(array('assessorid' => 0,
+ $this->set_defaults(['assessorid' => 0,
'manual' => 0,
'moderator' => 0,
'timelocked' => time(),
- 'stage_identifier' => ''), $data);
+ 'stage_identifier' => ''], $data);
global $DB;
$newitemid = $DB->insert_record('coursework_allocation_pairs', $data);
@@ -203,11 +203,11 @@ protected function process_coursework_mod_set_rule($data) {
$data->courseworkid = $this->get_new_parentid('coursework');
- $this->set_defaults(array('rulename' => '',
+ $this->set_defaults(['rulename' => '',
'ruleorder' => 0,
'upperlimit' => 0,
'lowerlimit' => 0,
- 'minimum' => 0), $data);
+ 'minimum' => 0], $data);
global $DB;
$newitemid = $DB->insert_record('coursework_mod_set_members', $data);
@@ -219,12 +219,12 @@ protected function process_coursework_sample_set_rule($data) {
$data->courseworkid = $this->get_new_parentid('coursework');
- $this->set_defaults(array('ruletype' => '',
+ $this->set_defaults(['ruletype' => '',
'ruleorder' => 0,
'upperlimit' => 0,
'lowerlimit' => 0,
'sample_set_plugin_id' => 0,
- 'stage_identifier' => ''), $data);
+ 'stage_identifier' => ''], $data);
global $DB;
$newitemid = $DB->insert_record('coursework_sample_set_rules', $data);
@@ -237,9 +237,9 @@ protected function process_coursework_allocation_config($data) {
$data->courseworkid = $this->get_new_parentid('coursework');
$data->assessorid = $this->get_mappingid('user', $data->assessorid);
- $this->set_defaults(array('allocationstrategy' => '',
+ $this->set_defaults(['allocationstrategy' => '',
'value' => 0,
- 'purpose' => ''),
+ 'purpose' => ''],
$data);
global $DB;
@@ -253,7 +253,7 @@ protected function process_coursework_mod_set_member($data) {
$this->fixallocatable($data);
- $this->set_defaults(array('stage_identifier' => ''), $data);
+ $this->set_defaults(['stage_identifier' => ''], $data);
global $DB;
$newitemid = $DB->insert_record('coursework_mod_set_members', $data);
@@ -266,12 +266,12 @@ protected function process_coursework_sample_set_mbr($data) {
$this->fixallocatable($data);
- $this->set_defaults(array('allocatableid' => 0,
+ $this->set_defaults(['allocatableid' => 0,
'allocatabletype' => '',
'allocatableuser' => 0,
'allocatablegroup' => 0,
'stage_identifier' => '',
- 'selectiontype' => ''), $data);
+ 'selectiontype' => ''], $data);
global $DB;
$newitemid = $DB->insert_record('coursework_sample_set_mbrs', $data);
@@ -285,12 +285,12 @@ protected function process_coursework_extension($data) {
$this->fixallocatable($data);
- $this->updatedate(array('extended_deadline'), $data);
+ $this->updatedate(['extended_deadline'], $data);
- $this->set_defaults(array('extended_deadline' => 0,
+ $this->set_defaults(['extended_deadline' => 0,
'pre_defined_reason' => '',
'extra_information_text' => '',
- 'extra_information_format' => FORMAT_HTML)
+ 'extra_information_format' => FORMAT_HTML]
, $data);
global $DB;
@@ -307,15 +307,15 @@ protected function process_coursework_person_deadline($data) {
$this->fixallocatable($data);
- $this->updatedate(array('personal_deadline',
+ $this->updatedate(['personal_deadline',
'timecreated',
- 'timemodified'), $data);
+ 'timemodified'], $data);
$now = time();
- $this->set_defaults(array('personal_deadline' => 0,
+ $this->set_defaults(['personal_deadline' => 0,
'timecreated' => $now,
'timemodified' => 0,
- 'lastmodifiedbyid' => 0), $data);
+ 'lastmodifiedbyid' => 0], $data);
global $DB;
$newitemid = $DB->insert_record('coursework_person_deadlines', $data);
@@ -330,15 +330,15 @@ protected function process_coursework_mod_agreement($data) {
$this->fixallocatable($data);
- $this->updatedate(array('timecreated',
- 'timemodified'), $data);
+ $this->updatedate(['timecreated',
+ 'timemodified'], $data);
$now = time();
- $this->set_defaults(array('timecreated' => $now,
+ $this->set_defaults(['timecreated' => $now,
'timemodified' => $now,
'lasteditedby' => 0,
'modcomment' => '',
- 'modcommentformat' => 1), $data);
+ 'modcommentformat' => 1], $data);
global $DB;
$newitemid = $DB->insert_record('coursework_mod_agreements', $data);
@@ -353,15 +353,15 @@ protected function process_coursework_plagiarism_flag($data) {
$this->fixallocatable($data);
- $this->updatedate(array('timecreated',
- 'timemodified'), $data);
+ $this->updatedate(['timecreated',
+ 'timemodified'], $data);
$now = time();
- $this->set_defaults(array('timecreated' => $now,
+ $this->set_defaults(['timecreated' => $now,
'timemodified' => $now,
'lastmodifieddby' => 0,
'comment' => '',
- 'comment_format' => 1), $data);
+ 'comment_format' => 1], $data);
global $DB;
$newitemid = $DB->insert_record('coursework_plagiarism_flags', $data);
@@ -380,15 +380,15 @@ protected function process_coursework($data) {
$oldid = $data->id;
$data->course = $this->get_courseid();
- $this->updatedate(array('timemodified',
+ $this->updatedate(['timemodified',
'timecreated',
'startdate',
'generalfeedbacktimepublished',
- 'deadline'), $data);
+ 'deadline'], $data);
$now = time();
// Taken from install.xml
- $this->set_defaults(array('formid' => 0,
+ $this->set_defaults(['formid' => 0,
'course' => 0,
'name' => '',
'intro' => '',
@@ -455,7 +455,7 @@ protected function process_coursework($data) {
'draftfeedbackenabled' => 0,
'processenrol' => 0,
'plagiarismflagenabled' => 0,
- 'processunenrol' => 0), $data);
+ 'processunenrol' => 0], $data);
$this->check_grade('grade', $data);
@@ -501,7 +501,7 @@ protected function after_execute() {
$itemid = $file->get_itemid();
$entry = $DB->get_record('coursework_submissions',
- array('id' => $itemid));
+ ['id' => $itemid]);
$submission = \mod_coursework\models\submission::find($entry->id);
$submission->rename_files(); // use cw function to handle file renaming as submission may have few files
diff --git a/classes/ability.php b/classes/ability.php
index c24ad60e..a13a2aeb 100644
--- a/classes/ability.php
+++ b/classes/ability.php
@@ -152,7 +152,7 @@ function (coursework $coursework) {
// New feedback
$this->prevent_new_feedback_with_no_submission();
- $this->prevent_new_feedback_when_submission_not_finalised();
+ $this->prevent_new_feedback_when_submission_not_finalised();
$this->prevent_new_feedback_when_prerequisite_stages_have_no_feedback();
$this->prevent_new_feedback_with_empty_stage();
$this->prevent_new_feedback_when_allocatable_already_has_feedback_for_this_stage();
@@ -163,7 +163,7 @@ function (coursework $coursework) {
$this->prevent_new_feedback_when_not_assessor_for_stage();
$this->prevent_new_feedback_from_non_allocated_assessors();
$this->allow_new_feedback_by_allocated_assessor();
- $this->allow_new_feedback_from_any_assessor_when_allocation_is_disabled_for_stage_or_instance();
+ $this->allow_new_feedback_from_any_assessor_when_allocation_is_disabled_for_stage_or_instance();
$this->allow_new_feedback_if_agreed_feedback_and_user_can_add_agreed_feedback();
// Create feedback
@@ -230,7 +230,7 @@ function (coursework $coursework) {
// Plagiarism flagging rules for Plagiarism Alert
// New
- // $this->prevent_new_plagiarism_flag_if_already_exists();
+ // $this->prevent_new_plagiarism_flag_if_already_exists();
$this->allow_new_plagiarism_flag_with_capability();
// Edit
@@ -259,10 +259,10 @@ public function require_can($action, $thing) {
* @return array
*/
protected function classname_mappings() {
- return array(
+ return [
'submission_groups_decorator' => 'submission',
'coursework_groups_decorator' => 'coursework',
- );
+ ];
}
/**
@@ -309,12 +309,12 @@ protected function prevent_new_submissions_if_one_already_exists() {
$this->prevent('new',
'mod_coursework\models\submission',
function (submission $submission) {
- $exists_params = array(
+ $existsparams = [
'courseworkid' => $submission->courseworkid,
'allocatableid' => $submission->allocatableid,
'allocatabletype' => $submission->allocatabletype,
- );
- if (submission::exists($exists_params)) {
+ ];
+ if (submission::exists($existsparams)) {
$this->set_message('Submission already exists');
return true;
}
@@ -349,8 +349,8 @@ protected function allow_new_submissions_if_there_is_an_active_extension() {
'mod_coursework\models\submission',
function (submission $submission) {
$coursework = $submission->get_coursework();
- $submitting_allocatable = $coursework->submiting_allocatable_for_student($this->get_user());
- return deadline_extension::allocatable_extension_allows_submission($submitting_allocatable,
+ $submittingallocatable = $coursework->submiting_allocatable_for_student($this->get_user());
+ return deadline_extension::allocatable_extension_allows_submission($submittingallocatable,
$coursework);
});
}
@@ -383,8 +383,8 @@ protected function allow_show_submission_if_user_has_previously_added_feedback_f
$this->allow('show',
'mod_coursework\models\submission',
function (submission $submission) {
- return feedback::exists(array('submissionid' => $submission->id,
- 'assessorid' => $this->get_user()->id()));
+ return feedback::exists(['submissionid' => $submission->id,
+ 'assessorid' => $this->get_user()->id()]);
});
}
@@ -402,10 +402,10 @@ protected function allow_show_submission_if_user_has_an_allocation_for_any_stage
function (submission $submission) {
// Should be visible to those who are OK to mark it.
- $allocation_enabled = $submission->get_coursework()->allocation_enabled();
- $user_has_any_allocation = $submission->get_coursework()
+ $allocationenabled = $submission->get_coursework()->allocation_enabled();
+ $userhasanyallocation = $submission->get_coursework()
->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable());
- return $allocation_enabled && $user_has_any_allocation;
+ return $allocationenabled && $userhasanyallocation;
});
}
@@ -415,28 +415,28 @@ protected function allow_show_submission_to_graders_when_allocations_are_disable
function (submission $submission) {
// Should be visible to those who are OK to mark it.
- $allocation_disabled = !$submission->get_coursework()->allocation_enabled();
- $allowed_to_grade = has_capability('mod/coursework:addinitialgrade',
+ $allocationdisabled = !$submission->get_coursework()->allocation_enabled();
+ $allowedtograde = has_capability('mod/coursework:addinitialgrade',
$submission->get_coursework()->get_context());
- $allowed_to_agree_grades = has_capability('mod/coursework:addagreedgrade',
+ $allowedtoagreegrades = has_capability('mod/coursework:addagreedgrade',
$submission->get_coursework()->get_context());
- return $allocation_disabled && ($allowed_to_grade || $allowed_to_agree_grades);
+ return $allocationdisabled && ($allowedtograde || $allowedtoagreegrades);
});
}
protected function allow_show_submission_to_graders_after_feedback_release() {
-// Show to graders after release
+ // Show to graders after release
$this->allow('show',
'mod_coursework\models\submission',
function (submission $submission) {
- $allowed_to_grade = has_capability('mod/coursework:addinitialgrade',
+ $allowedtograde = has_capability('mod/coursework:addinitialgrade',
$submission->get_coursework()->get_context());
- $allowed_to_agree_grades = has_capability('mod/coursework:addagreedgrade',
+ $allowedtoagreegrades = has_capability('mod/coursework:addagreedgrade',
$submission->get_coursework()->get_context());
- $allocation_disabled = !$submission->get_coursework()->allocation_enabled();
+ $allocationdisabled = !$submission->get_coursework()->allocation_enabled();
- return $allocation_disabled && $submission->is_published() && ($allowed_to_grade || $allowed_to_agree_grades);
+ return $allocationdisabled && $submission->is_published() && ($allowedtograde || $allowedtoagreegrades);
});
}
@@ -445,9 +445,9 @@ protected function allow_show_submission_if_user_is_agreed_grade_assessor_and_su
'mod_coursework\models\submission',
function (submission $submission) {
$state = $submission->get_state();
- $allowed_to_agree_grades = has_capability('mod/coursework:addagreedgrade', $submission->get_coursework()->get_context());
- $allowed_to_edit_agree_grades = has_capability('mod/coursework:editagreedgrade', $submission->get_coursework()->get_context());
- return (($allowed_to_agree_grades && $state == submission::FULLY_GRADED) || ($allowed_to_edit_agree_grades && $state >= submission::FULLY_GRADED));
+ $allowedtoagreegrades = has_capability('mod/coursework:addagreedgrade', $submission->get_coursework()->get_context());
+ $allowedtoeditagreegrades = has_capability('mod/coursework:editagreedgrade', $submission->get_coursework()->get_context());
+ return (($allowedtoagreegrades && $state == submission::FULLY_GRADED) || ($allowedtoeditagreegrades && $state >= submission::FULLY_GRADED));
});
}
@@ -484,15 +484,15 @@ protected function prevent_edit_submission_past_deadline_and_no_extension() {
function (submission $submission) {
// take into account courseworks with personal deadlines
if ($submission->get_coursework()->personal_deadlines_enabled()) {
- $deadline_passed = (bool)$submission->submission_personal_deadline() < time();
- } else {
- $deadline_passed = $submission->get_coursework()->deadline_has_passed();
+ $deadlinepassed = (bool)$submission->submission_personal_deadline() < time();
+ } else {
+ $deadlinepassed = $submission->get_coursework()->deadline_has_passed();
}
- $ok_to_submit_late = $submission->get_coursework()->allow_late_submissions();
+ $oktosubmitlate = $submission->get_coursework()->allow_late_submissions();
$coursework = $submission->get_coursework();
- $submitting_allocatable = $coursework->submiting_allocatable_for_student($this->get_user());
- if ($deadline_passed && !deadline_extension::allocatable_extension_allows_submission($submitting_allocatable, $coursework)) {
- if (!$ok_to_submit_late) {
+ $submittingallocatable = $coursework->submiting_allocatable_for_student($this->get_user());
+ if ($deadlinepassed && !deadline_extension::allocatable_extension_allows_submission($submittingallocatable, $coursework)) {
+ if (!$oktosubmitlate) {
$this->set_message('Cannot submit past the deadline');
return true;
} else {
@@ -518,8 +518,8 @@ protected function allow_edit_submission_when_permitted_and_own_submission() {
$this->allow('edit',
'mod_coursework\models\submission',
function (submission $submission) {
- $can_submit = has_capability('mod/coursework:submit', $submission->get_context(), $this->get_user());
- return $can_submit && $submission->belongs_to_user($this->get_user());
+ $cansubmit = has_capability('mod/coursework:submit', $submission->get_context(), $this->get_user());
+ return $cansubmit && $submission->belongs_to_user($this->get_user());
});
}
@@ -571,12 +571,12 @@ function (submission $submission) {
/**
* @var submission $submission
*/
- $not_already_finalised = !$submission->ready_to_grade();
- $early_finalisation_allowed = $submission->get_coursework()->early_finalisation_allowed();
- $coursework_has_no_deadline = !$submission->get_coursework()->has_deadline();
- $allowed_to = $this->can('new', $submission) || $this->can('edit', $submission);
+ $notalreadyfinalised = !$submission->ready_to_grade();
+ $earlyfinalisationallowed = $submission->get_coursework()->early_finalisation_allowed();
+ $courseworkhasnodeadline = !$submission->get_coursework()->has_deadline();
+ $allowedto = $this->can('new', $submission) || $this->can('edit', $submission);
- return $allowed_to && $not_already_finalised && ($early_finalisation_allowed || $coursework_has_no_deadline);
+ return $allowedto && $notalreadyfinalised && ($earlyfinalisationallowed || $courseworkhasnodeadline);
});
}
@@ -643,11 +643,11 @@ protected function allow_new_moderation_if_user_is_allocated_to_moderate() {
$this->allow('new',
'mod_coursework\models\moderation',
function (moderation $moderation) {
- $is_allocated = false;
+ $isallocated = false;
if ($moderation->get_coursework()->allocation_enabled()) {
- $is_allocated = $moderation->is_moderator_allocated();
+ $isallocated = $moderation->is_moderator_allocated();
}
- return $is_allocated;
+ return $isallocated;
});
}
@@ -655,11 +655,11 @@ protected function prevent_new_moderation_if_user_is_not_allocated_to_moderate()
$this->prevent('new',
'mod_coursework\models\moderation',
function (moderation $moderation) {
- $is_allocated = false;
+ $isallocated = false;
if ($moderation->get_coursework()->allocation_enabled() && !is_siteadmin()) {
- $is_allocated = !$moderation->is_moderator_allocated();
+ $isallocated = !$moderation->is_moderator_allocated();
}
- return $is_allocated;
+ return $isallocated;
});
}
@@ -667,10 +667,10 @@ protected function allow_edit_moderation_if_user_created_moderation_and_can_edit
$this->allow('edit',
'mod_coursework\models\moderation',
function (moderation $moderation) {
- $has_capability = has_capability('mod/coursework:moderate', $moderation->get_coursework()
- ->get_context());
- $is_creator = $moderation->moderatorid == $this->get_user()->id;
- return $has_capability && ($is_creator || is_siteadmin());
+ $hascapability = has_capability('mod/coursework:moderate', $moderation->get_coursework()
+ ->get_context());
+ $iscreator = $moderation->moderatorid == $this->get_user()->id;
+ return $hascapability && ($iscreator || is_siteadmin());
});
}
@@ -678,8 +678,8 @@ protected function allow_edit_moderation_if_user_is_allocated_to_moderate() {
$this->allow('edit',
'mod_coursework\models\moderation',
function (moderation $moderation) {
- $is_allocated = $moderation->is_moderator_allocated();
- return $is_allocated;
+ $isallocated = $moderation->is_moderator_allocated();
+ return $isallocated;
});
}
@@ -803,9 +803,9 @@ function (feedback $feedback) {
$allocatable = $feedback->get_submission()->get_allocatable();
if ($stage->uses_allocation() && $feedback->get_coursework()->allocation_enabled()) {
- $allocated_teacher = $stage->allocated_teacher_for($allocatable);
- if ($allocated_teacher) {
- if ($allocated_teacher->id == $this->user->id) {
+ $allocatedteacher = $stage->allocated_teacher_for($allocatable);
+ if ($allocatedteacher) {
+ if ($allocatedteacher->id == $this->user->id) {
return true;
}
}
@@ -823,9 +823,9 @@ function (feedback $feedback) {
$allocatable = $feedback->get_submission()->get_allocatable();
if ($stage->uses_allocation() && $feedback->get_coursework()->allocation_enabled()) {
- $allocated_teacher = $stage->allocated_teacher_for($allocatable);
- if ($allocated_teacher) {
- if ($allocated_teacher->id() != $this->get_user()->id()) {
+ $allocatedteacher = $stage->allocated_teacher_for($allocatable);
+ if ($allocatedteacher) {
+ if ($allocatedteacher->id() != $this->get_user()->id()) {
return true;
}
}
@@ -839,14 +839,14 @@ protected function allow_new_feedback_from_any_assessor_when_allocation_is_disab
'mod_coursework\models\feedback',
function (feedback $feedback) {
- $has_editable_feedbacks = false;
+ $haseditablefeedbacks = false;
// find out if the previous grades are editable
if ($feedback->is_agreed_grade()) {
- $has_editable_feedbacks = $feedback->get_submission()->editable_feedbacks_exist();
+ $haseditablefeedbacks = $feedback->get_submission()->editable_feedbacks_exist();
}
- if ((!$feedback->get_coursework()->allocation_enabled() || !$feedback->get_stage()->uses_allocation()) && !$has_editable_feedbacks ) {
+ if ((!$feedback->get_coursework()->allocation_enabled() || !$feedback->get_stage()->uses_allocation()) && !$haseditablefeedbacks ) {
return true;
}
return false;
@@ -896,16 +896,16 @@ protected function allow_edit_feedback_if_user_created_feedback_and_is_initial_f
function (feedback $feedback) {
global $CFG;
- $is_initial_grade = $feedback->is_initial_assessor_feedback();
- $has_capability = has_capability('mod/coursework:editinitialgrade', $feedback->get_context());
- $is_creator = $feedback->assessorid == $this->get_user()->id;
- $is_allocated = $feedback->is_assessor_allocated();
+ $isinitialgrade = $feedback->is_initial_assessor_feedback();
+ $hascapability = has_capability('mod/coursework:editinitialgrade', $feedback->get_context());
+ $iscreator = $feedback->assessorid == $this->get_user()->id;
+ $isallocated = $feedback->is_assessor_allocated();
$submission = $feedback->get_submission();
- $in_editable_period = (!empty($feedback->get_coursework()->get_grade_editing_time()) && $feedback->timecreated + $feedback->get_coursework()->get_grade_editing_time() > time());
+ $ineditableperiod = (!empty($feedback->get_coursework()->get_grade_editing_time()) && $feedback->timecreated + $feedback->get_coursework()->get_grade_editing_time() > time());
- return $is_initial_grade && ($has_capability || $in_editable_period) && ($is_creator || $is_allocated);
+ return $isinitialgrade && ($hascapability || $ineditableperiod) && ($iscreator || $isallocated);
});
}
@@ -933,9 +933,9 @@ protected function allow_edit_own_feedback_if_in_draft() {
$this->allow('edit',
'mod_coursework\models\feedback',
function (feedback $feedback) {
- $is_creator = $feedback->assessorid == $this->get_user()->id;
+ $iscreator = $feedback->assessorid == $this->get_user()->id;
$stage = $feedback->get_stage();
- return $is_creator && ($feedback->get_submission()->editable_feedbacks_exist() || $feedback->get_submission()->editable_final_feedback_exist()
+ return $iscreator && ($feedback->get_submission()->editable_feedbacks_exist() || $feedback->get_submission()->editable_final_feedback_exist()
&& ((!$feedback->get_coursework()->has_multiple_markers() && $stage->is_initial_assesor_stage() ) || !$stage->is_initial_assesor_stage()));
});
}
@@ -998,10 +998,10 @@ protected function allow_show_feedback_to_initial_assessors_once_agreed_grade_is
$this->allow('show',
'mod_coursework\models\feedback',
function (feedback $feedback) {
- $is_assessor =
+ $isassessor =
has_capability('mod/coursework:addinitialgrade', $feedback->get_coursework()->get_context());
- $agreed_grade_done = $feedback->get_submission()->final_grade_agreed();
- return $is_assessor && $agreed_grade_done;
+ $agreedgradedone = $feedback->get_submission()->final_grade_agreed();
+ return $isassessor && $agreedgradedone;
});
}
@@ -1045,11 +1045,11 @@ function (allocation $allocation) {
protected function allow_show_grading_table_row_if_allocation_enabled_and_user_has_any_allocation() {
$this->allow('show',
'mod_coursework\grading_table_row_base',
- function (grading_table_row_base $grading_table_row) {
- $allocatable = $grading_table_row->get_allocatable();
+ function (grading_table_row_base $gradingtablerow) {
+ $allocatable = $gradingtablerow->get_allocatable();
- if ($grading_table_row->get_coursework()->allocation_enabled()) {
- if ($grading_table_row->get_coursework()->assessor_has_any_allocation_for_student($allocatable)) {
+ if ($gradingtablerow->get_coursework()->allocation_enabled()) {
+ if ($gradingtablerow->get_coursework()->assessor_has_any_allocation_for_student($allocatable)) {
return true;
}
}
@@ -1060,22 +1060,22 @@ function (grading_table_row_base $grading_table_row) {
protected function allow_show_grading_table_row_if_allocation_enabled_and_all_initial_feedback_done_and_user_can_do_agreed_grades() {
$this->allow('show',
'mod_coursework\grading_table_row_base',
- function (grading_table_row_base $grading_table_row) {
- $can_add_agreed_grade = has_capability('mod/coursework:addagreedgrade',
- $grading_table_row->get_coursework()
+ function (grading_table_row_base $gradingtablerow) {
+ $canaddagreedgrade = has_capability('mod/coursework:addagreedgrade',
+ $gradingtablerow->get_coursework()
->get_context());
- if ($grading_table_row->get_coursework()
- ->allocation_enabled() && $grading_table_row->has_submission()
+ if ($gradingtablerow->get_coursework()
+ ->allocation_enabled() && $gradingtablerow->has_submission()
) {
- $submission_has_all_initial_assessor_feedbacks = $grading_table_row->get_submission()
- ->get_state() >= submission::FULLY_GRADED;
- if ($can_add_agreed_grade &&
- $submission_has_all_initial_assessor_feedbacks
+ $submissionhasallinitialassessorfeedbacks = $gradingtablerow->get_submission()
+ ->get_state() >= submission::FULLY_GRADED;
+ if ($canaddagreedgrade &&
+ $submissionhasallinitialassessorfeedbacks
) {
- $submission_in_sample = $grading_table_row->get_submission()->sampled_feedback_exists();
- return (!$grading_table_row->get_coursework()->sampling_enabled() || $submission_in_sample) ? true : false;
+ $submissioninsample = $gradingtablerow->get_submission()->sampled_feedback_exists();
+ return (!$gradingtablerow->get_coursework()->sampling_enabled() || $submissioninsample) ? true : false;
}
}
return false;
@@ -1085,9 +1085,9 @@ function (grading_table_row_base $grading_table_row) {
protected function allow_show_grading_table_row_if_allocation_not_enabled_and_user_is_assessor_of_any_stage() {
$this->allow('show',
'mod_coursework\grading_table_row_base',
- function (grading_table_row_base $grading_table_row) {
- if (!$grading_table_row->get_coursework()->allocation_enabled()) {
- foreach ($grading_table_row->get_coursework()->marking_stages() as $stage) {
+ function (grading_table_row_base $gradingtablerow) {
+ if (!$gradingtablerow->get_coursework()->allocation_enabled()) {
+ foreach ($gradingtablerow->get_coursework()->marking_stages() as $stage) {
if ($stage->user_is_assessor($this->get_user())) {
return true;
}
@@ -1100,10 +1100,10 @@ function (grading_table_row_base $grading_table_row) {
protected function allow_show_grading_table_row_if_user_has_added_feedback_for_this_submission() {
$this->allow('show',
'mod_coursework\grading_table_row_base',
- function (grading_table_row_base $grading_table_row) {
- if ($grading_table_row->has_submission()) {
- if (feedback::exists(array('submissionid' => $grading_table_row->get_submission()->id,
- 'assessorid' => $this->get_user()->id()))
+ function (grading_table_row_base $gradingtablerow) {
+ if ($gradingtablerow->has_submission()) {
+ if (feedback::exists(['submissionid' => $gradingtablerow->get_submission()->id,
+ 'assessorid' => $this->get_user()->id()])
) {
return true;
}
@@ -1115,27 +1115,27 @@ function (grading_table_row_base $grading_table_row) {
protected function allow_show_grading_table_row_if_user_can_view_grades_at_all_times() {
$this->allow('show',
'mod_coursework\grading_table_row_base',
- function (grading_table_row_base $grading_table_row) {
+ function (grading_table_row_base $gradingtablerow) {
return has_capability('mod/coursework:viewallgradesatalltimes',
- $grading_table_row->get_coursework()->get_context());
+ $gradingtablerow->get_coursework()->get_context());
});
}
protected function allow_show_grading_table_row_if_user_can_submit_on_behalf_of() {
$this->allow('show',
'mod_coursework\grading_table_row_base',
- function (grading_table_row_base $grading_table_row) {
+ function (grading_table_row_base $gradingtablerow) {
return has_capability('mod/coursework:submitonbehalfof',
- $grading_table_row->get_coursework()->get_context());
+ $gradingtablerow->get_coursework()->get_context());
});
}
protected function allow_show_grading_table_row_if_user_can_export_final_grades() {
$this->allow('show',
'mod_coursework\grading_table_row_base',
- function (grading_table_row_base $grading_table_row) {
+ function (grading_table_row_base $gradingtablerow) {
return has_capability('mod/coursework:canexportfinalgrades',
- $grading_table_row->get_coursework()->get_context());
+ $gradingtablerow->get_coursework()->get_context());
});
}
@@ -1158,21 +1158,21 @@ private function allow_new_feedback_if_agreed_feedback_and_user_can_add_agreed_f
function (feedback $feedback) {
$this->set_message('User can not add new agreed feedback.');
- $has_editable_feedbacks = false;
+ $haseditablefeedbacks = false;
// find out if the previous grades are editable
if ($feedback->is_agreed_grade()) {
- $has_editable_feedbacks = $feedback->get_submission()->editable_feedbacks_exist();
+ $haseditablefeedbacks = $feedback->get_submission()->editable_feedbacks_exist();
}
- return $feedback->is_agreed_grade() && !$has_editable_feedbacks && (has_capability('mod/coursework:addagreedgrade',
+ return $feedback->is_agreed_grade() && !$haseditablefeedbacks && (has_capability('mod/coursework:addagreedgrade',
$feedback->get_coursework()
->get_context())
|| has_capability('mod/coursework:addallocatedagreedgrade',
$feedback->get_coursework()
- ->get_context())
+ ->get_context())
&& $feedback->get_submission()->is_assessor_initial_grader());
});
}
@@ -1202,7 +1202,7 @@ private function allow_show_grading_table_row_if_user_can_grant_extension_and_no
'mod_coursework\grading_table_row_base',
function (grading_table_row_base $row) {
- return (!$row->get_coursework()->allocation_enabled() && has_capability('mod/coursework:grantextensions',
+ return (!$row->get_coursework()->allocation_enabled() && has_capability('mod/coursework:grantextensions',
$row->get_coursework()
->get_context()));
@@ -1222,9 +1222,9 @@ function (feedback $feedback) {
private function allow_new_deadline_extension_with_capability() {
$this->allow('new',
'mod_coursework\models\deadline_extension',
- function (deadline_extension $deadline_extension) {
- return $deadline_extension->get_coursework()->has_deadline() && has_capability('mod/coursework:grantextensions',
- $deadline_extension->get_coursework()
+ function (deadline_extension $deadlineextension) {
+ return $deadlineextension->get_coursework()->has_deadline() && has_capability('mod/coursework:grantextensions',
+ $deadlineextension->get_coursework()
->get_context());
});
}
@@ -1232,9 +1232,9 @@ function (deadline_extension $deadline_extension) {
private function allow_show_deadline_extension_with_capability() {
$this->allow('show',
'mod_coursework\models\deadline_extension',
- function (deadline_extension $deadline_extension) {
+ function (deadline_extension $deadlineextension) {
return has_capability('mod/coursework:viewextensions',
- $deadline_extension->get_coursework()
+ $deadlineextension->get_coursework()
->get_context());
});
}
@@ -1242,9 +1242,9 @@ function (deadline_extension $deadline_extension) {
private function allow_edit_deadline_extension_with_capability() {
$this->allow('edit',
'mod_coursework\models\deadline_extension',
- function (deadline_extension $deadline_extension) {
+ function (deadline_extension $deadlineextension) {
return has_capability('mod/coursework:grantextensions',
- $deadline_extension->get_coursework()
+ $deadlineextension->get_coursework()
->get_context());
});
}
@@ -1252,12 +1252,12 @@ function (deadline_extension $deadline_extension) {
private function prevent_new_deadline_extension_if_already_exists() {
$this->prevent('new',
'mod_coursework\models\deadline_extension',
- function (deadline_extension $deadline_extension) {
- $conditions = array(
- 'allocatableid' => $deadline_extension->allocatableid,
- 'allocatabletype' => $deadline_extension->allocatabletype,
- 'courseworkid' => $deadline_extension->courseworkid,
- );
+ function (deadline_extension $deadlineextension) {
+ $conditions = [
+ 'allocatableid' => $deadlineextension->allocatableid,
+ 'allocatabletype' => $deadlineextension->allocatabletype,
+ 'courseworkid' => $deadlineextension->courseworkid,
+ ];
return deadline_extension::exists($conditions);
});
}
@@ -1265,24 +1265,24 @@ function (deadline_extension $deadline_extension) {
private function prevent_edit_deadline_extension_if_not_persisted() {
$this->prevent('edit',
'mod_coursework\models\deadline_extension',
- function (deadline_extension $deadline_extension) {
- return !$deadline_extension->persisted();
+ function (deadline_extension $deadlineextension) {
+ return !$deadlineextension->persisted();
});
}
private function allow_create_deadline_extension_if_can_new() {
$this->allow('create',
'mod_coursework\models\deadline_extension',
- function (deadline_extension $deadline_extension) {
- return $this->can('new', $deadline_extension);
+ function (deadline_extension $deadlineextension) {
+ return $this->can('new', $deadlineextension);
});
}
private function allow_update_deadline_extension_if_can_edit() {
$this->allow('update',
'mod_coursework\models\deadline_extension',
- function (deadline_extension $deadline_extension) {
- return $this->can('edit', $deadline_extension);
+ function (deadline_extension $deadlineextension) {
+ return $this->can('edit', $deadlineextension);
});
}
@@ -1306,10 +1306,10 @@ function (submission $submission) {
private function allow_edit_personal_deadline_with_capability() {
$this->allow('edit',
'mod_coursework\models\personal_deadline',
- function (personal_deadline $personal_deadline) {
- return $personal_deadline->get_coursework()->personal_deadlines_enabled()
+ function (personal_deadline $personaldeadline) {
+ return $personaldeadline->get_coursework()->personal_deadlines_enabled()
&& has_capability('mod/coursework:editpersonaldeadline',
- $personal_deadline->get_coursework()
+ $personaldeadline->get_coursework()
->get_context());
});
}
@@ -1317,26 +1317,26 @@ function (personal_deadline $personal_deadline) {
private function prevent_edit_personal_deadline_if_extension_given() {
$this->prevent('edit',
'mod_coursework\models\personal_deadline',
- function (personal_deadline $personal_deadline) {
+ function (personal_deadline $personaldeadline) {
// check if extension for this PD exists
- return $personal_deadline->extension_exists();
+ return $personaldeadline->extension_exists();
});
}
private function allow_new_plagiarism_flag_with_capability() {
$this->allow('new',
'mod_coursework\models\plagiarism_flag',
- function (plagiarism_flag $plagiarism_flag) {
- return has_capability('mod/coursework:addplagiarismflag', $plagiarism_flag->get_coursework()->get_context());
+ function (plagiarism_flag $plagiarismflag) {
+ return has_capability('mod/coursework:addplagiarismflag', $plagiarismflag->get_coursework()->get_context());
});
}
private function allow_edit_plagiarism_flag_with_capability() {
$this->allow('edit',
'mod_coursework\models\plagiarism_flag',
- function (plagiarism_flag $plagiarism_flag) {
+ function (plagiarism_flag $plagiarismflag) {
return has_capability('mod/coursework:updateplagiarismflag',
- $plagiarism_flag->get_coursework()
+ $plagiarismflag->get_coursework()
->get_context());
});
}
@@ -1344,8 +1344,8 @@ function (plagiarism_flag $plagiarism_flag) {
private function prevent_edit_plagiarism_flag_if_not_persisted() {
$this->prevent('edit',
'mod_coursework\models\plagiarism_flag',
- function (plagiarism_flag $plagiarism_flag) {
- return !$plagiarism_flag->persisted();
+ function (plagiarism_flag $plagiarismflag) {
+ return !$plagiarismflag->persisted();
});
}
diff --git a/classes/ability/rule.php b/classes/ability/rule.php
index 15272a7e..a3393fa0 100644
--- a/classes/ability/rule.php
+++ b/classes/ability/rule.php
@@ -38,12 +38,12 @@ class rule {
/**
* @var string
*/
- protected $class_name;
+ protected $classname;
/**
* @var callable
*/
- protected $rule_function;
+ protected $rulefunction;
/**
* @var bool
@@ -52,14 +52,14 @@ class rule {
/**
* @param string $action
- * @param string $class_name
- * @param $rule_function
+ * @param string $classname
+ * @param $rulefunction
* @param bool $allow
*/
- public function __construct($action, $class_name, $rule_function, $allow = true) {
+ public function __construct($action, $classname, $rulefunction, $allow = true) {
$this->action = $action;
- $this->class_name = $class_name;
- $this->rule_function = $rule_function;
+ $this->classname = $classname;
+ $this->rulefunction = $rulefunction;
$this->allow = $allow;
}
@@ -81,7 +81,7 @@ public function matches($action, $object) {
* @return bool
*/
public function allows($object) {
- $rule = $this->rule_function;
+ $rule = $this->rulefunction;
return $rule($object) && $this->allow;
}
@@ -92,7 +92,7 @@ public function allows($object) {
* @return bool
*/
public function prevents($object) {
- $rule = $this->rule_function;
+ $rule = $this->rulefunction;
return $rule($object) && !$this->allow;
}
@@ -109,10 +109,10 @@ protected function action_matches($action) {
* @return bool
*/
protected function class_matches($object) {
- if (get_class($object) == $this->class_name) {
+ if (get_class($object) == $this->classname) {
return true;
}
- if (get_parent_class($object) == $this->class_name) {
+ if (get_parent_class($object) == $this->classname) {
return true;
}
return false;
diff --git a/classes/allocation/allocatable.php b/classes/allocation/allocatable.php
index 7a215d7c..c772a6e4 100644
--- a/classes/allocation/allocatable.php
+++ b/classes/allocation/allocatable.php
@@ -58,7 +58,7 @@ public function picture();
* @param bool $with_picture
* @return string
*/
- public function profile_link($with_picture = false);
+ public function profile_link($withpicture = false);
/**
* @param \stdClass $course
diff --git a/classes/allocation/auto_allocator.php b/classes/allocation/auto_allocator.php
index 97b65961..461b7a39 100644
--- a/classes/allocation/auto_allocator.php
+++ b/classes/allocation/auto_allocator.php
@@ -105,7 +105,7 @@ private function get_allocatables() {
private function delete_all_ungraded_auto_allocations() {
global $DB;
- $ungraded_allocations = $DB->get_records_sql('
+ $ungradedallocations = $DB->get_records_sql('
SELECT *
FROM {coursework_allocation_pairs} p
WHERE courseworkid = ?
@@ -120,14 +120,14 @@ private function delete_all_ungraded_auto_allocations() {
AND s.courseworkid = p.courseworkid
AND f.stage_identifier = p.stage_identifier
)
- ', array('courseworkid' => $this->get_coursework()->id));
+ ', ['courseworkid' => $this->get_coursework()->id]);
- foreach ($ungraded_allocations as &$allocation) {
+ foreach ($ungradedallocations as &$allocation) {
/**
* @var allocation $allocation_object
*/
- $allocation_object = allocation::find($allocation);
- $allocation_object->destroy();
+ $allocationobject = allocation::find($allocation);
+ $allocationobject->destroy();
}
}
diff --git a/classes/allocation/manager.php b/classes/allocation/manager.php
index e25b57af..57b38a9a 100644
--- a/classes/allocation/manager.php
+++ b/classes/allocation/manager.php
@@ -123,9 +123,9 @@ public static function get_allocation_classnames($type = coursework::ASSESSOR) {
// move 'none' to be the first option
if (array_key_exists('none', $options)) {
- $new_value = array('none' => $options['none']);
+ $newvalue = ['none' => $options['none']];
unset($options['none']);
- $options = $new_value + $options;
+ $options = $newvalue + $options;
}
return $options;
@@ -161,25 +161,25 @@ public function auto_generate_moderation_set() {
$allocatables = $this->get_coursework()->get_allocatables();
$stage = $this->get_coursework()->get_moderator_marking_stage();
- $set_rules = $this->get_moderation_set_rules();
+ $setrules = $this->get_moderation_set_rules();
// No set to make.
- if (empty($set_rules)) {
+ if (empty($setrules)) {
return;
}
// These are the ones we will actually moderate (or which have already been moderated).
- $moderation_set = [];
+ $moderationset = [];
// 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.
- $moderation_set = $this->add_already_moderated_allocatables_to_set($allocatables, $stage, $moderation_set);
+ $moderationset = $this->add_already_moderated_allocatables_to_set($allocatables, $stage, $moderationset);
// Now, we loop over the set repeatedly, once for each rule, and add those we want to the set.
- foreach ($set_rules as $rule) {
+ foreach ($setrules as $rule) {
// The rule will separate out those students that ought to be included, leaving
// the arrays altered.
- $rule->adjust_set($moderation_set, $allocatables, $stage);
+ $rule->adjust_set($moderationset, $allocatables, $stage);
}
}
@@ -191,8 +191,8 @@ public function auto_generate_moderation_set() {
* @return array
*/
public function get_sampling_options() {
- return array('0' => get_string('manual', 'mod_coursework'),
- '1' => get_string('automatic', 'mod_coursework'));
+ return ['0' => get_string('manual', 'mod_coursework'),
+ '1' => get_string('automatic', 'mod_coursework')];
}
@@ -206,7 +206,7 @@ public function get_sampling_set_rules() {
global $DB;
// Get rules for include sets.
- $params = array('courseworkid' => $this->coursework->id);
+ $params = ['courseworkid' => $this->coursework->id];
$rules = $DB->get_records('coursework_mod_set_rules', $params, 'ruleorder');
foreach ($rules as $key => &$rule) {
@@ -242,7 +242,7 @@ public function get_sampling_set_widget($requestedrule = false) {
* @param string $rule_name
* @throws moodle_exception
*/
- public function save_sample_set_rule($assessor_number) {
+ public function save_sample_set_rule($assessornumber) {
global $CFG, $DB;
@@ -254,7 +254,7 @@ public function save_sample_set_rule($assessor_number) {
$rule = new $classname($this->coursework);
- $rule->save_form_data($assessor_number, $order);
+ $rule->save_form_data($assessornumber, $order);
}
@@ -263,12 +263,12 @@ public function save_sample_set_rule($assessor_number) {
public function save_sample() {
global $DB;
- $DB->delete_records('coursework_sample_set_rules', array('courseworkid' => $this->coursework->id));
+ $DB->delete_records('coursework_sample_set_rules', ['courseworkid' => $this->coursework->id]);
for ($i = 2; $i <= $this->coursework->get_max_markers(); $i++) {
- $sample_strategy = required_param("assessor_{$i}_samplingstrategy", PARAM_INT);
+ $samplestrategy = required_param("assessor_{$i}_samplingstrategy", PARAM_INT);
- if ($sample_strategy) {
+ if ($samplestrategy) {
$this->save_sample_set_rule($i);
}
@@ -289,20 +289,22 @@ public function auto_generate_sample_set() {
$sampleplugins = $DB->get_records('coursework_sample_set_plugin', null, 'pluginorder');
$order = 0;
- $sample_set = [];
+ $sampleset = [];
$allocatables = $this->get_coursework()->get_allocatables();
- $final_agreed_allocatables = $this->get_allocatables_with_final_agreed();
+ $finalagreedallocatables = $this->get_allocatables_with_final_agreed();
// Remove any allocatables that have a status of final agreed as these can not be sampled
- foreach ($final_agreed_allocatables as $faa) {
- if (isset($allocatables[$faa->allocatableid])) unset($allocatables[$faa->allocatableid]);
+ foreach ($finalagreedallocatables as $faa) {
+ if (isset($allocatables[$faa->allocatableid])) {
+ unset($allocatables[$faa->allocatableid]);
+ }
}
- for ($stage_number = 2; $stage_number <= $this->get_coursework()->get_max_markers(); $stage_number++) {
+ for ($stagenumber = 2; $stagenumber <= $this->get_coursework()->get_max_markers(); $stagenumber++) {
- $stage = "assessor_{$stage_number}";
+ $stage = "assessor_{$stagenumber}";
$this->remove_unmarked_automatic_allocatables($stage);
@@ -315,57 +317,59 @@ public function auto_generate_sample_set() {
AND stage_identifier = :stage
ORDER BY ruleorder)a";
- if ($sampleplugins = $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id, 'stage' => $stage))) {
+ if ($sampleplugins = $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id, 'stage' => $stage])) {
//$allocatables = $this->get_coursework()->get_allocatables_with_feedback();
$allocatables = $this->get_coursework()->get_allocatables();
- $manual_sample_set = $this->get_include_in_sample_set($stage_number);
+ $manualsampleset = $this->get_include_in_sample_set($stagenumber);
- $auto_with_feedback = $this->get_automatic_with_feedback($stage);
+ $autowithfeedback = $this->get_automatic_with_feedback($stage);
// Ok this array merge is being carried out using an foreach rather than array_merge as we want to preserve keys
// I am also not using add the two arrays as using the overloaded + can produce dubious results when a key exists
// In both arrays
- foreach ($auto_with_feedback as $k => $v) {
- if (!isset($manual_sample_set[$k])) $manual_sample_set[$k] = $v;
+ foreach ($autowithfeedback as $k => $v) {
+ if (!isset($manualsampleset[$k])) {
+ $manualsampleset[$k] = $v;
+ }
}
- $auto_sample_set = [];
+ $autosampleset = [];
foreach ($sampleplugins as $plugin) {
$classname = '\mod_coursework\sample_set_rule\\' . $plugin->rulename;
$rule = new $classname($this->coursework);
- $rule->adjust_sample_set($stage_number, $allocatables, $manual_sample_set, $auto_sample_set);
+ $rule->adjust_sample_set($stagenumber, $allocatables, $manualsampleset, $autosampleset);
}
// Save sample set
- if (!empty($auto_sample_set)) {
- foreach ($auto_sample_set as $allocatable) {
- $sample = new \stdClass();
- $sample->courseworkid = $this->coursework->id;
- $sample->allocatableid = $allocatable->id;
- $sample->allocatabletype = ($this->coursework->is_configured_to_have_group_submissions()) ? "group" : "user";
- $sample->stage_identifier = "assessor_{$stage_number}";
- $sample->selectiontype = "automatic";
-
- // If this a manually selected allocatable check to see if the allocatable is already in the table
- $DB->insert_record("coursework_sample_set_mbrs", $sample);
-
- }
+ if (!empty($autosampleset)) {
+ foreach ($autosampleset as $allocatable) {
+ $sample = new \stdClass();
+ $sample->courseworkid = $this->coursework->id;
+ $sample->allocatableid = $allocatable->id;
+ $sample->allocatabletype = ($this->coursework->is_configured_to_have_group_submissions()) ? "group" : "user";
+ $sample->stage_identifier = "assessor_{$stagenumber}";
+ $sample->selectiontype = "automatic";
+
+ // If this a manually selected allocatable check to see if the allocatable is already in the table
+ $DB->insert_record("coursework_sample_set_mbrs", $sample);
+
+ }
}
}
}
}
- public function get_include_in_sample_set($stage_number) {
+ public function get_include_in_sample_set($stagenumber) {
global $DB;
- $stage = "assessor_{$stage_number}";
+ $stage = "assessor_{$stagenumber}";
$sql = "SELECT allocatableid,
courseworkid,
@@ -379,7 +383,7 @@ public function get_include_in_sample_set($stage_number) {
// Get all users in manually selected for stage in coursework
return $DB->get_records_sql($sql,
- array('courseworkid' => $this->coursework->id, 'stage_identifier' => $stage));
+ ['courseworkid' => $this->coursework->id, 'stage_identifier' => $stage]);
}
@@ -400,7 +404,7 @@ public function get_automatic_with_feedback($stage) {
AND f.stage_identifier = m.stage_identifier
";
- return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id, 'stage' => $stage));
+ return $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id, 'stage' => $stage]);
}
public function remove_unmarked_automatic_allocatables($stage) {
@@ -436,7 +440,7 @@ public function get_allocatables_with_final_agreed() {
WHERE s.courseworkid = {$this->coursework->id}
AND f.stage_identifier = 'final_agreed_1'";
- return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id));
+ return $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id]);
}
diff --git a/classes/allocation/strategy/base.php b/classes/allocation/strategy/base.php
index 4069fa15..ea6e4386 100644
--- a/classes/allocation/strategy/base.php
+++ b/classes/allocation/strategy/base.php
@@ -54,10 +54,10 @@ abstract class base {
/**
* @var array the columns in the DB
*/
- protected $fields = array(
+ protected $fields = [
'id',
'courseworkid',
- );
+ ];
/**
* Holds the config settings to avoid repeated DB calls.
@@ -138,17 +138,17 @@ abstract public function save_allocation_strategy_options();
* @param bool $reset we cache this stuff, so reset = true will wipe the cache
* @return \stdClass[]
*/
- protected final function get_existing_config_data($type = 'assessor', $reset = false) {
+ final protected function get_existing_config_data($type = 'assessor', $reset = false) {
global $DB;
if (!isset($this->settings[$type]) || $reset) {
- $params = array(
+ $params = [
'courseworkid' => $this->coursework->id,
'allocationstrategy' => $this->get_name(),
- 'purpose' => $type
+ 'purpose' => $type,
- );
+ ];
$this->settings[$type] = $DB->get_records('coursework_allocation_config', $params);
}
@@ -159,8 +159,8 @@ protected final function get_existing_config_data($type = 'assessor', $reset = f
* @return string
*/
protected function get_type() {
- $exploded_class_name = explode('\\', get_class($this->stage));
- return array_pop($exploded_class_name);
+ $explodedclassname = explode('\\', get_class($this->stage));
+ return array_pop($explodedclassname);
}
/**
@@ -169,12 +169,12 @@ protected function get_type() {
* @return bool
*/
protected function teacher_already_has_an_allocation_for_this_allocatable($student, $teacher) {
- $params = array(
+ $params = [
'courseworkid' => $this->coursework->id,
'allocatableid' => $student->id(),
'allocatabletype' => $student->type(),
'assessorid' => $teacher->id,
- );
+ ];
return allocation::exists($params);
}
@@ -183,10 +183,10 @@ protected function teacher_already_has_an_allocation_for_this_allocatable($stude
* @return int
*/
protected function number_of_existing_allocations_teacher_has($teacher) {
- $params = array(
+ $params = [
'courseworkid' => $this->coursework->id,
'assessorid' => $teacher->id,
- );
+ ];
return allocation::count($params);
}
@@ -194,17 +194,17 @@ protected function number_of_existing_allocations_teacher_has($teacher) {
* @param array $teacher_counts teacherid => number_of_allocations_so_far
* @return user|bool
*/
- protected function get_teacher_with_smallest_number_of_current_allocations($teacher_counts) {
+ protected function get_teacher_with_smallest_number_of_current_allocations($teachercounts) {
// What if there aren't any e.g. only one teacher, but two are needed?
- if (empty($teacher_counts)) {
+ if (empty($teachercounts)) {
return false;
}
// Which is the best one? Whichever has the fewest. Might be several with the same number, so we
// get the allocations count value that's lowest (may represent multiple teachers), then get the first array
// key (teacher id) that has that number of allocations.
- $smallestcount = min($teacher_counts);
- return user::find(array_search($smallestcount, $teacher_counts));
+ $smallestcount = min($teachercounts);
+ return user::find(array_search($smallestcount, $teachercounts));
}
/**
diff --git a/classes/allocation/strategy/percentages.php b/classes/allocation/strategy/percentages.php
index a6fc2064..172dec05 100644
--- a/classes/allocation/strategy/percentages.php
+++ b/classes/allocation/strategy/percentages.php
@@ -102,10 +102,10 @@ public function add_form_elements($strategypurpose = 'assessor') {
}
}
- $attributes = array(
+ $attributes = [
'name' => 'assessorstrategy'.$this->get_name().'['.$teacher->id.']',
- 'size' => 3
- );
+ 'size' => 3,
+ ];
if ($currentsetting) {
$attributes['value'] = $currentsetting->value;
}
@@ -155,12 +155,12 @@ public function save_allocation_strategy_options() {
if (!is_numeric($value)) {
// Empty or duff - make sure we delete any existing record.
- $params = array(
+ $params = [
'courseworkid' => $this->coursework->id,
'allocationstrategy' => $this->get_name(),
'assessorid' => $teacherid,
- 'purpose' => 'assessor'
- );
+ 'purpose' => 'assessor',
+ ];
$DB->delete_records('coursework_allocation_config', $params);
continue;
}
@@ -202,13 +202,13 @@ private function percentage_for_teacher($teacher) {
global $DB;
- $params = array(
+ $params = [
'courseworkid' => $this->coursework->id,
'allocationstrategy' => $this->get_name(),
'purpose' => $this->get_type(),
'assessorid' => $teacher->id,
- );
+ ];
$setting = $DB->get_field('coursework_allocation_config', 'value', $params);
return $setting ? $setting : 0; // Default to 0 percent.
@@ -233,9 +233,9 @@ private function number_of_total_allocations_this_teacher_should_have($teacher)
*/
private function teacher_already_has_maximum_allocations($teacher) {
$targetnumber = $this->number_of_total_allocations_this_teacher_should_have($teacher);
- $number_of_exisiting_allocations = $this->number_of_existing_allocations_teacher_has($teacher);
+ $numberofexisitingallocations = $this->number_of_existing_allocations_teacher_has($teacher);
- return $number_of_exisiting_allocations >= $targetnumber;
+ return $numberofexisitingallocations >= $targetnumber;
}
/**
diff --git a/classes/allocation/table/cell/builder.php b/classes/allocation/table/cell/builder.php
index 859cb3e6..df5b8ec9 100644
--- a/classes/allocation/table/cell/builder.php
+++ b/classes/allocation/table/cell/builder.php
@@ -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 = []) {
+ public function __construct($coursework, $allocatable, $stage, $dataarray = []) {
$this->coursework = $coursework;
$this->allocatable = $allocatable;
$this->stage = $stage;
@@ -166,7 +166,7 @@ private function prepare_allocation_table_cell() {
$class = $this->get_stage()->identifier();
$contents = '';
- $assessor_dropdown = '';
+ $assessordropdown = '';
if ($this->coursework->sampling_enabled()) {
if ($class == 'final_agreed_1') {
@@ -191,33 +191,33 @@ private function prepare_allocation_table_cell() {
}
$contents .= '
';
- if ($this->coursework->allocation_enabled()) {
- $assessor_dropdown = $this->get_potential_marker_dropdown();
- }
- $assessor_name = '';
+ if ($this->coursework->allocation_enabled()) {
+ $assessordropdown = $this->get_potential_marker_dropdown();
+ }
+ $assessorname = '';
if ($this->has_feedback()) {
$class .= ' has-assessor-feedback ';
$feedback = $this->get_feedback();
$assessor = $feedback->assessor();
- $assessor_name = $assessor->profile_link();
- $assessor_name .= '
';
- $assessor_name .= 'Grade: ';
- $assessor_name .= $this->get_feedback()->get_grade();
+ $assessorname = $assessor->profile_link();
+ $assessorname .= '
';
+ $assessorname .= 'Grade: ';
+ $assessorname .= $this->get_feedback()->get_grade();
} else if ($this->has_allocation()) {
- $assessor_name .= ' '.$this->pinned_checkbox($assessor_dropdown);
- $assessor_name .= $this->get_stage()->get_allocated_assessor_name($this->get_allocatable());
+ $assessorname .= ' '.$this->pinned_checkbox($assessordropdown);
+ $assessorname .= $this->get_stage()->get_allocated_assessor_name($this->get_allocatable());
}
- if ($assessor_name) {
- if ($this->get_stage()->uses_sampling() && !$this->get_feedback() && !$this->has_automatic_sampling()) {
+ if ($assessorname) {
+ if ($this->get_stage()->uses_sampling() && !$this->get_feedback() && !$this->has_automatic_sampling()) {
$contents .= '
';
}
- $contents .= "{$assessor_name}";
+ $contents .= "{$assessorname}";
}
- if ($assessor_dropdown) {
- $contents .= $assessor_dropdown;
+ if ($assessordropdown) {
+ $contents .= $assessordropdown;
}
return '
@@ -234,35 +234,35 @@ private function prepare_moderation_table_cell() {
$contents = '';
$class = 'moderators';
- $moderator_dropdown = '';
+ $moderatordropdown = '';
if ($this->coursework->allocation_enabled()) {
- $moderator_dropdown = $this->get_potential_moderators_dropdown();
+ $moderatordropdown = $this->get_potential_moderators_dropdown();
}
- $moderator_name = '';
+ $moderatorname = '';
if ($this->has_moderation()) {
$class .= ' has-moderation-agreement ';
$moderation = $this->get_moderation();
$moderator = $moderation->moderator();
- $moderator_name = $moderator->profile_link();
- $moderator_name .= '
';
- $moderator_name .= 'Agreement: ';
- $moderator_name .= get_string($this->get_moderation()->agreement, 'coursework');
+ $moderatorname = $moderator->profile_link();
+ $moderatorname .= '
';
+ $moderatorname .= 'Agreement: ';
+ $moderatorname .= get_string($this->get_moderation()->agreement, 'coursework');
} else if ($this->has_allocation()) {
- $moderator_name = ' ' . $this->pinned_checkbox($moderator_dropdown);
- $moderator_name .= $this->get_stage()->get_allocated_assessor_name($this->get_allocatable());
+ $moderatorname = ' ' . $this->pinned_checkbox($moderatordropdown);
+ $moderatorname .= $this->get_stage()->get_allocated_assessor_name($this->get_allocatable());
}
- if ($moderator_name) {
+ if ($moderatorname) {
$contents .= '
';
- $contents .= "{$moderator_name}";
+ $contents .= "{$moderatorname}";
}
- if ($moderator_dropdown) {
+ if ($moderatordropdown) {
$contents .= '
';
- $contents .= $moderator_dropdown;
+ $contents .= $moderatordropdown;
}
return '
@@ -289,20 +289,20 @@ private function get_stage() {
* @throws \coding_exception
*/
private function sampling_set_checkbox() {
- $checkbox_name =
+ $checkboxname =
'allocatables[' . $this->get_allocatable()->id . '][' . $this->get_stage()->identifier() . '][in_set]';
- $checkbox_checked = 0;
+ $checkboxchecked = 0;
if ($this->get_stage()->allocatable_is_in_sample($this->get_allocatable()) || $this->get_stage()->identifier() == 'assessor_1') {
- $checkbox_checked = 1;
+ $checkboxchecked = 1;
}
- $checkbox_checked = $this->checkbox_checked_in_session($checkbox_name, $checkbox_checked);
+ $checkboxchecked = $this->checkbox_checked_in_session($checkboxname, $checkboxchecked);
- $checkbox_title = 'Included in sample';
+ $checkboxtitle = 'Included in sample';
- $attributes = array('class' => 'sampling_set_checkbox',
+ $attributes = ['class' => 'sampling_set_checkbox',
'id' => $this->get_allocatable()->type().'_' . $this->get_allocatable()->id() . '_'.$this->get_stage()->identifier() .'_samplecheckbox',
- 'title' => $checkbox_title);
+ 'title' => $checkboxtitle];
// if agreed grade given or grade published to students disable remaining sampling checkbox
$submission = $this->get_submission();
@@ -310,9 +310,9 @@ private function sampling_set_checkbox() {
$attributes['disabled'] = 'true';
}
- return \html_writer::checkbox($checkbox_name,
+ return \html_writer::checkbox($checkboxname,
1,
- $checkbox_checked,
+ $checkboxchecked,
get_string('includedinsample', 'mod_coursework'),
$attributes);
}
@@ -321,17 +321,17 @@ private function sampling_set_checkbox() {
* @return string
*/
private function sampling_hidden_checkbox() {
- $checkbox_name =
+ $checkboxname =
'allocatables[' . $this->get_allocatable()->id . '][' . $this->get_stage()->identifier() . '][in_set]';
- $checkbox_title = 'Included in sample';
+ $checkboxtitle = 'Included in sample';
- return \html_writer::checkbox($checkbox_name,
+ return \html_writer::checkbox($checkboxname,
1,
1,
'',
- array('class' => 'sampling_set_checkbox',
+ ['class' => 'sampling_set_checkbox',
'id' => $this->get_allocatable()->type().'_' . $this->get_allocatable()->id() . '_'.$this->get_stage()->identifier() .'_samplecheckbox',
- 'title' => $checkbox_title, 'hidden' => true));
+ 'title' => $checkboxtitle, 'hidden' => true]);
}
/**
@@ -344,10 +344,10 @@ private function has_automatic_sampling() {
global $DB;
- $params = array('courseworkid' => $this->coursework->id(),
+ $params = ['courseworkid' => $this->coursework->id(),
'allocatableid' => $this->get_allocatable()->id(),
'stage_identifier' => $this->get_stage()->identifier(),
- 'selectiontype' => 'automatic');
+ 'selectiontype' => 'automatic'];
return $DB->record_exists('coursework_sample_set_mbrs', $params);
}
@@ -357,25 +357,25 @@ private function has_automatic_sampling() {
*/
private function pinned_checkbox() {
- $checkbox_name =
+ $checkboxname =
'allocatables[' . $this->get_allocatable()->id . '][' . $this->get_stage()->identifier() . '][pinned]';
- $checkbox_checked = 0;
+ $checkboxchecked = 0;
if ($this->get_stage()->has_allocation($this->get_allocatable())) {
if ($this->get_stage()->get_allocation($this->get_allocatable())->is_pinned()) {
- $checkbox_checked = 1;
+ $checkboxchecked = 1;
}
}
- $checkbox_checked = $this->checkbox_checked_in_session($checkbox_name, $checkbox_checked);
+ $checkboxchecked = $this->checkbox_checked_in_session($checkboxname, $checkboxchecked);
$stage = substr($this->get_stage()->identifier(), -1);
- $checkbox_title = 'Pinned (auto allocations will not alter this)';
- return \html_writer::checkbox($checkbox_name,
+ $checkboxtitle = 'Pinned (auto allocations will not alter this)';
+ return \html_writer::checkbox($checkboxname,
1,
- $checkbox_checked,
+ $checkboxchecked,
'',
- array('class' => "pinned pin_$stage",
- 'title' => $checkbox_title));
+ ['class' => "pinned pin_$stage",
+ 'title' => $checkboxtitle]);
}
private function checkbox_checked_in_session($checkboxname, $checkboxstate) {
@@ -414,7 +414,7 @@ private function stage_does_not_use_allocation() {
* @throws \coding_exception
*/
private function get_included_in_sample_label() {
- return \html_writer::label(get_string('includedinsample', 'mod_coursework'), null, true, array('class' => 'included_in_sample'));
+ return \html_writer::label(get_string('includedinsample', 'mod_coursework'), null, true, ['class' => 'included_in_sample']);
}
/**
@@ -422,7 +422,7 @@ private function get_included_in_sample_label() {
* @throws \coding_exception
*/
private function get_automatically_in_sample_label() {
- return \html_writer::label(get_string('automaticallyinsample', 'mod_coursework'), null, true, array('class' => 'included_in_sample'));
+ return \html_writer::label(get_string('automaticallyinsample', 'mod_coursework'), null, true, ['class' => 'included_in_sample']);
}
/**
@@ -437,15 +437,15 @@ private function has_final_feedback() {
[$this->allocatable->id(), $this->allocatable->type()]
);
if ($submission) {
- $feedbacks = isset(feedback::$pool[$this->coursework->id]['submissionid'][$submission->id]) ?
+ $feedbacks = isset(feedback::$pool[$this->coursework->id]['submissionid'][$submission->id]) ?
feedback::$pool[$this->coursework->id]['submissionid'][$submission->id] : [];
- foreach ($feedbacks as $feedback) {
- if ($feedback->stage_identifier == 'final_agreed_1') {
- return true;
+ foreach ($feedbacks as $feedback) {
+ if ($feedback->stage_identifier == 'final_agreed_1') {
+ return true;
+ }
}
}
- }
return false;
}
diff --git a/classes/allocation/table/cell/processor.php b/classes/allocation/table/cell/processor.php
index f009d81a..73a35b0d 100644
--- a/classes/allocation/table/cell/processor.php
+++ b/classes/allocation/table/cell/processor.php
@@ -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 = []) {
+ public function __construct($coursework, $allocatable, $stage, $dataarray = []) {
$this->coursework = $coursework;
$this->allocatable = $allocatable;
$this->stage = $stage;
@@ -65,16 +65,16 @@ public function __construct($coursework, $allocatable, $stage, $data_array = []
/**
* @param data $cell_data
*/
- public function process($cell_data) {
+ public function process($celldata) {
if ($this->get_stage()->uses_sampling()) {
- $this->process_sampling_membership($cell_data);
+ $this->process_sampling_membership($celldata);
} else if ($this->get_stage()->has_allocation($this->get_allocatable())) {
- $this->process_pin($cell_data);
+ $this->process_pin($celldata);
}
- if ($cell_data->has_assessor() && $this->get_stage()->allocatable_is_in_sample($this->get_allocatable())) {
- $this->save_assessor_allocation($cell_data);
+ if ($celldata->has_assessor() && $this->get_stage()->allocatable_is_in_sample($this->get_allocatable())) {
+ $this->save_assessor_allocation($celldata);
}
}
@@ -153,10 +153,10 @@ private function get_stage() {
/**
* @param data $cell_data
*/
- private function process_pin($cell_data) {
+ private function process_pin($celldata) {
$allocation = $this->get_allocation();
- if ($cell_data->is_pinned()) {
+ if ($celldata->is_pinned()) {
$allocation->pin();
} else {
$allocation->unpin();
@@ -173,10 +173,10 @@ private function has_automatic_sampling() {
global $DB;
- $params = array('courseworkid' => $this->coursework->id(),
+ $params = ['courseworkid' => $this->coursework->id(),
'allocatableid' => $this->get_allocatable()->id(),
'stage_identifier' => $this->get_stage()->identifier(),
- 'selectiontype' => 'automatic');
+ 'selectiontype' => 'automatic'];
return $DB->record_exists('coursework_sample_set_mbrs', $params);
}
diff --git a/classes/allocation/table/processor.php b/classes/allocation/table/processor.php
index 7b6c5f85..e47d16ce 100644
--- a/classes/allocation/table/processor.php
+++ b/classes/allocation/table/processor.php
@@ -52,20 +52,20 @@ public function __construct($coursework) {
/**
* @param array $table_data
*/
- public function process_data($table_data = []) {
- $clean_data = $this->clean_data($table_data);
+ public function process_data($tabledata = []) {
+ $cleandata = $this->clean_data($tabledata);
$allocatables = $this->coursework->get_allocatables();
foreach ($allocatables as $allocatable) {
- if (array_key_exists($allocatable->id(), $clean_data)) {
- $row_data = $clean_data[$allocatable->id()];
+ if (array_key_exists($allocatable->id(), $cleandata)) {
+ $rowdata = $cleandata[$allocatable->id()];
} else {
- $row_data = [];
+ $rowdata = [];
}
$allocatable = $this->get_allocatable_from_id($allocatable->id());
- $row_object = $this->get_row($allocatable);
- $row_object->process($row_data);
+ $rowobject = $this->get_row($allocatable);
+ $rowobject->process($rowdata);
}
}
@@ -84,53 +84,53 @@ private function get_row($allocatable) {
* @param array $raw_data
* @return array
*/
- private function clean_data($raw_data) {
+ private function clean_data($rawdata) {
// Data looks like this:
-// $example_data = array(
-// 4543 => array( // Student id
-// 'assessor_1' => array(
-// 'allocation_id' => 43,
-// 'assessor_id' => 232,
-// ),
-// 'moderator_1' => array(
-// 'allocation_id' => 46,
-// 'assessor_id' => 235,
-// 'in_set' => 1,
-// )
-// )
-// );
-
- $clean_data = [];
- foreach ($raw_data as $allocatable_id => $datarrays) {
-
- if (!$this->allocatable_id_is_valid($allocatable_id)) { // Should be the id of a student.
+ // $example_data = array(
+ // 4543 => array( // Student id
+ // 'assessor_1' => array(
+ // 'allocation_id' => 43,
+ // 'assessor_id' => 232,
+ // ),
+ // 'moderator_1' => array(
+ // 'allocation_id' => 46,
+ // 'assessor_id' => 235,
+ // 'in_set' => 1,
+ // )
+ // )
+ // );
+
+ $cleandata = [];
+ foreach ($rawdata as $allocatableid => $datarrays) {
+
+ if (!$this->allocatable_id_is_valid($allocatableid)) { // Should be the id of a student.
continue;
}
- $clean_data[$allocatable_id] = [];
+ $cleandata[$allocatableid] = [];
foreach ($this->coursework->marking_stages() as $stage) {
if (array_key_exists($stage->identifier(), $datarrays)) {
- $stage_data = $datarrays[$stage->identifier()];
- $clean_data[$allocatable_id][$stage->identifier()] = $stage_data;
+ $stagedata = $datarrays[$stage->identifier()];
+ $cleandata[$allocatableid][$stage->identifier()] = $stagedata;
}
}
- /* if (array_key_exists('moderator', $datarrays)) {
+ /* if (array_key_exists('moderator', $datarrays)) {
$moderator_data = $datarrays['moderator'];
$clean_data[$allocatable_id]['moderator'] = $moderator_data;
}*/
}
- return $clean_data;
+ return $cleandata;
}
/**
* @param int $student_id
* @return bool
*/
- private function allocatable_id_is_valid($student_id) {
- $allocatable = $this->get_allocatable_from_id($student_id);
+ private function allocatable_id_is_valid($studentid) {
+ $allocatable = $this->get_allocatable_from_id($studentid);
return $allocatable && $allocatable->is_valid_for_course($this->coursework->get_course());
}
@@ -138,11 +138,11 @@ private function allocatable_id_is_valid($student_id) {
* @param int $allocatable_id
* @return allocatable
*/
- private function get_allocatable_from_id($allocatable_id) {
+ private function get_allocatable_from_id($allocatableid) {
if ($this->coursework->is_configured_to_have_group_submissions()) {
- return group::find($allocatable_id);
+ return group::find($allocatableid);
} else {
- return user::find($allocatable_id);
+ return user::find($allocatableid);
}
}
}
diff --git a/classes/allocation/table/row/builder.php b/classes/allocation/table/row/builder.php
index 0fa49e30..284ddfcc 100644
--- a/classes/allocation/table/row/builder.php
+++ b/classes/allocation/table/row/builder.php
@@ -54,8 +54,8 @@ class builder implements user_row {
* @param table_builder $allocation_table
* @param allocatable $allocatable
*/
- public function __construct($allocation_table, $allocatable) {
- $this->allocationtable = $allocation_table;
+ public function __construct($allocationtable, $allocatable) {
+ $this->allocationtable = $allocationtable;
$this->allocatable = $allocatable;
}
diff --git a/classes/allocation/upload.php b/classes/allocation/upload.php
index 3e73df61..04cff697 100644
--- a/classes/allocation/upload.php
+++ b/classes/allocation/upload.php
@@ -47,7 +47,7 @@ public function __construct($coursework) {
public function validate_csv($content, $encoding, $delimeter) {
global $CFG, $DB;
- $assessor_identifier = $CFG->coursework_allocation_identifier;
+ $assessoridentifier = $CFG->coursework_allocation_identifier;
$iid = \csv_import_reader::get_new_iid('courseworkallocationsdata');
$csvreader = new \csv_import_reader($iid, 'courseworkallocationsdata');
@@ -81,40 +81,48 @@ public function validate_csv($content, $encoding, $delimeter) {
$assessors = array_keys($assessors); // keep only assessors' ids
$allocatablesinfile = [];
- $csv_cells = array('allocatable');
+ $csvcells = ['allocatable'];
$stages = $this->coursework->get_max_markers();
for ($i = 1; $i <= $stages; $i++) {
- $csv_cells[] = 'assessor_'.$i;
+ $csvcells[] = 'assessor_'.$i;
}
while ($line = $csvreader->next()) {
- $cells = $csv_cells;
+ $cells = $csvcells;
$assessorsinfile = [];
- if (count($line) != count($csv_cells)) {$errors = get_string('incorrectfileformat', 'coursework'); break;}
+ if (count($line) != count($csvcells)) {
+ $errors = get_string('incorrectfileformat', 'coursework'); break;
+ }
foreach ($line as $keynum => $value) {
// validate allocatable (user or group)
if ($cells[$keynum] == 'allocatable') {
// check if allocatable exists in the file
- if (empty($value)) {$errors[$s] = get_string($allocatabletype .'namemissing', 'coursework'); break;}
+ if (empty($value)) {
+ $errors[$s] = get_string($allocatabletype .'namemissing', 'coursework'); break;
+ }
if ($allocatabletype == 'user') {
// get user id
- $suballocatable = $DB->get_record('user', array($assessor_identifier => $value));
+ $suballocatable = $DB->get_record('user', [$assessoridentifier => $value]);
$allocatable = ($suballocatable) ? \mod_coursework\models\user::find($suballocatable->id) : '';
} else {
// get group id
- $suballocatable = $DB->get_record('groups', array('courseid' => $this->coursework->course,
- 'name' => $value));
+ $suballocatable = $DB->get_record('groups', ['courseid' => $this->coursework->course,
+ 'name' => $value]);
$allocatable = ($suballocatable) ? \mod_coursework\models\group::find($suballocatable->id) : '';
}
// check if allocatable exists in this coursework
- if (!$allocatable || !in_array($allocatable->id, $allocatables)) {$errors[$s] = get_string($allocatabletype .'notincoursework', 'coursework'); break;}
+ if (!$allocatable || !in_array($allocatable->id, $allocatables)) {
+ $errors[$s] = get_string($allocatabletype .'notincoursework', 'coursework'); break;
+ }
// duplicate user or group
- if ($allocatable && in_array($allocatable->id, $allocatablesinfile)) {$errors[$s] = get_string('duplicate'. $allocatabletype, 'coursework'); break;}
+ if ($allocatable && in_array($allocatable->id, $allocatablesinfile)) {
+ $errors[$s] = get_string('duplicate'. $allocatabletype, 'coursework'); break;
+ }
$allocatablesinfile[] = $allocatable->id;
}
@@ -122,11 +130,15 @@ public function validate_csv($content, $encoding, $delimeter) {
// in initial stage
if (substr($cells[$keynum], 0, 8) == 'assessor') {
// skip empty assessors fields
- if (empty($value)) { continue;}
+ if (empty($value)) {
+ continue;
+ }
- $assessor = $DB->get_record('user', array($assessor_identifier => $value));
+ $assessor = $DB->get_record('user', [$assessoridentifier => $value]);
- if (!$assessor ||!in_array($assessor->id, $assessors)) {$errors[$s] = get_string('assessornotincoursework', 'coursework', $keynum ); continue;}
+ if (!$assessor ||!in_array($assessor->id, $assessors)) {
+ $errors[$s] = get_string('assessornotincoursework', 'coursework', $keynum ); continue;
+ }
// check if current assessor is not already allocated for this allocatable in different stage
// or is not already in the file in previous stage
@@ -159,7 +171,7 @@ public function process_csv($content, $encoding, $delimiter, $processingresults)
global $CFG, $DB, $PAGE;
- $assessor_identifier = $CFG->coursework_allocation_identifier;
+ $assessoridentifier = $CFG->coursework_allocation_identifier;
$iid = \csv_import_reader::get_new_iid('courseworkallocationsdata');
$csvreader = new \csv_import_reader($iid, 'courseworkallocationsdata');
@@ -184,10 +196,10 @@ public function process_csv($content, $encoding, $delimiter, $processingresults)
$csvreader->init();
$s = 0;
- $csv_cells = array('allocatable');
+ $csvcells = ['allocatable'];
$stages = $this->coursework->get_max_markers();
for ($i = 1; $i <= $stages; $i++) {
- $csv_cells[] = 'assessor_'.$i;
+ $csvcells[] = 'assessor_'.$i;
}
while ($line = $csvreader->next()) {
@@ -198,9 +210,11 @@ public function process_csv($content, $encoding, $delimiter, $processingresults)
continue;
}
- $cells = $csv_cells;
+ $cells = $csvcells;
- if (count($line) != count($csv_cells)) {$errors = get_string('incorrectfileformat', 'coursework'); break;}
+ if (count($line) != count($csvcells)) {
+ $errors = get_string('incorrectfileformat', 'coursework'); break;
+ }
foreach ($line as $keynum => $value) {
@@ -211,23 +225,23 @@ public function process_csv($content, $encoding, $delimiter, $processingresults)
if ($cells[$keynum] == 'allocatable') {
if ($allocatabletype == 'user') {
// get user id
- $suballocatable = $DB->get_record('user', array($assessor_identifier => $value));
+ $suballocatable = $DB->get_record('user', [$assessoridentifier => $value]);
$allocatable = ($suballocatable) ? \mod_coursework\models\user::find($suballocatable->id) : '';
} else {
// get group id
- $suballocatable = $DB->get_record('groups', array('courseid' => $this->coursework->course,
- 'name' => $value));
+ $suballocatable = $DB->get_record('groups', ['courseid' => $this->coursework->course,
+ 'name' => $value]);
$allocatable = ($suballocatable) ? \mod_coursework\models\group::find($suballocatable->id) : '';
}
}
if (substr($cells[$keynum], 0, 8) == 'assessor' && !(empty($value))) {
- $assessor = $DB->get_record('user', array($assessor_identifier => $value));
+ $assessor = $DB->get_record('user', [$assessoridentifier => $value]);
- $params = array('courseworkid' => $this->coursework->id,
+ $params = ['courseworkid' => $this->coursework->id,
'allocatableid' => $allocatable->id,
'allocatabletype' => $allocatabletype,
- 'stage_identifier' => $cells[$keynum]);
+ 'stage_identifier' => $cells[$keynum]];
$allocation = $DB->get_record('coursework_allocation_pairs', $params);
@@ -237,9 +251,9 @@ public function process_csv($content, $encoding, $delimiter, $processingresults)
} else {
// update allocation if submission was not marked yet
- $subdbrecord = $DB->get_record('coursework_submissions', array('courseworkid' => $this->coursework->id,
+ $subdbrecord = $DB->get_record('coursework_submissions', ['courseworkid' => $this->coursework->id,
'allocatabletype' => $allocatabletype,
- 'allocatableid' => $allocatable->id));
+ 'allocatableid' => $allocatable->id]);
$submission = \mod_coursework\models\submission::find($subdbrecord);
if (!$submission || !$submission->get_assessor_feedback_by_stage($cells[$keynum])) {
@@ -266,19 +280,19 @@ public function process_csv($content, $encoding, $delimiter, $processingresults)
* @param $allocatabletype
* @return bool|int
*/
- public function add_allocation($assessorid, $stage_identifier, $allocatable) {
+ public function add_allocation($assessorid, $stageidentifier, $allocatable) {
global $DB;
- $add_allocation = new \stdClass();
- $add_allocation->id = '';
- $add_allocation->courseworkid = $this->coursework->id;
- $add_allocation->assessorid = $assessorid;
- $add_allocation->manual = 1;
- $add_allocation->stage_identifier = $stage_identifier;
- $add_allocation->allocatableid = $allocatable->id();
- $add_allocation->allocatabletype = $allocatable->type();
+ $addallocation = new \stdClass();
+ $addallocation->id = '';
+ $addallocation->courseworkid = $this->coursework->id;
+ $addallocation->assessorid = $assessorid;
+ $addallocation->manual = 1;
+ $addallocation->stage_identifier = $stageidentifier;
+ $addallocation->allocatableid = $allocatable->id();
+ $addallocation->allocatabletype = $allocatable->type();
- $allocationid = $DB->insert_record('coursework_allocation_pairs', $add_allocation, true);
+ $allocationid = $DB->insert_record('coursework_allocation_pairs', $addallocation, true);
return $allocationid;
@@ -294,12 +308,12 @@ public function add_allocation($assessorid, $stage_identifier, $allocatable) {
public function update_allocation($allocationid, $assessorid) {
global $DB;
- $update_allocation = new \stdClass();
- $update_allocation->id = $allocationid;
- $update_allocation->manual = 1;
- $update_allocation->assessorid = $assessorid;
+ $updateallocation = new \stdClass();
+ $updateallocation->id = $allocationid;
+ $updateallocation->manual = 1;
+ $updateallocation->assessorid = $assessorid;
- $update = $DB->update_record('coursework_allocation_pairs', $update_allocation);
+ $update = $DB->update_record('coursework_allocation_pairs', $updateallocation);
return $update;
}
diff --git a/classes/assessor_feedback_row.php b/classes/assessor_feedback_row.php
index d24932d6..f45a965e 100644
--- a/classes/assessor_feedback_row.php
+++ b/classes/assessor_feedback_row.php
@@ -128,7 +128,7 @@ public function get_graded_by() {
* @return string
*/
public function get_graders_name() {
- return $this->get_graded_by()->profile_link();
+ return $this->get_graded_by()->profile_link();
}
/**
@@ -194,11 +194,11 @@ public function get_submission() {
if (isset($this->submission)) {
return $this->submission;
}
- $params = array(
+ $params = [
'courseworkid' => $this->get_coursework()->id,
'allocatableid' => $this->get_allocatable()->id(),
'allocatabletype' => $this->get_allocatable()->type(),
- );
+ ];
$this->submission = submission::find($params);
return $this->submission;
}
diff --git a/classes/assessor_feedback_table.php b/classes/assessor_feedback_table.php
index 2676e3f3..936ed26f 100644
--- a/classes/assessor_feedback_table.php
+++ b/classes/assessor_feedback_table.php
@@ -80,8 +80,8 @@ public function get_renderable_feedback_rows() {
$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;
+ $renderablerow = new assessor_feedback_row($stage, $this->get_allocatable(), $this->coursework);
+ $feedbackobjects[] = $renderablerow;
}
return $feedbackobjects;
diff --git a/classes/auto_grader/average_grade.php b/classes/auto_grader/average_grade.php
index 149f166b..7645a998 100644
--- a/classes/auto_grader/average_grade.php
+++ b/classes/auto_grader/average_grade.php
@@ -78,9 +78,9 @@ public function create_auto_grade_if_rules_match() {
$this->create_final_feedback();
} else {
// update only if AgreedGrade has been automatic
- $agreed_feedback = $this->get_allocatable()->get_agreed_feedback($this->get_coursework());
- if ($agreed_feedback->timecreated == $agreed_feedback->timemodified || $agreed_feedback->lasteditedbyuser == 0) {
- $this->update_final_feedback($agreed_feedback);
+ $agreedfeedback = $this->get_allocatable()->get_agreed_feedback($this->get_coursework());
+ if ($agreedfeedback->timecreated == $agreedfeedback->timemodified || $agreedfeedback->lasteditedbyuser == 0) {
+ $this->update_final_feedback($agreedfeedback);
}
}
@@ -132,12 +132,12 @@ private function get_allocatable() {
*
*/
private function create_final_feedback() {
- feedback::create(array(
+ feedback::create([
'stage_identifier' => 'final_agreed_1',
'submissionid' => $this->get_allocatable()->get_submission($this->get_coursework())->id(),
- 'grade' => $this->automatic_grade()
+ 'grade' => $this->automatic_grade(),
- ));
+ ]);
}
/**
@@ -146,12 +146,12 @@ private function create_final_feedback() {
private function update_final_feedback($feedback) {
global $DB;
- $updated_feedback = new \stdClass();
- $updated_feedback->id = $feedback->id;
- $updated_feedback->grade = $this->automatic_grade();
- $updated_feedback->lasteditedbyuser = 0;
+ $updatedfeedback = new \stdClass();
+ $updatedfeedback->id = $feedback->id;
+ $updatedfeedback->grade = $this->automatic_grade();
+ $updatedfeedback->lasteditedbyuser = 0;
- $DB->update_record('coursework_feedbacks', $updated_feedback);
+ $DB->update_record('coursework_feedbacks', $updatedfeedback);
}
@@ -159,11 +159,11 @@ private function update_final_feedback($feedback) {
* @return array
*/
private function grades_as_percentages() {
- $initial_feedbacks = $this->get_allocatable()->get_initial_feedbacks($this->get_coursework());
+ $initialfeedbacks = $this->get_allocatable()->get_initial_feedbacks($this->get_coursework());
$grades = array_map(function ($feedback) {
return ($feedback->get_grade() / $this->get_coursework()->get_max_grade()) * 100;
},
- $initial_feedbacks);
+ $initialfeedbacks);
return $grades;
}
}
diff --git a/classes/auto_grader/percentage_distance.php b/classes/auto_grader/percentage_distance.php
index 92575b51..8ef2abdf 100644
--- a/classes/auto_grader/percentage_distance.php
+++ b/classes/auto_grader/percentage_distance.php
@@ -75,14 +75,14 @@ public function create_auto_grade_if_rules_match() {
return;
}
- if ($this->grades_are_close_enough() ) {
+ if ($this->grades_are_close_enough()) {
if (!$this->get_allocatable()->has_agreed_feedback($this->get_coursework())) {
$this->create_final_feedback();
} else {
// update only if AgreedGrade has been automatic
- $agreed_feedback = $this->get_allocatable()->get_agreed_feedback($this->get_coursework());
- if ($agreed_feedback->timecreated == $agreed_feedback->timemodified || $agreed_feedback->lasteditedbyuser == 0) {
- $this->update_final_feedback($agreed_feedback);
+ $agreedfeedback = $this->get_allocatable()->get_agreed_feedback($this->get_coursework());
+ if ($agreedfeedback->timecreated == $agreedfeedback->timemodified || $agreedfeedback->lasteditedbyuser == 0) {
+ $this->update_final_feedback($agreedfeedback);
}
}
@@ -113,10 +113,10 @@ private function automatic_grade() {
private function grades_are_close_enough() {
// test if the rules apply
$grades = $this->grades_as_percentages();
- $max_grade = max($grades);
- $min_grade = min($grades);
+ $maxgrade = max($grades);
+ $mingrade = min($grades);
- return ($max_grade - $min_grade) <= $this->percentage;
+ return ($maxgrade - $mingrade) <= $this->percentage;
}
/**
@@ -130,12 +130,12 @@ private function get_allocatable() {
*
*/
private function create_final_feedback() {
- feedback::create(array(
+ feedback::create([
'stage_identifier' => 'final_agreed_1',
'submissionid' => $this->get_allocatable()->get_submission($this->get_coursework())->id(),
- 'grade' => $this->automatic_grade()
+ 'grade' => $this->automatic_grade(),
- ));
+ ]);
}
/**
@@ -144,12 +144,12 @@ private function create_final_feedback() {
private function update_final_feedback($feedback) {
global $DB;
- $updated_feedback = new \stdClass();
- $updated_feedback->id = $feedback->id;
- $updated_feedback->grade = $this->automatic_grade();
- $updated_feedback->lasteditedbyuser = 0;
+ $updatedfeedback = new \stdClass();
+ $updatedfeedback->id = $feedback->id;
+ $updatedfeedback->grade = $this->automatic_grade();
+ $updatedfeedback->lasteditedbyuser = 0;
- $DB->update_record('coursework_feedbacks', $updated_feedback);
+ $DB->update_record('coursework_feedbacks', $updatedfeedback);
}
@@ -157,11 +157,11 @@ private function update_final_feedback($feedback) {
* @return array
*/
private function grades_as_percentages() {
- $initial_feedbacks = $this->get_allocatable()->get_initial_feedbacks($this->get_coursework());
+ $initialfeedbacks = $this->get_allocatable()->get_initial_feedbacks($this->get_coursework());
$grades = array_map(function ($feedback) {
return ($feedback->get_grade() / $this->get_coursework()->get_max_grade()) * 100;
},
- $initial_feedbacks);
+ $initialfeedbacks);
return $grades;
}
}
diff --git a/classes/calendar.php b/classes/calendar.php
index 6d52af5c..d2489124 100644
--- a/classes/calendar.php
+++ b/classes/calendar.php
@@ -56,15 +56,15 @@ public static function coursework_event(object $coursework, string $eventtype, ?
// to support module events with file areas.
$intro = strip_pluginfile_content($intro);
if ($cm->showdescription) {
- $event->description = array(
+ $event->description = [
'text' => $intro,
- 'format' => $coursework->introformat
- );
+ 'format' => $coursework->introformat,
+ ];
} else {
- $event->description = array(
+ $event->description = [
'text' => '',
- 'format' => $coursework->introformat
- );
+ 'format' => $coursework->introformat,
+ ];
}
$event->courseid = $coursework->course;
@@ -92,7 +92,7 @@ public static function coursework_event(object $coursework, string $eventtype, ?
public static function remove_event($coursework, $eventtype = '') {
global $DB;
- $params = array('modulename' => 'coursework', 'instance' => $coursework->id);
+ $params = ['modulename' => 'coursework', 'instance' => $coursework->id];
if ($eventtype) {
$params['eventtype'] = $eventtype;
diff --git a/classes/controllers/controller_base.php b/classes/controllers/controller_base.php
index a5c4f745..2eb8e0eb 100644
--- a/classes/controllers/controller_base.php
+++ b/classes/controllers/controller_base.php
@@ -104,14 +104,14 @@ protected function prepare_environment() {
// if there's an id, lets's assume it's an edit or update and we should just get the main model
if (!empty($this->params['id'])) {
- $model_class = $this->model_class();
- $model_name = $this->model_name();
- $this->$model_name = $model_class::find($this->params['id']);
- $this->coursework = $this->$model_name->get_coursework();
+ $modelclass = $this->model_class();
+ $modelname = $this->model_name();
+ $this->$modelname = $modelclass::find($this->params['id']);
+ $this->coursework = $this->$modelname->get_coursework();
}
if (!empty($this->params['courseworkid'])) {
- $coursework = $DB->get_record('coursework', array('id' => $this->params['courseworkid']), '*', MUST_EXIST);
+ $coursework = $DB->get_record('coursework', ['id' => $this->params['courseworkid']], '*', MUST_EXIST);
$this->coursework = coursework::find($coursework);
$this->coursemodule = get_coursemodule_from_instance('coursework', $this->coursework->id);
@@ -131,7 +131,7 @@ protected function prepare_environment() {
if (empty($this->course)) {
if (!empty($this->params['courseid'])) {
- $this->course = $DB->get_record('course', array('id' => $this->params['courseid']), '*', MUST_EXIST);
+ $this->course = $DB->get_record('course', ['id' => $this->params['courseid']], '*', MUST_EXIST);
}
if (!empty($this->coursework)) {
@@ -168,14 +168,14 @@ protected function prepare_environment() {
* @param $arguments
* @throws coding_exception
*/
- public function __call($method_name, $arguments) {
+ public function __call($methodname, $arguments) {
- if (method_exists($this, $method_name)) {
+ if (method_exists($this, $methodname)) {
$this->prepare_environment();
- call_user_func(array($this,
- $method_name));
+ call_user_func([$this,
+ $methodname]);
} else {
- throw new coding_exception('No page defined in the controller called "'.$method_name.'"');
+ throw new coding_exception('No page defined in the controller called "'.$methodname.'"');
}
}
@@ -193,9 +193,9 @@ protected function get_context() {
* @param $items
* @return string
*/
- protected function get_path($path_name, $items) {
+ protected function get_path($pathname, $items) {
- return call_user_func_array(array($this->get_router(), 'get_path'), func_get_args());
+ return call_user_func_array([$this->get_router(), 'get_path'], func_get_args());
}
@@ -228,11 +228,11 @@ protected function get_page_renderer() {
/**
* @param string $page_name
*/
- protected function render_page($page_name) {
- $renderer_class = $this->renderer_class();
- $renderer = new $renderer_class;
- $function_name = $page_name . '_page';
- $renderer->$function_name(get_object_vars($this));
+ protected function render_page($pagename) {
+ $rendererclass = $this->renderer_class();
+ $renderer = new $rendererclass;
+ $functionname = $pagename . '_page';
+ $renderer->$functionname(get_object_vars($this));
$this->page_rendered = true;
}
@@ -240,10 +240,10 @@ protected function render_page($page_name) {
* @return string
*/
public function model_name() {
- $class_name = get_class($this);
- $bits = explode('\\', $class_name);
- $controller_name = end($bits);
- return str_replace('s_controller', '', $controller_name);
+ $classname = get_class($this);
+ $bits = explode('\\', $classname);
+ $controllername = end($bits);
+ return str_replace('s_controller', '', $controllername);
}
/**
@@ -260,15 +260,15 @@ protected function cancel_button_was_pressed() {
* @return table_base
*/
protected function model_class() {
- $renderer_class_name = "\\mod_coursework\\models\\{$this->model_name()}";
- return $renderer_class_name;
+ $rendererclassname = "\\mod_coursework\\models\\{$this->model_name()}";
+ return $rendererclassname;
}
/**
* @return string
*/
protected function renderer_class() {
- $renderer_class_name = "\\mod_coursework\\renderers\\{$this->model_name()}_renderer";
- return $renderer_class_name;
+ $rendererclassname = "\\mod_coursework\\renderers\\{$this->model_name()}_renderer";
+ return $rendererclassname;
}
}
diff --git a/classes/controllers/deadline_extensions_controller.php b/classes/controllers/deadline_extensions_controller.php
index 7612db02..cf3634b0 100644
--- a/classes/controllers/deadline_extensions_controller.php
+++ b/classes/controllers/deadline_extensions_controller.php
@@ -61,9 +61,9 @@ protected function new_deadline_extension() {
$ability->require_can('new', $this->deadline_extension);
$PAGE->set_url('/mod/coursework/actions/deadline_extensions/new.php', $params);
- $create_url = $this->get_router()->get_path('create deadline extension');
+ $createurl = $this->get_router()->get_path('create deadline extension');
- $this->form = new deadline_extension_form($create_url, array('coursework' => $this->coursework));
+ $this->form = new deadline_extension_form($createurl, ['coursework' => $this->coursework]);
$this->form->set_data($this->deadline_extension);
$this->render_page('new');
@@ -73,11 +73,11 @@ protected function new_deadline_extension() {
protected function create_deadline_extension() {
global $USER;
- $create_url = $this->get_router()->get_path('create deadline extension');
- $this->form = new deadline_extension_form($create_url, array('coursework' => $this->coursework));
- $coursework_page_url = $this->get_path('coursework', array('coursework' => $this->coursework));
+ $createurl = $this->get_router()->get_path('create deadline extension');
+ $this->form = new deadline_extension_form($createurl, ['coursework' => $this->coursework]);
+ $courseworkpageurl = $this->get_path('coursework', ['coursework' => $this->coursework]);
if ($this->cancel_button_was_pressed()) {
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
/**
* @var deadline_extension $deadline_extension
@@ -92,7 +92,7 @@ protected function create_deadline_extension() {
$ability->require_can('create', $this->deadline_extension);
$this->deadline_extension->save();
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
} else {
$this->set_default_current_deadline();
$this->render_page('new');
@@ -103,22 +103,22 @@ protected function create_deadline_extension() {
protected function edit_deadline_extension() {
global $USER, $PAGE;
- $params = array(
+ $params = [
'id' => $this->params['id'],
- );
+ ];
$this->deadline_extension = deadline_extension::find($params);
$ability = new ability(user::find($USER), $this->coursework);
$ability->require_can('edit', $this->deadline_extension);
$PAGE->set_url('/mod/coursework/actions/deadline_extensions/edit.php', $params);
- $update_url = $this->get_router()->get_path('update deadline extension');
+ $updateurl = $this->get_router()->get_path('update deadline extension');
- $this->form = new deadline_extension_form($update_url, array('coursework' => $this->coursework));
- $this->deadline_extension->extra_information = array(
+ $this->form = new deadline_extension_form($updateurl, ['coursework' => $this->coursework]);
+ $this->deadline_extension->extra_information = [
'text' => $this->deadline_extension->extra_information_text,
'format' => $this->deadline_extension->extra_information_format,
- );
+ ];
$this->form->set_data($this->deadline_extension);
$this->render_page('edit');
@@ -127,11 +127,11 @@ protected function edit_deadline_extension() {
protected function update_deadline_extension() {
global $USER;
- $update_url = $this->get_router()->get_path('update deadline extension');
- $this->form = new deadline_extension_form($update_url, array('coursework' => $this->coursework));
- $coursework_page_url = $this->get_path('coursework', array('coursework' => $this->coursework));
+ $updateurl = $this->get_router()->get_path('update deadline extension');
+ $this->form = new deadline_extension_form($updateurl, ['coursework' => $this->coursework]);
+ $courseworkpageurl = $this->get_path('coursework', ['coursework' => $this->coursework]);
if ($this->cancel_button_was_pressed()) {
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
/**
* @var deadline_extension $deadline_extension
@@ -145,7 +145,7 @@ protected function update_deadline_extension() {
$values->extra_information_text = $values->extra_information['text'];
$values->extra_information_format = $values->extra_information['format'];
$this->deadline_extension->update_attributes($values);
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
} else {
$this->render_page('edit');
}
@@ -158,18 +158,18 @@ protected function update_deadline_extension() {
*/
protected function set_default_current_deadline() {
global $DB;
- $params = array(
+ $params = [
'allocatableid' => $this->params['allocatableid'],
'allocatabletype' => $this->params['allocatabletype'],
'courseworkid' => $this->params['courseworkid'],
- );
+ ];
$this->deadline_extension = deadline_extension::build($params);
// Default to current deadline
// check for personal deadline first o
if ($this->coursework->personaldeadlineenabled) {
- $personal_deadline = $DB->get_record('coursework_person_deadlines', $params);
- if ($personal_deadline) {
- $this->coursework->deadline = $personal_deadline->personal_deadline;
+ $personaldeadline = $DB->get_record('coursework_person_deadlines', $params);
+ if ($personaldeadline) {
+ $this->coursework->deadline = $personaldeadline->personal_deadline;
}
}
$this->deadline_extension->extended_deadline = $this->coursework->deadline;
@@ -179,9 +179,9 @@ protected function set_default_current_deadline() {
/**
* Begin Ajax functions
*/
- public function ajax_submit_mitigation($data_params) {
+ public function ajax_submit_mitigation($dataparams) {
global $USER, $OUTPUT;
- $extended_deadline = false;
+ $extendeddeadline = false;
$response = [];
$this->coursework = coursework::find(['id' => $this->params['courseworkid']]);
$cm = get_coursemodule_from_instance(
@@ -190,8 +190,8 @@ public function ajax_submit_mitigation($data_params) {
require_login($this->coursework->course, false, $cm);
$params = $this->set_default_current_deadline();
$ability = new ability(user::find($USER), $this->coursework);
- $errors = $this->validation($data_params);
- $data = (object) $data_params;
+ $errors = $this->validation($dataparams);
+ $data = (object) $dataparams;
if (!$errors) {
if ($data->id > 0) {
$this->deadline_extension = deadline_extension::find(['id' => $data->id]);
@@ -202,21 +202,21 @@ public function ajax_submit_mitigation($data_params) {
$this->deadline_extension = deadline_extension::build($data);
$ability->require_can('new', $this->deadline_extension);
$this->deadline_extension->save();
- $data_params['id'] = $this->deadline_extension->id;
+ $dataparams['id'] = $this->deadline_extension->id;
}
- $content = $this->table_cell_response($data_params);
+ $content = $this->table_cell_response($dataparams);
$response = [
'error' => 0,
- 'data' => $data_params,
- 'content' => $content
+ 'data' => $dataparams,
+ 'content' => $content,
];
echo json_encode($response);
} else {
$response = [
'error' => 1,
- 'messages' => $errors
+ 'messages' => $errors,
];
echo json_encode($response);
@@ -225,10 +225,10 @@ public function ajax_submit_mitigation($data_params) {
public function validation($data) {
global $CFG;
- $max_deadline = $CFG->coursework_max_extension_deadline;
+ $maxdeadline = $CFG->coursework_max_extension_deadline;
- if ($this->coursework->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()) {
- $deadline = $personal_deadline->personal_deadline;
+ if ($this->coursework->personaldeadlineenabled && $personaldeadline = $this->personal_deadline()) {
+ $deadline = $personaldeadline->personal_deadline;
} else {
$deadline = $this->coursework->deadline;
}
@@ -243,11 +243,11 @@ public function validation($data) {
public function submission_exists($data) {
global $DB;
- return $DB->record_exists('coursework_submissions', array(
+ return $DB->record_exists('coursework_submissions', [
'courseworkid' => $data['courseworkid'],
'allocatableid' => $data['allocatableid'],
- 'allocatabletype' => $data['allocatabletype']
- ));
+ 'allocatabletype' => $data['allocatabletype'],
+ ]);
}
public function personal_deadline() {
@@ -256,7 +256,7 @@ public function personal_deadline() {
$extensionid = optional_param('id', 0, PARAM_INT);
if ($extensionid != 0) {
- $ext = $DB->get_record('coursework_extensions', array('id' => $extensionid));
+ $ext = $DB->get_record('coursework_extensions', ['id' => $extensionid]);
$allocatableid = $ext->allocatableid;
$allocatabletype = $ext->allocatabletype;
$courseworkid = $ext->courseworkid;
@@ -267,19 +267,19 @@ public function personal_deadline() {
$courseworkid = required_param('courseworkid', PARAM_INT);
}
- $params = array(
+ $params = [
'allocatableid' => $allocatableid ?? 0,
'allocatabletype' => $allocatabletype ?? 0,
'courseworkid' => $courseworkid ?? 0,
- );
+ ];
- return $personal_deadline = $DB->get_record('coursework_person_deadlines', $params);
+ return $personaldeadline = $DB->get_record('coursework_person_deadlines', $params);
}
- public function ajax_edit_mitigation($data_params) {
+ public function ajax_edit_mitigation($dataparams) {
global $USER;
$response = [];
- if ($data_params['id'] > 0) {
+ if ($dataparams['id'] > 0) {
$this->coursework = coursework::find(['id' => $this->params['courseworkid']]);
$cm = get_coursemodule_from_instance(
'coursework', $this->coursework->id, 0, false, MUST_EXIST
@@ -287,54 +287,54 @@ public function ajax_edit_mitigation($data_params) {
require_login($this->coursework->course, false, $cm);
$ability = new ability(user::find($USER), $this->coursework);
- $deadline_extension = deadline_extension::find(['id' => $data_params['id']]);
- if (empty($deadline_extension)) {
+ $deadlineextension = deadline_extension::find(['id' => $dataparams['id']]);
+ if (empty($deadlineextension)) {
$response = [
'error' => 1,
'message' => 'This Deadline Extension does not exist!',
];
} else {
- $ability->require_can('edit', $deadline_extension);
- $time_content = '';
+ $ability->require_can('edit', $deadlineextension);
+ $timecontent = '';
$time = '';
- if ($this->coursework->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()) {
- $time_content = 'Personal deadline: ' . userdate($personal_deadline->personal_deadline);
- $time = date('d-m-Y H:i', $personal_deadline->personal_deadline);
+ if ($this->coursework->personaldeadlineenabled && $personaldeadline = $this->personal_deadline()) {
+ $timecontent = 'Personal deadline: ' . userdate($personaldeadline->personal_deadline);
+ $time = date('d-m-Y H:i', $personaldeadline->personal_deadline);
} else if ($this->coursework->deadline) {
// Current deadline for comparison
- $time_content = 'Default deadline: ' . userdate($this->coursework->deadline);
+ $timecontent = 'Default deadline: ' . userdate($this->coursework->deadline);
$time = date('d-m-Y H:i', $this->coursework->deadline);
}
- if (!empty($deadline_extension->extended_deadline) && $deadline_extension->extended_deadline > 0) {
- $time = date('d-m-Y H:i', $deadline_extension->extended_deadline);
+ if (!empty($deadlineextension->extended_deadline) && $deadlineextension->extended_deadline > 0) {
+ $time = date('d-m-Y H:i', $deadlineextension->extended_deadline);
}
- $deadline_extension_transform = [
- 'time_content' => $time_content,
+ $deadlineextensiontransform = [
+ 'time_content' => $timecontent,
'time' => $time,
- 'text' => $deadline_extension->extra_information_text,
- 'allocatableid' => $deadline_extension->allocatableid,
- 'allocatabletype' => $deadline_extension->allocatabletype,
- 'courseworkid' => $deadline_extension->courseworkid,
- 'id' => $deadline_extension->id,
- 'pre_defined_reason' => $deadline_extension->pre_defined_reason,
+ 'text' => $deadlineextension->extra_information_text,
+ 'allocatableid' => $deadlineextension->allocatableid,
+ 'allocatabletype' => $deadlineextension->allocatabletype,
+ 'courseworkid' => $deadlineextension->courseworkid,
+ 'id' => $deadlineextension->id,
+ 'pre_defined_reason' => $deadlineextension->pre_defined_reason,
];
$response = [
'error' => 0,
- 'data' => $deadline_extension_transform
+ 'data' => $deadlineextensiontransform,
];
}
} else {
$response = [
'error' => 1,
- 'message' => 'ID can not be lower than 1!'
+ 'message' => 'ID can not be lower than 1!',
];
}
echo json_encode($response);
}
- public function ajax_new_mitigation($data_params) {
+ public function ajax_new_mitigation($dataparams) {
global $USER, $DB;
$response = [];
$this->coursework = coursework::find(['id' => $this->params['courseworkid']]);
@@ -343,37 +343,37 @@ public function ajax_new_mitigation($data_params) {
);
require_login($this->coursework->course, false, $cm);
- $params = array(
+ $params = [
'allocatableid' => $this->params['allocatableid'],
'allocatabletype' => $this->params['allocatabletype'],
'courseworkid' => $this->params['courseworkid'],
- );
+ ];
$ability = new ability(user::find($USER), $this->coursework);
- $deadline_extension = deadline_extension::build($params);
- $ability->require_can('new', $deadline_extension);
- $time_content = '';
+ $deadlineextension = deadline_extension::build($params);
+ $ability->require_can('new', $deadlineextension);
+ $timecontent = '';
$time = '';
if ($this->coursework->deadline) {
- $personal_deadline = $DB->get_record('coursework_person_deadlines', $params);
- if ($personal_deadline) {
- $time_content = 'Personal deadline: ' . userdate($personal_deadline->personal_deadline);
+ $personaldeadline = $DB->get_record('coursework_person_deadlines', $params);
+ if ($personaldeadline) {
+ $timecontent = 'Personal deadline: ' . userdate($personaldeadline->personal_deadline);
// $this->coursework->deadline = $personal_deadline->personal_deadline;
- $time = date('d-m-Y H:i', $personal_deadline->personal_deadline);
+ $time = date('d-m-Y H:i', $personaldeadline->personal_deadline);
} else {
- $time_content = 'Default deadline: ' . userdate($this->coursework->deadline);
+ $timecontent = 'Default deadline: ' . userdate($this->coursework->deadline);
$time = date('d-m-Y H:i', $this->coursework->deadline);
}
}
- $deadline_extension_transform = [
- 'time_content' => $time_content,
+ $deadlineextensiontransform = [
+ 'time_content' => $timecontent,
'time' => $time,
];
$response = [
'error' => 0,
- 'data' => $deadline_extension_transform
+ 'data' => $deadlineextensiontransform,
];
echo json_encode($response);
@@ -388,18 +388,18 @@ public function ajax_new_mitigation($data_params) {
*
*/
- public function table_cell_response($data_params) {
- $participant = ($data_params['allocatabletype'] && $data_params['allocatabletype'] == 'group') ? group::find($data_params['allocatableid']) : user::find($data_params['allocatableid']);
+ public function table_cell_response($dataparams) {
+ $participant = ($dataparams['allocatabletype'] && $dataparams['allocatabletype'] == 'group') ? group::find($dataparams['allocatableid']) : user::find($dataparams['allocatableid']);
$coursework = ($this->coursework instanceof coursework_groups_decorator) ? $this->coursework->wrapped_object() : $this->coursework;
if ($this->coursework->has_multiple_markers()) {
- $row_object = new \mod_coursework\grading_table_row_multi($coursework, $participant);
+ $rowobject = new \mod_coursework\grading_table_row_multi($coursework, $participant);
} else {
- $row_object = new \mod_coursework\grading_table_row_single($coursework, $participant);
+ $rowobject = new \mod_coursework\grading_table_row_single($coursework, $participant);
}
- $time_submitted_cell = new \mod_coursework\render_helpers\grading_report\cells\time_submitted_cell(array('coursework' => $this->coursework));
+ $timesubmittedcell = new \mod_coursework\render_helpers\grading_report\cells\time_submitted_cell(['coursework' => $this->coursework]);
- $content = $time_submitted_cell->prepare_content_cell($row_object);
+ $content = $timesubmittedcell->prepare_content_cell($rowobject);
return $content;
}
diff --git a/classes/controllers/grading_controller.php b/classes/controllers/grading_controller.php
index 6548460e..481e4c39 100644
--- a/classes/controllers/grading_controller.php
+++ b/classes/controllers/grading_controller.php
@@ -33,21 +33,21 @@ class grading_controller extends controller_base {
public function get_remain_rows_grading_table($options) {
global $DB, $PAGE;
- $coursework_record = $DB->get_record('coursework', array('id' => $options['courseworkid']), '*', MUST_EXIST);
+ $courseworkrecord = $DB->get_record('coursework', ['id' => $options['courseworkid']], '*', MUST_EXIST);
//$coursework = mod_coursework\models\coursework::find($coursework_record);
- $coursework = coursework::find($coursework_record, false);
+ $coursework = coursework::find($courseworkrecord, false);
$coursework->coursemodule = get_coursemodule_from_instance('coursework', $coursework->id, $coursework->course, false, MUST_EXIST);
require_login($coursework->course, false, $coursework->coursemodule);
- $grading_report = $coursework->renderable_grading_report_factory($options);
+ $gradingreport = $coursework->renderable_grading_report_factory($options);
- $tablerows = $grading_report->get_table_rows_for_page();
- $cell_helpers = $grading_report->get_cells_helpers();
- $sub_row_helper = $grading_report->get_sub_row_helper();
+ $tablerows = $gradingreport->get_table_rows_for_page();
+ $cellhelpers = $gradingreport->get_cells_helpers();
+ $subrowhelper = $gradingreport->get_sub_row_helper();
- $grading_report_renderer = $PAGE->get_renderer('mod_coursework', 'grading_report');
- $table_html = $grading_report_renderer->make_rows($tablerows, $cell_helpers, $sub_row_helper, $coursework->has_multiple_markers());
- return $table_html;
+ $gradingreportrenderer = $PAGE->get_renderer('mod_coursework', 'grading_report');
+ $tablehtml = $gradingreportrenderer->make_rows($tablerows, $cellhelpers, $subrowhelper, $coursework->has_multiple_markers());
+ return $tablehtml;
}
}
diff --git a/classes/controllers/moderations_controller.php b/classes/controllers/moderations_controller.php
index d80c822c..da151a93 100644
--- a/classes/controllers/moderations_controller.php
+++ b/classes/controllers/moderations_controller.php
@@ -62,27 +62,27 @@ protected function new_moderation() {
global $PAGE, $USER;
- $moderator_agreement = new moderation();
- $moderator_agreement->submissionid = $this->params['submissionid'];
- $moderator_agreement->moderatorid = $this->params['moderatorid'];
- $moderator_agreement->stage_identifier = $this->params['stage_identifier'];
- $moderator_agreement->courseworkid = $this->params['courseworkid'];
- $moderator_agreement->feedbackid = $this->params['feedbackid'];
+ $moderatoragreement = new moderation();
+ $moderatoragreement->submissionid = $this->params['submissionid'];
+ $moderatoragreement->moderatorid = $this->params['moderatorid'];
+ $moderatoragreement->stage_identifier = $this->params['stage_identifier'];
+ $moderatoragreement->courseworkid = $this->params['courseworkid'];
+ $moderatoragreement->feedbackid = $this->params['feedbackid'];
$ability = new ability(user::find($USER), $this->coursework);
- $ability->require_can('new', $moderator_agreement);
+ $ability->require_can('new', $moderatoragreement);
$this->check_stage_permissions($this->params['stage_identifier']);
$urlparams = [];
- $urlparams['submissionid'] = $moderator_agreement->submissionid;
- $urlparams['moderatorid'] = $moderator_agreement->moderatorid;
- $urlparams['stage_identifier'] = $moderator_agreement->stage_identifier;
- $urlparams['feedbackid'] = $moderator_agreement->feedbackid;
+ $urlparams['submissionid'] = $moderatoragreement->submissionid;
+ $urlparams['moderatorid'] = $moderatoragreement->moderatorid;
+ $urlparams['stage_identifier'] = $moderatoragreement->stage_identifier;
+ $urlparams['feedbackid'] = $moderatoragreement->feedbackid;
$PAGE->set_url('/mod/coursework/actions/moderations/new.php', $urlparams);
$renderer = $this->get_page_renderer();
- $renderer->new_moderation_page($moderator_agreement);
+ $renderer->new_moderation_page($moderatoragreement);
}
@@ -101,12 +101,12 @@ protected function edit_moderation() {
$ability = new ability(user::find($USER), $this->coursework);
$ability->require_can('edit', $moderation);
- $urlparams = array('moderationid' => $this->params['moderationid']);
+ $urlparams = ['moderationid' => $this->params['moderationid']];
$PAGE->set_url('/mod/coursework/actions/moderations/edit.php', $urlparams);
- $moderator = $DB->get_record('user', array('id' => $moderation->moderatorid));
+ $moderator = $DB->get_record('user', ['id' => $moderation->moderatorid]);
if (!empty($moderation->lasteditedby)) {
- $editor = $DB->get_record('user', array('id' => $moderation->lasteditedby));
+ $editor = $DB->get_record('user', ['id' => $moderation->lasteditedby]);
} else {
$editor = $moderator;
}
@@ -132,22 +132,22 @@ protected function create_moderation() {
$moderatoragreement->feedbackid = $this->params['feedbackid'];
$submission = submission::find($this->params['submissionid']);
- $path_params = array(
+ $pathparams = [
'submission' => $submission,
'moderator' => \core_user::get_user($this->params['moderatorid']),
'stage' => 'moderator',
- );
- $url = $this->get_router()->get_path('new moderation', $path_params, true);
+ ];
+ $url = $this->get_router()->get_path('new moderation', $pathparams, true);
$PAGE->set_url($url);
$ability = new ability(user::find($USER), $this->coursework);
$ability->require_can('new', $moderatoragreement);
- $form = new moderator_agreement_mform(null, array('moderation' => $moderatoragreement));
+ $form = new moderator_agreement_mform(null, ['moderation' => $moderatoragreement]);
- $coursework_page_url = $this->get_path('coursework', array('coursework' => $moderatoragreement->get_coursework()));
+ $courseworkpageurl = $this->get_path('coursework', ['coursework' => $moderatoragreement->get_coursework()]);
if ($form->is_cancelled()) {
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
$data = $form->get_data();
@@ -156,7 +156,7 @@ protected function create_moderation() {
$moderatoragreement = $form->process_data($moderatoragreement);
$moderatoragreement->save();
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
} else {
$renderer = $this->get_page_renderer();
$renderer->new_moderation_page($moderatoragreement);
@@ -178,17 +178,17 @@ protected function update_moderation() {
$this->check_stage_permissions($moderatoragreement->stage_identifier);
- $form = new moderator_agreement_mform(null, array('moderation' => $moderatoragreement));
+ $form = new moderator_agreement_mform(null, ['moderation' => $moderatoragreement]);
- $coursework_page_url = $this->get_path('coursework', array('coursework' => $moderatoragreement->get_coursework()));
+ $courseworkpageurl = $this->get_path('coursework', ['coursework' => $moderatoragreement->get_coursework()]);
if ($form->is_cancelled()) {
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
$moderatoragreement = $form->process_data($moderatoragreement);
$moderatoragreement->save();
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
/**
@@ -200,7 +200,7 @@ protected function update_moderation() {
protected function show_moderation() {
global $PAGE, $USER;
- $urlparams = array('moderationid' => $this->params['moderationid']);
+ $urlparams = ['moderationid' => $this->params['moderationid']];
$PAGE->set_url('/mod/coursework/actions/moderations/show.php', $urlparams);
$moderation = new moderation($this->params['moderationid']);
@@ -220,7 +220,7 @@ protected function prepare_environment() {
if (!empty($this->params['feedbackid'])) {
$feedback = $DB->get_record('coursework_feedbacks',
- array('id' => $this->params['feedbackid']),
+ ['id' => $this->params['feedbackid']],
'*',
MUST_EXIST);
$this->feedback = new feedback($feedback);
@@ -229,7 +229,7 @@ protected function prepare_environment() {
if (!empty($this->params['submissionid'])) {
$submission = $DB->get_record('coursework_submissions',
- array('id' => $this->params['submissionid']),
+ ['id' => $this->params['submissionid']],
'*',
MUST_EXIST);
$this->submission = submission::find($submission);
@@ -238,7 +238,7 @@ protected function prepare_environment() {
if (!empty($this->params['moderationid'])) {
$moderation = $DB->get_record('coursework_mod_agreements',
- array('id' => $this->params['moderationid']),
+ ['id' => $this->params['moderationid']],
'*',
MUST_EXIST);
$this->moderation = moderation::find($moderation);
diff --git a/classes/controllers/personal_deadlines_controller.php b/classes/controllers/personal_deadlines_controller.php
index c34d6385..a7464d2b 100644
--- a/classes/controllers/personal_deadlines_controller.php
+++ b/classes/controllers/personal_deadlines_controller.php
@@ -42,8 +42,8 @@ class personal_deadlines_controller extends controller_base {
protected function new_personal_deadline() {
global $USER, $PAGE;
- $coursework_page_url = (empty($this->params['setpersonaldeadlinespage'])) ? $this->get_path('coursework', array('coursework' => $this->coursework)) :
- $this->get_path('set personal deadlines', array('coursework' => $this->coursework));
+ $courseworkpageurl = (empty($this->params['setpersonaldeadlinespage'])) ? $this->get_path('coursework', ['coursework' => $this->coursework]) :
+ $this->get_path('set personal deadlines', ['coursework' => $this->coursework]);
$params = $this->set_default_current_deadline();
$ability = new ability(user::find($USER), $this->coursework);
@@ -54,9 +54,9 @@ protected function new_personal_deadline() {
: serialize($params['allocatableid']);
$PAGE->set_url('/mod/coursework/actions/personal_deadline/new.php', $params);
- $create_url = $this->get_router()->get_path('edit personal deadline');
+ $createurl = $this->get_router()->get_path('edit personal deadline');
- $this->form = new personal_deadline_form($create_url, array('coursework' => $this->coursework));
+ $this->form = new personal_deadline_form($createurl, ['coursework' => $this->coursework]);
$this->personal_deadline->setpersonaldeadlinespage = $this->params['setpersonaldeadlinespage'];
$this->personal_deadline->multipleuserdeadlines = $this->params['multipleuserdeadlines'];
@@ -64,13 +64,13 @@ protected function new_personal_deadline() {
$this->personal_deadline->allocatableid = $params['allocatableid'];
$this->form->set_data($this->personal_deadline);
if ($this->cancel_button_was_pressed()) {
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
if ($this->form->is_validated()) {
$data = $this->form->get_data();
- if (empty($data->multipleuserdeadlines) ) {
+ if (empty($data->multipleuserdeadlines)) {
if (!$this->get_personal_deadline()) { // personal deadline doesnt exist
// add new
$data->createdbyid = $USER->id;
@@ -84,38 +84,36 @@ protected function new_personal_deadline() {
$this->personal_deadline->update_attributes($data);
}
} else {
-
- $allocatables = unserialize($data->allocatableid);
-
- foreach ($allocatables as $allocatableid) {
- $data->allocatableid = $allocatableid;
- $data->id = '';
- //$data->id = '';
- $findparams = array(
- 'allocatableid' => $allocatableid,
- 'allocatabletype' => $data->allocatabletype,
- 'courseworkid' => $data->courseworkid,
- );
- $this->personal_deadline = personal_deadline::find_or_build($findparams);
-
- if (empty($this->personal_deadline->personal_deadline)) { // personal deadline doesnt exist
- // add new
- $data->createdbyid = $USER->id;
- $this->personal_deadline = personal_deadline::build($data);
- $this->personal_deadline->save();
-
- } else {
- // update
- $data->id = $this->personal_deadline->id;
- $data->lastmodifiedbyid = $USER->id;
- $data->timemodified = time();
- $this->personal_deadline->update_attributes($data);
- }
-
+ $allocatables = unserialize($data->allocatableid);
+ foreach ($allocatables as $allocatableid) {
+ $data->allocatableid = $allocatableid;
+ $data->id = '';
+ //$data->id = '';
+ $findparams = [
+ 'allocatableid' => $allocatableid,
+ 'allocatabletype' => $data->allocatabletype,
+ 'courseworkid' => $data->courseworkid,
+ ];
+ $this->personal_deadline = personal_deadline::find_or_build($findparams);
+
+ if (empty($this->personal_deadline->personal_deadline)) { // personal deadline doesnt exist
+ // add new
+ $data->createdbyid = $USER->id;
+ $this->personal_deadline = personal_deadline::build($data);
+ $this->personal_deadline->save();
+
+ } else {
+ // update
+ $data->id = $this->personal_deadline->id;
+ $data->lastmodifiedbyid = $USER->id;
+ $data->timemodified = time();
+ $this->personal_deadline->update_attributes($data);
}
+ }
+
}
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
$this->render_page('new');
@@ -127,11 +125,11 @@ protected function new_personal_deadline() {
* @return array
*/
protected function set_default_current_deadline() {
- $params = array(
+ $params = [
'allocatableid' => $this->params['allocatableid'],
'allocatabletype' => $this->params['allocatabletype'],
'courseworkid' => $this->params['courseworkid'],
- );
+ ];
// If the allocatableid is an array then the current page will probably be setting multiple the personal deadlines
// We use the first element in the array to setup the personal deadline object
@@ -141,12 +139,12 @@ protected function set_default_current_deadline() {
$params['allocatableid'] = $this->params['allocatableid'];
- // If the allocatableid is an array then the current page will probably be setting multiple the personal deadlines
- // of multiple allocatable ids in which case set the personal deadline to the coursework default
- if (is_array($this->params['allocatableid']) || !$this->get_personal_deadline()) { // if no personal deadline then use coursework deadline
- $this->personal_deadline->personal_deadline = $this->coursework->deadline;
+ // If the allocatableid is an array then the current page will probably be setting multiple the personal deadlines
+ // of multiple allocatable ids in which case set the personal deadline to the coursework default
+ if (is_array($this->params['allocatableid']) || !$this->get_personal_deadline()) { // if no personal deadline then use coursework deadline
+ $this->personal_deadline->personal_deadline = $this->coursework->deadline;
- }
+ }
return $params;
}
@@ -157,11 +155,11 @@ protected function set_default_current_deadline() {
*/
protected function get_personal_deadline() {
global $DB;
- $params = array(
+ $params = [
'allocatableid' => $this->params['allocatableid'],
'allocatabletype' => $this->params['allocatabletype'],
'courseworkid' => $this->params['courseworkid'],
- );
+ ];
return $DB->get_record('coursework_person_deadlines', $params);
}
@@ -179,7 +177,7 @@ public function insert_update($time) {
if (!$this->validated($time)) {
return [
'error' => 1,
- 'message' => 'The new deadline you chose has already passed. Please select appropriate deadline'
+ 'message' => 'The new deadline you chose has already passed. Please select appropriate deadline',
];
}
$this->coursework = coursework::find(['id' => $this->params['courseworkid']]);
@@ -217,11 +215,11 @@ public function insert_update($time) {
$data->allocatableid = $allocatableid;
$data->id = '';
//$data->id = '';
- $findparams = array(
+ $findparams = [
'allocatableid' => $allocatableid,
'allocatabletype' => $data->allocatabletype,
'courseworkid' => $data->courseworkid,
- );
+ ];
$this->personal_deadline = personal_deadline::find_or_build($findparams);
if (empty($this->personal_deadline->personal_deadline)) { // personal deadline doesnt exist
@@ -243,7 +241,7 @@ public function insert_update($time) {
return [
'error' => 0,
'time' => $date,
- 'timestamp' => $timestamp
+ 'timestamp' => $timestamp,
];
}
diff --git a/classes/controllers/plagiarism_flagging_controller.php b/classes/controllers/plagiarism_flagging_controller.php
index 30e2bf50..06641e3b 100644
--- a/classes/controllers/plagiarism_flagging_controller.php
+++ b/classes/controllers/plagiarism_flagging_controller.php
@@ -51,7 +51,7 @@ class plagiarism_flagging_controller extends controller_base {
/**
* @var plagiarism_flag
*/
- protected $plagiarism_flag;
+ protected $plagiarismflag;
/**
* This deals with the page that the assessors see when they want to add component feedbacks.
@@ -88,23 +88,23 @@ protected function edit_plagiarism_flag() {
global $DB, $PAGE, $USER;
- $plagiarism_flag = new plagiarism_flag($this->params['flagid']);
+ $plagiarismflag = new plagiarism_flag($this->params['flagid']);
$ability = new ability(user::find($USER), $this->coursework);
- $ability->require_can('edit', $plagiarism_flag);
+ $ability->require_can('edit', $plagiarismflag);
- $urlparams = array('flagid' => $this->params['flagid']);
+ $urlparams = ['flagid' => $this->params['flagid']];
$PAGE->set_url('/mod/coursework/actions/plagiarism_flagging/edit.php', $urlparams);
- $creator = $DB->get_record('user', array('id' => $plagiarism_flag->createdby));
- if (!empty($plagiarism_flag->lastmodifiedby)) {
- $editor = $DB->get_record('user', array('id' => $plagiarism_flag->lastmodifiedby));
+ $creator = $DB->get_record('user', ['id' => $plagiarismflag->createdby]);
+ if (!empty($plagiarismflag->lastmodifiedby)) {
+ $editor = $DB->get_record('user', ['id' => $plagiarismflag->lastmodifiedby]);
} else {
$editor = $creator;
}
$renderer = $this->get_page_renderer();
- $renderer->edit_plagiarism_flag_page($plagiarism_flag, $creator, $editor);
+ $renderer->edit_plagiarism_flag_page($plagiarismflag, $creator, $editor);
}
/**
@@ -120,18 +120,18 @@ protected function create_plagiarism_flag() {
$plagiarismflag->createdby = $USER->id;
$submission = submission::find($this->params['submissionid']);
- $path_params = array('submission' => $submission);
- $url = $this->get_router()->get_path('new plagiarism flag', $path_params, true);
+ $pathparams = ['submission' => $submission];
+ $url = $this->get_router()->get_path('new plagiarism flag', $pathparams, true);
$PAGE->set_url($url);
$ability = new ability(user::find($USER), $this->coursework);
$ability->require_can('new', $plagiarismflag);
- $form = new plagiarism_flagging_mform(null, array('plagiarism_flag' => $plagiarismflag));
+ $form = new plagiarism_flagging_mform(null, ['plagiarism_flag' => $plagiarismflag]);
- $coursework_page_url = $this->get_path('coursework', array('coursework' => $plagiarismflag->get_coursework()));
+ $courseworkpageurl = $this->get_path('coursework', ['coursework' => $plagiarismflag->get_coursework()]);
if ($form->is_cancelled()) {
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
$data = $form->get_data();
@@ -140,7 +140,7 @@ protected function create_plagiarism_flag() {
$plagiarismflag = $form->process_data($plagiarismflag);
$plagiarismflag->save();
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
} else {
$renderer = $this->get_page_renderer();
$renderer->new_plagiarism_flag_page($plagiarismflag);
@@ -161,36 +161,36 @@ protected function update_plagiarism_flag() {
$ability = new ability(user::find($USER), $this->coursework);
$ability->require_can('edit', $plagiarismflag);
- $form = new plagiarism_flagging_mform(null, array('plagiarism_flag' => $plagiarismflag));
+ $form = new plagiarism_flagging_mform(null, ['plagiarism_flag' => $plagiarismflag]);
- $coursework_page_url = $this->get_path('coursework', array('coursework' => $plagiarismflag->get_coursework()));
+ $courseworkpageurl = $this->get_path('coursework', ['coursework' => $plagiarismflag->get_coursework()]);
if ($form->is_cancelled()) {
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
$plagiarismflag = $form->process_data($plagiarismflag);
// add to log here
- $oldstatus = $DB->get_field(plagiarism_flag::get_table_name(), 'status', array('id' => $flagid)); // Retrieve old status before saving new
- $params = array(
+ $oldstatus = $DB->get_field(plagiarism_flag::get_table_name(), 'status', ['id' => $flagid]); // Retrieve old status before saving new
+ $params = [
'context' => \context_module::instance($this->coursework->get_course_module()->id),
'courseid' => $this->coursework->get_course()->id,
'objectid' => $this->coursework->id,
- 'other' => array(
+ 'other' => [
'courseworkid' => $this->coursework->id,
'submissionid' => $plagiarismflag->submissionid,
'flagid' => $flagid,
'oldstatus' => $oldstatus,
- 'newstatus' => $plagiarismflag->status
- )
- );
+ 'newstatus' => $plagiarismflag->status,
+ ],
+ ];
$event = \mod_coursework\event\coursework_plagiarism_flag_updated::create($params);
$event->trigger();
$plagiarismflag->save();
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
/**
@@ -200,17 +200,17 @@ protected function prepare_environment() {
global $DB;
if (!empty($this->params['flagid'])) {
- $plagiarism_flag = $DB->get_record('coursework_plagiarism_flags',
- array('id' => $this->params['flagid']),
+ $plagiarismflag = $DB->get_record('coursework_plagiarism_flags',
+ ['id' => $this->params['flagid']],
'*',
MUST_EXIST);
- $this->flag = new plagiarism_flag($plagiarism_flag);
+ $this->flag = new plagiarism_flag($plagiarismflag);
$this->params['courseworkid'] = $this->flag->get_coursework()->id;
}
if (!empty($this->params['submissionid'])) {
$submission = $DB->get_record('coursework_submissions',
- array('id' => $this->params['submissionid']),
+ ['id' => $this->params['submissionid']],
'*',
MUST_EXIST);
$this->submission = submission::find($submission);
@@ -219,7 +219,7 @@ protected function prepare_environment() {
if (!empty($this->params['moderationid'])) {
$moderation = $DB->get_record('coursework_mod_agreements',
- array('id' => $this->params['moderationid']),
+ ['id' => $this->params['moderationid']],
'*',
MUST_EXIST);
$this->moderation = moderation::find($moderation);
diff --git a/classes/controllers/submissions_controller.php b/classes/controllers/submissions_controller.php
index 467111d8..2d367e75 100644
--- a/classes/controllers/submissions_controller.php
+++ b/classes/controllers/submissions_controller.php
@@ -57,11 +57,11 @@ protected function new_submission() {
$user = user::find($USER);
$validation = false;
- $submission = submission::build(array(
+ $submission = submission::build([
'allocatableid' => $this->params['allocatableid'],
'allocatabletype' => $this->params['allocatabletype'],
'courseworkid' => $this->coursework->id,
- 'createdby' => $user->id()));
+ 'createdby' => $user->id()]);
$ability = new ability($user, $this->coursework);
if (!$ability->can('new', $submission)) {
@@ -70,20 +70,20 @@ protected function new_submission() {
$this->check_coursework_is_open($this->coursework);
- $urlparams = array('courseworkid' => $this->params['courseworkid']);
+ $urlparams = ['courseworkid' => $this->params['courseworkid']];
$PAGE->set_url('/mod/coursework/actions/submissions/new.php', $urlparams);
- $path = $this->get_router()->get_path('create submission', array('coursework' => $this->coursework));
- $submit_form = new student_submission_form($path,
- array(
+ $path = $this->get_router()->get_path('create submission', ['coursework' => $this->coursework]);
+ $submitform = new student_submission_form($path,
+ [
'coursework' => $this->coursework,
- 'submission' => $submission
- ));
- if ($submit_form->is_submitted()) {
- $validation = $submit_form->validate_defined_fields();
+ 'submission' => $submission,
+ ]);
+ if ($submitform->is_submitted()) {
+ $validation = $submitform->validate_defined_fields();
}
if ($validation != true) {
- $this->get_page_renderer()->new_submission_page($submit_form, $submission);
+ $this->get_page_renderer()->new_submission_page($submitform, $submission);
return true;
}
@@ -95,9 +95,9 @@ protected function new_submission() {
protected function create_submission() {
global $USER, $CFG, $DB;
- $coursework_page_url = $this->get_path('coursework', array('coursework' => $this->coursework));
+ $courseworkpageurl = $this->get_path('coursework', ['coursework' => $this->coursework]);
if ($this->cancel_button_was_pressed()) {
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
$validated = $this->new_submission();
@@ -116,14 +116,14 @@ protected function create_submission() {
$submission->authorid = $submission->get_author_id(); // Create new function to get the author id depending on whether the current user is submitting on behalf
$submission->timesubmitted = time();
- // Automatically finalise any submissions that's past the deadline/personal deadline and doesn't have valid extension
+ // Automatically finalise any submissions that's past the deadline/personal deadline and doesn't have valid extension
if ($this->coursework->personal_deadlines_enabled()) {
// Check is submission has a valid personal deadline or a valid extension
- if (!$this->has_valid_personal_deadline($submission) && !$this->has_valid_extension($submission)) {
- $submission->finalised = 1;
- }
+ if (!$this->has_valid_personal_deadline($submission) && !$this->has_valid_extension($submission)) {
+ $submission->finalised = 1;
+ }
} else if ($this->coursework->deadline_has_passed() && !$this->has_valid_extension($submission)) {
- $submission->finalised = 1;
+ $submission->finalised = 1;
}
$ability = new ability(user::find($USER), $this->coursework);
@@ -143,18 +143,18 @@ protected function create_submission() {
$submission->save();
- $files_id = file_get_submitted_draft_itemid('submission_manager');
- $submission->save_files($files_id);
+ $filesid = file_get_submitted_draft_itemid('submission_manager');
+ $submission->save_files($filesid);
$context = \context_module::instance($this->coursemodule->id);
// Trigger assessable_submitted event to show files are complete.
- $params = array(
+ $params = [
'context' => $context,
'objectid' => $submission->id,
- 'other' => array(
- 'courseworkid' => $this->coursework->id
- )
- );
+ 'other' => [
+ 'courseworkid' => $this->coursework->id,
+ ],
+ ];
$event = assessable_submitted::create($params);
$event->trigger();
@@ -167,16 +167,18 @@ protected function create_submission() {
}
}
- if ($submission->finalised) {
+ if ($submission->finalised) {
if (!$submission->get_coursework()->has_deadline()) {
$userids = explode(',', $submission->get_coursework()->get_submission_notification_users());
if (!empty($userids)) {
foreach ($userids as $u) {
- $notifyuser = $DB->get_record('user', array('id' => trim($u)));
+ $notifyuser = $DB->get_record('user', ['id' => trim($u)]);
- if (!empty($notifyuser)) $mailer->send_submission_notification($notifyuser);
+ if (!empty($notifyuser)) {
+ $mailer->send_submission_notification($notifyuser);
+ }
}
}
@@ -184,7 +186,7 @@ protected function create_submission() {
}
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
/**
@@ -206,26 +208,26 @@ protected function edit_submission() {
throw new access_denied($this->coursework);
}
- $urlparams = array('submissionid' => $this->params['submissionid']);
+ $urlparams = ['submissionid' => $this->params['submissionid']];
$PAGE->set_url('/mod/coursework/actions/submissions/edit.php', $urlparams);
- $path = $this->get_router()->get_path('update submission', array('submission' => $submission));
- $submit_form = new student_submission_form($path,
- array(
+ $path = $this->get_router()->get_path('update submission', ['submission' => $submission]);
+ $submitform = new student_submission_form($path,
+ [
'coursework' => $this->coursework,
- 'submission' => $submission
- ));
- if ($submit_form->is_submitted()) {
- $validation = $submit_form->validate_defined_fields();
+ 'submission' => $submission,
+ ]);
+ if ($submitform->is_submitted()) {
+ $validation = $submitform->validate_defined_fields();
}
- $submit_form->set_data($submission);
+ $submitform->set_data($submission);
- if ($validation != true) {
- $this->get_page_renderer()->edit_submission_page($submit_form, $submission);
+ if ($validation != true) {
+ $this->get_page_renderer()->edit_submission_page($submitform, $submission);
return true;
- }
- }
+ }
+ }
/**
*
@@ -234,9 +236,9 @@ protected function update_submission() {
global $USER, $CFG;
- $coursework_page_url = $this->get_path('coursework', array('coursework' => $this->coursework));
+ $courseworkpageurl = $this->get_path('coursework', ['coursework' => $this->coursework]);
if ($this->cancel_button_was_pressed()) {
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
$validated = $this->edit_submission();
@@ -253,42 +255,42 @@ protected function update_submission() {
throw new access_denied($this->coursework, $ability->get_last_message());
}
- $notify_about_finalisation = false;
- $incoming_finalised_setting = $this->params['finalised'] ? 1 : 0;
- if ($incoming_finalised_setting == 1 && $submission->finalised == 0) {
- $notify_about_finalisation = true;
+ $notifyaboutfinalisation = false;
+ $incomingfinalisedsetting = $this->params['finalised'] ? 1 : 0;
+ if ($incomingfinalisedsetting == 1 && $submission->finalised == 0) {
+ $notifyaboutfinalisation = true;
}
- $submission->finalised = $incoming_finalised_setting;
+ $submission->finalised = $incomingfinalisedsetting;
$submission->lastupdatedby = $USER->id;
$submission->timesubmitted = time();
$submission->save();
- $files_id = file_get_submitted_draft_itemid('submission_manager');
- $submission->save_files($files_id);
+ $filesid = file_get_submitted_draft_itemid('submission_manager');
+ $submission->save_files($filesid);
$context = \context_module::instance($this->coursemodule->id);
// Trigger assessable_submitted event to show files are complete.
- $params = array(
+ $params = [
'context' => $context,
'objectid' => $submission->id,
- 'other' => array(
- 'courseworkid' => $this->coursework->id
- )
- );
+ 'other' => [
+ 'courseworkid' => $this->coursework->id,
+ ],
+ ];
$event = assessable_submitted::create($params);
$event->trigger();
$submission->submit_plagiarism();
- if ($CFG->coursework_allsubmissionreceipt || $notify_about_finalisation) {
+ if ($CFG->coursework_allsubmissionreceipt || $notifyaboutfinalisation) {
$mailer = new mailer($this->coursework);
foreach ($submission->get_students() as $student) {
- $mailer->send_submission_receipt($student, $notify_about_finalisation);
+ $mailer->send_submission_receipt($student, $notifyaboutfinalisation);
}
}
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
@@ -299,9 +301,9 @@ protected function finalise_submission() {
global $USER;
- $coursework_page_url = $this->get_path('coursework', array('coursework' => $this->coursework));
+ $courseworkpageurl = $this->get_path('coursework', ['coursework' => $this->coursework]);
if ($this->cancel_button_was_pressed()) {
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
$submission = submission::find($this->params['submissionid']);
@@ -320,32 +322,32 @@ protected function finalise_submission() {
$mailer->send_submission_receipt($student, true);
}
- redirect($coursework_page_url);
+ redirect($courseworkpageurl);
}
protected function unfinalise_submission() {
global $USER, $DB;
- $allocatableids = (!is_array($this->params['allocatableid'])) ? array($this->params['allocatableid']) : $this->params['allocatableid'];
+ $allocatableids = (!is_array($this->params['allocatableid'])) ? [$this->params['allocatableid']] : $this->params['allocatableid'];
- $personaldeadline_page_url = new \moodle_url('/mod/coursework/actions/personal_deadline.php',
- array('id' => $this->coursework->get_coursemodule_id(), 'multipleuserdeadlines' => 1, 'setpersonaldeadlinespage' => 1,
- 'courseworkid' => $this->params['courseworkid'], 'allocatabletype' => $this->params['allocatabletype']));
+ $personaldeadlinepageurl = new \moodle_url('/mod/coursework/actions/personal_deadline.php',
+ ['id' => $this->coursework->get_coursemodule_id(), 'multipleuserdeadlines' => 1, 'setpersonaldeadlinespage' => 1,
+ 'courseworkid' => $this->params['courseworkid'], 'allocatabletype' => $this->params['allocatabletype']]);
$changedeadlines = false;
foreach ($allocatableids as $aid) {
- $submission_db = $DB->get_record('coursework_submissions',
- array('courseworkid' => $this->params['courseworkid'], 'allocatableid' => $aid, 'allocatabletype' => $this->params['allocatabletype']));
- if (!empty($submission_db)) {
- $submission = \mod_coursework\models\submission::find($submission_db);
+ $submissiondb = $DB->get_record('coursework_submissions',
+ ['courseworkid' => $this->params['courseworkid'], 'allocatableid' => $aid, 'allocatabletype' => $this->params['allocatabletype']]);
+ if (!empty($submissiondb)) {
+ $submission = \mod_coursework\models\submission::find($submissiondb);
if ($submission->can_be_unfinalised()) {
$submission->finalised = 0;
$submission->save();
- $personaldeadline_page_url->param("allocatableid_arr[$aid]", $aid);
+ $personaldeadlinepageurl->param("allocatableid_arr[$aid]", $aid);
$changedeadlines = true;
}
}
@@ -353,11 +355,11 @@ protected function unfinalise_submission() {
}
if (!empty($changedeadlines)) {
- redirect($personaldeadline_page_url, get_string('unfinalisedchangesubmissiondate', 'mod_coursework'));
+ redirect($personaldeadlinepageurl, get_string('unfinalisedchangesubmissiondate', 'mod_coursework'));
} else {
- $setpersonaldeadline_page_url = new \moodle_url('/mod/coursework/actions/set_personal_deadlines.php',
- array('id' => $this->coursework->get_coursemodule_id()));
- redirect($setpersonaldeadline_page_url);
+ $setpersonaldeadlinepageurl = new \moodle_url('/mod/coursework/actions/set_personal_deadlines.php',
+ ['id' => $this->coursework->get_coursemodule_id()]);
+ redirect($setpersonaldeadlinepageurl);
}
}
@@ -398,14 +400,14 @@ protected function check_coursework_is_open($coursework) {
* @throws late_submission
*/
private function exception_if_late($submission) {
- $could_have_submitted = has_capability('mod/coursework:submit', $this->coursework->get_context());
- if ($this->coursework->personal_deadlines_enabled()) {
- $deadline_has_passed = !$this->has_valid_personal_deadline($submission);
- } else {
- $deadline_has_passed = $this->coursework->deadline_has_passed();
- }
-
- if ($could_have_submitted && $deadline_has_passed && !$this->has_valid_extension($submission) && !$this->coursework->allow_late_submissions()) {
+ $couldhavesubmitted = has_capability('mod/coursework:submit', $this->coursework->get_context());
+ if ($this->coursework->personal_deadlines_enabled()) {
+ $deadlinehaspassed = !$this->has_valid_personal_deadline($submission);
+ } else {
+ $deadlinehaspassed = $this->coursework->deadline_has_passed();
+ }
+
+ if ($couldhavesubmitted && $deadlinehaspassed && !$this->has_valid_extension($submission) && !$this->coursework->allow_late_submissions()) {
throw new late_submission($this->coursework);
}
}
@@ -417,12 +419,12 @@ private function exception_if_late($submission) {
protected function submissions_exists($submission) {
global $DB;
- $sub_exists = $DB->record_exists('coursework_submissions',
- array('courseworkid' => $submission->courseworkid,
+ $subexists = $DB->record_exists('coursework_submissions',
+ ['courseworkid' => $submission->courseworkid,
'allocatableid' => $submission->allocatableid,
- 'allocatabletype' => $submission->allocatabletype));
+ 'allocatabletype' => $submission->allocatabletype]);
- return $sub_exists;
+ return $subexists;
}
/**
@@ -432,19 +434,19 @@ protected function submissions_exists($submission) {
protected function has_valid_extension($submission) {
global $DB;
- $valid_extension = false;
+ $validextension = false;
$extension = $DB->get_record('coursework_extensions',
- array('courseworkid' => $submission->courseworkid,
+ ['courseworkid' => $submission->courseworkid,
'allocatableid' => $submission->allocatableid,
- 'allocatabletype' => $submission->allocatabletype));
+ 'allocatabletype' => $submission->allocatabletype]);
if ($extension) {
if ($extension->extended_deadline > time()) {
- $valid_extension = true;
+ $validextension = true;
}
}
- return $valid_extension;
+ return $validextension;
}
/**
@@ -454,18 +456,18 @@ protected function has_valid_extension($submission) {
protected function has_valid_personal_deadline($submission) {
global $DB;
- $valid_personal_deadline = false;
- $personal_deadline = $DB->get_record('coursework_person_deadlines',
- array('courseworkid' => $submission->courseworkid,
+ $validpersonaldeadline = false;
+ $personaldeadline = $DB->get_record('coursework_person_deadlines',
+ ['courseworkid' => $submission->courseworkid,
'allocatableid' => $submission->allocatableid,
- 'allocatabletype' => $submission->allocatabletype));
- if ($personal_deadline) {
- if ($personal_deadline->personal_deadline > time()) {
- $valid_personal_deadline = true;
+ 'allocatabletype' => $submission->allocatabletype]);
+ if ($personaldeadline) {
+ if ($personaldeadline->personal_deadline > time()) {
+ $validpersonaldeadline = true;
}
} else {
- $valid_personal_deadline = !$this->coursework->deadline_has_passed();
+ $validpersonaldeadline = !$this->coursework->deadline_has_passed();
}
- return $valid_personal_deadline;
+ return $validpersonaldeadline;
}
}
diff --git a/classes/cron.php b/classes/cron.php
index 57a7f363..c2ff9588 100644
--- a/classes/cron.php
+++ b/classes/cron.php
@@ -51,7 +51,7 @@ public static function run() {
echo "Starting coursework cron functions...\n";
self::finalise_any_submissions_where_the_deadline_has_passed();
self::send_reminders_to_students();
- // self::send_first_reminders_to_admins(); #90211934
+ // self::send_first_reminders_to_admins(); #90211934
self::autorelease_feedbacks_where_the_release_date_has_passed();
return true;
}
@@ -69,19 +69,19 @@ private static function send_reminders_to_students() {
global $CFG, $DB;
- $counts = array(
+ $counts = [
'emails' => 0,
- 'users' => 0
- );
+ 'users' => 0,
+ ];
$userswhoneedreminding = [];
- $raw_courseworks = $DB->get_records('coursework');
- foreach ($raw_courseworks as $raw_coursework) {
+ $rawcourseworks = $DB->get_records('coursework');
+ foreach ($rawcourseworks as $rawcoursework) {
/**
* @var coursework $coursework
*/
- $coursework = coursework::find($raw_coursework);
+ $coursework = coursework::find($rawcoursework);
if (!$coursework || !$coursework->is_coursework_visible()) {// check if coursework exists and is not hidden
continue;
}
@@ -95,37 +95,37 @@ private static function send_reminders_to_students() {
$students = $coursework->get_students_who_have_not_yet_submitted();
foreach ($students as $student) {
- $individual_extension = false;
- $personal_deadline = false;
+ $individualextension = false;
+ $personaldeadline = false;
if ($coursework->extensions_enabled()) {
- $individual_extension = \mod_coursework\models\deadline_extension::get_extension_for_student($student, $coursework);
+ $individualextension = \mod_coursework\models\deadline_extension::get_extension_for_student($student, $coursework);
}
if ($coursework->personal_deadlines_enabled()) {
- $personal_deadline = \mod_coursework\models\personal_deadline::get_personal_deadline_for_student($student, $coursework);
+ $personaldeadline = \mod_coursework\models\personal_deadline::get_personal_deadline_for_student($student, $coursework);
}
- $deadline = $personal_deadline ? $personal_deadline->personal_deadline : $coursework->deadline;
+ $deadline = $personaldeadline ? $personaldeadline->personal_deadline : $coursework->deadline;
- if ($individual_extension) {
+ if ($individualextension) {
// check if 1st reminder is due to be sent but has not been sent yet
- if ($coursework->due_to_send_first_reminders($individual_extension->extended_deadline) &&
- $student->has_not_been_sent_reminder($coursework, 1, $individual_extension->extended_deadline)) {
- $student->deadline = $individual_extension->extended_deadline;
- $student->extension = $individual_extension->extended_deadline;
+ if ($coursework->due_to_send_first_reminders($individualextension->extended_deadline) &&
+ $student->has_not_been_sent_reminder($coursework, 1, $individualextension->extended_deadline)) {
+ $student->deadline = $individualextension->extended_deadline;
+ $student->extension = $individualextension->extended_deadline;
$student->coursework_id = $coursework->id;
$student->nextremindernumber = 1;
$userswhoneedreminding[$student->id().'_'.$coursework->id] = $student;
- // check if 2nd reminder is due to be sent but has not been sent yet
- } else if ($coursework->due_to_send_second_reminders($individual_extension->extended_deadline) &&
- $student->has_not_been_sent_reminder($coursework, 2, $individual_extension->extended_deadline)) {
- $student->deadline = $individual_extension->extended_deadline;
- $student->extension = $individual_extension->extended_deadline;
+ // check if 2nd reminder is due to be sent but has not been sent yet
+ } else if ($coursework->due_to_send_second_reminders($individualextension->extended_deadline) &&
+ $student->has_not_been_sent_reminder($coursework, 2, $individualextension->extended_deadline)) {
+ $student->deadline = $individualextension->extended_deadline;
+ $student->extension = $individualextension->extended_deadline;
$student->coursework_id = $coursework->id;
$student->nextremindernumber = 2;
$userswhoneedreminding[$student->id().'_'.$coursework->id] = $student;
- }
+ }
} else if ($deadline > time()) { // coursework or personal deadline hasn't passed
// check if 1st reminder is due to be sent but has not been sent yet
@@ -214,29 +214,29 @@ private static function send_first_reminders_to_admins() {
foreach ($courseworks as $coursework) {
/* @var coursework $coursework_instance */
- $coursework_instance = coursework::find($coursework->coursework_id);
+ $courseworkinstance = coursework::find($coursework->coursework_id);
if (empty($coursework)) {
continue;
}
- $context = context::instance_by_id($coursework_instance->get_context_id());
+ $context = context::instance_by_id($courseworkinstance->get_context_id());
$users = self::get_admins_and_teachers($context);
foreach ($users as $user) {
- if ($DB->record_exists('coursework_reminder', array(
- 'coursework_id' => $coursework_instance->id,
+ if ($DB->record_exists('coursework_reminder', [
+ 'coursework_id' => $courseworkinstance->id,
'userid' => $user->id,
'remindernumber' => 1,
- ))) {
+ ])) {
continue;
}
- $user->coursework_name = $coursework_instance->name;
- $user->deadline = userdate($coursework_instance->get_deadline(), '%a, %d %b %Y, %H:%M');
- $user->day_hour = coursework_seconds_to_string($coursework_instance->get_deadline() - time());
+ $user->coursework_name = $courseworkinstance->name;
+ $user->deadline = userdate($courseworkinstance->get_deadline(), '%a, %d %b %Y, %H:%M');
+ $user->day_hour = coursework_seconds_to_string($courseworkinstance->get_deadline() - time());
$subject = get_string('cron_email_subject_admin', 'mod_coursework', $user);
$text = get_string('cron_email_text_admin', 'mod_coursework', $user);
@@ -248,13 +248,13 @@ private static function send_first_reminders_to_admins() {
$emailssent++;
// Need to record this so they don;t get another one.
- $number_of_existing_reminders = $DB->count_records('coursework_reminder', array('coursework_id' => $coursework_instance->id,
+ $numberofexistingreminders = $DB->count_records('coursework_reminder', ['coursework_id' => $courseworkinstance->id,
'userid' => $user->id,
- ));
+ ]);
$reminder = new stdClass();
$reminder->userid = $user->id;
- $reminder->coursework_id = $coursework_instance->id;
- $reminder->remindernumber = $number_of_existing_reminders + 1;
+ $reminder->coursework_id = $courseworkinstance->id;
+ $reminder->remindernumber = $numberofexistingreminders + 1;
$DB->insert_record('coursework_reminder', $reminder);
}
@@ -289,8 +289,8 @@ public static function coursework_debuggable_query($query, $params = []) {
// Now put all the params in place.
foreach ($params as $name => $value) {
$pattern = '/:' . $name . '/';
- $replace_value = (is_numeric($value) ? $value : "'" . $value . "'");
- $query = preg_replace($pattern, $replace_value, $query);
+ $replacevalue = (is_numeric($value) ? $value : "'" . $value . "'");
+ $query = preg_replace($pattern, $replacevalue, $query);
}
return $query;
@@ -314,9 +314,9 @@ private static function send_email_reminders_to_students(array $users, array &$c
foreach ($users as $user) {
- $coursework_instance = coursework::find($user->coursework_id);
+ $courseworkinstance = coursework::find($user->coursework_id);
- $mailer = new mailer($coursework_instance);
+ $mailer = new mailer($courseworkinstance);
if ($mailer->send_student_deadline_reminder($user)) {
@@ -328,12 +328,12 @@ private static function send_email_reminders_to_students(array $users, array &$c
}
$extension = isset($user->extension) ? $user->extension : 0;
- $email_reminder = new stdClass();
- $email_reminder->userid = $user->id;
- $email_reminder->coursework_id = $user->coursework_id;
- $email_reminder->remindernumber = $user->nextremindernumber;
- $email_reminder->extension = $extension;
- $DB->insert_record('coursework_reminder', $email_reminder);
+ $emailreminder = new stdClass();
+ $emailreminder->userid = $user->id;
+ $emailreminder->coursework_id = $user->coursework_id;
+ $emailreminder->remindernumber = $user->nextremindernumber;
+ $emailreminder->extension = $extension;
+ $DB->insert_record('coursework_reminder', $emailreminder);
}
}
@@ -368,9 +368,9 @@ private static function finalise_any_submissions_where_the_deadline_has_passed()
* @return bool
*/
public static function in_test_environment() {
- $in_phpunit = defined('PHPUNIT_TEST') ? PHPUNIT_TEST : false;
- $in_behat = defined('BEHAT_TEST') ? BEHAT_TEST : false;
- if (!empty($in_phpunit) || !empty($in_behat)) {
+ $inphpunit = defined('PHPUNIT_TEST') ? PHPUNIT_TEST : false;
+ $inbehat = defined('BEHAT_TEST') ? BEHAT_TEST : false;
+ if (!empty($inphpunit) || !empty($inbehat)) {
return true;
}
return false;
@@ -386,7 +386,7 @@ private static function autorelease_feedbacks_where_the_release_date_has_passed(
global $DB;
echo 'Auto releasing feedbacks for courseworks where the release date have passed...';
- $sql = "SELECT *
+ $sql = "SELECT *
FROM {coursework} c
JOIN {coursework_submissions} cs
ON c.id = cs.courseworkid
@@ -395,18 +395,18 @@ private static function autorelease_feedbacks_where_the_release_date_has_passed(
AND c.individualfeedback IS NOT NULL
AND cs.firstpublished IS NULL";
- $coursework_submissions = $DB->get_records_sql($sql, array('now' => time()));
+ $courseworksubmissions = $DB->get_records_sql($sql, ['now' => time()]);
- foreach ($coursework_submissions as $coursework_submission) {
+ foreach ($courseworksubmissions as $courseworksubmission) {
- $submission = submission::find($coursework_submission);
- $feedback_autorelease_deadline = $submission->get_coursework()->get_individual_feedback_deadline();
+ $submission = submission::find($courseworksubmission);
+ $feedbackautoreleasedeadline = $submission->get_coursework()->get_individual_feedback_deadline();
$allocatable = $submission->get_allocatable();
if (empty($allocatable)) {
continue;
}
- if ($feedback_autorelease_deadline < time() && $submission->ready_to_publish()) {
+ if ($feedbackautoreleasedeadline < time() && $submission->ready_to_publish()) {
$submission->publish();
}
}
diff --git a/classes/decorators/submission_groups_decorator.php b/classes/decorators/submission_groups_decorator.php
index c67e4db1..8756dc7b 100644
--- a/classes/decorators/submission_groups_decorator.php
+++ b/classes/decorators/submission_groups_decorator.php
@@ -31,7 +31,7 @@
* submissions enabled. We want to make sure that the students get the grade of the group thing rather
* than their own missing assignment.
*
- * @property submission wrapped_object
+ * @property submission wrappedobject
* @package mod_coursework\decorators
*/
class submission_groups_decorator extends decorator {
@@ -43,11 +43,11 @@ class submission_groups_decorator extends decorator {
*/
public function user_is_in_same_group($user) {
- if (!$this->wrapped_object->get_coursework()->is_configured_to_have_group_submissions()) {
+ if (!$this->wrappedobject->get_coursework()->is_configured_to_have_group_submissions()) {
throw new \coding_exception('Asking for groups membership of a submissions when we are not using groups');
}
- $group = $this->wrapped_object->get_allocatable();
+ $group = $this->wrappedobject->get_allocatable();
return groups_is_member($group->id, $user->id);
}
diff --git a/classes/event/assessable_submitted.php b/classes/event/assessable_submitted.php
index d32319d3..5ea9a3d3 100644
--- a/classes/event/assessable_submitted.php
+++ b/classes/event/assessable_submitted.php
@@ -16,7 +16,7 @@
/**
*
- * @package coursework_submitted
+ * @package mod_coursework
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
diff --git a/classes/event/assessable_uploaded.php b/classes/event/assessable_uploaded.php
index 7b3a4cc9..98551bbb 100644
--- a/classes/event/assessable_uploaded.php
+++ b/classes/event/assessable_uploaded.php
@@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+
/**
* @package mod_coursework
* @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk}
@@ -57,7 +58,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
- return new \moodle_url('/mod/coursework/view.php', array('id' => $this->contextinstanceid));
+ return new \moodle_url('/mod/coursework/view.php', ['id' => $this->contextinstanceid]);
}
/**
@@ -81,6 +82,6 @@ protected function init() {
}
public static function get_objectid_mapping() {
- return array('db' => 'coursework_submissions', 'restore' => 'submission');
+ return ['db' => 'coursework_submissions', 'restore' => 'submission'];
}
}
diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php
index 185374ee..cb348115 100644
--- a/classes/event/course_module_viewed.php
+++ b/classes/event/course_module_viewed.php
@@ -39,7 +39,7 @@ protected function init() {
* @return \moodle_url
*/
public function get_url() {
- return new \moodle_url("/mod/$this->objecttable/view.php", array('id' => $this->contextinstanceid));
+ return new \moodle_url("/mod/$this->objecttable/view.php", ['id' => $this->contextinstanceid]);
}
// You might need to override get_url() and get_legacy_log_data() if view mode needs to be stored as well.
}
diff --git a/classes/exceptions/access_denied.php b/classes/exceptions/access_denied.php
index 2c8c0620..c79afc02 100644
--- a/classes/exceptions/access_denied.php
+++ b/classes/exceptions/access_denied.php
@@ -42,7 +42,7 @@ class access_denied extends \moodle_exception {
*/
public function __construct($coursework, $message = null) {
- $link = router::instance()->get_path('coursework', array('coursework' => $coursework));
+ $link = router::instance()->get_path('coursework', ['coursework' => $coursework]);
parent::__construct('access_denied', 'mod_coursework', $link, null, $message);
}
diff --git a/classes/exceptions/late_submission.php b/classes/exceptions/late_submission.php
index 07291198..3b191d0a 100644
--- a/classes/exceptions/late_submission.php
+++ b/classes/exceptions/late_submission.php
@@ -42,7 +42,7 @@ class late_submission extends \moodle_exception {
*/
public function __construct($coursework, $message = null) {
- $link = router::instance()->get_path('coursework', array('coursework' => $coursework));
+ $link = router::instance()->get_path('coursework', ['coursework' => $coursework]);
parent::__construct('latesubmissionsnotallowed', 'mod_coursework', $link, null, $message);
}
diff --git a/classes/export/csv.php b/classes/export/csv.php
index c0db544a..e16cafea 100644
--- a/classes/export/csv.php
+++ b/classes/export/csv.php
@@ -52,7 +52,7 @@ class csv {
/**
* @var array
*/
- protected $csv_cells;
+ protected $csvcells;
/**
* @var string
*/
@@ -63,10 +63,10 @@ class csv {
* @param $csv_cells
* @param $filename
*/
- public function __construct($coursework, $csv_cells, $filename) {
+ public function __construct($coursework, $csvcells, $filename) {
$this->coursework = $coursework;
$this->dateformat = '%a, %d %b %Y, %H:%M';
- $this->csv_cells = $csv_cells;
+ $this->csvcells = $csvcells;
$this->filename = $filename;
}
@@ -78,9 +78,9 @@ public function export() {
$this->csvexport = new csv_export_writer();
$this->add_filename($this->filename);
- $csv_data = [];
+ $csvdata = [];
// headers
- $this->add_headers($this->csv_cells);
+ $this->add_headers($this->csvcells);
/**
* @var submission[] $submissions
@@ -88,16 +88,16 @@ public function export() {
$submissions = $this->get_submissions();
// sort submissions by lastname
- usort($submissions, array($this, "sort_by_lastname"));
+ usort($submissions, [$this, "sort_by_lastname"]);
// loop through each submission in the coursework
foreach ($submissions as $submission) {
// add data to cvs
$data = $this->add_csv_data($submission);
- $csv_data = array_merge($csv_data, $data);
+ $csvdata = array_merge($csvdata, $data);
}
- $this->add_data_to_csv($csv_data);
+ $this->add_data_to_csv($csvdata);
$this->csvexport->download_file();
die;
@@ -110,29 +110,29 @@ public function export() {
* @param $csv_cells
* @return array
*/
- public function add_cells_to_array($submission, $student, $csv_cells) {
+ public function add_cells_to_array($submission, $student, $csvcells) {
$row = [];
- foreach ($csv_cells as $csv_cell) {
- if (substr($csv_cell, 0, 8) == 'assessor') {
- $stage_dentifier = 'assessor_'.(substr($csv_cell, -1));
- $csv_cell = substr($csv_cell, 0, -1);
+ foreach ($csvcells as $csvcell) {
+ if (substr($csvcell, 0, 8) == 'assessor') {
+ $stagedentifier = 'assessor_'.(substr($csvcell, -1));
+ $csvcell = substr($csvcell, 0, -1);
}
- $class = "mod_coursework\\export\\csv\\cells\\".$csv_cell."_cell";
+ $class = "mod_coursework\\export\\csv\\cells\\".$csvcell."_cell";
$cell = new $class($this->coursework);
- if (substr($csv_cell, 0, 8) == 'assessor') {
- $cell = $cell->get_cell($submission, $student, $stage_dentifier);
+ if (substr($csvcell, 0, 8) == 'assessor') {
+ $cell = $cell->get_cell($submission, $student, $stagedentifier);
if (is_array($cell)) {
$row = array_merge($row, $cell);
} else {
$row[] = $cell;
}
- } else if ($csv_cell != 'stages' && $csv_cell != 'moderationagreement' && $csv_cell != 'otherassessors') {
+ } else if ($csvcell != 'stages' && $csvcell != 'moderationagreement' && $csvcell != 'otherassessors') {
$cell = $cell->get_cell($submission, $student, false);
- if (is_array($cell)) {
- $row = array_merge($row, $cell);
- } else {
- $row[] = $cell;
- }
+ if (is_array($cell)) {
+ $row = array_merge($row, $cell);
+ } else {
+ $row[] = $cell;
+ }
} else {
$stages = $cell->get_cell($submission, $student, false);
@@ -147,50 +147,50 @@ public function add_cells_to_array($submission, $student, $csv_cells) {
* create headers for CSV
* @param $csv_headers
*/
- public function add_headers($csv_headers) {
- $headers = [];
- foreach ($csv_headers as $header) {
- if (substr($header, 0, 8) == 'assessor') {
- $stage = (substr($header, -1));
- $header = substr($header, 0, -1);
+ public function add_headers($csvheaders) {
+ $headers = [];
+ foreach ($csvheaders as $header) {
+ if (substr($header, 0, 8) == 'assessor') {
+ $stage = (substr($header, -1));
+ $header = substr($header, 0, -1);
+ }
+ $class = "mod_coursework\\export\\csv\\cells\\".$header."_cell";
+ $cell = new $class($this->coursework);
+ if (substr($header, 0, 8) == 'assessor') {
+ $head = $cell->get_header($stage);
+ if (is_array($head)) {
+ $headers = array_merge($headers, $head);
+ } else {
+ $headers[$header.$stage] = $head;
}
- $class = "mod_coursework\\export\\csv\\cells\\".$header."_cell";
- $cell = new $class($this->coursework);
- if (substr($header, 0, 8) == 'assessor') {
- $head = $cell->get_header($stage);
- if (is_array($head)) {
- $headers = array_merge($headers, $head);
- } else {
- $headers[$header.$stage] = $head;
- }
-
- } else if ($header != 'stages' && $header != 'moderationagreement' && $header != 'otherassessors' ) {
- $head = $cell->get_header(false);
- if (is_array($head)) {
- $headers = array_merge($headers, $head);
- } else {
- $headers[$header] = $head;
- }
+
+ } else if ($header != 'stages' && $header != 'moderationagreement' && $header != 'otherassessors' ) {
+ $head = $cell->get_header(false);
+ if (is_array($head)) {
+ $headers = array_merge($headers, $head);
} else {
- $array_headers = $cell->get_header(false);
- $headers = array_merge($headers, $array_headers);
+ $headers[$header] = $head;
}
+ } else {
+ $arrayheaders = $cell->get_header(false);
+ $headers = array_merge($headers, $arrayheaders);
}
+ }
- $this->csvexport->add_data($headers);
+ $this->csvexport->add_data($headers);
- }
+ }
/**
* Add filename to the CSV
* @param $filename
* @return string
*/
- public function add_filename($filename) {
+ public function add_filename($filename) {
- $filename = clean_filename($filename);
- return $this->csvexport->filename = $filename.'.csv';
- }
+ $filename = clean_filename($filename);
+ return $this->csvexport->filename = $filename.'.csv';
+ }
/**
* Function to sort array in order of submission's lastname
@@ -207,8 +207,8 @@ protected function sort_by_lastname($a, $b) {
/**
* @param array $csv_data
*/
- private function add_data_to_csv($csv_data) {
- foreach ($csv_data as $data) {
+ private function add_data_to_csv($csvdata) {
+ foreach ($csvdata as $data) {
$this->csvexport->add_data($data);
}
}
@@ -219,11 +219,11 @@ private function add_data_to_csv($csv_data) {
* @return array
* @throws \coding_exception
*/
- public function get_submissions($groupid = null, $selected_submission_ids = '') {
+ public function get_submissions($groupid = null, $selectedsubmissionids = '') {
$submissions = submission::$pool[$this->coursework->id]['id'] ?? submission::find_all(['courseworkid' => $this->coursework->id]);
- if ($selected_submission_ids && $selected_submission_ids = json_decode($selected_submission_ids)) {
- $result = array_flip($selected_submission_ids);
+ if ($selectedsubmissionids && $selectedsubmissionids = json_decode($selectedsubmissionids)) {
+ $result = array_flip($selectedsubmissionids);
foreach ($submissions as $submission) {
if (array_key_exists($submission->id, $result)) {
$result[$submission->id] = $submission;
@@ -241,15 +241,15 @@ public function get_submissions($groupid = null, $selected_submission_ids = '')
*/
public function add_csv_data($submission) {
- $csv_data = [];
+ $csvdata = [];
// retrieve all students (even if group coursework)
$students = $submission->get_students();
foreach ($students as $student) {
- $csv_data[] = $this->add_cells_to_array($submission, $student, $this->csv_cells);
+ $csvdata[] = $this->add_cells_to_array($submission, $student, $this->csvcells);
}
- return $csv_data;
+ return $csvdata;
}
public function other_assessors_cells() {
@@ -264,9 +264,9 @@ public function other_assessors_cells() {
$increment = 2;
}
- for ($i = 1; $i < $this->coursework->get_max_markers(); $i++) {
- $cells = $cells + $increment; // one for grade, one for feedback
- }
+ for ($i = 1; $i < $this->coursework->get_max_markers(); $i++) {
+ $cells = $cells + $increment; // one for grade, one for feedback
+ }
return $cells;
diff --git a/classes/export/csv/cells/agreedfeedback_cell.php b/classes/export/csv/cells/agreedfeedback_cell.php
index 05ca1d9c..368dbb6d 100644
--- a/classes/export/csv/cells/agreedfeedback_cell.php
+++ b/classes/export/csv/cells/agreedfeedback_cell.php
@@ -38,7 +38,7 @@ class agreedfeedback_cell extends cell_base {
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
return $gradedata[] = $submission->get_agreed_grade() == false ? '' : strip_tags($submission->get_agreed_grade()->feedbackcomment);
}
@@ -51,53 +51,63 @@ public function get_header($stage) {
return get_string('agreedgradefeedback', 'coursework');
}
- public function validate_cell($value, $submissionid, $stage_identifier='', $uploadedgradecells = []) {
+ public function validate_cell($value, $submissionid, $stageidentifier='', $uploadedgradecells = []) {
global $DB, $PAGE, $USER;
- $stage_identifier = 'final_agreed_1';
- $agreedgradecap = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade',
- 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade');
+ $stageidentifier = 'final_agreed_1';
+ $agreedgradecap = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade',
+ 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade'];
if (has_any_capability($agreedgradecap, $PAGE->context)
|| has_capability('mod/coursework:administergrades', $PAGE->context)) {
- $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid));
+ $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]);
$submission = \mod_coursework\models\submission::find($subdbrecord);
// Is the submission in question ready to grade?
- if (!$submission->all_inital_graded() && !empty($value)) return get_string('submissionnotreadyforagreedgrade', 'coursework');
+ if (!$submission->all_inital_graded() && !empty($value)) {
+ return get_string('submissionnotreadyforagreedgrade', 'coursework');
+ }
// Has the submission been published if yes then no further grades are allowed
- if ($submission->get_state() >= submission::PUBLISHED) return $submission->get_status_text();
+ if ($submission->get_state() >= submission::PUBLISHED) {
+ return $submission->get_status_text();
+ }
// If you have administer grades you can grade anything
- if (has_capability('mod/coursework:administergrades', $PAGE->context)) return true;
+ if (has_capability('mod/coursework:administergrades', $PAGE->context)) {
+ return true;
+ }
// Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled).
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $submission->id,
- 'stage_identifier' => $stage_identifier,
- );
+ 'stage_identifier' => $stageidentifier,
+ ];
- $feedback = feedback::find($feedback_params);
+ $feedback = feedback::find($feedbackparams);
$ability = new ability(user::find($USER), $this->coursework);
//does a feedback exist for this stage
if (empty($feedback)) {
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $submissionid,
'assessorid' => $USER->id,
- 'stage_identifier' => $stage_identifier,
- );
- $new_feedback = feedback::build($feedback_params);
+ 'stage_identifier' => $stageidentifier,
+ ];
+ $newfeedback = feedback::build($feedbackparams);
// This is a new feedback check it against the new ability checks
- if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && !$ability->can('new', $new_feedback)) return get_string('nopermissiontogradesubmission', 'coursework');
+ if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && !$ability->can('new', $newfeedback)) {
+ return get_string('nopermissiontogradesubmission', 'coursework');
+ }
} else {
// This is a new feedback check it against the edit ability checks
- if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework');
+ if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) {
+ return get_string('nopermissiontoeditgrade', 'coursework');
+ }
}
} else {
diff --git a/classes/export/csv/cells/agreedgrade_cell.php b/classes/export/csv/cells/agreedgrade_cell.php
index 1deae83e..c662d8cf 100644
--- a/classes/export/csv/cells/agreedgrade_cell.php
+++ b/classes/export/csv/cells/agreedgrade_cell.php
@@ -38,7 +38,7 @@ class agreedgrade_cell extends cell_base {
* @return array|mixed|null|string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
$agreedgrade = $submission->get_agreed_grade();
if ($this->coursework->is_using_rubric() && $this->coursework->finalstagegrading != 1) {
@@ -72,15 +72,17 @@ public function get_header($stage) {
return $strings;
}
- public function validate_cell($value, $submissionid, $stage_identifier='', $uploadedgradecells = []) {
+ public function validate_cell($value, $submissionid, $stageidentifier='', $uploadedgradecells = []) {
global $DB, $PAGE, $USER;
- $stage_identifier = 'final_agreed_1';
- $agreedgradecap = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade',
- 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade');
+ $stageidentifier = 'final_agreed_1';
+ $agreedgradecap = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade',
+ 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade'];
- if (empty($value)) return true;
+ if (empty($value)) {
+ return true;
+ }
if (has_any_capability($agreedgradecap, $PAGE->context)
|| has_capability('mod/coursework:administergrades', $PAGE->context)) {
@@ -146,45 +148,56 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo
}
- if (!empty($errormsg)) return $errormsg;
+ if (!empty($errormsg)) {
+ return $errormsg;
+ }
- $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid));
+ $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]);
$submission = \mod_coursework\models\submission::find($subdbrecord);
// Is the submission in question ready to grade?
- if (!$submission->all_inital_graded() && !empty($value) && count($uploadedgradecells) < $submission->max_number_of_feedbacks()) return get_string('submissionnotreadyforagreedgrade', 'coursework');
+ if (!$submission->all_inital_graded() && !empty($value) && count($uploadedgradecells) < $submission->max_number_of_feedbacks()) { return get_string('submissionnotreadyforagreedgrade', 'coursework');
+ }
// Has the submission been published if yes then no further grades are allowed
- if ($submission->get_state() >= submission::PUBLISHED) return $submission->get_status_text();
+ if ($submission->get_state() >= submission::PUBLISHED) {
+ return $submission->get_status_text();
+ }
// If you have administer grades you can grade anything
- if (has_capability('mod/coursework:administergrades', $PAGE->context)) return true;
+ if (has_capability('mod/coursework:administergrades', $PAGE->context)) {
+ return true;
+ }
// Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled).
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $submission->id,
- 'stage_identifier' => $stage_identifier,
- );
+ 'stage_identifier' => $stageidentifier,
+ ];
- $feedback = feedback::find($feedback_params);
+ $feedback = feedback::find($feedbackparams);
$ability = new ability(user::find($USER), $this->coursework);
//does a feedback exist for this stage
if (empty($feedback)) {
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $submissionid,
'assessorid' => $USER->id,
- 'stage_identifier' => $stage_identifier,
- );
- $new_feedback = feedback::build($feedback_params);
+ 'stage_identifier' => $stageidentifier,
+ ];
+ $newfeedback = feedback::build($feedbackparams);
// This is a new feedback check it against the new ability checks
- if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && !$ability->can('new', $new_feedback)) return get_string('nopermissiontogradesubmission', 'coursework');
+ if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && !$ability->can('new', $newfeedback)) {
+ return get_string('nopermissiontogradesubmission', 'coursework');
+ }
} else {
// This is a new feedback check it against the edit ability checks
- if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework');
+ if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) {
+ return get_string('nopermissiontoeditgrade', 'coursework');
+ }
}
} else {
@@ -233,7 +246,7 @@ function value_in_rubric($criteria, $value) {
* @param $csv_cells
* @return array
*/
- function get_rubrics($coursework, $csv_cells) {
+ function get_rubrics($coursework, $csvcells) {
if ($coursework->is_using_rubric() && $this->coursework->finalstagegrading != 1) {
@@ -247,16 +260,16 @@ function get_rubrics($coursework, $csv_cells) {
}
// Find out the position of singlegrade
- $position = array_search('singlegrade', $csv_cells);
+ $position = array_search('singlegrade', $csvcells);
// Get all data from the position of the singlegrade to the length of rubricheaders
// $csv_cells = array_splice($csv_cells,5, 1, $rubricheaders);
- $start_cells = array_slice($csv_cells, 0, $position, true);
- $end_cells = array_slice($csv_cells, $position + 1, count($csv_cells), true);
+ $startcells = array_slice($csvcells, 0, $position, true);
+ $endcells = array_slice($csvcells, $position + 1, count($csvcells), true);
- $cells = array_merge($start_cells, $rubricheaders);
+ $cells = array_merge($startcells, $rubricheaders);
- $cells = array_merge($cells, $end_cells);
+ $cells = array_merge($cells, $endcells);
}
diff --git a/classes/export/csv/cells/assessor_cell.php b/classes/export/csv/cells/assessor_cell.php
index ad34049f..f28eb1d5 100644
--- a/classes/export/csv/cells/assessor_cell.php
+++ b/classes/export/csv/cells/assessor_cell.php
@@ -35,10 +35,10 @@ class assessor_cell extends cell_base {
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
$assessor = '';
- $allocation = $this->coursework->get_assessor_allocation($submission, $stage_identifier );
+ $allocation = $this->coursework->get_assessor_allocation($submission, $stageidentifier );
if ($allocation) {
$assessor = $this->get_assessor_name($allocation->assessorid);
} else if ($this->coursework->sampling_enabled()) {
diff --git a/classes/export/csv/cells/assessorfeedback_cell.php b/classes/export/csv/cells/assessorfeedback_cell.php
index 86bf9aaf..726b3928 100644
--- a/classes/export/csv/cells/assessorfeedback_cell.php
+++ b/classes/export/csv/cells/assessorfeedback_cell.php
@@ -37,20 +37,20 @@ class assessorfeedback_cell extends cell_base {
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
global $USER;
- $grade = $submission->get_assessor_feedback_by_stage($stage_identifier);
+ $grade = $submission->get_assessor_feedback_by_stage($stageidentifier);
if ($grade) {
// check if user can see initial grades before all of them are completed
$ability = new ability(user::find($USER), $this->coursework);
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $submission->id,
- 'stage_identifier' => $stage_identifier,
- );
- $feedback = feedback::find($feedback_params);
+ 'stage_identifier' => $stageidentifier,
+ ];
+ $feedback = feedback::find($feedbackparams);
if ($submission->get_agreed_grade() || $ability->can('show', $feedback) || is_siteadmin($USER->id)) {
$grade = strip_tags($grade->feedbackcomment);
@@ -74,7 +74,7 @@ public function get_header($stage) {
return get_string('assessorfeedbackcsv', 'coursework', $stage);
}
- public function validate_cell($value, $submissionid, $stage_identifier='', $uploadedgradecells = []) {
+ public function validate_cell($value, $submissionid, $stageidentifier='', $uploadedgradecells = []) {
global $DB, $PAGE, $USER;
$modulecontext = $PAGE->context;
@@ -86,62 +86,75 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo
"Invalid context level " . $modulecontext->contextlevel
);
}
- $agreedgradecap = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade');
- $initialgradecap = array('mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade');
+ $agreedgradecap = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade'];
+ $initialgradecap = ['mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade'];
- $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid));
+ $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]);
$submission = \mod_coursework\models\submission::find($subdbrecord);
if (has_any_capability($agreedgradecap, $modulecontext) && has_any_capability($initialgradecap, $modulecontext)
|| has_capability('mod/coursework:administergrades', $modulecontext)) {
// Is the submission in question ready to grade?
- if (!$submission->ready_to_grade()) return get_string('submissionnotreadytograde', 'coursework');
+ if (!$submission->ready_to_grade()) {
+ return get_string('submissionnotreadytograde', 'coursework');
+ }
// Has the submission been published if yes then no further grades are allowed
- if ($submission->get_state() >= submission::PUBLISHED) return $submission->get_status_text();
+ if ($submission->get_state() >= submission::PUBLISHED) {
+ return $submission->get_status_text();
+ }
// If you have administer grades you can grade anything
- if (has_capability('mod/coursework:administergrades', $modulecontext)) return true;
+ if (has_capability('mod/coursework:administergrades', $modulecontext)) {
+ return true;
+ }
// Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled).
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $submission->id,
- 'stage_identifier' => $stage_identifier,
- );
- $feedback = feedback::find($feedback_params);
+ 'stage_identifier' => $stageidentifier,
+ ];
+ $feedback = feedback::find($feedbackparams);
$ability = new ability(user::find($USER), $this->coursework);
//does a feedback exist for this stage
if (!empty($feedback)) {
// This is a new feedback check it against the new ability checks
- if (!has_capability('mod/coursework:administergrades', $modulecontext) && !$ability->can('new', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework');
+ if (!has_capability('mod/coursework:administergrades', $modulecontext) && !$ability->can('new', $feedback)) {
+ return get_string('nopermissiontoeditgrade', 'coursework');
+ }
} else {
// This is a new feedback check it against the edit ability checks
- if (!has_capability('mod/coursework:administergrades', $modulecontext) && !$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework');
+ if (!has_capability('mod/coursework:administergrades', $modulecontext) && !$ability->can('edit', $feedback)) {
+ return get_string('nopermissiontoeditgrade', 'coursework');
+ }
}
if (!$this->coursework->allocation_enabled() && !empty($feedback)) {
- // Was this user the one who last graded this submission if not then user cannot grade
- if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $modulecontext) )
+ // Was this user the one who last graded this submission if not then user cannot grade
+ if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $modulecontext) ) {
return get_string('nopermissiontogradesubmission', 'coursework');
+ }
}
if ($this->coursework->allocation_enabled()) {
// Check that the user is allocated to the author of the submission
- $allocation_params = array(
+ $allocationparams = [
'courseworkid' => $this->coursework->id,
'allocatableid' => $submission->allocatableid,
'allocatabletype' => $submission->allocatabletype,
- 'stage_identifier' => $stage_identifier
- );
+ 'stage_identifier' => $stageidentifier,
+ ];
if (!has_capability('mod/coursework:administergrades', $modulecontext)
- && !$DB->get_record('coursework_allocation_pairs', $allocation_params)) return get_string('nopermissiontogradesubmission', 'coursework');
+ && !$DB->get_record('coursework_allocation_pairs', $allocationparams)) {
+ return get_string('nopermissiontogradesubmission', 'coursework');
+ }
}
// Check for coursework without allocations - with/without samplings
@@ -149,17 +162,19 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo
&& $this->coursework->get_max_markers() > 1 && !$this->coursework->allocation_enabled()) {
// check how many feedbacks for this submission
- $feedbacks = $DB->count_records('coursework_feedbacks', array('submissionid' => $submissionid));
+ $feedbacks = $DB->count_records('coursework_feedbacks', ['submissionid' => $submissionid]);
if ($this->coursework->sampling_enabled()) {
// check how many sample assessors + add 1 that is always in sample
- $in_sample = $submission->get_submissions_in_sample();
- $assessors = ($in_sample) ? count($in_sample) + 1 : 1;
+ $insample = $submission->get_submissions_in_sample();
+ $assessors = ($insample) ? count($insample) + 1 : 1;
} else {
// Check how many assessors for this coursework
$assessors = $this->coursework->get_max_markers();
}
- if ($assessors == $feedbacks) return get_string('gradealreadyexists', 'coursework');
+ if ($assessors == $feedbacks) {
+ return get_string('gradealreadyexists', 'coursework');
+ }
}
} else if (has_any_capability($agreedgradecap, $modulecontext)) {
diff --git a/classes/export/csv/cells/assessorgrade_cell.php b/classes/export/csv/cells/assessorgrade_cell.php
index 3c2a83b8..40a22d96 100644
--- a/classes/export/csv/cells/assessorgrade_cell.php
+++ b/classes/export/csv/cells/assessorgrade_cell.php
@@ -39,20 +39,20 @@ class assessorgrade_cell extends cell_base {
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
global $USER;
- $grade = $submission->get_assessor_feedback_by_stage($stage_identifier);
+ $grade = $submission->get_assessor_feedback_by_stage($stageidentifier);
// check if user can see initial grades before all of them are completed
$ability = new ability(user::find($USER), $this->coursework);
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $submission->id,
- 'stage_identifier' => $stage_identifier,
- );
- $feedback = feedback::find($feedback_params);
+ 'stage_identifier' => $stageidentifier,
+ ];
+ $feedback = feedback::find($feedbackparams);
if (($submission->get_agreed_grade() || ($feedback && $ability->can('show', $feedback))) || !$submission->any_editable_feedback_exists() || is_siteadmin($USER->id)) {
@@ -69,8 +69,8 @@ public function get_cell($submission, $student, $stage_identifier) {
if ($this->coursework->is_using_rubric()) {
$criterias = $this->coursework->get_rubric_criteria();
foreach ($criterias as $criteria) { // rubrics can have multiple parts, so let's create header for each of it
- $gradedata['assessor'.$stage_identifier.'_'.$criteria['id']] = get_string('grade_hidden_manager', 'mod_coursework');
- $gradedata['assessor'.$stage_identifier.'_'.$criteria['id']. 'comment'] = '';
+ $gradedata['assessor'.$stageidentifier.'_'.$criteria['id']] = get_string('grade_hidden_manager', 'mod_coursework');
+ $gradedata['assessor'.$stageidentifier.'_'.$criteria['id']. 'comment'] = '';
}
} else {
$gradedata = get_string('grade_hidden_manager', 'mod_coursework');
@@ -103,14 +103,16 @@ public function get_header($stage) {
}
- public function validate_cell($value, $submissionid, $stage_identifier='', $uploadedgradecells = []) {
+ public function validate_cell($value, $submissionid, $stageidentifier='', $uploadedgradecells = []) {
global $DB, $PAGE, $USER;
- if (empty($value)) return true;
+ if (empty($value)) {
+ return true;
+ }
- $agreedgradecap = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade');
- $initialgradecap = array('mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade');
- $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid));
+ $agreedgradecap = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade'];
+ $initialgradecap = ['mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade'];
+ $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]);
$submission = \mod_coursework\models\submission::find($subdbrecord);
if (has_any_capability($agreedgradecap, $PAGE->context) && has_any_capability($initialgradecap, $PAGE->context)
@@ -172,57 +174,72 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo
}
- if (!empty($errormsg)) return $errormsg;
+ if (!empty($errormsg)) {
+ return $errormsg;
+ }
// Is the submission in question ready to grade?
- if (!$submission->ready_to_grade()) return get_string('submissionnotreadytograde', 'coursework');
+ if (!$submission->ready_to_grade()) {
+ return get_string('submissionnotreadytograde', 'coursework');
+ }
// Has the submission been published if yes then no further grades are allowed
- if ($submission->get_state() >= submission::PUBLISHED) return $submission->get_status_text();
+ if ($submission->get_state() >= submission::PUBLISHED) {
+ return $submission->get_status_text();
+ }
// If you have administer grades you can grade anything
- if (has_capability('mod/coursework:administergrades', $PAGE->context)) return true;
+ if (has_capability('mod/coursework:administergrades', $PAGE->context)) {
+ return true;
+ }
// Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled).
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $submission->id,
- 'stage_identifier' => $stage_identifier,
- );
- $feedback = feedback::find($feedback_params);
+ 'stage_identifier' => $stageidentifier,
+ ];
+ $feedback = feedback::find($feedbackparams);
$ability = new ability(user::find($USER), $this->coursework);
//does a feedback exist for this stage
if (!empty($feedback)) {
// This is a new feedback check it against the new ability checks
- if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('new', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework');
+ if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('new', $feedback)) {
+ return get_string('nopermissiontoeditgrade', 'coursework');
+ }
} else {
// This is a new feedback check it against the edit ability checks
- if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework');
+ if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) {
+ return get_string('nopermissiontoeditgrade', 'coursework');
+ }
}
if (!$this->coursework->allocation_enabled() && !empty($feedback)) {
- // Was this user the one who last graded this submission if not then user cannot grade
- if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $PAGE->context))
+ // Was this user the one who last graded this submission if not then user cannot grade
+ if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $PAGE->context)) {
return get_string('nopermissiontogradesubmission', 'coursework');
+ }
}
if ($this->coursework->allocation_enabled()) {
// Check that the user is allocated to the author of the submission
- $allocation_params = array(
+ $allocationparams = [
'courseworkid' => $this->coursework->id,
'allocatableid' => $submission->allocatableid,
'allocatabletype' => $submission->allocatabletype,
- 'stage_identifier' => $stage_identifier
- );
+ 'stage_identifier' => $stageidentifier,
+ ];
if (!has_capability('mod/coursework:administergrades', $PAGE->context)
- && !$DB->get_record('coursework_allocation_pairs', $allocation_params)
- ) return get_string('nopermissiontogradesubmission', 'coursework');
+ && !$DB->get_record('coursework_allocation_pairs', $allocationparams)
+ ) {
+ return get_string('nopermissiontogradesubmission', 'coursework');
+ }
}
// Check for coursework without allocations - with/without samplings
@@ -231,24 +248,26 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo
) {
// check how many feedbacks for this submission
- $feedbacks = $DB->count_records('coursework_feedbacks', array('submissionid' => $submissionid));
+ $feedbacks = $DB->count_records('coursework_feedbacks', ['submissionid' => $submissionid]);
if ($this->coursework->sampling_enabled()) {
// check how many sample assessors + add 1 that is always in sample
- $in_sample = $submission->get_submissions_in_sample();
- $assessors = ($in_sample) ? count($in_sample) + 1 : 1;
+ $insample = $submission->get_submissions_in_sample();
+ $assessors = ($insample) ? count($insample) + 1 : 1;
} else {
// Check how many assessors for this coursework
$assessors = $this->coursework->get_max_markers();
}
- if ($assessors == $feedbacks) return get_string('gradealreadyexists', 'coursework');
+ if ($assessors == $feedbacks) {
+ return get_string('gradealreadyexists', 'coursework');
+ }
}
} else if (has_any_capability($agreedgradecap, $PAGE->context)) {
- // If you have the add agreed or edit agreed grades capabilities then you may have the grades on your export sheet
- // We will return true as we will ignore them
- return true;
+ // If you have the add agreed or edit agreed grades capabilities then you may have the grades on your export sheet
+ // We will return true as we will ignore them
+ return true;
} else {
return get_string('nopermissiontoimportgrade', 'coursework');
@@ -292,7 +311,7 @@ function value_in_rubric($criteria, $value) {
* @param $csv_cells
*
*/
- function get_rubrics($coursework, $csv_cells) {
+ function get_rubrics($coursework, $csvcells) {
if ($coursework->is_using_rubric()) {
@@ -306,16 +325,16 @@ function get_rubrics($coursework, $csv_cells) {
}
// Find out the position of singlegrade
- $position = array_search('singlegrade', $csv_cells);
+ $position = array_search('singlegrade', $csvcells);
// Get all data from the position of the singlegrade to the length of rubricheaders
// $csv_cells = array_splice($csv_cells,5, 1, $rubricheaders);
- $start_cells = array_slice($csv_cells, 0, $position, true);
- $end_cells = array_slice($csv_cells, $position + 1, count($csv_cells), true);
+ $startcells = array_slice($csvcells, 0, $position, true);
+ $endcells = array_slice($csvcells, $position + 1, count($csvcells), true);
- $cells = array_merge($start_cells, $rubricheaders);
+ $cells = array_merge($startcells, $rubricheaders);
- $cells = array_merge($cells, $end_cells);
+ $cells = array_merge($cells, $endcells);
}
diff --git a/classes/export/csv/cells/cell_base.php b/classes/export/csv/cells/cell_base.php
index 563f8484..bbdb2d65 100644
--- a/classes/export/csv/cells/cell_base.php
+++ b/classes/export/csv/cells/cell_base.php
@@ -112,10 +112,10 @@ public function get_extension_extra_info_for_csv($student) {
public function get_extension_reason_for_csv($student) {
$extension = $this->extension->get_extension_for_student($student, $this->coursework);
- $extension_reasons = $this->get_extension_predefined_reasons();
+ $extensionreasons = $this->get_extension_predefined_reasons();
- return (!empty($extension_reasons[$extension->pre_defined_reason])) ?
- strip_tags($extension_reasons[$extension->pre_defined_reason]) : "";
+ return (!empty($extensionreasons[$extension->pre_defined_reason])) ?
+ strip_tags($extensionreasons[$extension->pre_defined_reason]) : "";
}
/**
@@ -182,7 +182,7 @@ public function get_actual_grade($grade) {
public function get_assessor_name($assessorid) {
global $DB;
- $assessor = $DB->get_record('user', array('id' => $assessorid), 'firstname, lastname');
+ $assessor = $DB->get_record('user', ['id' => $assessorid], 'firstname, lastname');
return $assessor->lastname .' '. $assessor->firstname;
}
@@ -195,7 +195,7 @@ public function get_assessor_name($assessorid) {
public function get_assessor_username($assessorid) {
global $DB;
- $assessor = $DB->get_record('user', array('id' => $assessorid), 'username');
+ $assessor = $DB->get_record('user', ['id' => $assessorid], 'username');
return $assessor->username;
}
@@ -230,7 +230,7 @@ public function get_stage_identifier_for_assessor($submission, $student) {
} else if ($this->coursework->get_max_markers() > 1) {
// get existing feedback
- $sql = "SELECT * FROM {coursework_feedbacks}
+ $sql = "SELECT * FROM {coursework_feedbacks}
WHERE submissionid= $submission->id
AND assessorid = $USER->id
AND stage_identifier <> 'final_agreed_1'";
@@ -250,7 +250,7 @@ public function get_stage_identifier_for_assessor($submission, $student) {
* Function to validate cell for the file upload
* @return mixed
*/
- public function validate_cell($value, $submissions, $stage_dentifier='', $uploadedgradecells = []) {
+ public function validate_cell($value, $submissions, $stagedentifier='', $uploadedgradecells = []) {
return true;
}
@@ -267,9 +267,9 @@ public function get_rubric_scores_gradedata($grade, &$gradedata) {
/**
* @var gradingform_rubric_instance $grade
*/
- $rubric_marks = $gradinginstance->get_rubric_filling();
+ $rubricmarks = $gradinginstance->get_rubric_filling();
- foreach ($rubric_marks['criteria'] as $id => $record) {
+ foreach ($rubricmarks['criteria'] as $id => $record) {
$gradedata[] = $controller->get_definition()->rubric_criteria[$id]['levels'][$record['levelid']]['score'];
$gradedata[] = $record['remark'];
diff --git a/classes/export/csv/cells/cell_interface.php b/classes/export/csv/cells/cell_interface.php
index 5df28a06..0d8e1859 100644
--- a/classes/export/csv/cells/cell_interface.php
+++ b/classes/export/csv/cells/cell_interface.php
@@ -33,7 +33,7 @@ interface cell_interface {
* @param $stage_identifier
* @return mixed
*/
- public function get_cell($submission, $student, $stage_identifier);
+ public function get_cell($submission, $student, $stageidentifier);
/**
* @param $stage
@@ -47,6 +47,6 @@ public function get_header($stage);
* @param $stage_dentifier
* @return mixed
*/
- public function validate_cell($value, $submissions, $stage_dentifier='');
+ public function validate_cell($value, $submissions, $stagedentifier='');
}
diff --git a/classes/export/csv/cells/email_cell.php b/classes/export/csv/cells/email_cell.php
index f40ebeb8..14698ee9 100644
--- a/classes/export/csv/cells/email_cell.php
+++ b/classes/export/csv/cells/email_cell.php
@@ -35,7 +35,7 @@ class email_cell extends cell_base {
* @return string
* @throws \coding_exception
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
if ($this->can_view_hidden() || $submission->is_published()) {
$name = $student->email;
diff --git a/classes/export/csv/cells/extensiondeadline_cell.php b/classes/export/csv/cells/extensiondeadline_cell.php
index c8644568..e7c7e766 100644
--- a/classes/export/csv/cells/extensiondeadline_cell.php
+++ b/classes/export/csv/cells/extensiondeadline_cell.php
@@ -33,7 +33,7 @@ class extensiondeadline_cell extends cell_base {
* @param $stage_identifier
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
if ($this->extension_exists($student)) {
$deadline = $this->get_extension_date_for_csv($student);
diff --git a/classes/export/csv/cells/extensionextrainfo_cell.php b/classes/export/csv/cells/extensionextrainfo_cell.php
index bb57a8a1..8eb8773f 100644
--- a/classes/export/csv/cells/extensionextrainfo_cell.php
+++ b/classes/export/csv/cells/extensionextrainfo_cell.php
@@ -33,14 +33,14 @@ class extensionextrainfo_cell extends cell_base {
* @param $stage_identifier
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
if ($this->extension_exists($student)) {
- $extra_info = $this->get_extension_extra_info_for_csv($student);
+ $extrainfo = $this->get_extension_extra_info_for_csv($student);
} else {
- $extra_info = '';
+ $extrainfo = '';
}
- return $extra_info;
+ return $extrainfo;
}
/**
diff --git a/classes/export/csv/cells/extensionreason_cell.php b/classes/export/csv/cells/extensionreason_cell.php
index e7ca00a3..4815678a 100644
--- a/classes/export/csv/cells/extensionreason_cell.php
+++ b/classes/export/csv/cells/extensionreason_cell.php
@@ -33,7 +33,7 @@ class extensionreason_cell extends cell_base {
* @param $stage_identifier
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
if ($this->extension_exists($student)) {
$reason = $this->get_extension_reason_for_csv($student);
diff --git a/classes/export/csv/cells/finalgrade_cell.php b/classes/export/csv/cells/finalgrade_cell.php
index 6c2926f4..6cb989ef 100644
--- a/classes/export/csv/cells/finalgrade_cell.php
+++ b/classes/export/csv/cells/finalgrade_cell.php
@@ -34,7 +34,7 @@ class finalgrade_cell extends cell_base {
* @param $stage_identifier
* @return null|string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
return $submission->get_final_grade() == false || $submission->editable_final_feedback_exist() ? '' : $this->get_actual_grade($submission->get_final_grade());
diff --git a/classes/export/csv/cells/group_cell.php b/classes/export/csv/cells/group_cell.php
index 599f76a3..b37083b8 100644
--- a/classes/export/csv/cells/group_cell.php
+++ b/classes/export/csv/cells/group_cell.php
@@ -33,7 +33,7 @@ class group_cell extends cell_base {
* @param $stage_identifier
* @return mixed
*/
- public function get_cell($submission, $group, $stage_identifier) {
+ public function get_cell($submission, $group, $stageidentifier) {
return $group->name;
}
diff --git a/classes/export/csv/cells/idnumber_cell.php b/classes/export/csv/cells/idnumber_cell.php
index 422cdfbb..b7cac9ca 100644
--- a/classes/export/csv/cells/idnumber_cell.php
+++ b/classes/export/csv/cells/idnumber_cell.php
@@ -35,7 +35,7 @@ class idnumber_cell extends cell_base {
* @return string
* @throws \coding_exception
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
if ($this->can_view_hidden() || $submission->is_published()) {
$name = $student->idnumber;
diff --git a/classes/export/csv/cells/moderationagreement_cell.php b/classes/export/csv/cells/moderationagreement_cell.php
index a989a1e2..62d20a9a 100644
--- a/classes/export/csv/cells/moderationagreement_cell.php
+++ b/classes/export/csv/cells/moderationagreement_cell.php
@@ -35,11 +35,11 @@ class moderationagreement_cell extends cell_base {
* @param $stage_identifier
* @return array
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
global $DB;
$data = [];
- $moderation_agreement = '';
+ $moderationagreement = '';
$moderation = '';
if ($this->coursework->allocation_enabled()) {
@@ -53,21 +53,25 @@ public function get_cell($submission, $student, $stage_identifier) {
}
}
$feedback = $submission->get_assessor_feedback_by_stage('assessor_1');
- if ($feedback) $moderation = moderation::find(array('feedbackid' => $feedback->id));
+ if ($feedback) {
+ $moderation = moderation::find(['feedbackid' => $feedback->id]);
+ }
- if ($moderation) $moderation_agreement = $moderation->get_moderator_agreement($feedback);
+ if ($moderation) {
+ $moderationagreement = $moderation->get_moderator_agreement($feedback);
+ }
- if ($moderation_agreement) {
- $data[] = $moderation_agreement->agreement;
- $data[] = $this->get_assessor_name($moderation_agreement->moderatorid);
- $data[] = $this->get_assessor_username($moderation_agreement->moderatorid);
- $data[] = userdate($moderation_agreement->timemodified, $this->dateformat);
- } else {
- $data[] = '';
- $data[] = '';
- $data[] = '';
- $data[] = '';
- }
+ if ($moderationagreement) {
+ $data[] = $moderationagreement->agreement;
+ $data[] = $this->get_assessor_name($moderationagreement->moderatorid);
+ $data[] = $this->get_assessor_username($moderationagreement->moderatorid);
+ $data[] = userdate($moderationagreement->timemodified, $this->dateformat);
+ } else {
+ $data[] = '';
+ $data[] = '';
+ $data[] = '';
+ $data[] = '';
+ }
return $data;
}
diff --git a/classes/export/csv/cells/name_cell.php b/classes/export/csv/cells/name_cell.php
index 23b4b17a..9123ebfd 100644
--- a/classes/export/csv/cells/name_cell.php
+++ b/classes/export/csv/cells/name_cell.php
@@ -35,7 +35,7 @@ class name_cell extends cell_base {
* @return string
* @throws \coding_exception
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
if ($this->can_view_hidden() || $submission->is_published()) {
$name = $student->lastname . ' ' . $student->firstname;
diff --git a/classes/export/csv/cells/otherassessors_cell.php b/classes/export/csv/cells/otherassessors_cell.php
index 008def5a..e0dc9469 100644
--- a/classes/export/csv/cells/otherassessors_cell.php
+++ b/classes/export/csv/cells/otherassessors_cell.php
@@ -38,18 +38,18 @@ class otherassessors_cell extends cell_base {
* @param $stage_identifier
* @return null|string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
global $DB, $USER;
// find out current user stage identifier
- // $stage_identifier =
- // retrieve all feedbacks without currents user feedback
+ // $stage_identifier =
+ // retrieve all feedbacks without currents user feedback
- $params = array(
+ $params = [
'submissionid' => $submission->id,
'assessorid' => $USER->id,
- 'stageidentifier' => $stage_identifier
- );
+ 'stageidentifier' => $stageidentifier,
+ ];
$sql = "SELECT * FROM {coursework_feedbacks}
WHERE submissionid = :submissionid
@@ -59,16 +59,18 @@ public function get_cell($submission, $student, $stage_identifier) {
$feedbacks = $DB->get_records_sql($sql, $params);
$gradedata = [];
- // $stage_identifier = ($this->coursework->get_max_markers() == 1) ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student);
+ // $stage_identifier = ($this->coursework->get_max_markers() == 1) ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student);
foreach ($feedbacks as $feedback) {
$grade = $submission->get_assessor_feedback_by_stage($feedback->stage_identifier);
if ($grade) {
// skip if you are allocated but someone else graded it
$allocation = $submission->get_assessor_allocation_by_stage($feedback->stage_identifier);
- if ($allocation && $allocation->assessorid == $USER->id) continue;
+ if ($allocation && $allocation->assessorid == $USER->id) {
+ continue;
+ }
$ability = new ability(user::find($USER), $this->coursework);
- if ((($ability->can('show', $feedback) || has_capability('mod/coursework:addallocatedagreedgrade', $submission->get_coursework()->get_context())) &&
+ if ((($ability->can('show', $feedback) || has_capability('mod/coursework:addallocatedagreedgrade', $submission->get_coursework()->get_context())) &&
(!$submission->any_editable_feedback_exists() && count($submission->get_assessor_feedbacks()) <= $submission->max_number_of_feedbacks())) || is_siteadmin($USER->id)) {
if ($this->coursework->is_using_rubric()) {
@@ -89,8 +91,8 @@ public function get_cell($submission, $student, $stage_identifier) {
if ($this->coursework->is_using_rubric()) {
$criterias = $this->coursework->get_rubric_criteria();
foreach ($criterias as $criteria) { // rubrics can have multiple parts, so let's create header for each of it
- $gradedata['assessor' . $stage_identifier . '_' . $criteria['id']] = get_string('grade_hidden_manager', 'mod_coursework');
- $gradedata['assessor' . $stage_identifier . '_' . $criteria['id'] . 'comment'] = '';
+ $gradedata['assessor' . $stageidentifier . '_' . $criteria['id']] = get_string('grade_hidden_manager', 'mod_coursework');
+ $gradedata['assessor' . $stageidentifier . '_' . $criteria['id'] . 'comment'] = '';
}
} else {
$gradedata[] = '';
@@ -110,8 +112,8 @@ public function get_cell($submission, $student, $stage_identifier) {
if ($this->coursework->is_using_rubric()) {
$criterias = $this->coursework->get_rubric_criteria();
foreach ($criterias as $criteria) { // rubrics can have multiple parts, so let's create header for each of it
- $gradedata['assessor' . $stage_identifier.$i. '_' . $criteria['id']] = '';
- $gradedata['assessor' . $stage_identifier.$i. '_' . $criteria['id'] . 'comment'] = '';
+ $gradedata['assessor' . $stageidentifier.$i. '_' . $criteria['id']] = '';
+ $gradedata['assessor' . $stageidentifier.$i. '_' . $criteria['id'] . 'comment'] = '';
}
} else {
$gradedata[] = '';
@@ -146,7 +148,7 @@ public function get_header($stage) {
}
$fields['otherassessorfeedback' . $i] = get_string('otherassessorfeedback', 'coursework', $i);
}
- return $fields;
+ return $fields;
}
}
diff --git a/classes/export/csv/cells/personaldeadline_cell.php b/classes/export/csv/cells/personaldeadline_cell.php
index e77dc73d..50a39552 100644
--- a/classes/export/csv/cells/personaldeadline_cell.php
+++ b/classes/export/csv/cells/personaldeadline_cell.php
@@ -33,11 +33,11 @@ class personaldeadline_cell extends cell_base {
* @param $stage_identifier
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
- $personal_deadline = $submission->submission_personal_deadline();
+ $personaldeadline = $submission->submission_personal_deadline();
- return userdate($personal_deadline, $this->dateformat);
+ return userdate($personaldeadline, $this->dateformat);
}
/**
diff --git a/classes/export/csv/cells/plagiarismflagcomment_cell.php b/classes/export/csv/cells/plagiarismflagcomment_cell.php
index f7a93314..70b0f225 100644
--- a/classes/export/csv/cells/plagiarismflagcomment_cell.php
+++ b/classes/export/csv/cells/plagiarismflagcomment_cell.php
@@ -33,7 +33,7 @@ class plagiarismflagcomment_cell extends cell_base {
* @param $stage_identifier
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
if ($this->plagiarism_flagged($submission)) {
$flag = $this->get_plagiarism_flag_comment_for_csv($submission);
diff --git a/classes/export/csv/cells/plagiarismflagstatus_cell.php b/classes/export/csv/cells/plagiarismflagstatus_cell.php
index fdb399e7..bf467448 100644
--- a/classes/export/csv/cells/plagiarismflagstatus_cell.php
+++ b/classes/export/csv/cells/plagiarismflagstatus_cell.php
@@ -33,7 +33,7 @@ class plagiarismflagstatus_cell extends cell_base {
* @param $stage_identifier
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
if ($this->plagiarism_flagged($submission)) {
$flag = $this->get_plagiarism_flag_status_for_csv($submission);
diff --git a/classes/export/csv/cells/singlegrade_cell.php b/classes/export/csv/cells/singlegrade_cell.php
index 22c2d721..0d1ccfe6 100644
--- a/classes/export/csv/cells/singlegrade_cell.php
+++ b/classes/export/csv/cells/singlegrade_cell.php
@@ -38,11 +38,11 @@ class singlegrade_cell extends cell_base {
* @param $stage_identifier
* @return array|mixed|null|string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
- $stage_identifier = ($this->coursework->get_max_markers() == 1) ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student);
+ $stageidentifier = ($this->coursework->get_max_markers() == 1) ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student);
- $grade = $submission->get_assessor_feedback_by_stage($stage_identifier);
+ $grade = $submission->get_assessor_feedback_by_stage($stageidentifier);
if ($this->coursework->is_using_rubric()) {
$gradedata = [];
$this->get_rubric_scores_gradedata($grade, $gradedata); // multiple parts are handled here
@@ -73,7 +73,7 @@ public function get_header($stage) {
return $strings;
}
- public function validate_cell($value, $submissionid, $stage_identifier='', $uploadedgradecells = []) {
+ public function validate_cell($value, $submissionid, $stageidentifier='', $uploadedgradecells = []) {
global $PAGE, $DB, $USER;
@@ -133,64 +133,78 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo
}
- if (!empty($errormsg)) return $errormsg;
+ if (!empty($errormsg)) {
+ return $errormsg;
+ }
- $dbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid));
+ $dbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]);
$submission = \mod_coursework\models\submission::find($dbrecord);
// Is this submission ready to be graded
- if (!$submission->ready_to_grade() && $submission->get_state() < \mod_coursework\models\submission::FULLY_GRADED) return get_string('submissionnotreadytograde', 'coursework');
+ if (!$submission->ready_to_grade() && $submission->get_state() < \mod_coursework\models\submission::FULLY_GRADED) {
+ return get_string('submissionnotreadytograde', 'coursework');
+ }
// If you have administer grades you can grade anything
- if (has_capability('mod/coursework:administergrades', $PAGE->context)) return true;
+ if (has_capability('mod/coursework:administergrades', $PAGE->context)) {
+ return true;
+ }
// Is the current user an assessor at any of this submissions grading stages or do they have administer grades
- if ($this->coursework->allocation_enabled() && !$this->coursework->is_assessor($USER) && !has_capability('mod/coursework:administergrades', $PAGE->context))
+ if ($this->coursework->allocation_enabled() && !$this->coursework->is_assessor($USER) && !has_capability('mod/coursework:administergrades', $PAGE->context)) {
return get_string('nopermissiontogradesubmission', 'coursework');
+ }
// Has the submission been published if yes then no further grades are allowed
- if ($submission->get_state() >= submission::PUBLISHED) return $submission->get_status_text();
+ if ($submission->get_state() >= submission::PUBLISHED) {
+ return $submission->get_status_text();
+ }
// Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled).
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $submission->id,
- 'stage_identifier' => $stage_identifier,
- );
- $feedback = feedback::find($feedback_params);
+ 'stage_identifier' => $stageidentifier,
+ ];
+ $feedback = feedback::find($feedbackparams);
if (!$this->coursework->allocation_enabled() && !empty($feedback)) {
- // Was this user the one who last graded this submission if not then user cannot grade
- if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $PAGE->context) && !has_capability('mod/coursework:administergrades', $PAGE->context))
+ // Was this user the one who last graded this submission if not then user cannot grade
+ if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $PAGE->context) && !has_capability('mod/coursework:administergrades', $PAGE->context)) {
return get_string('nopermissiontoeditgrade', 'coursework');
+ }
}
$ability = new ability(user::find($USER), $this->coursework);
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $submission->id,
- 'stage_identifier' => $stage_identifier,
- );
- $feedback = feedback::find($feedback_params);
+ 'stage_identifier' => $stageidentifier,
+ ];
+ $feedback = feedback::find($feedbackparams);
//if (!$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework');
//does a feedback exist for this stage
if (empty($feedback)) {
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $submissionid,
'assessorid' => $USER->id,
- 'stage_identifier' => $stage_identifier,
- );
- $new_feedback = feedback::build($feedback_params);
+ 'stage_identifier' => $stageidentifier,
+ ];
+ $newfeedback = feedback::build($feedbackparams);
// This is a new feedback check it against the new ability checks
- if (!$ability->can('new', $new_feedback)) return get_string('nopermissiontogradesubmission', 'coursework');
+ if (!$ability->can('new', $newfeedback)) {
+ return get_string('nopermissiontogradesubmission', 'coursework');
+ }
} else {
// This is a new feedback check it against the edit ability checks
- if (!$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework');
+ if (!$ability->can('edit', $feedback)) {
+ return get_string('nopermissiontoeditgrade', 'coursework');
+ }
}
} else {
@@ -237,7 +251,7 @@ function value_in_rubric($criteria, $value) {
* @param $csv_cells
*
*/
- function get_rubrics($coursework, $csv_cells) {
+ function get_rubrics($coursework, $csvcells) {
if ($coursework->is_using_rubric()) {
@@ -251,16 +265,16 @@ function get_rubrics($coursework, $csv_cells) {
}
// Find out the position of singlegrade
- $position = array_search('singlegrade', $csv_cells);
+ $position = array_search('singlegrade', $csvcells);
// Get all data from the position of the singlegrade to the length of rubricheaders
- // $csv_cells = array_splice($csv_cells,5, 1, $rubricheaders);
+ // $csv_cells = array_splice($csv_cells,5, 1, $rubricheaders);
- $start_cells = array_slice($csv_cells, 0, $position, true);
- $end_cells = array_slice($csv_cells, $position + 1, count($csv_cells), true);
+ $startcells = array_slice($csvcells, 0, $position, true);
+ $endcells = array_slice($csvcells, $position + 1, count($csvcells), true);
- $cells = array_merge($start_cells, $rubricheaders);
+ $cells = array_merge($startcells, $rubricheaders);
- $cells = array_merge($cells, $end_cells);
+ $cells = array_merge($cells, $endcells);
}
diff --git a/classes/export/csv/cells/stages_cell.php b/classes/export/csv/cells/stages_cell.php
index aa595648..b444e357 100644
--- a/classes/export/csv/cells/stages_cell.php
+++ b/classes/export/csv/cells/stages_cell.php
@@ -34,13 +34,13 @@ class stages_cell extends cell_base {
* @param $stage_identifier
* @return array
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
global $DB;
$timecreated = 0;
$timemodified = 0;
- $feedback = $DB->get_record('coursework_feedbacks', array('submissionid' => $submission->id, 'assessorid' => 0));
+ $feedback = $DB->get_record('coursework_feedbacks', ['submissionid' => $submission->id, 'assessorid' => 0]);
if ($feedback) {
$timecreated = $feedback->timecreated;
$timemodified = $feedback->timemodified;
@@ -49,11 +49,11 @@ public function get_cell($submission, $student, $stage_identifier) {
$gradedata = [];
// go through each stage and get a grade, if grade not present then put a placeholder
for ($i = 1; $i <= $this->stages; $i++) {
- $stage_identifier = 'assessor_'.$i;
- $grade = $submission->get_assessor_feedback_by_stage($stage_identifier);
+ $stageidentifier = 'assessor_'.$i;
+ $grade = $submission->get_assessor_feedback_by_stage($stageidentifier);
if ($this->coursework->allocation_enabled()) {
- $allocation = $submission->get_assessor_allocation_by_stage($stage_identifier);
+ $allocation = $submission->get_assessor_allocation_by_stage($stageidentifier);
if ($allocation) {
$gradedata[] = $this->get_assessor_name($allocation->assessorid);
$gradedata[] = $this->get_assessor_username($allocation->assessorid);
diff --git a/classes/export/csv/cells/submissiondate_cell.php b/classes/export/csv/cells/submissiondate_cell.php
index cf173e10..a047e656 100644
--- a/classes/export/csv/cells/submissiondate_cell.php
+++ b/classes/export/csv/cells/submissiondate_cell.php
@@ -34,7 +34,7 @@ class submissiondate_cell extends cell_base {
* @param $stage_identifier
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
return userdate($submission->time_submitted(), $this->dateformat);
}
diff --git a/classes/export/csv/cells/submissionfileid_cell.php b/classes/export/csv/cells/submissionfileid_cell.php
index 36b014b2..ca4230e2 100644
--- a/classes/export/csv/cells/submissionfileid_cell.php
+++ b/classes/export/csv/cells/submissionfileid_cell.php
@@ -33,7 +33,7 @@ class submissionfileid_cell extends cell_base {
* @param $stage_identifier
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
return $this->coursework->get_username_hash($submission->allocatableid);
}
@@ -46,14 +46,14 @@ public function get_header($stage) {
return get_string('submissionfileid', 'coursework');
}
- public function validate_cell($value, $submissionid, $stage_dentifier='', $uploadedgradecells = []) {
+ public function validate_cell($value, $submissionid, $stagedentifier='', $uploadedgradecells = []) {
global $DB;
if (empty($value)) {
return 'No submission hash value entered';
}
- $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid));
+ $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]);
$submission = \mod_coursework\models\submission::find($subdbrecord);
diff --git a/classes/export/csv/cells/submissionid_cell.php b/classes/export/csv/cells/submissionid_cell.php
index 228cae80..916c29de 100644
--- a/classes/export/csv/cells/submissionid_cell.php
+++ b/classes/export/csv/cells/submissionid_cell.php
@@ -33,7 +33,7 @@ class submissionid_cell extends cell_base {
* @param $stage_identifier
* @return mixed
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
return $submission->id;
}
@@ -46,9 +46,9 @@ public function get_header($stage) {
return get_string('submissionid', 'coursework');
}
- public function validate_cell($value, $submissionid, $stage_dentifier = '', $uploadedgradecells = []) {
+ public function validate_cell($value, $submissionid, $stagedentifier = '', $uploadedgradecells = []) {
global $DB;
- return $DB->record_exists('coursework_submissions', array('id' => $submissionid, 'courseworkid' => $this->coursework->id()))
+ return $DB->record_exists('coursework_submissions', ['id' => $submissionid, 'courseworkid' => $this->coursework->id()])
? true
: get_string('submissionnotfoundincoursework', 'coursework');
}
diff --git a/classes/export/csv/cells/submissiontime_cell.php b/classes/export/csv/cells/submissiontime_cell.php
index a7452bdf..c30e93fb 100644
--- a/classes/export/csv/cells/submissiontime_cell.php
+++ b/classes/export/csv/cells/submissiontime_cell.php
@@ -33,8 +33,8 @@ class submissiontime_cell extends cell_base {
* @param $stage_identifier
* @return string
*/
- public function get_cell($submission, $student, $stage_identifier) {
- return $this->submission_time($submission);
+ public function get_cell($submission, $student, $stageidentifier) {
+ return $this->submission_time($submission);
}
/**
diff --git a/classes/export/csv/cells/username_cell.php b/classes/export/csv/cells/username_cell.php
index fa4ce0cc..c444c7b2 100644
--- a/classes/export/csv/cells/username_cell.php
+++ b/classes/export/csv/cells/username_cell.php
@@ -35,7 +35,7 @@ class username_cell extends cell_base {
* @return string
* @throws \coding_exception
*/
- public function get_cell($submission, $student, $stage_identifier) {
+ public function get_cell($submission, $student, $stageidentifier) {
if ($this->can_view_hidden() || $submission->is_published()) {
$username = $student->username;
diff --git a/classes/export/grading_sheet.php b/classes/export/grading_sheet.php
index d3ce543d..c4302413 100644
--- a/classes/export/grading_sheet.php
+++ b/classes/export/grading_sheet.php
@@ -29,13 +29,13 @@
class grading_sheet extends csv {
- public function get_submissions($groupid = null, $selected_submission_ids = '') {
+ public function get_submissions($groupid = null, $selectedsubmissionids = '') {
global $PAGE, $USER;
- $params = array(
- 'courseworkid' => $this->coursework->id
- );
+ $params = [
+ 'courseworkid' => $this->coursework->id,
+ ];
- $submissions = submission::find_all($params);
+ $submissions = submission::find_all($params);
// remove unfinalised submissions
foreach ($submissions as $submission) {
@@ -55,47 +55,47 @@ public function get_submissions($groupid = null, $selected_submission_ids = '')
/**
* @var submission[] $submissions
*/
- foreach ($submissions as $submission) {
- $stage_identifiers = [];
- // remove all submissions that a user is not supposed to see
-
- // double marking not allocated
- $stages = $this->coursework->get_max_markers();
- if ($stages > 1 && !$this->coursework->allocation_enabled() && !has_capability('mod/coursework:addagreedgrade', $PAGE->context)) {
- // if samplings enabled, work out how many per submission
- if ($this->coursework->sampling_enabled()) {
- $stage_identifiers[] = 'assessor_1'; // always have at least one assessor
- // check how many other assessors for this submission
- $in_sample = $submission->get_submissions_in_sample();
- foreach ($in_sample as $i) {
- $stage_identifiers[] = $i->stage_identifier;
- }
- } else { // if sampling not enabled, everyone is marked in all stages
- for ($i = 1; $i <= $stages; $i++) {
- $stage_identifiers[] = 'assessor_' . $i;
- }
- }
- // check if any of the submissions still requires marking
- for ($i = 0; $i < count($stage_identifiers); $i++) {
- $feedback = $submission->get_assessor_feedback_by_stage($stage_identifiers[$i]);
- // if no feedback or feedback belongs to current user don't remove submission
- if (!$feedback || $feedback->assessorid == $USER->id) {
- break;
- } else if ($i + 1 < count($stage_identifiers)) {
- continue;
- }
- // if the last submission was already marked remove it from the array
- unset($submissions[$submission->id]);
- }
- }
-
- // TODO - decide if already marked submissions should be displayed in single marking
- // if not marked by a user than dont display it as it would allow them to edit it??
- // || $submission->get_state() == submission::FINAL_GRADED
- if (!$ability->can('show', $submission)
+ foreach ($submissions as $submission) {
+ $stageidentifiers = [];
+ // remove all submissions that a user is not supposed to see
+
+ // double marking not allocated
+ $stages = $this->coursework->get_max_markers();
+ if ($stages > 1 && !$this->coursework->allocation_enabled() && !has_capability('mod/coursework:addagreedgrade', $PAGE->context)) {
+ // if samplings enabled, work out how many per submission
+ if ($this->coursework->sampling_enabled()) {
+ $stageidentifiers[] = 'assessor_1'; // always have at least one assessor
+ // check how many other assessors for this submission
+ $insample = $submission->get_submissions_in_sample();
+ foreach ($insample as $i) {
+ $stageidentifiers[] = $i->stage_identifier;
+ }
+ } else { // if sampling not enabled, everyone is marked in all stages
+ for ($i = 1; $i <= $stages; $i++) {
+ $stageidentifiers[] = 'assessor_' . $i;
+ }
+ }
+ // check if any of the submissions still requires marking
+ for ($i = 0; $i < count($stageidentifiers); $i++) {
+ $feedback = $submission->get_assessor_feedback_by_stage($stageidentifiers[$i]);
+ // if no feedback or feedback belongs to current user don't remove submission
+ if (!$feedback || $feedback->assessorid == $USER->id) {
+ break;
+ } else if ($i + 1 < count($stageidentifiers)) {
+ continue;
+ }
+ // if the last submission was already marked remove it from the array
+ unset($submissions[$submission->id]);
+ }
+ }
+
+ // TODO - decide if already marked submissions should be displayed in single marking
+ // if not marked by a user than dont display it as it would allow them to edit it??
+ // || $submission->get_state() == submission::FINAL_GRADED
+ if (!$ability->can('show', $submission)
|| ($stages == 1 && !has_capability('mod/coursework:addinitialgrade', $PAGE->context))
|| ($this->coursework->allocation_enabled() && !$this->coursework
- ->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable())
+ ->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable())
&& (has_capability('mod/coursework:addinitialgrade', $PAGE->context) && !has_capability('mod/coursework:addagreedgrade', $PAGE->context)))
|| ($stages > 1 && $this->coursework->sampling_enabled()
&& !$submission->sampled_feedback_exists()
@@ -105,12 +105,12 @@ public function get_submissions($groupid = null, $selected_submission_ids = '')
&& (has_capability('mod/coursework:addagreedgrade', $PAGE->context)
|| has_capability('mod/coursework:editagreedgrade', $PAGE->context)))
|| ((has_capability('mod/coursework:addagreedgrade', $PAGE->context) && $submission->get_state() < submission::FULLY_GRADED ))
- ) {
- unset($submissions[$submission->id]);
- continue;
- }
- }
- }
+ ) {
+ unset($submissions[$submission->id]);
+ continue;
+ }
+ }
+ }
return $submissions;
}
@@ -122,11 +122,11 @@ public function get_submissions($groupid = null, $selected_submission_ids = '')
*/
public function add_csv_data($submission) {
- $csv_data = [];
+ $csvdata = [];
// groups
if ($this->coursework->is_configured_to_have_group_submissions()) {
$group = \mod_coursework\models\group::find($submission->allocatableid);
- $csv_data[] = $this->add_cells_to_array($submission, $group, $this->csv_cells);
+ $csvdata[] = $this->add_cells_to_array($submission, $group, $this->csv_cells);
} else {
// students
@@ -134,11 +134,11 @@ public function add_csv_data($submission) {
foreach ($students as $student) {
$student = \mod_coursework\models\user::find($student);
- $csv_data[] = $this->add_cells_to_array($submission, $student, $this->csv_cells);
+ $csvdata[] = $this->add_cells_to_array($submission, $student, $this->csv_cells);
}
}
- return $csv_data;
+ return $csvdata;
}
/**
@@ -151,50 +151,50 @@ public static function cells_array($coursework) {
global $PAGE;
// headers and data for csv
- $csv_cells = array('submissionid', 'submissionfileid');
+ $csvcells = ['submissionid', 'submissionfileid'];
if ($coursework->is_configured_to_have_group_submissions()) {
- $csv_cells[] = 'group';
+ $csvcells[] = 'group';
} else {
- $csv_cells[] = 'name';
- $csv_cells[] = 'username';
- $csv_cells[] = 'idnumber';
- $csv_cells[] = 'email';
+ $csvcells[] = 'name';
+ $csvcells[] = 'username';
+ $csvcells[] = 'idnumber';
+ $csvcells[] = 'email';
}
- $csv_cells[] = 'submissiontime';
+ $csvcells[] = 'submissiontime';
// based on capabilities decide what view display - singlegrade or multiplegrade
if ((has_capability('mod/coursework:addagreedgrade', $PAGE->context) || has_capability('mod/coursework:administergrades', $PAGE->context))
&& $coursework->get_max_markers() > 1 ) {
- for ($i = 1; $i <= $coursework->get_max_markers(); $i++) {
- // extra column with allocated assessor name
- if ($coursework->allocation_enabled() && $coursework->get_max_markers() > 1
+ for ($i = 1; $i <= $coursework->get_max_markers(); $i++) {
+ // extra column with allocated assessor name
+ if ($coursework->allocation_enabled() && $coursework->get_max_markers() > 1
&& (has_capability('mod/coursework:addinitialgrade', $PAGE->context)
|| has_capability('mod/coursework:editinitialgrade', $PAGE->context))) {
- $csv_cells[] = 'assessor' . $i;
- }
- $csv_cells[] = 'assessorgrade'.$i;
- $csv_cells[] = 'assessorfeedback'.$i;
+ $csvcells[] = 'assessor' . $i;
+ }
+ $csvcells[] = 'assessorgrade'.$i;
+ $csvcells[] = 'assessorfeedback'.$i;
}
- $csv_cells[] = 'agreedgrade';
- $csv_cells[] = 'agreedfeedback';
+ $csvcells[] = 'agreedgrade';
+ $csvcells[] = 'agreedfeedback';
} else if (has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && $coursework->get_max_markers() > 1) {
- $csv_cells[] = 'singlegrade';
- $csv_cells[] = 'feedbackcomments';
+ $csvcells[] = 'singlegrade';
+ $csvcells[] = 'feedbackcomments';
// Other grades
- $csv_cells[] = 'otherassessors';
+ $csvcells[] = 'otherassessors';
- $csv_cells[] = 'agreedgrade';
- $csv_cells[] = 'agreedfeedback';
+ $csvcells[] = 'agreedgrade';
+ $csvcells[] = 'agreedfeedback';
} else if (has_capability('mod/coursework:addinitialgrade', $PAGE->context)
|| has_capability('mod/coursework:administergrades', $PAGE->context)) {
- // if (!$coursework->is_using_rubric()) {
- $csv_cells[] = 'singlegrade';
- /* } else {
+ // if (!$coursework->is_using_rubric()) {
+ $csvcells[] = 'singlegrade';
+ /* } else {
$criterias = $coursework->get_rubric_criteria();
@@ -204,11 +204,11 @@ public static function cells_array($coursework) {
}
}
- */
- $csv_cells[] = 'feedbackcomments';
+ */
+ $csvcells[] = 'feedbackcomments';
}
- return $csv_cells;
+ return $csvcells;
}
}
diff --git a/classes/export/import.php b/classes/export/import.php
index bc8e10e7..d0c6e208 100644
--- a/classes/export/import.php
+++ b/classes/export/import.php
@@ -49,7 +49,7 @@ public function validate_submissionfileid() {
* @throws \coding_exception
* @throws \moodle_exception
*/
- public function validate_csv($content, $encoding, $delimeter, $csv_cells) {
+ public function validate_csv($content, $encoding, $delimeter, $csvcells) {
global $DB, $USER;
@@ -80,7 +80,7 @@ public function validate_csv($content, $encoding, $delimeter, $csv_cells) {
while ($line = $csvreader->next()) {
- $csv = $this->remove_other_assessors_grade($csv_cells, $line);
+ $csv = $this->remove_other_assessors_grade($csvcells, $line);
$cells = $csv;
@@ -90,7 +90,9 @@ public function validate_csv($content, $encoding, $delimeter, $csv_cells) {
$submissionid = false;
// if the csv headers count is different than expected return error
- if ((!$this->coursework->is_using_rubric() && count($line) != count($cells)) || ($this->coursework->is_using_rubric() && !$this->rubric_count_correct($cells, $line))) {$errors = get_string('incorrectfileformat', 'coursework'); break;}
+ if ((!$this->coursework->is_using_rubric() && count($line) != count($cells)) || ($this->coursework->is_using_rubric() && !$this->rubric_count_correct($cells, $line))) {
+ $errors = get_string('incorrectfileformat', 'coursework'); break;
+ }
$offset = 0;
@@ -100,7 +102,7 @@ public function validate_csv($content, $encoding, $delimeter, $csv_cells) {
for ($z = 0; $z < count($line); $z++) {
$value = $line[$z];
- $stage_identifier = $this->get_stage_identifier($submissionid, $cells[$i]);
+ $stageidentifier = $this->get_stage_identifier($submissionid, $cells[$i]);
// remove numbers from cell names so they can be dynamically validated
if (substr($cells[$i], 0, 8) == 'assessor') {
@@ -115,7 +117,9 @@ public function validate_csv($content, $encoding, $delimeter, $csv_cells) {
$submissionid = $value;
}
- if (empty($submissionid)) $errors[$s][] = get_string('emptysubmissionid', 'coursework');
+ if (empty($submissionid)) {
+ $errors[$s][] = get_string('emptysubmissionid', 'coursework');
+ }
// Offsets the position of that we extract the data from $line based on data that has been extracted before
@@ -132,24 +136,24 @@ public function validate_csv($content, $encoding, $delimeter, $csv_cells) {
$rubriclinedata = array_slice($line, $position + $offset, count($rubricheaders), true);
// Pass the rubric data in
- $result = $cell->validate_cell($rubriclinedata, $submissionid, $stage_identifier, $uploadedgradecells);
+ $result = $cell->validate_cell($rubriclinedata, $submissionid, $stageidentifier, $uploadedgradecells);
$z = $z + count($rubricheaders) - 1;
- $offset = $offset + count($rubricheaders)-1;
+ $offset = $offset + count($rubricheaders) - 1;
} else {
- $result = $cell->validate_cell($value, $submissionid, $stage_identifier, $uploadedgradecells);
+ $result = $cell->validate_cell($value, $submissionid, $stageidentifier, $uploadedgradecells);
}
- if ($result !== true) {
- $errors[$s] = $result;
- break; // Go to next line on error
- } else if ($cells[$i] == "singlegrade" || $cells[$i] == "assessorgrade" || $cells[$i] == "agreedgrade" && !empty($value)) {
+ if ($result !== true) {
+ $errors[$s] = $result;
+ break; // Go to next line on error
+ } else if ($cells[$i] == "singlegrade" || $cells[$i] == "assessorgrade" || $cells[$i] == "agreedgrade" && !empty($value)) {
- $uploadedgradecells[] = $stage_identifier;
+ $uploadedgradecells[] = $stageidentifier;
- }
- $i++;
+ }
+ $i++;
}
$s++;
}
@@ -162,9 +166,10 @@ function rubric_count_correct($csvheader, $linefromimportedcsv) {
// get criteria of rubrics and match it to grade cells
if ($this->coursework->is_using_rubric()) {
- $types = array("singlegrade", "assessorgrade");
+ $types = ["singlegrade", "assessorgrade"];
- if ($this->coursework->finalstagegrading == 0 ) $types[] = "agreedgrade";
+ if ($this->coursework->finalstagegrading == 0 ) { $types[] = "agreedgrade";
+ }
foreach ($types as $type) {
@@ -179,7 +184,9 @@ function rubric_count_correct($csvheader, $linefromimportedcsv) {
if (strpos($ch, $type) !== false) {
- if (empty($typepositions)) $typepositions = [];
+ if (empty($typepositions)) {
+ $typepositions = [];
+ }
$typefound = true;
$typepositions[] = $i;
@@ -195,7 +202,7 @@ function rubric_count_correct($csvheader, $linefromimportedcsv) {
$offset = 0;
foreach ($typepositions as $position) {
- //if ($position = array_search($type, $csvheader)) {
+ // if ($position = array_search($type, $csvheader)) {
$class = "mod_coursework\\export\\csv\\cells\\{$type}_cell";
$cell = new $class($this->coursework);
@@ -203,10 +210,10 @@ function rubric_count_correct($csvheader, $linefromimportedcsv) {
unset($csvheader[$position + $offset]);
unset($linefromimportedcsv[$position + $offset]);
-// if ($type == 'agreedgrade' && $this->coursework->finalstagegrading == 0) {
+ // if ($type == 'agreedgrade' && $this->coursework->finalstagegrading == 0) {
array_splice($csvheader, $position + $offset, 0, array_keys($headers));
- array_splice($linefromimportedcsv, $position + $offset, 0, array(''));
-// }
+ array_splice($linefromimportedcsv, $position + $offset, 0, ['']);
+ // }
$offset = $offset + count($headers) - 1;
$expectedsize = (int)count($csvheader);
$actualsize = (int)count($linefromimportedcsv);
@@ -226,7 +233,7 @@ function get_rubric_headers($csvheader) {
// get criteria of rubrics and match it to grade cells
if ($this->coursework->is_using_rubric()) {
- $types = array("singlegrade", "assessorgrade");
+ $types = ["singlegrade", "assessorgrade"];
foreach ($types as $type) {
@@ -259,7 +266,7 @@ function get_rubric_headers($csvheader) {
* @return array|bool
* @throws \moodle_exception
*/
- public function process_csv($content, $encoding, $delimiter, $csv_cells, $processingresults) {
+ public function process_csv($content, $encoding, $delimiter, $csvcells, $processingresults) {
global $DB, $PAGE, $USER;
@@ -295,7 +302,7 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces
continue;
}
- $csv = $this->remove_other_assessors_grade($csv_cells, $line);
+ $csv = $this->remove_other_assessors_grade($csvcells, $line);
// Gets the headers that should be being used in the uploaded csv
//$cells = $this->get_rubric_headers($csv);
$cells = $csv;
@@ -321,12 +328,14 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces
}
// Save the value into the csvline with the relevant pointer
- if (isset($cells[$i])) $csvline[$cells[$i]] = $value;
+ if (isset($cells[$i])) {
+ $csvline[$cells[$i]] = $value;
+ }
$i++;
}
- $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid));
+ $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]);
$submission = \mod_coursework\models\submission::find($subdbrecord);
// Is this submission graded? if yes did this user grade it?
@@ -344,9 +353,9 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces
foreach ($csvline as $k => $v) {
if (substr($k, 0, 13) == 'assessorgrade' || substr($k, 0, 11) == 'singlegrade') {
- $stages[$k] = $this->get_stage_identifier($csvline['submissionid'], $k);
+ $stages[$k] = $this->get_stage_identifier($csvline['submissionid'], $k);
} else if (substr($k, 0, 11) == 'agreedgrade') {
- $stages[$k] = 'final_agreed_1';
+ $stages[$k] = 'final_agreed_1';
}
}
}
@@ -362,10 +371,12 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces
foreach ($stages as $k => $stage) {
- // When allocation is enabled
+ // When allocation is enabled
if (has_capability('mod/coursework:administergrades', $PAGE->context) && $coursework->allocation_enabled() && $stage != 'final_agreed_1' && $coursework->has_multiple_markers() == true) {
$rubricoffset += 1;
- if ($a == 1) $rubricoffsetstart += 1;
+ if ($a == 1) {
+ $rubricoffsetstart += 1;
+ }
}
// check for initial grade capability otherwise ignore it
if ($stage != 'final_agreed_1' && (!has_capability('mod/coursework:addinitialgrade', $PAGE->context)) &&
@@ -387,8 +398,8 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces
// if sampling enabled check if this grade should be included in sample
if ($this->coursework->sampling_enabled() && $stage != 'final_agreed_1') {
- $in_sample = $submission->get_submissions_in_sample_by_stage($stage);
- if (!$in_sample && $stage != 'assessor_1') {
+ $insample = $submission->get_submissions_in_sample_by_stage($stage);
+ if (!$insample && $stage != 'assessor_1') {
continue;
}
}
@@ -407,7 +418,7 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces
$criteriacount = 0;
- $numberofrubrics = count($criterias) * 2;
+ $numberofrubrics = count($criterias) * 2;
// If the stage is final agrade we need to make sure the offset is set to the position of the
//agreed grades in the csv, this is needed as some users will only have agreed grade capability
@@ -418,7 +429,9 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces
$rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier);
- if ($coursework->allocation_enabled()) $rubricoffset += 1;
+ if ($coursework->allocation_enabled()) {
+ $rubricoffset += 1;
+ }
$rubricdata = array_slice($line, $rubricoffset, $numberofrubrics);
$feedbackdata = array_slice($line, $rubricoffset + $numberofrubrics, 1);
@@ -436,62 +449,64 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces
$rubricoffset = $rubricoffset + $numberofrubrics + 1;
}
- $arrayvalues = array_filter($rubricdata);
+ $arrayvalues = array_filter($rubricdata);
- if (!empty($arrayvalues)) {
+ if (!empty($arrayvalues)) {
- //for ( $critidx < $numberofrubrics; ) {
- $critidx = 0;
- // This assumes that the data in the csv is in the correct criteria order.....it should be
- foreach ($criterias as $c) {
- $criteriagrade = [];
+ //for ( $critidx < $numberofrubrics; ) {
+ $critidx = 0;
+ // This assumes that the data in the csv is in the correct criteria order.....it should be
+ foreach ($criterias as $c) {
+ $criteriagrade = [];
- // We need to get the levelid for the value that the criteria has been given
+ // We need to get the levelid for the value that the criteria has been given
- $levelid = $this->get_value_rubric_levelid($c, $rubricdata[$critidx]);
+ $levelid = $this->get_value_rubric_levelid($c, $rubricdata[$critidx]);
- $criteriagrade['levelid'] = $levelid;
- $criteriagrade['remark'] = $rubricdata[$critidx + 1];
+ $criteriagrade['levelid'] = $levelid;
+ $criteriagrade['remark'] = $rubricdata[$critidx + 1];
- $criteriagradedata['criteria'][$c['id']] = $criteriagrade;
+ $criteriagradedata['criteria'][$c['id']] = $criteriagrade;
- $critidx = $critidx + 2;
+ $critidx = $critidx + 2;
- }
- } else {
- $criteriagradedata = false;
}
+ } else {
+ $criteriagradedata = false;
+ }
- // Need to decide where the grade instance submit and get grade should be put as in order
+ // Need to decide where the grade instance submit and get grade should be put as in order
- // Pass the criteria data into the csvline position for the grade data so we can generate a grade
- $csvline[$gradepointer] = $criteriagradedata;
+ // Pass the criteria data into the csvline position for the grade data so we can generate a grade
+ $csvline[$gradepointer] = $criteriagradedata;
- // In case there is another rubric to be extracted from the csv set the new value of the rubric offset
+ // In case there is another rubric to be extracted from the csv set the new value of the rubric offset
- } else if ($coursework->is_using_rubric() && ($stage == 'final_agreed_1' && $this->coursework->finalstagegrading == 1)) {
+ } else if ($coursework->is_using_rubric() && ($stage == 'final_agreed_1' && $this->coursework->finalstagegrading == 1)) {
- if (!isset($numberofrubrics)) {
+ if (!isset($numberofrubrics)) {
- $criterias = $this->coursework->get_rubric_criteria();
+ $criterias = $this->coursework->get_rubric_criteria();
- $numberofrubrics = count($criterias) * 2;
+ $numberofrubrics = count($criterias) * 2;
- }
- $stagemultiplier = $numberofstages - 1;
+ }
+ $stagemultiplier = $numberofstages - 1;
- // The calculation below finds the position of the agreed grades in the uploaded csv
+ // The calculation below finds the position of the agreed grades in the uploaded csv
- $rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier);
+ $rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier);
- if ($coursework->allocation_enabled()) $rubricoffset += 1;
+ if ($coursework->allocation_enabled()) {
+ $rubricoffset += 1;
+ }
- $gradearrvalue = array_slice($line, $rubricoffset, 2);
+ $gradearrvalue = array_slice($line, $rubricoffset, 2);
- $csvline[$gradepointer] = $gradearrvalue[0];
- $csvline[$feedbackpointer] = $gradearrvalue[1];
+ $csvline[$gradepointer] = $gradearrvalue[0];
+ $csvline[$feedbackpointer] = $gradearrvalue[1];
- }
+ }
// don't create/update feedback if grade is empty
if (!empty($csvline[$gradepointer])) {
@@ -561,51 +576,51 @@ function get_value_rubric_levelid($criteria, $value) {
* @param $stage_identifier
* @return bool|int
*/
- public function add_grade($submissionid, $grade, $feedback, $stage_identifier, $uses_rubric=false) {
+ public function add_grade($submissionid, $grade, $feedback, $stageidentifier, $usesrubric=false) {
global $DB, $USER;
// workout markernumber
- if ($stage_identifier == 'assessor_1') {
- // assessor_1 is always marker 1
+ if ($stageidentifier == 'assessor_1') {
+ // assessor_1 is always marker 1
$markernumber = 1;
} else {
// get all feedbacks and add 1
- $feedbacks = $DB->count_records('coursework_feedbacks', array('submissionid' => $submissionid));
+ $feedbacks = $DB->count_records('coursework_feedbacks', ['submissionid' => $submissionid]);
$markernumber = $feedbacks + 1;
}
$gradejudge = new grade_judge($this->coursework);
$grade = $gradejudge->get_grade($grade);
- $add_grade = new \stdClass();
- $add_grade->id = '';
- $add_grade->submissionid = $submissionid;
- $add_grade->assessorid = $USER->id;
- $add_grade->timecreated = time();
- $add_grade->timemodified = time();
+ $addgrade = new \stdClass();
+ $addgrade->id = '';
+ $addgrade->submissionid = $submissionid;
+ $addgrade->assessorid = $USER->id;
+ $addgrade->timecreated = time();
+ $addgrade->timemodified = time();
// We cant save the grade if this coursework uses rubrics as the grade has not been generated and the grade var contains
// Criteria that will be used to genenrate the grade. We need the feedback id to do this so we need to make the feedback
// First
- $add_grade->grade = (!$uses_rubric) ? $grade : null;
- $add_grade->feedbackcomment = $feedback;
- $add_grade->lasteditedbyuser = $USER->id;
- $add_grade->markernumber = $markernumber;
- $add_grade->stage_identifier = $stage_identifier;
- $add_grade->finalised = 1;
+ $addgrade->grade = (!$usesrubric) ? $grade : null;
+ $addgrade->feedbackcomment = $feedback;
+ $addgrade->lasteditedbyuser = $USER->id;
+ $addgrade->markernumber = $markernumber;
+ $addgrade->stage_identifier = $stageidentifier;
+ $addgrade->finalised = 1;
- $feedbackid = $DB->insert_record('coursework_feedbacks', $add_grade, true);
+ $feedbackid = $DB->insert_record('coursework_feedbacks', $addgrade, true);
- if ($uses_rubric) {
+ if ($usesrubric) {
$controller = $this->coursework->get_advanced_grading_active_controller();
// Find out how many criteria there are
$gradinginstance = $controller->get_or_create_instance(0, $USER->id, $feedbackid);
$rubricgrade = $gradinginstance->submit_and_get_grade($grade, $feedbackid);
- $add_grade->id = $feedbackid;
- $add_grade->grade = $rubricgrade;
+ $addgrade->id = $feedbackid;
+ $addgrade->grade = $rubricgrade;
- $DB->update_record('coursework_feedbacks', $add_grade);
+ $DB->update_record('coursework_feedbacks', $addgrade);
}
@@ -619,11 +634,11 @@ public function add_grade($submissionid, $grade, $feedback, $stage_identifier, $
* @param $stage_identifier
* @return mixed
*/
- public function get_coursework_feedback_id($submissionid, $stage_identifier) {
+ public function get_coursework_feedback_id($submissionid, $stageidentifier) {
global $DB;
- $record = $DB->get_record('coursework_feedbacks', array('submissionid' => $submissionid,
- 'stage_identifier' => $stage_identifier),
+ $record = $DB->get_record('coursework_feedbacks', ['submissionid' => $submissionid,
+ 'stage_identifier' => $stageidentifier],
'id');
return $record->id;
@@ -637,10 +652,10 @@ public function get_coursework_feedback_id($submissionid, $stage_identifier) {
* @param $feedback
* @return bool]
*/
- public function edit_grade($cwfeedbackid, $grade, $feedback, $uses_rubric=false) {
+ public function edit_grade($cwfeedbackid, $grade, $feedback, $usesrubric=false) {
global $DB, $USER;
- if (!$uses_rubric) {
+ if (!$usesrubric) {
$gradejudge = new grade_judge($this->coursework);
$grade = $gradejudge->get_grade($grade);
} else {
@@ -655,24 +670,24 @@ public function edit_grade($cwfeedbackid, $grade, $feedback, $uses_rubric=false)
$update = false;
// update record only if the value of grade or feedback is changed
- $current_feedback = $DB->get_record('coursework_feedbacks', array('id' => $cwfeedbackid));
+ $currentfeedback = $DB->get_record('coursework_feedbacks', ['id' => $cwfeedbackid]);
- if ($current_feedback->grade != $grade || strip_tags($current_feedback->feedbackcomment) != $feedback) {
+ if ($currentfeedback->grade != $grade || strip_tags($currentfeedback->feedbackcomment) != $feedback) {
- $edit_grade = new \stdClass();
- $edit_grade->id = $cwfeedbackid;
- $edit_grade->timemodified = time();
- $edit_grade->grade = $grade;
- $edit_grade->feedbackcomment = $feedback;
- $edit_grade->lasteditedbyuser = $USER->id;
- $edit_grade->finalised = 1;
+ $editgrade = new \stdClass();
+ $editgrade->id = $cwfeedbackid;
+ $editgrade->timemodified = time();
+ $editgrade->grade = $grade;
+ $editgrade->feedbackcomment = $feedback;
+ $editgrade->lasteditedbyuser = $USER->id;
+ $editgrade->finalised = 1;
- $update = $DB->update_record('coursework_feedbacks', $edit_grade);
+ $update = $DB->update_record('coursework_feedbacks', $editgrade);
// if record updated and coursework has automatic grading enabled update agreedgrade
- if ($update && $this->coursework->automaticagreement_enabled()) {
- $this->auto_agreement($cwfeedbackid);
- }
+ if ($update && $this->coursework->automaticagreement_enabled()) {
+ $this->auto_agreement($cwfeedbackid);
+ }
}
return $update;
@@ -688,31 +703,31 @@ public function edit_grade($cwfeedbackid, $grade, $feedback, $uses_rubric=false)
* @throws \dml_missing_record_exception
* @throws \dml_multiple_records_exception
*/
- public function get_stage_identifier($submissionid, $cell_identifier) {
+ public function get_stage_identifier($submissionid, $cellidentifier) {
global $DB, $USER;
- $submission = $DB->get_record('coursework_submissions', array('id' => $submissionid));
+ $submission = $DB->get_record('coursework_submissions', ['id' => $submissionid]);
$submission = \mod_coursework\models\submission::find($submission);
// single marked - singlegrade - allocated/notallocated
- $stage_identifier = 'assessor_1';
+ $stageidentifier = 'assessor_1';
//double marked - singlegrade - allocated
- if ($this->coursework->get_max_markers() > 1 && ($cell_identifier == 'singlegrade' || $cell_identifier == 'feedbackcomments')
+ if ($this->coursework->get_max_markers() > 1 && ($cellidentifier == 'singlegrade' || $cellidentifier == 'feedbackcomments')
&& $this->coursework->allocation_enabled()) {
$dbrecord = $DB->get_record('coursework_allocation_pairs',
- array('courseworkid' => $this->coursework->id,
+ ['courseworkid' => $this->coursework->id,
'allocatableid' => $submission->allocatableid,
'allocatabletype' => $submission->allocatabletype,
- 'assessorid' => $USER->id
- ));
- $stage_identifier = $dbrecord->stage_identifier;
+ 'assessorid' => $USER->id,
+ ]);
+ $stageidentifier = $dbrecord->stage_identifier;
}
//double marked - singlegrade - notallocated
- if ($this->coursework->get_max_markers() > 1 && ($cell_identifier == 'singlegrade' || $cell_identifier == 'feedbackcomments')
+ if ($this->coursework->get_max_markers() > 1 && ($cellidentifier == 'singlegrade' || $cellidentifier == 'feedbackcomments')
&& !$this->coursework->allocation_enabled()) {
// if any part of initial submission graded by the user then get stage_identifier from feedback
@@ -723,7 +738,7 @@ public function get_stage_identifier($submissionid, $cell_identifier) {
AND stage_identifier <> 'final_agreed_1'";
$record = $DB->get_record_sql($sql);
if (!empty($record)) {
- $stage_identifier = $record->stage_identifier;
+ $stageidentifier = $record->stage_identifier;
} else if (!$this->coursework->sampling_enabled()) { // Samplings disabled
// workout if any stage is still available
$sql = "SELECT count(*) as graded FROM {coursework_feedbacks}
@@ -733,42 +748,42 @@ public function get_stage_identifier($submissionid, $cell_identifier) {
if ($this->coursework->get_max_markers() > $record->graded) {
$stage = $record->graded + 1;
- $stage_identifier = 'assessor_' . $stage;
+ $stageidentifier = 'assessor_' . $stage;
}
} else if ($this->coursework->sampling_enabled()) { // samplings enabled
- $in_sample = ($subs = $submission->get_submissions_in_sample()) ? count($subs) : 0;
- $feedback = $DB->record_exists('coursework_feedbacks', array('submissionid' => $submissionid,
- 'stage_identifier' => 'assessor_1'));
+ $insample = ($subs = $submission->get_submissions_in_sample()) ? count($subs) : 0;
+ $feedback = $DB->record_exists('coursework_feedbacks', ['submissionid' => $submissionid,
+ 'stage_identifier' => 'assessor_1']);
// no sample or no feedback for sample yet
- if (!$in_sample || ($in_sample && !$feedback)) {
- $stage_identifier = 'assessor_1';
+ if (!$insample || ($insample && !$feedback)) {
+ $stageidentifier = 'assessor_1';
} else { // find out which sample wasn't graded yet
- $samples = $submission->get_submissions_in_sample();
- foreach ($samples as $sample) {
- $feedback = $DB->record_exists('coursework_feedbacks', array('submissionid' => $submissionid,
- 'stage_identifier' => $sample->stage_identifier));
- // if feedback doesn't exist, we'll use this stage identifier for a new feedback
- if (!$feedback) {
- $stage_identifier = $sample->stage_identifier;
- break;
- }
- }
- }
+ $samples = $submission->get_submissions_in_sample();
+ foreach ($samples as $sample) {
+ $feedback = $DB->record_exists('coursework_feedbacks', ['submissionid' => $submissionid,
+ 'stage_identifier' => $sample->stage_identifier]);
+ // if feedback doesn't exist, we'll use this stage identifier for a new feedback
+ if (!$feedback) {
+ $stageidentifier = $sample->stage_identifier;
+ break;
+ }
+ }
+ }
}
}
// double marked - multiplegrade - allocated/notallocated
- if ($this->coursework->get_max_markers() > 1 && ($cell_identifier != 'singlegrade' && $cell_identifier != 'feedbackcomments')) {
- if (substr($cell_identifier, 0, 8) == 'assessor') {
- $stage_identifier = 'assessor_' . (substr($cell_identifier, -1));
+ if ($this->coursework->get_max_markers() > 1 && ($cellidentifier != 'singlegrade' && $cellidentifier != 'feedbackcomments')) {
+ if (substr($cellidentifier, 0, 8) == 'assessor') {
+ $stageidentifier = 'assessor_' . (substr($cellidentifier, -1));
//$cells[$i] = substr($cells[$i], 0, -1);
- } else if (substr($cell_identifier, 0, 6) == 'agreed') {
- $stage_identifier = 'final_agreed_1';
+ } else if (substr($cellidentifier, 0, 6) == 'agreed') {
+ $stageidentifier = 'final_agreed_1';
}
}
- return $stage_identifier;
+ return $stageidentifier;
}
/**
@@ -778,49 +793,49 @@ public function get_stage_identifier($submissionid, $cell_identifier) {
public function auto_agreement($cwfeedbackid) {
global $DB;
- $feedback = $DB->get_record('coursework_feedbacks', array('id' => $cwfeedbackid));
+ $feedback = $DB->get_record('coursework_feedbacks', ['id' => $cwfeedbackid]);
$feedback = \mod_coursework\models\feedback::find($feedback);
- $auto_feedback_classname = '\mod_coursework\auto_grader\\' . $this->coursework->automaticagreementstrategy;
+ $autofeedbackclassname = '\mod_coursework\auto_grader\\' . $this->coursework->automaticagreementstrategy;
/**
* @var auto_grader $auto_grader
*/
- $auto_grader = new $auto_feedback_classname($this->coursework,
+ $autograder = new $autofeedbackclassname($this->coursework,
$feedback->get_submission()->get_allocatable(),
$this->coursework->automaticagreementrange);
- $auto_grader->create_auto_grade_if_rules_match();
+ $autograder->create_auto_grade_if_rules_match();
}
- public function remove_other_assessors_grade($csv_cells, &$line) {
+ public function remove_other_assessors_grade($csvcells, &$line) {
- $otherassessors = false;
+ $otherassessors = false;
- if (in_array('otherassessors', $csv_cells)) {
+ if (in_array('otherassessors', $csvcells)) {
// find position of otherassesors so we know from which key to unset
- $key = array_search('otherassessors', $csv_cells);
- unset($csv_cells[$key]);
+ $key = array_search('otherassessors', $csvcells);
+ unset($csvcells[$key]);
$othercells = $this->other_assessors_cells();
if ($this->coursework->is_using_rubric()) {
- $singlegradeposition = array_search('singlegrade', $csv_cells);
+ $singlegradeposition = array_search('singlegrade', $csvcells);
$criterias = $this->coursework->get_rubric_criteria();
- $startposition = $singlegradeposition+ ((count($criterias) * 2) + 1);
+ $startposition = $singlegradeposition + ((count($criterias) * 2) + 1);
} else {
- $startposition = array_search('otherassessors', $csv_cells);
+ $startposition = array_search('otherassessors', $csvcells);
}
- for ($i = $startposition; $i < $startposition+$othercells; $i++) {
+ for ($i = $startposition; $i < $startposition + $othercells; $i++) {
unset($line[$i]);
}
- $csv_cells = array_values($csv_cells);
+ $csvcells = array_values($csvcells);
$line = array_values($line);
}
- return $csv_cells;
+ return $csvcells;
}
}
diff --git a/classes/file_importer.php b/classes/file_importer.php
index d41f4b5c..0a9ef229 100644
--- a/classes/file_importer.php
+++ b/classes/file_importer.php
@@ -118,7 +118,7 @@ public function import_zip_files($coursework, $feedbackstage, $overwritecurrent)
if ($allocatableid = $this->is_valid_feedback_file_filename($coursework, $file, $participants) ) {
- $subdbrecord = $DB->get_record('coursework_submissions', array('courseworkid' => $coursework->id(), 'allocatableid' => $allocatableid, 'allocatabletype' => $coursework->get_allocatable_type()));
+ $subdbrecord = $DB->get_record('coursework_submissions', ['courseworkid' => $coursework->id(), 'allocatableid' => $allocatableid, 'allocatabletype' => $coursework->get_allocatable_type()]);
$submission = \mod_coursework\models\submission::find($subdbrecord);
@@ -127,7 +127,7 @@ public function import_zip_files($coursework, $feedbackstage, $overwritecurrent)
// If only add/edit initial capability then workout stage identifier
if ($feedbackstage == 'initialassessor') {
- $feedback = $DB->get_record('coursework_feedbacks', array('submissionid' => $submission->id, 'assessorid' => $USER->id ));
+ $feedback = $DB->get_record('coursework_feedbacks', ['submissionid' => $submission->id, 'assessorid' => $USER->id ]);
if ($feedback) {
$feedbackstage = $feedback->stage_identifier;
@@ -177,7 +177,7 @@ public function import_zip_files($coursework, $feedbackstage, $overwritecurrent)
$results[$filename] = get_string('feedbacksubmissionpublished', 'mod_coursework');
}
- } else {
+ } else {
$results[$filename] = get_string('feedbacknotfound', 'mod_coursework');
}
}
@@ -230,8 +230,8 @@ public function feedback_exists($coursework, $submission, $stageidentifier) {
AND stage_identifier = :stage
";
- $params = array('submissionid' => $submission->id,
- 'stage' => $stageidentifier);
+ $params = ['submissionid' => $submission->id,
+ 'stage' => $stageidentifier];
if (!has_capability('mod/coursework:administergrades', $coursework->get_context())) {
$sql .= "AND (assessorid = :assessorid || lasteditedbyuser = :lasteditedbyuser)";
diff --git a/classes/forms/advance_plugins_form.php b/classes/forms/advance_plugins_form.php
index 9c2d4932..50879023 100644
--- a/classes/forms/advance_plugins_form.php
+++ b/classes/forms/advance_plugins_form.php
@@ -50,16 +50,16 @@ public function definition() {
$mform->addElement('editor', 'text_element', get_string('comment', 'mod_coursework'), []);
$mform->setType('editor', PARAM_RAW);
- $file_manager_options = array(
+ $filemanageroptions = [
'subdirs' => false,
'accepted_types' => '*',
- 'return_types' => FILE_INTERNAL
- );
+ 'return_types' => FILE_INTERNAL,
+ ];
$this->_form->addElement('filemanager',
'file_element',
'',
null,
- $file_manager_options);
+ $filemanageroptions);
}
}
diff --git a/classes/forms/assessor_feedback_mform.php b/classes/forms/assessor_feedback_mform.php
index fb419e14..00a60679 100644
--- a/classes/forms/assessor_feedback_mform.php
+++ b/classes/forms/assessor_feedback_mform.php
@@ -44,7 +44,7 @@ class assessor_feedback_mform extends moodleform {
/**
* @var int the id of the submission that the grade pertains to
*/
- public $submission_id;
+ public $submissionid;
/**
* @var int
@@ -88,16 +88,16 @@ public function definition() {
$grademenu = make_grades_menu($coursework->grade);
- if (($coursework->is_using_advanced_grading() && $coursework->finalstagegrading ==0 ) || ($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 1 && $feedback->stage_identifier != 'final_agreed_1')) {
+ if (($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 0 ) || ($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 1 && $feedback->stage_identifier != 'final_agreed_1')) {
$this->_grading_controller = $coursework->get_advanced_grading_active_controller();
$this->_grading_instance = $this->_grading_controller->get_or_create_instance(0, $feedback->assessorid, $feedback->id);
- $mform->addElement('grading', 'advancedgrading', get_string('grade', 'mod_coursework'), array('gradinginstance' => $this->_grading_instance));
+ $mform->addElement('grading', 'advancedgrading', get_string('grade', 'mod_coursework'), ['gradinginstance' => $this->_grading_instance]);
} else {
$mform->addElement('select',
'grade',
get_string('grade', 'mod_coursework'),
$grademenu,
- array('id' => 'feedback_grade'));
+ ['id' => 'feedback_grade']);
}
// Useful to keep the overall comments even if we have a rubric or something. There may be a place
@@ -105,18 +105,18 @@ public function definition() {
$mform->addElement('editor', 'feedbackcomment', get_string('comment', 'mod_coursework'));
$mform->setType('editor', PARAM_RAW);
- $file_manager_options = array(
+ $filemanageroptions = [
'subdirs' => false,
'accepted_types' => '*',
- 'return_types' => FILE_INTERNAL
- );
+ 'return_types' => FILE_INTERNAL,
+ ];
$uploadfilestring = get_string('uploadafile');
$this->_form->addElement('filemanager',
'feedback_manager',
$uploadfilestring,
null,
- $file_manager_options);
+ $filemanageroptions);
$this->add_submit_buttons($coursework->draft_feedback_enabled(), $feedback->id);
@@ -134,24 +134,24 @@ public function get_grading_controller() {
*/
public function add_submit_buttons($draftenabled, $feedbackid) {
- $button_array = [];
+ $buttonarray = [];
if ($draftenabled) {
- $button_array[] = $this->_form->createElement('submit', 'submitfeedbackbutton', get_string('saveasdraft', 'coursework'));
+ $buttonarray[] = $this->_form->createElement('submit', 'submitfeedbackbutton', get_string('saveasdraft', 'coursework'));
}
- $button_array[] =
+ $buttonarray[] =
$this->_form->createElement('submit', 'submitbutton', get_string('saveandfinalise', 'coursework'));
$feedback = $this->_customdata['feedback'];
- $is_published = $feedback->get_submission()->is_published();
+ $ispublished = $feedback->get_submission()->is_published();
- if ($feedbackid && !$is_published) {
- $button_array[] = $this->_form->createElement('submit', 'removefeedbackbutton', get_string('removefeedback', 'coursework'));
+ if ($feedbackid && !$ispublished) {
+ $buttonarray[] = $this->_form->createElement('submit', 'removefeedbackbutton', get_string('removefeedback', 'coursework'));
}
- $button_array[] = $this->_form->createElement('cancel');
- $this->_form->addGroup($button_array, 'buttonar', '', array(' '), false);
+ $buttonarray[] = $this->_form->createElement('cancel');
+ $this->_form->addGroup($buttonarray, 'buttonar', '', [' '], false);
$this->_form->closeHeaderBefore('buttonar');
}
@@ -235,7 +235,7 @@ public function get_file_options() {
'areamaxbytes' => $filemanager->getAreamaxbytes(),
'target' => 'id_' . $filemanager->getName(),
'context' => $PAGE->context,
- 'itemid' => $filemanager->getValue()
+ 'itemid' => $filemanager->getValue(),
];
$fm = new \form_filemanager($params);
$options = $fm->options;
diff --git a/classes/forms/choose_student_for_submission_mform.php b/classes/forms/choose_student_for_submission_mform.php
index 78936938..892a2222 100644
--- a/classes/forms/choose_student_for_submission_mform.php
+++ b/classes/forms/choose_student_for_submission_mform.php
@@ -16,8 +16,7 @@
/**
*
- * @package
- * @subpackage
+ * @package mod_coursework
* @copyright 2012 Matt Gibson {@link http://moodle.org/user/view.php?id=81450}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
diff --git a/classes/forms/deadline_extension_form.php b/classes/forms/deadline_extension_form.php
index b6083172..5471952f 100644
--- a/classes/forms/deadline_extension_form.php
+++ b/classes/forms/deadline_extension_form.php
@@ -44,8 +44,8 @@ protected function definition() {
$this->_form->addElement('hidden', 'id');
$this->_form->settype('id', PARAM_INT);
- if ($this->get_coursework()->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()) {
- $this->_form->addElement('html', ' Personal deadline: '. userdate($personal_deadline->personal_deadline).' ');
+ if ($this->get_coursework()->personaldeadlineenabled && $personaldeadline = $this->personal_deadline()) {
+ $this->_form->addElement('html', 'Personal deadline: '. userdate($personaldeadline->personal_deadline).' ');
} else {
// Current deadline for comparison
$this->_form->addElement('html', 'Default deadline: ' . userdate($this->get_coursework()->deadline) . ' ');
@@ -55,13 +55,13 @@ protected function definition() {
$this->_form->addElement('date_time_selector', 'extended_deadline', get_string('extended_deadline',
'mod_coursework'));
- $extension_reasons = coursework::extension_reasons();
- if (!empty($extension_reasons)) {
+ $extensionreasons = coursework::extension_reasons();
+ if (!empty($extensionreasons)) {
$this->_form->addElement('select',
'pre_defined_reason',
get_string('extension_reason',
'mod_coursework'),
- $extension_reasons);
+ $extensionreasons);
}
$this->_form->addElement('editor', 'extra_information', get_string('extra_information', 'mod_coursework'));
@@ -82,10 +82,10 @@ private function get_coursework() {
*/
public function validation($data, $files) {
global $CFG;
- $max_deadline = $CFG->coursework_max_extension_deadline;
+ $maxdeadline = $CFG->coursework_max_extension_deadline;
- if ($this->get_coursework()->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()) {
- $deadline = $personal_deadline->personal_deadline;
+ if ($this->get_coursework()->personaldeadlineenabled && $personaldeadline = $this->personal_deadline()) {
+ $deadline = $personaldeadline->personal_deadline;
} else {
$deadline = $this->get_coursework()->deadline;
}
@@ -94,8 +94,8 @@ public function validation($data, $files) {
if ($data['extended_deadline'] <= $deadline) {
$errors['extended_deadline'] = 'The new deadline must be later than the current deadline';
}
- if ($data['extended_deadline'] >= strtotime("+$max_deadline months", $deadline)) {
- $errors['extended_deadline'] = "The new deadline must not be later than $max_deadline months after the current deadline";
+ if ($data['extended_deadline'] >= strtotime("+$maxdeadline months", $deadline)) {
+ $errors['extended_deadline'] = "The new deadline must not be later than $maxdeadline months after the current deadline";
}
return $errors;
}
@@ -106,7 +106,7 @@ public function personal_deadline() {
$extensionid = optional_param('id', 0, PARAM_INT);
if ($extensionid != 0) {
- $ext = $DB->get_record('coursework_extensions', array('id' => $extensionid));
+ $ext = $DB->get_record('coursework_extensions', ['id' => $extensionid]);
$allocatableid = $ext->allocatableid;
$allocatabletype = $ext->allocatabletype;
$courseworkid = $ext->courseworkid;
@@ -118,13 +118,13 @@ public function personal_deadline() {
$courseworkid = required_param('courseworkid', PARAM_INT);
}
- $params = array(
+ $params = [
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype ,
'courseworkid' => $courseworkid,
- );
+ ];
- return $personal_deadline = $DB->get_record('coursework_person_deadlines', $params);
+ return $personaldeadline = $DB->get_record('coursework_person_deadlines', $params);
}
}
diff --git a/classes/forms/moderator_agreement_mform.php b/classes/forms/moderator_agreement_mform.php
index 9cc67b75..ff99e574 100644
--- a/classes/forms/moderator_agreement_mform.php
+++ b/classes/forms/moderator_agreement_mform.php
@@ -41,7 +41,7 @@ class moderator_agreement_mform extends moodleform {
/**
* @var int the id of the submission that the grade pertains to
*/
- public $submission_id;
+ public $submissionid;
/**
* @var int
@@ -60,7 +60,7 @@ public function definition() {
*/
$moderation = $this->_customdata['moderation'];
$feedback = $moderation->get_feedback();
- $coursework = $moderation-> get_coursework();
+ $coursework = $moderation->get_coursework();
$mform->addElement('hidden', 'submissionid', $moderation->get_submission()->id);
$mform->setType('submissionid', PARAM_INT);
@@ -81,13 +81,13 @@ public function definition() {
$mform->setType('courseworkid', PARAM_INT);
// moderator agreement
- $options = array('agreed' => get_string('agreed', 'coursework'), 'disagreed' => get_string('disagreed', 'coursework'));
+ $options = ['agreed' => get_string('agreed', 'coursework'), 'disagreed' => get_string('disagreed', 'coursework')];
$mform->addElement('select', 'agreement',
get_string('moderationagreement', 'coursework'),
$options,
- array('id' => 'moderation_agreement'));
+ ['id' => 'moderation_agreement']);
- $mform->addElement('editor', 'modcomment', get_string('comment', 'mod_coursework'), array('id' => 'moderation_comment'));
+ $mform->addElement('editor', 'modcomment', get_string('comment', 'mod_coursework'), ['id' => 'moderation_comment']);
$mform->setType('editor', PARAM_RAW);
$this->add_action_buttons();
diff --git a/classes/forms/plagiarism_flagging_mform.php b/classes/forms/plagiarism_flagging_mform.php
index b66e8940..7176f738 100644
--- a/classes/forms/plagiarism_flagging_mform.php
+++ b/classes/forms/plagiarism_flagging_mform.php
@@ -41,7 +41,7 @@ class plagiarism_flagging_mform extends moodleform {
/**
* @var int the id of the submission that the grade pertains to
*/
- public $submission_id;
+ public $submissionid;
/**
* Makes the form elements.
@@ -53,25 +53,25 @@ public function definition() {
/**
* @var $plagiarism_flag plagiarism_flag
*/
- $plagiarism_flag = $this->_customdata['plagiarism_flag'];
+ $plagiarismflag = $this->_customdata['plagiarism_flag'];
- $mform->addElement('hidden', 'submissionid', $plagiarism_flag->get_submission()->id);
+ $mform->addElement('hidden', 'submissionid', $plagiarismflag->get_submission()->id);
$mform->setType('submissionid', PARAM_INT);
// plagiarism status
- $options = array(plagiarism_flag::INVESTIGATION => get_string('plagiarism_'.plagiarism_flag::INVESTIGATION, 'coursework'),
+ $options = [plagiarism_flag::INVESTIGATION => get_string('plagiarism_'.plagiarism_flag::INVESTIGATION, 'coursework'),
plagiarism_flag::RELEASED => get_string('plagiarism_'.plagiarism_flag::RELEASED, 'coursework'),
plagiarism_flag::CLEARED => get_string('plagiarism_'.plagiarism_flag::CLEARED, 'coursework'),
- plagiarism_flag::NOTCLEARED => get_string('plagiarism_'.plagiarism_flag::NOTCLEARED, 'coursework'));
+ plagiarism_flag::NOTCLEARED => get_string('plagiarism_'.plagiarism_flag::NOTCLEARED, 'coursework')];
$mform->addElement('select', 'status',
get_string('status', 'coursework'),
$options,
- array('id' => 'plagiarism_status'));
+ ['id' => 'plagiarism_status']);
$mform->addHelpButton('status', 'status', 'mod_coursework');
- $mform->addElement('editor', 'plagiarismcomment', get_string('comment', 'mod_coursework'), array('id' => 'plagiarism_comment'));
+ $mform->addElement('editor', 'plagiarismcomment', get_string('comment', 'mod_coursework'), ['id' => 'plagiarism_comment']);
$mform->setType('editor', PARAM_RAW);
$mform->hideIf('plagiarismcomment', 'status', 'eq', "1");
diff --git a/classes/forms/publish_form.php b/classes/forms/publish_form.php
index 8be01f98..a799bf29 100644
--- a/classes/forms/publish_form.php
+++ b/classes/forms/publish_form.php
@@ -46,11 +46,11 @@ public function definition() {
$attributes = [];
$explaintext = false;
- $should_release = true;
+ $shouldrelease = true;
if (!$coursework->has_stuff_to_publish()) {
- $should_release = false;
+ $shouldrelease = false;
$explaintext = get_string('nofinalgradedworkyet', 'mod_coursework');
} else if ($coursework->blindmarking_enabled() && $coursework->has_stuff_to_publish()) {
@@ -62,12 +62,12 @@ public function definition() {
$coursework->moderation_enabled() &&
$coursework->unmoderated_work_exists()) {
- $should_release = false;
+ $shouldrelease = false;
$explaintext = get_string('unmoderatedworkexists', 'mod_coursework');
}
// Confusing to show them the button with nothing to release.
- if ($coursework->has_stuff_to_publish() && $should_release) {
+ if ($coursework->has_stuff_to_publish() && $shouldrelease) {
$buttontext = get_string('publish', 'coursework');
$this->_form->addElement('submit', 'publishbutton', $buttontext, $attributes);
}
diff --git a/classes/forms/student_submission_form.php b/classes/forms/student_submission_form.php
index ff5bca7f..934bb78e 100644
--- a/classes/forms/student_submission_form.php
+++ b/classes/forms/student_submission_form.php
@@ -103,7 +103,7 @@ public function handle() {
$link = $CFG->wwwroot.'/mod/coursework/view.php?id='.$cmid;
if ($this->is_cancelled()) {
- redirect(new moodle_url('/mod/coursework/view.php', array('id' => $cmid)));
+ redirect(new moodle_url('/mod/coursework/view.php', ['id' => $cmid]));
}
$data = $this->get_data();
@@ -145,8 +145,8 @@ public function handle() {
$file = $submission->get_first_submitted_file();
$file->get_id();
- $file_information = new stdClass();
- $file_information->id = $file->get_id();
+ $fileinformation = new stdClass();
+ $fileinformation->id = $file->get_id();
// Some files may have more thn one dot in the name. This makes sure we get the chunk after
// the last dot.
@@ -156,18 +156,18 @@ public function handle() {
if (!empty($extension)) {
$extension = '.'.$extension;
}
- $file_information->filename = $coursework->get_username_hash($submission->userid).$extension;
+ $fileinformation->filename = $coursework->get_username_hash($submission->userid).$extension;
$pathnamehash = file_storage::get_pathname_hash($file->get_contextid(),
$file->get_component(),
$file->get_filearea(),
$file->get_itemid(),
$file->get_filepath(),
- $file_information->filename);
+ $fileinformation->filename);
- $file_information->pathnamehash = $pathnamehash;
+ $fileinformation->pathnamehash = $pathnamehash;
- $DB->update_record('files', $file_information);
+ $DB->update_record('files', $fileinformation);
// Force submission to update file record.
$submission->submission_files = null;
@@ -179,11 +179,13 @@ public function handle() {
if (!empty($userids)) {
foreach ($userids as $u) {
- $notifyuser = $DB->get_record('user', array('id' => trim($u)));
+ $notifyuser = $DB->get_record('user', ['id' => trim($u)]);
$mailer = new mailer($coursework);
- if (!empty($notifyuser)) $mailer->send_submission_notification($notifyuser);
- }
+ if (!empty($notifyuser)) {
+ $mailer->send_submission_notification($notifyuser);
+ }
+ }
}
}
@@ -207,10 +209,10 @@ public function handle() {
if ($CFG->coursework_allsubmissionreceipt || $data->finalisebutton) {
// send the receipts to students
- $students_who_need_a_receipt = $submission->get_students();
+ $studentswhoneedareceipt = $submission->get_students();
$mailer = new mailer($coursework);
- foreach ($students_who_need_a_receipt as $student) {
+ foreach ($studentswhoneedareceipt as $student) {
$mailer->send_submission_receipt($student, $data->finalisebutton);
}
}
@@ -239,19 +241,19 @@ public function set_data($submission) {
// Get any files that were previously submitted. This fetches an itemid from the $_GET
// params.
- $draft_item_id = file_get_submitted_draft_itemid('submission_manager');
+ $draftitemid = file_get_submitted_draft_itemid('submission_manager');
// Put them into a draft area.
- file_prepare_draft_area($draft_item_id,
+ file_prepare_draft_area($draftitemid,
$this->get_coursework()->get_context_id(),
'mod_coursework',
'submission',
$this->get_submission()->id,
$this->get_coursework()->get_file_options());
// Load that area into the form.
- $submission->submission_manager = $draft_item_id;
+ $submission->submission_manager = $draftitemid;
$data = new stdClass();
- $data->submission_manager = $draft_item_id;
+ $data->submission_manager = $draftitemid;
$data->courseworkid = $this->get_coursework()->id;
$data->userid = $submission->userid;
$data->submissionid = $this->get_submission()->id;
@@ -280,12 +282,12 @@ protected function get_submission() {
protected function add_agree_terms_elements_to_form() {
global $CFG;
- $terms_html = '';
- $terms_html .= html_writer::start_tag('h4');
- $terms_html .= get_string('youmustagreetotheterms', 'mod_coursework');
- $terms_html .= html_writer::end_tag('h4');
- $terms_html .= $CFG->coursework_agree_terms_text;
- $this->_form->addElement('html', $terms_html);
+ $termshtml = '';
+ $termshtml .= html_writer::start_tag('h4');
+ $termshtml .= get_string('youmustagreetotheterms', 'mod_coursework');
+ $termshtml .= html_writer::end_tag('h4');
+ $termshtml .= $CFG->coursework_agree_terms_text;
+ $this->_form->addElement('html', $termshtml);
$this->_form->addElement('checkbox', 'termsagreed', get_string('iagreetotheterms', 'mod_coursework'));
$this->_form->setType('termsagreed', PARAM_INT);
$this->_form->addRule('termsagreed', null, 'required');
@@ -299,20 +301,20 @@ protected function add_submit_buttons_to_form() {
$ability = new ability(user::find($USER), $this->get_coursework());
- $button_array = [];
+ $buttonarray = [];
// If submitting on behalf of someone else, we want to make sure that we don't have people leaving it in a draft
// state because the reason for doing submit on behalf of in the first place is that the student cannot use the
// interface themselves, so they are unable to come back later to finalise it themselves.
if (($ability->can('create', $this->get_submission()) || $ability->can('update', $this->get_submission()))
&& $this->get_submission()->get_coursework()->has_deadline() ) {
- $button_array[] = $this->_form->createElement('submit', 'submitbutton', get_string('submit'));
+ $buttonarray[] = $this->_form->createElement('submit', 'submitbutton', get_string('submit'));
}
if ($ability->can('finalise', $this->get_submission())) {
- $button_array[] =
+ $buttonarray[] =
$this->_form->createElement('submit', 'finalisebutton', get_string('submitandfinalise', 'coursework'));
}
- $button_array[] = $this->_form->createElement('cancel');
- $this->_form->addGroup($button_array, 'buttonar', '', array(' '), false);
+ $buttonarray[] = $this->_form->createElement('cancel');
+ $this->_form->addGroup($buttonarray, 'buttonar', '', [' '], false);
$this->_form->closeHeaderBefore('buttonar');
}
@@ -362,14 +364,14 @@ protected function add_file_manager_to_form() {
* @throws \coding_exception
*/
protected function add_instructions_to_form() {
- $file_manager_options = $this->get_file_manager_options();
+ $filemanageroptions = $this->get_file_manager_options();
$usernamehash = $this->get_coursework()->get_username_hash($this->get_submission()->userid);
$filerenamestring = ($this->get_coursework()->renamefiles == 1) ? get_string('file_rename', 'coursework', $usernamehash) : "";
$filerenamestring .= $this->make_plagiarism_instructions();
$filerenamestring .= html_writer::empty_tag('br');
- if ($file_manager_options['accepted_types'] != '*') {
- $filerenamestring .= 'Allowed file types: ' . implode(' ', $file_manager_options['accepted_types']);
+ if ($filemanageroptions['accepted_types'] != '*') {
+ $filerenamestring .= 'Allowed file types: ' . implode(' ', $filemanageroptions['accepted_types']);
} else {
$filerenamestring .= 'All file types are allowed.';
}
@@ -381,11 +383,11 @@ protected function add_instructions_to_form() {
* @throws \coding_exception
*/
protected function add_header_to_form() {
- $file_manager_options = $this->get_file_manager_options();
- $files_string = ($file_manager_options['maxfiles'] == 1) ? 'yoursubmissionfile' : 'yoursubmissionfiles';
+ $filemanageroptions = $this->get_file_manager_options();
+ $filesstring = ($filemanageroptions['maxfiles'] == 1) ? 'yoursubmissionfile' : 'yoursubmissionfiles';
$renamed = ($this->get_coursework()->renamefiles == 1) ? get_string('yoursubmissionfile_renamed', 'coursework') : "";
- $this->_form->addElement('header', 'submitform', get_string($files_string, 'coursework'). $renamed);
+ $this->_form->addElement('header', 'submitform', get_string($filesstring, 'coursework'). $renamed);
}
@@ -393,26 +395,26 @@ protected function add_header_to_form() {
* @return array
*/
protected function get_file_manager_options() {
- $file_manager_options = $this->get_coursework()->get_file_options();
- return $file_manager_options;
+ $filemanageroptions = $this->get_coursework()->get_file_options();
+ return $filemanageroptions;
}
/**
* @return string
*/
protected function make_plagiarism_instructions() {
- $plagiarism_helpers = $this->get_coursework()->get_plagiarism_helpers();
- $plagiarism_instructions = [];
- foreach ($plagiarism_helpers as $helper) {
+ $plagiarismhelpers = $this->get_coursework()->get_plagiarism_helpers();
+ $plagiarisminstructions = [];
+ foreach ($plagiarismhelpers as $helper) {
if ($helper->file_submission_instructions()) {
- $plagiarism_instructions[] = $helper->file_submission_instructions();
+ $plagiarisminstructions[] = $helper->file_submission_instructions();
}
}
- $plagiarism_instructions = implode(' ', $plagiarism_instructions);
- if ($plagiarism_instructions) {
- $plagiarism_instructions = ' ' . $plagiarism_instructions;
- return $plagiarism_instructions;
+ $plagiarisminstructions = implode(' ', $plagiarisminstructions);
+ if ($plagiarisminstructions) {
+ $plagiarisminstructions = ' ' . $plagiarisminstructions;
+ return $plagiarisminstructions;
}
- return $plagiarism_instructions;
+ return $plagiarisminstructions;
}
}
diff --git a/classes/forms/upload_allocations_form.php b/classes/forms/upload_allocations_form.php
index 795d2847..9824b6cd 100644
--- a/classes/forms/upload_allocations_form.php
+++ b/classes/forms/upload_allocations_form.php
@@ -1,5 +1,4 @@
_form;
- $mform->addElement('filepicker', 'allocationsdata', get_string('allocationsfile', 'coursework'), null, array( 'accepted_types' => '*.csv'));
+ $mform->addElement('filepicker', 'allocationsdata', get_string('allocationsfile', 'coursework'), null, [ 'accepted_types' => '*.csv']);
$mform->addRule('allocationsdata', null, 'required');
- // $mform->addElement('checkbox', 'overwrite', '', get_string('overwritegrades', 'coursework'));
+ // $mform->addElement('checkbox', 'overwrite', '', get_string('overwritegrades', 'coursework'));
$mform->addElement('hidden', 'cmid', $this->cmid);
$mform->setType('cmid', PARAM_RAW);
diff --git a/classes/forms/upload_feedback_form.php b/classes/forms/upload_feedback_form.php
index 7f49a791..362e7a0e 100644
--- a/classes/forms/upload_feedback_form.php
+++ b/classes/forms/upload_feedback_form.php
@@ -37,11 +37,11 @@ function __construct($coursework, $cmid) {
function definition() {
$mform =& $this->_form;
- $mform->addElement('filepicker', 'feedbackzip', get_string('feedbackzipfile', 'coursework'), null, array( 'accepted_types' => '*.zip'));
+ $mform->addElement('filepicker', 'feedbackzip', get_string('feedbackzipfile', 'coursework'), null, [ 'accepted_types' => '*.zip']);
$mform->addRule('feedbackzip', null, 'required');
$mform->addHelpButton('feedbackzip', 'feedbackzipfile', 'coursework');
- $mform->addElement('advcheckbox', 'overwrite', '', get_string('overwritefeedback', 'coursework'), null, array(0, 1));
+ $mform->addElement('advcheckbox', 'overwrite', '', get_string('overwritefeedback', 'coursework'), null, [0, 1]);
$mform->addElement('hidden', 'cmid', $this->cmid);
$mform->setType('cmid', PARAM_RAW);
@@ -49,18 +49,24 @@ function definition() {
if ($this->coursework->get_max_markers() > 1) {
- $capability = array('mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade');
+ $capability = ['mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade'];
if (has_any_capability($capability, $this->coursework->get_context()) && !has_capability('mod/coursework:administergrades', $this->coursework->get_context())) {
$options['initialassessor'] = get_string('initialassessor', 'coursework');
} else if (has_capability('mod/coursework:administergrades', $this->coursework->get_context())) {
$options['assessor_1'] = get_string('assessorupload', 'coursework', '1');
- if ($this->coursework->get_max_markers() >= 2) $options['assessor_2'] = get_string('assessorupload', 'coursework', '2');
- if ($this->coursework->get_max_markers() >= 3) $options['assessor_3'] = get_string('assessorupload', 'coursework', '3');
+ if ($this->coursework->get_max_markers() >= 2) {
+ $options['assessor_2'] = get_string('assessorupload', 'coursework', '2');
+ }
+ if ($this->coursework->get_max_markers() >= 3) {
+ $options['assessor_3'] = get_string('assessorupload', 'coursework', '3');
+ }
}
- $capability = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', 'mod/coursework:administergrades');
- if (has_any_capability($capability, $this->coursework->get_context())) $options['final_agreed_1'] = get_string('finalagreed', 'coursework');
+ $capability = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', 'mod/coursework:administergrades'];
+ if (has_any_capability($capability, $this->coursework->get_context())) {
+ $options['final_agreed_1'] = get_string('finalagreed', 'coursework');
+ }
$mform->addElement('select', 'feedbackstage', get_string('feedbackstage', 'coursework'), $options);
} else {
diff --git a/classes/forms/upload_grading_sheet_form.php b/classes/forms/upload_grading_sheet_form.php
index fd396742..e409a72b 100644
--- a/classes/forms/upload_grading_sheet_form.php
+++ b/classes/forms/upload_grading_sheet_form.php
@@ -35,7 +35,7 @@ function __construct($cmid) {
function definition() {
$mform =& $this->_form;
- $mform->addElement('filepicker', 'gradingdata', get_string('gradingsheetfile', 'coursework'), null, array( 'accepted_types' => '*.csv'));
+ $mform->addElement('filepicker', 'gradingdata', get_string('gradingsheetfile', 'coursework'), null, [ 'accepted_types' => '*.csv']);
$mform->addRule('gradingdata', null, 'required');
$mform->addElement('checkbox', 'overwrite', '', get_string('overwritegrades', 'coursework'));
diff --git a/classes/framework/ability.php b/classes/framework/ability.php
index edf38364..b7ef2ec9 100644
--- a/classes/framework/ability.php
+++ b/classes/framework/ability.php
@@ -120,8 +120,8 @@ protected function get_action_type($thing) {
return $thing;
}
- $class_name_with_namespace = get_class($thing);
- $bits = explode('\\', $class_name_with_namespace); // 'mod_coursework\models\submission'
+ $classnamewithnamespace = get_class($thing);
+ $bits = explode('\\', $classnamewithnamespace); // 'mod_coursework\models\submission'
$classname = end($bits); // 'submission'
// For non-standard things like decorated classes:
diff --git a/classes/framework/decorator.php b/classes/framework/decorator.php
index 7ebe0f7d..6f520d90 100644
--- a/classes/framework/decorator.php
+++ b/classes/framework/decorator.php
@@ -33,13 +33,13 @@ class decorator {
/**
* @var
*/
- protected $wrapped_object;
+ protected $wrappedobject;
/**
- * @param $wrapped_object
+ * @param $wrappedobject
*/
- public function __construct($wrapped_object) {
- $this->wrapped_object = $wrapped_object;
+ public function __construct($wrappedobject) {
+ $this->wrappedobject = $wrappedobject;
}
/**
@@ -50,8 +50,8 @@ public function __construct($wrapped_object) {
* @return mixed
*/
public function __call($method, $args) {
- return call_user_func_array(array($this->wrapped_object,
- $method),
+ return call_user_func_array([$this->wrappedobject,
+ $method],
$args);
}
@@ -62,7 +62,7 @@ public function __call($method, $args) {
* @return mixed
*/
public function __get($name) {
- return $this->wrapped_object->$name;
+ return $this->wrappedobject->$name;
}
/**
@@ -73,13 +73,13 @@ public function __get($name) {
* @return mixed
*/
public function __set($name, $value) {
- return $this->wrapped_object->$name = $value;
+ return $this->wrappedobject->$name = $value;
}
/**
* @return mixed
*/
public function wrapped_object() {
- return $this->wrapped_object;
+ return $this->wrappedobject;
}
}
diff --git a/classes/framework/test/classes/user_table.php b/classes/framework/test/classes/user_table.php
index afc21545..7deb3c15 100644
--- a/classes/framework/test/classes/user_table.php
+++ b/classes/framework/test/classes/user_table.php
@@ -31,6 +31,6 @@ class framework_user_table extends \mod_coursework\framework\table_base {
/**
* @var string
*/
- protected static $table_name = 'user';
+ protected static $tablename = 'user';
}
diff --git a/classes/framework/test/table_base_test.php b/classes/framework/test/table_base_test.php
index 2f16324e..e7851dba 100644
--- a/classes/framework/test/table_base_test.php
+++ b/classes/framework/test/table_base_test.php
@@ -51,9 +51,9 @@ public function test_get_table_name() {
public function test_find_when_true_with_id() {
$generator = testing_util::get_data_generator();
- $params = array(
- 'username' => 'freddo'
- );
+ $params = [
+ 'username' => 'freddo',
+ ];
$user = $generator->create_user($params);
$this->assertEquals($user->id, framework_user_table::find($user->id)->id);
@@ -62,9 +62,9 @@ public function test_find_when_true_with_id() {
public function test_find_when_true_with_other_param() {
$generator = testing_util::get_data_generator();
- $params = array(
- 'username' => 'freddo'
- );
+ $params = [
+ 'username' => 'freddo',
+ ];
$user = $generator->create_user($params);
$this->assertEquals($user->id, framework_user_table::find($params)->id);
@@ -73,18 +73,18 @@ public function test_find_when_true_with_other_param() {
public function test_find_when_true_with_entire_db_object() {
$generator = testing_util::get_data_generator();
- $params = array(
- 'username' => 'freddo'
- );
+ $params = [
+ 'username' => 'freddo',
+ ];
$user = $generator->create_user($params);
$this->assertEquals($user->id, framework_user_table::find($user)->id);
}
public function test_find_when_false() {
- $params = array(
- 'username' => 'freddo'
- );
+ $params = [
+ 'username' => 'freddo',
+ ];
$this->assertFalse(framework_user_table::find($params));
}
@@ -95,27 +95,27 @@ public function test_find_when_false_and_zero_supplied() {
public function test_exists_when_true() {
$generator = testing_util::get_data_generator();
- $params = array(
- 'username' => 'freddo'
- );
+ $params = [
+ 'username' => 'freddo',
+ ];
$generator->create_user($params);
$this->assertTrue(framework_user_table::exists($params));
}
public function test_exists_when_false() {
- $params = array(
- 'username' => 'freddo'
- );
+ $params = [
+ 'username' => 'freddo',
+ ];
$this->assertFalse(framework_user_table::exists($params));
}
public function test_find_when_given_a_db_record() {
$generator = testing_util::get_data_generator();
- $params = array(
- 'username' => 'freddo'
- );
+ $params = [
+ 'username' => 'freddo',
+ ];
$user = $generator->create_user($params);
$this->assertEquals($user->id, framework_user_table::find($user)->id);
}
@@ -133,10 +133,10 @@ public function test_find_all_returns_records() {
public function test_find_all_returns_specific_records() {
$generator = testing_util::get_data_generator();
- $generator->create_user(array('firstname' => 'Dave'));
- $generator->create_user(array('firstname' => 'Dave'));
+ $generator->create_user(['firstname' => 'Dave']);
+ $generator->create_user(['firstname' => 'Dave']);
// Admin user and guest user are there too
- $this->assertEquals(2, count(framework_user_table::find_all(array('firstname' => 'Dave'))));
+ $this->assertEquals(2, count(framework_user_table::find_all(['firstname' => 'Dave'])));
}
}
diff --git a/classes/grading_report.php b/classes/grading_report.php
index b806f21b..73afd9e7 100644
--- a/classes/grading_report.php
+++ b/classes/grading_report.php
@@ -39,10 +39,10 @@
*/
class grading_report {
- //added static vars to determine in what manner the report is loaded
- public static $MODE_GET_ALL = 1;
- public static $MODE_GET_FIRST_RECORDS = 2;
- public static $MODE_GET_REMAIN_RECORDS = 3;
+ // Added constants to determine in what manner the report is loaded.
+ const MODE_GET_ALL = 1;
+ const MODE_GET_FIRST_RECORDS = 2;
+ const MODE_GET_REMAIN_RECORDS = 3;
/**
* @var array rendering options
@@ -73,7 +73,7 @@ class grading_report {
/**
* @var
*/
- private $sub_rows;
+ private $subrows;
/**
* @var cell_interface[]
@@ -102,13 +102,13 @@ public function __construct(array $options, $coursework) {
protected function fill_pool() {
global $DB;
- $coursework_id = $this->coursework->id;
- submission::fill_pool_coursework($coursework_id);
+ $courseworkid = $this->coursework->id;
+ submission::fill_pool_coursework($courseworkid);
coursework::fill_pool([$this->coursework]);
course_module::fill_pool([$this->coursework->get_course_module()]);
module::fill_pool($DB->get_records('modules', ['name' => 'coursework']));
- feedback::fill_pool_submissions($coursework_id, array_keys(submission::$pool[$coursework_id]['id']));
- allocation::fill_pool_coursework($coursework_id);
+ feedback::fill_pool_submissions($courseworkid, array_keys(submission::$pool[$courseworkid]['id']));
+ allocation::fill_pool_coursework($courseworkid);
}
/**
@@ -125,8 +125,8 @@ public function get_coursework() {
* @return string
*/
protected function construct_sort_function_name($options) {
- $method_name = 'sort_by_' . $options['sortby'];
- return $method_name;
+ $methodname = 'sort_by_' . $options['sortby'];
+ return $methodname;
}
/**
@@ -313,14 +313,14 @@ public function get_cells_helpers() {
* @return sub_rows_interface
*/
public function get_sub_row_helper() {
- return $this->sub_rows;
+ return $this->subrows;
}
/**
* @param $rows_strategy
*/
- public function add_sub_rows($rows_strategy) {
- $this->sub_rows = $rows_strategy;
+ public function add_sub_rows($rowsstrategy) {
+ $this->subrows = $rowsstrategy;
}
/**
@@ -352,7 +352,7 @@ public function get_table_rows_for_page($rowcount = false) {
// Make tablerow objects so we can use the methods to check permissions and set things.
$rows = [];
- $row_class = $this->coursework->has_multiple_markers() ? 'mod_coursework\grading_table_row_multi' : 'mod_coursework\grading_table_row_single';
+ $rowclass = $this->coursework->has_multiple_markers() ? 'mod_coursework\grading_table_row_multi' : 'mod_coursework\grading_table_row_single';
$ability = new ability(user::find($USER, false), $this->get_coursework());
$participantsfound = 0;
@@ -362,37 +362,43 @@ public function get_table_rows_for_page($rowcount = false) {
// handle 'Group mode' - unset groups/individuals thaat are not in the chosen group
if (!empty($options['group']) && $options['group'] != -1) {
if ($this->coursework->is_configured_to_have_group_submissions()) {
- if ($options['group'] != $participant->id) continue;
+ if ($options['group'] != $participant->id) {
+ continue;
+ }
} else {
- if (!$this->coursework->student_in_group($participant->id, $options['group']))continue;
+ if (!$this->coursework->student_in_group($participant->id, $options['group'])) {
+ continue;
+ }
}
}
- $row = new $row_class($this->coursework, $participant);
+ $row = new $rowclass($this->coursework, $participant);
// Now, we skip the ones who should not be visible on this page.
- $can_show = $ability->can('show', $row);
- if (!$can_show && !isset($options['unallocated'])) {
+ $canshow = $ability->can('show', $row);
+ if (!$canshow && !isset($options['unallocated'])) {
unset($participants[$key]);
continue;
}
- if ($can_show && isset($options['unallocated'])) {
+ if ($canshow && isset($options['unallocated'])) {
unset($participants[$key]);
continue;
}
$rows[$participant->id()] = $row;
$participantsfound++;
- if (!empty($rowcount) && $participantsfound >= $rowcount) break;
+ if (!empty($rowcount) && $participantsfound >= $rowcount) {
+ break;
+ }
}
// Sort the rows.
- $method_name = 'sort_by_' . $options['sortby'];
- if (method_exists($this, $method_name)) {
+ $methodname = 'sort_by_' . $options['sortby'];
+ if (method_exists($this, $methodname)) {
usort($rows,
- array($this,
- $method_name));
+ [$this,
+ $methodname]);
}
// Some will have submissions and therefore data fields. Others will have those fields null.
@@ -400,13 +406,13 @@ public function get_table_rows_for_page($rowcount = false) {
$counter = count($rows);
$this->realtotalrows = $counter;
- $mode = empty($this->options['mode']) ? self::$MODE_GET_ALL : $this->options['mode'];
- if ($mode != self::$MODE_GET_ALL) {
+ $mode = empty($this->options['mode']) ? self::MODE_GET_ALL : $this->options['mode'];
+ if ($mode != self::MODE_GET_ALL) {
$perpage = $this->options['perpage'] ?? 10;
if ($counter > $perpage) {
- if ($mode == self::$MODE_GET_FIRST_RECORDS) {
+ if ($mode == self::MODE_GET_FIRST_RECORDS) {
$rows = array_slice($rows, 0, $perpage);
- } else if ($mode == self::$MODE_GET_REMAIN_RECORDS) {
+ } else if ($mode == self::MODE_GET_REMAIN_RECORDS) {
$rows = array_slice($rows, $perpage);
}
}
diff --git a/classes/grading_table_row_base.php b/classes/grading_table_row_base.php
index 51532886..ae8b88fc 100644
--- a/classes/grading_table_row_base.php
+++ b/classes/grading_table_row_base.php
@@ -107,12 +107,12 @@ public function get_user_name($link = false) {
$viewanonymous = has_capability('mod/coursework:viewanonymous', $this->get_coursework()->get_context());
if (!$this->get_coursework()->blindmarking || $viewanonymous || $this->is_published()) {
- $user = $DB->get_record('user', array('id' => $this->get_allocatable_id()));
+ $user = $DB->get_record('user', ['id' => $this->get_allocatable_id()]);
$fullname = fullname($user);
$allowed = has_capability('moodle/user:viewdetails', $this->get_coursework()->get_context());
if ($link && $allowed) {
- $url = new moodle_url('/user/view.php', array('id' => $this->get_allocatable_id(),
- 'course' => $this->get_coursework()->get_course_id()));
+ $url = new moodle_url('/user/view.php', ['id' => $this->get_allocatable_id(),
+ 'course' => $this->get_coursework()->get_course_id()]);
return html_writer::link($url, $fullname);
} else {
return $fullname;
@@ -133,7 +133,7 @@ public function get_idnumber() {
$viewanonymous = has_capability('mod/coursework:viewanonymous', $this->get_coursework()->get_context());
if (!$this->get_coursework()->blindmarking || $viewanonymous || $this->is_published()) {
- $user = $DB->get_record('user', array('id' => $this->get_allocatable_id()));
+ $user = $DB->get_record('user', ['id' => $this->get_allocatable_id()]);
return $user->idnumber;
} else {
return get_string('hidden', 'mod_coursework');
@@ -151,7 +151,7 @@ public function get_email() {
$viewanonymous = has_capability('mod/coursework:viewanonymous', $this->get_coursework()->get_context());
if (!$this->get_coursework()->blindmarking || $viewanonymous || $this->is_published()) {
- $user = $DB->get_record('user', array('id' => $this->get_allocatable_id()));
+ $user = $DB->get_record('user', ['id' => $this->get_allocatable_id()]);
return $user->email;
} else {
return '';
@@ -197,17 +197,17 @@ public function get_personal_deadlines() {
return '';
}
- $personal_deadline = $DB->get_record('coursework_person_deadlines',
- array('courseworkid' => $this->get_coursework()->id,
+ $personaldeadline = $DB->get_record('coursework_person_deadlines',
+ ['courseworkid' => $this->get_coursework()->id,
'allocatableid' => $allocatable->id(),
- 'allocatabletype' => $allocatable->type()));
- if ($personal_deadline) {
- $personal_deadline = $personal_deadline->personal_deadline;
+ 'allocatabletype' => $allocatable->type()]);
+ if ($personaldeadline) {
+ $personaldeadline = $personaldeadline->personal_deadline;
} else {
- $personal_deadline = $this->get_coursework()->deadline;
+ $personaldeadline = $this->get_coursework()->deadline;
}
- return $personal_deadline;
+ return $personaldeadline;
}
/**
@@ -255,10 +255,10 @@ public function get_submission() {
*/
public function get_plagiarism_flag() {
- $submission = $this->get_submission();
- $params = array(
- 'submissionid' => $submission->id
- );
+ $submission = $this->get_submission();
+ $params = [
+ 'submissionid' => $submission->id,
+ ];
return plagiarism_flag::find($params);
}
@@ -405,9 +405,9 @@ public function get_single_feedback() {
public function has_extension() {
global $DB;
- return $DB->record_exists('coursework_extensions', array('courseworkid' => $this->get_coursework()->id,
+ return $DB->record_exists('coursework_extensions', ['courseworkid' => $this->get_coursework()->id,
'allocatableid' => $this->get_allocatable()->id(),
- 'allocatabletype' => $this->get_allocatable()->type()));
+ 'allocatabletype' => $this->get_allocatable()->type()]);
}
@@ -419,9 +419,9 @@ public function has_extension() {
*/
public function get_extension() {
global $DB;
- return $DB->get_record('coursework_extensions', array('courseworkid' => $this->get_coursework()->id,
+ return $DB->get_record('coursework_extensions', ['courseworkid' => $this->get_coursework()->id,
'allocatableid' => $this->get_allocatable()->id(),
- 'allocatabletype' => $this->get_allocatable()->type()));
+ 'allocatabletype' => $this->get_allocatable()->type()]);
}
public function get_user_firstname() {
diff --git a/classes/mailer.php b/classes/mailer.php
index 7d9dee85..eb9fd1ee 100644
--- a/classes/mailer.php
+++ b/classes/mailer.php
@@ -59,21 +59,21 @@ public function send_submission_receipt($user, $finalised = false) {
if ($this->coursework && $this->coursework->is_coursework_visible()) {// check if coursework exists and is not hidden
- $email_data = new \stdClass();
- $email_data->name = $user->name();
+ $emaildata = new \stdClass();
+ $emaildata->name = $user->name();
$dateformat = '%a, %d %b %Y, %H:%M';
- $email_data->submittedtime = userdate($submission->time_submitted(), $dateformat);
- $email_data->coursework_name = $this->coursework->name;
- $email_data->submissionid = $submission->id;
+ $emaildata->submittedtime = userdate($submission->time_submitted(), $dateformat);
+ $emaildata->coursework_name = $this->coursework->name;
+ $emaildata->submissionid = $submission->id;
if ($finalised) {
- $email_data->finalised = get_string('save_email_finalised', 'coursework');
+ $emaildata->finalised = get_string('save_email_finalised', 'coursework');
} else {
- $email_data->finalised = '';
+ $emaildata->finalised = '';
}
$subject = get_string('save_email_subject', 'coursework');
- $text_body = get_string('save_email_text', 'coursework', $email_data);
- $html_body = get_string('save_email_html', 'coursework', $email_data);
+ $textbody = get_string('save_email_text', 'coursework', $emaildata);
+ $htmlbody = get_string('save_email_html', 'coursework', $emaildata);
// New approach.
$eventdata = new \core\message\message();
@@ -82,10 +82,10 @@ public function send_submission_receipt($user, $finalised = false) {
$eventdata->userfrom = \core_user::get_noreply_user();
$eventdata->userto = $user->get_raw_record();
$eventdata->subject = $subject;
- $eventdata->fullmessage = $text_body;
+ $eventdata->fullmessage = $textbody;
$eventdata->fullmessageformat = FORMAT_PLAIN;
- $eventdata->fullmessagehtml = $html_body;
- $eventdata->smallmessage = $text_body;
+ $eventdata->fullmessagehtml = $htmlbody;
+ $eventdata->smallmessage = $textbody;
$eventdata->notification = 1;
$eventdata->contexturl = $CFG->wwwroot . '/mod/coursework/view.php?id=' . $submission->get_coursework()->get_coursemodule_id();
$eventdata->contexturlname = 'View your submission here';
@@ -103,8 +103,8 @@ public function send_late_submission_notification($submission) {
global $CFG;
$coursework = $submission->get_coursework();
- $student_or_group = $submission->get_allocatable();
- $recipients = $coursework->initial_assessors($student_or_group);
+ $studentorgroup = $submission->get_allocatable();
+ $recipients = $coursework->initial_assessors($studentorgroup);
foreach ($recipients as $recipient) {
// New approach.
@@ -114,12 +114,12 @@ public function send_late_submission_notification($submission) {
$eventdata->userfrom = \core_user::get_noreply_user();
$eventdata->userto = $recipient;
$eventdata->subject = 'Late submission for '.$coursework->name;
- $message_text =
- 'A late submission was just submitted for ' . $student_or_group->type() . ' ' . $student_or_group->name();
- $eventdata->fullmessage = $message_text;
+ $messagetext =
+ 'A late submission was just submitted for ' . $studentorgroup->type() . ' ' . $studentorgroup->name();
+ $eventdata->fullmessage = $messagetext;
$eventdata->fullmessageformat = FORMAT_PLAIN;
- $eventdata->fullmessagehtml = $message_text;
- $eventdata->smallmessage = $message_text;
+ $eventdata->fullmessagehtml = $messagetext;
+ $eventdata->smallmessage = $messagetext;
$eventdata->notification = 1;
$eventdata->contexturl =
$CFG->wwwroot . '/mod/coursework/view.php?id=' . $coursework->get_coursemodule_id();
@@ -141,8 +141,8 @@ public function send_feedback_notification($submission) {
if ($this->coursework && $this->coursework->is_coursework_visible()) {// check if coursework exists and is not hidden
- $email_data = new \stdClass();
- $email_data->coursework_name = $this->coursework->name;
+ $emaildata = new \stdClass();
+ $emaildata->coursework_name = $this->coursework->name;
$subject = get_string('feedback_released_email_subject', 'coursework');
@@ -152,9 +152,9 @@ public function send_feedback_notification($submission) {
foreach ($students as $student) {
$student = \mod_coursework\models\user::find($student);
- $email_data->name = $student->name();
- $text_body = get_string('feedback_released_email_text', 'coursework', $email_data);
- $html_body = get_string('feedback_released_email_html', 'coursework', $email_data);
+ $emaildata->name = $student->name();
+ $textbody = get_string('feedback_released_email_text', 'coursework', $emaildata);
+ $htmlbody = get_string('feedback_released_email_html', 'coursework', $emaildata);
$eventdata = new \core\message\message();
$eventdata->component = 'mod_coursework';
@@ -162,10 +162,10 @@ public function send_feedback_notification($submission) {
$eventdata->userfrom = \core_user::get_noreply_user();
$eventdata->userto = $student->get_raw_record();
$eventdata->subject = $subject;
- $eventdata->fullmessage = $text_body;
+ $eventdata->fullmessage = $textbody;
$eventdata->fullmessageformat = FORMAT_PLAIN;
- $eventdata->fullmessagehtml = $html_body;
- $eventdata->smallmessage = $text_body;
+ $eventdata->fullmessagehtml = $htmlbody;
+ $eventdata->smallmessage = $textbody;
$eventdata->notification = 1;
$eventdata->contexturl = $CFG->wwwroot . '/mod/coursework/view.php?id=' . $submission->get_coursework()->get_coursemodule_id();
$eventdata->contexturlname = 'View your submission here';
@@ -190,29 +190,29 @@ public function send_student_deadline_reminder($user) {
if (!$this->coursework || !$this->coursework->is_coursework_visible()) {// check if coursework exists and is not hidden
return false;
}
- $email_data = new \stdClass();
- $email_data->coursework_name = $this->coursework->name;
- $email_data->coursework_name_with_link = \html_writer::link($CFG->wwwroot . '/mod/coursework/view.php?id=' . $this->coursework->get_coursemodule_id(), $this->coursework->name);
- $email_data->deadline = $user->deadline;
- $email_data->human_deadline = userdate($user->deadline, '%a, %d %b %Y, %H:%M');
+ $emaildata = new \stdClass();
+ $emaildata->coursework_name = $this->coursework->name;
+ $emaildata->coursework_name_with_link = \html_writer::link($CFG->wwwroot . '/mod/coursework/view.php?id=' . $this->coursework->get_coursemodule_id(), $this->coursework->name);
+ $emaildata->deadline = $user->deadline;
+ $emaildata->human_deadline = userdate($user->deadline, '%a, %d %b %Y, %H:%M');
$secondstodeadline = $user->deadline - time();
$days = floor($secondstodeadline / 86400);
$hours = floor($secondstodeadline / 3600) % 24;
- $days_to_deadline = '';
+ $daystodeadline = '';
if ($days > 0) {
- $days_to_deadline = $days . ' days and ';
+ $daystodeadline = $days . ' days and ';
}
- $days_to_deadline .= $hours . ' hours';
- $email_data->day_hour = $days_to_deadline;
+ $daystodeadline .= $hours . ' hours';
+ $emaildata->day_hour = $daystodeadline;
- $subject = get_string('cron_email_subject', 'mod_coursework', $email_data);
+ $subject = get_string('cron_email_subject', 'mod_coursework', $emaildata);
$student = \mod_coursework\models\user::find($user);
- $email_data->name = $student->name();
- $text_body = get_string('cron_email_text', 'mod_coursework', $email_data);
- $html_body = get_string('cron_email_html', 'mod_coursework', $email_data);
+ $emaildata->name = $student->name();
+ $textbody = get_string('cron_email_text', 'mod_coursework', $emaildata);
+ $htmlbody = get_string('cron_email_html', 'mod_coursework', $emaildata);
$eventdata = new \core\message\message();
$eventdata->component = 'mod_coursework';
@@ -220,10 +220,10 @@ public function send_student_deadline_reminder($user) {
$eventdata->userfrom = \core_user::get_noreply_user();
$eventdata->userto = $student->get_raw_record();
$eventdata->subject = $subject;
- $eventdata->fullmessage = $text_body;
+ $eventdata->fullmessage = $textbody;
$eventdata->fullmessageformat = FORMAT_PLAIN;
- $eventdata->fullmessagehtml = $html_body;
- $eventdata->smallmessage = $text_body;
+ $eventdata->fullmessagehtml = $htmlbody;
+ $eventdata->smallmessage = $textbody;
$eventdata->notification = 1;
$eventdata->contexturl = $CFG->wwwroot . '/mod/coursework/view.php?id=' . $this->coursework->get_coursemodule_id();
$eventdata->contexturlname = 'View the coursework here';
@@ -238,16 +238,16 @@ public function send_submission_notification($userstonotify) {
if ($this->coursework && $this->coursework->is_coursework_visible()) {// check if coursework exists and is not hidden
- $email_data = new \stdClass();
- $email_data->coursework_name = $this->coursework->name;
+ $emaildata = new \stdClass();
+ $emaildata->coursework_name = $this->coursework->name;
- $subject = get_string('submission_notification_subject', 'coursework', $email_data->coursework_name);
+ $subject = get_string('submission_notification_subject', 'coursework', $emaildata->coursework_name);
$userstonotify = \mod_coursework\models\user::find($userstonotify);
- $email_data->name = $userstonotify->name();
- $text_body = get_string('submission_notification_text', 'coursework', $email_data);
- $html_body = get_string('submission_notification_html', 'coursework', $email_data);
+ $emaildata->name = $userstonotify->name();
+ $textbody = get_string('submission_notification_text', 'coursework', $emaildata);
+ $htmlbody = get_string('submission_notification_html', 'coursework', $emaildata);
$eventdata = new \core\message\message();
$eventdata->component = 'mod_coursework';
@@ -255,10 +255,10 @@ public function send_submission_notification($userstonotify) {
$eventdata->userfrom = \core_user::get_noreply_user();
$eventdata->userto = $userstonotify->get_raw_record();
$eventdata->subject = $subject;
- $eventdata->fullmessage = $text_body;
+ $eventdata->fullmessage = $textbody;
$eventdata->fullmessageformat = FORMAT_PLAIN;
- $eventdata->fullmessagehtml = $html_body;
- $eventdata->smallmessage = $text_body;
+ $eventdata->fullmessagehtml = $htmlbody;
+ $eventdata->smallmessage = $textbody;
$eventdata->notification = 1;
$eventdata->contexturl = $CFG->wwwroot . '/mod/coursework/view.php?id=' . $this->coursework->id();
$eventdata->contexturlname = 'coursework submission';
diff --git a/classes/models/course_module.php b/classes/models/course_module.php
index ed0aeccb..33f0b63a 100644
--- a/classes/models/course_module.php
+++ b/classes/models/course_module.php
@@ -35,7 +35,7 @@ class course_module extends table_base {
/**
* @var string
*/
- protected static $table_name = 'course_modules';
+ protected static $tablename = 'course_modules';
/**
* @var int
@@ -57,7 +57,7 @@ class course_module extends table_base {
public static function fill_pool($array) {
self::$pool = [
'id' => [],
- 'course-module-instance' => []
+ 'course-module-instance' => [],
];
foreach ($array as $record) {
$object = new self($record);
diff --git a/classes/models/moderation.php b/classes/models/moderation.php
index ca7808cd..5d72bb5c 100644
--- a/classes/models/moderation.php
+++ b/classes/models/moderation.php
@@ -48,17 +48,17 @@ class moderation extends table_base {
/**
* @var int
*/
- public $feedbackid;
+ public $feedbackid;
/**
- * @var int
- */
+ * @var int
+ */
public $moderatorid;
/**
* @var int
*/
- public $stage_identifier = 'moderator';
+ public $stageidentifier = 'moderator';
/**
* @var string
*/
@@ -68,7 +68,7 @@ class moderation extends table_base {
/**
* @var string
*/
- protected static $table_name = 'coursework_mod_agreements';
+ protected static $tablename = 'coursework_mod_agreements';
/**
* @var string
@@ -96,7 +96,7 @@ public function get_feedback() {
global $DB;
//Moderation done only for single courseworks so submission id to retrieve feedback is enough
- $params = array('id' => $this->feedbackid);
+ $params = ['id' => $this->feedbackid];
$feedback = $DB->get_record('coursework_feedbacks', $params);
return $feedback;
@@ -113,8 +113,8 @@ public function get_agreement() {
* @return bool|submission
*/
public function get_submission() {
- $feedback = $this->get_feedback();
- $this->submission = submission::find($feedback->submissionid);
+ $feedback = $this->get_feedback();
+ $this->submission = submission::find($feedback->submissionid);
return $this->submission;
}
@@ -173,7 +173,7 @@ public function get_stage() {
public static function get_moderator_agreement($feedback) {
global $DB;
- $params = array('feedbackid' => $feedback->id);
+ $params = ['feedbackid' => $feedback->id];
// Should only ever be one that has the particular combination of these three options.
$moderation = $DB->get_record('coursework_mod_agreements', $params);
diff --git a/classes/models/moderation_set_rule.php b/classes/models/moderation_set_rule.php
index 11d44550..e1935aa4 100644
--- a/classes/models/moderation_set_rule.php
+++ b/classes/models/moderation_set_rule.php
@@ -49,7 +49,7 @@ abstract class moderation_set_rule extends table_base implements renderable {
/**
* @var string DB table this class relates to.
*/
- protected static $table_name = 'coursework_mod_set_rules';
+ protected static $tablename = 'coursework_mod_set_rules';
/**
* @var int
@@ -89,15 +89,15 @@ abstract class moderation_set_rule extends table_base implements renderable {
/**
* @var array List of class properties that correspond with DB fields.
*/
- protected $fields = array(
+ protected $fields = [
'id',
'courseworkid',
'rulename',
'ruleorder',
'upperlimit',
'lowerlimit',
- 'minimum'
- );
+ 'minimum',
+ ];
/**
* @param bool|int|stdClass $dbrecord
@@ -123,7 +123,7 @@ public function __construct($dbrecord = false) {
* @param stage_base $stage
* @return mixed
*/
- abstract public function adjust_set(array &$moderationset, array &$potential_allocatables, $stage);
+ abstract public function adjust_set(array &$moderationset, array &$potentialallocatables, $stage);
/**
* Returns the name of the class without the 'coursework_moderation_set_rule_' prefix.
diff --git a/classes/models/null_user.php b/classes/models/null_user.php
index 4a694371..597c2336 100644
--- a/classes/models/null_user.php
+++ b/classes/models/null_user.php
@@ -59,7 +59,7 @@ public function type() {
* @param bool $with_picture
* @return string
*/
- public function profile_link($with_picture = false) {
+ public function profile_link($withpicture = false) {
return '';
}
diff --git a/classes/models/outstanding_marking.php b/classes/models/outstanding_marking.php
index f6bc8fac..67f89094 100644
--- a/classes/models/outstanding_marking.php
+++ b/classes/models/outstanding_marking.php
@@ -24,7 +24,7 @@
class outstanding_marking {
- private $day_in_secs;
+ private $dayinsecs;
public function __construct() {
@@ -73,13 +73,13 @@ public function get_to_grade_agreed_count($cwkrecord, $userid) {
//AGREED GRADE INFORMATION
- if ($this->should_get_to_mark_agreed_grade_info($coursework->id, $userid) && $coursework->has_multiple_markers()) {
- if (!$coursework->sampling_enabled()) {
- $agreedsubmissions = $this->get_to_grade_agreed_grade_submissions($coursework->id, $coursework->get_max_markers());
- } else {
- $agreedsubmissions = $this->get_to_grade_agreed_grade_sampled_submissions($coursework->id);
- }
+ if ($this->should_get_to_mark_agreed_grade_info($coursework->id, $userid) && $coursework->has_multiple_markers()) {
+ if (!$coursework->sampling_enabled()) {
+ $agreedsubmissions = $this->get_to_grade_agreed_grade_submissions($coursework->id, $coursework->get_max_markers());
+ } else {
+ $agreedsubmissions = $this->get_to_grade_agreed_grade_sampled_submissions($coursework->id);
}
+ }
return (!empty($agreedsubmissions)) ? count($agreedsubmissions) : 0;
}
@@ -274,11 +274,11 @@ private function get_to_grade_agreed_grade_sampled_submissions($courseworkid) {
* @param $user_id
* @return bool
*/
- private function has_agreed_grade($course_id, $user_id) {
+ private function has_agreed_grade($courseid, $userid) {
- $coursecontext = \context_course::instance($course_id);
+ $coursecontext = \context_course::instance($courseid);
- return has_capability('mod/coursework:addagreedgrade', $coursecontext, $user_id) || has_capability('mod/coursework:addallocatedagreedgrade', $coursecontext, $user_id);
+ return has_capability('mod/coursework:addagreedgrade', $coursecontext, $userid) || has_capability('mod/coursework:addallocatedagreedgrade', $coursecontext, $userid);
}
/**
@@ -286,11 +286,11 @@ private function has_agreed_grade($course_id, $user_id) {
* @param $user_id
* @return bool
*/
- private function has_initial_grade($course_id, $user_id) {
+ private function has_initial_grade($courseid, $userid) {
- $coursecontext = \context_course::instance($course_id);
+ $coursecontext = \context_course::instance($courseid);
- return has_capability('mod/coursework:addinitialgrade', $coursecontext, $user_id);
+ return has_capability('mod/coursework:addinitialgrade', $coursecontext, $userid);
}
/**
@@ -303,9 +303,9 @@ private function should_get_to_mark_initial_grade_info($courseworkid, $userid) {
$coursework = new \mod_coursework\models\coursework($courseworkid);
// Findout if the user can create an initial grade
- $user_has_initial_grade_capability = $this->has_initial_grade($coursework->get_course()->id, $userid);
+ $userhasinitialgradecapability = $this->has_initial_grade($coursework->get_course()->id, $userid);
- return $user_has_initial_grade_capability;
+ return $userhasinitialgradecapability;
}
/**
@@ -318,9 +318,9 @@ private function should_get_to_mark_agreed_grade_info($courseworkid, $userid) {
$coursework = new \mod_coursework\models\coursework($courseworkid);
// Findout if the user can create an initial grade
- $user_has_agreed_grade_capability = $this->has_agreed_grade($coursework->get_course()->id, $userid);
+ $userhasagreedgradecapability = $this->has_agreed_grade($coursework->get_course()->id, $userid);
- return $user_has_agreed_grade_capability;
+ return $userhasagreedgradecapability;
}
}
diff --git a/classes/models/personal_deadline.php b/classes/models/personal_deadline.php
index b02713bd..1a60c83c 100644
--- a/classes/models/personal_deadline.php
+++ b/classes/models/personal_deadline.php
@@ -44,7 +44,7 @@ class personal_deadline extends table_base {
/**
* @var string
*/
- protected static $table_name = 'coursework_person_deadlines';
+ protected static $tablename = 'coursework_person_deadlines';
/**
* @return mixed|\mod_coursework_coursework
@@ -59,8 +59,8 @@ public function get_coursework() {
}
public function get_allocatable() {
- $class_name = "\\mod_coursework\\models\\{$this->allocatabletype}";
- return $class_name::find($this->allocatableid);
+ $classname = "\\mod_coursework\\models\\{$this->allocatabletype}";
+ return $classname::find($this->allocatableid);
}
/**
@@ -70,9 +70,9 @@ public function get_allocatable() {
public function extension_exists() {
$coursework = $this->get_coursework();
- $params = array('courseworkid' => $coursework->id,
+ $params = ['courseworkid' => $coursework->id,
'allocatableid' => $this->allocatableid,
- 'allocatabletype' => $this->allocatabletype);
+ 'allocatabletype' => $this->allocatabletype];
return deadline_extension::find($params);
}
@@ -89,10 +89,10 @@ public static function get_personal_deadline_for_student($student, $coursework)
$allocatable = $student;
}
if ($allocatable) {
- return static::find(array('courseworkid' => $coursework->id,
+ return static::find(['courseworkid' => $coursework->id,
'allocatableid' => $allocatable->id(),
'allocatabletype' => $allocatable->type(),
- ));
+ ]);
}
}
@@ -108,11 +108,11 @@ public static function get_personal_deadline_for_student($student, $coursework)
* @param $coursework_id
* @return array
*/
- protected static function get_cache_array($coursework_id) {
+ protected static function get_cache_array($courseworkid) {
global $DB;
- $records = $DB->get_records(static::$table_name, ['courseworkid' => $coursework_id]);
+ $records = $DB->get_records(static::$tablename, ['courseworkid' => $courseworkid]);
$result = [
- 'allocatableid-allocatabletype' => []
+ 'allocatableid-allocatabletype' => [],
];
if ($records) {
foreach ($records as $record) {
@@ -130,12 +130,12 @@ protected static function get_cache_array($coursework_id) {
* @param $params
* @return bool
*/
- public static function get_object($coursework_id, $key, $params) {
- if (!isset(self::$pool[$coursework_id])) {
- self::fill_pool_coursework($coursework_id);
+ public static function get_object($courseworkid, $key, $params) {
+ if (!isset(self::$pool[$courseworkid])) {
+ self::fill_pool_coursework($courseworkid);
}
- $value_key = implode('-', $params);
- return self::$pool[$coursework_id][$key][$value_key][0] ?? false;
+ $valuekey = implode('-', $params);
+ return self::$pool[$courseworkid][$key][$valuekey][0] ?? false;
}
/**
diff --git a/classes/models/reminder.php b/classes/models/reminder.php
index c15c74ab..0c964a5f 100644
--- a/classes/models/reminder.php
+++ b/classes/models/reminder.php
@@ -30,6 +30,6 @@
*/
class reminder extends table_base {
- protected static $table_name = 'coursework_reminder';
+ protected static $tablename = 'coursework_reminder';
}
diff --git a/classes/models/sample_set_rule.php b/classes/models/sample_set_rule.php
index 465bbe23..011551bb 100644
--- a/classes/models/sample_set_rule.php
+++ b/classes/models/sample_set_rule.php
@@ -49,7 +49,7 @@ abstract class sample_set_rule extends table_base implements renderable {
/**
* @var string DB table this class relates to.
*/
- protected static $table_name = 'coursework_mod_set_rules';
+ protected static $tablename = 'coursework_mod_set_rules';
/**
* @var int
@@ -89,15 +89,15 @@ abstract class sample_set_rule extends table_base implements renderable {
/**
* @var array List of class properties that correspond with DB fields.
*/
- protected $fields = array(
+ protected $fields = [
'id',
'courseworkid',
'rulename',
'ruleorder',
'upperlimit',
'lowerlimit',
- 'minimum'
- );
+ 'minimum',
+ ];
/**
* @param bool|int|stdClass $dbrecord
@@ -126,7 +126,7 @@ public function __construct($coursework) {
* @param stage_base $stage
* @return mixed
*/
- abstract public function adjust_set(array &$moderationset, array &$potential_allocatables, $stage);
+ abstract public function adjust_set(array &$moderationset, array &$potentialallocatables, $stage);
/**
* Returns the name of the class without the 'coursework_moderation_set_rule_' prefix.
@@ -168,7 +168,7 @@ public static function allow_multiple() {
* @abstract
* @return mixed
*/
- abstract public function add_form_elements(coursework $coursework, $assessor_number);
+ abstract public function add_form_elements(coursework $coursework, $assessornumber);
/**
* Validates and saves data from the form elements defined by {@link get_form_elements()}.
diff --git a/classes/moderation_set_rule/minimum_range_grade_percent.php b/classes/moderation_set_rule/minimum_range_grade_percent.php
index 888b48b3..541a43a8 100644
--- a/classes/moderation_set_rule/minimum_range_grade_percent.php
+++ b/classes/moderation_set_rule/minimum_range_grade_percent.php
@@ -51,18 +51,18 @@ class minimum_range_grade_percent extends moderation_set_rule {
* @param \mod_coursework\stages\base $stage
* @return mixed
*/
- public function adjust_set(array &$moderation_set, array &$potential_allocatables, $stage) {
+ public function adjust_set(array &$moderationset, array &$potentialallocatables, $stage) {
// Convert percentages to raw grades for comparison.
global $DB;
- $params = array('id' => $this->courseworkid);
+ $params = ['id' => $this->courseworkid];
$maxgrade = $DB->get_field('coursework', 'grade', $params);
// Convert percentages to raw grades for comparison.
$upperlimit = ($this->upperlimit / 100) * $maxgrade;
$lowerlimit = ($this->lowerlimit / 100) * $maxgrade;
- foreach ($potential_allocatables as $id => $allocatable) {
+ foreach ($potentialallocatables as $id => $allocatable) {
if ($this->allocatable_is_not_yet_graded($allocatable)) {
continue;
@@ -74,8 +74,8 @@ public function adjust_set(array &$moderation_set, array &$potential_allocatable
$this->grade_is_above_lower_limit($grade, $lowerlimit) &&
($this->counter < $this->minimum)) {
- $moderation_set[$id] = $allocatable;
- unset ($potential_allocatables[$id]);
+ $moderationset[$id] = $allocatable;
+ unset ($potentialallocatables[$id]);
$this->counter++;
}
}
@@ -126,28 +126,28 @@ public function get_form_elements() {
// Upper limit.
$html .= html_writer::start_tag('p');
$html .= get_string('upperlimit', 'mod_coursework').' ';
- $attributes = array(
+ $attributes = [
'name' => 'rule_'.self::get_name().'_upperlimit',
- 'size' => 3
- );
+ 'size' => 3,
+ ];
$html .= html_writer::empty_tag('input', $attributes);
$html .= html_writer::end_tag('p');
// Lower limit.
$html .= html_writer::start_tag('p');
$html .= get_string('lowerlimit', 'mod_coursework').' ';
- $attributes = array(
+ $attributes = [
'name' => self::get_name().'_lowerlimit',
- 'size' => 3
- );
+ 'size' => 3,
+ ];
$html .= html_writer::empty_tag('input', $attributes);
$html .= html_writer::end_tag('p');
// Lower limit.
$html .= html_writer::start_tag('p');
$html .= get_string('modsetminimum', 'mod_coursework').' ';
- $attributes = array(
+ $attributes = [
'name' => self::get_name().'_minimum',
- 'size' => 4
- );
+ 'size' => 4,
+ ];
$html .= html_writer::empty_tag('input', $attributes);
$html .= html_writer::end_tag('p');
return $html;
diff --git a/classes/moderation_set_rule/minimum_range_grade_raw.php b/classes/moderation_set_rule/minimum_range_grade_raw.php
index 76985030..efa078ae 100644
--- a/classes/moderation_set_rule/minimum_range_grade_raw.php
+++ b/classes/moderation_set_rule/minimum_range_grade_raw.php
@@ -50,13 +50,13 @@ class minimum_range_grade_raw extends moderation_set_rule {
* @param \mod_coursework\stages\base $stage
* @return mixed
*/
- public function adjust_set(array &$moderation_set, array &$potential_allocatables, $stage) {
+ public function adjust_set(array &$moderationset, array &$potentialallocatables, $stage) {
// Convert percentages to raw grades for comparison.
$upperlimit = $this->upperlimit;
$lowerlimit = $this->lowerlimit;
- foreach ($potential_allocatables as $id => $allocatable) {
+ foreach ($potentialallocatables as $id => $allocatable) {
if ($this->allocatable_is_not_yet_graded($allocatable)) {
continue;
@@ -68,8 +68,8 @@ public function adjust_set(array &$moderation_set, array &$potential_allocatable
$grade >= $lowerlimit &&
($this->counter < $this->minimum)) {
- $moderation_set[$id] = $allocatable;
- unset ($potential_allocatables[$id]);
+ $moderationset[$id] = $allocatable;
+ unset ($potentialallocatables[$id]);
$this->counter++;
}
}
@@ -120,28 +120,28 @@ public function get_form_elements() {
// Upper limit.
$html .= html_writer::start_tag('p');
$html .= get_string('upperlimit', 'mod_coursework').' ';
- $attributes = array(
+ $attributes = [
'name' => 'rule_minimum_range_grade_raw_upperlimit',
- 'size' => 3
- );
+ 'size' => 3,
+ ];
$html .= html_writer::empty_tag('input', $attributes);
$html .= html_writer::end_tag('p');
// Lower limit.
$html .= html_writer::start_tag('p');
$html .= get_string('lowerlimit', 'mod_coursework').' ';
- $attributes = array(
+ $attributes = [
'name' => 'rule_minimum_range_grade_raw_lowerlimit',
- 'size' => 3
- );
+ 'size' => 3,
+ ];
$html .= html_writer::empty_tag('input', $attributes);
$html .= html_writer::end_tag('p');
// Lower limit.
$html .= html_writer::start_tag('p');
$html .= get_string('modsetminimum', 'mod_coursework').' ';
- $attributes = array(
+ $attributes = [
'name' => 'rule_minimum_range_grade_raw_minimum',
- 'size' => 4
- );
+ 'size' => 4,
+ ];
$html .= html_writer::empty_tag('input', $attributes);
$html .= html_writer::end_tag('p');
diff --git a/classes/moderation_set_rule/range_grade_percent.php b/classes/moderation_set_rule/range_grade_percent.php
index 25cfff42..5e6763e1 100644
--- a/classes/moderation_set_rule/range_grade_percent.php
+++ b/classes/moderation_set_rule/range_grade_percent.php
@@ -48,14 +48,14 @@ class range_grade_percent extends moderation_set_rule {
* @param \mod_coursework\stages\base $stage
* @return mixed
*/
- public function adjust_set(array &$moderation_set, array &$potential_allocatables, $stage) {
+ public function adjust_set(array &$moderationset, array &$potentialallocatables, $stage) {
$maxgrade = $this->get_coursework()->get_max_grade();
// Convert percentages to raw grades for comparison.
$upperlimit = ($this->upperlimit / 100) * $maxgrade;
$lowerlimit = ($this->lowerlimit / 100) * $maxgrade;
- foreach ($potential_allocatables as $id => $allocatable) {
+ foreach ($potentialallocatables as $id => $allocatable) {
if ($this->allocatable_is_not_yet_graded($allocatable)) {
continue;
@@ -66,8 +66,8 @@ public function adjust_set(array &$moderation_set, array &$potential_allocatable
if ($grade <= $upperlimit &&
$grade >= $lowerlimit) {
- $moderation_set[$id] = $allocatable;
- unset ($potential_allocatables[$id]);
+ $moderationset[$id] = $allocatable;
+ unset ($potentialallocatables[$id]);
}
}
}
@@ -117,19 +117,19 @@ public function get_form_elements() {
// Upper limit.
$html .= html_writer::start_tag('p');
$html .= get_string('upperlimit', 'mod_coursework').' ';
- $attributes = array(
+ $attributes = [
'name' => 'rule_range_grade_percent_upperlimit',
- 'size' => 3
- );
+ 'size' => 3,
+ ];
$html .= html_writer::empty_tag('input', $attributes).'%';
$html .= html_writer::end_tag('p');
// Lower limit.
$html .= html_writer::start_tag('p');
$html .= get_string('lowerlimit', 'mod_coursework').' ';
- $attributes = array(
+ $attributes = [
'name' => 'rule_range_grade_percent_lowerlimit',
- 'size' => 3
- );
+ 'size' => 3,
+ ];
$html .= html_writer::empty_tag('input', $attributes).'%';
$html .= html_writer::end_tag('p');
diff --git a/classes/moderation_set_rule/range_grade_raw.php b/classes/moderation_set_rule/range_grade_raw.php
index 7e4502cf..c2edac70 100644
--- a/classes/moderation_set_rule/range_grade_raw.php
+++ b/classes/moderation_set_rule/range_grade_raw.php
@@ -47,9 +47,9 @@ class range_grade_raw extends moderation_set_rule {
* @param \mod_coursework\stages\base $stage
* @return mixed
*/
- public function adjust_set(array &$moderation_set, array &$potential_allocatables, $stage) {
+ public function adjust_set(array &$moderationset, array &$potentialallocatables, $stage) {
- foreach ($potential_allocatables as $id => $allocatable) {
+ foreach ($potentialallocatables as $id => $allocatable) {
if ($this->allocatable_is_not_yet_graded($allocatable)) {
continue;
@@ -59,8 +59,8 @@ public function adjust_set(array &$moderation_set, array &$potential_allocatable
if ($grade <= $this->upperlimit && $grade >= $this->lowerlimit) {
- $moderation_set[$id] = $allocatable;
- unset ($potential_allocatables[$id]);
+ $moderationset[$id] = $allocatable;
+ unset ($potentialallocatables[$id]);
}
}
}
@@ -108,19 +108,19 @@ public function get_form_elements() {
// Upper limit.
$html .= html_writer::start_tag('p');
$html .= get_string('upperlimit', 'mod_coursework').' ';
- $attributes = array(
+ $attributes = [
'name' => 'rule_range_grade_raw_upperlimit',
- 'size' => 3
- );
+ 'size' => 3,
+ ];
$html .= html_writer::empty_tag('input', $attributes);
$html .= html_writer::end_tag('p');
// Lower limit.
$html .= html_writer::start_tag('p');
$html .= get_string('lowerlimit', 'mod_coursework').' ';
- $attributes = array(
+ $attributes = [
'name' => 'rule_range_grade_raw_lowerlimit',
- 'size' => 3
- );
+ 'size' => 3,
+ ];
$html .= html_writer::empty_tag('input', $attributes);
$html .= html_writer::end_tag('p');
return $html;
diff --git a/classes/moderation_set_rule/range_total_percent.php b/classes/moderation_set_rule/range_total_percent.php
index 825ed812..f1038f1e 100644
--- a/classes/moderation_set_rule/range_total_percent.php
+++ b/classes/moderation_set_rule/range_total_percent.php
@@ -65,23 +65,23 @@ public function __construct($dbrecord = false) {
* @param \mod_coursework\stages\base $stage
* @return mixed
*/
- public function adjust_set(array &$moderation_set, array &$potential_allocatables, $stage) {
+ public function adjust_set(array &$moderationset, array &$potentialallocatables, $stage) {
- $total_number = count($moderation_set) + count($potential_allocatables);
+ $totalnumber = count($moderationset) + count($potentialallocatables);
// We need to round up as we may have small numbers of students and e.g. 25% of 10 students ought to
// equate to 3.
- $number_needed = ceil($total_number * ($this->upperlimit / 100));
+ $numberneeded = ceil($totalnumber * ($this->upperlimit / 100));
- while (count($moderation_set) < $number_needed) {
+ while (count($moderationset) < $numberneeded) {
// Add random ones till we have enough.
- $id = array_rand($potential_allocatables);
+ $id = array_rand($potentialallocatables);
- $moderation_set[$id] = $potential_allocatables[$id];
- unset ($potential_allocatables[$id]);
+ $moderationset[$id] = $potentialallocatables[$id];
+ unset ($potentialallocatables[$id]);
- $number_needed--;
+ $numberneeded--;
}
}
@@ -125,10 +125,10 @@ public function get_form_elements() {
// Upper limit.
$html .= html_writer::start_tag('p');
$html .= get_string('upperlimit', 'mod_coursework').' ';
- $attributes = array(
+ $attributes = [
'name' => 'rule_range_total_percent_upperlimit',
- 'size' => 3
- );
+ 'size' => 3,
+ ];
$html .= html_writer::empty_tag('input', $attributes).'%';
$html .= html_writer::end_tag('p');
return $html;
diff --git a/classes/personal_deadline/allocatable.php b/classes/personal_deadline/allocatable.php
index b1e0441f..53b9df49 100644
--- a/classes/personal_deadline/allocatable.php
+++ b/classes/personal_deadline/allocatable.php
@@ -58,7 +58,7 @@ public function picture();
* @param bool $with_picture
* @return string
*/
- public function profile_link($with_picture = false);
+ public function profile_link($withpicture = false);
/**
* @param \stdClass $course
diff --git a/classes/personal_deadline/table/builder.php b/classes/personal_deadline/table/builder.php
index ec6d52e2..3201b202 100644
--- a/classes/personal_deadline/table/builder.php
+++ b/classes/personal_deadline/table/builder.php
@@ -78,11 +78,11 @@ public function get_rows() {
// Sort the rows.
$sorting = new mod_coursework\grading_report($this->options, $this->coursework);
- $method_name = 'sort_by_' . $this->options['sortby'];
- if (method_exists($sorting, $method_name)) {
+ $methodname = 'sort_by_' . $this->options['sortby'];
+ if (method_exists($sorting, $methodname)) {
usort($rows,
- array($sorting,
- $method_name));
+ [$sorting,
+ $methodname]);
}
return $rows;
@@ -111,9 +111,9 @@ public function get_options() {
* @return allocatable_cell
*/
public function get_allocatable_cell() {
- $items = array(
- 'coursework' => $this->coursework
- );
+ $items = [
+ 'coursework' => $this->coursework,
+ ];
if ($this->coursework->is_configured_to_have_group_submissions()) {
return new group_cell($items);
@@ -125,9 +125,9 @@ public function get_allocatable_cell() {
* @return personal_deadline_cell
*/
public function get_personal_deadline_cell() {
- $items = array(
- 'coursework' => $this->coursework
- );
+ $items = [
+ 'coursework' => $this->coursework,
+ ];
return new personal_deadline_cell($items);
}
diff --git a/classes/personal_deadline/table/row/builder.php b/classes/personal_deadline/table/row/builder.php
index f6e8bb89..ddd3a4fc 100644
--- a/classes/personal_deadline/table/row/builder.php
+++ b/classes/personal_deadline/table/row/builder.php
@@ -54,8 +54,8 @@ class builder implements user_row {
* @param table_builder $personal_deadline_table
* @param allocatable $allocatable
*/
- public function __construct($personal_deadline_table, $allocatable) {
- $this->personaldeadlinetable = $personal_deadline_table;
+ public function __construct($personaldeadlinetable, $allocatable) {
+ $this->personaldeadlinetable = $personaldeadlinetable;
$this->allocatable = $allocatable;
}
@@ -184,28 +184,28 @@ public function get_personal_deadlines() {
return '';
}
- $personal_deadline = $DB->get_record('coursework_person_deadlines',
- array('courseworkid' => $this->get_coursework()->id,
+ $personaldeadline = $DB->get_record('coursework_person_deadlines',
+ ['courseworkid' => $this->get_coursework()->id,
'allocatableid' => $this->allocatable->id(),
- 'allocatabletype' => $this->allocatable->type()));
- if ($personal_deadline) {
- $personal_deadline = $personal_deadline->personal_deadline;
+ 'allocatabletype' => $this->allocatable->type()]);
+ if ($personaldeadline) {
+ $personaldeadline = $personaldeadline->personal_deadline;
} else {
- $personal_deadline = $this->get_coursework()->deadline;
+ $personaldeadline = $this->get_coursework()->deadline;
}
- return $personal_deadline;
+ return $personaldeadline;
}
public function get_submission_status() {
global $DB;
- $submission_db = $DB->get_record('coursework_submissions',
- array('courseworkid' => $this->get_coursework()->id,
+ $submissiondb = $DB->get_record('coursework_submissions',
+ ['courseworkid' => $this->get_coursework()->id,
'allocatableid' => $this->allocatable->id(),
- 'allocatabletype' => $this->allocatable->type()));
+ 'allocatabletype' => $this->allocatable->type()]);
- $submission = \mod_coursework\models\submission::find($submission_db);
+ $submission = \mod_coursework\models\submission::find($submissiondb);
$statustext = get_string('statusnotsubmitted', 'mod_coursework');
diff --git a/classes/plagiarism_helpers/turnitin.php b/classes/plagiarism_helpers/turnitin.php
index ec2c23b8..58af3da1 100644
--- a/classes/plagiarism_helpers/turnitin.php
+++ b/classes/plagiarism_helpers/turnitin.php
@@ -47,11 +47,11 @@ public function enabled() {
if ($CFG->enableplagiarism) {
$plagiarismsettings = (array)get_config('plagiarism_turnitin');
if (!empty($plagiarismsettings['enabled'])) {
- $params = array(
+ $params = [
'cm' => $this->get_coursework()->get_course_module()->id,
'name' => 'use_turnitin',
- 'value' => 1
- );
+ 'value' => 1,
+ ];
if ($DB->record_exists('plagiarism_turnitin_config', $params)) {
return true;
}
diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php
index acc79b7a..7405770a 100644
--- a/classes/privacy/provider.php
+++ b/classes/privacy/provider.php
@@ -47,14 +47,14 @@ class provider implements
* @param collection $collection A collection of meta data items to be added to.
* @return collection Returns the collection of metadata.
*/
- public static function get_metadata(collection $collection) : collection {
+ public static function get_metadata(collection $collection): collection {
$feedbacks = [
'assessorid' => 'privacy:metadata:assessorid',
'timecreated' => 'privacy:metadata:timecreated',
'timemodified' => 'timemodified',
'grade' => 'privacy:metadata:grade',
'submissionid' => 'privacy:metadata:submissionid',
- 'feedbackcomment' => 'privacy:metadata:feedbackcomment'
+ 'feedbackcomment' => 'privacy:metadata:feedbackcomment',
];
$submissions = [
'authorid' => 'privacy:metadata:authorid',
@@ -62,7 +62,7 @@ public static function get_metadata(collection $collection) : collection {
'timecreated' => 'privacy:metadata:timecreated',
'timemodified' => 'timemodified',
'createdby' => 'createdby',
- 'timesubmitted' => 'timesubmitted'
+ 'timesubmitted' => 'timesubmitted',
];
$extensions = [
'allocatableid' => 'privacy:metadata:allocatableid',
@@ -70,27 +70,27 @@ public static function get_metadata(collection $collection) : collection {
'extra_information_text' => 'privacy:metadata:extra_information_text',
'extended_deadline' => 'privacy:metadata:extended_deadline',
'allocatableuser' => 'privacy:metadata:userid',
- 'allocatablegroup' => 'privacy:metadata:groupid'
+ 'allocatablegroup' => 'privacy:metadata:groupid',
];
$persondeadlines = [
'allocatableid' => 'privacy:metadata:allocatableid',
'createdbyid' => 'privacy:metadata:createdbyid',
'personal_deadline' => 'privacy:metadata:personal_deadline',
'allocatableuser' => 'privacy:metadata:userid',
- 'allocatablegroup' => 'privacy:metadata:groupid'
+ 'allocatablegroup' => 'privacy:metadata:groupid',
];
$modagreements = [
'moderatorid' => 'privacy:metadata:moderatorid',
'agreement' => 'privacy:metadata:agreement',
'modcomment' => 'privacy:metadata:modcomment',
'timecreated' => 'privacy:metadata:timecreated',
- 'timemodified' => 'timemodified'
+ 'timemodified' => 'timemodified',
];
$plagiarismflags = [
'createdby' => 'privacy:metadata:createdby',
'comment' => 'privacy:metadata:comment',
'timecreated' => 'privacy:metadata:timecreated',
- 'timemodified' => 'timemodified'
+ 'timemodified' => 'timemodified',
];
$collection->add_database_table('coursework_feedbacks', $feedbacks, 'privacy:metadata:feedbacks');
$collection->add_database_table('coursework_submissions', $submissions, 'privacy:metadata:submissions');
@@ -113,7 +113,7 @@ public static function get_users_in_context(userlist $userlist) {
$params = [
'modulename' => 'coursework',
'contextid' => $context->id,
- 'contextlevel' => CONTEXT_MODULE
+ 'contextlevel' => CONTEXT_MODULE,
];
$sql = "SELECT cwf.assessorid
FROM {context} ctx
@@ -181,7 +181,7 @@ public static function get_users_in_context(userlist $userlist) {
* @param int $userid The user ID.
* @return contextlist an object with the contexts related to a userid.
*/
- public static function get_contexts_for_userid(int $userid) : contextlist {
+ public static function get_contexts_for_userid(int $userid): contextlist {
$params = [
'modulename' => 'coursework',
'contextlevel' => CONTEXT_MODULE,
@@ -192,7 +192,7 @@ public static function get_contexts_for_userid(int $userid) : contextlist {
'allocatableuser' => $userid,
'allocatablegroup' => $userid,
'moderatorid' => $userid,
- 'createdby' => $userid
+ 'createdby' => $userid,
];
$sql = "SELECT ctx.id
FROM {course_modules} cm
@@ -345,11 +345,11 @@ public static function delete_data_for_users(approved_userlist $userlist) {
// Get the coursework related to this context.
$coursework = self::get_coursework_instance($context);
$userids = $userlist->get_userids();
- foreach ($userids as $user_id) {
+ foreach ($userids as $userid) {
// Get the coursework related to this context.
$coursework = self::get_coursework_instance($context);
// Retrieve all submissions by user-id to remove relating data
- $submissions = $coursework->retrieve_submissions_by_user($user_id);
+ $submissions = $coursework->retrieve_submissions_by_user($userid);
foreach ($submissions as $submission) {
// Remove all plagiarisms of the current submission
$coursework->remove_plagiarisms_by_submission($submission->id);
@@ -367,21 +367,21 @@ public static function delete_data_for_users(approved_userlist $userlist) {
$coursework->remove_feedbacks_by_submission($submission->id);
}
// Remove all submissions submitted by this user
- $coursework->remove_submissions_by_user($user_id);
+ $coursework->remove_submissions_by_user($userid);
// Remove all deadline extensions
- $coursework->remove_deadline_extensions_by_user($user_id);
+ $coursework->remove_deadline_extensions_by_user($userid);
// Remove all personal deadlines
- $coursework->remove_personal_deadlines_by_user($user_id);
+ $coursework->remove_personal_deadlines_by_user($userid);
}
}
protected static function get_coursework_instance(\context $context) {
global $DB;
- $courseId = array('id' => $context->get_course_context()->instanceid);
- $course = $DB->get_record('course', $courseId, '*', MUST_EXIST);
+ $courseid = ['id' => $context->get_course_context()->instanceid];
+ $course = $DB->get_record('course', $courseid, '*', MUST_EXIST);
$modinfo = get_fast_modinfo($course);
$coursemodule = $modinfo->get_cm($context->instanceid);
- $courseworkId = array('id' => $coursemodule->instance);
- $coursework = new \mod_coursework\models\coursework($courseworkId);
+ $courseworkid = ['id' => $coursemodule->instance];
+ $coursework = new \mod_coursework\models\coursework($courseworkid);
return $coursework;
}
/**
@@ -408,9 +408,9 @@ protected static function export_coursework_submissions($coursework, $user, $con
}
}
}
- protected static function export_submission_files($context, $submissionId, $currentpath) {
+ protected static function export_submission_files($context, $submissionid, $currentpath) {
$fs = get_file_storage();
- $files = $fs->get_area_files($context->id, 'mod_coursework', 'submission', $submissionId);
+ $files = $fs->get_area_files($context->id, 'mod_coursework', 'submission', $submissionid);
if (!empty($files)) {
foreach ($files as $file) {
writer::with_context($context)->export_file($currentpath, $file);
@@ -425,7 +425,7 @@ protected static function export_submission_files($context, $submissionId, $curr
*/
protected static function get_user_submissions($userid, $courseworkid) {
global $DB;
- $params = array('courseworkid' => $courseworkid, 'authorid' => $userid);
+ $params = ['courseworkid' => $courseworkid, 'authorid' => $userid];
$submissions = $DB->get_records('coursework_submissions', $params);
return $submissions;
}
@@ -438,17 +438,17 @@ protected static function get_user_submissions($userid, $courseworkid) {
*/
protected static function export_coursework_submission(\stdClass $submission, \context $context, array $currentpath) {
$status = self::get_submissions_status($submission->id);
- $submissionData = (object)[
+ $submissiondata = (object)[
'userid' => $submission->userid,
'status' => $status ? $status : '',
'timecreated' => transform::datetime($submission->timecreated),
'timemodified' => transform::datetime($submission->timemodified),
'timesubmitted' => transform::datetime($submission->timesubmitted),
'createdby' => $submission->createdby,
- 'finalised' => transform::yesno($submission->finalised)
+ 'finalised' => transform::yesno($submission->finalised),
];
writer::with_context($context)
- ->export_data(array_merge($currentpath, [get_string('privacy:submissionpath', 'mod_coursework')]), $submissionData);
+ ->export_data(array_merge($currentpath, [get_string('privacy:submissionpath', 'mod_coursework')]), $submissiondata);
}
protected static function get_submissions_status($submissionid) {
$submission = new \mod_coursework\models\submission($submissionid);
@@ -459,16 +459,16 @@ protected static function get_submissions_status($submissionid) {
}
protected static function get_submission_feedbacks($submissionid) {
global $DB;
- $params = array('submissionid' => $submissionid);
+ $params = ['submissionid' => $submissionid];
$feedbacks = $DB->get_records('coursework_feedbacks', $params);
return $feedbacks;
}
protected static function export_submissions_feedbacks($feedbacks, $context, $path) {
- $feedbacksData = [];
+ $feedbacksdata = [];
foreach ($feedbacks as $feedback) {
- $feedbackDataFormatted = self::format_submissions_feedback($feedback);
- if ($feedbackDataFormatted) {
- array_push($feedbacksData, $feedbackDataFormatted);
+ $feedbackdataformatted = self::format_submissions_feedback($feedback);
+ if ($feedbackdataformatted) {
+ array_push($feedbacksdata, $feedbackdataformatted);
}
if ($feedback->ismoderation) {
self::export_mod_agreements($feedback->id, $context, $path);
@@ -476,14 +476,14 @@ protected static function export_submissions_feedbacks($feedbacks, $context, $pa
self::export_feedback_files($context, $feedback->id, $path);
}
// coursework_feedbacks table contains all grading information
- if (!empty($feedbacksData)) {
+ if (!empty($feedbacksdata)) {
writer::with_context($context)
- ->export_data(array_merge($path, [get_string('privacy:feedbackspath', 'mod_coursework')]), (object) $feedbacksData);
+ ->export_data(array_merge($path, [get_string('privacy:feedbackspath', 'mod_coursework')]), (object) $feedbacksdata);
}
}
- protected static function export_feedback_files($context, $feedbackId, $currentpath) {
+ protected static function export_feedback_files($context, $feedbackid, $currentpath) {
$fs = get_file_storage();
- $files = $fs->get_area_files($context->id, 'mod_coursework', 'feedback', $feedbackId);
+ $files = $fs->get_area_files($context->id, 'mod_coursework', 'feedback', $feedbackid);
if (!empty($files)) {
foreach ($files as $file) {
writer::with_context($context)->export_file($currentpath, $file);
@@ -496,72 +496,72 @@ protected static function export_feedback_files($context, $feedbackId, $currentp
* @param \stdClass $feedback The coursework submission grade object
*/
protected static function format_submissions_feedback(\stdClass $feedback) {
- $feedbackData = [
+ $feedbackdata = [
'assessorid' => $feedback->assessorid,
'timecreated' => transform::datetime($feedback->timecreated),
'timemodified' => transform::datetime($feedback->timemodified),
'grade' => $feedback->grade,
'feedbackcomment' => $feedback->feedbackcomment,
'stage_identifier' => $feedback->stage_identifier,
- 'finalised' => transform::yesno($feedback->finalised)
+ 'finalised' => transform::yesno($feedback->finalised),
];
- return $feedbackData;
+ return $feedbackdata;
}
- protected static function export_coursework_extension($courseworkId, $userId, $context, $path) {
- $extension = self::get_coursework_extension($courseworkId, $userId);
+ protected static function export_coursework_extension($courseworkid, $userid, $context, $path) {
+ $extension = self::get_coursework_extension($courseworkid, $userid);
if ($extension) {
self::export_coursework_extension_data($extension, $context, $path);
}
}
- protected static function get_coursework_extension($courseworkId, $userId) {
+ protected static function get_coursework_extension($courseworkid, $userid) {
global $DB;
- $params = array('courseworkid' => $courseworkId, 'allocatableid' => $userId);
+ $params = ['courseworkid' => $courseworkid, 'allocatableid' => $userid];
$extension = $DB->get_record('coursework_extensions', $params);
return $extension;
}
protected static function export_coursework_extension_data($extension, $context, $path) {
- $extensionData = [
+ $extensiondata = [
'extended_deadline' => transform::datetime($extension->extended_deadline),
'extra_information_text' => $extension->extra_information_text,
- 'createdbyid' => $extension->createdbyid
+ 'createdbyid' => $extension->createdbyid,
];
writer::with_context($context)
- ->export_data(array_merge($path, [get_string('privacy:extensionpath', 'mod_coursework')]), (object) $extensionData);
+ ->export_data(array_merge($path, [get_string('privacy:extensionpath', 'mod_coursework')]), (object) $extensiondata);
}
- protected static function export_person_deadlines($courseworkId, $userId, $context, $path) {
- $personDeadline = self::get_person_deadline($courseworkId, $userId);
- if ($personDeadline) {
- self::export_person_deadline_data($personDeadline, $context, $path);
+ protected static function export_person_deadlines($courseworkid, $userid, $context, $path) {
+ $persondeadline = self::get_person_deadline($courseworkid, $userid);
+ if ($persondeadline) {
+ self::export_person_deadline_data($persondeadline, $context, $path);
}
}
- protected static function get_person_deadline($courseworkId, $userId) {
+ protected static function get_person_deadline($courseworkid, $userid) {
global $DB;
- $params = array('courseworkid' => $courseworkId, 'allocatableid' => $userId);
- $personDeadline = $DB->get_record('coursework_person_deadlines', $params);
- return $personDeadline;
+ $params = ['courseworkid' => $courseworkid, 'allocatableid' => $userid];
+ $persondeadline = $DB->get_record('coursework_person_deadlines', $params);
+ return $persondeadline;
}
- protected static function export_person_deadline_data($personDeadline, $context, $path) {
- $personDeadlineData = [
- 'personal_deadline' => transform::datetime($personDeadline->personal_deadline),
- 'timecreated' => transform::datetime($personDeadline->timecreated),
- 'timemodified' => transform::datetime($personDeadline->timemodified),
- 'createdbyid' => $personDeadline->createdbyid
+ protected static function export_person_deadline_data($persondeadline, $context, $path) {
+ $persondeadlinedata = [
+ 'personal_deadline' => transform::datetime($persondeadline->personal_deadline),
+ 'timecreated' => transform::datetime($persondeadline->timecreated),
+ 'timemodified' => transform::datetime($persondeadline->timemodified),
+ 'createdbyid' => $persondeadline->createdbyid,
];
writer::with_context($context)
- ->export_data(array_merge($path, [get_string('privacy:person_deadlines', 'mod_coursework')]), (object) $personDeadlineData);
+ ->export_data(array_merge($path, [get_string('privacy:person_deadlines', 'mod_coursework')]), (object) $persondeadlinedata);
}
- protected static function export_plagiarism_flags($courseworkId, $context, $path) {
- $plagiarism = self::get_plagiarism_flags($courseworkId);
+ protected static function export_plagiarism_flags($courseworkid, $context, $path) {
+ $plagiarism = self::get_plagiarism_flags($courseworkid);
if ($plagiarism) {
self::export_plagiarism_flags_data($plagiarism, $context, $path);
}
}
- protected static function get_plagiarism_flags($courseworkId) {
+ protected static function get_plagiarism_flags($courseworkid) {
global $DB;
- $param = array('courseworkid' => $courseworkId);
+ $param = ['courseworkid' => $courseworkid];
$plagiarism = $DB->get_record('coursework_plagiarism_flags', $param);
@@ -572,54 +572,54 @@ protected static function export_plagiarism_flags_data($plagiarism, $context, $p
$status = self::format_plagiarism_status($plagiarism->status);
- $plagiarismData = [
+ $plagiarismdata = [
'comment' => transform::datetime($plagiarism->comment),
'status' => $status,
'timecreated' => transform::datetime($plagiarism->timecreated),
'timemodified' => transform::datetime($plagiarism->timemodified),
- 'createdby' => $plagiarism->createdby
+ 'createdby' => $plagiarism->createdby,
];
writer::with_context($context)
- ->export_data(array_merge($path, [get_string('privacy:plagiarism_alert', 'mod_coursework')]), (object) $plagiarismData);
+ ->export_data(array_merge($path, [get_string('privacy:plagiarism_alert', 'mod_coursework')]), (object) $plagiarismdata);
}
protected static function format_plagiarism_status($status) {
switch ($status) {
case 0:
- $statusString = get_string('plagiarism_0', 'mod_coursework');
+ $statusstring = get_string('plagiarism_0', 'mod_coursework');
break;
case 1:
- $statusString = get_string('plagiarism_1', 'mod_coursework');
+ $statusstring = get_string('plagiarism_1', 'mod_coursework');
break;
case 2:
- $statusString = get_string('plagiarism_2', 'mod_coursework');
+ $statusstring = get_string('plagiarism_2', 'mod_coursework');
break;
case 3:
- $statusString = get_string('plagiarism_3', 'mod_coursework');
+ $statusstring = get_string('plagiarism_3', 'mod_coursework');
break;
default:
- $statusString = '';
+ $statusstring = '';
break;
}
- return $statusString;
+ return $statusstring;
}
- protected static function export_mod_agreements($feedbackId, $context, $path) {
- $agreement = self::get_mod_agreement($feedbackId);
+ protected static function export_mod_agreements($feedbackid, $context, $path) {
+ $agreement = self::get_mod_agreement($feedbackid);
if ($agreement) {
self::export_mod_agreement_data($agreement, $context, $path);
}
}
- protected static function get_mod_agreement($feedbackId) {
+ protected static function get_mod_agreement($feedbackid) {
global $DB;
- $param = array('feedbackid' => $feedbackId);
+ $param = ['feedbackid' => $feedbackid];
$agreement = $DB->get_record('coursework_mod_agreements', $param);
return $agreement;
}
protected static function export_mod_agreement_data($agreement, $context, $path) {
- $agreementData = [
+ $agreementdata = [
'moderatorid' => $agreement->moderatorid,
'agreement' => $agreement->agreement,
'modcomment' => $agreement->modcomment,
@@ -627,6 +627,6 @@ protected static function export_mod_agreement_data($agreement, $context, $path)
'timemodified' => transform::datetime($agreement->timemodified),
];
writer::with_context($context)
- ->export_data(array_merge($path, [get_string('privacy:moderator', 'mod_coursework')]), (object) $agreementData);
+ ->export_data(array_merge($path, [get_string('privacy:moderator', 'mod_coursework')]), (object) $agreementdata);
}
}
diff --git a/classes/render_helpers/grading_report/cells/_user_cell.php b/classes/render_helpers/grading_report/cells/_user_cell.php
index def69931..e3a7e8ea 100644
--- a/classes/render_helpers/grading_report/cells/_user_cell.php
+++ b/classes/render_helpers/grading_report/cells/_user_cell.php
@@ -48,7 +48,7 @@ public function get_table_cell($rowobject) {
*/
$user = $rowobject->get_allocatable();
- /* if ($rowobject->can_view_username()) {
+ /* if ($rowobject->can_view_username()) {
$content .= $OUTPUT->user_picture($user->get_raw_record());
} else {
$renderer = $PAGE->get_renderer('core');
@@ -69,35 +69,35 @@ public function get_table_cell($rowobject) {
*/
public function get_table_header($options = []) {
- $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context());
+ $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context());
//adding this line so that the sortable heading function will make a sortable link unique to the table
// If tablename is set
$tablename = (!empty($options['tablename'])) ? $options['tablename'] : '';
- // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous
- if ($viewanonymous || !$this->coursework->blindmarking) {
- $sort_by_first_name = $this->helper_sortable_heading(get_string('firstname'),
+ // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous
+ if ($viewanonymous || !$this->coursework->blindmarking) {
+ $sortbyfirstname = $this->helper_sortable_heading(get_string('firstname'),
'firstname',
$options['sorthow'],
$options['sortby'],
$tablename);
- $sort_by_last_name = $this->helper_sortable_heading(get_string('lastname'),
+ $sortbylastname = $this->helper_sortable_heading(get_string('lastname'),
'lastname',
$options['sorthow'],
$options['sortby'],
$tablename);
- } else { // otherwise display header without sorting
- $sort_by_first_name = get_string('firstname');
- $sort_by_last_name =get_string('lastname');
- }
+ } else { // otherwise display header without sorting
+ $sortbyfirstname = get_string('firstname');
+ $sortbylastname = get_string('lastname');
+ }
if ($this->fullname_format() == 'lf') {
- $sort_by_name = $sort_by_last_name . ' / ' . $sort_by_first_name;
+ $sortbyname = $sortbylastname . ' / ' . $sortbyfirstname;
} else {
- $sort_by_name = $sort_by_first_name . ' / ' . $sort_by_last_name;
+ $sortbyname = $sortbyfirstname . ' / ' . $sortbylastname;
}
- return $sort_by_name;
+ return $sortbyname;
}
/**
diff --git a/classes/render_helpers/grading_report/cells/cell_base.php b/classes/render_helpers/grading_report/cells/cell_base.php
index d3fdb5a6..7b187644 100644
--- a/classes/render_helpers/grading_report/cells/cell_base.php
+++ b/classes/render_helpers/grading_report/cells/cell_base.php
@@ -53,11 +53,11 @@ public function __construct($items = []) {
* @param string $sortby The current sort from the URL.
* @return string
*/
- protected function helper_sortable_heading($display_name, $field, $sort_how, $sortby = '', $tablename='') {
+ protected function helper_sortable_heading($displayname, $field, $sorthow, $sortby = '', $tablename='') {
global $PAGE;
- $params = array('id' => optional_param('id', 0, PARAM_INT));
+ $params = ['id' => optional_param('id', 0, PARAM_INT)];
$tablename = (!empty($tablename)) ? $tablename.'_' : '';
@@ -66,7 +66,7 @@ protected function helper_sortable_heading($display_name, $field, $sort_how, $so
}
$params[$tablename.'sortby'] = $field;
if ($field == $sortby) {
- $params[$tablename.'sorthow'] = $sort_how == 'ASC' ? 'DESC' : 'ASC';
+ $params[$tablename.'sorthow'] = $sorthow == 'ASC' ? 'DESC' : 'ASC';
} else {
// Default for columns not currently being sorted.
$params[$tablename.'sorthow'] = 'ASC';
@@ -82,7 +82,7 @@ protected function helper_sortable_heading($display_name, $field, $sort_how, $so
// }
// return html_writer::link($url, $display_name);
- return $display_name;
+ return $displayname;
}
/**
@@ -105,8 +105,8 @@ protected function get_renderer() {
* @return string|void
*/
public function cell_name() {
- $namespaced_class = get_class($this);
- $bits = explode('\\', $namespaced_class);
+ $namespacedclass = get_class($this);
+ $bits = explode('\\', $namespacedclass);
return end($bits);
}
diff --git a/classes/render_helpers/grading_report/cells/grade_for_gradebook_cell.php b/classes/render_helpers/grading_report/cells/grade_for_gradebook_cell.php
index d11947e2..9f1fecec 100644
--- a/classes/render_helpers/grading_report/cells/grade_for_gradebook_cell.php
+++ b/classes/render_helpers/grading_report/cells/grade_for_gradebook_cell.php
@@ -37,14 +37,14 @@ class grade_for_gradebook_cell extends cell_base {
* @param grading_table_row_base $row_object
* @return string
*/
- public function get_table_cell($row_object) {
+ public function get_table_cell($rowobject) {
global $USER;
$content = '';
- $ability = new ability(user::find($USER), $row_object->get_coursework());
+ $ability = new ability(user::find($USER), $rowobject->get_coursework());
$judge = new grade_judge($this->coursework);
- if ($ability->can('show', $judge->get_feedback_that_is_promoted_to_gradebook($row_object->get_submission())) && !$row_object->get_submission()->editable_final_feedback_exist()) {
- $grade = $judge->get_grade_capped_by_submission_time($row_object->get_submission());
+ if ($ability->can('show', $judge->get_feedback_that_is_promoted_to_gradebook($rowobject->get_submission())) && !$rowobject->get_submission()->editable_final_feedback_exist()) {
+ $grade = $judge->get_grade_capped_by_submission_time($rowobject->get_submission());
$content .= $judge->grade_to_display($grade);
}
return $this->get_new_cell_with_class($content);
diff --git a/classes/render_helpers/grading_report/cells/group_cell.php b/classes/render_helpers/grading_report/cells/group_cell.php
index 93fb8e2b..1ae59bc5 100644
--- a/classes/render_helpers/grading_report/cells/group_cell.php
+++ b/classes/render_helpers/grading_report/cells/group_cell.php
@@ -37,27 +37,27 @@ class group_cell extends cell_base implements allocatable_cell {
* @throws coding_exception
* @return string
*/
- public function get_table_cell($row_object) {
+ public function get_table_cell($rowobject) {
$content = '';
/**
* @var group $group
*/
- $group = $row_object->get_allocatable();
+ $group = $rowobject->get_allocatable();
$content .= ''.$group->name().'';
$content .= ' ';
$content .= '';
$content .= '';
$content .= ' ';
@@ -95,12 +95,12 @@ public function get_table_header_class() {
* @param user $group_member
* @return string
*/
- protected function add_group_member_name($group_member, $row_object) {
+ protected function add_group_member_name($groupmember, $rowobject) {
$text = '';
return $text;
diff --git a/classes/render_helpers/grading_report/cells/idnumber_cell.php b/classes/render_helpers/grading_report/cells/idnumber_cell.php
index b9f74155..046c0609 100644
--- a/classes/render_helpers/grading_report/cells/idnumber_cell.php
+++ b/classes/render_helpers/grading_report/cells/idnumber_cell.php
@@ -57,17 +57,17 @@ public function get_table_header($options = []) {
// allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous
if ($viewanonymous || !$this->coursework->blindmarking) {
- $sort_header = $this->helper_sortable_heading(get_string('idnumber'),
+ $sortheader = $this->helper_sortable_heading(get_string('idnumber'),
'idnumber',
$options['sorthow'],
$options['sortby'],
$tablename);
} else { // otherwise display header without sorting
- $sort_header = get_string('idnumber');
+ $sortheader = get_string('idnumber');
}
- return $sort_header;
+ return $sortheader;
}
/**
diff --git a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php
index 53aca8a7..dff7b8be 100644
--- a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php
+++ b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php
@@ -74,15 +74,15 @@ public function get_table_cell($rowobject) {
$rowobject->get_submission()->final_grade_agreed() &&
($this->stage->user_is_moderator($USER))) {
- $moderation_params = array(
+ $moderationparams = [
'submissionid' => $rowobject->get_submission()->id,
'moderatorid' => $USER->id,
'stage_identifier' => $this->stage->identifier(),
- 'feedbackid' => $rowobject->get_single_feedback()->id
- );
+ 'feedbackid' => $rowobject->get_single_feedback()->id,
+ ];
// allow moderations if feedback exists
- $new_moderation = moderation::build($moderation_params);
- if ($ability->can('new', $new_moderation) && ($rowobject->get_single_feedback()->finalised || is_siteadmin($USER->id))) {
+ $newmoderation = moderation::build($moderationparams);
+ if ($ability->can('new', $newmoderation) && ($rowobject->get_single_feedback()->finalised || is_siteadmin($USER->id))) {
$content .= $this->new_moderation_button($rowobject, user::find($USER));
$content .= html_writer::empty_tag('br');
}
@@ -162,23 +162,23 @@ private function new_moderation_button($rowobject, $assessor) {
// moderation only done for single marking courseworks
$feedback = $rowobject->get_submission()->get_assessor_feedback_by_stage('assessor_1');
- $moderation_params = array(
+ $moderationparams = [
'submission' => $rowobject->get_submission(),
'assessor' => $assessor,
'stage' => $this->stage,
- 'feedbackid' => $feedback->id
- );
- $link = $this->get_router()->get_path('new moderations', $moderation_params);
+ 'feedbackid' => $feedback->id,
+ ];
+ $link = $this->get_router()->get_path('new moderations', $moderationparams);
- $link_id = 'new_moderation_' . $rowobject->get_coursework()
- ->get_allocatable_identifier_hash($rowobject->get_allocatable());
+ $linkid = 'new_moderation_' . $rowobject->get_coursework()
+ ->get_allocatable_identifier_hash($rowobject->get_allocatable());
$title = get_string('moderate', 'coursework');
return $OUTPUT->action_link($link,
$title,
null,
- array('class' => 'new_moderation', 'id' => $link_id));
+ ['class' => 'new_moderation', 'id' => $linkid]);
}
/**
@@ -190,13 +190,13 @@ private function edit_moderation_button($rowobject) {
global $OUTPUT;
$feedback = $rowobject->get_submission()->get_assessor_feedback_by_stage('assessor_1');
- $feedback_params = array(
- 'moderation' => $this->stage->get_moderation_for_feedback($feedback)
- );
- $link = $this->get_router()->get_path('edit moderation', $feedback_params);
+ $feedbackparams = [
+ 'moderation' => $this->stage->get_moderation_for_feedback($feedback),
+ ];
+ $link = $this->get_router()->get_path('edit moderation', $feedbackparams);
- $link_id = 'edit_moderation_' . $rowobject->get_coursework()
- ->get_allocatable_identifier_hash($rowobject->get_allocatable());
+ $linkid = 'edit_moderation_' . $rowobject->get_coursework()
+ ->get_allocatable_identifier_hash($rowobject->get_allocatable());
$title = get_string('editmoderation', 'coursework');
$icon = new pix_icon('edit', $title, 'coursework');
@@ -204,7 +204,7 @@ private function edit_moderation_button($rowobject) {
return $OUTPUT->action_icon($link,
$icon,
null,
- array('id' => $link_id));
+ ['id' => $linkid]);
}
@@ -217,18 +217,18 @@ private function show_moderation_button($rowobject) {
global $OUTPUT;
$feedback = $rowobject->get_submission()->get_assessor_feedback_by_stage('assessor_1');
- $moderation_params = array(
- 'moderation' => $this->stage->get_moderation_for_feedback($feedback)
- );
+ $moderationparams = [
+ 'moderation' => $this->stage->get_moderation_for_feedback($feedback),
+ ];
$linktitle = get_string('viewmoderation', 'mod_coursework');
- $link_id = "show_moderation_" . $rowobject->get_coursework()
- ->get_allocatable_identifier_hash($rowobject->get_allocatable());
- $link = $this->get_router()->get_path('show moderation', $moderation_params);
+ $linkid = "show_moderation_" . $rowobject->get_coursework()
+ ->get_allocatable_identifier_hash($rowobject->get_allocatable());
+ $link = $this->get_router()->get_path('show moderation', $moderationparams);
return $OUTPUT->action_link($link,
$linktitle,
null,
- array('class' => 'show_moderation', 'id' => $link_id));
+ ['class' => 'show_moderation', 'id' => $linkid]);
}
}
diff --git a/classes/render_helpers/grading_report/cells/moderation_cell.php b/classes/render_helpers/grading_report/cells/moderation_cell.php
index 91addf16..ccceb0a1 100644
--- a/classes/render_helpers/grading_report/cells/moderation_cell.php
+++ b/classes/render_helpers/grading_report/cells/moderation_cell.php
@@ -53,27 +53,27 @@ protected function after_initialisation($items) {
* @throws coding_exception
* @return string
*/
- public function get_table_cell($row_object) {
+ public function get_table_cell($rowobject) {
global $USER;
$content = '';
- if ($this->stage->has_feedback($row_object->get_allocatable())) {
- $content .= $this->add_existing_moderator_feedback_details_to_cell($row_object);
+ if ($this->stage->has_feedback($rowobject->get_allocatable())) {
+ $content .= $this->add_existing_moderator_feedback_details_to_cell($rowobject);
}
- $ability = new ability(user::find($USER), $row_object->get_coursework());
- $existing_feedback = $this->stage->get_feedback_for_allocatable($row_object->get_allocatable());
- $new_feedback = feedback::build(array(
- 'submissionid' => $row_object->get_submission_id(),
+ $ability = new ability(user::find($USER), $rowobject->get_coursework());
+ $existingfeedback = $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable());
+ $newfeedback = feedback::build([
+ 'submissionid' => $rowobject->get_submission_id(),
'stage_identifier' => $this->stage->identifier(),
'assessorid' => $USER->id,
- ));
+ ]);
// New or edit for moderators
- if ($existing_feedback && $ability->can('edit', $existing_feedback)) { // Edit
- $content .= $this->add_edit_feedback_link_to_cell($row_object, $existing_feedback);
- } else if ($ability->can('new', $new_feedback)) { // New
- $content .= $this->add_new_feedback_link_to_cell($row_object);
+ if ($existingfeedback && $ability->can('edit', $existingfeedback)) { // Edit
+ $content .= $this->add_edit_feedback_link_to_cell($rowobject, $existingfeedback);
+ } else if ($ability->can('new', $newfeedback)) { // New
+ $content .= $this->add_new_feedback_link_to_cell($rowobject);
}
return $this->get_new_cell_with_class($content);
@@ -107,8 +107,8 @@ public function get_table_header_class() {
* @param grading_table_row_base $row_object
* @return string
*/
- protected function add_existing_moderator_feedback_details_to_cell($row_object) {
- $feedback = $this->stage->get_feedback_for_allocatable($row_object->get_allocatable());
+ protected function add_existing_moderator_feedback_details_to_cell($rowobject) {
+ $feedback = $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable());
$html = '';
$html .= $feedback->assessor()->profile_link();
$html .= ' ';
@@ -122,21 +122,21 @@ protected function add_existing_moderator_feedback_details_to_cell($row_object)
* @return string
* @throws \coding_exception
*/
- protected function add_edit_feedback_link_to_cell($row_object, $feedback) {
+ protected function add_edit_feedback_link_to_cell($rowobject, $feedback) {
global $OUTPUT;
$title = get_string('moderatethis', 'coursework');
- $icon = new pix_icon('moderate', $title, 'coursework', array('width' => '20px'));
+ $icon = new pix_icon('moderate', $title, 'coursework', ['width' => '20px']);
- $feedback_params = array(
+ $feedbackparams = [
'feedback' => $feedback,
- );
- $link = $this->get_router()->get_path('edit feedback', $feedback_params);
- $html_attributes = array(
- 'id' => 'edit_moderator_feedback_' . $row_object->get_filename_hash(),
+ ];
+ $link = $this->get_router()->get_path('edit feedback', $feedbackparams);
+ $htmlattributes = [
+ 'id' => 'edit_moderator_feedback_' . $rowobject->get_filename_hash(),
'class' => 'edit_feedback',
- );
- $iconlink = $OUTPUT->action_icon($link, $icon, null, $html_attributes);
+ ];
+ $iconlink = $OUTPUT->action_icon($link, $icon, null, $htmlattributes);
return ' ' . $iconlink;
}
@@ -146,23 +146,23 @@ protected function add_edit_feedback_link_to_cell($row_object, $feedback) {
* @return string
* @throws \coding_exception
*/
- protected function add_new_feedback_link_to_cell($row_object) {
+ protected function add_new_feedback_link_to_cell($rowobject) {
global $OUTPUT;
$title = get_string('moderatethis', 'coursework');
- $icon = new pix_icon('moderate', $title, 'coursework', array('width' => '20px'));
+ $icon = new pix_icon('moderate', $title, 'coursework', ['width' => '20px']);
- $feedback_params = array(
- 'submission' => $row_object->get_submission(),
+ $feedbackparams = [
+ 'submission' => $rowobject->get_submission(),
'stage' => $this->stage,
- );
- $link = $this->get_router()->get_path('new moderator feedback', $feedback_params);
+ ];
+ $link = $this->get_router()->get_path('new moderator feedback', $feedbackparams);
- $html_attributes = array(
- 'id' => 'new_moderator_feedback_' . $row_object->get_coursework()->get_allocatable_identifier_hash($row_object->get_allocatable()),
+ $htmlattributes = [
+ 'id' => 'new_moderator_feedback_' . $rowobject->get_coursework()->get_allocatable_identifier_hash($rowobject->get_allocatable()),
'class' => 'new_feedback',
- );
- $iconlink = $OUTPUT->action_icon($link, $icon, null, $html_attributes);
+ ];
+ $iconlink = $OUTPUT->action_icon($link, $icon, null, $htmlattributes);
return ' ' . $iconlink;
}
diff --git a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php
index 8654576a..84107692 100644
--- a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php
+++ b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php
@@ -77,70 +77,70 @@ public function get_content($rowobject) {
$finalfeedback = $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable());
if ($finalfeedback !== false) {
- $grade_judge = new grade_judge($this->coursework);
- $content .= $grade_judge->grade_to_display($finalfeedback->get_grade());
- // $content .= html_writer::empty_tag('br');
- // $content .= ' by: ' . $finalfeedback->get_assesor_username();
+ $gradejudge = new grade_judge($this->coursework);
+ $content .= $gradejudge->grade_to_display($finalfeedback->get_grade());
+ // $content .= html_writer::empty_tag('br');
+ // $content .= ' by: ' . $finalfeedback->get_assesor_username();
}
// Edit/new link
- $existing_feedback = $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable());
+ $existingfeedback = $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable());
$title = get_string('editfinalgrade', 'coursework');
$icon = new pix_icon('edit', $title, 'coursework');
$iconlink = '';
- if ($existing_feedback && $ability->can('edit', $existing_feedback)) {
+ if ($existingfeedback && $ability->can('edit', $existingfeedback)) {
- $feedback_route_params = array(
- 'feedback' => $finalfeedback
- );
- $link = $this->get_router()->get_path('ajax edit feedback', $feedback_route_params);
+ $feedbackrouteparams = [
+ 'feedback' => $finalfeedback,
+ ];
+ $link = $this->get_router()->get_path('ajax edit feedback', $feedbackrouteparams);
$iconlink = $OUTPUT->action_icon($link,
$icon,
null,
- array(
+ [
'class' => 'edit_final_feedback',
'id' => 'edit_final_feedback_' . $rowobject->get_coursework()
- ->get_allocatable_identifier_hash($rowobject->get_allocatable())));
+ ->get_allocatable_identifier_hash($rowobject->get_allocatable())]);
} else if ($rowobject->has_submission()) { // New
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $rowobject->get_submission()->id,
'assessorid' => $USER->id,
'stage_identifier' => $this->stage->identifier(),
- );
- $new_feedback = feedback::build($feedback_params);
+ ];
+ $newfeedback = feedback::build($feedbackparams);
// If the user is a site admin then they can add final feedback
- if ($ability->can('new', $new_feedback) || is_siteadmin()) {
+ if ($ability->can('new', $newfeedback) || is_siteadmin()) {
$title = get_string('addfinalfeedback', 'coursework');
- $feedback_route_params = array(
+ $feedbackrouteparams = [
'submission' => $rowobject->get_submission(),
'assessor' => $USER,
'stage' => $this->stage,
- );
- $link = $this->get_router()->get_path('ajax new final feedback', $feedback_route_params);
+ ];
+ $link = $this->get_router()->get_path('ajax new final feedback', $feedbackrouteparams);
$iconlink = $OUTPUT->action_link($link,
$title,
null,
- array('class' => 'new_final_feedback',
+ ['class' => 'new_final_feedback',
'id' => 'new_final_feedback_' . $rowobject->get_coursework()
- ->get_allocatable_identifier_hash($rowobject->get_allocatable())));
+ ->get_allocatable_identifier_hash($rowobject->get_allocatable())]);
- } else if ($existing_feedback && $ability->can('show', $existing_feedback)) {
+ } else if ($existingfeedback && $ability->can('show', $existingfeedback)) {
$linktitle = get_string('viewfeedback', 'mod_coursework');
- $link_id = "show_feedback_" . $rowobject->get_coursework()
- ->get_allocatable_identifier_hash($rowobject->get_allocatable());
+ $linkid = "show_feedback_" . $rowobject->get_coursework()
+ ->get_allocatable_identifier_hash($rowobject->get_allocatable());
$link = $this->get_router()
- ->get_path('show feedback', array('feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable())));
+ ->get_path('show feedback', ['feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable())]);
$iconlink = $OUTPUT->action_link($link,
$linktitle,
null,
- array('class' => 'show_feedback', 'id' => $link_id));
+ ['class' => 'show_feedback', 'id' => $linkid]);
}
}
@@ -150,13 +150,13 @@ public function get_content($rowobject) {
if ($finalfeedback !== false) {
$content .= html_writer::empty_tag('br');
- if ((!$this->coursework->sampling_enabled() || $rowobject->get_submission()->sampled_feedback_exists()) && ($finalfeedback->get_feedbacks_assessorid() == 0
+ if ((!$this->coursework->sampling_enabled() || $rowobject->get_submission()->sampled_feedback_exists()) && ($finalfeedback->get_feedbacks_assessorid() == 0
&& $finalfeedback->timecreated == $finalfeedback->timemodified)
|| $finalfeedback->lasteditedbyuser == 0) { // if the grade was automatically agreed
- $content .= "(".get_string('automaticagreement', 'coursework').")";
- } else {
- $content .= ' by: ' . $finalfeedback->get_assesor_username();
- }
+ $content .= "(".get_string('automaticagreement', 'coursework').")";
+ } else {
+ $content .= ' by: ' . $finalfeedback->get_assesor_username();
+ }
}
return $content;
}
@@ -171,8 +171,8 @@ public function get_table_header($options = []) {
// If tablename is set
$tablename = (isset($options['tablename'])) ? $options['tablename'] : '';
- $column_name = get_string('agreedgrade', 'coursework');
- return $this->helper_sortable_heading($column_name, 'finalgrade', $options['sorthow'], $options['sortby'], $tablename);
+ $columnname = get_string('agreedgrade', 'coursework');
+ return $this->helper_sortable_heading($columnname, 'finalgrade', $options['sorthow'], $options['sortby'], $tablename);
}
/**
diff --git a/classes/render_helpers/grading_report/cells/personal_deadline_cell.php b/classes/render_helpers/grading_report/cells/personal_deadline_cell.php
index 1b0d75c2..e15c3e70 100644
--- a/classes/render_helpers/grading_report/cells/personal_deadline_cell.php
+++ b/classes/render_helpers/grading_report/cells/personal_deadline_cell.php
@@ -38,40 +38,40 @@ class personal_deadline_cell extends cell_base {
* @throws coding_exception
* @return string
*/
- public function get_table_cell($row_object) {
+ public function get_table_cell($rowobject) {
global $OUTPUT, $USER;
- $coursework = $row_object->get_coursework();
+ $coursework = $rowobject->get_coursework();
$deadline = $coursework->get_deadline();
$content = '';
- $new_personal_deadline_params = array(
- 'allocatableid' => $row_object->get_allocatable()->id(),
- 'allocatabletype' => $row_object->get_allocatable()->type(),
- 'courseworkid' => $row_object->get_coursework()->id,
- );
+ $newpersonaldeadlineparams = [
+ 'allocatableid' => $rowobject->get_allocatable()->id(),
+ 'allocatabletype' => $rowobject->get_allocatable()->type(),
+ 'courseworkid' => $rowobject->get_coursework()->id,
+ ];
- $personal_deadline = personal_deadline::find_or_build($new_personal_deadline_params);
- if ($personal_deadline->personal_deadline) {
- $deadline = $personal_deadline->personal_deadline;
+ $personaldeadline = personal_deadline::find_or_build($newpersonaldeadlineparams);
+ if ($personaldeadline->personal_deadline) {
+ $deadline = $personaldeadline->personal_deadline;
}
$date = userdate($deadline, '%a, %d %b %Y, %H:%M');
$content .= ' '.$date.' ';
- $ability = new ability(user::find($USER, false), $row_object->get_coursework());
+ $ability = new ability(user::find($USER, false), $rowobject->get_coursework());
$class = 'edit_personal_deadline';
- if (!$ability->can('edit', $personal_deadline)) {
+ if (!$ability->can('edit', $personaldeadline)) {
$class .= ' display-none';
}
- $link = $this->get_router()->get_path('edit personal deadline', $new_personal_deadline_params);
+ $link = $this->get_router()->get_path('edit personal deadline', $newpersonaldeadlineparams);
// $link = '/';
$icon = new pix_icon('edit', 'Edit personal deadline', 'coursework');
- $new_personal_deadline_params['multipleuserdeadlines'] = 0;
+ $newpersonaldeadlineparams['multipleuserdeadlines'] = 0;
$content .= $OUTPUT->action_icon($link,
$icon,
null,
- array('class' => $class,'data-get' => json_encode($new_personal_deadline_params), 'data-time' => date('d-m-Y H:i', $deadline) ));
+ ['class' => $class, 'data-get' => json_encode($newpersonaldeadlineparams), 'data-time' => date('d-m-Y H:i', $deadline) ]);
$content .= ' ';
return $this->get_new_cell_with_order_data(['display' => $content, '@data-order' => $deadline]);
diff --git a/classes/render_helpers/grading_report/cells/plagiarism_cell.php b/classes/render_helpers/grading_report/cells/plagiarism_cell.php
index c5040102..d20b35ef 100644
--- a/classes/render_helpers/grading_report/cells/plagiarism_cell.php
+++ b/classes/render_helpers/grading_report/cells/plagiarism_cell.php
@@ -48,9 +48,9 @@ public function get_table_cell($rowobject) {
if ($rowobject->has_submission() && $ability->can('show', $rowobject->get_submission())) {
// The files and the form to resubmit them.
- $submission_files = $rowobject->get_submission_files();
- if ($submission_files) {
- $content .= $this->get_renderer()->render_plagiarism_links(new mod_coursework_submission_files($submission_files));
+ $submissionfiles = $rowobject->get_submission_files();
+ if ($submissionfiles) {
+ $content .= $this->get_renderer()->render_plagiarism_links(new mod_coursework_submission_files($submissionfiles));
}
}
diff --git a/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php b/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php
index f4b22698..7f07aab2 100644
--- a/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php
+++ b/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php
@@ -50,25 +50,25 @@ public function get_table_cell($rowobject) {
$ability = new ability(user::find($USER), $rowobject->get_coursework());
if ($rowobject->has_submission() && $rowobject->get_submission()->finalised) {
- $plagiarism_flag_params = array(
- 'submissionid' => $rowobject->get_submission()->id
- );
- $plagiarism_flag = plagiarism_flag::find($plagiarism_flag_params);
+ $plagiarismflagparams = [
+ 'submissionid' => $rowobject->get_submission()->id,
+ ];
+ $plagiarismflag = plagiarism_flag::find($plagiarismflagparams);
- if (!$plagiarism_flag) { // if plagiarism flag for this submission doesn't exist, we can create one
- $plagiarism_flag_params = array('courseworkid' => $rowobject->get_coursework()->id,
- 'submissionid' => $rowobject->get_submission()->id);
- $new_plagiarism_flag = plagiarism_flag::build($plagiarism_flag_params);
+ if (!$plagiarismflag) { // if plagiarism flag for this submission doesn't exist, we can create one
+ $plagiarismflagparams = ['courseworkid' => $rowobject->get_coursework()->id,
+ 'submissionid' => $rowobject->get_submission()->id];
+ $newplagiarismflag = plagiarism_flag::build($plagiarismflagparams);
- if ($ability->can('new', $new_plagiarism_flag)) {
+ if ($ability->can('new', $newplagiarismflag)) {
$content .= $this->new_flag_plagiarism_button($rowobject); // new button
$content .= html_writer::empty_tag('br');
}
} else {
- $content .= "status.">".get_string('plagiarism_' . $plagiarism_flag->status, 'coursework')." ";
+ $content .= " status.">".get_string('plagiarism_' . $plagiarismflag->status, 'coursework')." ";
- if ($ability->can('edit', $plagiarism_flag)) { // Edit
+ if ($ability->can('edit', $plagiarismflag)) { // Edit
$content .= $this->edit_flag_plagiarism_button($rowobject); // edit button
}
$content .= " ";
@@ -105,22 +105,22 @@ public function header_group() {
* @return string
* @throws \coding_exception
*/
- private function new_flag_plagiarism_button($row_object) {
+ private function new_flag_plagiarism_button($rowobject) {
global $OUTPUT;
$title = get_string('flagplagiarism', 'coursework');
- $feedback_params = array(
- 'submission' => $row_object->get_submission()
- );
- $link = $this->get_router()->get_path('new plagiarism flag', $feedback_params);
+ $feedbackparams = [
+ 'submission' => $rowobject->get_submission(),
+ ];
+ $link = $this->get_router()->get_path('new plagiarism flag', $feedbackparams);
- $html_attributes = array(
- 'id' => 'new_plagiarism_flag_' . $row_object->get_coursework()->get_allocatable_identifier_hash($row_object->get_allocatable()),
+ $htmlattributes = [
+ 'id' => 'new_plagiarism_flag_' . $rowobject->get_coursework()->get_allocatable_identifier_hash($rowobject->get_allocatable()),
'class' => 'new_plagiarism_flag',
- );
+ ];
- return $OUTPUT->action_link($link, $title, null, $html_attributes);
+ return $OUTPUT->action_link($link, $title, null, $htmlattributes);
}
/**
@@ -128,19 +128,19 @@ private function new_flag_plagiarism_button($row_object) {
* @return string
* @throws \coding_exception
*/
- private function edit_flag_plagiarism_button($row_object) {
+ private function edit_flag_plagiarism_button($rowobject) {
global $OUTPUT;
$title = get_string('editflagplagiarism', 'coursework');
- $feedback_params = array(
- 'flag' => $row_object->get_plagiarism_flag()
- );
- $link = $this->get_router()->get_path('edit plagiarism flag', $feedback_params);
+ $feedbackparams = [
+ 'flag' => $rowobject->get_plagiarism_flag(),
+ ];
+ $link = $this->get_router()->get_path('edit plagiarism flag', $feedbackparams);
- $link_id = 'edit_plagiarism_flag_' . $row_object->get_coursework()->get_allocatable_identifier_hash($row_object->get_allocatable());
+ $linkid = 'edit_plagiarism_flag_' . $rowobject->get_coursework()->get_allocatable_identifier_hash($rowobject->get_allocatable());
$icon = new pix_icon('edit', $title, 'coursework');
- return $OUTPUT->action_icon($link, $icon, null, array('id' => $link_id));
+ return $OUTPUT->action_icon($link, $icon, null, ['id' => $linkid]);
}
}
diff --git a/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php b/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php
index 1573f4e2..5474c86d 100644
--- a/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php
+++ b/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php
@@ -87,13 +87,13 @@ public function get_content($rowobject) {
($this->stage->user_is_assessor($USER) ||
has_capability('mod/coursework:administergrades', $this->coursework->get_context()))) {
- $feedback_params = array(
+ $feedbackparams = [
'submissionid' => $rowobject->get_submission()->id,
'assessorid' => $USER->id,
'stage_identifier' => $this->stage->identifier(),
- );
- $new_feedback = feedback::build($feedback_params);
- if ($ability->can('new', $new_feedback)) {
+ ];
+ $newfeedback = feedback::build($feedbackparams);
+ if ($ability->can('new', $newfeedback)) {
$content .= $this->new_feedback_button($rowobject, user::find($USER));
$content .= html_writer::empty_tag('br');
}
@@ -166,13 +166,13 @@ public function header_group() {
private function edit_feedback_button($rowobject) {
global $OUTPUT;
- $feedback_params = array(
- 'feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable())
- );
- $link = $this->get_router()->get_path('edit feedback', $feedback_params);
+ $feedbackparams = [
+ 'feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable()),
+ ];
+ $link = $this->get_router()->get_path('edit feedback', $feedbackparams);
- $link_id = 'edit_final_feedback_' . $rowobject->get_coursework()
- ->get_allocatable_identifier_hash($rowobject->get_allocatable());
+ $linkid = 'edit_final_feedback_' . $rowobject->get_coursework()
+ ->get_allocatable_identifier_hash($rowobject->get_allocatable());
$title = get_string('editfinalgrade', 'coursework');
$icon = new pix_icon('edit', $title, 'coursework');
@@ -180,7 +180,7 @@ private function edit_feedback_button($rowobject) {
return $OUTPUT->action_icon($link,
$icon,
null,
- array('id' => $link_id, 'class' => 'edit_final_feedback'));
+ ['id' => $linkid, 'class' => 'edit_final_feedback']);
}
@@ -193,14 +193,14 @@ private function show_feedback_button($rowobject) {
global $OUTPUT;
$linktitle = get_string('viewfeedback', 'mod_coursework');
- $link_id = "show_feedback_" . $rowobject->get_coursework()
+ $linkid = "show_feedback_" . $rowobject->get_coursework()
->get_allocatable_identifier_hash($rowobject->get_allocatable());
$link = $this->get_router()
- ->get_path('show feedback', array('feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable())));
+ ->get_path('show feedback', ['feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable())]);
$iconlink = $OUTPUT->action_link($link,
$linktitle,
null,
- array('class' => 'show_feedback', 'id' => $link_id));
+ ['class' => 'show_feedback', 'id' => $linkid]);
return $iconlink;
}
@@ -214,22 +214,22 @@ private function show_feedback_button($rowobject) {
private function new_feedback_button($rowobject, $assessor) {
global $OUTPUT;
- $feedback_params = array(
+ $feedbackparams = [
'submission' => $rowobject->get_submission(),
'assessor' => $assessor,
'stage' => $this->stage,
- );
- $link = $this->get_router()->get_path('ajax new final feedback', $feedback_params);
+ ];
+ $link = $this->get_router()->get_path('ajax new final feedback', $feedbackparams);
- $link_id = 'new_final_feedback_' . $rowobject->get_coursework()
- ->get_allocatable_identifier_hash($rowobject->get_allocatable());
+ $linkid = 'new_final_feedback_' . $rowobject->get_coursework()
+ ->get_allocatable_identifier_hash($rowobject->get_allocatable());
$title = get_string('addfinalfeedback', 'coursework');
return $OUTPUT->action_link($link,
$title,
null,
- array('class' => 'new_final_feedback', 'id' => $link_id));
+ ['class' => 'new_final_feedback', 'id' => $linkid]);
}
}
diff --git a/classes/render_helpers/grading_report/cells/submission_cell.php b/classes/render_helpers/grading_report/cells/submission_cell.php
index ff4eff2b..975ebbc3 100644
--- a/classes/render_helpers/grading_report/cells/submission_cell.php
+++ b/classes/render_helpers/grading_report/cells/submission_cell.php
@@ -51,15 +51,15 @@ public function get_table_cell($rowobject) {
if ($rowobject->has_submission() && $ability->can('show', $rowobject->get_submission())) {
// The files and the form to resubmit them.
- $submission_files = $rowobject->get_submission_files();
- if ($submission_files) {
- $content .= $this->get_renderer()->render_submission_files(new mod_coursework_submission_files($submission_files));
+ $submissionfiles = $rowobject->get_submission_files();
+ if ($submissionfiles) {
+ $content .= $this->get_renderer()->render_submission_files(new mod_coursework_submission_files($submissionfiles));
}
if ($ability->can('revert', $rowobject->get_submission())) {
$url = new moodle_url('/mod/coursework/actions/revert.php',
- array('cmid' => $rowobject->get_course_module_id(),
- 'submissionid' => $rowobject->get_submission_id()));
+ ['cmid' => $rowobject->get_course_module_id(),
+ 'submissionid' => $rowobject->get_submission_id()]);
$content .= html_writer::empty_tag('br');
$revertstring = get_string('revert', 'coursework');
$content .= html_writer::link($url, $revertstring);
@@ -70,25 +70,25 @@ public function get_table_cell($rowobject) {
$ability = new ability(user::find($USER), $rowobject->get_coursework());
- $submission_on_behalf_of_allocatable = submission::build(array(
+ $submissiononbehalfofallocatable = submission::build([
'allocatableid' => $rowobject->get_allocatable()
->id(),
'allocatabletype' => $rowobject->get_allocatable()
->type(),
'courseworkid' => $rowobject->get_coursework()->id,
'createdby' => $USER->id,
- ));
+ ]);
if (($rowobject->get_submission()&& !$rowobject->get_submission()->finalised)
|| !$rowobject->get_submission()) {
- if ($ability->can('new', $submission_on_behalf_of_allocatable) && (!$rowobject->get_coursework()->has_deadline()
+ if ($ability->can('new', $submissiononbehalfofallocatable) && (!$rowobject->get_coursework()->has_deadline()
|| $rowobject->get_coursework()->allow_late_submissions() || ($rowobject->get_personal_deadlines() >= time() || ($rowobject->has_extension() && $rowobject->get_extension()->extended_deadline > time())))) {
// New submission on behalf of button
$url = $this->get_router()
- ->get_path('new submission', array('submission' => $submission_on_behalf_of_allocatable), true);
+ ->get_path('new submission', ['submission' => $submissiononbehalfofallocatable], true);
$label =
'Submit on behalf';
@@ -96,7 +96,7 @@ public function get_table_cell($rowobject) {
$content .= $OUTPUT->action_link($url,
$label,
null,
- array('class' => 'new_submission'));
+ ['class' => 'new_submission']);
} else if ($rowobject->has_submission() &&
$ability->can('edit', $rowobject->get_submission()) &&
!$rowobject->has_feedback() ) {
@@ -104,7 +104,7 @@ public function get_table_cell($rowobject) {
// Edit submission on behalf of button
$url = $this->get_router()
- ->get_path('edit submission', array('submission' => $rowobject->get_submission()), true);
+ ->get_path('edit submission', ['submission' => $rowobject->get_submission()], true);
$label =
'Edit submission on behalf of this ' . ($rowobject->get_coursework()
@@ -115,7 +115,7 @@ public function get_table_cell($rowobject) {
$content .= ' '.$OUTPUT->action_icon($url,
$icon,
null,
- array('class' => 'edit_submission'));
+ ['class' => 'edit_submission']);
}
}
diff --git a/classes/render_helpers/grading_report/cells/time_submitted_cell.php b/classes/render_helpers/grading_report/cells/time_submitted_cell.php
index 338c7a26..1e65963d 100644
--- a/classes/render_helpers/grading_report/cells/time_submitted_cell.php
+++ b/classes/render_helpers/grading_report/cells/time_submitted_cell.php
@@ -40,41 +40,41 @@ class time_submitted_cell extends cell_base {
* @throws coding_exception
* @return string
*/
- public function get_table_cell($row_object) {
+ public function get_table_cell($rowobject) {
- $data = $this->prepare_content_cell($row_object);
+ $data = $this->prepare_content_cell($rowobject);
return $this->get_new_cell_with_order_data($data);
}
- public function prepare_content_cell($row_object) {
+ public function prepare_content_cell($rowobject) {
global $OUTPUT, $USER;
$content = '';
- $time_submitted = $displayeddeadline = 0;
+ $timesubmitted = $displayeddeadline = 0;
- $coursework = $row_object->get_coursework();
- $submission = $row_object->get_submission();
+ $coursework = $rowobject->get_coursework();
+ $submission = $rowobject->get_submission();
if ($submission) {
// If we have groups enabled and this is not the student who submitted the
// group files, show who did.
- if ($coursework->is_configured_to_have_group_submissions() && !$row_object->has_submission()) {
+ if ($coursework->is_configured_to_have_group_submissions() && !$rowobject->has_submission()) {
$user = user::get_object($submission->userid);
- if ($row_object->can_view_username()) {
+ if ($rowobject->can_view_username()) {
$content .= "Submitted by";
$content .= html_writer::empty_tag('br');
$content .= $OUTPUT->user_picture($user);
- $content .= $row_object->get_user_name(true);
+ $content .= $rowobject->get_user_name(true);
}
$content .= html_writer::empty_tag('br');
}
- $time_submitted = $submission->time_submitted();
+ $timesubmitted = $submission->time_submitted();
- $content .= userdate($time_submitted,'%a, %d %b %Y, %H:%M');
+ $content .= userdate($timesubmitted, '%a, %d %b %Y, %H:%M');
$content .= html_writer::empty_tag('br');
if ($submission->is_late() && (!$submission->has_extension() || !$submission->submitted_within_extension())) {
@@ -88,7 +88,7 @@ public function prepare_content_cell($row_object) {
$deadline = ($submission->has_extension()) ? $submission->extension_deadline() : $deadline;
- $lateseconds = $time_submitted - $deadline;
+ $lateseconds = $timesubmitted - $deadline;
$days = floor($lateseconds / 86400);
$hours = floor($lateseconds / 3600) % 24;
@@ -108,7 +108,7 @@ public function prepare_content_cell($row_object) {
}
if ($submission->get_allocatable()->type() == 'group') {
- if ($row_object->can_view_username() || $row_object->is_published()) {
+ if ($rowobject->can_view_username() || $rowobject->is_published()) {
$content .= ' by ' . $submission->get_last_submitter()->profile_link();
}
}
@@ -117,17 +117,17 @@ public function prepare_content_cell($row_object) {
}
$content .= ' ';
- $allocatableid = $row_object->get_allocatable()->id();
- $allocatabletype = $row_object->get_allocatable()->type();
- $coursework = $row_object->get_coursework();
- $new_extension_params = array(
+ $allocatableid = $rowobject->get_allocatable()->id();
+ $allocatabletype = $rowobject->get_allocatable()->type();
+ $coursework = $rowobject->get_coursework();
+ $newextensionparams = [
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
'courseworkid' => $coursework->id,
- );
+ ];
- $extension = deadline_extension::find_or_build($new_extension_params);
- $ability = new ability(user::find($USER), $row_object->get_coursework());
+ $extension = deadline_extension::find_or_build($newextensionparams);
+ $ability = new ability(user::find($USER), $rowobject->get_coursework());
if ($extension->persisted()) {
$content .= 'Extension: '.userdate($extension->extended_deadline, '%a, %d %b %Y, %H:%M');
@@ -135,40 +135,40 @@ public function prepare_content_cell($row_object) {
}
if ($extension->id) {
- $new_extension_params['id'] = $extension->id;
+ $newextensionparams['id'] = $extension->id;
}
if ($submission) {
- $new_extension_params['submissionid'] = $submission->id;
+ $newextensionparams['submissionid'] = $submission->id;
}
$deadline = $deadline ?? $coursework->deadline;
- $content_time = [
+ $contenttime = [
'time' => date('d-m-Y H:i', $deadline),
'time_content' => userdate($deadline),
'is_have_deadline' => ($coursework->deadline > 0) ? 1 : 0,
];
if ($ability->can('new', $extension) && $coursework->extensions_enabled()) {
- $link = $this->get_router()->get_path('new deadline extension', $new_extension_params);
+ $link = $this->get_router()->get_path('new deadline extension', $newextensionparams);
$title = 'New extension';
$content .= $OUTPUT->action_link($link,
$title,
null,
- array('class' => 'new_deadline_extension', 'data-name' => $row_object->get_allocatable()->name(), 'data-params' => json_encode($new_extension_params), 'data-time' => json_encode($content_time) ));
+ ['class' => 'new_deadline_extension', 'data-name' => $rowobject->get_allocatable()->name(), 'data-params' => json_encode($newextensionparams), 'data-time' => json_encode($contenttime) ]);
} else if ($ability->can('edit', $extension) && $coursework->extensions_enabled()) {
- $link = $this->get_router()->get_path('edit deadline extension', array('id' => $extension->id));
+ $link = $this->get_router()->get_path('edit deadline extension', ['id' => $extension->id]);
$icon = new pix_icon('edit', 'Edit extension', 'coursework');
$content .= $OUTPUT->action_icon($link,
$icon,
null,
- array('class' => 'edit_deadline_extension', 'data-name' => $row_object->get_allocatable()->name(), 'data-params' => json_encode($new_extension_params), 'data-time' => json_encode($content_time)));
+ ['class' => 'edit_deadline_extension', 'data-name' => $rowobject->get_allocatable()->name(), 'data-params' => json_encode($newextensionparams), 'data-time' => json_encode($contenttime)]);
}
$content .= ' ';
- return ['display' => $content, '@data-order' => $this->standardize_time_for_compare($time_submitted) . '|' . $this->standardize_time_for_compare($displayeddeadline)];
+ return ['display' => $content, '@data-order' => $this->standardize_time_for_compare($timesubmitted) . '|' . $this->standardize_time_for_compare($displayeddeadline)];
}
/**
diff --git a/classes/render_helpers/grading_report/cells/user_cell.php b/classes/render_helpers/grading_report/cells/user_cell.php
index 6eddeab0..80768b79 100644
--- a/classes/render_helpers/grading_report/cells/user_cell.php
+++ b/classes/render_helpers/grading_report/cells/user_cell.php
@@ -43,7 +43,7 @@ public function get_table_cell($rowobject) {
$content = '';
- /* if ($rowobject->can_view_username()) {
+ /* if ($rowobject->can_view_username()) {
$content .= $OUTPUT->user_picture($user->get_raw_record());
} else {
$renderer = $PAGE->get_renderer('core');
@@ -56,7 +56,7 @@ public function get_table_cell($rowobject) {
$content .= ' ' . $rowobject->get_user_name(true);
$content .= " ".$rowobject->get_email();
$user = $rowobject->get_allocatable();
-/*
+ /*
$candidatenumber = $user->candidate_number();
if (!empty($candidatenumber)) {
@@ -65,7 +65,7 @@ public function get_table_cell($rowobject) {
}
-*/
+ */
return $this->get_new_cell_with_class($content);
}
@@ -76,54 +76,54 @@ public function get_table_cell($rowobject) {
*/
public function get_table_header($options = []) {
- $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context());
+ $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context());
//adding this line so that the sortable heading function will make a sortable link unique to the table
// If tablename is set
$tablename = (!empty($options['tablename'])) ? $options['tablename'] : '';
- // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous
- if ($viewanonymous || !$this->coursework->blindmarking) {
- $sort_by_first_name = $this->helper_sortable_heading(get_string('firstname'),
+ // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous
+ if ($viewanonymous || !$this->coursework->blindmarking) {
+ $sortbyfirstname = $this->helper_sortable_heading(get_string('firstname'),
'firstname',
$options['sorthow'],
$options['sortby'],
$tablename);
- $sort_by_last_name = $this->helper_sortable_heading(get_string('lastname'),
+ $sortbylastname = $this->helper_sortable_heading(get_string('lastname'),
'lastname',
$options['sorthow'],
$options['sortby'],
$tablename);
- $sort_by_email = $this->helper_sortable_heading(get_string('email', 'mod_coursework'),
+ $sortbyemail = $this->helper_sortable_heading(get_string('email', 'mod_coursework'),
'email',
$options['sorthow'],
$options['sortby'],
$tablename);
- } else { // otherwise display header without sorting
- $sort_by_first_name = get_string('firstname');
- $sort_by_last_name = get_string('lastname');
- $sort_by_email = get_string('email', 'mod_coursework');
- }
+ } else { // otherwise display header without sorting
+ $sortbyfirstname = get_string('firstname');
+ $sortbylastname = get_string('lastname');
+ $sortbyemail = get_string('email', 'mod_coursework');
+ }
if ($this->fullname_format() == 'lf') {
- $sort_by_first_name = ' / ' . $sort_by_first_name;
+ $sortbyfirstname = ' / ' . $sortbyfirstname;
} else {
- $sort_by_last_name = ' / ' . $sort_by_last_name;
+ $sortbylastname = ' / ' . $sortbylastname;
}
- $sort_by_first_name = ' '.$sort_by_first_name.'';
+ $sortbyfirstname = ' '.$sortbyfirstname.'';
- $sort_by_last_name = ' '.$sort_by_last_name.'';
+ $sortbylastname = ' '.$sortbylastname.'';
- $sort_by_email = ' '.$sort_by_email.'';
+ $sortbyemail = ' '.$sortbyemail.'';
if ($this->fullname_format() == 'lf') {
- $sort_by_name = $sort_by_last_name . $sort_by_first_name;
+ $sortbyname = $sortbylastname . $sortbyfirstname;
} else {
- $sort_by_name = $sort_by_first_name . $sort_by_last_name;
+ $sortbyname = $sortbyfirstname . $sortbylastname;
}
- $sort = $sort_by_name ." " .$sort_by_email;
+ $sort = $sortbyname ." " .$sortbyemail;
return $sort;
}
diff --git a/classes/render_helpers/grading_report/sub_rows/no_sub_rows.php b/classes/render_helpers/grading_report/sub_rows/no_sub_rows.php
index bd94f12c..15bc93d7 100644
--- a/classes/render_helpers/grading_report/sub_rows/no_sub_rows.php
+++ b/classes/render_helpers/grading_report/sub_rows/no_sub_rows.php
@@ -32,7 +32,7 @@ class no_sub_rows implements sub_rows_interface {
* @param int $column_width
* @return mixed
*/
- public function get_row_with_assessor_feedback_table($row_object, $column_width) {
+ public function get_row_with_assessor_feedback_table($rowobject, $columnwidth) {
return '';
}
}
diff --git a/classes/render_helpers/grading_report/sub_rows/sub_rows_interface.php b/classes/render_helpers/grading_report/sub_rows/sub_rows_interface.php
index c324b303..9933a3a8 100644
--- a/classes/render_helpers/grading_report/sub_rows/sub_rows_interface.php
+++ b/classes/render_helpers/grading_report/sub_rows/sub_rows_interface.php
@@ -34,6 +34,6 @@ interface sub_rows_interface {
* @param int $column_width
* @return mixed
*/
- public function get_row_with_assessor_feedback_table($row_object, $column_width);
+ public function get_row_with_assessor_feedback_table($rowobject, $columnwidth);
}
diff --git a/classes/renderers/personal_deadline_renderer.php b/classes/renderers/personal_deadline_renderer.php
index c0f81d59..c8d6c308 100644
--- a/classes/renderers/personal_deadline_renderer.php
+++ b/classes/renderers/personal_deadline_renderer.php
@@ -48,8 +48,8 @@ public function new_page($vars) {
//deadline
if (empty($vars['params']['multipleuserdeadlines'])) {
$allocatable = $vars['personal_deadline']->get_allocatable();
- $createdby = $DB->get_record('user', array('id' => $vars['personal_deadline']->createdbyid));
- $lasteditedby = $DB->get_record('user', array('id' => $vars['personal_deadline']->lastmodifiedbyid));
+ $createdby = $DB->get_record('user', ['id' => $vars['personal_deadline']->createdbyid]);
+ $lasteditedby = $DB->get_record('user', ['id' => $vars['personal_deadline']->lastmodifiedbyid]);
$html = ' Edit personal deadline for ' . $allocatable->name() . '';
diff --git a/classes/router.php b/classes/router.php
index 8077e876..9175b84c 100644
--- a/classes/router.php
+++ b/classes/router.php
@@ -46,7 +46,8 @@ class router {
/**
* Singleton.
*/
- private function __construct() {}
+ private function __construct() {
+ }
/**
* Singleton accessor.
@@ -68,32 +69,32 @@ public static function instance() {
* @throws \coding_exception
* @return moodle_url|string url
*/
- public function get_path($path_name, $items = [], $as_url_object = false, $escaped = true) {
+ public function get_path($pathname, $items = [], $asurlobject = false, $escaped = true) {
global $CFG;
- $context_id = false;
- $coursemodule_id = false;
+ $contextid = false;
+ $coursemoduleid = false;
if (array_key_exists('coursework', $items)) {
/**
* @var coursework $coursework
*/
$coursework = $items['coursework'];
- $context_id = $coursework->get_context_id();
- $coursemodule_id = $coursework->get_coursemodule_id();
+ $contextid = $coursework->get_context_id();
+ $coursemoduleid = $coursework->get_coursemodule_id();
}
$url = false;
- switch ($path_name) {
+ switch ($pathname) {
case 'create feedback':
$url = new moodle_url('/mod/coursework/actions/feedbacks/create.php');
break;
case 'course':
- $url = new moodle_url('/course/view.php', array('id' => $items['course']->id));
+ $url = new moodle_url('/course/view.php', ['id' => $items['course']->id]);
break;
case 'edit coursework':
@@ -101,47 +102,47 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap
break;
case 'coursework settings':
- $url = new moodle_url('/course/modedit.php', array('update' => $coursemodule_id));
+ $url = new moodle_url('/course/modedit.php', ['update' => $coursemoduleid]);
break;
case 'coursework':
- $url = new moodle_url('/mod/coursework/view.php', array('id' => $coursemodule_id));
+ $url = new moodle_url('/mod/coursework/view.php', ['id' => $coursemoduleid]);
break;
case 'allocations':
$url = new moodle_url('/mod/coursework/actions/allocate.php',
- array('id' => $coursemodule_id));
+ ['id' => $coursemoduleid]);
break;
case 'assessor grading':
case 'ajax new feedback':
$url = new moodle_url('/mod/coursework/actions/feedbacks/new.php',
- array('submissionid' => $items['submission']->id,
+ ['submissionid' => $items['submission']->id,
'stage_identifier' => $items['stage']->identifier(),
'assessorid' => $items['assessor']->id,
- 'ajax' => 1));
+ 'ajax' => 1]);
break;
case 'new feedback':
$url = new moodle_url('/mod/coursework/actions/feedbacks/new.php',
- array('submissionid' => $items['submission']->id,
+ ['submissionid' => $items['submission']->id,
'stage_identifier' => $items['stage']->identifier(),
- 'assessorid' => $items['assessor']->id));
+ 'assessorid' => $items['assessor']->id]);
break;
case 'ajax new final feedback':
- $params = array('submissionid' => $items['submission']->id,
+ $params = ['submissionid' => $items['submission']->id,
'stage_identifier' => $items['stage']->identifier(),
'isfinalgrade' => 1,
- 'ajax' => 1);
+ 'ajax' => 1];
$url = new moodle_url('/mod/coursework/actions/feedbacks/new.php', $params);
break;
case 'new final feedback':
- $params = array('submissionid' => $items['submission']->id,
+ $params = ['submissionid' => $items['submission']->id,
'stage_identifier' => $items['stage']->identifier(),
- 'isfinalgrade' => 1);
+ 'isfinalgrade' => 1];
$url = new moodle_url('/mod/coursework/actions/feedbacks/new.php', $params);
break;
@@ -154,31 +155,31 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap
case 'new submission':
$url = new moodle_url('/mod/coursework/actions/submissions/new.php',
- array(
+ [
'allocatableid' => $items['submission']->allocatableid,
'allocatabletype' => $items['submission']->allocatabletype,
'courseworkid' => $items['submission']->courseworkid,
- ));
+ ]);
break;
case 'ajax edit feedback':
$url = new moodle_url('/mod/coursework/actions/feedbacks/edit.php',
- array('feedbackid' => $items['feedback']->id, 'ajax' => 1));
+ ['feedbackid' => $items['feedback']->id, 'ajax' => 1]);
break;
case 'edit feedback':
$url = new moodle_url('/mod/coursework/actions/feedbacks/edit.php',
- array('feedbackid' => $items['feedback']->id));
+ ['feedbackid' => $items['feedback']->id]);
break;
case 'ajax update feedback':
$url = new moodle_url('/mod/coursework/actions/feedbacks/update.php',
- array('feedbackid' => $items['feedback']->id, 'ajax' => 1));
+ ['feedbackid' => $items['feedback']->id, 'ajax' => 1]);
break;
case 'update feedback':
$url = new moodle_url('/mod/coursework/actions/feedbacks/update.php',
- array('feedbackid' => $items['feedback']->id));
+ ['feedbackid' => $items['feedback']->id]);
break;
case 'new deadline extension':
@@ -198,13 +199,13 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap
case 'set personal deadlines':
$url = new moodle_url('/mod/coursework/actions/set_personal_deadlines.php',
- array('id' => $coursemodule_id));
+ ['id' => $coursemoduleid]);
break;
case 'new moderations':
- $params = array('submissionid' => $items['submission']->id,
+ $params = ['submissionid' => $items['submission']->id,
'stage_identifier' => $items['stage']->identifier(),
- 'feedbackid' => $items['feedbackid']);
+ 'feedbackid' => $items['feedbackid']];
$url = new moodle_url('/mod/coursework/actions/moderations/new.php', $params);
break;
@@ -214,8 +215,8 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap
case 'edit moderation':
$url = new moodle_url('/mod/coursework/actions/moderations/edit.php',
- array('moderationid' => $items['moderation']->id,
- 'feedbackid' => $items['moderation']->feedbackid));
+ ['moderationid' => $items['moderation']->id,
+ 'feedbackid' => $items['moderation']->feedbackid]);
break;
case 'update moderation':
@@ -224,14 +225,14 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap
case 'show moderation':
$url = new moodle_url('/mod/coursework/actions/moderations/show.php',
- array('moderationid' => $items['moderation']->id,
- 'feedbackid' => $items['moderation']->feedbackid));
+ ['moderationid' => $items['moderation']->id,
+ 'feedbackid' => $items['moderation']->feedbackid]);
break;
case 'new plagiarism flag':
$url = new moodle_url('/mod/coursework/actions/plagiarism_flagging/new.php',
- array('submissionid' => $items['submission']->id ));
+ ['submissionid' => $items['submission']->id ]);
break;
@@ -242,13 +243,13 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap
case 'edit plagiarism flag':
$url = new moodle_url('/mod/coursework/actions/plagiarism_flagging/edit.php',
- array('flagid' => $items['flag']->id ));
+ ['flagid' => $items['flag']->id ]);
break;
case 'update plagiarism flag':
$url = new moodle_url('/mod/coursework/actions/plagiarism_flagging/update.php',
- array('flagid' => $items['flag']->id));
+ ['flagid' => $items['flag']->id]);
break;
}
@@ -256,12 +257,12 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap
if (!$url) {
// Try to auto construct it.
- $bits = explode(' ', $path_name);
+ $bits = explode(' ', $pathname);
$action = array_shift($bits);
$type = implode('_', $bits);
- $auto_path = '/mod/coursework/actions/' . $this->pluralise($type) . '/' . $action . '.php';
- if (file_exists($CFG->dirroot . $auto_path)) {
+ $autopath = '/mod/coursework/actions/' . $this->pluralise($type) . '/' . $action . '.php';
+ if (file_exists($CFG->dirroot . $autopath)) {
$params = [];
if (array_key_exists($type, $items)) {
@@ -272,15 +273,15 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap
$params['courseworkid'] = $items['courseworkid'];
}
- $url = new moodle_url($auto_path, $params);
+ $url = new moodle_url($autopath, $params);
}
}
if (!$url) {
- throw new coding_exception("No target file for path: '{$path_name}'");
+ throw new coding_exception("No target file for path: '{$pathname}'");
}
- return $as_url_object ? $url : $url->out($escaped);
+ return $asurlobject ? $url : $url->out($escaped);
}
/**
diff --git a/classes/sample_set_rule/range_sample_type.php b/classes/sample_set_rule/range_sample_type.php
index 303fc868..b3336f8d 100644
--- a/classes/sample_set_rule/range_sample_type.php
+++ b/classes/sample_set_rule/range_sample_type.php
@@ -37,7 +37,7 @@
*/
class range_sample_type extends \mod_coursework\sample_set_rule\sample_base {
- public function adjust_set(array &$moderation_set, array &$potential_allocatables, $stage) {
+ public function adjust_set(array &$moderationset, array &$potentialallocatables, $stage) {
}
@@ -49,7 +49,7 @@ public function get_default_rule_order() {
}
- public function add_form_elements($assessor_number=0) {
+ public function add_form_elements($assessornumber=0) {
global $DB;
@@ -60,7 +60,7 @@ public function add_form_elements($assessor_number=0) {
{coursework_sample_set_plugin} sp
WHERE sr.sample_set_plugin_id = sp.id
AND sr.courseworkid = {$this->coursework->id}
- AND sr.stage_identifier = 'assessor_{$assessor_number}'
+ AND sr.stage_identifier = 'assessor_{$assessornumber}'
AND sp.rulename = 'range_sample_type'";
$rulesfound = false;
@@ -70,88 +70,92 @@ public function add_form_elements($assessor_number=0) {
if (!empty($samplerecords)) {
$seq = 0;
foreach ($samplerecords as $record) {
- $html .= $this->range_elements($assessor_number, $seq, $record);
+ $html .= $this->range_elements($assessornumber, $seq, $record);
$seq++;
}
} else {
- $html .= $this->range_elements($assessor_number, 0, false);
+ $html .= $this->range_elements($assessornumber, 0, false);
}
- $html .= html_writer::link('#', get_string('addgraderule', 'mod_coursework'), array('id' => "assessor_{$assessor_number}_addgradderule", 'class' => 'addgradderule sample_set_rule'));
+ $html .= html_writer::link('#', get_string('addgraderule', 'mod_coursework'), ['id' => "assessor_{$assessornumber}_addgradderule", 'class' => 'addgradderule sample_set_rule']);
$html .= " ";
- $html .= html_writer::link('#', get_string('removegraderule', 'mod_coursework'), array('id' => "assessor_{$assessor_number}_removegradderule", 'class' => 'removegradderule sample_set_rule'));
+ $html .= html_writer::link('#', get_string('removegraderule', 'mod_coursework'), ['id' => "assessor_{$assessornumber}_removegradderule", 'class' => 'removegradderule sample_set_rule']);
return $html;
}
- public function range_elements($assessor_number, $sequence, $dbrecord=false) {
+ public function range_elements($assessornumber, $sequence, $dbrecord=false) {
- $percentage_options = [];
+ $percentageoptions = [];
- for ($i = 0;$i < 110; $i = $i + 10) {
- $percentage_options[$i] = "{$i}";
+ for ($i = 0; $i < 110; $i = $i + 10) {
+ $percentageoptions[$i] = "{$i}";
}
$scale = [];
- if ($this->coursework->grade > 0) {
- for ($i = 0;$i <= $this->coursework->grade; $i++) {
+ if ($this->coursework->grade > 0) {
+ for ($i = 0; $i <= $this->coursework->grade; $i++) {
$scale[] = $i;
}
} else {
- $grade_scale = \grade_scale::fetch(array('id' => abs($this->coursework->grade)));
- $scale = explode(",", $grade_scale->scale);
+ $gradescale = \grade_scale::fetch(['id' => abs($this->coursework->grade)]);
+ $scale = explode(",", $gradescale->scale);
}
if ($dbrecord) {
- $selected_type = array($dbrecord->ruletype => get_string($dbrecord->ruletype, 'mod_coursework'));
- $selected_to = ($dbrecord->ruletype == 'scale') ? array($dbrecord->upperlimit => $scale[$dbrecord->upperlimit]) : array($dbrecord->upperlimit => $dbrecord->upperlimit);
+ $selectedtype = [$dbrecord->ruletype => get_string($dbrecord->ruletype, 'mod_coursework')];
+ $selectedto = ($dbrecord->ruletype == 'scale') ? [$dbrecord->upperlimit => $scale[$dbrecord->upperlimit]] : [$dbrecord->upperlimit => $dbrecord->upperlimit];
- $selected_from = ($dbrecord->ruletype == 'scale') ? array($dbrecord->lowerlimit => $scale[$dbrecord->lowerlimit]) : array($dbrecord->lowerlimit => $dbrecord->lowerlimit);
+ $selectedfrom = ($dbrecord->ruletype == 'scale') ? [$dbrecord->lowerlimit => $scale[$dbrecord->lowerlimit]] : [$dbrecord->lowerlimit => $dbrecord->lowerlimit];
- $rules_checked = ($dbrecord) ? true : false;
+ $ruleschecked = ($dbrecord) ? true : false;
} else {
- $selected_type = array('percentage' => get_string('percentage', 'mod_coursework'));
- $selected_to = array('100' => '100');
- $selected_from = array('0' => '0');;
- $rules_checked = false;
+ $selectedtype = ['percentage' => get_string('percentage', 'mod_coursework')];
+ $selectedto = ['100' => '100'];
+ $selectedfrom = ['0' => '0'];;
+ $ruleschecked = false;
}
- $html = html_writer::start_tag('div', array('class' => "assessor_{$assessor_number}_grade_rules", 'id' => "assessor_{$assessor_number}_grade_rules_{$sequence}"));
+ $html = html_writer::start_tag(
+ 'div',
+ ['class' => "assessor_{$assessornumber}_grade_rules", 'id' => "assessor_{$assessornumber}_grade_rules_{$sequence}"]
+ );
- $html .= html_writer::checkbox("assessor_{$assessor_number}_samplerules[]", 1, $rules_checked, '',
- array('id' => "assessor_{$assessor_number}_samplerules_{$sequence}", 'class' => "assessor_{$assessor_number} range_grade_checkbox sample_set_rule"));
+ $html .= html_writer::checkbox(
+ "assessor_{$assessornumber}_samplerules[]", 1, $ruleschecked, '',
+ ['id' => "assessor_{$assessornumber}_samplerules_{$sequence}", 'class' => "assessor_{$assessornumber} range_grade_checkbox sample_set_rule"]);
- $grade_scale_text = ($this->coursework->grade < 0) ? get_string('scale', 'mod_coursework') : get_string('grade', 'mod_coursework');
- $grade_scale_val = ($this->coursework->grade < 0) ? 'scale' : 'grade';
+ $gradescaletext = ($this->coursework->grade < 0) ? get_string('scale', 'mod_coursework') : get_string('grade', 'mod_coursework');
+ $gradescaleval = ($this->coursework->grade < 0) ? 'scale' : 'grade';
- $options = array('percentage' => get_string('percentage', 'mod_coursework'),
- $grade_scale_val => $grade_scale_text);
+ $options = ['percentage' => get_string('percentage', 'mod_coursework'),
+ $gradescaleval => $gradescaletext];
$html .= html_writer::select($options,
- "assessor_{$assessor_number}_sampletype[]",
+ "assessor_{$assessornumber}_sampletype[]",
"",
- $selected_type,
- array('id' => "assessor_{$assessor_number}_sampletype_{$sequence}", 'class' => "grade_type sample_set_rule"));
+ $selectedtype,
+ ['id' => "assessor_{$assessornumber}_sampletype_{$sequence}", 'class' => "grade_type sample_set_rule"]);
$html .= html_writer::label(get_string('from', 'mod_coursework'), 'assessortwo_samplefrom[0]');
- $rule_options = (!empty($selected_type) && array_key_exists('percentage', $selected_type)) ? $percentage_options : $scale; //change this into a ternary statement that
+ $ruleoptions = (!empty($selectedtype) && array_key_exists('percentage', $selectedtype)) ? $percentageoptions : $scale; //change this into a ternary statement that
- $html .= html_writer::select($rule_options,
- "assessor_{$assessor_number}_samplefrom[]",
+ $html .= html_writer::select($ruleoptions,
+ "assessor_{$assessornumber}_samplefrom[]",
"",
- $selected_from,
- array('id' => "assessor_{$assessor_number}_samplefrom_{$sequence}", 'class' => " sample_set_rule range_drop_down range_samp_from"));
+ $selectedfrom,
+ ['id' => "assessor_{$assessornumber}_samplefrom_{$sequence}", 'class' => " sample_set_rule range_drop_down range_samp_from"]);
- $html .= html_writer::label(get_string('to', 'mod_coursework'), "assessor_{$assessor_number}_sampleto[0]");
+ $html .= html_writer::label(get_string('to', 'mod_coursework'), "assessor_{$assessornumber}_sampleto[0]");
- $html .= html_writer::select(array_reverse($rule_options, true),
- "assessor_{$assessor_number}_sampleto[]",
+ $html .= html_writer::select(array_reverse($ruleoptions, true),
+ "assessor_{$assessornumber}_sampleto[]",
"",
- $selected_to,
- array('id' => "assessor_{$assessor_number}_sampleto_{$sequence}", 'class' => " sample_set_rule range_drop_down"));
+ $selectedto,
+ ['id' => "assessor_{$assessornumber}_sampleto_{$sequence}", 'class' => " sample_set_rule range_drop_down"]);
$html .= html_writer::end_tag('div', '');
@@ -159,9 +163,9 @@ public function range_elements($assessor_number, $sequence, $dbrecord=false) {
}
- public function add_form_elements_js($assessor_number=0) {
+ public function add_form_elements_js($assessornumber=0) {
- $js_script = "
+ $jsscript = "
var AUTOMATIC_SAMPLING = 1;
@@ -323,45 +327,45 @@ function change_options(element) {
";
- return html_writer::script($js_script, null);
+ return html_writer::script($jsscript, null);
}
- public function save_form_data($assessor_number=0, &$order=0) {
+ public function save_form_data($assessornumber=0, &$order=0) {
global $DB;
- $sample_rules = optional_param_array("assessor_{$assessor_number}_samplerules", false, PARAM_RAW);
- $sample_type = optional_param_array("assessor_{$assessor_number}_sampletype", false, PARAM_RAW);
- $sample_from = optional_param_array("assessor_{$assessor_number}_samplefrom", false, PARAM_RAW);
- $sample_to = optional_param_array("assessor_{$assessor_number}_sampleto", false, PARAM_RAW);
+ $samplerules = optional_param_array("assessor_{$assessornumber}_samplerules", false, PARAM_RAW);
+ $sampletype = optional_param_array("assessor_{$assessornumber}_sampletype", false, PARAM_RAW);
+ $samplefrom = optional_param_array("assessor_{$assessornumber}_samplefrom", false, PARAM_RAW);
+ $sampleto = optional_param_array("assessor_{$assessornumber}_sampleto", false, PARAM_RAW);
- $sample_plugin = $DB->get_record('coursework_sample_set_plugin', array('rulename' => 'range_sample_type'));
+ $sampleplugin = $DB->get_record('coursework_sample_set_plugin', ['rulename' => 'range_sample_type']);
- if ($sample_rules) {
- foreach ($sample_rules as $i => $val) {
+ if ($samplerules) {
+ foreach ($samplerules as $i => $val) {
- $dbrecord = new \stdClass();
+ $dbrecord = new \stdClass();
- $dbrecord->ruletype = $sample_type[$i];
- $dbrecord->lowerlimit = $sample_from[$i];
- $dbrecord->upperlimit = $sample_to[$i];
- $dbrecord->sample_set_plugin_id = $sample_plugin->id;
- $dbrecord->courseworkid = $this->coursework->id;
- $dbrecord->ruleorder = $order;
- $dbrecord->stage_identifier = "assessor_{$assessor_number}";
+ $dbrecord->ruletype = $sampletype[$i];
+ $dbrecord->lowerlimit = $samplefrom[$i];
+ $dbrecord->upperlimit = $sampleto[$i];
+ $dbrecord->sample_set_plugin_id = $sampleplugin->id;
+ $dbrecord->courseworkid = $this->coursework->id;
+ $dbrecord->ruleorder = $order;
+ $dbrecord->stage_identifier = "assessor_{$assessornumber}";
- $DB->insert_record("coursework_sample_set_rules", $dbrecord);
- $order++;
- }
+ $DB->insert_record("coursework_sample_set_rules", $dbrecord);
+ $order++;
}
+ }
}
- public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample_set, &$auto_sample_set) {
+ public function adjust_sample_set($stagenumber, &$allocatables, &$manualsampleset, &$autosampleset) {
global $DB;
- $stage = "assessor_".$stage_number;
+ $stage = "assessor_" . $stagenumber;
$sql = "SELECT r.*,p.rulename
FROM {coursework_sample_set_plugin} p,
@@ -372,25 +376,25 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample
AND stage_identifier = :stage
ORDER BY ruleorder";
- $ruleinstance = $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id, 'stage' => $stage));
+ $ruleinstance = $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id, 'stage' => $stage]);
foreach ($ruleinstance as $ri) {
$limit = $this->rationalise($ri->ruletype, $ri->lowerlimit, $ri->upperlimit);
// all allocatables that are within specified range based on previous stage
- $previous_stage = $stage_number-1;
- $allocatables_in_range = $this->get_allocatables_in_range("assessor_".$previous_stage, $limit[0], $limit[1]);
+ $previousstage = $stagenumber - 1;
+ $allocatablesinrange = $this->get_allocatables_in_range("assessor_".$previousstage, $limit[0], $limit[1]);
$finalised = $this->finalised_submissions();
$published = $this->released_submissions();
- foreach ($allocatables_in_range as $awf) {
+ foreach ($allocatablesinrange as $awf) {
if (!isset($published[$awf->allocatableid]) && !isset($finalised[$awf->allocatableid])
- && !isset($auto_sample_set[$awf->allocatableid]) && !isset($manual_sample_set[$awf->allocatableid])
- && isset($allocatables[$awf->allocatableid]))
- $auto_sample_set[$awf->allocatableid] = $allocatables[$awf->allocatableid];
-
+ && !isset($autosampleset[$awf->allocatableid]) && !isset($manualsampleset[$awf->allocatableid])
+ && isset($allocatables[$awf->allocatableid])) {
+ $autosampleset[$awf->allocatableid] = $allocatables[$awf->allocatableid];
+ }
}
}
}
@@ -401,38 +405,38 @@ private function rationalise($ruletype, $limit1, $limit2) {
$limits = [];
- $limits[0] = ($limit1>$limit2) ? $limit2 : $limit1;
- $limits[1] = ($limit1>$limit2) ? $limit1 : $limit2;
-
- if ($ruletype == 'scale') {
- ++$limits[0];
- ++$limits[1];
- }
+ $limits[0] = ($limit1 > $limit2) ? $limit2 : $limit1;
+ $limits[1] = ($limit1 > $limit2) ? $limit1 : $limit2;
- if ($ruletype == 'percentage') {
- if ($this->coursework->grade > 0) {
- $limits[0] = $this->coursework->grade * $limits[0] / 100;
- $limits[1] = $this->coursework->grade * $limits[1] / 100;
- } else {
- $scale = $DB->get_record("scale", array('id' => abs($this->coursework->grade)));
+ if ($ruletype == 'scale') {
+ ++$limits[0];
+ ++$limits[1];
+ }
- if ($scale) {
+ if ($ruletype == 'percentage') {
+ if ($this->coursework->grade > 0) {
+ $limits[0] = $this->coursework->grade * $limits[0] / 100;
+ $limits[1] = $this->coursework->grade * $limits[1] / 100;
+ } else {
+ $scale = $DB->get_record("scale", ['id' => abs($this->coursework->grade)]);
- $coursework_scale = explode(",", $scale->scale);
+ if ($scale) {
- $number_of_items = count($coursework_scale);
+ $courseworkscale = explode(",", $scale->scale);
- $weighting = 100 / $number_of_items; // shall we round it????
+ $numberofitems = count($courseworkscale);
- $limits[0] = ceil($limits[0]/$weighting); // element of array
- $limits[1] = ceil($limits[1]/$weighting); // element of array
+ $weighting = 100 / $numberofitems; // shall we round it????
- // Note we have to add one as the values are not stored in there element positions
+ $limits[0] = ceil($limits[0] / $weighting); // element of array
+ $limits[1] = ceil($limits[1] / $weighting); // element of array
- }
+ // Note we have to add one as the values are not stored in there element positions
}
+
}
+ }
return $limits;
}
@@ -453,9 +457,9 @@ private function get_allocatables_in_range($stage, $limit1, $limit2) {
// Note as things stand limit1 and limit2 can not be params as the type of the grade field (varchar)
//means the values are cast as strings
- return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id,
- 'stage' => $stage));
-
+ return $DB->get_records_sql($sql,
+ ['courseworkid' => $this->coursework->id, 'stage' => $stage]
+ );
}
}
diff --git a/classes/sample_set_rule/sample_base.php b/classes/sample_set_rule/sample_base.php
index e4a25d12..3fa9a482 100644
--- a/classes/sample_set_rule/sample_base.php
+++ b/classes/sample_set_rule/sample_base.php
@@ -38,7 +38,7 @@ abstract class sample_base {
/**
* @var string DB table this class relates to.
*/
- protected static $table_name = 'coursework_mod_set_rules';
+ protected static $tablename = 'coursework_mod_set_rules';
/**
* @var int
@@ -80,15 +80,15 @@ abstract class sample_base {
/**
* @var array List of class properties that correspond with DB fields.
*/
- protected $fields = array(
+ protected $fields = [
'id',
'courseworkid',
'rulename',
'ruleorder',
'upperlimit',
'lowerlimit',
- 'minimum'
- );
+ 'minimum',
+ ];
function __construct($coursework) {
$this->coursework = $coursework;
@@ -115,7 +115,7 @@ final public function get_name() {
* @param stage_base $stage
* @return mixed
*/
- abstract public function adjust_set(array &$moderationset, array &$potential_allocatables, $stage);
+ abstract public function adjust_set(array &$moderationset, array &$potentialallocatables, $stage);
/**
* Tells us where this ought to be in relation to other rules. The one for percent of total must happen last,
@@ -142,13 +142,13 @@ public static function allow_multiple() {
* @abstract
* @return mixed
*/
- abstract public function add_form_elements($assessor_number);
+ abstract public function add_form_elements($assessornumber);
- abstract public function add_form_elements_js($assessor_number);
+ abstract public function add_form_elements_js($assessornumber);
- abstract public function save_form_data($assessor_number=0, &$order=0);
+ abstract public function save_form_data($assessornumber=0, &$order=0);
- abstract public function adjust_sample_set($rule_id, &$manual_sample_set, &$allocatables, &$auto_sample_set);
+ abstract public function adjust_sample_set($ruleid, &$manualsampleset, &$allocatables, &$autosampleset);
/**
*
@@ -164,7 +164,7 @@ protected function finalised_submissions() {
WHERE s.courseworkid = :courseworkid
AND f.stage_identifier = 'final_agreed_1'";
- return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id));
+ return $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id]);
}
/**
@@ -179,7 +179,7 @@ protected function released_submissions() {
WHERE courseworkid = :courseworkid
AND firstpublished IS NOT NULL";
- return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id));
+ return $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id]);
}
}
diff --git a/classes/sample_set_rule/total_sample_type.php b/classes/sample_set_rule/total_sample_type.php
index f1993680..16d985d0 100644
--- a/classes/sample_set_rule/total_sample_type.php
+++ b/classes/sample_set_rule/total_sample_type.php
@@ -37,7 +37,7 @@
*/
class total_sample_type extends \mod_coursework\sample_set_rule\sample_base {
- public function adjust_set(array &$moderation_set, array &$potential_allocatables, $stage) {
+ public function adjust_set(array &$moderationset, array &$potentialallocatables, $stage) {
}
@@ -49,7 +49,7 @@ public function get_default_rule_order() {
}
- public function add_form_elements($assessor_number=0) {
+ public function add_form_elements($assessornumber = 0) {
global $DB;
@@ -58,28 +58,30 @@ public function add_form_elements($assessor_number=0) {
{coursework_sample_set_plugin} sp
WHERE sr.sample_set_plugin_id = sp.id
AND sr.courseworkid = {$this->coursework->id}
- AND sr.stage_identifier = 'assessor_{$assessor_number}'
+ AND sr.stage_identifier = 'assessor_{$assessornumber}'
AND sp.rulename = 'total_sample_type'";
- $selected = ($record = $DB->get_record_sql($sql)) ? array($record->upperlimit => $record->upperlimit) : false;
+ $selected = ($record = $DB->get_record_sql($sql)) ? [$record->upperlimit => $record->upperlimit] : false;
$checked = ($selected) ? true : false;
- $percentage_options = [];
+ $percentageoptions = [];
- for ($i = 5;$i <= 100; $i = $i + 5) {
- $percentage_options[$i] = "{$i}";
+ for ($i = 5; $i <= 100; $i = $i + 5) {
+ $percentageoptions[$i] = "{$i}";
}
$html = html_writer::start_div('sampletotal');
- $html .= html_writer::checkbox("assessor_{$assessor_number}_sampletotal_checkbox", 1, $checked, get_string('topupto', 'mod_coursework'),
- array('id' => "assessor_{$assessor_number}_sampletotal_checkbox", 'class' => "assessor_{$assessor_number} total_checkbox sample_set_rule"));
+ $html .= html_writer::checkbox(
+ "assessor_{$assessornumber}_sampletotal_checkbox", 1, $checked, get_string('topupto', 'mod_coursework'),
+ ['id' => "assessor_{$assessornumber}_sampletotal_checkbox", 'class' => "assessor{$assessornumber} totalcheckbox samplesetrule"]);
- $html .= html_writer::select($percentage_options,
- "assessor_{$assessor_number}_sampletotal",
+ $html .= html_writer::select(
+ $percentageoptions,
+ "assessor_{$assessornumber}_sampletotal",
"",
$selected,
- array('id' => "assessor_{$assessor_number}_sampletotal", 'class' => " sample_set_rule"));
+ ['id' => "assessor_{$assessornumber}_sampletotal", 'class' => " sample_set_rule"]);
$html .= html_writer::label(get_string('ofallstudents', 'mod_coursework'), 'assessortwo_sampletotal[]');
$html .= html_writer::end_div();
@@ -87,9 +89,9 @@ public function add_form_elements($assessor_number=0) {
return $html;
}
- public function add_form_elements_js($assessor_number=0) {
+ public function add_form_elements_js($assessornumber = 0) {
- $js_script = "
+ $jsscript = "
$('.total_checkbox').each(function(e,element) {
@@ -109,26 +111,26 @@ public function add_form_elements_js($assessor_number=0) {
";
- return html_writer::script($js_script, null);
+ return html_writer::script($jsscript, null);
}
- function save_form_data($assessor_number=0, &$order=0) {
+ function save_form_data($assessornumber = 0, &$order = 0) {
global $DB;
- $total_checkbox = optional_param("assessor_{$assessor_number}_sampletotal_checkbox", false, PARAM_INT);
- $sample_total = optional_param("assessor_{$assessor_number}_sampletotal", false, PARAM_INT);
+ $totalcheckbox = optional_param("assessor_{$assessornumber}_sampletotal_checkbox", false, PARAM_INT);
+ $sampletotal = optional_param("assessor_{$assessornumber}_sampletotal", false, PARAM_INT);
- if ($total_checkbox) {
+ if ($totalcheckbox) {
$dbrecord = new \stdClass();
$dbrecord->ruletype = "";
$dbrecord->lowerlimit = 0;
- $dbrecord->upperlimit = $sample_total;
+ $dbrecord->upperlimit = $sampletotal;
$dbrecord->sample_set_plugin_id = 2; // TODO: THIS SHOULD NOT BE HARD CODED - AF
$dbrecord->courseworkid = $this->coursework->id;
$dbrecord->ruleorder = $order;
- $dbrecord->stage_identifier = "assessor_{$assessor_number}";
+ $dbrecord->stage_identifier = "assessor_{$assessornumber}";
$DB->insert_record('coursework_sample_set_rules', $dbrecord);
}
@@ -136,15 +138,17 @@ function save_form_data($assessor_number=0, &$order=0) {
}
static function compare_key($a, $b) {
- if ($a === $b) return 0;
+ if ($a === $b) {
+ return 0;
+ }
return ($a > $b) ? 1 : -1;
}
- public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample_set, &$auto_sample_set) {
+ public function adjust_sample_set($stagenumber, &$allocatables, &$manualsampleset, &$autosampleset) {
global $DB;
- $stage = "assessor_".$stage_number;
+ $stage = "assessor_" . $stagenumber;
$sql = "SELECT r.*,p.rulename
FROM {coursework_sample_set_plugin} p,
@@ -155,84 +159,94 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample
AND stage_identifier = :stage
ORDER BY ruleorder";
- $rule = $DB->get_record_sql($sql, array('courseworkid' => $this->coursework->id, 'stage' => $stage));
+ $rule = $DB->get_record_sql($sql, ['courseworkid' => $this->coursework->id, 'stage' => $stage]);
if ($rule) {
$finalised = $this->finalised_submissions();
$published = $this->released_submissions();
- $number_of_alloctables = count($allocatables);
+ $numberofalloctables = count($allocatables);
- $total_to_return = ceil(($rule->upperlimit / 100) * $number_of_alloctables);
+ $totaltoreturn = ceil(($rule->upperlimit / 100) * $numberofalloctables);
// We include the manual sample set in the count
// TODO: should we do this?
- $total_to_return -= count($manual_sample_set);
+ $totaltoreturn -= count($manualsampleset);
// If the resultant number isnt greater than 0 then no automatic sample allocatables will be used
- if ($total_to_return > 0) {
+ if ($totaltoreturn > 0) {
//use array chunk to split auto sample set into chunks we will only use the first chunk
- if ($chunked_array = array_chunk($auto_sample_set, $total_to_return, true)) $auto_sample_set = $chunked_array[0];
+ if ($chunkedarray = array_chunk($autosampleset, $totaltoreturn, true)) {
+ $autosampleset = $chunkedarray[0];
+ }
// If the number in the sample set is less than the total to return
- if (count($auto_sample_set) < $total_to_return) {
+ if (count($autosampleset) < $totaltoreturn) {
// We need to top up the sample set with other allocatables
// Graded at the previous stage take precedence
- $previous_stage_number = $stage_number - 1;
+ $previousstagenumber = $stagenumber - 1;
- $previous_stage = 'assessor_' . $previous_stage_number;
+ $previousstage = 'assessor_' . $previousstagenumber;
- $allocatables_feedback = $this->coursework->get_allocatables_with_feedback($previous_stage, true);
+ $allocatablesfeedback = $this->coursework->get_allocatables_with_feedback($previousstage, true);
- foreach ($allocatables_feedback as $af) {
+ foreach ($allocatablesfeedback as $af) {
if (!isset($published[$af->allocatableid]) && !isset($finalised[$af->allocatableid])
- && !isset($auto_sample_set[$af->allocatableid]) && !isset($manual_sample_set[$af->allocatableid]))
- $auto_sample_set[$af->allocatableid] = $allocatables[$af->allocatableid];
+ && !isset($autosampleset[$af->allocatableid]) && !isset($manualsampleset[$af->allocatableid])) {
+ $autosampleset[$af->allocatableid] = $allocatables[$af->allocatableid];
+ }
- if (count($auto_sample_set) == $total_to_return) break;
+ if (count($autosampleset) == $totaltoreturn) {
+ break;
+ }
}
}
// If this is not enough select anyone (which should == the ungraded as all graded should have been added)
- if (count($auto_sample_set) < $total_to_return) {
+ if (count($autosampleset) < $totaltoreturn) {
// Remove allocatables with published submissions
- $allocatable_sample_set = array_diff_ukey($allocatables, $published, array("mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"));
+ $allocatablesampleset = array_diff_ukey($allocatables, $published, ["mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"]);
// Remove allocatables with finalised submissions
- $allocatable_sample_set = array_diff_ukey($allocatable_sample_set, $finalised, array("mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"));
+ $allocatablesampleset = array_diff_ukey($allocatablesampleset, $finalised, ["mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"]);
// Remove allocatables who have been manually selected
- $allocatable_sample_set = array_diff_ukey($allocatable_sample_set, $manual_sample_set, array("mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"));
+ $allocatablesampleset = array_diff_ukey($allocatablesampleset, $manualsampleset, ["mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"]);
// Remove allocatables already in the sample set
- $allocatable_sample_set = array_diff_ukey($allocatable_sample_set, $auto_sample_set, array("mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"));
+ $allocatablesampleset = array_diff_ukey($allocatablesampleset, $autosampleset, ["mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"]);
- $array_keys = array_rand($allocatable_sample_set, $total_to_return - count($auto_sample_set));
+ $arraykeys = array_rand($allocatablesampleset, $totaltoreturn - count($autosampleset));
- if (!is_array($array_keys)) $array_keys = array($array_keys);
+ if (!is_array($arraykeys)) {
+ $arraykeys = [$arraykeys];
+ }
//use the allocatables array to get other ungraded allocatables
- foreach ($array_keys as $id) {
+ foreach ($arraykeys as $id) {
- if (!isset($published[$id]) && !isset($finalised[$id])
- && !isset($auto_sample_set[$id]) && !isset($manual_sample_set[$id])
- )
- $auto_sample_set[$id] = $allocatables[$id];
+ if (!isset($published[$id]) && !isset($finalised[$id])
+ && !isset($autosampleset[$id]) && !isset($manualsampleset[$id])
+ ) {
+ $autosampleset[$id] = $allocatables[$id];
+ }
- if (count($auto_sample_set) == $total_to_return) break;
+ if (count($autosampleset) == $totaltoreturn) {
+ break;
}
+ }
}
} else {
- $auto_sample_set = [];
+ $autosampleset = [];
}
}
diff --git a/classes/sampling_set_widget.php b/classes/sampling_set_widget.php
index f1d7bbc2..bae38f7e 100644
--- a/classes/sampling_set_widget.php
+++ b/classes/sampling_set_widget.php
@@ -124,10 +124,10 @@ public function get_potential_rule_class_names() {
$fullclassname = '\mod_coursework\sample_set_rule\\'. $rulename;
if (!$fullclassname::allow_multiple()) {
- $params = array(
+ $params = [
'courseworkid' => $this->coursework->id,
- 'rulename' => $rulename
- );
+ 'rulename' => $rulename,
+ ];
$alreadygotone = $DB->record_exists('coursework_mod_set_rules', $params);
if ($alreadygotone) {
continue;
@@ -171,11 +171,11 @@ public function get_add_rule_form_elements() {
$classes = $this->get_potential_rule_class_names();
foreach ($classes as $shortname => $class) {
- $attributes = array(
+ $attributes = [
'class' => 'rule-config',
'id' => 'rule-config-'.$shortname,
- 'style' => 'display:none' // Always hide, so they only get revealed by clicking the radio buttons.
- );
+ 'style' => 'display:none', // Always hide, so they only get revealed by clicking the radio buttons.
+ ];
$html .= html_writer::start_tag('div', $attributes);
/* @var models\moderation_set_rule $instance */
$instance = new $class();
diff --git a/classes/stages/base.php b/classes/stages/base.php
index e81b86c0..05e96ea7 100644
--- a/classes/stages/base.php
+++ b/classes/stages/base.php
@@ -50,41 +50,41 @@ abstract class base {
/**
* @var string
*/
- protected $stage_identifier;
+ protected $stageidentifier;
/**
* @var array|null
*/
- protected $allocatables_with_feedback;
+ protected $allocatableswithfeedback;
/**
* @var array|null
*/
- protected $allocatables_with_moderation;
+ protected $allocatableswithmoderation;
/**
* @var array
*/
- private static $self_cache = [
- 'user_is_assessor' => []
+ private static $selfcache = [
+ 'user_is_assessor' => [],
];
/**
* @param coursework $coursework
* @param int $stage_identifier
*/
- public function __construct($coursework, $stage_identifier) {
+ public function __construct($coursework, $stageidentifier) {
$this->coursework = $coursework;
- $this->stage_identifier = $stage_identifier;
+ $this->stageidentifier = $stageidentifier;
}
/**
* @return strategy_base
*/
private function get_allocation_strategy() {
- $strategy_name = $this->strategy_name();
- $class_name = "\\mod_coursework\\allocation\\strategy\\{$strategy_name}";
- return new $class_name($this->get_coursework(), $this);
+ $strategyname = $this->strategy_name();
+ $classname = "\\modcoursework\\allocation\\strategy\\{$strategyname}";
+ return new $classname($this->get_coursework(), $this);
}
/**
@@ -121,10 +121,10 @@ protected function get_coursework() {
* @return bool
*/
private function already_allocated($allocatable) {
- $coursework_id = $this->get_coursework_id();
- allocation::fill_pool_coursework($coursework_id);
+ $courseworkid = $this->get_coursework_id();
+ allocation::fill_pool_coursework($courseworkid);
$record = allocation::get_object(
- $coursework_id,
+ $courseworkid,
'allocatableid-allocatabletype-stage_identifier',
[$allocatable->id(), $allocatable->type(), $this->identifier()]
);
@@ -139,10 +139,10 @@ private function already_allocated($allocatable) {
public function assessor_already_allocated_for_this_submission($allocatable, $assessor) {
if (!empty($assessor)) {
- $coursework_id = $this->get_coursework_id();
- allocation::fill_pool_coursework($coursework_id);
+ $courseworkid = $this->get_coursework_id();
+ allocation::fill_pool_coursework($courseworkid);
$record = allocation::get_object(
- $coursework_id,
+ $courseworkid,
'allocatableid-allocatabletype-assessorid',
[$allocatable->id(), $allocatable->type(), $assessor->id]
);
@@ -164,7 +164,7 @@ protected function strategy_name() {
* @return string 'assessor_1'
*/
public function identifier() {
- return $this->stage_identifier;
+ return $this->stageidentifier;
}
/**
@@ -194,9 +194,9 @@ public function make_manual_allocation($allocatable, $teacher) {
* @return \html_table_cell
*/
public function get_allocation_table_cell($allocatable) {
- $cell_helper = $this->get_cell_helper($allocatable);
+ $cellhelper = $this->get_cell_helper($allocatable);
- return $cell_helper->get_renderable_allocation_table_cell();
+ return $cellhelper->get_renderable_allocation_table_cell();
}
/**
@@ -204,9 +204,9 @@ public function get_allocation_table_cell($allocatable) {
* @return \html_table_cell
*/
public function get_moderation_table_cell($allocatable) {
- $cell_helper = $this->get_cell_helper($allocatable);
+ $cellhelper = $this->get_cell_helper($allocatable);
- return $cell_helper->get_renderable_moderation_table_cell();
+ return $cellhelper->get_renderable_moderation_table_cell();
}
/**
@@ -250,7 +250,7 @@ private function get_next_teacher($allocatable) {
private function get_percentage_allocated_teachers() {
global $DB;
- return $DB->get_records('coursework_allocation_config', array('courseworkid' => $this->get_coursework_id()), '', 'assessorid as id');
+ return $DB->get_records('coursework_allocation_config', ['courseworkid' => $this->get_coursework_id()], '', 'assessorid as id');
}
/**
@@ -275,10 +275,10 @@ private function prepare_allocation_to_save($allocatable, $teacher) {
*/
public function allocation_is_manual($allocatable) {
- $coursework_id = $this->get_coursework_id();
- allocation::fill_pool_coursework($coursework_id);
+ $courseworkid = $this->get_coursework_id();
+ allocation::fill_pool_coursework($courseworkid);
$record = allocation::get_object(
- $coursework_id,
+ $courseworkid,
'allocatableid-allocatabletype-stage_identifier',
[$allocatable->id(), $allocatable->type(), $this->identifier()]
);
@@ -294,24 +294,24 @@ public function allocation_is_manual($allocatable) {
public function get_teachers() {
$cache = \cache::make('mod_coursework', 'courseworkdata');
- $serialised_teachers = $cache->get($this->coursework->id()."_teachers");
+ $serialisedteachers = $cache->get($this->coursework->id()."_teachers");
// There is a chance that when the teachers were initially cached the dataset was empty
// So check again
- if (empty($serialised_teachers) || empty(unserialize($serialised_teachers))) {
+ if (empty($serialisedteachers) || empty(unserialize($serialisedteachers))) {
$users = get_enrolled_users($this->coursework->get_context());
- $teacher_users = [];
+ $teacherusers = [];
$modcontext = $this->coursework->get_context();
foreach ($users as $user) {
if (has_capability($this->assessor_capability(), $modcontext, $user)) {
- $teacher_users[] = user::build($user);
+ $teacherusers[] = user::build($user);
}
}
- $cache->set($this->coursework->id()."_teachers", serialize($teacher_users));
+ $cache->set($this->coursework->id()."_teachers", serialize($teacherusers));
} else {
- $teacher_users = unserialize($serialised_teachers);
+ $teacherusers = unserialize($serialisedteachers);
}
- return $teacher_users;
+ return $teacherusers;
}
/**
@@ -327,12 +327,12 @@ abstract protected function assessor_capability();
*/
public function has_feedback($allocatable) {
$feedback = null;
- $coursework_id = $this->get_coursework_id();
- submission::fill_pool_coursework($coursework_id);
- $submission = submission::get_object($coursework_id, 'allocatableid', [$allocatable->id]);
+ $courseworkid = $this->get_coursework_id();
+ submission::fill_pool_coursework($courseworkid);
+ $submission = submission::get_object($courseworkid, 'allocatableid', [$allocatable->id]);
if ($submission) {
- feedback::fill_pool_coursework($coursework_id);
- $feedback = feedback::get_object($coursework_id, 'submissionid-stage_identifier', [$submission->id, $this->identifier()]);
+ feedback::fill_pool_coursework($courseworkid);
+ $feedback = feedback::get_object($courseworkid, 'submissionid-stage_identifier', [$submission->id, $this->identifier()]);
}
return !empty($feedback);
}
@@ -350,7 +350,7 @@ public function has_moderation($submission) {
$sql = "SELECT *
FROM {coursework_mod_agreements}
WHERE feedbackid = ?";
- return $DB->record_exists_sql($sql, array($feedback->id));
+ return $DB->record_exists_sql($sql, [$feedback->id]);
} else {
return false;
}
@@ -363,8 +363,8 @@ public function has_moderation($submission) {
public function get_moderation($submission) {
$feedback = $this->get_single_feedback($submission);
if ($feedback) {
- $moderation_params = array('feedbackid' => $feedback->id);
- return moderation::find($moderation_params);
+ $moderationparams = ['feedbackid' => $feedback->id];
+ return moderation::find($moderationparams);
} else {
return false;
}
@@ -401,11 +401,11 @@ public function get_single_feedback($submission) {
*/
public function has_allocation($allocatable) {
if (!isset($this->allocatables_with_allocations)) {
- $coursework_id = $this->get_coursework()->id;
- if (!isset(allocation::$pool[$coursework_id]['stage_identifier'])) {
- allocation::fill_pool_coursework($coursework_id);
+ $courseworkid = $this->get_coursework()->id;
+ if (!isset(allocation::$pool[$courseworkid]['stage_identifier'])) {
+ allocation::fill_pool_coursework($courseworkid);
}
- $this->allocatables_with_allocations = array_column(allocation::$pool[$coursework_id]['stage_identifier'][$this->stage_identifier] ?? [], 'allocatableid');
+ $this->allocatables_with_allocations = array_column(allocation::$pool[$courseworkid]['stage_identifier'][$this->stageidentifier] ?? [], 'allocatableid');
}
return in_array($allocatable->id, $this->allocatables_with_allocations);
@@ -417,9 +417,9 @@ public function has_allocation($allocatable) {
* @return bool
*/
public function stage_has_allocation() {
- $coursework_id = $this->get_coursework_id();
- allocation::fill_pool_coursework($coursework_id);
- $record = allocation::get_object($coursework_id, 'stage_identifier', [$this->stage_identifier]);
+ $courseworkid = $this->get_coursework_id();
+ allocation::fill_pool_coursework($courseworkid);
+ $record = allocation::get_object($courseworkid, 'stage_identifier', [$this->stageidentifier]);
return !empty($record);
}
@@ -448,10 +448,10 @@ public function get_allocation($allocatable) {
* @return user
*/
public function allocated_teacher_for($allocatable) {
- $coursework_id = $this->get_coursework_id();
- allocation::fill_pool_coursework($coursework_id);
+ $courseworkid = $this->get_coursework_id();
+ allocation::fill_pool_coursework($courseworkid);
$allocation = allocation::get_object(
- $coursework_id,
+ $courseworkid,
'allocatableid-allocatabletype-stage_identifier',
[$allocatable->id(), $allocatable->type(), $this->identifier()]
);
@@ -468,19 +468,19 @@ public function allocated_teacher_for($allocatable) {
* @param array $row_data
* @return void
*/
- public function process_allocation_form_row_data($allocatable, $row_data) {
- $cell_helper = $this->get_cell_processor($allocatable);
- $cell_data = $this->get_cell_data($row_data);
- $cell_helper->process($cell_data);
+ public function process_allocation_form_row_data($allocatable, $rowdata) {
+ $cellhelper = $this->get_cell_processor($allocatable);
+ $celldata = $this->get_cell_data($rowdata);
+ $cellhelper->process($celldata);
}
/**
* @param array $row_data
* @return mixed
*/
- private function get_cell_data($row_data) {
- if (array_key_exists($this->identifier(), $row_data)) {
- return new data($this, $row_data[$this->identifier()]);
+ private function get_cell_data($rowdata) {
+ if (array_key_exists($this->identifier(), $rowdata)) {
+ return new data($this, $rowdata[$this->identifier()]);
}
return new data($this);
}
@@ -510,7 +510,7 @@ public function allocatable_is_in_sample($allocatable) {
return true;
}
- if ($this->stage_identifier == 'final_agreed_1') {
+ if ($this->stageidentifier == 'final_agreed_1') {
return true;
}
@@ -518,7 +518,7 @@ public function allocatable_is_in_sample($allocatable) {
$record = assessment_set_membership::get_object(
$this->coursework->id,
'allocatableid-allocatabletype-stage_identifier',
- [$allocatable->id(), $allocatable->type(), $this->stage_identifier]);
+ [$allocatable->id(), $allocatable->type(), $this->stageidentifier]);
return !empty($record);
}
@@ -534,12 +534,12 @@ public function allocatable_is_not_in_sampling($allocatable) {
* @param allocatable $allocatable
*/
public function add_allocatable_to_sampling($allocatable) {
- $moderation_set_membership = new assessment_set_membership();
- $moderation_set_membership->courseworkid = $this->coursework->id;
- $moderation_set_membership->allocatableid = $allocatable->id();
- $moderation_set_membership->allocatabletype = $allocatable->type();
- $moderation_set_membership->stage_identifier = $this->stage_identifier;
- $moderation_set_membership->save();
+ $moderationsetmembership = new assessment_set_membership();
+ $moderationsetmembership->courseworkid = $this->coursework->id;
+ $moderationsetmembership->allocatableid = $allocatable->id();
+ $moderationsetmembership->allocatabletype = $allocatable->type();
+ $moderationsetmembership->stage_identifier = $this->stageidentifier;
+ $moderationsetmembership->save();
}
/**
@@ -548,12 +548,12 @@ public function add_allocatable_to_sampling($allocatable) {
public function remove_allocatable_from_sampling($allocatable) {
global $DB;
- $params = array(
+ $params = [
'courseworkid' => $this->coursework->id,
'allocatableid' => $allocatable->id(),
'allocatabletype' => $allocatable->type(),
- 'stage_identifier' => $this->stage_identifier
- );
+ 'stage_identifier' => $this->stageidentifier,
+ ];
$DB->delete_records('coursework_sample_set_mbrs', $params);
}
@@ -562,14 +562,14 @@ public function remove_allocatable_from_sampling($allocatable) {
* @return bool
*/
public function user_is_assessor($assessor) {
- if (!isset(self::$self_cache['user_is_assessor'][$this->coursework->id][$assessor->id])) {
+ if (!isset(self::$selfcache['user_is_assessor'][$this->coursework->id][$assessor->id])) {
$enrolled = is_enrolled($this->coursework->get_course_context(), $assessor);
$hasmoduleassessorcapability =
($enrolled && has_capability($this->assessor_capability(), $this->coursework->get_context(), $assessor))
|| is_primary_admin($assessor->id);
- self::$self_cache['user_is_assessor'][$this->coursework->id][$assessor->id] = $hasmoduleassessorcapability;
+ self::$selfcache['user_is_assessor'][$this->coursework->id][$assessor->id] = $hasmoduleassessorcapability;
}
- return self::$self_cache['user_is_assessor'][$this->coursework->id][$assessor->id];
+ return self::$selfcache['user_is_assessor'][$this->coursework->id][$assessor->id];
}
/**
@@ -592,7 +592,7 @@ public function assessor_has_allocation($allocatable) {
$allocation = allocation::get_object(
$this->coursework->id,
'allocatableid-allocatabletype-stage_identifier',
- [$allocatable->id(), $allocatable->type(), $this->stage_identifier]
+ [$allocatable->id(), $allocatable->type(), $this->stageidentifier]
);
$result = ($allocation && $allocation->assessorid == $USER->id);
return $result;
@@ -643,21 +643,21 @@ abstract public function allocation_table_header();
* @return bool
*/
public function prerequisite_stages_have_feedback($allocatable) {
- $all_stages = $this->get_coursework()->marking_stages();
+ $allstages = $this->get_coursework()->marking_stages();
// Some stages are parallel, so we ignore them being partially complete.
- $previous_stage_ok = true;
- $current_stage = false;
- $current_stage_ok = true;
- $coursework_id = $this->get_coursework_id();
- submission::fill_pool_coursework($coursework_id);
+ $previousstageok = true;
+ $currentstage = false;
+ $currentstageok = true;
+ $courseworkid = $this->get_coursework_id();
+ submission::fill_pool_coursework($courseworkid);
- foreach ($all_stages as $stage) {
+ foreach ($allstages as $stage) {
// if coursework has sampling enabled, each stage must be checked if it uses sampling
if ($this->get_coursework()->sampling_enabled()) {
- $submission = submission::get_object($coursework_id, 'allocatableid-allocatabletype', [$allocatable->id(), $allocatable->type()]);
+ $submission = submission::get_object($courseworkid, 'allocatableid-allocatabletype', [$allocatable->id(), $allocatable->type()]);
if (count($submission->get_assessor_feedbacks()) >= $submission->max_number_of_feedbacks()
&& $submission->sampled_feedback_exists()) {
@@ -669,16 +669,16 @@ public function prerequisite_stages_have_feedback($allocatable) {
break;
}
$class = get_class($stage);
- if ($class != $current_stage) { // New stage type
- $current_stage = $class;
- $previous_stage_ok = $current_stage_ok;
- $current_stage_ok = $stage->has_feedback($allocatable) && !$stage->in_editable_period($allocatable);
+ if ($class != $currentstage) { // New stage type
+ $currentstage = $class;
+ $previousstageok = $currentstageok;
+ $currentstageok = $stage->has_feedback($allocatable) && !$stage->in_editable_period($allocatable);
} else { // Same stage (parallel)
- $current_stage_ok = $current_stage_ok && $stage->has_feedback($allocatable) && !$stage->in_editable_period($allocatable);
+ $currentstageok = $currentstageok && $stage->has_feedback($allocatable) && !$stage->in_editable_period($allocatable);
}
}
- return $this->is_parallell() ? $previous_stage_ok : $current_stage_ok;
+ return $this->is_parallell() ? $previousstageok : $currentstageok;
}
/**
@@ -708,8 +708,8 @@ public function group_assessor_enabled() {
* @return feedback|bool
*/
public function get_feedback_for_submission($submission) {
- $stage_identifier = $this->identifier();
- $feedback = feedback::get_object($submission->courseworkid, 'submissionid-stage_identifier', [$submission->id, $stage_identifier]);
+ $stageidentifier = $this->identifier();
+ $feedback = feedback::get_object($submission->courseworkid, 'submissionid-stage_identifier', [$submission->id, $stageidentifier]);
return $feedback;
}
@@ -718,17 +718,17 @@ public function get_feedback_for_submission($submission) {
* @return moderation|bool
*/
public function get_moderation_for_feedback($feedback) {
- $moderation_params = array(
- 'feedbackid' => $feedback->id
- );
- return moderation::find($moderation_params);
+ $moderationparams = [
+ 'feedbackid' => $feedback->id,
+ ];
+ return moderation::find($moderationparams);
}
/**
* return bool
*/
public function assessment_set_is_not_empty() {
- return assessment_set_membership::exists(array('courseworkid' => $this->coursework->id));
+ return assessment_set_membership::exists(['courseworkid' => $this->coursework->id]);
}
/**
@@ -744,7 +744,7 @@ public function other_parallel_stage_has_feedback_from_this_assessor($assessor,
* @return string
*/
public function type() {
- return substr($this->stage_identifier, 0, -2);
+ return substr($this->stageidentifier, 0, -2);
}
/**
@@ -772,15 +772,15 @@ public function potential_marker_dropdown($allocatable) {
return ' ' . get_string('nomarkers', 'mod_coursework');
}
- $html_attributes = array(
+ $htmlattributes = [
'id' => $this->assessor_dropdown_id($allocatable),
'class' => 'assessor_id_dropdown',
- );
+ ];
if ($this->identifier() != 'assessor_1' && !$this->currently_allocated_assessor($allocatable)
&& $this->coursework->sampling_enabled() && !$this->allocatable_is_in_sample($allocatable)
) {
- $html_attributes['disabled'] = 'disabled';
+ $htmlattributes['disabled'] = 'disabled';
}
$grader = substr($this->identifier(), 0, -2);
@@ -790,20 +790,20 @@ public function potential_marker_dropdown($allocatable) {
$identifier = 'change' . $grader;
}
- $option_for_nothing_chosen_yet = array('' => get_string($identifier, 'mod_coursework'));
+ $optionfornothingchosenyet = ['' => get_string($identifier, 'mod_coursework')];
- $dropdown_name = $this->assessor_dropdown_name($allocatable);
+ $dropdownname = $this->assessor_dropdown_name($allocatable);
- $selected = $this->selected_allocation_in_session($dropdown_name);
+ $selected = $this->selected_allocation_in_session($dropdownname);
- $assessor_dropdown = \html_writer::select($this->assessor_dropdown_options,
- $dropdown_name,
+ $assessordropdown = \html_writer::select($this->assessor_dropdown_options,
+ $dropdownname,
$selected,
- $option_for_nothing_chosen_yet,
- $html_attributes
+ $optionfornothingchosenyet,
+ $htmlattributes
);
- return $assessor_dropdown;
+ return $assessordropdown;
}
/**
@@ -812,21 +812,21 @@ public function potential_marker_dropdown($allocatable) {
*/
public function potential_moderator_dropdown($allocatable) {
- $option_for_nothing_chosen_yet = array('' => 'Choose Moderator');
- $html_attributes = array(
+ $optionfornothingchosenyet = ['' => 'Choose Moderator'];
+ $htmlattributes = [
'id' => $this->moderator_dropdown_id($allocatable),
'class' => 'moderator_id_dropdown',
- );
+ ];
- $dropdown_name = $this->assessor_dropdown_name($allocatable);
+ $dropdownname = $this->assessor_dropdown_name($allocatable);
- $selected = $this->selected_allocation_in_session($dropdown_name);
+ $selected = $this->selected_allocation_in_session($dropdownname);
- return $moderator_dropdown = \html_writer::select($this->potential_moderators_as_options_array(),
+ return $moderatordropdown = \html_writer::select($this->potential_moderators_as_options_array(),
'allocatables[' . $allocatable->id . '][moderator][assessor_id]',
$selected,
- $option_for_nothing_chosen_yet,
- $html_attributes);
+ $optionfornothingchosenyet,
+ $htmlattributes);
}
/**
@@ -886,9 +886,9 @@ private function moderator_dropdown_id($allocatable) {
* @return string
*/
private function assessor_dropdown_name($allocatable) {
- $input_name =
+ $inputname =
'allocatables[' . $allocatable->id . '][' . $this->identifier() . '][assessor_id]';
- return $input_name;
+ return $inputname;
}
/**
@@ -910,11 +910,13 @@ private function in_editable_period($allocatable) {
$result = $this->get_coursework()->get_grade_editing_time();
// The feedback is not in the editable period if the editable setting is disabled
- if (empty($this->get_coursework()->get_grade_editing_time())) return false;
+ if (empty($this->get_coursework()->get_grade_editing_time())) {
+ return false;
+ }
- $coursework_id = $this->get_coursework_id();
- submission::fill_pool_coursework($coursework_id);
- $submission = submission::get_object($coursework_id, 'allocatableid-allocatabletype', [$allocatable->id(), $allocatable->type()]);
+ $courseworkid = $this->get_coursework_id();
+ submission::fill_pool_coursework($courseworkid);
+ $submission = submission::get_object($courseworkid, 'allocatableid-allocatabletype', [$allocatable->id(), $allocatable->type()]);
$feedback = $this->get_feedback_for_submission($submission);
if ($feedback) {
diff --git a/classes/task/enrol_task.php b/classes/task/enrol_task.php
index 0de5827b..8f4372ec 100644
--- a/classes/task/enrol_task.php
+++ b/classes/task/enrol_task.php
@@ -43,7 +43,7 @@ public function execute() {
global $DB;
- $courseworkids = $DB->get_records('coursework', array('processenrol' => 1));
+ $courseworkids = $DB->get_records('coursework', ['processenrol' => 1]);
if (!empty($courseworkids)) {
foreach ($courseworkids as $courseworkid) {
@@ -57,7 +57,7 @@ public function execute() {
$allocator = new \mod_coursework\allocation\auto_allocator($coursework);
$allocator->process_allocations();
- $DB->set_field('coursework', 'processenrol', 0, array('id' => $coursework->id()));
+ $DB->set_field('coursework', 'processenrol', 0, ['id' => $coursework->id()]);
}
}
diff --git a/classes/task/unenrol_task.php b/classes/task/unenrol_task.php
index acdc1d96..f5b7584a 100644
--- a/classes/task/unenrol_task.php
+++ b/classes/task/unenrol_task.php
@@ -43,7 +43,7 @@ public function execute() {
global $DB;
- $courseworkids = $DB->get_records('coursework', array('processunenrol' => 1));
+ $courseworkids = $DB->get_records('coursework', ['processunenrol' => 1]);
if (!empty($courseworkids)) {
foreach ($courseworkids as $courseworkid) {
@@ -55,7 +55,7 @@ public function execute() {
$allocator = new \mod_coursework\allocation\auto_allocator($coursework);
$allocator->process_allocations();
- $DB->set_field('coursework', 'processunenrol', 0, array('id' => $coursework->id()));
+ $DB->set_field('coursework', 'processunenrol', 0, ['id' => $coursework->id()]);
}
}
diff --git a/classes/traits/allocatable_functions.php b/classes/traits/allocatable_functions.php
index ccbf9a43..83bfdc7f 100644
--- a/classes/traits/allocatable_functions.php
+++ b/classes/traits/allocatable_functions.php
@@ -55,12 +55,12 @@ public function delete_all_submission_allocations($coursework) {
AND allocatabletype = :type
";
- $params = array(
+ $params = [
'courseworkid' => $coursework->id,
'courseworkid2' => $coursework->id,
'id' => $this->id(),
'type' => $this->type(),
- );
+ ];
$DB->execute($sql, $params);
}
@@ -79,7 +79,7 @@ public function has_agreed_feedback($coursework) {
AND s.allocatableid = :id
AND s.courseworkid = :courseworkid
";
- $result = $DB->count_records_sql($sql, array('id' => $this->id(), 'courseworkid' => $coursework->id()));
+ $result = $DB->count_records_sql($sql, ['id' => $this->id(), 'courseworkid' => $coursework->id()]);
return !empty($result);
}
@@ -98,7 +98,7 @@ public function get_agreed_feedback($coursework) {
AND s.allocatableid = :id
AND s.courseworkid = :courseworkid";
- return $DB->get_record_sql($sql, array('id' => $this->id(), 'courseworkid' => $coursework->id()));
+ return $DB->get_record_sql($sql, ['id' => $this->id(), 'courseworkid' => $coursework->id()]);
}
/**
@@ -108,7 +108,7 @@ public function get_agreed_feedback($coursework) {
public function has_all_initial_feedbacks($coursework) {
global $DB;
- $expected_markers = $coursework->numberofmarkers;
+ $expectedmarkers = $coursework->numberofmarkers;
$sql = "
SELECT COUNT(*)
@@ -120,8 +120,8 @@ public function has_all_initial_feedbacks($coursework) {
AND s.courseworkid = :courseworkid
";
$feedbacks = $DB->count_records_sql($sql,
- array('id' => $this->id(),
- 'courseworkid' => $coursework->id()));
+ ['id' => $this->id(),
+ 'courseworkid' => $coursework->id()]);
// when sampling is enabled, calculate how many stages are in sample
if ($coursework->sampling_enabled()) {
@@ -133,14 +133,14 @@ public function has_all_initial_feedbacks($coursework) {
AND allocatabletype = :allocatabletype";
$markers = $DB->count_records_sql($sql,
- array('courseworkid' => $coursework->id(),
+ ['courseworkid' => $coursework->id(),
'allocatableid' => $this->id(),
- 'allocatabletype' => $this->type()));
+ 'allocatabletype' => $this->type()]);
- $expected_markers = $markers + 1; // there is always a marker for stage 1
+ $expectedmarkers = $markers + 1; // there is always a marker for stage 1
}
- return $feedbacks == $expected_markers;
+ return $feedbacks == $expectedmarkers;
}
/**
@@ -173,8 +173,8 @@ public function get_submission($coursework) {
* @param $coursework
*/
private function fill_submission_and_feedback($coursework) {
- $coursework_id = $coursework->id;
- submission::fill_pool_coursework($coursework_id);
- feedback::fill_pool_coursework($coursework_id);
+ $courseworkid = $coursework->id;
+ submission::fill_pool_coursework($courseworkid);
+ feedback::fill_pool_coursework($courseworkid);
}
}
diff --git a/classes/warnings.php b/classes/warnings.php
index 21576ab3..d344de17 100644
--- a/classes/warnings.php
+++ b/classes/warnings.php
@@ -52,15 +52,15 @@ public function __construct($coursework) {
public function not_enough_assessors() {
$html = '';
- $first_stage = $this->coursework->get_stage('assessor_1');
- $actual_number = count($first_stage->get_teachers());
- $number_of_initial_assessors = $actual_number;
+ $firststage = $this->coursework->get_stage('assessor_1');
+ $actualnumber = count($firststage->get_teachers());
+ $numberofinitialassessors = $actualnumber;
- if ($number_of_initial_assessors < $this->coursework->numberofmarkers) {
+ if ($numberofinitialassessors < $this->coursework->numberofmarkers) {
// Problem!
$strings = new \stdClass();
- $strings->actual_number = $actual_number;
+ $strings->actual_number = $actualnumber;
$strings->required_number = $this->coursework->numberofmarkers;
$html .= get_string('not_enough_teachers', 'mod_coursework', $strings);
@@ -99,8 +99,8 @@ public function students_in_mutiple_grouos() {
GROUP BY gm.userid, groupings.groupingid, u.firstname, u.lastname)a
WHERE noofgroups > 1";
- $params = array('courseid' => $this->coursework->get_course()->id,
- 'groupingid' => $this->coursework->grouping_id);
+ $params = ['courseid' => $this->coursework->get_course()->id,
+ 'groupingid' => $this->coursework->grouping_id];
} else {
$sql = "SELECT * FROM (
SELECT gm.userid,
@@ -116,7 +116,7 @@ public function students_in_mutiple_grouos() {
GROUP BY gm.userid, u.firstname, u.lastname) a
WHERE noofgroups > 1";
- $params = array('courseid' => $this->coursework->get_course()->id);
+ $params = ['courseid' => $this->coursework->get_course()->id];
}
// get all students that are in more than a one group
@@ -142,10 +142,10 @@ public function students_in_mutiple_grouos() {
AND gm.userid = :userid
AND groupings.groupingid =:grouping_id";
- $params = array(
+ $params = [
'grouping_id' => $this->coursework->grouping_id,
'courseid' => $this->coursework->get_course()->id,
- 'userid' => $student->userid);
+ 'userid' => $student->userid];
} else {
$sql = "SELECT groups.id,groups.name
@@ -155,9 +155,9 @@ public function students_in_mutiple_grouos() {
WHERE groups.courseid = :courseid
AND gm.userid = :userid";
- $params = array(
+ $params = [
'courseid' => $this->coursework->get_course()->id,
- 'userid' => $student->userid);
+ 'userid' => $student->userid];
}
$studentmessage .= ' ';
$groups = $DB->get_records_sql($sql, $params);
@@ -201,10 +201,10 @@ public function percentage_allocations_not_complete() {
WHERE courseworkid = ?
AND allocationstrategy = 'percentages'
";
- $total_percentages = $DB->count_records_sql($sql, array($this->coursework->id));
+ $totalpercentages = $DB->count_records_sql($sql, [$this->coursework->id]);
- if ($total_percentages < 100) {
- return $this->alert_div(get_string('percentages_do_not_add_up', 'mod_coursework', $total_percentages));
+ if ($totalpercentages < 100) {
+ return $this->alert_div(get_string('percentages_do_not_add_up', 'mod_coursework', $totalpercentages));
}
}
@@ -220,45 +220,45 @@ public function manual_allocation_not_completed() {
$coursework = $this->coursework;
- $coursework_stages = $coursework->numberofmarkers;
- for ($i = 1; $i <= $coursework_stages; $i++) {
+ $courseworkstages = $coursework->numberofmarkers;
+ for ($i = 1; $i <= $courseworkstages; $i++) {
$assessor = 'assessor_'.$i;
- if ($coursework->samplingenabled == 0 || $assessor == 'assessor_1') {
- $allocatables = $coursework->get_allocatables();
+ if ($coursework->samplingenabled == 0 || $assessor == 'assessor_1') {
+ $allocatables = $coursework->get_allocatables();
- foreach ($allocatables as $allocatable) {
+ foreach ($allocatables as $allocatable) {
- $params = array('courseworkid' => $coursework->id,
- 'stageidentifier' => $assessor,
- 'allocatableid' => $allocatable->id);
+ $params = ['courseworkid' => $coursework->id,
+ 'stageidentifier' => $assessor,
+ 'allocatableid' => $allocatable->id];
- $existing_allocations = $this->check_existing_allocations($params);
+ $existingallocations = $this->check_existing_allocations($params);
- if ($existing_allocations == false) {
- return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework'));
- }
- }
- } else {
+ if ($existingallocations == false) {
+ return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework'));
+ }
+ }
+ } else {
- $params = array('courseworkid' => $coursework->id);
- $sql = "SELECT id, stage_identifier, allocatableid
+ $params = ['courseworkid' => $coursework->id];
+ $sql = "SELECT id, stage_identifier, allocatableid
FROM {coursework_sample_set_mbrs}
WHERE courseworkid = :courseworkid";
- $stage_identifiers = $DB->get_records_sql($sql, $params);
- foreach ($stage_identifiers as $stage_identifier) {
- $params = array('courseworkid' => $coursework->id,
- 'stageidentifier' => $stage_identifier->stage_identifier,
- 'allocatableid' => $stage_identifier->allocatableid);
+ $stageidentifiers = $DB->get_records_sql($sql, $params);
+ foreach ($stageidentifiers as $stageidentifier) {
+ $params = ['courseworkid' => $coursework->id,
+ 'stageidentifier' => $stageidentifier->stage_identifier,
+ 'allocatableid' => $stageidentifier->allocatableid];
- $existing_allocations = $this->check_existing_allocations($params);
+ $existingallocations = $this->check_existing_allocations($params);
- if ($existing_allocations == false) {
- return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework'));
- }
- }
- }
+ if ($existingallocations == false) {
+ return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework'));
+ }
+ }
+ }
}
return '';
}
@@ -275,7 +275,7 @@ public function check_existing_allocations($params) {
AND stage_identifier = :stageidentifier
AND allocatableid = :allocatableid";
- return $existing_allocations = $DB->get_records_sql($sql, $params);
+ return $existingallocations = $DB->get_records_sql($sql, $params);
}
@@ -292,24 +292,24 @@ public function student_in_no_group() {
return '';
}
- $student_ids = array_keys(get_enrolled_users($this->coursework->get_context(), 'mod/coursework:submit'));
+ $studentids = array_keys(get_enrolled_users($this->coursework->get_context(), 'mod/coursework:submit'));
- if (empty($student_ids)) {
+ if (empty($studentids)) {
return '';
}
- list($student_sql, $student_params) = $DB->get_in_or_equal($student_ids, SQL_PARAMS_NAMED);
+ list($studentsql, $studentparams) = $DB->get_in_or_equal($studentids, SQL_PARAMS_NAMED);
if ($this->coursework->grouping_id != 0) {
$students =
- $this->students_who_are_not_in_any_grouping_group($student_sql, $student_params);
+ $this->students_who_are_not_in_any_grouping_group($studentsql, $studentparams);
if ($students) {
$names = $this->make_list_of_student_names($students);
return $this->alert_div(get_string('students_in_no_group_warning', 'mod_coursework').$names);
}
} else {
- $students = $this->students_who_are_not_in_any_group($student_sql, $student_params);
+ $students = $this->students_who_are_not_in_any_group($studentsql, $studentparams);
if ($students) {
$names = $this->make_list_of_student_names($students);
@@ -352,7 +352,7 @@ protected function make_list_of_student_names($students) {
* @param $student_params
* @return mixed
*/
- private function students_who_are_not_in_any_group($student_sql, $student_params) {
+ private function students_who_are_not_in_any_group($studentsql, $studentparams) {
global $DB;
$sql = "SELECT u.*
@@ -365,14 +365,14 @@ private function students_who_are_not_in_any_group($student_sql, $student_params
WHERE m.userid = u.id
AND g.courseid = :courseid
)
- AND u.id $student_sql
+ AND u.id $studentsql
";
- $params = array_merge($student_params,
- array(
- 'courseid' => $this->coursework->get_course()->id
- ));
+ $params = array_merge($studentparams,
+ [
+ 'courseid' => $this->coursework->get_course()->id,
+ ]);
$students = $DB->get_records_sql($sql, $params);
return $students;
}
@@ -382,7 +382,7 @@ private function students_who_are_not_in_any_group($student_sql, $student_params
* @param $student_params
* @return mixed
*/
- private function students_who_are_not_in_any_grouping_group($student_sql, $student_params) {
+ private function students_who_are_not_in_any_grouping_group($studentsql, $studentparams) {
global $DB;
$sql = "SELECT u.*
@@ -398,14 +398,14 @@ private function students_who_are_not_in_any_grouping_group($student_sql, $stude
AND g.courseid = :courseid
AND gr.groupingid = :groupingid
)
- AND u.id $student_sql
+ AND u.id $studentsql
";
- $params = array_merge($student_params,
- array(
+ $params = array_merge($studentparams,
+ [
'courseid' => $this->coursework->get_course()->id,
'groupingid' => $this->coursework->grouping_id,
- ));
+ ]);
$students = $DB->get_records_sql($sql, $params);
return $students;
}
diff --git a/db/access.php b/db/access.php
index 07e8c4b2..15f87a44 100644
--- a/db/access.php
+++ b/db/access.php
@@ -52,263 +52,263 @@
defined('MOODLE_INTERNAL') || die();
-$capabilities = array(
+$capabilities = [
- 'mod/coursework:addinstance' => array(
+ 'mod/coursework:addinstance' => [
'riskbitmask' => RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
- 'archetypes' => array(
+ 'archetypes' => [
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- ),
- 'clonepermissionsfrom' => 'moodle/course:manageactivities'
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ 'clonepermissionsfrom' => 'moodle/course:manageactivities',
+ ],
- 'mod/coursework:view' => array(
+ 'mod/coursework:view' => [
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
+ 'legacy' => [
'guest' => CAP_ALLOW,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:submit' => array(
+ 'mod/coursework:submit' => [
'riskbitmask' => RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'student' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'student' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:submitonbehalfof' => array(
+ 'mod/coursework:submitonbehalfof' => [
'riskbitmask' => RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:addinitialgrade' => array(
+ 'mod/coursework:addinitialgrade' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
+ 'legacy' => [
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:editinitialgrade' => array(
+ 'mod/coursework:editinitialgrade' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:addagreedgrade' => array(
+ 'mod/coursework:addagreedgrade' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:editagreedgrade' => array(
+ 'mod/coursework:editagreedgrade' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:publish' => array(
+ 'mod/coursework:publish' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:viewanonymous' => array(
+ 'mod/coursework:viewanonymous' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:revertfinalised' => array(
+ 'mod/coursework:revertfinalised' => [
'riskbitmask' => RISK_MANAGETRUST,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:allocate' => array(
+ 'mod/coursework:allocate' => [
'riskbitmask' => RISK_MANAGETRUST,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:viewallgradesatalltimes' => array(
+ 'mod/coursework:viewallgradesatalltimes' => [
'riskbitmask' => RISK_MANAGETRUST | RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:administergrades' => array(
+ 'mod/coursework:administergrades' => [
'riskbitmask' => RISK_MANAGETRUST | RISK_PERSONAL | RISK_DATALOSS,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:grantextensions' => array(
+ 'mod/coursework:grantextensions' => [
'riskbitmask' => RISK_MANAGETRUST,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:canexportfinalgrades' => array(
+ 'mod/coursework:canexportfinalgrades' => [
'riskbitmask' => RISK_MANAGETRUST,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:viewextensions' => array(
+ 'mod/coursework:viewextensions' => [
'riskbitmask' => RISK_MANAGETRUST | RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
+ 'legacy' => [
'manager' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- )
- ),
+ ],
+ ],
- 'mod/coursework:grade' => array(
+ 'mod/coursework:grade' => [
'riskbitmask' => RISK_MANAGETRUST | RISK_PERSONAL,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
+ 'legacy' => [
'manager' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- )
- ),
- 'mod/coursework:addgeneralfeedback' => array(
+ ],
+ ],
+ 'mod/coursework:addgeneralfeedback' => [
'riskbitmask' => RISK_MANAGETRUST | RISK_PERSONAL,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
+ 'legacy' => [
'manager' => CAP_ALLOW,
- )
- ),
+ ],
+ ],
- 'mod/coursework:viewallstudents' => array(
+ 'mod/coursework:viewallstudents' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
+ 'legacy' => [
'manager' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
- 'editingteacher' => CAP_ALLOW
- )
- ),
+ 'editingteacher' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:addallocatedagreedgrade' => array(
+ 'mod/coursework:addallocatedagreedgrade' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:editallocatedagreedgrade' => array(
+ 'mod/coursework:editallocatedagreedgrade' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:editpersonaldeadline' => array(
+ 'mod/coursework:editpersonaldeadline' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:moderate' => array(
+ 'mod/coursework:moderate' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:receivesubmissionnotifications' => array(
+ 'mod/coursework:receivesubmissionnotifications' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:addplagiarismflag' => array(
+ 'mod/coursework:addplagiarismflag' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
+ 'legacy' => [
'manager' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
- 'editingteacher' => CAP_ALLOW
- )
- ),
+ 'editingteacher' => CAP_ALLOW,
+ ],
+ ],
- 'mod/coursework:updateplagiarismflag' => array(
+ 'mod/coursework:updateplagiarismflag' => [
'riskbitmask' => RISK_PERSONAL | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'legacy' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'legacy' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
-);
+];
diff --git a/db/caches.php b/db/caches.php
index b097c831..c51c2b13 100644
--- a/db/caches.php
+++ b/db/caches.php
@@ -20,8 +20,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$definitions = array(
- 'courseworkdata' => array(
- 'mode' => cache_store::MODE_APPLICATION
- )
-);
+$definitions = [
+ 'courseworkdata' => [
+ 'mode' => cache_store::MODE_APPLICATION,
+ ],
+];
diff --git a/db/events.php b/db/events.php
index 31627dd3..7791597b 100644
--- a/db/events.php
+++ b/db/events.php
@@ -22,44 +22,44 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$observers = array(
+$observers = [
- array(
+ [
'eventname' => '\core\event\role_assigned',
'callback' => 'mod_coursework_observer::autoallocate_when_user_added',
- ),
- array(
+ ],
+ [
'eventname' => '\core\event\role_unassigned',
'callback' => 'mod_coursework_observer::autoallocate_when_user_removed',
- ),
- array(
+ ],
+ [
'eventname' => '\mod_coursework\event\coursework_deadline_changed',
'callback' => 'mod_coursework_observer::coursework_deadline_changed',
- 'schedule' => 'cron'
- ),
- array(
+ 'schedule' => 'cron',
+ ],
+ [
'eventname' => '\core\event\course_module_updated',
'callback' => 'mod_coursework_observer::process_allocation_after_update',
- ),
- array(
+ ],
+ [
'eventname' => '\core\event\course_module_created',
'callback' => 'mod_coursework_observer::process_allocation_after_creation',
- ),
- array(
+ ],
+ [
'eventname' => '\core\event\group_member_added',
'callback' => 'mod_coursework_observer::process_allocations_when_group_member_added',
- ),
- array(
+ ],
+ [
'eventname' => '\core\event\group_member_removed',
'callback' => 'mod_coursework_observer::process_allocations_when_group_member_removed',
- ),
- array(
+ ],
+ [
'eventname' => 'core\event\role_assigned',
'callback' => 'mod_coursework_observer::add_teacher_to_dropdown_when_enrolled',
- ),
- array(
+ ],
+ [
'eventname' => 'core\event\role_unassigned',
'callback' => 'mod_coursework_observer::remove_teacher_from_dropdown_when_unenrolled',
- ),
-);
+ ],
+];
diff --git a/db/install.php b/db/install.php
index 3f8a2049..5a4a7f17 100644
--- a/db/install.php
+++ b/db/install.php
@@ -26,7 +26,7 @@ function xmldb_coursework_install() {
global $DB;
// Install the plugins used by sampling in the correct order
- $plugins = array('range_sample_type', 'total_sample_type');
+ $plugins = ['range_sample_type', 'total_sample_type'];
$i = 1;
diff --git a/db/log.php b/db/log.php
index cd5cd1a1..fa266c70 100644
--- a/db/log.php
+++ b/db/log.php
@@ -35,9 +35,9 @@
global $DB;
-$logs = array(
- array('module' => 'coursework', 'action' => 'add', 'mtable' => 'coursework', 'field' => 'name'),
- array('module' => 'coursework', 'action' => 'update', 'mtable' => 'coursework', 'field' => 'name'),
- array('module' => 'coursework', 'action' => 'view', 'mtable' => 'coursework', 'field' => 'name'),
- array('module' => 'coursework', 'action' => 'view all', 'mtable' => 'coursework', 'field' => 'name')
-);
+$logs = [
+ ['module' => 'coursework', 'action' => 'add', 'mtable' => 'coursework', 'field' => 'name'],
+ ['module' => 'coursework', 'action' => 'update', 'mtable' => 'coursework', 'field' => 'name'],
+ ['module' => 'coursework', 'action' => 'view', 'mtable' => 'coursework', 'field' => 'name'],
+ ['module' => 'coursework', 'action' => 'view all', 'mtable' => 'coursework', 'field' => 'name'],
+];
diff --git a/db/messages.php b/db/messages.php
index d6264739..0a1202a0 100644
--- a/db/messages.php
+++ b/db/messages.php
@@ -24,27 +24,27 @@
global $CFG;
-$messageproviders = array(
- 'deadlinechanged' => array(
- ),
- 'submission_receipt' => array(
- 'defaults' => array(
+$messageproviders = [
+ 'deadlinechanged' => [
+ ],
+ 'submission_receipt' => [
+ 'defaults' => [
'popup' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_ENABLED,
'email' => MESSAGE_FORCED,
- ),
- ),
- 'coursework_submission' => array(
- 'defaults' => array(
+ ],
+ ],
+ 'coursework_submission' => [
+ 'defaults' => [
'popup' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_ENABLED,
'email' => MESSAGE_FORCED,
- ),
- ),
- 'feedback_released' => array(
- 'defaults' => array(
+ ],
+ ],
+ 'feedback_released' => [
+ 'defaults' => [
'popup' => MESSAGE_DISALLOWED,
'email' => MESSAGE_FORCED,
- ),
- ),
- 'student_deadline_reminder' => array(
- ),
-);
+ ],
+ ],
+ 'student_deadline_reminder' => [
+ ],
+];
diff --git a/db/tasks.php b/db/tasks.php
index 8ab3a22e..bb3b7bd3 100644
--- a/db/tasks.php
+++ b/db/tasks.php
@@ -25,32 +25,32 @@
defined('MOODLE_INTERNAL') || die();
-$tasks = array(
- array(
+$tasks = [
+ [
'classname' => 'mod_coursework\task\cron_task',
'blocking' => 0,
'minute' => '0',
'hour' => '0',
'day' => '*',
'month' => '*',
- 'dayofweek' => '*'
- ),
- array(
+ 'dayofweek' => '*',
+ ],
+ [
'classname' => 'mod_coursework\task\enrol_task',
'blocking' => 0,
'minute' => '0',
'hour' => '*',
'day' => '*',
'month' => '*',
- 'dayofweek' => '*'
- ),
- array(
+ 'dayofweek' => '*',
+ ],
+ [
'classname' => 'mod_coursework\task\unenrol_task',
'blocking' => 0,
'minute' => '0',
'hour' => '*',
'day' => '*',
'month' => '*',
- 'dayofweek' => '*'
- )
-);
+ 'dayofweek' => '*',
+ ],
+];
diff --git a/db/upgrade.php b/db/upgrade.php
index 11960664..1c069ee8 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -129,7 +129,7 @@ function xmldb_coursework_upgrade($oldversion) {
$newcomment = [];
$oldcomment = $datarow->feedbackcomment; // Comma separated, with lots of extra commas.
$components = $DB->get_records('coursework_form_component',
- array('fieldid' => $datarow->fieldid));
+ ['fieldid' => $datarow->fieldid]);
foreach ($components as $component) {
if (!empty($oldcomment) && strpos($component->comp_description, $oldcomment) !== false) {
$newcomment[] = $component->id;
@@ -230,7 +230,7 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('manual', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
// Adding keys to table coursework_allocation_pairs.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for coursework_allocation_pairs.
if (!$dbman->table_exists($table)) {
@@ -339,9 +339,9 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('ruleorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
// Adding keys to table coursework_moderation_set_ru.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
- $table->add_key('coursework_fk', XMLDB_KEY_FOREIGN, array('courseworkid'), 'coursework',
- array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+ $table->add_key('coursework_fk', XMLDB_KEY_FOREIGN, ['courseworkid'], 'coursework',
+ ['id']);
// Conditionally launch create table for coursework_moderation_set_ru.
if (!$dbman->table_exists($table)) {
@@ -366,9 +366,9 @@ function xmldb_coursework_upgrade($oldversion) {
null);
// Adding keys to table coursework_mod_set_rule_bg.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
- $table->add_key('ruleinstance_fk', XMLDB_KEY_FOREIGN, array('ruleinstanceid'),
- 'coursework_mod_set_rules', array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+ $table->add_key('ruleinstance_fk', XMLDB_KEY_FOREIGN, ['ruleinstanceid'],
+ 'coursework_mod_set_rules', ['id']);
// Conditionally launch create table for coursework_mod_set_rule_bg.
if (!$dbman->table_exists($table)) {
@@ -454,9 +454,9 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('value', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
// Adding keys to table coursework_allocation_config.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
- $table->add_key('courseworkid_fk', XMLDB_KEY_FOREIGN, array('courseworkid'), 'coursework', array('id'));
- $table->add_key('assessorid_fk', XMLDB_KEY_FOREIGN, array('assessorid'), 'user', array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+ $table->add_key('courseworkid_fk', XMLDB_KEY_FOREIGN, ['courseworkid'], 'coursework', ['id']);
+ $table->add_key('assessorid_fk', XMLDB_KEY_FOREIGN, ['assessorid'], 'user', ['id']);
// Conditionally launch create table for coursework_allocation_config.
if (!$dbman->table_exists($table)) {
@@ -558,11 +558,11 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('createdby', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
// Adding keys to table coursework_mitigations.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
- $table->add_key('courseworkid_fk', XMLDB_KEY_FOREIGN, array('courseworkid'), 'coursework', array('id'));
- $table->add_key('studentid_fk', XMLDB_KEY_FOREIGN, array('studentid'), 'user', array('id'));
- $table->add_key('lastmodifiedby_fk', XMLDB_KEY_FOREIGN, array('lastmodifiedby'), 'user', array('id'));
- $table->add_key('createdby_fk', XMLDB_KEY_FOREIGN, array('createdby'), 'user', array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+ $table->add_key('courseworkid_fk', XMLDB_KEY_FOREIGN, ['courseworkid'], 'coursework', ['id']);
+ $table->add_key('studentid_fk', XMLDB_KEY_FOREIGN, ['studentid'], 'user', ['id']);
+ $table->add_key('lastmodifiedby_fk', XMLDB_KEY_FOREIGN, ['lastmodifiedby'], 'user', ['id']);
+ $table->add_key('createdby_fk', XMLDB_KEY_FOREIGN, ['createdby'], 'user', ['id']);
// Conditionally launch create table for coursework_mitigations.
if (!$dbman->table_exists($table)) {
@@ -726,7 +726,7 @@ function xmldb_coursework_upgrade($oldversion) {
$table = new xmldb_table('coursework_submissions');
// Conditionally launch drop index mitigation_id.
- $index = new xmldb_index('mitigation_id', XMLDB_INDEX_NOTUNIQUE, array('mitigation_id'));
+ $index = new xmldb_index('mitigation_id', XMLDB_INDEX_NOTUNIQUE, ['mitigation_id']);
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
@@ -975,7 +975,7 @@ function xmldb_coursework_upgrade($oldversion) {
";
$feedbacks = $DB->get_records_sql($sql);
foreach ($feedbacks as $feedback) {
- $DB->set_field('coursework_feedbacks', 'markernumber', 1, array('id' => $feedback->id));
+ $DB->set_field('coursework_feedbacks', 'markernumber', 1, ['id' => $feedback->id]);
}
// Then the second ones.
@@ -995,7 +995,7 @@ function xmldb_coursework_upgrade($oldversion) {
";
$feedbacks = $DB->get_records_sql($sql);
foreach ($feedbacks as $feedback) {
- $DB->set_field('coursework_feedbacks', 'markernumber', 2, array('id' => $feedback->id));
+ $DB->set_field('coursework_feedbacks', 'markernumber', 2, ['id' => $feedback->id]);
}
// And the third.
$sql = "
@@ -1014,7 +1014,7 @@ function xmldb_coursework_upgrade($oldversion) {
";
$feedbacks = $DB->get_records_sql($sql);
foreach ($feedbacks as $feedback) {
- $DB->set_field('coursework_feedbacks', 'markernumber', 3, array('id' => $feedback->id));
+ $DB->set_field('coursework_feedbacks', 'markernumber', 3, ['id' => $feedback->id]);
}
// Just in case we have others floating around...
@@ -1034,7 +1034,7 @@ function xmldb_coursework_upgrade($oldversion) {
";
$feedbacks = $DB->get_records_sql($sql);
foreach ($feedbacks as $feedback) {
- $DB->set_field('coursework_feedbacks', 'markernumber', 4, array('id' => $feedback->id));
+ $DB->set_field('coursework_feedbacks', 'markernumber', 4, ['id' => $feedback->id]);
}
// Coursework savepoint reached.
@@ -1154,7 +1154,7 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('studentid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
// Adding keys to table coursework_mod_set_members.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for coursework_mod_set_members.
if (!$dbman->table_exists($table)) {
@@ -1186,19 +1186,19 @@ function xmldb_coursework_upgrade($oldversion) {
$courseworks = $DB->get_records('coursework', null, '', 'id');
foreach ($courseworks as $coursework) {
$coursework = \mod_coursework\models\coursework::find($coursework->id);
- $students_with_assessor_allocations = $DB->get_records_sql('
+ $studentswithassessorallocations = $DB->get_records_sql('
SELECT DISTINCT studentid
FROM {coursework_allocation_pairs} ap
WHERE ap.courseworkid = :courseworkid
AND ap.moderator = 0
- ', array('courseworkid' => $coursework->id));
- foreach ($students_with_assessor_allocations as $student) {
- $params = array(
+ ', ['courseworkid' => $coursework->id]);
+ foreach ($studentswithassessorallocations as $student) {
+ $params = [
'studentid' => $student->studentid,
'courseworkid' => $coursework->id,
'moderator' => 0,
- );
+ ];
$allocations = $DB->get_records('coursework_allocation_pairs', $params);
$number = 1;
foreach ($allocations as $allocation) {
@@ -1266,7 +1266,7 @@ function xmldb_coursework_upgrade($oldversion) {
foreach ($courseworks as $coursework) {
$coursework = \mod_coursework\models\coursework::find($coursework->id);
- $submissions_with_feedbacks = $DB->get_records_sql('
+ $submissionswithfeedbacks = $DB->get_records_sql('
SELECT DISTINCT s.id
FROM {coursework_feedbacks} f
INNER JOIN {coursework_submissions} s
@@ -1274,14 +1274,14 @@ function xmldb_coursework_upgrade($oldversion) {
WHERE s.courseworkid = :courseworkid
AND f.isfinalgrade = 0
AND f.ismoderation = 0
- ', array('courseworkid' => $coursework->id));
+ ', ['courseworkid' => $coursework->id]);
- foreach ($submissions_with_feedbacks as $submission) {
- $params = array(
+ foreach ($submissionswithfeedbacks as $submission) {
+ $params = [
'submissionid' => $submission->id,
'isfinalgrade' => 0,
'ismoderation' => 0,
- );
+ ];
$feedbacks = $DB->get_records('coursework_feedbacks', $params);
$number = 1;
foreach ($feedbacks as $feedback) {
@@ -1451,14 +1451,14 @@ function xmldb_coursework_upgrade($oldversion) {
// Set group submission allocatables
- $courseworks_with_groups = $DB->get_records('coursework', array('use_groups' => 1));
+ $courseworkswithgroups = $DB->get_records('coursework', ['use_groups' => 1]);
- foreach ($courseworks_with_groups as $coursework) {
+ foreach ($courseworkswithgroups as $coursework) {
$coursework = \mod_coursework\models\coursework::find($coursework);
- $params = array(
+ $params = [
'courseworkid' => $coursework->id,
- );
+ ];
$submissions = $DB->get_records('coursework_submissions', $params);
foreach ($submissions as $submission) {
$group = $coursework->get_student_group($submission->userid);
@@ -1725,7 +1725,7 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('extended_deadline', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
// Adding keys to table coursework_extensions.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for coursework_extensions.
if (!$dbman->table_exists($table)) {
@@ -1969,7 +1969,7 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('stage_identifier', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
// Adding keys to table coursework_moderation_set_ru.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for coursework_moderation_set_ru.
if (!$dbman->table_exists($table)) {
@@ -1985,13 +1985,13 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('pluginorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
// Adding keys to table coursework_moderation_set_ru.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
// Now create plugin records for sample set plugins
- $plugins = array('range_sample_type', 'total_sample_type');
+ $plugins = ['range_sample_type', 'total_sample_type'];
$i = 1;
@@ -2025,7 +2025,7 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('selectiontype', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, 'manual');
// Adding keys to table coursework_sample_set_mbrs.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for coursework_sample_set_mbrs.
if (!$dbman->table_exists($table)) {
@@ -2037,11 +2037,11 @@ function xmldb_coursework_upgrade($oldversion) {
}
- $allocatabletables = array('coursework_submissions',
+ $allocatabletables = ['coursework_submissions',
'coursework_allocation_pairs',
'coursework_mod_set_members',
'coursework_extensions',
- 'coursework_sample_set_mbrs');
+ 'coursework_sample_set_mbrs'];
if ($oldversion < 2015110303) {
$fields = [];
@@ -2218,7 +2218,7 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('lastmodifiedbyid', XMLDB_TYPE_INTEGER, '10', null, false, null, null);
// Adding keys to table coursework_person_deadlines.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for coursework_person_deadlines.
if (!$dbman->table_exists($table)) {
@@ -2266,7 +2266,7 @@ function xmldb_coursework_upgrade($oldversion) {
// update default value of automaticagreementstrategy field from NULL to none
- $allcourseworks = $DB->get_records('coursework', array('automaticagreementstrategy' => 'NULL')); // get all courseworks with automaticagreementstrategy set to NULL
+ $allcourseworks = $DB->get_records('coursework', ['automaticagreementstrategy' => 'NULL']); // get all courseworks with automaticagreementstrategy set to NULL
foreach ($allcourseworks as $coursework) {
$coursework->automaticagreementstrategy = 'none';
$DB->update_record('coursework', $coursework);
@@ -2308,7 +2308,7 @@ function xmldb_coursework_upgrade($oldversion) {
$dbman->change_field_default($table, $field);
// again update default value of automaticagreementstrategy field from NULL to none
- $allcourseworks = $DB->get_records('coursework', array('automaticagreementstrategy' => 'NULL')); // get all courseworks with automaticagreementstrategy set to NULL
+ $allcourseworks = $DB->get_records('coursework', ['automaticagreementstrategy' => 'NULL']); // get all courseworks with automaticagreementstrategy set to NULL
foreach ($allcourseworks as $coursework) {
$coursework->automaticagreementstrategy = 'none';
$DB->update_record('coursework', $coursework);
@@ -2347,7 +2347,7 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('modcomment', XMLDB_TYPE_TEXT, null, null, null, null, null);
$table->add_field('modcommentformat', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1');
// Adding keys to table coursework_person_deadlines.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for coursework_person_deadlines.
if (!$dbman->table_exists($table)) {
@@ -2458,14 +2458,14 @@ function xmldb_coursework_upgrade($oldversion) {
$table->add_field('submissionid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null);
$table->add_field('status', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
$table->add_field('comment', XMLDB_TYPE_TEXT, null, null, null, null, null);
- $table->add_field('comment_format',XMLDB_TYPE_INTEGER, '2', null, null, null, null);
+ $table->add_field('comment_format', XMLDB_TYPE_INTEGER, '2', null, null, null, null);
$table->add_field('createdby', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('lastmodifiedby', XMLDB_TYPE_INTEGER, '10', null, false, null, null);
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
// Adding keys to table coursework_plagiarism_flag.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for coursework_plagiarism_flag.
if (!$dbman->table_exists($table)) {
@@ -2481,7 +2481,7 @@ function xmldb_coursework_upgrade($oldversion) {
// Define table coursework_plagiarism_flag to be created.
$table = new xmldb_table('coursework');
- $field = $table->add_field('renamefiles',XMLDB_TYPE_INTEGER, '1', null, null, null, null);
+ $field = $table->add_field('renamefiles', XMLDB_TYPE_INTEGER, '1', null, null, null, null);
// Conditionally launch add field.
if (!$dbman->field_exists($table, $field)) {
@@ -2491,12 +2491,12 @@ function xmldb_coursework_upgrade($oldversion) {
$courseworkinstances = $DB->get_records('coursework');
foreach ($courseworkinstances as $cwk) {
- $courseworkhassubmissions = $DB->record_exists('coursework_submissions', array('courseworkid' => $cwk->id));
+ $courseworkhassubmissions = $DB->record_exists('coursework_submissions', ['courseworkid' => $cwk->id]);
$cwk->renamefiles = ($cwk->blindmarking == 1 || $courseworkhassubmissions) ? 1 : 0;
$DB->update_record('coursework', $cwk);
- }
+ }
// Coursework savepoint reached.
upgrade_mod_savepoint(true, 2019121403, 'coursework');
diff --git a/index.php b/index.php
index ba70f2a5..151840a8 100644
--- a/index.php
+++ b/index.php
@@ -29,27 +29,18 @@
$id = required_param('id', PARAM_INT); // course
-if (! $course = $DB->get_record('course', array('id' => $id))) {
+if (! $course = $DB->get_record('course', ['id' => $id])) {
error('Course ID is incorrect');
}
require_course_login($course);
-if ((float)substr($CFG->release, 0, 5) > 2.6) { // 2.8 > 2.6
- $event = \mod_coursework\event\course_module_instance_list_viewed::create(array('context' => context_course::instance($course->id)));
- $event->trigger();
-} else {
- add_to_log($course->id,
- 'coursework',
- 'view',
- "view.php?id=$course_module->id",
- $coursework->name,
- $course_module->id);
-}
+$event = \mod_coursework\event\course_module_instance_list_viewed::create(['context' => context_course::instance($course->id)]);
+$event->trigger();
// Print the header.
-$PAGE->set_url('/mod/coursework/view.php', array('id' => $id));
+$PAGE->set_url('/mod/coursework/view.php', ['id' => $id]);
$PAGE->set_title($course->fullname);
$PAGE->set_heading($course->shortname);
$PAGE->set_pagelayout('incourse');
@@ -65,6 +56,6 @@
}
echo $OUTPUT->heading(get_string('modulenameplural', 'coursework'), 2);
-$page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
-echo $page_renderer->view_course_index($course->id);
+$pagerenderer = $PAGE->get_renderer('mod_coursework', 'page');
+echo $pagerenderer->view_course_index($course->id);
echo $OUTPUT->footer();
diff --git a/lib.php b/lib.php
index 8784f020..7a2bd109 100644
--- a/lib.php
+++ b/lib.php
@@ -80,7 +80,7 @@ function mod_coursework_pluginfile($course, $cm, $context, $filearea, $args, $fo
require_login($course, false, $cm);
- if (!$coursework = $DB->get_record('coursework', array('id' => $cm->instance))) {
+ if (!$coursework = $DB->get_record('coursework', ['id' => $cm->instance])) {
return false;
}
@@ -185,7 +185,7 @@ function coursework_add_instance($formdata) {
// IMPORTANT: at this point, the coursemodule will be in existence, but will
// Not have the coursework id saved, because we only just made it.
- $coursemodule = $DB->get_record('course_modules', array('id' => $formdata->coursemodule));
+ $coursemodule = $DB->get_record('course_modules', ['id' => $formdata->coursemodule]);
$coursemodule->instance = $returnid;
// This is doing what will be done later by the core routines. Makes it simpler to use existing
// Code without special cases.
@@ -232,7 +232,7 @@ function mod_coursework_core_calendar_is_event_visible(calendar_event $event) {
$cm = get_fast_modinfo($event->courseid)->instances['coursework'][$event->instance];
- $dbcoursework = $DB->get_record('coursework', array('id' => $cm->instance));
+ $dbcoursework = $DB->get_record('coursework', ['id' => $cm->instance]);
$coursework = coursework::find($dbcoursework);
$user = user::find($USER->id);
@@ -262,11 +262,11 @@ function mod_coursework_core_calendar_provide_event_action(calendar_event $event
global $DB, $USER;
$cm = get_fast_modinfo($event->courseid)->instances['coursework'][$event->instance];
- $submission_url = new \moodle_url('/mod/coursework/view.php', array('id' => $cm->id));
+ $submissionurl = new \moodle_url('/mod/coursework/view.php', ['id' => $cm->id]);
$name = '';
$itemcount = 0;
- $dbcoursework = $DB->get_record('coursework', array('id' => $cm->instance));
+ $dbcoursework = $DB->get_record('coursework', ['id' => $cm->instance]);
$coursework = coursework::find($dbcoursework);
$user = user::find($USER->id);
@@ -276,38 +276,38 @@ function mod_coursework_core_calendar_provide_event_action(calendar_event $event
if ($marker) { // For markers
// Check how many submissions to mark
- $outstandingmarking = new outstanding_marking();
+ $outstandingmarking = new outstanding_marking();
- if ($event->eventtype == 'initialgradingdue') {
- // Initial grades
- $togradeinitialcount = $outstandingmarking->get_to_grade_initial_count($dbcoursework, $user->id());
- $name = ($coursework->has_multiple_markers()) ? get_string('initialgrade', 'coursework') : get_string('grade', 'mod_coursework');
- $itemcount = $togradeinitialcount;
+ if ($event->eventtype == 'initialgradingdue') {
+ // Initial grades
+ $togradeinitialcount = $outstandingmarking->get_to_grade_initial_count($dbcoursework, $user->id());
+ $name = ($coursework->has_multiple_markers()) ? get_string('initialgrade', 'coursework') : get_string('grade', 'mod_coursework');
+ $itemcount = $togradeinitialcount;
- } else if ($event->eventtype == 'agreedgradingdue') {
- // Agreed grades
- $togradeagreedcount = $outstandingmarking->get_to_grade_agreed_count($dbcoursework, $user->id());
- $name = get_string('agreedgrade', 'coursework');
- $itemcount = $togradeagreedcount;
+ } else if ($event->eventtype == 'agreedgradingdue') {
+ // Agreed grades
+ $togradeagreedcount = $outstandingmarking->get_to_grade_agreed_count($dbcoursework, $user->id());
+ $name = get_string('agreedgrade', 'coursework');
+ $itemcount = $togradeagreedcount;
- }
+ }
- $submission_url = new \moodle_url('/mod/coursework/view.php', array('id' => $cm->id));
+ $submissionurl = new \moodle_url('/mod/coursework/view.php', ['id' => $cm->id]);
} else if ($student) { // for students
// if group cw check if student is in group, if not then don't display 'Add submission' link
if ($coursework->is_configured_to_have_group_submissions() && !$coursework->get_student_group($user)) {
// return null;
- $submission_url = new \moodle_url('/mod/coursework/view.php', array('id' => $cm->id));
+ $submissionurl = new \moodle_url('/mod/coursework/view.php', ['id' => $cm->id]);
$itemcount = 1;
} else {
$submission = $coursework->get_user_submission($user);
- $new_submission = $coursework->build_own_submission($user);
+ $newsubmission = $coursework->build_own_submission($user);
if (!$submission) {
- $submission = $new_submission;
+ $submission = $newsubmission;
}
// Check if user can still submit
$ability = new ability($user, $coursework);
@@ -317,9 +317,9 @@ function mod_coursework_core_calendar_provide_event_action(calendar_event $event
$allocatableid = $submission->get_allocatable()->id();
$allocatabletype = $submission->get_allocatable()->type();
- $submission_url = new \moodle_url('/mod/coursework/actions/submissions/new.php', array('allocatableid' => $allocatableid,
+ $submissionurl = new \moodle_url('/mod/coursework/actions/submissions/new.php', ['allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
- 'courseworkid' => $coursework->id));
+ 'courseworkid' => $coursework->id]);
} else {
return null;
@@ -328,7 +328,7 @@ function mod_coursework_core_calendar_provide_event_action(calendar_event $event
}
return $factory->create_instance($name,
- $submission_url,
+ $submissionurl,
$itemcount,
true);
}
@@ -348,7 +348,7 @@ function mod_coursework_core_calendar_event_action_shows_item_count(calendar_eve
$agreedgradingdueeventtype = ['agreedgradingdue'];
$cm = get_fast_modinfo($event->courseid)->instances['coursework'][$event->instance];
- $dbcoursework = $DB->get_record('coursework', array('id' => $cm->instance));
+ $dbcoursework = $DB->get_record('coursework', ['id' => $cm->instance]);
$coursework = coursework::find($dbcoursework);
$student = $coursework->can_submit();
@@ -367,10 +367,10 @@ function coursework_grade_item_update($coursework, $grades = null) {
require_once($CFG->dirroot.'/lib/gradelib.php');
- $course_id = $coursework->get_course_id();
+ $courseid = $coursework->get_course_id();
- $params = array('itemname' => $coursework->name,
- 'idnumber' => $coursework->get_coursemodule_idnumber());
+ $params = ['itemname' => $coursework->name,
+ 'idnumber' => $coursework->get_coursemodule_idnumber()];
if ($coursework->grade > 0) {
$params['gradetype'] = GRADE_TYPE_VALUE;
@@ -390,7 +390,7 @@ function coursework_grade_item_update($coursework, $grades = null) {
$grades = null;
}
- return grade_update('mod/coursework', $course_id, 'mod', 'coursework', $coursework->id, 0,
+ return grade_update('mod/coursework', $courseid, 'mod', 'coursework', $coursework->id, 0,
$grades, $params);
}
@@ -405,7 +405,7 @@ function coursework_grade_item_delete(coursework $coursework) {
require_once($CFG->dirroot.'/lib/gradelib.php');
return grade_update('mod/coursework', $coursework->get_course_id(), 'mod', 'coursework',
- $coursework->id, 0, null, array('deleted' => 1));
+ $coursework->id, 0, null, ['deleted' => 1]);
}
/**
@@ -439,12 +439,12 @@ function coursework_update_instance($coursework) {
$coursework->submissionnotification = $subnotify;
- $courseworkhassubmissions = $DB->record_exists('coursework_submissions', array('courseworkid' => $coursework->id));
+ $courseworkhassubmissions = $DB->record_exists('coursework_submissions', ['courseworkid' => $coursework->id]);
// If the coursework has submissions then we the renamefiles setting can't be changes
if ($courseworkhassubmissions) {
- $currentcoursework = $DB->get_record('coursework', array('id' => $coursework->id));
+ $currentcoursework = $DB->get_record('coursework', ['id' => $coursework->id]);
$coursework->renamefiles = $currentcoursework->renamefiles;
@@ -454,9 +454,9 @@ function coursework_update_instance($coursework) {
}
- $oldsubmissiondeadline = $DB->get_field('coursework', 'deadline', array('id' => $coursework->id));
- $oldgeneraldeadline = $DB->get_field('coursework', 'generalfeedback', array('id' => $coursework->id));
- $oldindividualdeadline = $DB->get_field('coursework', 'individualfeedback', array('id' => $coursework->id));
+ $oldsubmissiondeadline = $DB->get_field('coursework', 'deadline', ['id' => $coursework->id]);
+ $oldgeneraldeadline = $DB->get_field('coursework', 'generalfeedback', ['id' => $coursework->id]);
+ $oldindividualdeadline = $DB->get_field('coursework', 'individualfeedback', ['id' => $coursework->id]);
if ($oldsubmissiondeadline != $coursework->deadline ||
$oldgeneraldeadline != $coursework->generalfeedback ||
@@ -466,11 +466,11 @@ function coursework_update_instance($coursework) {
$courseworkobj = coursework::find($coursework->id);
- $params = array(
+ $params = [
'context' => context_module::instance($courseworkobj->get_course_module()->id),
'courseid' => $courseworkobj->get_course()->id,
'objectid' => $coursework->id,
- 'other' => array(
+ 'other' => [
'courseworkid' => $coursework->id,
'oldsubmissiondeadline' => $oldsubmissiondeadline,
'newsubmissionsdeadline' => $coursework->deadline,
@@ -479,8 +479,8 @@ function coursework_update_instance($coursework) {
'oldindividualdeadline' => $oldindividualdeadline,
'newindividualdeadline' => $coursework->individualfeedback,
'userfrom' => $USER->id,
- )
- );
+ ],
+ ];
$event = \mod_coursework\event\coursework_deadline_changed::create($params);
$event->trigger();
@@ -517,45 +517,45 @@ function coursework_update_instance($coursework) {
*
* @param $coursework
*/
- function coursework_update_events($coursework, $eventtype) {
- global $DB;
-
- $event = "";
- $eventid = $DB->get_record('event', array('modulename' => 'coursework', 'instance' => $coursework->id, 'eventtype' => $eventtype));
-
- if ($eventid) {
- $event = calendar_event::load($eventid->id);
- }
-
- // Update/create event for coursework deadline [due]
- if ($eventtype == 'due') {
- $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->deadline);
- if ($event) {
- $event->update($data); //update if event exists
- } else {
- calendar_event::create($data); // Create new event as it doesn't exist
- }
- }
-
- // Update/create event for coursework initialmarking deadline [initialgradingdue]
- if ($eventtype == 'initialgradingdue') {
- $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->initialmarkingdeadline);
- if ($event) {
- $event->update($data); //update if event exists
- } else {
- calendar_event::create($data); // Create new event as it doesn't exist
- }
- }
-
- // Update/create event for coursework agreedgrademarking deadline [agreedgradingdue]
- if ($eventtype == 'agreedgradingdue') {
- $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->agreedgrademarkingdeadline);
- if ($event) {
- $event->update($data); //update if event exists
- } else {
- calendar_event::create($data); // Create new event as it doesn't exist
- }
- }
+function coursework_update_events($coursework, $eventtype) {
+ global $DB;
+
+ $event = "";
+ $eventid = $DB->get_record('event', ['modulename' => 'coursework', 'instance' => $coursework->id, 'eventtype' => $eventtype]);
+
+ if ($eventid) {
+ $event = calendar_event::load($eventid->id);
+ }
+
+ // Update/create event for coursework deadline [due]
+ if ($eventtype == 'due') {
+ $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->deadline);
+ if ($event) {
+ $event->update($data); //update if event exists
+ } else {
+ calendar_event::create($data); // Create new event as it doesn't exist
+ }
+ }
+
+ // Update/create event for coursework initialmarking deadline [initialgradingdue]
+ if ($eventtype == 'initialgradingdue') {
+ $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->initialmarkingdeadline);
+ if ($event) {
+ $event->update($data); //update if event exists
+ } else {
+ calendar_event::create($data); // Create new event as it doesn't exist
+ }
+ }
+
+ // Update/create event for coursework agreedgrademarking deadline [agreedgradingdue]
+ if ($eventtype == 'agreedgradingdue') {
+ $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->agreedgrademarkingdeadline);
+ if ($event) {
+ $event->update($data); //update if event exists
+ } else {
+ calendar_event::create($data); // Create new event as it doesn't exist
+ }
+ }
}
/**
@@ -569,7 +569,7 @@ function coursework_update_events($coursework, $eventtype) {
function coursework_delete_instance($id) {
global $DB;
- if (!$coursework = $DB->get_record('coursework', array('id' => $id))) {
+ if (!$coursework = $DB->get_record('coursework', ['id' => $id])) {
return false;
}
@@ -579,7 +579,7 @@ function coursework_delete_instance($id) {
// TODO delete allocations.
// TODO delete submissions.
- $DB->delete_records('coursework', array('id' => $coursework->id));
+ $DB->delete_records('coursework', ['id' => $coursework->id]);
return true;
}
@@ -588,14 +588,14 @@ function coursework_delete_instance($id) {
* @return array
*/
function coursework_get_view_actions() {
- return array('view');
+ return ['view'];
}
/**
* @return array
*/
function coursework_get_post_actions() {
- return array('upload');
+ return ['upload'];
}
/**
@@ -679,8 +679,8 @@ function coursework_scale_used($courseworkid, $scaleid) {
global $DB;
- $params = array('grade' => $scaleid,
- 'id' => $courseworkid);
+ $params = ['grade' => $scaleid,
+ 'id' => $courseworkid];
if ($scaleid && $DB->record_exists('coursework', $params)) {
return true;
} else {
@@ -699,7 +699,7 @@ function coursework_scale_used($courseworkid, $scaleid) {
function coursework_scale_used_anywhere($scaleid) {
global $DB;
- if ($scaleid && $DB->record_exists('coursework', array('grade' => $scaleid))) {
+ if ($scaleid && $DB->record_exists('coursework', ['grade' => $scaleid])) {
return true;
} else {
return false;
@@ -711,8 +711,8 @@ function coursework_scale_used_anywhere($scaleid) {
* @return array
*/
function coursework_get_extra_capabilities() {
- return array('moodle/site:accessallgroups',
- 'moodle/site:viewfullnames');
+ return ['moodle/site:accessallgroups',
+ 'moodle/site:viewfullnames'];
}
/**
@@ -780,11 +780,11 @@ function coursework_plagiarism_dates($cmid) {
$cm = get_coursemodule_from_id('coursework', $cmid);
$coursework = coursework::find($cm->instance);
- $dates_array = array('timeavailable' => $coursework->timecreated);
- $dates_array['timedue'] = $coursework->deadline;
- $dates_array['feedback'] = (string)$coursework->get_individual_feedback_deadline();
+ $datesarray = ['timeavailable' => $coursework->timecreated];
+ $datesarray['timedue'] = $coursework->deadline;
+ $datesarray['feedback'] = (string)$coursework->get_individual_feedback_deadline();
- return $dates_array;
+ return $datesarray;
}
/**
@@ -815,14 +815,14 @@ function coursework_extend_settings_navigation(settings_navigation $settings, na
if (has_capability('mod/coursework:allocate', $context) &&
($coursework->allocation_enabled() || $coursework->sampling_enabled())) {
- $link = new moodle_url('/mod/coursework/actions/allocate.php', array('id' => $cm->id));
- $lang_str = ($coursework->moderation_agreement_enabled()) ? 'allocateassessorsandmoderators' : 'allocateassessors';
- $navref->add(get_string($lang_str, 'mod_coursework'), $link, navigation_node::TYPE_SETTING);
+ $link = new moodle_url('/mod/coursework/actions/allocate.php', ['id' => $cm->id]);
+ $langstr = ($coursework->moderation_agreement_enabled()) ? 'allocateassessorsandmoderators' : 'allocateassessors';
+ $navref->add(get_string($langstr, 'mod_coursework'), $link, navigation_node::TYPE_SETTING);
}
// Link to personal deadlines screen
if (has_capability('mod/coursework:editpersonaldeadline', $context) && ($coursework->personal_deadlines_enabled())) {
- $link = new moodle_url('/mod/coursework/actions/set_personal_deadlines.php', array('id' => $cm->id));
+ $link = new moodle_url('/mod/coursework/actions/set_personal_deadlines.php', ['id' => $cm->id]);
$navref->add(get_string('setpersonaldeadlines', 'mod_coursework'), $link, navigation_node::TYPE_SETTING);
}
@@ -837,12 +837,12 @@ function coursework_extend_settings_navigation(settings_navigation $settings, na
function coursework_role_assigned_event_handler($roleassignment) {
global $DB;
-// return true; // Until we fix the auto allocator. The stuff below causes an infinite loop.
+ // return true; // Until we fix the auto allocator. The stuff below causes an infinite loop.
$courseworkids = coursework_get_coursework_ids_from_context_id($roleassignment->contextid);
foreach ($courseworkids as $courseworkid) {
- $DB->set_field('coursework', 'processenrol', 1, array('id' => $courseworkid));
+ $DB->set_field('coursework', 'processenrol', 1, ['id' => $courseworkid]);
}
return true;
@@ -863,7 +863,7 @@ function coursework_role_unassigned_event_handler($roleassignment) {
$courseworkids = coursework_get_coursework_ids_from_context_id($roleassignment->contextid);
foreach ($courseworkids as $courseworkid) {
- $DB->set_field('coursework', 'processunenrol', 1, array('id' => $courseworkid));
+ $DB->set_field('coursework', 'processunenrol', 1, ['id' => $courseworkid]);
}
return true;
@@ -890,7 +890,7 @@ function coursework_get_coursework_ids_from_context_id($contextid) {
case CONTEXT_MODULE:
$coursemodule = get_coursemodule_from_id('coursework', $context->instanceid);
- $courseworkmoduleid = $DB->get_field('modules', 'id', array('name' => 'coursework'));
+ $courseworkmoduleid = $DB->get_field('modules', 'id', ['name' => 'coursework']);
if ($coursemodule->module == $courseworkmoduleid) {
$courseworkids[] = $coursemodule->instance;
@@ -899,7 +899,7 @@ function coursework_get_coursework_ids_from_context_id($contextid) {
case CONTEXT_COURSE:
- $coursemodules = $DB->get_records('coursework', array('course' => $context->instanceid));
+ $coursemodules = $DB->get_records('coursework', ['course' => $context->instanceid]);
if ($coursemodules) {
$courseworkids = array_keys($coursemodules);
}
@@ -917,18 +917,18 @@ function coursework_get_coursework_ids_from_context_id($contextid) {
*/
function coursework_seconds_to_string($seconds) {
- $units = array(
- 604800 => array(get_string('week', 'mod_coursework'),
- get_string('weeks', 'mod_coursework')),
- 86400 => array(get_string('day', 'mod_coursework'),
- get_string('days', 'mod_coursework')),
- 3600 => array(get_string('hour', 'mod_coursework'),
- get_string('hours', 'mod_coursework')),
- 60 => array(get_string('minute', 'mod_coursework'),
- get_string('minutes', 'mod_coursework')),
- 1 => array(get_string('second', 'mod_coursework'),
- get_string('seconds', 'mod_coursework'))
- );
+ $units = [
+ 604800 => [get_string('week', 'mod_coursework'),
+ get_string('weeks', 'mod_coursework')],
+ 86400 => [get_string('day', 'mod_coursework'),
+ get_string('days', 'mod_coursework')],
+ 3600 => [get_string('hour', 'mod_coursework'),
+ get_string('hours', 'mod_coursework')],
+ 60 => [get_string('minute', 'mod_coursework'),
+ get_string('minutes', 'mod_coursework')],
+ 1 => [get_string('second', 'mod_coursework'),
+ get_string('seconds', 'mod_coursework')],
+ ];
$result = [];
foreach ($units as $divisor => $unitame) {
@@ -965,9 +965,9 @@ function coursework_get_current_max_feedbacks($courseworkid) {
AND feedbacks.stage_identifier LIKE 'assessor%'
GROUP BY feedbacks.submissionid) AS feedbackcounts
";
- $params = array(
- 'courseworkid' => $courseworkid
- );
+ $params = [
+ 'courseworkid' => $courseworkid,
+ ];
$max = $DB->get_field_sql($sql, $params);
if (!$max) {
@@ -992,7 +992,7 @@ function coursework_send_deadline_changed_emails($eventdata) {
// No need to send emails if none of the deadlines have changed.
- // echo 'Starting to send Coursework deadline changed emails...';
+ // echo 'Starting to send Coursework deadline changed emails...';
$counter = 0;
$coursework = coursework::find($eventdata->other['courseworkid']);
@@ -1074,7 +1074,7 @@ function coursework_send_deadline_changed_emails($eventdata) {
message_send($messagedata);
}
- // echo 'Sent '.$counter.' messages.';
+ // echo 'Sent '.$counter.' messages.';
return true;
}
@@ -1169,12 +1169,12 @@ function mod_coursework_supports($feature) {
* @param $event_data
* @return bool
*/
-function coursework_mod_updated($event_data) {
+function coursework_mod_updated($eventdata) {
global $DB;
- if ($event_data->other['modulename'] == 'coursework') {
+ if ($eventdata->other['modulename'] == 'coursework') {
- $coursework = coursework::find($event_data->other['instanceid']);
+ $coursework = coursework::find($eventdata->other['instanceid']);
/**
* @var coursework $coursework
*/
@@ -1195,34 +1195,34 @@ function coursework_mod_updated($event_data) {
* @throws dml_exception
*/
-function course_group_member_added($event_data) {
+function course_group_member_added($eventdata) {
global $DB;
- $groupid = $event_data->objectid;
- $courseid = $event_data->courseid;
- $addeduserid = $event_data->relateduserid;
+ $groupid = $eventdata->objectid;
+ $courseid = $eventdata->courseid;
+ $addeduserid = $eventdata->relateduserid;
// get all courseworks with group_assessor allocation strategy
- $courseworks = $DB->get_records('coursework', array('course' => $courseid, 'assessorallocationstrategy' => 'group_assessor'));
+ $courseworks = $DB->get_records('coursework', ['course' => $courseid, 'assessorallocationstrategy' => 'group_assessor']);
foreach ($courseworks as $coursework) {
$coursework = coursework::find($coursework);
$stage = $coursework->marking_stages();
- $stage_1 = $stage['assessor_1']; // this allocation is only for 1st stage, we don't touch other stages
+ $stage1 = $stage['assessor_1']; // this allocation is only for 1st stage, we don't touch other stages
$student = $coursework->can_submit(); // check if user is student in this course
- $initial_stage_assessor = has_capability('mod/coursework:addinitialgrade', $coursework->get_context(), $addeduserid); // check if user is initial stage assessor in this course
+ $initialstageassessor = has_capability('mod/coursework:addinitialgrade', $coursework->get_context(), $addeduserid); // check if user is initial stage assessor in this course
- if ($initial_stage_assessor) {
+ if ($initialstageassessor) {
// check if any assessor already exists in the group except currently added one
- $assessors_in_group = get_enrolled_users($coursework->get_context(), 'mod/coursework:addinitialgrade', $groupid);
- unset($assessors_in_group[$addeduserid]); // Remove added assessor as at this point they will be already in the group
+ $assessorsingroup = get_enrolled_users($coursework->get_context(), 'mod/coursework:addinitialgrade', $groupid);
+ unset($assessorsingroup[$addeduserid]); // Remove added assessor as at this point they will be already in the group
- if ($assessors_in_group) {//yes - do nothing as other assessor is already assigned to group members, return true
+ if ($assessorsingroup) {//yes - do nothing as other assessor is already assigned to group members, return true
break;
} else { // No - check if CW is a group coursework
if ($coursework->is_configured_to_have_group_submissions()) {// yes - assign the tutor to a allocatable group
- $stage_1->make_auto_allocation_if_necessary(group::find($groupid));
+ $stage1->make_auto_allocation_if_necessary(group::find($groupid));
} else { // no, check if group has any student members
$allocatables = $coursework->get_allocatables();
if ($allocatables) {
@@ -1230,7 +1230,7 @@ function course_group_member_added($event_data) {
foreach ($allocatables as $allocatable) {
// process students allocations
if ($coursework->student_is_in_any_group($allocatable)) { // student must belong to a group
- $stage_1->make_auto_allocation_if_necessary($allocatable);
+ $stage1->make_auto_allocation_if_necessary($allocatable);
}
}
} else {// no - do nothing, return true
@@ -1245,7 +1245,7 @@ function course_group_member_added($event_data) {
$allocatable = user::find($addeduserid);
}
// process allocatables (group or student) allocation
- $stage_1->make_auto_allocation_if_necessary($allocatable);
+ $stage1->make_auto_allocation_if_necessary($allocatable);
}
}
return true;
@@ -1259,66 +1259,66 @@ function course_group_member_added($event_data) {
* @throws coding_exception
* @throws dml_exception
*/
-function course_group_member_removed($event_data) {
+function course_group_member_removed($eventdata) {
global $DB;
- $groupid = $event_data->objectid;
- $courseid = $event_data->courseid;
- $removeduserid = $event_data->relateduserid;
+ $groupid = $eventdata->objectid;
+ $courseid = $eventdata->courseid;
+ $removeduserid = $eventdata->relateduserid;
// get all courseworks with group_assessor allocation strategy
- $courseworks = $DB->get_records('coursework', array('course' => $courseid, 'assessorallocationstrategy' => 'group_assessor'));
+ $courseworks = $DB->get_records('coursework', ['course' => $courseid, 'assessorallocationstrategy' => 'group_assessor']);
foreach ($courseworks as $coursework) {
$coursework = coursework::find($coursework);
$stage = $coursework->marking_stages();
- $stage_1 = $stage['assessor_1']; // this allocation is only for 1st stage, we don't touch other stages
+ $stage1 = $stage['assessor_1']; // this allocation is only for 1st stage, we don't touch other stages
$student = $coursework->can_submit(); // check if user is student in this course
- $initial_stage_assessor = has_capability('mod/coursework:addinitialgrade', $coursework->get_context(), $removeduserid); // check if user was initial stage assessor in this course
+ $initialstageassessor = has_capability('mod/coursework:addinitialgrade', $coursework->get_context(), $removeduserid); // check if user was initial stage assessor in this course
- if ($initial_stage_assessor) {
+ if ($initialstageassessor) {
// remove all assessor allocations for this group
if ($coursework->is_configured_to_have_group_submissions()) {
if (can_delete_allocation($coursework->id(), $groupid)) {
- $DB->delete_records('coursework_allocation_pairs', array('courseworkid' => $coursework->id(), 'assessorid' => $removeduserid, 'allocatableid' => $groupid, 'stage_identifier' => 'assessor_1'));
+ $DB->delete_records('coursework_allocation_pairs', ['courseworkid' => $coursework->id(), 'assessorid' => $removeduserid, 'allocatableid' => $groupid, 'stage_identifier' => 'assessor_1']);
}
} else {
// find all individual students in the group
- $students = get_enrolled_users($coursework->get_context(), 'mod/coursework:submit', $groupid);
- if ($students) {
- foreach ($students as $student) {
- if (can_delete_allocation($coursework->id(), $student->id)) {
- $DB->delete_records('coursework_allocation_pairs', array('courseworkid' => $coursework->id(), 'assessorid' => $removeduserid, 'allocatableid' => $student->id, 'stage_identifier' => 'assessor_1'));
- }
- }
- } else {
- continue;
- }
+ $students = get_enrolled_users($coursework->get_context(), 'mod/coursework:submit', $groupid);
+ if ($students) {
+ foreach ($students as $student) {
+ if (can_delete_allocation($coursework->id(), $student->id)) {
+ $DB->delete_records('coursework_allocation_pairs', ['courseworkid' => $coursework->id(), 'assessorid' => $removeduserid, 'allocatableid' => $student->id, 'stage_identifier' => 'assessor_1']);
+ }
+ }
+ } else {
+ continue;
+ }
}
// check if there are any other assessor in the group, at this point the removed member should no longer be in the group
- $assessors_in_group = get_enrolled_users($coursework->get_context(), 'mod/coursework:addinitialgrade', $groupid);
-
- if ($assessors_in_group) { // if another assessor found, assign all allocatables in this group to the other assessor
- if ($coursework->is_configured_to_have_group_submissions()) {// yes - assign the assessor to a allocatable group
- $stage_1->make_auto_allocation_if_necessary(group::find($groupid));
- } else {
- $allocatables = $coursework->get_allocatables();
- if ($allocatables) {
- // yes - assign this assessor to every allocatable student in the appropriate course group
- foreach ($allocatables as $allocatable) {
- // process students allocations
- $stage_1->make_auto_allocation_if_necessary($allocatable);
- }
- } else {// no - do nothing, return true
- continue;
- }
- }
- } else {
- continue;
- }
+ $assessorsingroup = get_enrolled_users($coursework->get_context(), 'mod/coursework:addinitialgrade', $groupid);
+
+ if ($assessorsingroup) { // if another assessor found, assign all allocatables in this group to the other assessor
+ if ($coursework->is_configured_to_have_group_submissions()) {// yes - assign the assessor to a allocatable group
+ $stage1->make_auto_allocation_if_necessary(group::find($groupid));
+ } else {
+ $allocatables = $coursework->get_allocatables();
+ if ($allocatables) {
+ // yes - assign this assessor to every allocatable student in the appropriate course group
+ foreach ($allocatables as $allocatable) {
+ // process students allocations
+ $stage1->make_auto_allocation_if_necessary($allocatable);
+ }
+ } else {// no - do nothing, return true
+ continue;
+ }
+ }
+ } else {
+ continue;
+ }
} else if ($student) {
if ($coursework->is_configured_to_have_group_submissions()) {
// check if student was the only student member in the group
@@ -1336,14 +1336,14 @@ function course_group_member_removed($event_data) {
}
if (can_delete_allocation($coursework->id(), $allocatableid)) {
- $DB->delete_records('coursework_allocation_pairs', array('courseworkid' => $coursework->id(), 'allocatableid' => $allocatableid, 'stage_identifier' => 'assessor_1'));
+ $DB->delete_records('coursework_allocation_pairs', ['courseworkid' => $coursework->id(), 'allocatableid' => $allocatableid, 'stage_identifier' => 'assessor_1']);
}
// check if the student was in a different group and allocate them to the first found group
if (!$coursework->is_configured_to_have_group_submissions()) {
$allocatable = user::find($allocatableid);
if ($coursework->student_is_in_any_group($allocatable)) {
- $stage_1->make_auto_allocation_if_necessary($allocatable);
+ $stage1->make_auto_allocation_if_necessary($allocatable);
}
}
}
@@ -1363,7 +1363,7 @@ function can_delete_allocation($courseworkid, $allocatableid) {
global $DB;
// check if allocation is pinned or already graded by an assessor / 1st stage only!
- $ungraded_allocations = $DB->get_record_sql("SELECT *
+ $ungradedallocations = $DB->get_record_sql("SELECT *
FROM {coursework_allocation_pairs} p
WHERE courseworkid = :courseworkid
AND p.manual = 0
@@ -1376,20 +1376,20 @@ function can_delete_allocation($courseworkid, $allocatableid) {
AND s.allocatabletype = p.allocatabletype
AND s.courseworkid = p.courseworkid
AND f.stage_identifier = p.stage_identifier)",
- array('courseworkid' => $courseworkid, 'allocatableid' => $allocatableid));
+ ['courseworkid' => $courseworkid, 'allocatableid' => $allocatableid]);
- return $ungraded_allocations;
+ return $ungradedallocations;
}
/**
* @param $course_module_id
* @return string
*/
- function plagiarism_similarity_information($course_module) {
+function plagiarism_similarity_information($coursemodule) {
$html = '';
ob_start();
- echo plagiarism_print_disclosure($course_module->id);
+ echo plagiarism_print_disclosure($coursemodule->id);
$html .= ob_get_clean();
return $html;
@@ -1402,7 +1402,7 @@ function has_user_seen_tii_EULA_agreement() {
global $CFG, $DB, $USER;
// if TII plagiarism enabled check if user agreed/disagreed EULA
- $shouldseeEULA = false;
+ $shouldseeeula = false;
if ($CFG->enableplagiarism) {
$plagiarismsettings = (array)get_config('plagiarism_turnitin');
if (!empty($plagiarismsettings['enabled'])) {
@@ -1417,12 +1417,12 @@ function has_user_seen_tii_EULA_agreement() {
AND user_agreement_accepted <> 0";
}
- $shouldseeEULA = $DB->record_exists_sql($sql, array('userid' => $USER->id));
+ $shouldseeeula = $DB->record_exists_sql($sql, ['userid' => $USER->id]);
}
} else {
- $shouldseeEULA = true;
+ $shouldseeeula = true;
}
- return $shouldseeEULA;
+ return $shouldseeeula;
}
function coursework_is_ulcc_digest_coursework_plugin_installed() {
@@ -1433,7 +1433,7 @@ function coursework_is_ulcc_digest_coursework_plugin_installed() {
$disgestblockexists = $DB->record_exists_sql("SELECT id FROM {block} WHERE name = 'ulcc_digest' AND visible = 1");
if (!empty($disgestblockexists)) {
- $pluginexists = $DB->record_exists('block_ulcc_digest_plgs', array('module' => 'coursework', 'status' => 1));
+ $pluginexists = $DB->record_exists('block_ulcc_digest_plgs', ['module' => 'coursework', 'status' => 1]);
}
return $pluginexists;
@@ -1451,7 +1451,7 @@ function coursework_personal_deadline_passed($courseworkid) {
WHERE courseworkid = :courseworkid
AND personal_deadline < :now";
- return $DB->record_exists_sql($sql, array('courseworkid' => $courseworkid, 'now' => time()));
+ return $DB->record_exists_sql($sql, ['courseworkid' => $courseworkid, 'now' => time()]);
}
@@ -1461,10 +1461,10 @@ function coursework_personal_deadline_passed($courseworkid) {
* @param $event_data
* @return bool
*/
-function teacher_allocation_cache_purge($event_data) {
+function teacher_allocation_cache_purge($eventdata) {
global $DB;
- $roleid = $event_data->objectid;
+ $roleid = $eventdata->objectid;
// get roles with a specific capability
$roles = get_roles_with_capability('mod/coursework:addinitialgrade');
@@ -1483,19 +1483,19 @@ function teacher_allocation_cache_purge($event_data) {
* @return bool
* @throws dml_exception
*/
-function teacher_removed_allocated_not_graded($event_data) {
+function teacher_removed_allocated_not_graded($eventdata) {
global $DB;
- $userid = $event_data->relateduserid;
- $courseid = $event_data->courseid;
+ $userid = $eventdata->relateduserid;
+ $courseid = $eventdata->courseid;
$courseworks = coursework_get_courseworks_by_courseid($courseid);
foreach ($courseworks as $cw) {
$coursework = coursework::find($cw->id);
if ($coursework->allocation_enabled()) {
- $assessor_allocations = $DB->get_records('coursework_allocation_pairs', array('courseworkid' => $coursework->id,
- 'assessorid' => $userid));
- foreach ($assessor_allocations as $allocation) {
+ $assessorallocations = $DB->get_records('coursework_allocation_pairs', ['courseworkid' => $coursework->id,
+ 'assessorid' => $userid]);
+ foreach ($assessorallocations as $allocation) {
if ($allocation->allocatabletype == 'user') {
$allocatable = user::find($allocation->allocatableid);
} else {
@@ -1508,9 +1508,9 @@ function teacher_removed_allocated_not_graded($event_data) {
continue;
}
- $DB->delete_records('coursework_allocation_pairs', array('courseworkid' => $coursework->id,
+ $DB->delete_records('coursework_allocation_pairs', ['courseworkid' => $coursework->id,
'assessorid' => $userid,
- 'allocatableid' => $allocatable->id));
+ 'allocatableid' => $allocatable->id]);
}
}
}
@@ -1528,6 +1528,6 @@ function teacher_removed_allocated_not_graded($event_data) {
function coursework_get_courseworks_by_courseid($courseid) {
global $DB;
- return $DB->get_records('coursework', array('course' => $courseid));
+ return $DB->get_records('coursework', ['course' => $courseid]);
}
diff --git a/mod_form.php b/mod_form.php
index 19201e1e..0accae25 100644
--- a/mod_form.php
+++ b/mod_form.php
@@ -46,13 +46,13 @@ public function definition() {
$PAGE->requires->jquery();
- $module = array(
+ $module = [
'name' => 'mod_coursework',
'fullpath' => '/mod/coursework/mod_form.js',
- 'requires' => array(
+ 'requires' => [
'node',
- 'ajax'
- ));
+ 'ajax',
+ ]];
$PAGE->requires->js_init_call('M.mod_coursework.init', [], true, $module);
@@ -69,13 +69,13 @@ public function definition() {
$this->add_submission_deadline_field();
$this->add_personal_deadline_field();
- // if (coursework_is_ulcc_digest_coursework_plugin_installed()) {
+ // if (coursework_is_ulcc_digest_coursework_plugin_installed()) {
$this->add_marking_deadline_field();
$this->add_initial_marking_deadline_field();
$this->add_agreed_grade_marking_deadline_field();
$this->add_relative_initial_marking_deadline_field();
$this->add_relative_agreed_grade_marking_deadline_field();
- // }
+ // }
$this->add_allow_early_finalisation_field();
$this->add_allow_late_submissions_field();
@@ -150,8 +150,8 @@ public function definition() {
* @param $default_values
* @return void
*/
- public function set_data($default_values) {
- $default_values = (array)$default_values;
+ public function set_data($defaultvalues) {
+ $defaultvalues = (array)$defaultvalues;
foreach ($this->_form->_elements as $element) {
@@ -169,13 +169,13 @@ public function set_data($default_values) {
if (isset($element->_attributes['name']) && substr($element->_attributes['name'], -6) == 'static') {
// TODO this is using private attributes directly. Need to switch to proper
// Getters and setters.
- if (isset($default_values[substr($element->_attributes['name'], 0, -6)])) {
- $default = $default_values[substr($element->_attributes['name'], 0, -6)];
- $default_values[$element->_attributes['name']] = $default;
+ if (isset($defaultvalues[substr($element->_attributes['name'], 0, -6)])) {
+ $default = $defaultvalues[substr($element->_attributes['name'], 0, -6)];
+ $defaultvalues[$element->_attributes['name']] = $default;
}
}
}
- parent::set_data($default_values);
+ parent::set_data($defaultvalues);
}
/**
@@ -191,11 +191,11 @@ public function validation($data, $files) {
$errors = [];
- if ($data['startdate'] != 0 && !empty($data['deadline']) && $data['startdate'] > $data['deadline']) {
- $errors['startdate'] = get_string('must_be_before_dealdine', 'mod_coursework');
- }
+ if ($data['startdate'] != 0 && !empty($data['deadline']) && $data['startdate'] > $data['deadline']) {
+ $errors['startdate'] = get_string('must_be_before_dealdine', 'mod_coursework');
+ }
- if ($data['individualfeedback'] != 0 && !empty($data['deadline']) && $data['individualfeedback'] < $data['deadline']) {
+ if ($data['individualfeedback'] != 0 && !empty($data['deadline']) && $data['individualfeedback'] < $data['deadline']) {
$errors['individualfeedback'] = get_string('must_be_after_dealdine', 'mod_coursework');
}
@@ -227,7 +227,7 @@ public function validation($data, $files) {
$errors['agreedgrademarkingdeadline'] = get_string('must_be_after_initial_grade_dealdine', 'mod_coursework');
}
- if (isset($data['relativeagreedmarkingdeadline']) && $data['relativeagreedmarkingdeadline'] != 0 && $data['relativeagreedmarkingdeadline'] < $data['relativeinitialmarkingdeadline'] ) {
+ if (isset($data['relativeagreedmarkingdeadline']) && $data['relativeagreedmarkingdeadline'] != 0 && $data['relativeagreedmarkingdeadline'] < $data['relativeinitialmarkingdeadline'] ) {
$errors['relativeagreedmarkingdeadline'] = get_string('must_be_after_or_equal_to_relative_initial_grade_dealdine', 'mod_coursework');
}
@@ -244,8 +244,8 @@ public function validation($data, $files) {
$errors['numberofmarkers'] = get_string('not_enough_assessors_for_sampling', 'mod_coursework');
}
- $parent_errors = parent::validation($data, $files);
- return array_merge($errors, $parent_errors);
+ $parenterrors = parent::validation($data, $files);
+ return array_merge($errors, $parenterrors);
}
@@ -262,7 +262,7 @@ function get_data() {
}
if ($this->forceblindmarking() == 1) {
- $data->blindmarking = $CFG->coursework_blindmarking;
+ $data->blindmarking = $CFG->coursework_blindmarking;
}
if ($data->numberofmarkers > 1) {
@@ -276,41 +276,41 @@ function get_data() {
* @throws coding_exception
*/
protected function add_submissions_header() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('header', 'submissions', get_string('submissions', 'mod_coursework'));
+ $moodleform->addElement('header', 'submissions', get_string('submissions', 'mod_coursework'));
// We want it expanded by default
- $moodle_form->setExpanded('submissions');
+ $moodleform->setExpanded('submissions');
}
/**
* @throws coding_exception
*/
protected function add_availability_header() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('header', 'availability', get_string('availability', 'mod_coursework'));
+ $moodleform->addElement('header', 'availability', get_string('availability', 'mod_coursework'));
// We want it expanded by default
- $moodle_form->setExpanded('availability');
+ $moodleform->setExpanded('availability');
}
/**
* @throws coding_exception
*/
protected function add_name_field() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('text',
+ $moodleform->addElement('text',
'name',
get_string('courseworkname', 'coursework'),
- array('size' => '64'));
- $moodle_form->addRule('name', null, 'required', null, 'client');
- $moodle_form->addRule('name',
+ ['size' => '64']);
+ $moodleform->addRule('name', null, 'required', null, 'client');
+ $moodleform->addRule('name',
get_string('maximumchars', '', 255),
'maxlength',
255,
'client');
- $moodle_form->setType('name', PARAM_TEXT);
+ $moodleform->setType('name', PARAM_TEXT);
}
/**
@@ -319,21 +319,21 @@ protected function add_name_field() {
protected function add_submission_deadline_field() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $default_timestamp = strtotime('+2 weeks');
+ $defaulttimestamp = strtotime('+2 weeks');
$disabled = true;
if (!empty($CFG->coursework_submission_deadline)) {
$disabled = false;
- $default_timestamp = strtotime('today');
+ $defaulttimestamp = strtotime('today');
if ($CFG->coursework_submission_deadline == 7 ) {
- $default_timestamp = strtotime('+1 weeks');
+ $defaulttimestamp = strtotime('+1 weeks');
} else if ($CFG->coursework_submission_deadline == 14 ) {
- $default_timestamp = strtotime('+2 weeks');
+ $defaulttimestamp = strtotime('+2 weeks');
} else if ($CFG->coursework_submission_deadline == 31 ) {
- $default_timestamp = strtotime('+1 month');
+ $defaulttimestamp = strtotime('+1 month');
}
}
@@ -346,17 +346,19 @@ protected function add_submission_deadline_field() {
}
}
- $moodle_form->addElement('date_time_selector',
+ $moodleform->addElement('date_time_selector',
'deadline',
get_string('deadline', 'coursework'),
- array('optional' => $optional, 'disabled' => $disabled));
+ ['optional' => $optional, 'disabled' => $disabled]);
- $moodle_form->addElement('html', '');
- $moodle_form->addElement('html', get_string('submissionsdeadlineinfo', 'mod_coursework'));
- $moodle_form->addElement('html', ' ');
+ $moodleform->addElement('html', '');
+ $moodleform->addElement('html', get_string('submissionsdeadlineinfo', 'mod_coursework'));
+ $moodleform->addElement('html', ' ');
- if (!empty($CFG->coursework_submission_deadline)) $moodle_form->setDefault('deadline', $default_timestamp);
- $moodle_form->addHelpButton('deadline', 'deadline', 'mod_coursework');
+ if (!empty($CFG->coursework_submission_deadline)) {
+ $moodleform->setDefault('deadline', $defaulttimestamp);
+ }
+ $moodleform->addHelpButton('deadline', 'deadline', 'mod_coursework');
}
/**
@@ -364,22 +366,22 @@ protected function add_submission_deadline_field() {
*/
protected function add_personal_deadline_field() {
- $moodle_form =& $this->_form;
- $options = array(0 => get_string('no'), 1 => get_string('yes'));
+ $moodleform =& $this->_form;
+ $options = [0 => get_string('no'), 1 => get_string('yes')];
$courseworkid = $this->get_coursework_id();
$disabled = [];
if (coursework_personal_deadline_passed($courseworkid)) {
- $moodle_form->disabledIf('personaldeadlineenabled', 'deadline[enabled]', 'notchecked');
- $disabled = array('disabled' => true);
+ $moodleform->disabledIf('personaldeadlineenabled', 'deadline[enabled]', 'notchecked');
+ $disabled = ['disabled' => true];
}
- $moodle_form->addElement('select',
+ $moodleform->addElement('select',
'personaldeadlineenabled',
get_string('usepersonaldeadline', 'mod_coursework'), $options, $disabled);
- $moodle_form->setType('personaldeadlineenabled', PARAM_INT);
- $moodle_form->addHelpButton('personaldeadlineenabled', 'personaldeadlineenabled', 'mod_coursework');
+ $moodleform->setType('personaldeadlineenabled', PARAM_INT);
+ $moodleform->addHelpButton('personaldeadlineenabled', 'personaldeadlineenabled', 'mod_coursework');
- $moodle_form->setDefault('personaldeadlineenabled', 0);
+ $moodleform->setDefault('personaldeadlineenabled', 0);
//$moodle_form->disabledIf('personaldeadlineenabled', 'deadline[enabled]', 'notchecked');
}
@@ -390,37 +392,39 @@ protected function add_personal_deadline_field() {
protected function add_start_date_field() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $default_timestamp = strtotime('+2 weeks');
+ $defaulttimestamp = strtotime('+2 weeks');
$disabled = true;
if (!empty($CFG->coursework_start_date)) {
$disabled = false;
- $default_timestamp = strtotime('today');
+ $defaulttimestamp = strtotime('today');
}
- $moodle_form->addElement('date_time_selector',
+ $moodleform->addElement('date_time_selector',
'startdate',
get_string('startdate', 'coursework'),
- array('optional' => true, 'disabled' => $disabled)
+ ['optional' => true, 'disabled' => $disabled]
);
- if (!empty($CFG->coursework_start_date)) $moodle_form->setDefault('startdate', $default_timestamp);
- $moodle_form->addHelpButton('startdate', 'startdate', 'mod_coursework');
+ if (!empty($CFG->coursework_start_date)) {
+ $moodleform->setDefault('startdate', $defaulttimestamp);
+ }
+ $moodleform->addHelpButton('startdate', 'startdate', 'mod_coursework');
}
private function add_marking_deadline_field() {
global $CFG;
- $moodle_form =& $this->_form;
- $options = array(0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select',
+ $moodleform =& $this->_form;
+ $options = [0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select',
'markingdeadlineenabled',
get_string('usemarkingdeadline', 'mod_coursework'), $options);
- $moodle_form->setType('markingdeadlineenabled', PARAM_INT);
+ $moodleform->setType('markingdeadlineenabled', PARAM_INT);
$settingdefault = (empty($CFG->coursework_marking_deadline) && empty($CFG->coursework_agreed_marking_deadline)) ? 0 : 1;
- $moodle_form->setDefault('markingdeadlineenabled', $settingdefault);
+ $moodleform->setDefault('markingdeadlineenabled', $settingdefault);
}
/**
@@ -429,20 +433,20 @@ private function add_marking_deadline_field() {
protected function add_initial_marking_deadline_field() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $default_timestamp = strtotime('today');
+ $defaulttimestamp = strtotime('today');
$disabled = true;
- $submission_deadline_timestamp = strtotime('today');
+ $submissiondeadlinetimestamp = strtotime('today');
if (!empty($CFG->coursework_submission_deadline)) {
if ($CFG->coursework_submission_deadline == 7 ) {
- $submission_deadline_timestamp = strtotime('+1 weeks');
+ $submissiondeadlinetimestamp = strtotime('+1 weeks');
} else if ($CFG->coursework_submission_deadline == 14 ) {
- $submission_deadline_timestamp = strtotime('+2 weeks');
+ $submissiondeadlinetimestamp = strtotime('+2 weeks');
} else if ($CFG->coursework_submission_deadline == 31 ) {
- $submission_deadline_timestamp = strtotime('+1 month');
+ $submissiondeadlinetimestamp = strtotime('+1 month');
}
}
@@ -451,29 +455,31 @@ protected function add_initial_marking_deadline_field() {
$disabled = false;
if ($CFG->coursework_marking_deadline == 7 ) {
- $default_timestamp = strtotime('+1 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+1 weeks', $submissiondeadlinetimestamp);
} else if ($CFG->coursework_marking_deadline == 14 ) {
- $default_timestamp = strtotime('+2 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+2 weeks', $submissiondeadlinetimestamp);
} else if ($CFG->coursework_marking_deadline == 21 ) {
- $default_timestamp = strtotime('+3 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+3 weeks', $submissiondeadlinetimestamp);
} else if ($CFG->coursework_marking_deadline == 28 ) {
- $default_timestamp = strtotime('+4 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+4 weeks', $submissiondeadlinetimestamp);
} else if ($CFG->coursework_marking_deadline == 35 ) {
- $default_timestamp = strtotime('+5 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+5 weeks', $submissiondeadlinetimestamp);
} else if ($CFG->coursework_marking_deadline == 42 ) {
- $default_timestamp = strtotime('+6 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+6 weeks', $submissiondeadlinetimestamp);
}
}
- $moodle_form->addElement('date_time_selector',
+ $moodleform->addElement('date_time_selector',
'initialmarkingdeadline',
get_string('initialmarkingdeadline', 'coursework'),
- array('optional' => true, 'disabled' => $disabled)
+ ['optional' => true, 'disabled' => $disabled]
);
- if (!empty($CFG->coursework_marking_deadline)) $moodle_form->setDefault('initialmarkingdeadline', $default_timestamp);
+ if (!empty($CFG->coursework_marking_deadline)) {
+ $moodleform->setDefault('initialmarkingdeadline', $defaulttimestamp);
+ }
- $moodle_form->addHelpButton('initialmarkingdeadline', 'initialmarkingdeadline', 'mod_coursework');
+ $moodleform->addHelpButton('initialmarkingdeadline', 'initialmarkingdeadline', 'mod_coursework');
}
/**
@@ -482,50 +488,52 @@ protected function add_initial_marking_deadline_field() {
protected function add_agreed_grade_marking_deadline_field() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $default_timestamp =strtotime('today');
+ $defaulttimestamp = strtotime('today');
$disabled = true;
- $submission_deadline_timestamp = strtotime('today');
+ $submissiondeadlinetimestamp = strtotime('today');
if (!empty($CFG->coursework_submission_deadline)) {
if ($CFG->coursework_submission_deadline == 7 ) {
- $submission_deadline_timestamp = strtotime('+1 weeks');
+ $submissiondeadlinetimestamp = strtotime('+1 weeks');
} else if ($CFG->coursework_submission_deadline == 14 ) {
- $submission_deadline_timestamp = strtotime('+2 weeks');
+ $submissiondeadlinetimestamp = strtotime('+2 weeks');
} else if ($CFG->coursework_submission_deadline == 31 ) {
- $submission_deadline_timestamp = strtotime('+1 month');
+ $submissiondeadlinetimestamp = strtotime('+1 month');
}
}
if (!empty($CFG->coursework_agreed_marking_deadline)) {
$disabled = false;
if ($CFG->coursework_agreed_marking_deadline == 7 ) {
- $default_timestamp = strtotime('+1 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+1 weeks', $submissiondeadlinetimestamp);
} else if ($CFG->coursework_agreed_marking_deadline == 14 ) {
- $default_timestamp = strtotime('+2 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+2 weeks', $submissiondeadlinetimestamp);
} else if ($CFG->coursework_agreed_marking_deadline == 21 ) {
- $default_timestamp = strtotime('+3 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+3 weeks', $submissiondeadlinetimestamp);
} else if ($CFG->coursework_agreed_marking_deadline == 28 ) {
- $default_timestamp = strtotime('+4 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+4 weeks', $submissiondeadlinetimestamp);
} else if ($CFG->coursework_agreed_marking_deadline == 35 ) {
- $default_timestamp = strtotime('+5 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+5 weeks', $submissiondeadlinetimestamp);
} else if ($CFG->coursework_agreed_marking_deadline == 42 ) {
- $default_timestamp = strtotime('+6 weeks', $submission_deadline_timestamp);
+ $defaulttimestamp = strtotime('+6 weeks', $submissiondeadlinetimestamp);
}
}
- $moodle_form->addElement('date_time_selector',
+ $moodleform->addElement('date_time_selector',
'agreedgrademarkingdeadline',
get_string('agreedgrademarkingdeadline', 'coursework'),
- array('optional' => true, 'disabled' => $disabled)
+ ['optional' => true, 'disabled' => $disabled]
);
- // $moodle_form->disabledIf('agreedgrademarkingdeadline', 'numberofmarkers', 'eq', '1');
+ // $moodle_form->disabledIf('agreedgrademarkingdeadline', 'numberofmarkers', 'eq', '1');
- if (!empty($CFG->coursework_agreed_marking_deadline)) $moodle_form->setDefault('agreedgrademarkingdeadline', $default_timestamp);
- $moodle_form->addHelpButton('agreedgrademarkingdeadline', 'agreedgrademarkingdeadline', 'mod_coursework');
+ if (!empty($CFG->coursework_agreed_marking_deadline)) {
+ $moodleform->setDefault('agreedgrademarkingdeadline', $defaulttimestamp);
+ }
+ $moodleform->addHelpButton('agreedgrademarkingdeadline', 'agreedgrademarkingdeadline', 'mod_coursework');
}
/********
@@ -534,9 +542,9 @@ protected function add_agreed_grade_marking_deadline_field() {
protected function add_relative_initial_marking_deadline_field() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $options = array('0' => get_string('disabled', 'mod_coursework'));
+ $options = ['0' => get_string('disabled', 'mod_coursework')];
$options['7'] = get_string('oneweekoption', 'mod_coursework');
$options['14'] = get_string('twoweeksoption', 'mod_coursework');
$options['21'] = get_string('threeweeksoption', 'mod_coursework');
@@ -544,12 +552,14 @@ protected function add_relative_initial_marking_deadline_field() {
$options['35'] = get_string('fiveweeksoption', 'mod_coursework');
$options['42'] = get_string('sixweeksoption', 'mod_coursework');
- $moodle_form->addElement('select',
+ $moodleform->addElement('select',
'relativeinitialmarkingdeadline',
get_string('relativeinitialmarkingdeadline', 'mod_coursework'), $options);
- if (!empty($CFG->coursework_marking_deadline)) $moodle_form->setDefault('relativeinitialmarkingdeadline', $CFG->coursework_marking_deadline);
- $moodle_form->addHelpButton('relativeinitialmarkingdeadline', 'agreedgrademarkingdeadline', 'mod_coursework');
+ if (!empty($CFG->coursework_marking_deadline)) {
+ $moodleform->setDefault('relativeinitialmarkingdeadline', $CFG->coursework_marking_deadline);
+ }
+ $moodleform->addHelpButton('relativeinitialmarkingdeadline', 'agreedgrademarkingdeadline', 'mod_coursework');
}
@@ -559,9 +569,9 @@ protected function add_relative_initial_marking_deadline_field() {
protected function add_relative_agreed_grade_marking_deadline_field() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $options = array('0' => get_string('disabled', 'mod_coursework'));
+ $options = ['0' => get_string('disabled', 'mod_coursework')];
$options['7'] = get_string('oneweekoption', 'mod_coursework');
$options['14'] = get_string('twoweeksoption', 'mod_coursework');
$options['21'] = get_string('threeweeksoption', 'mod_coursework');
@@ -569,12 +579,14 @@ protected function add_relative_agreed_grade_marking_deadline_field() {
$options['35'] = get_string('fiveweeksoption', 'mod_coursework');
$options['42'] = get_string('sixweeksoption', 'mod_coursework');
- $moodle_form->addElement('select',
+ $moodleform->addElement('select',
'relativeagreedmarkingdeadline',
get_string('relativeagreedmarkingdeadline', 'mod_coursework'), $options);
- if (!empty($CFG->coursework_agreed_marking_deadline)) $moodle_form->setDefault('relativeagreedmarkingdeadline', $CFG->coursework_agreed_marking_deadline);
- $moodle_form->addHelpButton('relativeagreedmarkingdeadline', 'agreedgrademarkingdeadline', 'mod_coursework');
+ if (!empty($CFG->coursework_agreed_marking_deadline)) {
+ $moodleform->setDefault('relativeagreedmarkingdeadline', $CFG->coursework_agreed_marking_deadline);
+ }
+ $moodleform->addHelpButton('relativeagreedmarkingdeadline', 'agreedgrademarkingdeadline', 'mod_coursework');
}
@@ -582,24 +594,24 @@ protected function add_relative_agreed_grade_marking_deadline_field() {
* @throws coding_exception
*/
protected function add_digest_header() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('header', 'digest', get_string('digest', 'mod_coursework'));
+ $moodleform->addElement('header', 'digest', get_string('digest', 'mod_coursework'));
// We want it expanded by default
- $moodle_form->setExpanded('digest');
+ $moodleform->setExpanded('digest');
}
private function add_marking_reminder_field() {
global $CFG;
- $moodle_form =& $this->_form;
- $options = array(0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select',
+ $moodleform =& $this->_form;
+ $options = [0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select',
'markingreminderenabled',
get_string('sendmarkingreminder', 'mod_coursework'), $options);
- $moodle_form->setType('markingreminderenabled', PARAM_INT);
+ $moodleform->setType('markingreminderenabled', PARAM_INT);
$settingdefault = (empty($CFG->coursework_marking_deadline)) ? 0 : 1;
- $moodle_form->setDefault('markingreminderenabled', $settingdefault);
+ $moodleform->setDefault('markingreminderenabled', $settingdefault);
}
@@ -614,13 +626,13 @@ protected function add_marking_reminder_warning() {
* @throws coding_exception
*/
protected function add_allow_early_finalisation_field() {
- $moodle_form =& $this->_form;
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select',
+ $moodleform =& $this->_form;
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select',
'allowearlyfinalisation',
get_string('allowearlyfinalisation', 'mod_coursework'), $options);
- $moodle_form->setType('allowearlyfinalisation', PARAM_INT);
- $moodle_form->disabledIf('allowearlyfinalisation', 'deadline[enabled]', 'notchecked');
+ $moodleform->setType('allowearlyfinalisation', PARAM_INT);
+ $moodleform->disabledIf('allowearlyfinalisation', 'deadline[enabled]', 'notchecked');
}
/**
@@ -628,11 +640,11 @@ protected function add_allow_early_finalisation_field() {
*/
protected function add_group_submission_header() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('header', 'group_submission', get_string('groupsubmissionsettings', 'mod_coursework'));
+ $moodleform->addElement('header', 'group_submission', get_string('groupsubmissionsettings', 'mod_coursework'));
// We want it expanded by default
- $moodle_form->setExpanded('group_submission');
+ $moodleform->setExpanded('group_submission');
}
@@ -640,11 +652,11 @@ protected function add_group_submission_header() {
* @throws coding_exception
*/
protected function add_use_groups_field() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select', 'use_groups', get_string('use_groups', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('use_groups', 'use_groups', 'mod_coursework');
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select', 'use_groups', get_string('use_groups', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('use_groups', 'use_groups', 'mod_coursework');
}
/**
@@ -653,50 +665,50 @@ protected function add_use_groups_field() {
protected function add_grouping_field() {
global $COURSE, $DB;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $groups_options_result = $DB->get_records('groupings', array('courseid' => $COURSE->id), 'name', 'id, name');
- $groups_options = [];
- if ($groups_options_result !== false) {
- foreach ($groups_options_result as $result) {
- $groups_options[$result->id] = $result->name;
+ $groupsoptionsresult = $DB->get_records('groupings', ['courseid' => $COURSE->id], 'name', 'id, name');
+ $groupsoptions = [];
+ if ($groupsoptionsresult !== false) {
+ foreach ($groupsoptionsresult as $result) {
+ $groupsoptions[$result->id] = $result->name;
}
}
// Not calling it groupingid as this conflicts with the groupingid field in the common module
// settings.
- $default_groups_options = array(0 => 'Use all groups');
- $groups_options = $default_groups_options + $groups_options;
- $moodle_form->addElement('select',
+ $defaultgroupsoptions = [0 => 'Use all groups'];
+ $groupsoptions = $defaultgroupsoptions + $groupsoptions;
+ $moodleform->addElement('select',
'grouping_id',
get_string('grouping_id', 'mod_coursework'),
- $groups_options);
- $moodle_form->addHelpButton('grouping_id', 'grouping_id', 'mod_coursework');
- $moodle_form->disabledIf('grouping_id', 'use_groups', 'eq', 0);
+ $groupsoptions);
+ $moodleform->addHelpButton('grouping_id', 'grouping_id', 'mod_coursework');
+ $moodleform->disabledIf('grouping_id', 'use_groups', 'eq', 0);
}
/**
* @throws coding_exception
*/
protected function add_general_header() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('header', 'generalstuff', get_string('general', 'form'));
+ $moodleform->addElement('header', 'generalstuff', get_string('general', 'form'));
}
/**
* @throws coding_exception
*/
protected function add_file_types_field() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('text',
+ $moodleform->addElement('text',
'filetypes',
get_string('filetypes', 'coursework'),
- array('placeholder' => 'e.g. doc, docx, txt, rtf'));
- $moodle_form->addHelpButton('filetypes', 'filetypes', 'mod_coursework');
- $moodle_form->setType('filetypes', PARAM_TEXT);
- $moodle_form->disabledIf('filetypes', 'use_turnitin', 'eq', '1');
+ ['placeholder' => 'e.g. doc, docx, txt, rtf']);
+ $moodleform->addHelpButton('filetypes', 'filetypes', 'mod_coursework');
+ $moodleform->setType('filetypes', PARAM_TEXT);
+ $moodleform->disabledIf('filetypes', 'use_turnitin', 'eq', '1');
}
/**
@@ -705,24 +717,24 @@ protected function add_file_types_field() {
protected function add_max_file_size_field() {
global $CFG, $COURSE;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
$choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
//$choices[0] = get_string('maximumupload') . ' (' . display_size($COURSE->maxbytes) . ')';
$choices[0] = get_string('maximumupload'). ' set in course';
- $moodle_form->addElement('select',
+ $moodleform->addElement('select',
'maxbytes',
get_string('maximumsize', 'coursework'),
$choices);
- $moodle_form->setDefault('maxbytes', $CFG->coursework_maxbytes);
- /* $moodle_form->addElement('static',
+ $moodleform->setDefault('maxbytes', $CFG->coursework_maxbytes);
+ /* $moodle_form->addElement('static',
'maxbyteslabel',
'',
get_string('maximumsizelabel', 'coursework'));*/
- $moodle_form->addHelpButton('maxbytes', 'maximumsize', 'mod_coursework');
- $moodle_form->disabledIf('maxbytes', 'use_turnitin', 'eq', '1');
+ $moodleform->addHelpButton('maxbytes', 'maximumsize', 'mod_coursework');
+ $moodleform->disabledIf('maxbytes', 'use_turnitin', 'eq', '1');
- $moodle_form->closeHeaderBefore('submissiontype');
+ $moodleform->closeHeaderBefore('submissiontype');
}
@@ -731,10 +743,10 @@ protected function add_max_file_size_field() {
*/
protected function add_number_of_files_field() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
// Maximum number of files:
- $choices = array(1 => 1,
+ $choices = [1 => 1,
2 => 2,
3 => 3,
4 => 4,
@@ -743,14 +755,14 @@ protected function add_number_of_files_field() {
7 => 7,
8 => 8,
9 => 9,
- 10 => 10);
- $moodle_form->addElement('select',
+ 10 => 10];
+ $moodleform->addElement('select',
'maxfiles',
get_string('maxfiles', 'coursework'),
$choices);
- $moodle_form->setDefault('maxfiles', 1);
- $moodle_form->setType('maxfiles', PARAM_INT);
- $moodle_form->addHelpButton('maxfiles', 'maxfiles', 'mod_coursework');
+ $moodleform->setDefault('maxfiles', 1);
+ $moodleform->setType('maxfiles', PARAM_INT);
+ $moodleform->addHelpButton('maxfiles', 'maxfiles', 'mod_coursework');
}
@@ -758,21 +770,21 @@ protected function add_rename_file_field() {
global $DB, $PAGE;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $choices = array('0' => get_string('no'), '1' => get_string('yes'));
+ $choices = ['0' => get_string('no'), '1' => get_string('yes')];
$courseworkid = $this->get_coursework_id();
$courseworkhassubmissions = !empty($courseworkid)
- && $DB->record_exists('coursework_submissions', array('courseworkid' => $courseworkid));
+ && $DB->record_exists('coursework_submissions', ['courseworkid' => $courseworkid]);
if (empty($courseworkid) || empty($courseworkhassubmissions)) {
- $moodle_form->addElement('select', 'renamefiles',
+ $moodleform->addElement('select', 'renamefiles',
get_string('renamefiles', 'mod_coursework'), $choices);
- $moodle_form->addHelpButton('renamefiles', 'renamefiles', 'mod_coursework');
+ $moodleform->addHelpButton('renamefiles', 'renamefiles', 'mod_coursework');
- $moodle_form->disabledIf('renamefiles', 'blindmarking', 'eq', '1');
+ $moodleform->disabledIf('renamefiles', 'blindmarking', 'eq', '1');
$PAGE->requires->js_amd_inline("
require(['jquery'], function() {
@@ -794,9 +806,9 @@ protected function add_rename_file_field() {
WHERE id = :courseworkid
AND renamefiles = 1";
- $settingvalue = ($DB->get_records_sql($sql, array('courseworkid' => $courseworkid))) ? get_string('yesrenamefile', 'mod_coursework') : get_string('norenamefile', 'mod_coursework');
+ $settingvalue = ($DB->get_records_sql($sql, ['courseworkid' => $courseworkid])) ? get_string('yesrenamefile', 'mod_coursework') : get_string('norenamefile', 'mod_coursework');
- $moodle_form->addElement('static', 'renamefilesdescription', get_string('renamefiles', 'mod_coursework'),
+ $moodleform->addElement('static', 'renamefilesdescription', get_string('renamefiles', 'mod_coursework'),
$settingvalue);
}
@@ -806,9 +818,9 @@ protected function add_rename_file_field() {
* @throws coding_exception
*/
protected function add_marking_workflow_header() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('header', 'markingworkflow', get_string('markingworkflow', 'mod_coursework'));
+ $moodleform->addElement('header', 'markingworkflow', get_string('markingworkflow', 'mod_coursework'));
}
/**
@@ -817,30 +829,30 @@ protected function add_marking_workflow_header() {
*/
protected function add_number_of_initial_assessors_field() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
$courseworkid = $this->get_coursework_id();
- $multi_options = array(
+ $multioptions = [
// Don't want to give the option for 0!
1 => 1,
2 => 2,
- 3 => 3
- );
+ 3 => 3,
+ ];
// Remove all options lower than the current maximum number of feedbacks that any student has.
$currentmaxfeedbacks = coursework_get_current_max_feedbacks($courseworkid);
if ($currentmaxfeedbacks) {
- foreach ($multi_options as $key => $option) {
+ foreach ($multioptions as $key => $option) {
if ($key < $currentmaxfeedbacks) {
- unset($multi_options[$key]);
+ unset($multioptions[$key]);
}
}
}
- $moodle_form->addElement('select',
+ $moodleform->addElement('select',
'numberofmarkers',
get_string('numberofmarkers', 'mod_coursework'),
- $multi_options);
- $moodle_form->addHelpButton('numberofmarkers', 'numberofmarkers', 'mod_coursework');
- $moodle_form->setDefault('numberofmarkers', 1);
+ $multioptions);
+ $moodleform->addHelpButton('numberofmarkers', 'numberofmarkers', 'mod_coursework');
+ $moodleform->setDefault('numberofmarkers', 1);
}
/**
@@ -848,13 +860,13 @@ protected function add_number_of_initial_assessors_field() {
* @throws coding_exception
*/
protected function add_enable_moderation_agreement_field() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $options = array(0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select', 'moderationagreementenabled', get_string('moderationagreementenabled', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('moderationagreementenabled', 'moderationagreementenabled', 'mod_coursework');
- $moodle_form->setDefault('moderationagreementenabled', 0);
- $moodle_form->disabledIf('moderationagreementenabled', 'numberofmarkers', 'neq', 1);
+ $options = [0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select', 'moderationagreementenabled', get_string('moderationagreementenabled', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('moderationagreementenabled', 'moderationagreementenabled', 'mod_coursework');
+ $moodleform->setDefault('moderationagreementenabled', 0);
+ $moodleform->disabledIf('moderationagreementenabled', 'numberofmarkers', 'neq', 1);
}
/**
@@ -876,18 +888,18 @@ protected function get_coursework_id() {
* @throws coding_exception
*/
protected function add_enable_allocation_field() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select', 'allocationenabled', get_string('allocationenabled', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('allocationenabled', 'allocationenabled', 'mod_coursework');
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select', 'allocationenabled', get_string('allocationenabled', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('allocationenabled', 'allocationenabled', 'mod_coursework');
}
/**
* @throws coding_exception
*/
protected function add_assessor_allocation_strategy_field_rdb() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
$options = mod_coursework\allocation\manager::get_allocation_classnames();
@@ -895,21 +907,21 @@ protected function add_assessor_allocation_strategy_field_rdb() {
$keys = array_keys($options);
foreach ($keys as $key) {
- $radioarray[] =& $moodle_form->createElement('radio', 'assessorallocationstrategy', '', $options[$key], $key, '');
+ $radioarray[] =& $moodleform->createElement('radio', 'assessorallocationstrategy', '', $options[$key], $key, '');
}
- $moodle_form->addGroup($radioarray, 'radioarray', get_string('assessorallocationstrategy', 'mod_coursework'), array(' '), false);
- $moodle_form->addHelpButton('radioarray', 'assessorallocationstrategy', 'mod_coursework');
- $moodle_form->disabledIf('radioarray', 'allocationenabled', 'eq', 0);
+ $moodleform->addGroup($radioarray, 'radioarray', get_string('assessorallocationstrategy', 'mod_coursework'), [' '], false);
+ $moodleform->addHelpButton('radioarray', 'assessorallocationstrategy', 'mod_coursework');
+ $moodleform->disabledIf('radioarray', 'allocationenabled', 'eq', 0);
}
protected function add_assessor_allocation_strategy_field() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
$options = mod_coursework\allocation\manager::get_allocation_classnames();
- $moodle_form->addElement('select', 'assessorallocationstrategy', get_string('assessorallocationstrategy', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('assessorallocationstrategy', 'assessorallocationstrategy', 'mod_coursework');
- $moodle_form->disabledIf('assessorallocationstrategy', 'allocationenabled', 'eq', 0);
+ $moodleform->addElement('select', 'assessorallocationstrategy', get_string('assessorallocationstrategy', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('assessorallocationstrategy', 'assessorallocationstrategy', 'mod_coursework');
+ $moodleform->disabledIf('assessorallocationstrategy', 'allocationenabled', 'eq', 0);
}
/**
@@ -917,13 +929,13 @@ protected function add_assessor_allocation_strategy_field() {
*/
protected function add_blind_marking_header() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('header', 'anonymity', get_string('blindmarking', 'mod_coursework'));
- $moodle_form->addElement('html', '');
- $moodle_form->addElement('html',
+ $moodleform->addElement('header', 'anonymity', get_string('blindmarking', 'mod_coursework'));
+ $moodleform->addElement('html', ' ');
+ $moodleform->addElement('html',
get_string('anonymitydescription', 'mod_coursework'));
- $moodle_form->addElement('html', ' ');
+ $moodleform->addElement('html', ' ');
}
@@ -931,13 +943,13 @@ protected function add_blind_marking_header() {
* @throws coding_exception
*/
protected function add_assessor_anonymity_header() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('header', 'assessoranonymityheader', get_string('assessoranonymity', 'mod_coursework'));
- $moodle_form->addElement('html', '');
- $moodle_form->addElement('html',
+ $moodleform->addElement('header', 'assessoranonymityheader', get_string('assessoranonymity', 'mod_coursework'));
+ $moodleform->addElement('html', ' ');
+ $moodleform->addElement('html',
get_string('assessoranonymity_desc', 'mod_coursework'));
- $moodle_form->addElement('html', ' ');
+ $moodleform->addElement('html', ' ');
}
/**
@@ -946,30 +958,30 @@ protected function add_assessor_anonymity_header() {
protected function add_enable_blind_marking_field() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select', 'blindmarking', get_string('blindmarking', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('blindmarking', 'blindmarking', 'mod_coursework');
- $moodle_form->setDefault('blindmarking', $CFG->coursework_blindmarking);
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select', 'blindmarking', get_string('blindmarking', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('blindmarking', 'blindmarking', 'mod_coursework');
+ $moodleform->setDefault('blindmarking', $CFG->coursework_blindmarking);
- $submission_exists = 0;
+ $submissionexists = 0;
// disable the setting if at least one submission exists
$courseworkid = $this->get_coursework_id();
if ($courseworkid && mod_coursework\models\coursework::find($courseworkid)->has_any_submission()) {
- $submission_exists = 1;
+ $submissionexists = 1;
}
- $moodle_form->addElement('hidden', 'submission_exists', $submission_exists);
- $moodle_form->setType('submission_exists', PARAM_INT);
- $moodle_form->disabledIf('blindmarking', 'submission_exists', 'eq', 1);
+ $moodleform->addElement('hidden', 'submission_exists', $submissionexists);
+ $moodleform->setType('submission_exists', PARAM_INT);
+ $moodleform->disabledIf('blindmarking', 'submission_exists', 'eq', 1);
//disable blindmarking if forceblindmarking is enabled, process data for DB in get_data()
if ($this->forceblindmarking() == 1) {
- $moodle_form->addElement('hidden', 'forceblindmarking', $this->forceblindmarking());
- $moodle_form->setType('forceblindmarking', PARAM_INT);
- $moodle_form->disabledIf('blindmarking', 'forceblindmarking', 'eq', 1);
- $moodle_form->addElement('static', 'forceblindmarking_explanation', '', get_string('forcedglobalsetting', 'mod_coursework'));
+ $moodleform->addElement('hidden', 'forceblindmarking', $this->forceblindmarking());
+ $moodleform->setType('forceblindmarking', PARAM_INT);
+ $moodleform->disabledIf('blindmarking', 'forceblindmarking', 'eq', 1);
+ $moodleform->addElement('static', 'forceblindmarking_explanation', '', get_string('forcedglobalsetting', 'mod_coursework'));
}
}
@@ -979,11 +991,11 @@ protected function add_enable_blind_marking_field() {
protected function add_enable_assessor_anonymity_field() {
global $CFG;
- $moodle_form =& $this->_form;
- $options = array(0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select', 'assessoranonymity', get_string('assessoranonymity', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('assessoranonymity', 'assessoranonymity', 'mod_coursework');
- $moodle_form->setDefault('assessoranonymity', $CFG->coursework_assessoranonymity);
+ $moodleform =& $this->_form;
+ $options = [0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select', 'assessoranonymity', get_string('assessoranonymity', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('assessoranonymity', 'assessoranonymity', 'mod_coursework');
+ $moodleform->setDefault('assessoranonymity', $CFG->coursework_assessoranonymity);
}
@@ -991,9 +1003,9 @@ protected function add_enable_assessor_anonymity_field() {
* @throws coding_exception
*/
protected function add_feedback_header() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('header', 'feedbacktypes', get_string('feedbacktypes', 'mod_coursework'));
+ $moodleform->addElement('header', 'feedbacktypes', get_string('feedbacktypes', 'mod_coursework'));
}
/**
@@ -1003,18 +1015,18 @@ protected function add_individual_feedback_release_date_field() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
$timestamp = strtotime('+' . $CFG->coursework_individualfeedback . ' weeks');
- $default = array(
+ $default = [
'day' => date('j', $timestamp),
'month' => date('n', $timestamp),
'year' => date('Y', $timestamp),
'hour' => date('G', $timestamp),
'minute' => date('i', $timestamp),
- );
- $options = array('optional' => true);
+ ];
+ $options = ['optional' => true];
if ($CFG->coursework_auto_release_individual_feedback == 0) {
$options['disabled'] = true;
@@ -1026,20 +1038,20 @@ protected function add_individual_feedback_release_date_field() {
$options['optional'] = false;
}
- $moodle_form->addElement('date_time_selector',
+ $moodleform->addElement('date_time_selector',
'individualfeedback',
get_string('individualfeedback', 'coursework'),
$options);
- $moodle_form->setDefault('individualfeedback', $default);
- $moodle_form->addHelpButton('individualfeedback', 'individualfeedback', 'mod_coursework');
+ $moodleform->setDefault('individualfeedback', $default);
+ $moodleform->addHelpButton('individualfeedback', 'individualfeedback', 'mod_coursework');
if ($this->forceautorelease() == 1 && $CFG->coursework_auto_release_individual_feedback == 0) {
- $moodle_form->addElement('hidden', 'forceautorelease', $this->forceautorelease());
- $moodle_form->setType('forceautorelease', PARAM_INT);
- $moodle_form->disabledIf('individualfeedback', 'forceautorelease', 'eq', 1);
+ $moodleform->addElement('hidden', 'forceautorelease', $this->forceautorelease());
+ $moodleform->setType('forceautorelease', PARAM_INT);
+ $moodleform->disabledIf('individualfeedback', 'forceautorelease', 'eq', 1);
}
- $moodle_form->disabledIf('individualfeedback', 'deadline[enabled]', 'notchecked');
-// $moodle_form->addRule(array('individualfeedback', 'deadline'), get_string('must_be_after_dealdine', 'mod_coursework'), 'compare', 'gt');
+ $moodleform->disabledIf('individualfeedback', 'deadline[enabled]', 'notchecked');
+ // $moodle_form->addRule(array('individualfeedback', 'deadline'), get_string('must_be_after_dealdine', 'mod_coursework'), 'compare', 'gt');
}
/**
@@ -1048,11 +1060,11 @@ protected function add_individual_feedback_release_date_field() {
protected function add_email_individual_feedback_notification_field() {
global $CFG;
- $moodle_form =& $this->_form;
- $options = array(0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select', 'feedbackreleaseemail', get_string('feedbackreleaseemail', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('feedbackreleaseemail', 'feedbackreleaseemail', 'mod_coursework');
- $moodle_form->setDefault('feedbackreleaseemail', $CFG->coursework_feedbackreleaseemail);
+ $moodleform =& $this->_form;
+ $options = [0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select', 'feedbackreleaseemail', get_string('feedbackreleaseemail', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('feedbackreleaseemail', 'feedbackreleaseemail', 'mod_coursework');
+ $moodleform->setDefault('feedbackreleaseemail', $CFG->coursework_feedbackreleaseemail);
}
/**
@@ -1061,44 +1073,44 @@ protected function add_email_individual_feedback_notification_field() {
protected function add_general_feedback_release_date_field() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('date_time_selector',
+ $moodleform->addElement('date_time_selector',
'generalfeedback',
get_string('generalfeedbackreleasedate', 'coursework'),
- array('optional' => true, 'disabled' => true));
+ ['optional' => true, 'disabled' => true]);
// We have a field which is sometimes disabled. Disabled fields are not sent back to the
// server, so the default is used.
$timestamp = strtotime('+' . $CFG->coursework_generalfeedback . ' weeks');
- $default = array(
+ $default = [
'day' => date('j', $timestamp),
'month' => date('n', $timestamp),
'year' => date('Y', $timestamp),
'hour' => date('G', $timestamp),
'minute' => date('i', $timestamp),
- );
- $moodle_form->setDefault('generalfeedback', $default);
- $moodle_form->addHelpButton('generalfeedback', 'generalfeedback', 'mod_coursework');
- $moodle_form->disabledIf('generalfeedback', 'deadline[enabled]', 'notchecked');
+ ];
+ $moodleform->setDefault('generalfeedback', $default);
+ $moodleform->addHelpButton('generalfeedback', 'generalfeedback', 'mod_coursework');
+ $moodleform->disabledIf('generalfeedback', 'deadline[enabled]', 'notchecked');
}
/**
*/
protected function add_tweaks_to_standard_grading_form_elements() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addHelpButton('grade', 'grade', 'mod_coursework');
- $moodle_form->setExpanded('modstandardgrade');
+ $moodleform->addHelpButton('grade', 'grade', 'mod_coursework');
+ $moodleform->setExpanded('modstandardgrade');
- $options = array(0 => get_string('sameforallstages', 'mod_coursework'),
- 1 => get_string('simpledirectgrading', 'mod_coursework'));
+ $options = [0 => get_string('sameforallstages', 'mod_coursework'),
+ 1 => get_string('simpledirectgrading', 'mod_coursework')];
- $moodle_form->addElement('select', 'finalstagegrading', get_string('finalstagegrading', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('finalstagegrading', 'finalstagegrading', 'mod_coursework');
- $moodle_form->setDefault('finalstagegrading', 0);
- $moodle_form->disabledIf('finalstagegrading', 'numberofmarkers', 'eq', 1);
- $moodle_form->disabledIf('finalstagegrading', 'advancedgradingmethod_submissions', 'eq', "");
+ $moodleform->addElement('select', 'finalstagegrading', get_string('finalstagegrading', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('finalstagegrading', 'finalstagegrading', 'mod_coursework');
+ $moodleform->setDefault('finalstagegrading', 0);
+ $moodleform->disabledIf('finalstagegrading', 'numberofmarkers', 'eq', 1);
+ $moodleform->disabledIf('finalstagegrading', 'advancedgradingmethod_submissions', 'eq', "");
$feedbackexists = 0;
// disable the setting if at least one feedback exists
@@ -1107,30 +1119,30 @@ protected function add_tweaks_to_standard_grading_form_elements() {
$feedbackexists = 1;
}
- $moodle_form->addElement('hidden', 'feedbackexists', $feedbackexists);
- $moodle_form->setType('feedbackexists', PARAM_INT);
- $moodle_form->disabledIf('finalstagegrading', 'feedbackexists', 'eq', 1);
+ $moodleform->addElement('hidden', 'feedbackexists', $feedbackexists);
+ $moodleform->setType('feedbackexists', PARAM_INT);
+ $moodleform->disabledIf('finalstagegrading', 'feedbackexists', 'eq', 1);
// Don't think this belongs here...
-// $options = array(0 => get_string('no'), 1 => get_string('yes'));
-// $moodle_form->addElement('select', 'automaticagreement', get_string('automaticagreement', 'mod_coursework'), $options);
-// $moodle_form->addHelpButton('automaticagreement', 'automaticagreement', 'mod_coursework');
-// $moodle_form->setDefault('automaticagreement',0);
-// $moodle_form->disabledIf('automaticagreement', 'numberofmarkers', 'eq', '1');
-//
-// $moodle_form->addElement('text', 'automaticagreementrange', get_string('automaticagreementrange', 'mod_coursework'), array('size' => 3));
-// $moodle_form->addHelpButton('automaticagreementrange', 'automaticagreementrange', 'mod_coursework');
-// $moodle_form->setDefault('automaticagreementrange',0);
-// $moodle_form->disabledIf('automaticagreementrange', 'automaticagreement', 'eq', '0');
+ // $options = array(0 => get_string('no'), 1 => get_string('yes'));
+ // $moodle_form->addElement('select', 'automaticagreement', get_string('automaticagreement', 'mod_coursework'), $options);
+ // $moodle_form->addHelpButton('automaticagreement', 'automaticagreement', 'mod_coursework');
+ // $moodle_form->setDefault('automaticagreement',0);
+ // $moodle_form->disabledIf('automaticagreement', 'numberofmarkers', 'eq', '1');
+ //
+ // $moodle_form->addElement('text', 'automaticagreementrange', get_string('automaticagreementrange', 'mod_coursework'), array('size' => 3));
+ // $moodle_form->addHelpButton('automaticagreementrange', 'automaticagreementrange', 'mod_coursework');
+ // $moodle_form->setDefault('automaticagreementrange',0);
+ // $moodle_form->disabledIf('automaticagreementrange', 'automaticagreement', 'eq', '0');
}
/**
*/
protected function set_form_attributes() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->_attributes['name'] = 'ocm_update_form';
+ $moodleform->_attributes['name'] = 'ocm_update_form';
}
protected function add_turnitin_files_settings_waring() {
@@ -1142,42 +1154,42 @@ protected function add_turnitin_files_settings_waring() {
private function add_allow_late_submissions_field() {
global $CFG;
- $moodle_form =& $this->_form;
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select',
+ $moodleform =& $this->_form;
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select',
'allowlatesubmissions',
get_string('allowlatesubmissions', 'mod_coursework'), $options);
- $moodle_form->setType('allowlatesubmissions', PARAM_INT);
- $moodle_form->setDefault('allowlatesubmissions', $CFG->coursework_allowlatesubmissions);
- $moodle_form->disabledIf('allowlatesubmissions', 'deadline[enabled]', 'notchecked');
+ $moodleform->setType('allowlatesubmissions', PARAM_INT);
+ $moodleform->setDefault('allowlatesubmissions', $CFG->coursework_allowlatesubmissions);
+ $moodleform->disabledIf('allowlatesubmissions', 'deadline[enabled]', 'notchecked');
}
protected function add_all_feedbacks_field() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select',
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select',
'showallfeedbacks',
get_string('showallfeedbacks', 'mod_coursework'), $options);
- $moodle_form->setDefault('showallfeedbacks', 0);
- $moodle_form->disabledIf('showallfeedbacks', 'numberofmarkers', 'eq', 1);
- $moodle_form->addHelpButton('showallfeedbacks', 'showallfeedbacks', 'mod_coursework');
+ $moodleform->setDefault('showallfeedbacks', 0);
+ $moodleform->disabledIf('showallfeedbacks', 'numberofmarkers', 'eq', 1);
+ $moodleform->addHelpButton('showallfeedbacks', 'showallfeedbacks', 'mod_coursework');
}
/**
* @throws coding_exception
*/
private function add_enable_sampling_checkbox() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('selectyesno', 'samplingenabled', get_string('samplingenabled', 'mod_coursework'));
- $moodle_form->addHelpButton('samplingenabled', 'samplingenabled', 'mod_coursework');
+ $moodleform->addElement('selectyesno', 'samplingenabled', get_string('samplingenabled', 'mod_coursework'));
+ $moodleform->addHelpButton('samplingenabled', 'samplingenabled', 'mod_coursework');
$courseworkid = $this->get_coursework_id();
if (!$courseworkid || ($courseworkid && !mod_coursework\models\coursework::find($courseworkid)->has_samples()) ) {
- $moodle_form->disabledIf('samplingenabled', 'numberofmarkers', 'eq', 1);
+ $moodleform->disabledIf('samplingenabled', 'numberofmarkers', 'eq', 1);
}
}
@@ -1187,21 +1199,21 @@ private function add_enable_sampling_checkbox() {
*/
private function add_view_initial_assessors_grade() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('selectyesno', 'viewinitialgradeenabled', get_string('viewinitialgradeenabled', 'mod_coursework'));
- $moodle_form->addHelpButton('viewinitialgradeenabled', 'viewinitialgradeenabled', 'mod_coursework');
+ $moodleform->addElement('selectyesno', 'viewinitialgradeenabled', get_string('viewinitialgradeenabled', 'mod_coursework'));
+ $moodleform->addHelpButton('viewinitialgradeenabled', 'viewinitialgradeenabled', 'mod_coursework');
- $moodle_form->disabledIf('viewinitialgradeenabled', 'numberofmarkers', 'eq', 1);
+ $moodleform->disabledIf('viewinitialgradeenabled', 'numberofmarkers', 'eq', 1);
}
private function add_enable_agreed_grade_delay() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $options = array('0' => get_string('disabled', 'mod_coursework'));
+ $options = ['0' => get_string('disabled', 'mod_coursework')];
$options['1800'] = get_string('timedminutes', 'mod_coursework', '30');
$options['3600'] = get_string('timedhour', 'mod_coursework', '1');
$options['7200'] = get_string('timedhours', 'mod_coursework', '2');
@@ -1209,11 +1221,11 @@ private function add_enable_agreed_grade_delay() {
$options['43200'] = get_string('timedhours', 'mod_coursework', '12');
$options['86400'] = get_string('aday', 'mod_coursework');
- $moodle_form->addElement('select', 'gradeeditingtime', get_string('gradeeditingtime', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('gradeeditingtime', 'gradeeditingtime', 'mod_coursework');
- $moodle_form->setDefault('gradeeditingtime', $CFG->coursework_grade_editing);
+ $moodleform->addElement('select', 'gradeeditingtime', get_string('gradeeditingtime', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('gradeeditingtime', 'gradeeditingtime', 'mod_coursework');
+ $moodleform->setDefault('gradeeditingtime', $CFG->coursework_grade_editing);
- $moodle_form->disabledIf('gradeeditingtime', 'numberofmarkers', 'eq', 1);
+ $moodleform->disabledIf('gradeeditingtime', 'numberofmarkers', 'eq', 1);
}
@@ -1222,13 +1234,13 @@ private function add_enable_agreed_grade_delay() {
*/
private function add_save_feedback_as_draft() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $options = array(0 => get_string('no'), 1 => get_string('yes'));
+ $options = [0 => get_string('no'), 1 => get_string('yes')];
- $moodle_form->addElement('select', 'draftfeedbackenabled', get_string('savefeedbackasdraft', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('draftfeedbackenabled', 'savefeedbackasdraft', 'mod_coursework');
- $moodle_form->setDefault('draftfeedbackenabled', 1);
+ $moodleform->addElement('select', 'draftfeedbackenabled', get_string('savefeedbackasdraft', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('draftfeedbackenabled', 'savefeedbackasdraft', 'mod_coursework');
+ $moodleform->setDefault('draftfeedbackenabled', 1);
}
@@ -1236,10 +1248,10 @@ private function add_save_feedback_as_draft() {
* @throws coding_exception
*/
private function add_auto_populate_agreed_feedback_comments() {
- $moodle_form =& $this->_form;
- $moodle_form->addElement('selectyesno', 'autopopulatefeedbackcomment', get_string('autopopulatefeedbackcomment', 'mod_coursework'));
- $moodle_form->addHelpButton('autopopulatefeedbackcomment', 'autopopulatefeedbackcomment', 'mod_coursework');
- $moodle_form->disabledIf('autopopulatefeedbackcomment', 'numberofmarkers', 'eq', 1);
+ $moodleform =& $this->_form;
+ $moodleform->addElement('selectyesno', 'autopopulatefeedbackcomment', get_string('autopopulatefeedbackcomment', 'mod_coursework'));
+ $moodleform->addHelpButton('autopopulatefeedbackcomment', 'autopopulatefeedbackcomment', 'mod_coursework');
+ $moodleform->disabledIf('autopopulatefeedbackcomment', 'numberofmarkers', 'eq', 1);
}
private function forceblindmarking() {
@@ -1255,26 +1267,26 @@ private function forceautorelease() {
}
private function add_extensions_header() {
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $moodle_form->addElement('header', 'extensions', get_string('extensions', 'mod_coursework'));
+ $moodleform->addElement('header', 'extensions', get_string('extensions', 'mod_coursework'));
}
private function add_enable_extensions_field() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select', 'extensionsenabled', get_string('individual_extension', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('extensionsenabled', 'individual_extension', 'mod_coursework');
- $moodle_form->setDefault('extensionsenabled', $CFG->coursework_individual_extension);
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select', 'extensionsenabled', get_string('individual_extension', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('extensionsenabled', 'individual_extension', 'mod_coursework');
+ $moodleform->setDefault('extensionsenabled', $CFG->coursework_individual_extension);
}
private function add_submission_notification_field() {
global $COURSE;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
$selectableusers = [];
@@ -1286,16 +1298,16 @@ private function add_submission_notification_field() {
}
}
- $select = $moodle_form->addElement('select', 'submissionnotification', get_string('submissionnotification', 'mod_coursework'), $selectableusers);
+ $select = $moodleform->addElement('select', 'submissionnotification', get_string('submissionnotification', 'mod_coursework'), $selectableusers);
$select->setMultiple(true);
- $moodle_form->disabledIf('submissionnotification', 'deadline[enabled]', 'checked');
+ $moodleform->disabledIf('submissionnotification', 'deadline[enabled]', 'checked');
}
private function add_automatic_agreement_enabled() {
- $options = array('none' => 'none',
+ $options = ['none' => 'none',
'percentage_distance' => 'percentage distance',
- 'average_grade' => 'average grade');
+ 'average_grade' => 'average grade'];
$this->form()->addelement('select',
'automaticagreementstrategy',
get_string('automaticagreementofgrades', 'mod_coursework'),
@@ -1314,9 +1326,9 @@ private function add_automatic_agreement_enabled() {
$this->form()->setDefault('automaticagreementrange', 10);
// rounding of the average grade
- $roundingoptions = array('mid' => get_string('roundmid', 'mod_coursework'),
+ $roundingoptions = ['mid' => get_string('roundmid', 'mod_coursework'),
'up' => get_string('roundup', 'mod_coursework'),
- 'down' => get_string('rounddown', 'mod_coursework'));
+ 'down' => get_string('rounddown', 'mod_coursework')];
$this->form()->addElement('select',
'roundingrule',
@@ -1332,12 +1344,12 @@ private function add_automatic_agreement_enabled() {
private function add_enable_plagiarism_flag_field() {
global $CFG;
- $moodle_form =& $this->_form;
+ $moodleform =& $this->_form;
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $moodle_form->addElement('select', 'plagiarismflagenabled', get_string('plagiarism_flag_enable', 'mod_coursework'), $options);
- $moodle_form->addHelpButton('plagiarismflagenabled', 'plagiarism_flag_enable', 'mod_coursework');
- $moodle_form->setDefault('plagiarismflagenabled', $CFG->coursework_plagiarismflag);
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $moodleform->addElement('select', 'plagiarismflagenabled', get_string('plagiarism_flag_enable', 'mod_coursework'), $options);
+ $moodleform->addHelpButton('plagiarismflagenabled', 'plagiarism_flag_enable', 'mod_coursework');
+ $moodleform->setDefault('plagiarismflagenabled', $CFG->coursework_plagiarismflag);
}
}
diff --git a/renderable.php b/renderable.php
index 374f2fb2..55b68cab 100644
--- a/renderable.php
+++ b/renderable.php
@@ -76,7 +76,8 @@ class mod_coursework_assessor_feedback_table extends mod_coursework_renderable {
/**
* @mixin \mod_coursework\models\coursework
*/
-class mod_coursework_coursework extends mod_coursework_renderable { }
+class mod_coursework_coursework extends mod_coursework_renderable {
+}
/**
* @mixin \mod_coursework\grading_table_row_multi
diff --git a/renderers/grading_report_renderer.php b/renderers/grading_report_renderer.php
index ae5ff26b..5c25160d 100644
--- a/renderers/grading_report_renderer.php
+++ b/renderers/grading_report_renderer.php
@@ -38,43 +38,43 @@ class mod_coursework_grading_report_renderer extends plugin_renderer_base {
/**
* @var
*/
- protected $row_class;
+ protected $rowclass;
/**
* @var
*/
- protected $is_multiple_markers;
+ protected $ismultiplemarkers;
/**
* @param grading_report $grading_report
- * param $is_multiple_markers
+ * param $ismultiplemarkers
* @return string
*/
- public function render_grading_report($grading_report, $is_multiple_markers) {
+ public function render_grading_report($gradingreport, $ismultiplemarkers) {
$langelement = $this->generate_lang_element();
- $options = $grading_report->get_options();
- $tablerows = $grading_report->get_table_rows_for_page();
- $cell_helpers = $grading_report->get_cells_helpers();
- $sub_row_helper = $grading_report->get_sub_row_helper();
- if (count($tablerows) == $grading_report->realtotalrows) {
+ $options = $gradingreport->get_options();
+ $tablerows = $gradingreport->get_table_rows_for_page();
+ $cellhelpers = $gradingreport->get_cells_helpers();
+ $subrowhelper = $gradingreport->get_sub_row_helper();
+ if (count($tablerows) == $gradingreport->realtotalrows) {
$options['class'] = 'full-loaded';
}
- $this->row_class = $is_multiple_markers ? 'submissionrowmulti' : 'submissionrowsingle';
+ $this->rowclass = $ismultiplemarkers ? 'submissionrowmulti' : 'submissionrowsingle';
if (empty($tablerows)) {
return $langelement . ''.get_string('nousers', 'coursework').' ';
}
- $table_html = $this->start_table($options);
- $table_html .= $this->make_table_headers($cell_helpers, $options, $is_multiple_markers);
- $table_html .= '';
- $table_html .= '';
- $table_html .= $this->make_rows($tablerows, $cell_helpers, $sub_row_helper, $is_multiple_markers,);
- $table_html .= '';
- $table_html .= $this->end_table();
+ $tablehtml = $this->start_table($options);
+ $tablehtml .= $this->make_table_headers($cellhelpers, $options, $ismultiplemarkers);
+ $tablehtml .= '';
+ $tablehtml .= '';
+ $tablehtml .= $this->make_rows($tablerows, $cellhelpers, $subrowhelper, $ismultiplemarkers, );
+ $tablehtml .= '';
+ $tablehtml .= $this->end_table();
- return $langelement . $table_html;
+ return $langelement . $tablehtml;
}
/**
@@ -82,18 +82,18 @@ public function render_grading_report($grading_report, $is_multiple_markers) {
* @return mixed
*/
private function generate_lang_element() {
- $lang_messages = [
+ $langmessages = [
'download_submitted_files' => get_string('download_submitted_files', 'mod_coursework'),
'exportfinalgrades' => get_string('exportfinalgrades', 'mod_coursework'),
'exportgradingsheets' => get_string('exportgradingsheets', 'mod_coursework'),
- 'loadingpagination' => get_string('loadingpagination', 'mod_coursework')
+ 'loadingpagination' => get_string('loadingpagination', 'mod_coursework'),
];
- $result = html_writer::empty_tag('input', array(
+ $result = html_writer::empty_tag('input', [
'name' => '',
'type' => 'hidden',
- 'data-lang' => json_encode($lang_messages),
- 'id' => 'element_lang_messages'
- ));
+ 'data-lang' => json_encode($langmessages),
+ 'id' => 'element_lang_messages',
+ ]);
$result = html_writer::div($result);
return $result;
@@ -104,15 +104,15 @@ private function generate_lang_element() {
* @param array $options
* @return string
*/
- protected function make_header_cell($cell_helper, $options) {
+ protected function make_header_cell($cellhelper, $options) {
$seq = empty($options['seq']) ? 0 : $options['seq'];
- $table_html = '';
- return $table_html;
+ $headername = $cellhelper->get_table_header($options);
+ $tablehtml .= $headername;
+ $tablehtml .= $cellhelper->get_table_header_help_icon();
+ $tablehtml .= '';
+ return $tablehtml;
}
/**
@@ -121,47 +121,47 @@ protected function make_header_cell($cell_helper, $options) {
* @param sub_rows_interface $sub_row_helper
* @return string
*/
- protected function make_row_for_allocatable($row_object, $cell_helpers, $sub_row_helper) {
+ protected function make_row_for_allocatable($rowobject, $cellhelpers, $subrowhelper) {
//$class = (!$row_object->get_coursework()->has_multiple_markers()) ? "submissionrowsingle": "submissionrowmulti";
- $class = $this->row_class;
+ $class = $this->rowclass;
- $submission = $row_object->get_submission();
- $allocatable = $row_object->get_allocatable();
+ $submission = $rowobject->get_submission();
+ $allocatable = $rowobject->get_allocatable();
- $table_html = '';
- $is_multiple_markers = $this->is_multiple_markers;
- $tbl_assessor_feedbacks = $sub_row_helper->get_row_with_assessor_feedback_table($row_object, count($cell_helpers));
- if ($is_multiple_markers) {
- $table_html .= ' | ';
+ $tablehtml = ' ';
+ $ismultiplemarkers = $this->ismultiplemarkers;
+ $tblassessorfeedbacks = $subrowhelper->get_row_with_assessor_feedback_table($rowobject, count($cellhelpers));
+ if ($ismultiplemarkers) {
+ $tablehtml .= ' | ';
}
- foreach ($cell_helpers as $cell_helper) {
- $html_td = trim($cell_helper->get_table_cell($row_object));
+ foreach ($cellhelpers as $cellhelper) {
+ $htmltd = trim($cellhelper->get_table_cell($rowobject));
- if ($is_multiple_markers &&
- ($cell_helper instanceof \mod_coursework\render_helpers\grading_report\cells\user_cell ||
- $cell_helper instanceof \mod_coursework\render_helpers\grading_report\cells\group_cell)
+ if ($ismultiplemarkers &&
+ ($cellhelper instanceof \mod_coursework\render_helpers\grading_report\cells\user_cell ||
+ $cellhelper instanceof \mod_coursework\render_helpers\grading_report\cells\group_cell)
) {
- $html_td = str_replace('', $tbl_assessor_feedbacks.'', $html_td);
+ $htmltd = str_replace('', $tblassessorfeedbacks.'', $htmltd);
}
- $table_html .= $html_td;
+ $tablehtml .= $htmltd;
}
- $table_html .= ' ';
+ $tablehtml .= '';
- if (!$is_multiple_markers) {
- $table_html .= $tbl_assessor_feedbacks;
+ if (!$ismultiplemarkers) {
+ $tablehtml .= $tblassessorfeedbacks;
}
- return $table_html;
+ return $tablehtml;
}
/**
* @return string
*/
- public function submissions_header($header_text = '') {
- $submisions = (!empty($header_text)) ? $header_text : get_string('submissions', 'mod_coursework');
+ public function submissions_header($headertext = '') {
+ $submisions = (!empty($headertext)) ? $headertext : get_string('submissions', 'mod_coursework');
return html_writer::tag('h3', $submisions);
}
@@ -171,23 +171,23 @@ public function submissions_header($header_text = '') {
* @param $options
* @return string
*/
- protected function make_table_headers($cell_helpers, $options, $is_multiple_markers) {
+ protected function make_table_headers($cellhelpers, $options, $ismultiplemarkers) {
- $table_html = $this->make_upper_headers($cell_helpers, $is_multiple_markers);
- $table_html .= '';
- $tr_html = '';
+ $tablehtml = $this->make_upper_headers($cellhelpers, $ismultiplemarkers);
+ $tablehtml .= ' ';
+ $trhtml = '';
$i = 0;
- if ($is_multiple_markers) {
- $tr_html .= ' | '; // This is for open or close buttons
+ if ($ismultiplemarkers) {
+ $trhtml .= ' | '; // This is for open or close buttons
++$i;
}
- foreach ($cell_helpers as $cell_helper) {
+ foreach ($cellhelpers as $cellhelper) {
$options['seq'] = $i++;
- $tr_html .= $this->make_header_cell($cell_helper, $options);
+ $trhtml .= $this->make_header_cell($cellhelper, $options);
}
- return $table_html . $tr_html . ' ';
+ return $tablehtml . $trhtml . '';
}
/**
@@ -198,9 +198,9 @@ protected function start_table($options = []) {
$options['class'] = (!empty($options['class'])) ? $options['class'] : '';
$options['class'] .= ' submissions datatabletest display compact';
$options['id'] = 'dt_table';
- $table_html = \html_writer::start_tag('table', $options);
- $table_html .= \html_writer::start_tag('thead');
- return $table_html;
+ $tablehtml = \html_writer::start_tag('table', $options);
+ $tablehtml .= \html_writer::start_tag('thead');
+ return $tablehtml;
}
/**
@@ -216,19 +216,19 @@ protected function end_table() {
* @param $tablerows
* @param $cell_helpers
* @param $sub_row_helper
- * @param $is_multiple_markers
+ * @param $ismultiplemarkers
* @return string
*/
- public function make_rows($tablerows, $cell_helpers, $sub_row_helper, $is_multiple_markers) {
- $table_html = '';
+ public function make_rows($tablerows, $cellhelpers, $subrowhelper, $ismultiplemarkers) {
+ $tablehtml = '';
- $this->row_class = $is_multiple_markers ? 'submissionrowmulti' : 'submissionrowsingle';
- $this->is_multiple_markers = $is_multiple_markers;
+ $this->rowclass = $ismultiplemarkers ? 'submissionrowmulti' : 'submissionrowsingle';
+ $this->ismultiplemarkers = $ismultiplemarkers;
- foreach ($tablerows as $row_object) {
- $table_html .= $this->make_row_for_allocatable($row_object, $cell_helpers, $sub_row_helper);
+ foreach ($tablerows as $rowobject) {
+ $tablehtml .= $this->make_row_for_allocatable($rowobject, $cellhelpers, $subrowhelper);
}
- return $table_html;
+ return $tablehtml;
}
/**
@@ -237,21 +237,21 @@ public function make_rows($tablerows, $cell_helpers, $sub_row_helper, $is_multip
* @param cell_interface[] $cell_helpers
* @return string
*/
- private function make_upper_headers($cell_helpers, $is_multiple_markers) {
+ private function make_upper_headers($cellhelpers, $ismultiplemarkers) {
$html = '';
- $headers = $this->upper_header_names_and_colspans($cell_helpers);
+ $headers = $this->upper_header_names_and_colspans($cellhelpers);
- foreach ($headers as $header_name => $colspan) {
- $colspan_value = $colspan;
+ foreach ($headers as $headername => $colspan) {
+ $colspanvalue = $colspan;
- if ($html == '' && $is_multiple_markers) {
- $colspan_value += 1;
+ if ($html == '' && $ismultiplemarkers) {
+ $colspanvalue += 1;
}
- $html .= '';
- $html .= get_string($header_name.'_table_header', 'mod_coursework');
- $html .= get_string($header_name.'_table_header', 'mod_coursework')
- ? ($this->output->help_icon($header_name.'_table_header', 'mod_coursework')) : '';
+ $html .= ' | ';
+ $html .= get_string($headername.'_table_header', 'mod_coursework');
+ $html .= get_string($headername.'_table_header', 'mod_coursework')
+ ? ($this->output->help_icon($headername.'_table_header', 'mod_coursework')) : '';
$html .= ' | ';
}
@@ -262,10 +262,10 @@ private function make_upper_headers($cell_helpers, $is_multiple_markers) {
* @param cell_interface[] $cell_helpers
* @return mixed
*/
- private function upper_header_names_and_colspans($cell_helpers) {
+ private function upper_header_names_and_colspans($cellhelpers) {
$headers = [];
- foreach ($cell_helpers as $helper) {
+ foreach ($cellhelpers as $helper) {
if (!array_key_exists($helper->header_group(), $headers)) {
$headers[$helper->header_group()] = 1;
} else {
diff --git a/renderers/object_renderer.php b/renderers/object_renderer.php
index 22bfe18c..51080243 100644
--- a/renderers/object_renderer.php
+++ b/renderers/object_renderer.php
@@ -80,93 +80,93 @@ public function render_feedback(feedback $feedback) {
$table->head[] = $header;
// Assessor who gave this feedback.
- $table_row = new html_table_row();
- $table_row->cells['left'] = get_string('assessor', 'mod_coursework');
+ $tablerow = new html_table_row();
+ $tablerow->cells['left'] = get_string('assessor', 'mod_coursework');
if (!has_capability('mod/coursework:submit', $coursework->get_context()) || is_siteadmin($USER->id) ) {
- $table_row->cells['right'] = $feedback->get_assesor_username();
+ $tablerow->cells['right'] = $feedback->get_assesor_username();
} else {
if ((!$submission->get_coursework()->sampling_enabled() || $submission->sampled_feedback_exists()) && $feedback->assessorid == 0 && $feedback->timecreated == $feedback->timemodified) {
- $table_row->cells['right'] = get_string('automaticagreement', 'mod_coursework');
+ $tablerow->cells['right'] = get_string('automaticagreement', 'mod_coursework');
} else {
- $table_row->cells['right'] = $feedback->display_assessor_name();
+ $tablerow->cells['right'] = $feedback->display_assessor_name();
}
}
- $table->data[] = $table_row;
+ $table->data[] = $tablerow;
// Grade row.
- $table_row = new html_table_row();
+ $tablerow = new html_table_row();
- $left_cell = new html_table_cell();
- $right_cell = new html_table_cell();
+ $leftcell = new html_table_cell();
+ $rightcell = new html_table_cell();
$nameforgrade = get_string('provisionalgrade', 'mod_coursework');
- $left_cell->text = $nameforgrade;
+ $leftcell->text = $nameforgrade;
// For final feedback, students should see the moderated grade, not the one awarded by the final grader.
- $grade_judge = new grade_judge($coursework);
- $right_cell->text = $grade_judge->grade_to_display($feedback->get_grade());
- $right_cell->id = 'final_feedback_grade';
+ $gradejudge = new grade_judge($coursework);
+ $rightcell->text = $gradejudge->grade_to_display($feedback->get_grade());
+ $rightcell->id = 'final_feedback_grade';
- $table_row->cells['left'] = $left_cell;
- $table_row->cells['right'] = $right_cell;
- $table->data[] = $table_row;
+ $tablerow->cells['left'] = $leftcell;
+ $tablerow->cells['right'] = $rightcell;
+ $table->data[] = $tablerow;
// Feedback comment.
$comment = $feedback->feedbackcomment;
- $table_row = new html_table_row();
- $left_cell = new html_table_cell();
- $right_cell = new html_table_cell();
+ $tablerow = new html_table_row();
+ $leftcell = new html_table_cell();
+ $rightcell = new html_table_cell();
- $left_cell->text = get_string('feedbackcomment', 'mod_coursework');
- $right_cell->text = $comment;
- $right_cell->id = 'final_feedback_comment';
+ $leftcell->text = get_string('feedbackcomment', 'mod_coursework');
+ $rightcell->text = $comment;
+ $rightcell->id = 'final_feedback_comment';
- $table_row->cells['left'] = $left_cell;
- $table_row->cells['right'] = $right_cell;
- $table->data[] = $table_row;
+ $tablerow->cells['left'] = $leftcell;
+ $tablerow->cells['right'] = $rightcell;
+ $table->data[] = $tablerow;
- $table_row = new html_table_row();
- $left_cell = new html_table_cell();
- $right_cell = new html_table_cell();
+ $tablerow = new html_table_row();
+ $leftcell = new html_table_cell();
+ $rightcell = new html_table_cell();
$files = $feedback->get_feedback_files();
if ($files) {
- $left_cell->text = get_string('feedbackfiles', 'mod_coursework');
- $right_cell->text = $this->render_feedback_files(new mod_coursework_feedback_files($files));
- $right_cell->id = 'final_feedback_files';
+ $leftcell->text = get_string('feedbackfiles', 'mod_coursework');
+ $rightcell->text = $this->render_feedback_files(new mod_coursework_feedback_files($files));
+ $rightcell->id = 'final_feedback_files';
- $table_row->cells['left'] = $left_cell;
- $table_row->cells['right'] = $right_cell;
- $table->data[] = $table_row;
+ $tablerow->cells['left'] = $leftcell;
+ $tablerow->cells['right'] = $rightcell;
+ $table->data[] = $tablerow;
}
// Rubric stuff if it's there
- if ($coursework->is_using_advanced_grading() && ($coursework->finalstagegrading ==0 || ($coursework->finalstagegrading ==1 && $feedback->stage_identifier != 'final_agreed_1'))) {
- $table_row = new html_table_row();
- $left_cell = new html_table_cell();
- $right_cell = new html_table_cell();
+ if ($coursework->is_using_advanced_grading() && ($coursework->finalstagegrading == 0 || ($coursework->finalstagegrading == 1 && $feedback->stage_identifier != 'final_agreed_1'))) {
+ $tablerow = new html_table_row();
+ $leftcell = new html_table_cell();
+ $rightcell = new html_table_cell();
$controller = $coursework->get_advanced_grading_active_controller();
- $left_cell->text = 'Advanced grading';
- $right_cell->text = $controller->render_grade($this->page, $feedback->id, null, '', false);
+ $leftcell->text = 'Advanced grading';
+ $rightcell->text = $controller->render_grade($this->page, $feedback->id, null, '', false);
- $table_row->cells['left'] = $left_cell;
- $table_row->cells['right'] = $right_cell;
- $table->data[] = $table_row;
+ $tablerow->cells['left'] = $leftcell;
+ $tablerow->cells['right'] = $rightcell;
+ $table->data[] = $tablerow;
}
$out .= html_writer::table($table);
// It seems html_table doesn't support colgroup, so manually add it here
$colgroup = '';
- $to_replace = '';
- $pos = strrpos($out, $to_replace);
+ $toreplace = '';
+ $pos = strrpos($out, $toreplace);
- $out = substr_replace($out, $colgroup . $to_replace, $pos, strlen($to_replace));
+ $out = substr_replace($out, $colgroup . $toreplace, $pos, strlen($toreplace));
return $out;
}
@@ -195,53 +195,53 @@ public function render_moderation(moderation $moderation) {
$table->head[] = $header;
// Moderated by
- $table_row = new html_table_row();
- $left_cell = new html_table_cell();
- $right_cell = new html_table_cell();
- $left_cell->text = get_string('moderatedby', 'coursework' );
- $right_cell->text = $moderatedby;
- $right_cell->id = 'moderation_moderatedby';
+ $tablerow = new html_table_row();
+ $leftcell = new html_table_cell();
+ $rightcell = new html_table_cell();
+ $leftcell->text = get_string('moderatedby', 'coursework' );
+ $rightcell->text = $moderatedby;
+ $rightcell->id = 'moderation_moderatedby';
- $table_row->cells['left'] = $left_cell;
- $table_row->cells['right'] = $right_cell;
- $table->data[] = $table_row;
+ $tablerow->cells['left'] = $leftcell;
+ $tablerow->cells['right'] = $rightcell;
+ $table->data[] = $tablerow;
// Last edited by
- $table_row = new html_table_row();
- $left_cell = new html_table_cell();
- $right_cell = new html_table_cell();
- $left_cell->text = get_string('lasteditedby', 'coursework');
- $right_cell->text = $lasteditedby . ' on ' .
+ $tablerow = new html_table_row();
+ $leftcell = new html_table_cell();
+ $rightcell = new html_table_cell();
+ $leftcell->text = get_string('lasteditedby', 'coursework');
+ $rightcell->text = $lasteditedby . ' on ' .
userdate($moderation->timemodified, '%a, %d %b %Y, %H:%M');
- $right_cell->id = 'moderation_lasteditedby';
+ $rightcell->id = 'moderation_lasteditedby';
- $table_row->cells['left'] = $left_cell;
- $table_row->cells['right'] = $right_cell;
- $table->data[] = $table_row;
+ $tablerow->cells['left'] = $leftcell;
+ $tablerow->cells['right'] = $rightcell;
+ $table->data[] = $tablerow;
// Moderation agreement
- $table_row = new html_table_row();
- $left_cell = new html_table_cell();
- $right_cell = new html_table_cell();
- $left_cell->text = get_string('moderationagreement', 'coursework');
- $right_cell->text = get_string($moderation->agreement, 'coursework');
- $right_cell->id = 'moderation_agreement';
+ $tablerow = new html_table_row();
+ $leftcell = new html_table_cell();
+ $rightcell = new html_table_cell();
+ $leftcell->text = get_string('moderationagreement', 'coursework');
+ $rightcell->text = get_string($moderation->agreement, 'coursework');
+ $rightcell->id = 'moderation_agreement';
- $table_row->cells['left'] = $left_cell;
- $table_row->cells['right'] = $right_cell;
- $table->data[] = $table_row;
+ $tablerow->cells['left'] = $leftcell;
+ $tablerow->cells['right'] = $rightcell;
+ $table->data[] = $tablerow;
// Moderation comment
- $table_row = new html_table_row();
- $left_cell = new html_table_cell();
- $right_cell = new html_table_cell();
- $left_cell->text = get_string('comment', 'mod_coursework');
- $right_cell->text = $moderation->modcomment;
- $right_cell->id = 'moderation_comment';
+ $tablerow = new html_table_row();
+ $leftcell = new html_table_cell();
+ $rightcell = new html_table_cell();
+ $leftcell->text = get_string('comment', 'mod_coursework');
+ $rightcell->text = $moderation->modcomment;
+ $rightcell->id = 'moderation_comment';
- $table_row->cells['left'] = $left_cell;
- $table_row->cells['right'] = $right_cell;
- $table->data[] = $table_row;
+ $tablerow->cells['left'] = $leftcell;
+ $tablerow->cells['right'] = $rightcell;
+ $table->data[] = $tablerow;
$out .= html_writer::table($table);
@@ -276,7 +276,7 @@ protected function render_mod_coursework_assessor_feedback_row(mod_coursework_as
$row->attributes['class'] =
"feedback-{$feedbackrow->get_assessor_id()}-{$feedbackrow->get_allocatable()->id()} {$feedbackrow->get_stage()->identifier()}";
- $existing_feedback = $feedbackrow->get_feedback();
+ $existingfeedback = $feedbackrow->get_feedback();
// Assessor cell: name, image and edit link.
@@ -285,8 +285,8 @@ protected function render_mod_coursework_assessor_feedback_row(mod_coursework_as
$cell->text = $assessor->picture();
$cell->text .= ' ';
- $profilelinkurl = new moodle_url('/user/profile.php', array('id' => $assessor->id(),
- 'course' => $COURSE->id));
+ $profilelinkurl = new moodle_url('/user/profile.php', ['id' => $assessor->id(),
+ 'course' => $COURSE->id]);
$cell->text .= html_writer::link($profilelinkurl, $assessor->name());
$row->cells['assessor'] = $cell;
@@ -297,51 +297,51 @@ protected function render_mod_coursework_assessor_feedback_row(mod_coursework_as
$cell->text = 'asdadas';
// Edit feedback link.
$submission = $feedbackrow->get_submission();
- $new_feedback = false;
- if (empty($existing_feedback)) {
- $params = array(
+ $newfeedback = false;
+ if (empty($existingfeedback)) {
+ $params = [
'assessorid' => $assessor->id(),
'stage_identifier' => $feedbackrow->get_stage()->identifier(),
- );
+ ];
if ($submission) {
$params['submissionid'] = $submission->id;
}
- $new_feedback = feedback::build($params);
+ $newfeedback = feedback::build($params);
}
$ability = new ability(user::find($USER), $feedbackrow->get_coursework());
- if ($existing_feedback && $ability->can('edit', $existing_feedback)) {
+ if ($existingfeedback && $ability->can('edit', $existingfeedback)) {
$linktitle = get_string('edit');
- $icon = new pix_icon('edit', $linktitle, 'coursework', array('width' => '20px'));
- $link_id = "edit_feedback_" . $feedbackrow->get_feedback()->id;
- $link = $this->get_router()->get_path('edit feedback', array('feedback' => $feedbackrow->get_feedback()));
- $iconlink = $this->output->action_icon($link, $icon, null, array('id' => $link_id));
+ $icon = new pix_icon('edit', $linktitle, 'coursework', ['width' => '20px']);
+ $linkid = "edit_feedback_" . $feedbackrow->get_feedback()->id;
+ $link = $this->get_router()->get_path('edit feedback', ['feedback' => $feedbackrow->get_feedback()]);
+ $iconlink = $this->output->action_icon($link, $icon, null, ['id' => $linkid]);
$cell->text .= $iconlink;
- } else if ($new_feedback && $ability->can('new', $new_feedback)) {
+ } else if ($newfeedback && $ability->can('new', $newfeedback)) {
// New
$linktitle = "new_feedback";
- $icon = new pix_icon('edit', $linktitle, 'coursework', array('width' => '20px'));
+ $icon = new pix_icon('edit', $linktitle, 'coursework', ['width' => '20px']);
- $new_feedback_params = array(
+ $newfeedbackparams = [
'submission' => $feedbackrow->get_submission(),
'assessor' => $feedbackrow->get_assessor(),
- 'stage' => $feedbackrow->get_stage()
- );
- $link = $this->get_router()->get_path('new feedback', $new_feedback_params);
- $iconlink = $this->output->action_icon($link, $icon, null, array('class' => "new_feedback"));
+ 'stage' => $feedbackrow->get_stage(),
+ ];
+ $link = $this->get_router()->get_path('new feedback', $newfeedbackparams);
+ $iconlink = $this->output->action_icon($link, $icon, null, ['class' => "new_feedback"]);
$cell->text .= $iconlink;
- } else if ($existing_feedback && $ability->can('show', $existing_feedback)) {
+ } else if ($existingfeedback && $ability->can('show', $existingfeedback)) {
// Show - for managers and others who are reviewing the grades but who should
// not be able to change them.
$linktitle = get_string('viewfeedback', 'mod_coursework');
- $icon = new pix_icon('show', $linktitle, 'coursework', array('width' => '20px'));
- $link_id = "show_feedback_" . $feedbackrow->get_feedback()->id;
- $link = $this->get_router()->get_path('show feedback', array('feedback' => $feedbackrow->get_feedback()));
- $iconlink = $this->output->action_icon($link, $icon, null, array('id' => $link_id));
+ $icon = new pix_icon('show', $linktitle, 'coursework', ['width' => '20px']);
+ $linkid = "show_feedback_" . $feedbackrow->get_feedback()->id;
+ $link = $this->get_router()->get_path('show feedback', ['feedback' => $feedbackrow->get_feedback()]);
+ $iconlink = $this->output->action_icon($link, $icon, null, ['id' => $linkid]);
$cell->text .= $iconlink;
}
@@ -374,15 +374,15 @@ protected function render_mod_coursework_assessor_feedback_row(mod_coursework_as
*/
public function render_submission_files(mod_coursework_submission_files $files) {
- $submission_files = $files->get_files();
- $files_array = [];
+ $submissionfiles = $files->get_files();
+ $filesarray = [];
- foreach ($submission_files as $file) {
- $files_array[] = $this->make_file_link($files, $file);
+ foreach ($submissionfiles as $file) {
+ $filesarray[] = $this->make_file_link($files, $file);
}
$br = html_writer::empty_tag('br');
- $out = implode($br, $files_array);
+ $out = implode($br, $filesarray);
return $out;
}
@@ -394,14 +394,14 @@ public function render_submission_files(mod_coursework_submission_files $files)
public function render_feedback_files(mod_coursework_feedback_files $files) {
- $files_array = [];
- $submission_files = $files->get_files();
- foreach ($submission_files as $file) {
- $files_array[] = $this->make_file_link($files, $file, 'feedbackfile');
+ $filesarray = [];
+ $submissionfiles = $files->get_files();
+ foreach ($submissionfiles as $file) {
+ $filesarray[] = $this->make_file_link($files, $file, 'feedbackfile');
}
$br = html_writer::empty_tag('br');
- $out = implode($br, $files_array);
+ $out = implode($br, $filesarray);
return $out;
}
@@ -413,18 +413,18 @@ public function render_feedback_files(mod_coursework_feedback_files $files) {
* @param bool $with_resubmit_button
* @return string
*/
- public function render_submission_files_with_plagiarism_links(mod_coursework_submission_files $files, $with_resubmit_button = true) {
+ public function render_submission_files_with_plagiarism_links(mod_coursework_submission_files $files, $withresubmitbutton = true) {
global $USER;
$ability = new ability(user::find($USER), $files->get_coursework());
$coursework = $files->get_coursework();
- $submission_files = $files->get_files();
+ $submissionfiles = $files->get_files();
$submission = $files->get_submission();
- $files_array = [];
+ $filesarray = [];
- foreach ($submission_files as $file) {
+ foreach ($submissionfiles as $file) {
$link = $this->make_file_link($files, $file);
@@ -433,15 +433,15 @@ public function render_submission_files_with_plagiarism_links(mod_coursework_sub
$link .= ''. $this->render_file_plagiarism_information($file, $coursework, $submission).' ';
}
- if ($with_resubmit_button) {
+ if ($withresubmitbutton) {
$link .= ''. $this->render_resubmit_to_plagiarism_button($coursework, $submission).' ';
}
- $files_array[] = $link;
+ $filesarray[] = $link;
}
$br = html_writer::empty_tag('br');
- $out = implode($br, $files_array);
+ $out = implode($br, $filesarray);
return $out;
}
@@ -459,11 +459,11 @@ public function render_plagiarism_links($files) {
$ability = new ability(user::find($USER), $files->get_coursework());
$coursework = $files->get_coursework();
- $submission_files = $files->get_files();
+ $submissionfiles = $files->get_files();
$submission = $files->get_submission();
- $files_array = [];
+ $filesarray = [];
- foreach ($submission_files as $file) {
+ foreach ($submissionfiles as $file) {
$link = '';
@@ -472,11 +472,11 @@ public function render_plagiarism_links($files) {
$link = $this->render_file_plagiarism_information($file, $coursework, $submission);
}
- $files_array[] = $link;
+ $filesarray[] = $link;
}
$br = html_writer::empty_tag('br');
- $out = implode($br, $files_array);
+ $out = implode($br, $filesarray);
return $out;
}
@@ -516,15 +516,15 @@ protected function render_mod_coursework_coursework(mod_coursework_coursework $c
$cangrade = has_capability('mod/coursework:addinitialgrade', $this->page->context);
$canpublish = has_capability('mod/coursework:publish', $this->page->context);
- $is_published = $coursework->user_grade_is_published($USER->id);
- $allowed_to_add_general_feedback = has_capability('mod/coursework:addgeneralfeedback', $coursework->get_context());
+ $ispublished = $coursework->user_grade_is_published($USER->id);
+ $allowedtoaddgeneralfeedback = has_capability('mod/coursework:addgeneralfeedback', $coursework->get_context());
$canaddgeneralfeedback = has_capability('mod/coursework:addgeneralfeedback', $this->page->context);
$out .= html_writer::tag('h3', get_string('gradingsummary', 'coursework'));
$out .= $this->coursework_grading_summary_table($coursework);
// Show general feedback if it's there and the deadline has passed or general feedback's date is not enabled which means it should be displayed automatically
- if (($coursework->is_general_feedback_enabled() && $allowed_to_add_general_feedback && (time() > $coursework->generalfeedback || $cangrade || $canpublish || $is_published)) || !$coursework->is_general_feedback_enabled()) {
+ if (($coursework->is_general_feedback_enabled() && $allowedtoaddgeneralfeedback && (time() > $coursework->generalfeedback || $cangrade || $canpublish || $ispublished)) || !$coursework->is_general_feedback_enabled()) {
$out .= html_writer::tag('h3', get_string('generalfeedback', 'coursework'));
$out .= $coursework->feedbackcomment
? html_writer::tag('p', $coursework->feedbackcomment)
@@ -534,12 +534,12 @@ protected function render_mod_coursework_coursework(mod_coursework_coursework $c
if ($canaddgeneralfeedback) {
$title = ($coursework->feedbackcomment) ? get_string('editgeneralfeedback', 'coursework') : get_string('addgeneralfeedback', 'coursework');
$class = ($coursework->feedbackcomment) ? 'edit-btn' : 'add-general_feedback-btn';
- $out .= html_writer::tag('p', '', array('id' => 'feedback_text'));
+ $out .= html_writer::tag('p', '', ['id' => 'feedback_text']);
$link = new moodle_url('/mod/coursework/actions/general_feedback.php',
- array('cmid' => $coursework->get_coursemodule_id()));
+ ['cmid' => $coursework->get_coursemodule_id()]);
$out .= html_writer::link($link,
$title,
- array('class' => $class));
+ ['class' => $class]);
$out .= html_writer::empty_tag('br');
$out .= html_writer::empty_tag('br');
}
@@ -554,13 +554,13 @@ protected function render_mod_coursework_coursework(mod_coursework_coursework $c
* @param mod_coursework_allocation_table $allocation_table
* @return string
*/
- protected function render_mod_coursework_allocation_table(mod_coursework_allocation_table $allocation_table) {
+ protected function render_mod_coursework_allocation_table(mod_coursework_allocation_table $allocationtable) {
global $SESSION;
- $table_html = $allocation_table->get_hidden_elements();
+ $tablehtml = $allocationtable->get_hidden_elements();
- $table_html .= '
+ $tablehtml .= '
@@ -568,92 +568,92 @@ protected function render_mod_coursework_allocation_table(mod_coursework_allocat
';
- $options = $allocation_table->get_options();
+ $options = $allocationtable->get_options();
- $paging_bar = new paging_bar($allocation_table->get_participant_count(), $options['page'], $options['perpage'],
+ $pagingbar = new paging_bar($allocationtable->get_participant_count(), $options['page'], $options['perpage'],
$this->page->url, 'page');
- $all = count($allocation_table->get_coursework()->get_allocatables());
+ $all = count($allocationtable->get_coursework()->get_allocatables());
- $records_per_page = array(3 => 3,
+ $recordsperpage = [3 => 3,
10 => 10,
20 => 20,
30 => 30,
40 => 40,
50 => 50,
100 => 100,
- $all => get_string('all', 'mod_coursework')); // for boost themes instead of 'all' we can put 0, however currently it is a bug
+ $all => get_string('all', 'mod_coursework')]; // for boost themes instead of 'all' we can put 0, however currently it is a bug
// Commenting these out as they appear unused and are causing exception in behat test.
// $single_select_params = compact('sortby', 'sorthow', 'page');
// $single_select_params['page'] = '0';
- $select = new single_select($this->page->url, 'per_page', $records_per_page, $options['perpage'], null);
+ $select = new single_select($this->page->url, 'per_page', $recordsperpage, $options['perpage'], null);
$select->label = get_string('records_per_page', 'coursework');
$select->class = 'jumpmenu';
$select->formid = 'sectionmenu';
- $table_html .= $this->output->render($select);
+ $tablehtml .= $this->output->render($select);
// Get the hidden elements used for assessors and moderators selected on other pages;
- $allocatable_cell_helper = $allocation_table->get_allocatable_cell();
- $table_html .= '';
- $table_html .= $allocatable_cell_helper->get_table_header($allocation_table->get_options());
- $table_html .= ' | ';
+ $allocatablecellhelper = $allocationtable->get_allocatable_cell();
+ $tablehtml .= '';
+ $tablehtml .= $allocatablecellhelper->get_table_header($allocationtable->get_options());
+ $tablehtml .= ' | ';
$no = 0;
- foreach ($allocation_table->marking_stages() as $stage) {
+ foreach ($allocationtable->marking_stages() as $stage) {
if ($stage->uses_allocation()) {
- $table_html .= '';
+ $tablehtml .= ' | ';
// pin all checkbox
- $checkbox_title = get_string('selectalltopin', 'coursework');
+ $checkboxtitle = get_string('selectalltopin', 'coursework');
if ($stage->allocation_table_header() == 'Assessor') {
$no++;
if ($stage->stage_has_allocation() ) {// has any pins
- $table_html .= '';
+ $tablehtml .= '';
}
- $table_html .= $stage->allocation_table_header() . ' ' . $no;
- } else if ($allocation_table->get_coursework()->moderation_agreement_enabled()) {
+ $tablehtml .= $stage->allocation_table_header() . ' ' . $no;
+ } else if ($allocationtable->get_coursework()->moderation_agreement_enabled()) {
//moderator header
if ($stage->stage_has_allocation() ) {// has any pins
- $table_html .= '';
+ $tablehtml .= '';
}
- $table_html .= get_string('moderator', 'coursework');
+ $tablehtml .= get_string('moderator', 'coursework');
} else {
- $table_html .= $stage->allocation_table_header();
+ $tablehtml .= $stage->allocation_table_header();
}
- $table_html .= ' | ';
+ $tablehtml .= '';
}
}
- $table_html .= '
+ $tablehtml .= '
';
- $rowdata = $allocation_table->get_table_rows_for_page();
+ $rowdata = $allocationtable->get_table_rows_for_page();
foreach ($rowdata as $row) {
- $table_html .= $this->render_allocation_table_row($row);
+ $tablehtml .= $this->render_allocation_table_row($row);
}
- $table_html .= '
+ $tablehtml .= '
';
// Form save button.
- $attributes = array('name' => 'save',
+ $attributes = ['name' => 'save',
'type' => 'submit',
'id' => 'save_manual_allocations_1',
- 'value' => get_string('save', 'mod_coursework'));
- $table_html .= html_writer::empty_tag('input', $attributes);
+ 'value' => get_string('save', 'mod_coursework')];
+ $tablehtml .= html_writer::empty_tag('input', $attributes);
- $table_html .= $this->output->render($select);
+ $tablehtml .= $this->output->render($select);
- $table_html .= $this->page->get_renderer('mod_coursework', 'object')->render($paging_bar);
+ $tablehtml .= $this->page->get_renderer('mod_coursework', 'object')->render($pagingbar);
- return $table_html;
+ return $tablehtml;
}
/**
@@ -664,20 +664,20 @@ protected function render_mod_coursework_allocation_table(mod_coursework_allocat
* @param mod_coursework_allocation_table_row $allocation_row
* @return \html_table_row
*/
- protected function render_mod_coursework_allocation_table_row(mod_coursework_allocation_table_row $allocation_row) {
+ protected function render_mod_coursework_allocation_table_row(mod_coursework_allocation_table_row $allocationrow) {
$row = new html_table_row();
- $row->id = $allocation_row->get_allocatable()->type().'_'.$allocation_row->get_allocatable()->id();
+ $row->id = $allocationrow->get_allocatable()->type().'_'.$allocationrow->get_allocatable()->id();
- $allocatable_cell_helper = $allocation_row->get_allocatable_cell();
+ $allocatablecellhelper = $allocationrow->get_allocatable_cell();
- $allocatable_cell = $allocatable_cell_helper->get_table_cell($allocation_row);
- $row->cells['allocatable'] = $allocatable_cell;
+ $allocatablecell = $allocatablecellhelper->get_table_cell($allocationrow);
+ $row->cells['allocatable'] = $allocatablecell;
- $stages = $allocation_row->marking_stages();
+ $stages = $allocationrow->marking_stages();
foreach ($stages as $stage) {
- $row->cells[$stage->identifier()] = $stage->get_allocation_table_cell($allocation_row->get_allocatable());
+ $row->cells[$stage->identifier()] = $stage->get_allocation_table_cell($allocationrow->get_allocatable());
}
return $row;
@@ -691,12 +691,12 @@ protected function render_mod_coursework_allocation_table_row(mod_coursework_all
* @return string
*/
public function render_mod_coursework_allocation_widget(mod_coursework_allocation_widget $allocationwidget) {
- $lang_str = ($allocationwidget->get_coursework()->moderation_agreement_enabled()) ? 'allocateassessorsandmoderators' : 'allocateassessors';
- $html = html_writer::tag('h2', get_string($lang_str, 'mod_coursework'));
+ $langstr = ($allocationwidget->get_coursework()->moderation_agreement_enabled()) ? 'allocateassessorsandmoderators' : 'allocateassessors';
+ $html = html_writer::tag('h2', get_string($langstr, 'mod_coursework'));
$html .= '';
- $html .= html_writer::start_tag('h3', array('id' => 'assessor_allocation_settings_header'));
+ $html .= html_writer::start_tag('h3', ['id' => 'assessor_allocation_settings_header']);
$html .= get_string('assessorallocationstrategy', 'mod_coursework');
//$html .= $this->output->help_icon('allocationstrategy', 'mod_coursework');
$html .= html_writer::end_tag('h3');
@@ -712,30 +712,30 @@ public function render_mod_coursework_allocation_widget(mod_coursework_allocatio
'');
// We want to allow the allocation strategy to add configuration options.
- $html .= html_writer::start_tag('div', array('class' => 'assessor-strategy-options-configs'));
+ $html .= html_writer::start_tag('div', ['class' => 'assessor-strategy-options-configs']);
$html .= $this->get_allocation_strategy_form_elements($allocationwidget->get_coursework());
$html .= html_writer::end_tag('div');
$html .= " ";
- $attributes = array('id' => 'coursework_input_buttons');
+ $attributes = ['id' => 'coursework_input_buttons'];
$html .= html_writer::start_tag('div', $attributes);
// Spacer so we get the button underneath the form stuff.
- $attributes = array('class' => 'coursework_spacer');
+ $attributes = ['class' => 'coursework_spacer'];
$html .= html_writer::start_tag('div', $attributes);
$html .= html_writer::end_tag('div');
// Save button.
- $attributes = array('name' => 'save',
+ $attributes = ['name' => 'save',
'type' => 'submit',
'id' => 'save_assessor_allocation_strategy',
'class' => 'coursework_assessor_allocation',
- 'value' => get_string('apply', 'mod_coursework'));
+ 'value' => get_string('apply', 'mod_coursework')];
$html .= html_writer::empty_tag('input', $attributes);
- $attributes = array('name' => 'saveandexit',
+ $attributes = ['name' => 'saveandexit',
'type' => 'submit',
'id' => 'save_and_exit_assessor_allocation_strategy',
'class' => 'coursework_assessor_allocation',
- 'value' => get_string('save_and_exit', 'mod_coursework'));
+ 'value' => get_string('save_and_exit', 'mod_coursework')];
$html .= html_writer::empty_tag('input', $attributes);
$html .= html_writer::end_tag('div');
$html .= ' ';
@@ -757,17 +757,17 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin
$html = html_writer::tag('h2', get_string('sampling', 'mod_coursework'));
- $html .= html_writer::start_tag('div', array('class' => 'assessor-sampling-wrapper accordion'));
+ $html .= html_writer::start_tag('div', ['class' => 'assessor-sampling-wrapper accordion']);
- $html .= html_writer::start_tag('h3', array('id' => 'sampling_strategy_settings_header'));
+ $html .= html_writer::start_tag('h3', ['id' => 'sampling_strategy_settings_header']);
$html .= get_string('samplingstrategy', 'mod_coursework');
$html .= html_writer::end_tag('h3');
- $html .= html_writer::start_tag('div', array('class' => 'sampling-rules'));
+ $html .= html_writer::start_tag('div', ['class' => 'sampling-rules']);
// We want to allow the allocation strategy to add configuration options.
- $html .= html_writer::start_tag('div', array('class' => 'sampling-select'));
+ $html .= html_writer::start_tag('div', ['class' => 'sampling-select']);
$script = "
var samplingValidateHdl = [];
@@ -777,7 +777,7 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin
$table = new html_table();
$table->attributes['class'] = 'sampling';
- $table->head = array('');
+ $table->head = [''];
$assessorheaders = [];
@@ -787,33 +787,33 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin
$scale = "";
- if ($samplingwidget->get_coursework()->grade > 0) {
+ if ($samplingwidget->get_coursework()->grade > 0) {
$comma = "";
- for ($i = 0; $i <= $samplingwidget->get_coursework()->grade; $i++) {
- $scale .= $comma.$i;
- $comma = ",";
- }
+ for ($i = 0; $i <= $samplingwidget->get_coursework()->grade; $i++) {
+ $scale .= $comma.$i;
+ $comma = ",";
+ }
} else {
- $grade_scale = \grade_scale::fetch(array('id' => abs($samplingwidget->get_coursework()->grade)));
- $scale = $grade_scale->scale;
+ $gradescale = \grade_scale::fetch(['id' => abs($samplingwidget->get_coursework()->grade)]);
+ $scale = $gradescale->scale;
}
$html .= "";
$table->head = $assessorheaders;
- $assessor1cell = html_writer::start_tag('div', array('class' => 'samples_strategy'));
+ $assessor1cell = html_writer::start_tag('div', ['class' => 'samples_strategy']);
$assessor1cell .= get_string('assessoronedefault', 'mod_coursework');
$assessor1cell .= html_writer::end_tag('div');
- $columndata = array(new html_table_cell($assessor1cell));
+ $columndata = [new html_table_cell($assessor1cell)];
- $percentage_options = [];
+ $percentageoptions = [];
- for ($i = 0;$i < 110; $i = $i + 10) {
- $percentage_options[$i] = "{$i}%";
+ for ($i = 0; $i < 110; $i = $i + 10) {
+ $percentageoptions[$i] = "{$i}%";
}
$javascript = false;
@@ -822,24 +822,26 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin
// Create the secon
- $sampling_strategies = array('0' => get_string('sampling_manual', 'mod_coursework'),
- '1' => get_string('sampling_automatic', 'mod_coursework'));
+ $samplingstrategies = ['0' => get_string('sampling_manual', 'mod_coursework'),
+ '1' => get_string('sampling_automatic', 'mod_coursework')];
// Check whether any rules have been saved for this stage
$selected = ($samplingwidget->get_coursework()->has_automatic_sampling_at_stage('assessor_'.$i)) ? '1' : false;
- $sampling_cell = html_writer::start_tag('div', array('class' => 'samples_strategy'));
- $sampling_cell .= html_writer::label(get_string('sampletype', 'mod_coursework'), "assessor_{$i}_samplingstrategy");
+ $samplingcell = html_writer::start_tag('div', ['class' => 'samples_strategy']);
+ $samplingcell .= html_writer::label(get_string('sampletype', 'mod_coursework'), "assessor_{$i}_samplingstrategy");
- $sampling_cell .= html_writer::select($sampling_strategies,
+ $samplingcell .= html_writer::select($samplingstrategies,
"assessor_{$i}_samplingstrategy",
$selected,
false,
- array('id' => "assessor_{$i}_samplingstrategy", 'class' => "assessor_sampling_strategy sampling_strategy_detail"));
+ ['id' => "assessor_{$i}_samplingstrategy", 'class' => "assessor_sampling_strategy sampling_strategy_detail"]);
- $sampling_cell .= html_writer::end_tag('div');
+ $samplingcell .= html_writer::end_tag('div');
- if ($i == $samplingwidget->get_coursework()->get_max_markers()) $javascript = true;
+ if ($i == $samplingwidget->get_coursework()->get_max_markers()) {
+ $javascript = true;
+ }
$graderules =
@@ -849,9 +851,9 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin
$graderules .= $this->get_sampling_strategy_form_elements($samplingwidget->get_coursework(), $i, $javascript);
- $sampling_cell .= html_writer::div($graderules, '', array('id' => "assessor_{$i}_automatic_rules"));
+ $samplingcell .= html_writer::div($graderules, '', ['id' => "assessor_{$i}_automatic_rules"]);
- $columndata[] = new html_table_cell($sampling_cell);
+ $columndata[] = new html_table_cell($samplingcell);
}
$table->data[] = $columndata;
@@ -861,10 +863,10 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin
$html .= html_writer::table($table);
// End the form with save button.
- $attributes = array('name' => 'save_sampling',
+ $attributes = ['name' => 'save_sampling',
'type' => 'submit',
'id' => 'save_manual_sampling',
- 'value' => get_string('save', 'mod_coursework'));
+ 'value' => get_string('save', 'mod_coursework')];
$html .= html_writer::empty_tag('input', $attributes);
/**
@@ -903,74 +905,74 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin
private function sampling_strategy_column($samplingwidget, $suffix = '') {
- $percentage_options = [];
+ $percentageoptions = [];
- for ($i = 0;$i < 110; $i = $i + 10) {
- $percentage_options[$i] = "{$i}%";
+ for ($i = 0; $i < 110; $i = $i + 10) {
+ $percentageoptions[$i] = "{$i}%";
}
// Hidden input containing scale values
$scale = [];
- $sampling_column = "";
+ $samplingcolumn = "";
- $sampling_column .= html_writer::tag('br', '');
- $sampling_column .= html_writer::tag('strong', get_string('selectrules', 'mod_coursework'));
- $sampling_column .= html_writer::tag('br', '');
+ $samplingcolumn .= html_writer::tag('br', '');
+ $samplingcolumn .= html_writer::tag('strong', get_string('selectrules', 'mod_coursework'));
+ $samplingcolumn .= html_writer::tag('br', '');
- $sampling_column .= html_writer::start_tag('div');
+ $samplingcolumn .= html_writer::start_tag('div');
for ($i = 0; $i < 1; $i++) {
- $sampling_column .= html_writer::start_tag('span', array('class' => "assessor_{$suffix}_grade_rules", 'id' => "assessor_{$suffix}_grade_rules"));
+ $samplingcolumn .= html_writer::start_tag('span', ['class' => "assessor_{$suffix}_grade_rules", 'id' => "assessor_{$suffix}_grade_rules"]);
- $sampling_column .= html_writer::checkbox("assessor_{$suffix}_samplerules[]", 1, false, get_string('grade', 'mod_coursework'),
- array('id' => "assessor_{$suffix}_samplerules_{$i}", 'class' => "assessor_{$suffix} sampling_strategy_detail"));
+ $samplingcolumn .= html_writer::checkbox("assessor_{$suffix}_samplerules[]", 1, false, get_string('grade', 'mod_coursework'),
+ ['id' => "assessor_{$suffix}_samplerules_{$i}", 'class' => "assessor_{$suffix} sampling_strategy_detail"]);
- $options = array('0' => get_string('percentagesign', 'mod_coursework'),
- '1' => get_string('gradescale', 'mod_coursework'));
+ $options = ['0' => get_string('percentagesign', 'mod_coursework'),
+ '1' => get_string('gradescale', 'mod_coursework')];
- $sampling_column .= html_writer::select($options,
+ $samplingcolumn .= html_writer::select($options,
"assessor_{$suffix}_sampletype[]",
$samplingwidget->get_sampling_strategy(),
false,
- array('id' => "assessor_{$suffix}_sampletype_{$i}", 'class' => "grade_type assessor_{$suffix} sampling_strategy_detail"));
+ ['id' => "assessor_{$suffix}_sampletype_{$i}", 'class' => "grade_type assessor_{$suffix} sampling_strategy_detail"]);
- $sampling_column .= html_writer::label(get_string('from', 'mod_coursework'), 'assessortwo_samplefrom[0]');
+ $samplingcolumn .= html_writer::label(get_string('from', 'mod_coursework'), 'assessortwo_samplefrom[0]');
- $rule_options = $percentage_options;
+ $ruleoptions = $percentageoptions;
- $sampling_column .= html_writer::select($rule_options,
+ $samplingcolumn .= html_writer::select($ruleoptions,
"assessor_{$suffix}_samplefrom[]",
$samplingwidget->get_sampling_strategy(),
false,
- array('id' => "assessor_{$suffix}_samplefrom_{$i}", 'class' => "assessor_{$suffix} sampling_strategy_detail"));
+ ['id' => "assessor_{$suffix}_samplefrom_{$i}", 'class' => "assessor_{$suffix} sampling_strategy_detail"]);
- $sampling_column .= html_writer::label(get_string('to', 'mod_coursework'), "assessor_{$suffix}_sampleto[0]");
+ $samplingcolumn .= html_writer::label(get_string('to', 'mod_coursework'), "assessor_{$suffix}_sampleto[0]");
- $sampling_column .= html_writer::select($rule_options,
+ $samplingcolumn .= html_writer::select($ruleoptions,
"assessor_{$suffix}_sampleto[]",
$samplingwidget->get_sampling_strategy(),
false,
- array('id' => "assessor_{$suffix}_sampleto_{$i}", 'class' => "assessor_{$suffix} sampling_strategy_detail"));
+ ['id' => "assessor_{$suffix}_sampleto_{$i}", 'class' => "assessor_{$suffix} sampling_strategy_detail"]);
- $sampling_column .= html_writer::end_tag('span', '');
+ $samplingcolumn .= html_writer::end_tag('span', '');
}
- $sampling_column .= html_writer::end_tag('div');
+ $samplingcolumn .= html_writer::end_tag('div');
- $sampling_column .= html_writer::link('#', get_string('addgraderule', 'mod_coursework'), array('id' => "assessor_{$suffix}_addgradderule", 'class' => 'addgradderule sampling_strategy_detail'));
- $sampling_column .= html_writer::link('#', get_string('removegraderule', 'mod_coursework'), array('id' => "assessor_{$suffix}_removegradderule", 'class' => 'removegradderule sampling_strategy_detail'));
+ $samplingcolumn .= html_writer::link('#', get_string('addgraderule', 'mod_coursework'), ['id' => "assessor_{$suffix}_addgradderule", 'class' => 'addgradderule sampling_strategy_detail']);
+ $samplingcolumn .= html_writer::link('#', get_string('removegraderule', 'mod_coursework'), ['id' => "assessor_{$suffix}_removegradderule", 'class' => 'removegradderule sampling_strategy_detail']);
- $sampling_column .= html_writer::checkbox("assessor_{$suffix}_samplertopup", 1, false, get_string('topupto', 'mod_coursework'),
- array('id' => "assessor_{$suffix}_samplerules[]", 'class' => "assessor_{$suffix} sampling_strategy_detail"));
+ $samplingcolumn .= html_writer::checkbox("assessor_{$suffix}_samplertopup", 1, false, get_string('topupto', 'mod_coursework'),
+ ['id' => "assessor_{$suffix}_samplerules[]", 'class' => "assessor_{$suffix} sampling_strategy_detail"]);
- $sampling_column .= html_writer::select($percentage_options,
+ $samplingcolumn .= html_writer::select($percentageoptions,
"assessor_{$suffix}_sampletopup",
$samplingwidget->get_sampling_strategy(),
false,
- array('id' => "assessor_{$suffix}_sampletopup", 'class' => "assessor_{$suffix} sampling_strategy_detail"));
- $sampling_column .= html_writer::label(get_string('ofallstudents', 'mod_coursework'), 'assessortwo_sampleto[]');
+ ['id' => "assessor_{$suffix}_sampletopup", 'class' => "assessor_{$suffix} sampling_strategy_detail"]);
+ $samplingcolumn .= html_writer::label(get_string('ofallstudents', 'mod_coursework'), 'assessortwo_sampleto[]');
- return $sampling_column;
+ return $samplingcolumn;
}
@@ -991,7 +993,7 @@ private function output_grade_as_string($grade, $maxgrade) {
if ($maxgrade < -1) { // Coursework is graded with a scale.
// TODO cache these.
$scalegrade = -$maxgrade;
- $scale = $DB->get_record('scale', array('id' => ($scalegrade)));
+ $scale = $DB->get_record('scale', ['id' => ($scalegrade)]);
if ($scale) {
$items = explode(',', $scale->scale);
@@ -1035,11 +1037,11 @@ protected function make_moderation_set_rule_row(moderation_set_rule $rule) {
// Can intercept with AJAX later if needs be.
$linktitle = get_string('delete');
- $attributes = array(
+ $attributes = [
'type' => 'submit',
'name' => 'delete-mod-set-rule[' . $rule->id . ']',
- 'value' => $linktitle
- );
+ 'value' => $linktitle,
+ ];
$controlscell->text .= html_writer::empty_tag('input', $attributes);
$row->cells[] = $controlscell;
@@ -1066,15 +1068,15 @@ protected function get_allocation_strategy_form_elements($coursework) {
}
preg_match('/([^\/]+).php/', $fullclassname, $matches);
$classname = $matches[1];
- $full_class_name = '\mod_coursework\allocation\strategy\\' . $classname;
+ $fullclassname = '\mod_coursework\allocation\strategy\\' . $classname;
// We want the elements from all the strategies so we can show/hide them.
/* @var \mod_coursework\allocation\strategy\base $strategy */
- $strategy = new $full_class_name($coursework);
+ $strategy = new $fullclassname($coursework);
- $attributes = array(
+ $attributes = [
'class' => 'assessor-strategy-options',
- 'id' => 'assessor-strategy-' . $classname
- );
+ 'id' => 'assessor-strategy-' . $classname,
+ ];
// Hide this if it's not currently selected.
$strategytype = 'assessorallocationstrategy';
if ($classname !== $coursework->$strategytype) {
@@ -1088,7 +1090,7 @@ protected function get_allocation_strategy_form_elements($coursework) {
return $html;
}
- protected function get_sampling_strategy_form_elements($coursework, $assessor_number, $load_javascript=false) {
+ protected function get_sampling_strategy_form_elements($coursework, $assessornumber, $loadjavascript=false) {
global $CFG, $DB;
@@ -1100,18 +1102,20 @@ protected function get_sampling_strategy_form_elements($coursework, $assessor_nu
//$fullclasspaths = glob($classdir . '/*.php');
foreach ($sampleplugins as $plugin) {
- /* if (strpos($fullclassname, 'base') !== false) {
+ /* if (strpos($fullclassname, 'base') !== false) {
continue;
}*/
preg_match('/([^\/]+).php/', $classdir."/".$plugin->rulename.".php", $matches);
$classname = $matches[1];
- $full_class_name = '\mod_coursework\sample_set_rule\\' . $classname;
+ $fullclassname = '\mod_coursework\sample_set_rule\\' . $classname;
- $sampling_rule = new $full_class_name($coursework);
+ $samplingrule = new $fullclassname($coursework);
- $html .= $sampling_rule->add_form_elements($assessor_number);
+ $html .= $samplingrule->add_form_elements($assessornumber);
- if ($load_javascript) $javascript .= $sampling_rule->add_form_elements_js($assessor_number);
+ if ($loadjavascript) {
+ $javascript .= $samplingrule->add_form_elements_js($assessornumber);
+ }
}
@@ -1128,27 +1132,27 @@ protected function get_sampling_strategy_form_elements($coursework, $assessor_nu
protected function resubmit_to_plagiarism_button($coursework, $submission) {
$html = '';
$html .= html_writer::start_tag('form',
- array('action' => $this->page->url,
- 'method' => 'POST'));
+ ['action' => $this->page->url,
+ 'method' => 'POST']);
$html .= html_writer::empty_tag('input',
- array('type' => 'hidden',
+ ['type' => 'hidden',
'name' => 'submissionid',
- 'value' => $submission->id));
+ 'value' => $submission->id]);
$html .= html_writer::empty_tag('input',
- array('type' => 'hidden',
+ ['type' => 'hidden',
'name' => 'id',
- 'value' => $coursework->get_coursemodule_id()));
- $plagiarism_plugin_names = [];
+ 'value' => $coursework->get_coursemodule_id()]);
+ $plagiarismpluginnames = [];
foreach ($coursework->get_plagiarism_helpers() as $helper) {
- $plagiarism_plugin_names[] = $helper->human_readable_name();
+ $plagiarismpluginnames[] = $helper->human_readable_name();
}
- $plagiarism_plugin_names = implode(' ', $plagiarism_plugin_names);
+ $plagiarismpluginnames = implode(' ', $plagiarismpluginnames);
- $resubmit = get_string('resubmit', 'coursework', $plagiarism_plugin_names);
+ $resubmit = get_string('resubmit', 'coursework', $plagiarismpluginnames);
$html .= html_writer::empty_tag('input',
- array('type' => 'submit',
+ ['type' => 'submit',
'value' => $resubmit,
- 'name' => 'resubmit'));
+ 'name' => 'resubmit']);
$html .= html_writer::end_tag('form');
return $html;
}
@@ -1160,15 +1164,15 @@ protected function resubmit_to_plagiarism_button($coursework, $submission) {
*/
protected function render_file_plagiarism_information($file, $coursework) {
- $plagiarism_links_params = array(
+ $plagiarismlinksparams = [
'userid' => $file->get_userid(),
'file' => $file,
'cmid' => $coursework->get_coursemodule_id(),
'course' => $coursework->get_course(),
'coursework' => $coursework->id,
- 'modname' => 'coursework'
- );
- $plagiarsmlinks = plagiarism_get_links($plagiarism_links_params);
+ 'modname' => 'coursework',
+ ];
+ $plagiarsmlinks = plagiarism_get_links($plagiarismlinksparams);
return $plagiarsmlinks;
}
@@ -1179,7 +1183,7 @@ protected function render_file_plagiarism_information($file, $coursework) {
* @param string $class_name
* @return string
*/
- protected function make_file_link($files, $file, $class_name = 'submissionfile') {
+ protected function make_file_link($files, $file, $classname = 'submissionfile') {
global $CFG;
$url = "{$CFG->wwwroot}/pluginfile.php/{$file->get_contextid()}" .
@@ -1189,10 +1193,10 @@ protected function make_file_link($files, $file, $class_name = 'submissionfile')
$image = $this->output->pix_icon(file_file_icon($file),
$filename,
'moodle',
- array('class' => 'submissionfileicon'));
+ ['class' => 'submissionfileicon']);
$fileurl = $url . $file->get_filepath() . $file->get_itemid() . '/' . rawurlencode($filename);
- return html_writer::link($fileurl, $image.$filename, array('class' => $class_name));
+ return html_writer::link($fileurl, $image.$filename, ['class' => $classname]);
}
/**
@@ -1220,34 +1224,34 @@ protected function render_resubmit_to_plagiarism_button($coursework, $submission
protected function coursework_deadlines_table(mod_coursework_coursework $coursework) {
global $USER;
- $dealine_extension =
+ $dealineextension =
\mod_coursework\models\deadline_extension::get_extension_for_student(user::find($USER), $coursework);
- $personal_deadline =
+ $personaldeadline =
\mod_coursework\models\personal_deadline::get_personal_deadline_for_student(user::find($USER), $coursework);
$normaldeadline = $coursework->deadline;
- if ($personal_deadline) {
- $normaldeadline = $personal_deadline->personal_deadline;
+ if ($personaldeadline) {
+ $normaldeadline = $personaldeadline->personal_deadline;
}
- $deadline_header_text = get_string('deadline', 'coursework');
+ $deadlineheadertext = get_string('deadline', 'coursework');
if ($coursework->personal_deadlines_enabled() && (!has_capability('mod/coursework:submit', $this->page->context) || is_siteadmin($USER))) {
- $deadline_header_text .= " ". get_string('default_deadline', 'coursework');
+ $deadlineheadertext .= " ". get_string('default_deadline', 'coursework');
}
- $deadline_date = '';
+ $deadlinedate = '';
- if ($dealine_extension) {
- $deadline_date .= '';
- $deadline_date .= userdate($normaldeadline, '%a, %d %b %Y, %H:%M');
- $deadline_date .= '';
+ if ($dealineextension) {
+ $deadlinedate .= '';
+ $deadlinedate .= userdate($normaldeadline, '%a, %d %b %Y, %H:%M');
+ $deadlinedate .= '';
} else if ($coursework->has_deadline()) {
- $deadline_date .= userdate($normaldeadline, '%a, %d %b %Y, %H:%M');
+ $deadlinedate .= userdate($normaldeadline, '%a, %d %b %Y, %H:%M');
} else {
- $deadline_date .= get_string('nocourseworkdeadline', 'mod_coursework');
+ $deadlinedate .= get_string('nocourseworkdeadline', 'mod_coursework');
}
- $deadline_message = '';
+ $deadlinemessage = '';
if ($coursework->has_deadline()) {
if ($coursework->allow_late_submissions()) {
$latemessage = get_string('latesubmissionsallowed', 'mod_coursework');
@@ -1257,50 +1261,50 @@ protected function coursework_deadlines_table(mod_coursework_coursework $coursew
$lateclass = $coursework->deadline_has_passed() ? 'text-error' : 'text-warning';
}
$latemessage .= ' ';
- $deadline_message = html_writer::start_tag('span', array('class' => $lateclass));
- $deadline_message .= $latemessage;
- $deadline_message .= html_writer::end_tag('span');
+ $deadlinemessage = html_writer::start_tag('span', ['class' => $lateclass]);
+ $deadlinemessage .= $latemessage;
+ $deadlinemessage .= html_writer::end_tag('span');
}
// Does the user have an extension?
- $deadline_extension_message = '';
- if ($dealine_extension) {
- $deadline_extension_message .= html_writer::start_tag('div');
- $deadline_extension_message .= 'You have an extension! Your deadine is: '
- . userdate($dealine_extension->extended_deadline);
- $deadline_extension_message .= html_writer::end_tag('div');
+ $deadlineextensionmessage = '';
+ if ($dealineextension) {
+ $deadlineextensionmessage .= html_writer::start_tag('div');
+ $deadlineextensionmessage .= 'You have an extension! Your deadine is: '
+ . userdate($dealineextension->extended_deadline);
+ $deadlineextensionmessage .= html_writer::end_tag('div');
}
if ($coursework->has_deadline()) {
- $deadline_message .= html_writer::start_tag('div', array('class' => 'autofinalise_info'));
- $deadline_message .= ($coursework->personal_deadlines_enabled() && (!has_capability('mod/coursework:submit', $this->page->context) || is_siteadmin($USER)))
+ $deadlinemessage .= html_writer::start_tag('div', ['class' => 'autofinalise_info']);
+ $deadlinemessage .= ($coursework->personal_deadlines_enabled() && (!has_capability('mod/coursework:submit', $this->page->context) || is_siteadmin($USER)))
? get_string('personal_deadline_warning', 'mod_coursework') : get_string('deadline_warning', 'mod_coursework');
- $deadline_message .= html_writer::end_tag('div');
+ $deadlinemessage .= html_writer::end_tag('div');
}
- $table_html = '
+ $tablehtml = '
- '.$deadline_header_text.' |
- '. $deadline_date.'
- '.$deadline_extension_message.'
- '. $deadline_message.' |
+ '.$deadlineheadertext.' |
+ '. $deadlinedate.'
+ '.$deadlineextensionmessage.'
+ '. $deadlinemessage.' |
';
if ($coursework->is_general_feedback_enabled() && $coursework->generalfeedback) {
- $general_feedback_header = get_string('generalfeedbackdeadline', 'coursework') . ': ';
- $general_feedback_deadline = $coursework->get_general_feedback_deadline();
- $general_feedback_deadline_message = $general_feedback_deadline
- ? userdate($general_feedback_deadline, '%a, %d %b %Y, %H:%M')
+ $generalfeedbackheader = get_string('generalfeedbackdeadline', 'coursework') . ': ';
+ $generalfeedbackdeadline = $coursework->get_general_feedback_deadline();
+ $generalfeedbackdeadlinemessage = $generalfeedbackdeadline
+ ? userdate($generalfeedbackdeadline, '%a, %d %b %Y, %H:%M')
: get_string('notset', 'coursework');
- $table_html .= '
+ $tablehtml .= '
- '. $general_feedback_header.' |
- '. $general_feedback_deadline_message.' |
+ '. $generalfeedbackheader.' |
+ '. $generalfeedbackdeadlinemessage.' |
';
@@ -1308,56 +1312,56 @@ protected function coursework_deadlines_table(mod_coursework_coursework $coursew
if ($coursework->individualfeedback) {
- $individual_feedback_header = get_string('individualfeedback', 'coursework');
- $individual_feedback_deadline = $coursework->get_individual_feedback_deadline();
- $indivisual_feedback_message = $individual_feedback_deadline
- ? userdate($individual_feedback_deadline, '%a, %d %b %Y, %H:%M')
+ $individualfeedbackheader = get_string('individualfeedback', 'coursework');
+ $individualfeedbackdeadline = $coursework->get_individual_feedback_deadline();
+ $indivisualfeedbackmessage = $individualfeedbackdeadline
+ ? userdate($individualfeedbackdeadline, '%a, %d %b %Y, %H:%M')
: get_string('notset', 'coursework');
- $table_html .= '
+ $tablehtml .= '
- '. $individual_feedback_header.' |
- '. $indivisual_feedback_message.' |
+ '. $individualfeedbackheader.' |
+ '. $indivisualfeedbackmessage.' |
';
}
- $table_html .= '
+ $tablehtml .= '
';
- return $table_html;
+ return $tablehtml;
}
/**
* @param \mod_coursework\allocation\table\row\builder $allocation_row
* @return string
*/
- private function render_allocation_table_row($allocation_row) {
+ private function render_allocation_table_row($allocationrow) {
- $row_html = '
-
+ $rowhtml = '
+
';
- $allocatable_cell_helper = $allocation_row->get_allocatable_cell();
- $row_html .= $allocatable_cell_helper->get_table_cell($allocation_row);
+ $allocatablecellhelper = $allocationrow->get_allocatable_cell();
+ $rowhtml .= $allocatablecellhelper->get_table_cell($allocationrow);
- foreach ($allocation_row->marking_stages() as $stage) {
+ foreach ($allocationrow->marking_stages() as $stage) {
if ($stage->uses_allocation() && $stage->identifier() != 'moderator') {
- $row_html .= $stage->get_allocation_table_cell($allocation_row->get_allocatable());
+ $rowhtml .= $stage->get_allocation_table_cell($allocationrow->get_allocatable());
}
}
// moderator
- if ($allocation_row->get_coursework()->moderation_agreement_enabled()) {
- $row_html .= $stage->get_moderation_table_cell($allocation_row->get_allocatable());
+ if ($allocationrow->get_coursework()->moderation_agreement_enabled()) {
+ $rowhtml .= $stage->get_moderation_table_cell($allocationrow->get_allocatable());
}
- $row_html .= ' ';
+ $rowhtml .= '';
- return $row_html;
+ return $rowhtml;
}
/**
@@ -1366,31 +1370,31 @@ private function render_allocation_table_row($allocation_row) {
* @param mod_coursework_personal_deadlines_table $personal_deadlines_table
* @return string
*/
- protected function render_mod_coursework_personal_deadlines_table(mod_coursework_personal_deadlines_table $personal_deadlines_table) {
- $coursework_page_url = $this->get_router()->get_path('coursework', array('coursework' => $personal_deadlines_table->get_coursework()));
- $table_html = ''.html_writer::link($coursework_page_url, get_string('returntocourseworkpage', 'mod_coursework')).' ';
+ protected function render_mod_coursework_personal_deadlines_table(mod_coursework_personal_deadlines_table $personaldeadlinestable) {
+ $courseworkpageurl = $this->get_router()->get_path('coursework', ['coursework' => $personaldeadlinestable->get_coursework()]);
+ $tablehtml = ''.html_writer::link($courseworkpageurl, get_string('returntocourseworkpage', 'mod_coursework')).' ';
- $table_html .= ''.get_string('nopersonaldeadlineforextensionwarning', 'mod_coursework').' ';
+ $tablehtml .= ''.get_string('nopersonaldeadlineforextensionwarning', 'mod_coursework').' ';
- $usergroups = $personal_deadlines_table->get_coursework()->get_allocatable_type();
+ $usergroups = $personaldeadlinestable->get_coursework()->get_allocatable_type();
- $table_html .= ''.html_writer::link('#', get_string('setdateforselected', 'mod_coursework', $personal_deadlines_table->get_coursework()->get_allocatable_type()), array('id' => 'selected_dates')).' ';
+ $tablehtml .= ''.html_writer::link('#', get_string('setdateforselected', 'mod_coursework', $personaldeadlinestable->get_coursework()->get_allocatable_type()), ['id' => 'selected_dates']).' ';
if (has_capability('mod/coursework:revertfinalised', $this->page->context)) {
- $table_html .= '' . html_writer::link('#', get_string('unfinaliseselected', 'mod_coursework', $personal_deadlines_table->get_coursework()->get_allocatable_type()), array('id' => 'selected_unfinalise')) . ' ';
+ $tablehtml .= '' . html_writer::link('#', get_string('unfinaliseselected', 'mod_coursework', $personaldeadlinestable->get_coursework()->get_allocatable_type()), ['id' => 'selected_unfinalise']) . ' ';
}
- $table_html .= ' ';
+ $tablehtml .= ' ';
$url = $this->get_router()->get_path('edit personal deadline', []);
- $table_html .= ' ';
+ $tablehtml .= '';
- return $table_html;
+ return $tablehtml;
}
@@ -1439,52 +1443,52 @@ protected function render_mod_coursework_personal_deadlines_table(mod_coursework
* @param \mod_coursework\personal_deadline\table\row\builder $personal_deadline_row
* @return string
*/
- private function render_personal_deadline_table_row($personal_deadline_row) {
+ private function render_personal_deadline_table_row($personaldeadlinerow) {
global $USER;
- $coursework = $personal_deadline_row->get_coursework();
+ $coursework = $personaldeadlinerow->get_coursework();
- $new_personal_deadline_params = array(
- 'allocatableid' => $personal_deadline_row->get_allocatable()->id(),
- 'allocatabletype' => $personal_deadline_row->get_allocatable()->type(),
- 'courseworkid' => $personal_deadline_row->get_coursework()->id,
- );
+ $newpersonaldeadlineparams = [
+ 'allocatableid' => $personaldeadlinerow->get_allocatable()->id(),
+ 'allocatabletype' => $personaldeadlinerow->get_allocatable()->type(),
+ 'courseworkid' => $personaldeadlinerow->get_coursework()->id,
+ ];
//$personal_deadline = \mod_coursework\models\personal_deadline::find($new_personal_deadline_params);
- $personal_deadline =
- \mod_coursework\models\personal_deadline::get_personal_deadline_for_student(user::find($personal_deadline_row->get_allocatable()->id()), $coursework);
+ $personaldeadline =
+ \mod_coursework\models\personal_deadline::get_personal_deadline_for_student(user::find($personaldeadlinerow->get_allocatable()->id()), $coursework);
- if (!$personal_deadline) {
- $personal_deadline = \mod_coursework\models\personal_deadline::build($new_personal_deadline_params);
+ if (!$personaldeadline) {
+ $personaldeadline = \mod_coursework\models\personal_deadline::build($newpersonaldeadlineparams);
}
$ability = new ability(user::find($USER), $coursework);
- $disabledelement = (!$personal_deadline ||($personal_deadline && $ability->can('edit', $personal_deadline)) ) ? "" : " disabled='disabled' ";
-
- $row_html = ' ';
- $row_html .= '';
- $row_html .= '';
- $row_html .= '';
- $row_html .= ' | ';
-
- $new_personal_deadline_params = array(
- 'allocatableid' => $personal_deadline_row->get_allocatable()->id(),
- 'allocatabletype' => $personal_deadline_row->get_allocatable()->type(),
- 'courseworkid' => $personal_deadline_row->get_coursework()->id,
- 'setpersonaldeadlinespage' => '1'
- );
-
- $allocatable_cell_helper = $personal_deadline_row->get_allocatable_cell();
- $personaldeadlines_cell_helper = $personal_deadline_row->get_personal_deadline_cell();
- $row_html .= $allocatable_cell_helper->get_table_cell($personal_deadline_row);
- $row_html .= $personaldeadlines_cell_helper->get_table_cell($personal_deadline_row);
- $row_html .= '';
- $row_html .= "".$personal_deadline_row->get_submission_status()." | ";
- $row_html .= ' ';
-
- return $row_html;
+ $disabledelement = (!$personaldeadline ||($personaldeadline && $ability->can('edit', $personaldeadline)) ) ? "" : " disabled='disabled' ";
+
+ $rowhtml = ' ';
+ $rowhtml .= '';
+ $rowhtml .= '';
+ $rowhtml .= '';
+ $rowhtml .= ' | ';
+
+ $newpersonaldeadlineparams = [
+ 'allocatableid' => $personaldeadlinerow->get_allocatable()->id(),
+ 'allocatabletype' => $personaldeadlinerow->get_allocatable()->type(),
+ 'courseworkid' => $personaldeadlinerow->get_coursework()->id,
+ 'setpersonaldeadlinespage' => '1',
+ ];
+
+ $allocatablecellhelper = $personaldeadlinerow->get_allocatable_cell();
+ $personaldeadlinescellhelper = $personaldeadlinerow->get_personal_deadline_cell();
+ $rowhtml .= $allocatablecellhelper->get_table_cell($personaldeadlinerow);
+ $rowhtml .= $personaldeadlinescellhelper->get_table_cell($personaldeadlinerow);
+ $rowhtml .= '';
+ $rowhtml .= "".$personaldeadlinerow->get_submission_status()." | ";
+ $rowhtml .= ' ';
+
+ return $rowhtml;
}
/**
@@ -1495,9 +1499,9 @@ private function render_personal_deadline_table_row($personal_deadline_row) {
protected function coursework_grading_summary_table(mod_coursework_coursework $coursework) {
global $USER;
- $gradedHeader = "";
+ $gradedheader = "";
- $warning_message = "";
+ $warningmessage = "";
$stagename = $coursework->has_multiple_markers() ? ' (Agreed grade)' : '';
$participants = 0;
@@ -1510,44 +1514,44 @@ protected function coursework_grading_summary_table(mod_coursework_coursework $c
if (!$coursework->has_multiple_markers() && !$coursework->allocation_enabled() && !has_capability('mod/coursework:addinitialgrade', $coursework->get_context())
&& has_capability('mod/coursework:addagreedgrade', $coursework->get_context())) {
- $warning_message = " You don't have a capability to grade anyone in this Coursework | ";
+ $warningmessage = " You don't have a capability to grade anyone in this Coursework | ";
} else {
$participants = $this->get_allocatables_count_per_assessor($coursework);
$allsubmissions = $coursework->get_all_submissions();
- $assessable_submitted_submissions = $this->get_submissions_for_assessor($coursework, $allsubmissions);
- $submitted = count($assessable_submitted_submissions);
+ $assessablesubmittedsubmissions = $this->get_submissions_for_assessor($coursework, $allsubmissions);
+ $submitted = count($assessablesubmittedsubmissions);
- $assessable_submitted_submissions = $this->remove_unfinalised_submissions($assessable_submitted_submissions);
+ $assessablesubmittedsubmissions = $this->remove_unfinalised_submissions($assessablesubmittedsubmissions);
- $assessable_submitted_submissions = $this->remove_ungradable_submissions($assessable_submitted_submissions);
+ $assessablesubmittedsubmissions = $this->remove_ungradable_submissions($assessablesubmittedsubmissions);
// Remove all submission with final grade
- $assessable_submitted_submissions = $this->removed_final_graded_submissions($assessable_submitted_submissions);
+ $assessablesubmittedsubmissions = $this->removed_final_graded_submissions($assessablesubmittedsubmissions);
// If has addagreedgrade or administergrade or addallocatedagreedgrade+initialgrade
- if (has_any_capability(array('mod/coursework:addagreedgrade', 'mod/coursework:administergrades'), $coursework->get_context())
+ if (has_any_capability(['mod/coursework:addagreedgrade', 'mod/coursework:administergrades'], $coursework->get_context())
|| (has_capability('mod/coursework:addinitialgrade', $coursework->get_context()) && has_capability('mod/coursework:addallocatedagreedgrade', $coursework->get_context()))) {
// Count number of submissions at final grade stage
- $numberofassessable = count($assessable_submitted_submissions);
+ $numberofassessable = count($assessablesubmittedsubmissions);
- $assessable_submitted_submissions = $this->remove_final_gradable_submissions($assessable_submitted_submissions);
+ $assessablesubmittedsubmissions = $this->remove_final_gradable_submissions($assessablesubmittedsubmissions);
- $needsgrading = $numberofassessable - count($assessable_submitted_submissions);
+ $needsgrading = $numberofassessable - count($assessablesubmittedsubmissions);
}
// If has initialgrade
- if (has_any_capability(array('mod/coursework:addinitialgrade', 'mod/coursework:administergrades'), $coursework->get_context())) {
+ if (has_any_capability(['mod/coursework:addinitialgrade', 'mod/coursework:administergrades'], $coursework->get_context())) {
- $assessable_submitted_submissions = $this->remove_final_gradable_submissions($assessable_submitted_submissions);
- $needsgrading += count($this->get_assessor_initial_graded_submissions($assessable_submitted_submissions));
+ $assessablesubmittedsubmissions = $this->remove_final_gradable_submissions($assessablesubmittedsubmissions);
+ $needsgrading += count($this->get_assessor_initial_graded_submissions($assessablesubmittedsubmissions));
}
- $graded_submissions = $this->get_submissions_with_final_grade($this->get_submissions_for_assessor($coursework, $allsubmissions));
- $graded = count($graded_submissions);
+ $gradedsubmissions = $this->get_submissions_with_final_grade($this->get_submissions_for_assessor($coursework, $allsubmissions));
+ $graded = count($gradedsubmissions);
$finalgrade = $graded;
// display breakdown of marks for initial stages
@@ -1558,7 +1562,7 @@ protected function coursework_grading_summary_table(mod_coursework_coursework $c
$initialassessorno = substr("$stage", -1);
$gradedsubmissions = $coursework->get_graded_submissions_by_stage($stage);
$grade = count($this->get_submissions_for_assessor($coursework, $gradedsubmissions));
- $gradedHeader .= " " . get_string('initialassessorno', 'mod_coursework', $initialassessorno);
+ $gradedheader .= " " . get_string('initialassessorno', 'mod_coursework', $initialassessorno);
$finalgrade .= " " . $grade;
}
}
@@ -1570,26 +1574,26 @@ protected function coursework_grading_summary_table(mod_coursework_coursework $c
}
// BUILD table
- $table_html = ' ';
- $table_html .= $warning_message;
+ $tablehtml = '';
+ $tablehtml .= $warningmessage;
// participants row
- $table_html .= ''.get_string('participants', 'mod_coursework').' | '.$participants.' | ';
+ $tablehtml .= ''.get_string('participants', 'mod_coursework').' | '.$participants.' | ';
// number of submission row
- $table_html .= ''.get_string('submitted', 'mod_coursework').' | '.$submitted.' | ';
+ $tablehtml .= ''.get_string('submitted', 'mod_coursework').' | '.$submitted.' | ';
// submissions needs grading row
- $table_html .= ''.get_string('needsgrading', 'mod_coursework').' | '.$needsgrading.' | ';
+ $tablehtml .= ''.get_string('needsgrading', 'mod_coursework').' | '.$needsgrading.' | ';
// submissions graded
if (has_capability('mod/coursework:addinitialgrade', $coursework->get_context()) && !is_siteadmin($USER)) {
- $table_html .= '' . get_string('graded', 'mod_coursework') . $stagename . $gradedHeader . ' | ' . $graded . ' | ';
+ $tablehtml .= '' . get_string('graded', 'mod_coursework') . $stagename . $gradedheader . ' | ' . $graded . ' | ';
} else {
- $table_html .= '' . get_string('graded', 'mod_coursework') . $stagename . $gradedHeader . ' | ' . $finalgrade . ' | ';
+ $tablehtml .= '' . get_string('graded', 'mod_coursework') . $stagename . $gradedheader . ' | ' . $finalgrade . ' | ';
}
// submissions graded and published
- $table_html .= ''.get_string('gradedandpublished', 'mod_coursework').' | '.$published.' | ';
+ $tablehtml .= ''.get_string('gradedandpublished', 'mod_coursework').' | '.$published.' | ';
- $table_html .= ' ';
+ $tablehtml .= ' ';
- return $table_html;
+ return $tablehtml;
}
/**
@@ -1618,15 +1622,15 @@ public function get_allocatables_count_per_assessor($coursework) {
$participant = count($submissions);
- } else if (is_siteadmin($USER) || !$coursework->allocation_enabled() || has_any_capability(array('mod/coursework:administergrades'), $coursework->get_context())) {
+ } else if (is_siteadmin($USER) || !$coursework->allocation_enabled() || has_any_capability(['mod/coursework:administergrades'], $coursework->get_context())) {
$participant = count($allocatables);
} else {
foreach ($allocatables as $allocatable) {
$submission = $allocatable->get_submission($coursework);
if ($coursework->assessor_has_any_allocation_for_student($allocatable) || has_capability('mod/coursework:addagreedgrade', $coursework->get_context())
- && !empty($submission) && (($submission->all_inital_graded() && !$coursework->sampling_enabled())
- || ($coursework->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() >1 ))) {
+ && !empty($submission) && (($submission->all_inital_graded() && !$coursework->sampling_enabled())
+ || ($coursework->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() > 1 ))) {
$participant ++;
}
}
@@ -1790,24 +1794,24 @@ public function get_submissions_for_assessor($coursework, $submissions) {
$gradeblesub = $submissions;
- } else if (is_siteadmin($USER) || !$coursework->allocation_enabled() || has_any_capability(array('mod/coursework:administergrades'), $coursework->get_context())) {
+ } else if (is_siteadmin($USER) || !$coursework->allocation_enabled() || has_any_capability(['mod/coursework:administergrades'], $coursework->get_context())) {
- foreach ($submissions as $sub) {
- $submission = submission::find($sub);
- $gradeblesub[$submission->id] = $submission;
- }
+ foreach ($submissions as $sub) {
+ $submission = submission::find($sub);
+ $gradeblesub[$submission->id] = $submission;
+ }
- } else {
- foreach ($submissions as $sub) {
- $submission = submission::find($sub);
- if ($coursework->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) || (has_capability('mod/coursework:addagreedgrade', $coursework->get_context()))
- && !empty($submission) && (($submission->all_inital_graded() && !$submission->get_coursework()->sampling_enabled())
- || ($submission->get_coursework()->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() > 1))) {
+ } else {
+ foreach ($submissions as $sub) {
+ $submission = submission::find($sub);
+ if ($coursework->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) || (has_capability('mod/coursework:addagreedgrade', $coursework->get_context()))
+ && !empty($submission) && (($submission->all_inital_graded() && !$submission->get_coursework()->sampling_enabled())
+ || ($submission->get_coursework()->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() > 1))) {
- $gradeblesub[$submission->id] = $submission;
- }
+ $gradeblesub[$submission->id] = $submission;
}
}
+ }
return $gradeblesub;
}
diff --git a/settings.php b/settings.php
index b6ec8765..12238a09 100644
--- a/settings.php
+++ b/settings.php
@@ -27,22 +27,22 @@
if ($ADMIN->fulltree) {
require_once($CFG->dirroot.'/mod/coursework/lib.php');
- $settings_header = new admin_setting_heading('settings_header', '', get_string('settings_header', 'mod_coursework'));
- $settings->add($settings_header);
+ $settingsheader = new admin_setting_heading('settings_header', '', get_string('settings_header', 'mod_coursework'));
+ $settings->add($settingsheader);
// Set site-wide option for late submission
- $availability_header = new admin_setting_heading('availability_header', get_string('availability', 'mod_coursework'), '');
- $settings->add($availability_header);
- $allow_late_submission_name = get_string('allowlatesubmissions', 'coursework');
- $allow_late_submission_description = get_string('allowlatesubmissions_desc', 'coursework');
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
+ $availabilityheader = new admin_setting_heading('availability_header', get_string('availability', 'mod_coursework'), '');
+ $settings->add($availabilityheader);
+ $allowlatesubmissionname = get_string('allowlatesubmissions', 'coursework');
+ $allowlatesubmissiondescription = get_string('allowlatesubmissions_desc', 'coursework');
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
$settings->add(new admin_setting_configselect('coursework_allowlatesubmissions',
- $allow_late_submission_name, $allow_late_submission_description, 0, $options));
+ $allowlatesubmissionname, $allowlatesubmissiondescription, 0, $options));
// Set site-wide limit on submissions sizes.
if (isset($CFG->maxbytes)) {
- $submissions_header = new admin_setting_heading('submissions_header', get_string('submissions', 'mod_coursework'), '');
- $settings->add($submissions_header);
+ $submissionsheader = new admin_setting_heading('submissions_header', get_string('submissions', 'mod_coursework'), '');
+ $settings->add($submissionsheader);
$configmaxbytesstring = get_string('configmaxbytes', 'coursework');
$maximumsizestring = get_string('maximumsize', 'coursework');
$maxbytessetting = new admin_setting_configselect('coursework_maxbytes',
@@ -54,41 +54,41 @@
}
// Submissions
- $submissions_header = new admin_setting_heading('submissions_header', get_string('submissions', 'mod_coursework'), '');
- $settings->add($submissions_header);
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
+ $submissionsheader = new admin_setting_heading('submissions_header', get_string('submissions', 'mod_coursework'), '');
+ $settings->add($submissionsheader);
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
$settings->add(new admin_setting_configselect('coursework_plagiarismflag', get_string('plagiarism_flag_enable', 'mod_coursework'), get_string('plagiarism_flag_enable_desc', 'mod_coursework'), 0, $options));
// Submission receipt
- $submissionreceipt_header = new admin_setting_heading('submissionreceipt_header', get_string('submissionreceipt', 'mod_coursework'), '');
- $settings->add($submissionreceipt_header);
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
+ $submissionreceiptheader = new admin_setting_heading('submissionreceipt_header', get_string('submissionreceipt', 'mod_coursework'), '');
+ $settings->add($submissionreceiptheader);
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
$settings->add(new admin_setting_configselect('coursework_allsubmissionreceipt', get_string('allsubmission', 'mod_coursework'), get_string('allsubmission_desc', 'mod_coursework'), 0, $options));
// Blind marking
- $blindmarking_header = new admin_setting_heading('blindmarking_header', get_string('blindmarking', 'mod_coursework'), '');
- $settings->add($blindmarking_header);
- $blind_marking_name = get_string('blindmarking', 'coursework');
- $blind_marking_description = get_string('blindmarking_desc', 'coursework');
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $settings->add(new admin_setting_configselect('coursework_blindmarking', $blind_marking_name, $blind_marking_description, 0, $options));
+ $blindmarkingheader = new admin_setting_heading('blindmarking_header', get_string('blindmarking', 'mod_coursework'), '');
+ $settings->add($blindmarkingheader);
+ $blindmarkingname = get_string('blindmarking', 'coursework');
+ $blindmarkingdescription = get_string('blindmarking_desc', 'coursework');
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $settings->add(new admin_setting_configselect('coursework_blindmarking', $blindmarkingname, $blindmarkingdescription, 0, $options));
$settings->add(new admin_setting_configcheckbox('coursework_forceblindmarking', get_string('forceblindmarking', 'mod_coursework'), get_string('forceblindmarking_desc', 'mod_coursework'), 0));
// Assessor anonymity
- $assessoranonymity_header = new admin_setting_heading('assessoranonymity_header', get_string('assessoranonymity', 'mod_coursework'), '');
- $settings->add($assessoranonymity_header);
- $assessor_anonymity_name = get_string('assessoranonymity', 'coursework');
- $assessor_anonymity_description = get_string('assessoranonymity_desc', 'coursework');
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $settings->add(new admin_setting_configselect('coursework_assessoranonymity', $assessor_anonymity_name, $assessor_anonymity_description, 0, $options));
+ $assessoranonymityheader = new admin_setting_heading('assessoranonymity_header', get_string('assessoranonymity', 'mod_coursework'), '');
+ $settings->add($assessoranonymityheader);
+ $assessoranonymityname = get_string('assessoranonymity', 'coursework');
+ $assessoranonymitydescription = get_string('assessoranonymity_desc', 'coursework');
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $settings->add(new admin_setting_configselect('coursework_assessoranonymity', $assessoranonymityname, $assessoranonymitydescription, 0, $options));
// Set site-wide options for when feedback is due.
$weeks = [];
for ($i = 1; $i <= 10; $i++) {
$weeks[$i] = $i;
}
- $feedbacktypes_header = new admin_setting_heading('feedbacktypes_header', get_string('feedbacktypes', 'mod_coursework'), '');
- $settings->add($feedbacktypes_header);
+ $feedbacktypesheader = new admin_setting_heading('feedbacktypes_header', get_string('feedbacktypes', 'mod_coursework'), '');
+ $settings->add($feedbacktypesheader);
$generalfeedbackstring = get_string('generalfeedback', 'coursework');
$configgeneralfeedbackstring = get_string('configgeneralfeedback', 'coursework');
$generalfeedbacksetting = new admin_setting_configselect('coursework_generalfeedback',
@@ -98,10 +98,10 @@
$settings->add($generalfeedbacksetting);
// enable auto-release of individual feedback
- $individual_feedback_auto_release_name = get_string('individual_feedback_auto_release', 'coursework');
- $individual_feedback_auto_release_name_description = get_string('individual_feedback_auto_release_desc', 'coursework');
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $settings->add(new admin_setting_configselect('coursework_auto_release_individual_feedback', $individual_feedback_auto_release_name, $individual_feedback_auto_release_name_description, 0, $options));
+ $individualfeedbackautoreleasename = get_string('individual_feedback_auto_release', 'coursework');
+ $individualfeedbackautoreleasenamedescription = get_string('individual_feedback_auto_release_desc', 'coursework');
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $settings->add(new admin_setting_configselect('coursework_auto_release_individual_feedback', $individualfeedbackautoreleasename, $individualfeedbackautoreleasenamedescription, 0, $options));
$settings->add(new admin_setting_configcheckbox('coursework_forceauto_release_individual_feedback', get_string('forceautoauto_release_individual_feedback', 'mod_coursework'), get_string('forceautoauto_release_individual_feedback_desc', 'mod_coursework'), 0));
$individualfeedbackstring = get_string('individualfeedback', 'coursework');
@@ -113,76 +113,76 @@
$settings->add($individualfeedbacksetting);
// Feedback release email
- $feedbackreleaseemail_name = get_string('feedbackreleaseemail', 'coursework');
- $feedbackreleaseemail_description = get_string('feedbackreleaseemail_help', 'coursework');
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $settings->add(new admin_setting_configselect('coursework_feedbackreleaseemail', $feedbackreleaseemail_name, $feedbackreleaseemail_description, 1, $options));
+ $feedbackreleaseemailname = get_string('feedbackreleaseemail', 'coursework');
+ $feedbackreleaseemaildescription = get_string('feedbackreleaseemail_help', 'coursework');
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $settings->add(new admin_setting_configselect('coursework_feedbackreleaseemail', $feedbackreleaseemailname, $feedbackreleaseemaildescription, 1, $options));
- $day_reminder = [];
+ $dayreminder = [];
for ($i = 2; $i <= 7; $i++) {
- $day_reminder[$i] = $i;
+ $dayreminder[$i] = $i;
}
- $studentreminder_header = new admin_setting_heading('studentreminder_header', get_string('studentreminder', 'mod_coursework'), '');
- $settings->add($studentreminder_header);
+ $studentreminderheader = new admin_setting_heading('studentreminder_header', get_string('studentreminder', 'mod_coursework'), '');
+ $settings->add($studentreminderheader);
$reminderstring = get_string('coursework_reminder', 'coursework');
$confreminderstring = get_string('config_coursework_reminder', 'coursework');
$settings->add(new admin_setting_configselect('coursework_day_reminder', $reminderstring,
- $confreminderstring, 7, $day_reminder));
+ $confreminderstring, 7, $dayreminder));
$secondreminderstring = get_string('second_reminder', 'coursework');
$confsecondreminderstring = get_string('config_second_reminder', 'coursework');
$settings->add(new admin_setting_configselect('coursework_day_second_reminder', $secondreminderstring,
- $confsecondreminderstring, 3, $day_reminder));
+ $confsecondreminderstring, 3, $dayreminder));
// Sitewide message that students will see and agree to before submitting or editing.
- $termsagreement_header = new admin_setting_heading('termsagreement_header', get_string('termsagreement', 'mod_coursework'), '');
- $settings->add($termsagreement_header);
- $agree_terms_name = get_string('agreeterms', 'coursework');
- $agree_terms_description = get_string('agreetermsdescription', 'coursework');
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
+ $termsagreementheader = new admin_setting_heading('termsagreement_header', get_string('termsagreement', 'mod_coursework'), '');
+ $settings->add($termsagreementheader);
+ $agreetermsname = get_string('agreeterms', 'coursework');
+ $agreetermsdescription = get_string('agreetermsdescription', 'coursework');
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
$settings->add(new admin_setting_configselect('coursework_agree_terms',
- $agree_terms_name, $agree_terms_description, 0, $options));
+ $agreetermsname, $agreetermsdescription, 0, $options));
- $agree_terms_text = get_string('agreetermstext', 'coursework');
+ $agreetermstext = get_string('agreetermstext', 'coursework');
$settings->add(new admin_setting_confightmleditor('coursework_agree_terms_text',
- $agree_terms_text, '', ''));
+ $agreetermstext, '', ''));
// Extensions
- $extensions_header =
+ $extensionsheader =
new admin_setting_heading('extensions_header', get_string('extensions', 'mod_coursework'), '');
- $settings->add($extensions_header);
+ $settings->add($extensionsheader);
// Enable coursework individual extensions
- $individual_extension_name = get_string('individual_extension', 'coursework');
- $individual_extension_description = get_string('individual_extension_desc', 'coursework');
- $options = array( 0 => get_string('no'), 1 => get_string('yes'));
- $settings->add(new admin_setting_configselect('coursework_individual_extension', $individual_extension_name, $individual_extension_description, 1, $options));
+ $individualextensionname = get_string('individual_extension', 'coursework');
+ $individualextensiondescription = get_string('individual_extension_desc', 'coursework');
+ $options = [ 0 => get_string('no'), 1 => get_string('yes')];
+ $settings->add(new admin_setting_configselect('coursework_individual_extension', $individualextensionname, $individualextensiondescription, 1, $options));
// Allow people to specify a list of extension reasons here so that they can be quickly chosen
- $extension_list_label = get_string('extension_reasons', 'coursework');
- $extension_list_description = get_string('extension_reasons_desc', 'coursework');
+ $extensionlistlabel = get_string('extension_reasons', 'coursework');
+ $extensionlistdescription = get_string('extension_reasons_desc', 'coursework');
$settings->add(new admin_setting_configtextarea('coursework_extension_reasons_list',
- $extension_list_label, $extension_list_description, ''));
+ $extensionlistlabel, $extensionlistdescription, ''));
// maximum extension deadline
$settings->add(new admin_setting_configtext('coursework_max_extension_deadline', get_string('maximum_extension_deadline', 'coursework'),
get_string('maximum_extension_deadline_desc', 'coursework'),
18, PARAM_INT, 2));
- // Default per page
+ // Default per page
- $options = array('3' => '3', '10' => '10', '20' => '20', '30' => '30', '40' => '40', '50' => '50', '100' => '100');
+ $options = ['3' => '3', '10' => '10', '20' => '20', '30' => '30', '40' => '40', '50' => '50', '100' => '100'];
- $grading_page_header = new admin_setting_heading('grading_page_header', get_string('grading_page', 'mod_coursework'), '');
- $settings->add($grading_page_header);
+ $gradingpageheader = new admin_setting_heading('grading_page_header', get_string('grading_page', 'mod_coursework'), '');
+ $settings->add($gradingpageheader);
- $per_page = get_string('per_page', 'coursework');
- $per_page_description = get_string('per_page_desc', 'coursework');
- $settings->add(new admin_setting_configselect('coursework_per_page', $per_page, $per_page_description, '10', $options));
+ $perpage = get_string('per_page', 'coursework');
+ $perpagedescription = get_string('per_page_desc', 'coursework');
+ $settings->add(new admin_setting_configselect('coursework_per_page', $perpage, $perpagedescription, '10', $options));
// Automatic agreement delay
- $options = array('0' => get_string('disabled', 'mod_coursework'));
+ $options = ['0' => get_string('disabled', 'mod_coursework')];
$options['1800'] = get_string('timedminutes', 'mod_coursework', '30');
$options['3600'] = get_string('timedhour', 'mod_coursework', '1');
$options['7200'] = get_string('timedhours', 'mod_coursework', '2');
@@ -190,31 +190,31 @@
$options['43200'] = get_string('timedhours', 'mod_coursework', '12');
$options['86400'] = get_string('aday', 'mod_coursework');
- $grade_editing_header = new admin_setting_heading('grade_editing_header', get_string('grade_editing', 'mod_coursework'), '');
- $settings->add($grade_editing_header);
+ $gradeeditingheader = new admin_setting_heading('grade_editing_header', get_string('grade_editing', 'mod_coursework'), '');
+ $settings->add($gradeeditingheader);
- $grade_editing_name = get_string('grade_editing_enabled', 'coursework');
- $grade_editing_description = get_string('grade_editing_enabled_desc', 'coursework');
- $settings->add(new admin_setting_configselect('coursework_grade_editing', $grade_editing_name, $grade_editing_description, '0', $options));
+ $gradeeditingname = get_string('grade_editing_enabled', 'coursework');
+ $gradeeditingdescription = get_string('grade_editing_enabled_desc', 'coursework');
+ $settings->add(new admin_setting_configselect('coursework_grade_editing', $gradeeditingname, $gradeeditingdescription, '0', $options));
// Deadline defaults
- $deadline_defaults_header = new admin_setting_heading('deadline_defaults_header', get_string('deadline_defaults', 'mod_coursework'), '');
- $settings->add($deadline_defaults_header);
+ $deadlinedefaultsheader = new admin_setting_heading('deadline_defaults_header', get_string('deadline_defaults', 'mod_coursework'), '');
+ $settings->add($deadlinedefaultsheader);
// Marking deadline
- $options = array('0' => get_string('disabled', 'mod_coursework'));
+ $options = ['0' => get_string('disabled', 'mod_coursework')];
$options['7'] = get_string('oneweekoption', 'mod_coursework');
$options['14'] = get_string('twoweeksoption', 'mod_coursework');
$options['21'] = get_string('threeweeksoption', 'mod_coursework');
$options['28'] = get_string('fourweeksoption', 'mod_coursework');
$options['35'] = get_string('fiveweeksoption', 'mod_coursework');
$options['42'] = get_string('sixweeksoption', 'mod_coursework');
- $marking_deadline_name = get_string('marking_deadline_default', 'coursework');
- $marking_deadline_description = get_string('marking_deadline_enabled_desc', 'coursework');
- $settings->add(new admin_setting_configselect('coursework_marking_deadline', $marking_deadline_name, $marking_deadline_description, '0', $options));
+ $markingdeadlinename = get_string('marking_deadline_default', 'coursework');
+ $markingdeadlinedescription = get_string('marking_deadline_enabled_desc', 'coursework');
+ $settings->add(new admin_setting_configselect('coursework_marking_deadline', $markingdeadlinename, $markingdeadlinedescription, '0', $options));
// Marking deadline
- $options = array('0' => get_string('disabled', 'mod_coursework'));
+ $options = ['0' => get_string('disabled', 'mod_coursework')];
$options['7'] = get_string('oneweekoption', 'mod_coursework');
$options['14'] = get_string('twoweeksoption', 'mod_coursework');
$options['21'] = get_string('threeweeksoption', 'mod_coursework');
@@ -222,34 +222,34 @@
$options['35'] = get_string('fiveweeksoption', 'mod_coursework');
$options['42'] = get_string('sixweeksoption', 'mod_coursework');
- $agreed_marking_deadline_name = get_string('agreed_marking_deadline_default', 'coursework');
- $agreed_marking_deadline_description = get_string('agreed_marking_deadline_default_desc', 'coursework');
- $settings->add(new admin_setting_configselect('coursework_agreed_marking_deadline', $agreed_marking_deadline_name, $agreed_marking_deadline_description, '0', $options));
+ $agreedmarkingdeadlinename = get_string('agreed_marking_deadline_default', 'coursework');
+ $agreedmarkingdeadlinedescription = get_string('agreed_marking_deadline_default_desc', 'coursework');
+ $settings->add(new admin_setting_configselect('coursework_agreed_marking_deadline', $agreedmarkingdeadlinename, $agreedmarkingdeadlinedescription, '0', $options));
// Start date
- $options = array('0' => get_string('disabled', 'mod_coursework'));
+ $options = ['0' => get_string('disabled', 'mod_coursework')];
$options['1'] = get_string('today', 'mod_coursework');
- $start_date_name = get_string('startdate', 'coursework');
- $start_date_description = get_string('start_date_enabled_desc', 'coursework');
- $settings->add(new admin_setting_configselect('coursework_start_date', $start_date_name, $start_date_description, '0', $options));
+ $startdatename = get_string('startdate', 'coursework');
+ $startdatedescription = get_string('start_date_enabled_desc', 'coursework');
+ $settings->add(new admin_setting_configselect('coursework_start_date', $startdatename, $startdatedescription, '0', $options));
// Submission deadline
- $options = array('0' => get_string('disabled', 'mod_coursework'));
+ $options = ['0' => get_string('disabled', 'mod_coursework')];
$options['1'] = get_string('today', 'mod_coursework');
$options['7'] = get_string('sevendays', 'mod_coursework');
$options['14'] = get_string('fourteendays', 'mod_coursework');
$options['31'] = get_string('onemonth', 'mod_coursework');
- $submission_deadline_name = get_string('submissiondeadline', 'coursework');
- $submission_deadline_description = get_string('submission_deadline_enabled_desc', 'coursework');
- $settings->add(new admin_setting_configselect('coursework_submission_deadline', $submission_deadline_name, $submission_deadline_description, '0', $options));
+ $submissiondeadlinename = get_string('submissiondeadline', 'coursework');
+ $submissiondeadlinedescription = get_string('submission_deadline_enabled_desc', 'coursework');
+ $settings->add(new admin_setting_configselect('coursework_submission_deadline', $submissiondeadlinename, $submissiondeadlinedescription, '0', $options));
// Assessor allocations
- $assessor_allocations_header = new admin_setting_heading('assessor_allocations_header_header', get_string('assessorallocations', 'mod_coursework'), '');
- $settings->add($assessor_allocations_header);
+ $assessorallocationsheader = new admin_setting_heading('assessor_allocations_header_header', get_string('assessorallocations', 'mod_coursework'), '');
+ $settings->add($assessorallocationsheader);
- $options = array( 'username' => get_string('username'), 'email' => get_string('email'));
+ $options = [ 'username' => get_string('username'), 'email' => get_string('email')];
$settings->add(new admin_setting_configselect('coursework_allocation_identifier', get_string('allocationidentifier', 'coursework'), get_string('allocationidentifier_desc', 'coursework'), 'username', $options));
}
diff --git a/tests/behat/pages/coursework_page.php b/tests/behat/pages/coursework_page.php
index 1e2ca213..59bfa617 100644
--- a/tests/behat/pages/coursework_page.php
+++ b/tests/behat/pages/coursework_page.php
@@ -41,8 +41,8 @@ class mod_coursework_behat_coursework_page extends mod_coursework_behat_page_bas
*/
public function individual_feedback_date_present() {
$table = $this->getPage()->find('css', 'table.deadlines');
- $table_header_present = strpos($table->getText(), 'utomatically release individual feedback') !== false;
- return $table_header_present;
+ $tableheaderpresent = strpos($table->getText(), 'utomatically release individual feedback') !== false;
+ return $tableheaderpresent;
}
/**
@@ -50,8 +50,8 @@ public function individual_feedback_date_present() {
*/
public function general_feedback_date_present() {
$table = $this->getPage()->find('css', 'table.deadlines');
- $table_header_present = strpos($table->getText(), 'General feedback deadline');
- return $table_header_present !== false;
+ $tableheaderpresent = strpos($table->getText(), 'General feedback deadline');
+ return $tableheaderpresent !== false;
}
public function confirm() {
@@ -68,21 +68,21 @@ public function show_hide_non_allocated_students() {
}
}
- public function get_coursework_name($courseworkName) {
- $coursework_heading = $this->getPage()->find('css', 'h2');
- $coursework_heading_present = strpos($coursework_heading->getText(), $courseworkName);
+ public function get_coursework_name($courseworkname) {
+ $courseworkheading = $this->getPage()->find('css', 'h2');
+ $courseworkheadingpresent = strpos($courseworkheading->getText(), $courseworkname);
- return $coursework_heading_present !== false;
+ return $courseworkheadingpresent !== false;
}
- public function get_coursework_student_name($studentName) {
- $table_users = $this->getPage()->findAll('css', 'table.submissions');
+ public function get_coursework_student_name($studentname) {
+ $tableusers = $this->getPage()->findAll('css', 'table.submissions');
- if (!empty($table_users)) {
- foreach ($table_users as $table_user) {
- $coursework_student_name = strpos($table_user->getText(), $studentName);
+ if (!empty($tableusers)) {
+ foreach ($tableusers as $tableuser) {
+ $courseworkstudentname = strpos($tableuser->getText(), $studentname);
- if ($coursework_student_name !== false) {
+ if ($courseworkstudentname !== false) {
return true;
}
}
diff --git a/tests/classes/rule_test.php b/tests/classes/rule_test.php
index 68fcd3b6..814f003f 100644
--- a/tests/classes/rule_test.php
+++ b/tests/classes/rule_test.php
@@ -32,37 +32,37 @@ class abiity_rule_test extends basic_testcase {
public function test_allows_when_allowed_and_rule_returns_true() {
$coursework = new \mod_coursework\models\coursework();
- $rule_function = function ($object) {
+ $rulefunction = function ($object) {
return true;
};
- $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rule_function, true );
+ $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rulefunction, true );
$this->assertTrue($rule->allows($coursework));
}
public function test_allows_when_prevent_and_rule_returns_true() {
$coursework = new \mod_coursework\models\coursework();
- $rule_function = function ($object) {
+ $rulefunction = function ($object) {
return true;
};
- $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rule_function, false);
+ $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rulefunction, false);
$this->assertFalse($rule->allows($coursework));
}
public function test_prevents_when_allowed_and_rule_returns_true() {
$coursework = new \mod_coursework\models\coursework();
- $rule_function = function ($object) {
+ $rulefunction = function ($object) {
return true;
};
- $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rule_function, true);
+ $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rulefunction, true);
$this->assertFalse($rule->prevents($coursework));
}
public function test_prevents_when_prevent_and_rule_returns_true() {
$coursework = new \mod_coursework\models\coursework();
- $rule_function = function ($object) {
+ $rulefunction = function ($object) {
return true;
};
- $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rule_function, false);
+ $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rulefunction, false);
$this->assertTrue($rule->prevents($coursework));
}
@@ -70,37 +70,37 @@ public function test_prevents_when_prevent_and_rule_returns_true() {
public function test_allows_when_allowed_and_rule_returns_false() {
$coursework = new \mod_coursework\models\coursework();
- $rule_function = function ($object) {
+ $rulefunction = function ($object) {
return false;
};
- $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rule_function, true);
+ $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rulefunction, true);
$this->assertFalse($rule->allows($coursework));
}
public function test_allows_when_prevent_and_rule_returns_false() {
$coursework = new \mod_coursework\models\coursework();
- $rule_function = function ($object) {
+ $rulefunction = function ($object) {
return false;
};
- $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rule_function, false);
+ $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rulefunction, false);
$this->assertFalse($rule->allows($coursework));
}
public function test_prevents_when_allowed_and_rule_returns_false() {
$coursework = new \mod_coursework\models\coursework();
- $rule_function = function ($object) {
+ $rulefunction = function ($object) {
return false;
};
- $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rule_function, true);
+ $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rulefunction, true);
$this->assertFalse($rule->prevents($coursework));
}
public function test_prevents_when_prevent_and_rule_returns_false() {
$coursework = new \mod_coursework\models\coursework();
- $rule_function = function ($object) {
+ $rulefunction = function ($object) {
return false;
};
- $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rule_function, false);
+ $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rulefunction, false);
$this->assertFalse($rule->prevents($coursework));
}
}
diff --git a/tests/generator/lib.php b/tests/generator/lib.php
index fe449eae..12a56be1 100644
--- a/tests/generator/lib.php
+++ b/tests/generator/lib.php
@@ -240,7 +240,7 @@ public function create_submission($submission, $coursework) {
$fs = get_file_storage();
// Prepare file record object
- $fileinfo = array(
+ $fileinfo = [
'contextid' => $coursework->get_context_id(),
// ID of context
'component' => 'mod_coursework',
@@ -251,7 +251,7 @@ public function create_submission($submission, $coursework) {
// usually = ID of row in table
'filepath' => '/',
// any path beginning and ending in /
- 'filename' => 'myfile.txt'); // any filename
+ 'filename' => 'myfile.txt']; // any filename
// Create file containing text 'hello world'
$fs->create_file_from_string($fileinfo, 'hello world');
diff --git a/version.php b/version.php
index c671f302..f6f52b99 100644
--- a/version.php
+++ b/version.php
@@ -24,7 +24,7 @@
$plugin->component = 'mod_coursework';
-$plugin->version = 2024082700; // If version == 0 then module will not be installed
+$plugin->version = 2024090300; // If version == 0 then module will not be installed
$plugin->requires = 2023100400; // Requires this Moodle version
$plugin->cron = 300; // Period for cron to check this module (secs).
diff --git a/view.php b/view.php
index 51bb866e..b8ae5bfe 100644
--- a/view.php
+++ b/view.php
@@ -42,22 +42,22 @@
require_once($CFG->dirroot . '/mod/coursework/classes/export/csv.php');
// TODO move all js to renderer.
-$jsmodule = array(
+$jsmodule = [
'name' => 'mod_coursework',
'fullpath' => '/mod/coursework/module.js',
- 'requires' => array('base',
- 'node-base'),
- 'strings' => []
-);
+ 'requires' => ['base',
+ 'node-base'],
+ 'strings' => [],
+];
$PAGE->requires->yui_module('moodle-core-notification', 'notification_init');
// Course_module ID, or coursework instance ID - it should be named as the first character of the module.
-$course_module_id = optional_param('id', 0, PARAM_INT);
-$coursework_id = optional_param('e', 0, PARAM_INT);
+$coursemoduleid = optional_param('id', 0, PARAM_INT);
+$courseworkid = optional_param('e', 0, PARAM_INT);
// Hacky fix for the need for the form to self-submit to this page.
-if (!$coursework_id) {
- $coursework_id = optional_param('courseworkid', 0, PARAM_INT);
+if (!$courseworkid) {
+ $courseworkid = optional_param('courseworkid', 0, PARAM_INT);
}
$publish = optional_param('publishbutton', 0, PARAM_ALPHA);
$download = optional_param('download', false, PARAM_BOOL);
@@ -65,184 +65,184 @@
$resubmitted = optional_param('resubmitted', 0, PARAM_INT); // Is this a post-resubmit redirect?
$submissionid = optional_param('submissionid', 0, PARAM_INT); // Which thing to resubmit.
$confirm = optional_param('confirm', 0, PARAM_INT);
-$export_grades = optional_param('export', false, PARAM_BOOL);
-$download_grading_sheet = optional_param('export_grading_sheet', false, PARAM_BOOL);
+$exportgrades = optional_param('export', false, PARAM_BOOL);
+$downloadgradingsheet = optional_param('export_grading_sheet', false, PARAM_BOOL);
$group = optional_param('group', -1, PARAM_INT);
$resettable = optional_param('treset', 0, PARAM_INT);
$allresettable = optional_param('alltreset', 0, PARAM_INT);
-if (!isset($SESSION->displayallstudents[$course_module_id])) {
- $SESSION->displayallstudents[$course_module_id] = optional_param('displayallstudents', false, PARAM_BOOL);
+if (!isset($SESSION->displayallstudents[$coursemoduleid])) {
+ $SESSION->displayallstudents[$coursemoduleid] = optional_param('displayallstudents', false, PARAM_BOOL);
- $displayallstudents = $SESSION->displayallstudents[$course_module_id];
+ $displayallstudents = $SESSION->displayallstudents[$coursemoduleid];
} else {
- $displayallstudents = optional_param('displayallstudents', $SESSION->displayallstudents[$course_module_id], PARAM_INT);
- $SESSION->displayallstudents[$course_module_id] = $displayallstudents;
+ $displayallstudents = optional_param('displayallstudents', $SESSION->displayallstudents[$coursemoduleid], PARAM_INT);
+ $SESSION->displayallstudents[$coursemoduleid] = $displayallstudents;
}
// If a session variable holding page preference for the specific coursework is not set, set default value (0).
-if (isset($SESSION->perpage[$course_module_id]) && optional_param('per_page', 0, PARAM_INT) != $SESSION->perpage[$course_module_id]
+if (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
$page = 0;
- $SESSION->page[$course_module_id] = $page;
-} else if (!(isset($SESSION->page[$course_module_id]))) {
- $SESSION->page[$course_module_id] = optional_param('page', 0, PARAM_INT);
- $page = $SESSION->page[$course_module_id];
+ $SESSION->page[$coursemoduleid] = $page;
+} else if (!(isset($SESSION->page[$coursemoduleid]))) {
+ $SESSION->page[$coursemoduleid] = optional_param('page', 0, PARAM_INT);
+ $page = $SESSION->page[$coursemoduleid];
} else {
- $page = optional_param('page', $SESSION->page[$course_module_id], PARAM_INT);
- $SESSION->page[$course_module_id] = $page;
+ $page = optional_param('page', $SESSION->page[$coursemoduleid], PARAM_INT);
+ $SESSION->page[$coursemoduleid] = $page;
}
// If a session variable holding perpage preference for the specific coursework is not set, set default value (grab default value from global setting).
-if (!(isset($SESSION->perpage[$course_module_id]))) {
- $SESSION->perpage[$course_module_id] = optional_param('per_page', $CFG->coursework_per_page, PARAM_INT);
- $perpage = $SESSION->perpage[$course_module_id];
+if (!(isset($SESSION->perpage[$coursemoduleid]))) {
+ $SESSION->perpage[$coursemoduleid] = optional_param('per_page', $CFG->coursework_per_page, PARAM_INT);
+ $perpage = $SESSION->perpage[$coursemoduleid];
} else {
- $perpage = optional_param('per_page', $SESSION->perpage[$course_module_id], PARAM_INT);
- $SESSION->perpage[$course_module_id] = $perpage;
+ $perpage = optional_param('per_page', $SESSION->perpage[$coursemoduleid], PARAM_INT);
+ $SESSION->perpage[$coursemoduleid] = $perpage;
}
// If a session variable holding sortby preference for the specific coursework is not set, set default value ('lastname').
-if (!(isset($SESSION->sortby[$course_module_id]))) {
- $SESSION->sortby[$course_module_id] = optional_param('sortby', 'lastname', PARAM_ALPHA);
- $sortby = $SESSION->sortby[$course_module_id];
+if (!(isset($SESSION->sortby[$coursemoduleid]))) {
+ $SESSION->sortby[$coursemoduleid] = optional_param('sortby', 'lastname', PARAM_ALPHA);
+ $sortby = $SESSION->sortby[$coursemoduleid];
} else {
- $sortby = optional_param('sortby', $SESSION->sortby[$course_module_id], PARAM_ALPHA);
- $SESSION->sortby[$course_module_id] = $sortby;
+ $sortby = optional_param('sortby', $SESSION->sortby[$coursemoduleid], PARAM_ALPHA);
+ $SESSION->sortby[$coursemoduleid] = $sortby;
}
// If a session variable holding sorthow preference for the specific coursework is not set, set default value ('ASC').
-if (!(isset($SESSION->sorthow[$course_module_id]))) {
- $SESSION->sorthow[$course_module_id] = optional_param('sorthow', 'ASC', PARAM_ALPHA);
- $sorthow = $SESSION->sorthow[$course_module_id];
+if (!(isset($SESSION->sorthow[$coursemoduleid]))) {
+ $SESSION->sorthow[$coursemoduleid] = optional_param('sorthow', 'ASC', PARAM_ALPHA);
+ $sorthow = $SESSION->sorthow[$coursemoduleid];
} else {
- $sorthow = optional_param('sorthow', $SESSION->sorthow[$course_module_id], PARAM_ALPHA);
- $SESSION->sorthow[$course_module_id] = $sorthow;
+ $sorthow = optional_param('sorthow', $SESSION->sorthow[$coursemoduleid], PARAM_ALPHA);
+ $SESSION->sorthow[$coursemoduleid] = $sorthow;
}
// First name alpha
-if (!(isset($SESSION->coursework_firstname_alpha[$course_module_id]))) {
- $SESSION->coursework_firstname_alpha[$course_module_id] = optional_param('coursework_firstname_alpha', '', PARAM_ALPHA);
- $coursework_firstname_alpha = $SESSION->coursework_firstname_alpha[$course_module_id];
+if (!(isset($SESSION->coursework_firstname_alpha[$coursemoduleid]))) {
+ $SESSION->coursework_firstname_alpha[$coursemoduleid] = optional_param('coursework_firstname_alpha', '', PARAM_ALPHA);
+ $courseworkfirstnamealpha = $SESSION->coursework_firstname_alpha[$coursemoduleid];
} else {
- $coursework_firstname_alpha = optional_param('coursework_firstname_alpha', $SESSION->coursework_firstname_alpha[$course_module_id], PARAM_ALPHA);
- $SESSION->coursework_firstname_alpha[$course_module_id] = $coursework_firstname_alpha;
+ $courseworkfirstnamealpha = optional_param('coursework_firstname_alpha', $SESSION->coursework_firstname_alpha[$coursemoduleid], PARAM_ALPHA);
+ $SESSION->coursework_firstname_alpha[$coursemoduleid] = $courseworkfirstnamealpha;
}
// Last name alpha
-if (!(isset($SESSION->coursework_lastname_alpha[$course_module_id]))) {
- $SESSION->coursework_lastname_alpha[$course_module_id] = optional_param('coursework_lastname_alpha', '', PARAM_ALPHA);
- $coursework_lastname_alpha = $SESSION->coursework_lastname_alpha[$course_module_id];
+if (!(isset($SESSION->coursework_lastname_alpha[$coursemoduleid]))) {
+ $SESSION->coursework_lastname_alpha[$coursemoduleid] = optional_param('coursework_lastname_alpha', '', PARAM_ALPHA);
+ $courseworklastnamealpha = $SESSION->coursework_lastname_alpha[$coursemoduleid];
} else {
- $coursework_lastname_alpha = optional_param('coursework_lastname_alpha', $SESSION->coursework_lastname_alpha[$course_module_id], PARAM_ALPHA);
- $SESSION->coursework_lastname_alpha[$course_module_id] = $coursework_lastname_alpha;
+ $courseworklastnamealpha = optional_param('coursework_lastname_alpha', $SESSION->coursework_lastname_alpha[$coursemoduleid], PARAM_ALPHA);
+ $SESSION->coursework_lastname_alpha[$coursemoduleid] = $courseworklastnamealpha;
}
// Group name alpha
-if (!(isset($SESSION->coursework_groupname_alpha[$course_module_id]))) {
- $SESSION->coursework_groupname_alpha[$course_module_id] = optional_param('coursework_groupname_alpha', '', PARAM_ALPHA);
- $coursework_groupname_alpha = $SESSION->coursework_groupname_alpha[$course_module_id];
+if (!(isset($SESSION->coursework_groupname_alpha[$coursemoduleid]))) {
+ $SESSION->coursework_groupname_alpha[$coursemoduleid] = optional_param('coursework_groupname_alpha', '', PARAM_ALPHA);
+ $courseworkgroupnamealpha = $SESSION->coursework_groupname_alpha[$coursemoduleid];
} else {
- $coursework_groupname_alpha = optional_param('coursework_groupname_alpha', $SESSION->coursework_groupname_alpha[$course_module_id], PARAM_ALPHA);
- $SESSION->coursework_groupname_alpha[$course_module_id] = $coursework_groupname_alpha;
+ $courseworkgroupnamealpha = optional_param('coursework_groupname_alpha', $SESSION->coursework_groupname_alpha[$coursemoduleid], PARAM_ALPHA);
+ $SESSION->coursework_groupname_alpha[$coursemoduleid] = $courseworkgroupnamealpha;
}
// We will use the same defaults as page (above) defaulting to page setting if no specific viewallstudents_page has been set
-if (isset($SESSION->viewallstudents_perpage[$course_module_id]) && optional_param('viewallstudents_per_page', 0, PARAM_INT) != $SESSION->viewallstudents_perpage[$course_module_id]
+if (isset($SESSION->viewallstudents_perpage[$coursemoduleid]) && optional_param('viewallstudents_per_page', 0, PARAM_INT) != $SESSION->viewallstudents_perpage[$coursemoduleid]
&& optional_param('viewallstudents_per_page', 0, PARAM_INT) != 0) { // prevent blank pages if not in correct page
- $viewallstudents_page = 0;
- $SESSION->viewallstudents_page[$course_module_id] = $viewallstudents_page;
-} else if (!(isset($SESSION->viewallstudents_page[$course_module_id]))) {
- $SESSION->viewallstudents_page[$course_module_id] = optional_param('viewallstudents_page', 0, PARAM_INT);
- $viewallstudents_page = $SESSION->viewallstudents_page[$course_module_id];
+ $viewallstudentspage = 0;
+ $SESSION->viewallstudents_page[$coursemoduleid] = $viewallstudentspage;
+} else if (!(isset($SESSION->viewallstudents_page[$coursemoduleid]))) {
+ $SESSION->viewallstudents_page[$coursemoduleid] = optional_param('viewallstudents_page', 0, PARAM_INT);
+ $viewallstudentspage = $SESSION->viewallstudents_page[$coursemoduleid];
} else {
- $viewallstudents_page = optional_param('viewallstudents_page', $SESSION->viewallstudents_page[$course_module_id], PARAM_INT);
- $SESSION->viewallstudents_page[$course_module_id] = $viewallstudents_page;
+ $viewallstudentspage = optional_param('viewallstudents_page', $SESSION->viewallstudents_page[$coursemoduleid], PARAM_INT);
+ $SESSION->viewallstudents_page[$coursemoduleid] = $viewallstudentspage;
}
// We will use the same defaults as perpage (above) defaulting to perpage setting if no specific viewallstudents_perpage has been set
-if (!(isset($SESSION->viewallstudents_perpage[$course_module_id]))) {
- $SESSION->viewallstudents_perpage[$course_module_id] = optional_param('viewallstudents_per_page', $perpage, PARAM_INT);
- $viewallstudents_perpage = $SESSION->viewallstudents_perpage[$course_module_id];
+if (!(isset($SESSION->viewallstudents_perpage[$coursemoduleid]))) {
+ $SESSION->viewallstudents_perpage[$coursemoduleid] = optional_param('viewallstudents_per_page', $perpage, PARAM_INT);
+ $viewallstudentsperpage = $SESSION->viewallstudents_perpage[$coursemoduleid];
} else {
- $viewallstudents_perpage = optional_param('viewallstudents_per_page', $SESSION->perpage[$course_module_id], PARAM_INT);
- $SESSION->viewallstudents_perpage[$course_module_id] = $viewallstudents_perpage;
+ $viewallstudentsperpage = optional_param('viewallstudents_per_page', $SESSION->perpage[$coursemoduleid], PARAM_INT);
+ $SESSION->viewallstudents_perpage[$coursemoduleid] = $viewallstudentsperpage;
}
// We will use the same defaults as sortby (above) defaulting to sortby setting if no specific viewallstudents_sortby has been set
-if (!(isset($SESSION->viewallstudents_sortby[$course_module_id]))) {
- $SESSION->viewallstudents_sortby[$course_module_id] = optional_param('viewallstudents_sortby', $sortby, PARAM_ALPHA);
- $viewallstudents_sortby = $SESSION->viewallstudents_sortby[$course_module_id];
+if (!(isset($SESSION->viewallstudents_sortby[$coursemoduleid]))) {
+ $SESSION->viewallstudents_sortby[$coursemoduleid] = optional_param('viewallstudents_sortby', $sortby, PARAM_ALPHA);
+ $viewallstudentssortby = $SESSION->viewallstudents_sortby[$coursemoduleid];
} else {
- $viewallstudents_sortby = optional_param('viewallstudents_sortby', $SESSION->sortby[$course_module_id], PARAM_ALPHA);
- $SESSION->viewallstudents_sortby[$course_module_id] = $viewallstudents_sortby;
+ $viewallstudentssortby = optional_param('viewallstudents_sortby', $SESSION->sortby[$coursemoduleid], PARAM_ALPHA);
+ $SESSION->viewallstudents_sortby[$coursemoduleid] = $viewallstudentssortby;
}
// We will use the same defaults as sorthow (above) defaulting to sorthow setting if no specific viewallstudents_sorthow has been set
-if (!(isset($SESSION->viewallstudents_sorthow[$course_module_id]))) {
- $SESSION->viewallstudents_sorthow[$course_module_id] = optional_param('viewallstudents_sorthow', $sorthow, PARAM_ALPHA);
- $viewallstudents_sorthow = $SESSION->viewallstudents_sorthow[$course_module_id];
+if (!(isset($SESSION->viewallstudents_sorthow[$coursemoduleid]))) {
+ $SESSION->viewallstudents_sorthow[$coursemoduleid] = optional_param('viewallstudents_sorthow', $sorthow, PARAM_ALPHA);
+ $viewallstudentssorthow = $SESSION->viewallstudents_sorthow[$coursemoduleid];
} else {
- $viewallstudents_sorthow = optional_param('viewallstudents_sorthow', $SESSION->sorthow[$course_module_id], PARAM_ALPHA);
- $SESSION->viewallstudents_sorthow[$course_module_id] = $viewallstudents_sorthow;
+ $viewallstudentssorthow = optional_param('viewallstudents_sorthow', $SESSION->sorthow[$coursemoduleid], PARAM_ALPHA);
+ $SESSION->viewallstudents_sorthow[$coursemoduleid] = $viewallstudentssorthow;
}
// First name alpha
-if (!(isset($SESSION->viewallstudents_firstname_alpha[$course_module_id]))) {
- $SESSION->viewallstudents_firstname_alpha[$course_module_id] = optional_param('viewallstudents_firstname_alpha', '', PARAM_ALPHA);
- $viewallstudents_firstname_alpha = $SESSION->coursework_firstname_alpha[$course_module_id];
+if (!(isset($SESSION->viewallstudents_firstname_alpha[$coursemoduleid]))) {
+ $SESSION->viewallstudents_firstname_alpha[$coursemoduleid] = optional_param('viewallstudents_firstname_alpha', '', PARAM_ALPHA);
+ $viewallstudentsfirstnamealpha = $SESSION->coursework_firstname_alpha[$coursemoduleid];
} else {
- $viewallstudents_firstname_alpha = optional_param('viewallstudents_firstname_alpha', $SESSION->viewallstudents_firstname_alpha[$course_module_id], PARAM_ALPHA);
- $SESSION->viewallstudents_firstname_alpha[$course_module_id] = $viewallstudents_firstname_alpha;
+ $viewallstudentsfirstnamealpha = optional_param('viewallstudents_firstname_alpha', $SESSION->viewallstudents_firstname_alpha[$coursemoduleid], PARAM_ALPHA);
+ $SESSION->viewallstudents_firstname_alpha[$coursemoduleid] = $viewallstudentsfirstnamealpha;
}
// Last name alpha
-if (!(isset($SESSION->viewallstudents_lastname_alpha[$course_module_id]))) {
- $SESSION->viewallstudents_lastname_alpha[$course_module_id] = optional_param('viewallstudents_lastname_alpha', '', PARAM_ALPHA);
- $viewallstudents_lastname_alpha = $SESSION->viewallstudents_lastname_alpha[$course_module_id];
+if (!(isset($SESSION->viewallstudents_lastname_alpha[$coursemoduleid]))) {
+ $SESSION->viewallstudents_lastname_alpha[$coursemoduleid] = optional_param('viewallstudents_lastname_alpha', '', PARAM_ALPHA);
+ $viewallstudentslastnamealpha = $SESSION->viewallstudents_lastname_alpha[$coursemoduleid];
} else {
- $viewallstudents_lastname_alpha = optional_param('viewallstudents_lastname_alpha', $SESSION->viewallstudents_lastname_alpha[$course_module_id], PARAM_ALPHA);
- $SESSION->viewallstudents_lastname_alpha[$course_module_id] = $viewallstudents_lastname_alpha;
+ $viewallstudentslastnamealpha = optional_param('viewallstudents_lastname_alpha', $SESSION->viewallstudents_lastname_alpha[$coursemoduleid], PARAM_ALPHA);
+ $SESSION->viewallstudents_lastname_alpha[$coursemoduleid] = $viewallstudentslastnamealpha;
}
// Group name alpha
-if (!(isset($SESSION->viewallstudents_groupname_alpha[$course_module_id]))) {
- $SESSION->viewallstudents_groupname_alpha[$course_module_id] = optional_param('viewallstudents_groupname_alpha', '', PARAM_ALPHA);
- $viewallstudents_groupname_alpha = $SESSION->viewallstudents_groupname_alpha[$course_module_id];
+if (!(isset($SESSION->viewallstudents_groupname_alpha[$coursemoduleid]))) {
+ $SESSION->viewallstudents_groupname_alpha[$coursemoduleid] = optional_param('viewallstudents_groupname_alpha', '', PARAM_ALPHA);
+ $viewallstudentsgroupnamealpha = $SESSION->viewallstudents_groupname_alpha[$coursemoduleid];
} else {
- $viewallstudents_groupname_alpha = optional_param('viewallstudents_groupname_alpha', $SESSION->viewallstudents_groupname_alpha[$course_module_id], PARAM_ALPHA);
- $SESSION->viewallstudents_groupname_alpha[$course_module_id] = $viewallstudents_groupname_alpha;
+ $viewallstudentsgroupnamealpha = optional_param('viewallstudents_groupname_alpha', $SESSION->viewallstudents_groupname_alpha[$coursemoduleid], PARAM_ALPHA);
+ $SESSION->viewallstudents_groupname_alpha[$coursemoduleid] = $viewallstudentsgroupnamealpha;
}
if (!($sorthow === 'ASC' || $sorthow === 'DESC')) {
$sorthow = 'ASC';
}
-$coursework_record = new stdClass();
+$courseworkrecord = new stdClass();
-if ($course_module_id) {
- $course_module = get_coursemodule_from_id('coursework',
- $course_module_id,
+if ($coursemoduleid) {
+ $coursemodule = get_coursemodule_from_id('coursework',
+ $coursemoduleid,
0,
false,
MUST_EXIST);
- $course = $DB->get_record('course', array('id' => $course_module->course), '*', MUST_EXIST);
- $coursework_record = $DB->get_record('coursework',
- array('id' => $course_module->instance),
+ $course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST);
+ $courseworkrecord = $DB->get_record('coursework',
+ ['id' => $coursemodule->instance],
'*',
MUST_EXIST);
} else {
- if ($coursework_id) {
- $coursework_record = $DB->get_record('coursework',
- array('id' => $coursework_id),
+ if ($courseworkid) {
+ $courseworkrecord = $DB->get_record('coursework',
+ ['id' => $courseworkid],
'*',
MUST_EXIST);
$course = $DB->get_record('course',
- array('id' => $coursework_record->course),
+ ['id' => $courseworkrecord->course],
'*',
MUST_EXIST);
- $course_module = get_coursemodule_from_instance('coursework',
- $coursework_record->id,
+ $coursemodule = get_coursemodule_from_instance('coursework',
+ $courseworkrecord->id,
$course->id,
false,
MUST_EXIST);
@@ -251,7 +251,7 @@
}
}
-$coursework = mod_coursework\models\coursework::find($coursework_record);
+$coursework = mod_coursework\models\coursework::find($courseworkrecord);
// Check if group is in session and use it no group available in url
if (groups_get_activity_groupmode($coursework->get_course_module()) != 0 && $group == -1) {
@@ -291,68 +291,68 @@
}
// This will set $PAGE->context to the coursemodule's context.
-require_login($course, true, $course_module);
+require_login($course, true, $coursemodule);
// Name of new zip file.
$filename = str_replace(' ', '_', clean_filename($COURSE->shortname . '-' . $coursework->name . '.zip'));
-if ($download && $zip_file = $coursework->pack_files()) {
- send_temp_file($zip_file, $filename); // Send file and delete after sending.
+if ($download && $zipfile = $coursework->pack_files()) {
+ send_temp_file($zipfile, $filename); // Send file and delete after sending.
}
-if ($export_grades) {
+if ($exportgrades) {
// Headers and data for csv
- $csv_cells = array('name', 'username', 'idnumber', 'email');
+ $csvcells = ['name', 'username', 'idnumber', 'email'];
if ($coursework->personal_deadlines_enabled()) {
- $csv_cells[] = 'personaldeadline';
+ $csvcells[] = 'personaldeadline';
}
- $csv_cells[] = 'submissiondate';
- $csv_cells[] = 'submissiontime';
- $csv_cells[] = 'submissionfileid';
+ $csvcells[] = 'submissiondate';
+ $csvcells[] = 'submissiontime';
+ $csvcells[] = 'submissionfileid';
if ($coursework->extensions_enabled() && ($coursework->has_deadline()) || $coursework->personal_deadlines_enabled()) {
- $csv_cells[] = 'extensiondeadline';
- $csv_cells[] = 'extensionreason';
- $csv_cells[] = 'extensionextrainfo';
+ $csvcells[] = 'extensiondeadline';
+ $csvcells[] = 'extensionreason';
+ $csvcells[] = 'extensionextrainfo';
}
if ($coursework->plagiarism_flagging_enbled()) {
- $csv_cells[] = 'plagiarismflagstatus';
- $csv_cells[] = 'plagiarismflagcomment';
+ $csvcells[] = 'plagiarismflagstatus';
+ $csvcells[] = 'plagiarismflagcomment';
}
- $csv_cells[] = 'stages';
+ $csvcells[] = 'stages';
if ($coursework->moderation_agreement_enabled()) {
- $csv_cells[] = 'moderationagreement';
+ $csvcells[] = 'moderationagreement';
}
- $csv_cells[] = 'finalgrade';
+ $csvcells[] = 'finalgrade';
$timestamp = date('d_m_y @ H-i');
$filename = get_string('finalgradesfor', 'coursework'). $coursework->name .' '.$timestamp;
- $csv = new \mod_coursework\export\csv($coursework, $csv_cells, $filename);
+ $csv = new \mod_coursework\export\csv($coursework, $csvcells, $filename);
$csv->export();
}
-if ($download_grading_sheet) {
+if ($downloadgradingsheet) {
- $csv_cells = \mod_coursework\export\grading_sheet::cells_array($coursework);
+ $csvcells = \mod_coursework\export\grading_sheet::cells_array($coursework);
$timestamp = date('d_m_y @ H-i');
$filename = get_string('gradingsheetfor', 'coursework'). $coursework->name .' '.$timestamp;
- $grading_sheet = new \mod_coursework\export\grading_sheet($coursework, $csv_cells, $filename);
- $grading_sheet->export();
+ $gradingsheet = new \mod_coursework\export\grading_sheet($coursework, $csvcells, $filename);
+ $gradingsheet->export();
}
-$can_grade = has_capability('mod/coursework:addinitialgrade', $PAGE->context);
-$can_submit = has_capability('mod/coursework:submit', $PAGE->context);
-$can_view_students = false;
+$cangrade = has_capability('mod/coursework:addinitialgrade', $PAGE->context);
+$cansubmit = has_capability('mod/coursework:submit', $PAGE->context);
+$canviewstudents = false;
// TODO this is awful.
-$capabilities = array('addinstance',
+$capabilities = ['addinstance',
'submitonbehalfof',
'addinitialgrade',
'editinitialgrade',
@@ -367,49 +367,40 @@
'grantextensions',
'canexportfinalgrades',
'viewextensions',
- 'grade');
+ 'grade'];
foreach ($capabilities as $capability) {
if (has_capability('mod/coursework:' . $capability, $PAGE->context)) {
- $can_view_students = true;
+ $canviewstudents = true;
break;
}
}
-if ((float)substr($CFG->release, 0, 5) > 2.6) { // 2.8 > 2.6
- $event = \mod_coursework\event\course_module_viewed::create(array(
- 'objectid' => $coursework->id,
- 'context' => $coursework->get_context(),
- ));
- $event->trigger();
-} else {
- add_to_log($course->id,
- 'coursework',
- 'view',
- "view.php?id=$course_module->id",
- $coursework->name,
- $course_module->id);
-}
+
+$event = \mod_coursework\event\course_module_viewed::create(
+ ['objectid' => $coursework->id, 'context' => $coursework->get_context()]
+);
+$event->trigger();
// Print the page header.
// Sort group by groupname (default)
if ($coursework->is_configured_to_have_group_submissions()) {
$sortby = optional_param('sortby', 'groupname', PARAM_ALPHA);
- $viewallstudents_sortby = optional_param('viewallstudents_sortby', 'groupname', PARAM_ALPHA);
+ $viewallstudentssortby = optional_param('viewallstudents_sortby', 'groupname', PARAM_ALPHA);
}
-$params = array('id' => $course_module->id,
+$params = ['id' => $coursemodule->id,
'sortby' => $sortby,
'sorthow' => $sorthow,
'per_page' => $perpage,
- 'group' => $group);
+ 'group' => $group];
-if (!empty($SESSION->displayallstudents[$course_module_id])) {
- $params['viewallstudents_sorthow'] = $viewallstudents_sorthow;
- $params['viewallstudents_sortby'] = $viewallstudents_sortby;
- $params['viewallstudents_per_page'] = $viewallstudents_perpage;
+if (!empty($SESSION->displayallstudents[$coursemoduleid])) {
+ $params['viewallstudents_sorthow'] = $viewallstudentssorthow;
+ $params['viewallstudents_sortby'] = $viewallstudentssortby;
+ $params['viewallstudents_per_page'] = $viewallstudentsperpage;
}
$PAGE->set_url('/mod/coursework/view.php', $params);
@@ -437,25 +428,25 @@
/**
* @var mod_coursework_object_renderer $object_renderer
*/
-$object_renderer = $PAGE->get_renderer('mod_coursework', 'object');
+$objectrenderer = $PAGE->get_renderer('mod_coursework', 'object');
/**
* @var mod_coursework_page_renderer $page_renderer
*/
-$page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
+$pagerenderer = $PAGE->get_renderer('mod_coursework', 'page');
-$html .= $object_renderer->render(new mod_coursework_coursework($coursework));
+$html .= $objectrenderer->render(new mod_coursework_coursework($coursework));
// Allow tutors to upload files as part of the coursework task? Easily done via the main
// course thing, so not necessary.
// If this is a student, show the submission form, or their existing submission, or both
// There is scope for an arbitrary number of files to be added here, before the deadline.
-if ($can_submit && !$can_grade) {
- $html .= $page_renderer->student_view_page($coursework, \mod_coursework\models\user::find($USER));
+if ($cansubmit && !$cangrade) {
+ $html .= $pagerenderer->student_view_page($coursework, \mod_coursework\models\user::find($USER));
}
// Display the submissions table of all the students instead.
-if ($can_view_students) {
+if ($canviewstudents) {
// If the resubmit button was pressed (for plagiarism), we need to fire a new event.
if ($resubmit && $submissionid) {
@@ -465,10 +456,10 @@
*/
$submission = submission::find($submissionid);
- $params = array(
- 'cm' => $course_module->id,
+ $params = [
+ 'cm' => $coursemodule->id,
'userid' => $submission->get_author_id(),
- );
+ ];
// Get the hash so we can retrieve the file and update timemodified.
$filehash = $DB->get_field('plagiarism_turnitin_files', 'identifier', $params);
@@ -480,9 +471,9 @@
// to be now and rely on the submission timemodified date to tell us when the student finalised their
// work.
if ($filehash) {
- $params = array(
- 'pathnamehash' => $filehash
- );
+ $params = [
+ 'pathnamehash' => $filehash,
+ ];
$file = $DB->get_record('files', $params);
$file->timemodified = time();
$DB->update_record('files', $file);
@@ -505,28 +496,28 @@
// Already confirmed. Publish and redirect.
$coursework->publish_grades();
$url = clone($PAGE->url);
- $url->remove_params(array('confirm',
- 'publishbutton'));
+ $url->remove_params(['confirm',
+ 'publishbutton']);
redirect($url, get_string('gradespublished', 'mod_coursework'));
}
} else {
if ($resettable) {
- $coursework_firstname_alpha = $SESSION->coursework_firstname_alpha[$course_module_id] = "";
- $coursework_lastname_alpha = $SESSION->coursework_lastname_alpha[$course_module_id] = "";
- $coursework_groupname_alpha = $SESSION->coursework_groupname_alpha[$course_module_id] = "";
+ $courseworkfirstnamealpha = $SESSION->coursework_firstname_alpha[$coursemoduleid] = "";
+ $courseworklastnamealpha = $SESSION->coursework_lastname_alpha[$coursemoduleid] = "";
+ $courseworkgroupnamealpha = $SESSION->coursework_groupname_alpha[$coursemoduleid] = "";
}
if ($allresettable) {
- $viewallstudents_firstname_alpha = $SESSION->viewallstudents_firstname_alpha[$course_module_id] = "";
- $viewallstudents_lastname_alpha = $SESSION->viewallstudents_lastname_alpha[$course_module_id] = "";
- $viewallstudents_groupname_alpha = $SESSION->viewallstudents_groupname_alpha[$course_module_id] = "";
+ $viewallstudentsfirstnamealpha = $SESSION->viewallstudents_firstname_alpha[$coursemoduleid] = "";
+ $viewallstudentslastnamealpha = $SESSION->viewallstudents_lastname_alpha[$coursemoduleid] = "";
+ $viewallstudentsgroupnamealpha = $SESSION->viewallstudents_groupname_alpha[$coursemoduleid] = "";
}
- $html .= $page_renderer->teacher_grading_page($coursework, $page, $perpage, $sortby, $sorthow, $group, $coursework_firstname_alpha, $coursework_lastname_alpha, $coursework_groupname_alpha, $resettable);
- $html .= $page_renderer->non_teacher_allocated_grading_page($coursework, $viewallstudents_page, $viewallstudents_perpage, $viewallstudents_sortby, $viewallstudents_sorthow, $group, $displayallstudents, $viewallstudents_firstname_alpha, $viewallstudents_lastname_alpha, $viewallstudents_groupname_alpha);
- $html .= $page_renderer->datatables_render($coursework);
- $html .= $page_renderer->render_modal();
+ $html .= $pagerenderer->teacher_grading_page($coursework, $page, $perpage, $sortby, $sorthow, $group, $courseworkfirstnamealpha, $courseworklastnamealpha, $courseworkgroupnamealpha, $resettable);
+ $html .= $pagerenderer->non_teacher_allocated_grading_page($coursework, $viewallstudentspage, $viewallstudentsperpage, $viewallstudentssortby, $viewallstudentssorthow, $group, $displayallstudents, $viewallstudentsfirstnamealpha, $viewallstudentslastnamealpha, $viewallstudentsgroupnamealpha);
+ $html .= $pagerenderer->datatables_render($coursework);
+ $html .= $pagerenderer->render_modal();
}
}
|