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 .= '