diff --git a/actions/ajax/datatable/grading.php b/actions/ajax/datatable/grading.php index a3875c18..f2b25973 100644 --- a/actions/ajax/datatable/grading.php +++ b/actions/ajax/datatable/grading.php @@ -1,4 +1,25 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + ob_start(); require_once(dirname(__FILE__) . '/../../../../../config.php'); @@ -14,7 +35,7 @@ $unallocated = optional_param('unallocated', false, PARAM_BOOL); // Grading report display options. -$report_options = array(); +$report_options = []; if ($unallocated) { $report_options['unallocated'] = true; } diff --git a/actions/ajax/deadline_extension/edit.php b/actions/ajax/deadline_extension/edit.php index 34a70bb2..9c66ace6 100644 --- a/actions/ajax/deadline_extension/edit.php +++ b/actions/ajax/deadline_extension/edit.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ require_once(dirname(__FILE__) . '/../../../../../config.php'); @@ -29,4 +49,4 @@ $params['submissionid'] = $submissionid; $params['name'] = $name; -$controller->ajax_edit_mitigation($params); \ No newline at end of file +$controller->ajax_edit_mitigation($params); diff --git a/actions/ajax/deadline_extension/new.php b/actions/ajax/deadline_extension/new.php index 59b9ac9c..162f851b 100644 --- a/actions/ajax/deadline_extension/new.php +++ b/actions/ajax/deadline_extension/new.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ require_once(dirname(__FILE__) . '/../../../../../config.php'); @@ -29,4 +49,4 @@ $params['submissionid'] = $submissionid; $params['name'] = $name; -$controller->ajax_new_mitigation($params); \ No newline at end of file +$controller->ajax_new_mitigation($params); diff --git a/actions/ajax/deadline_extension/submit.php b/actions/ajax/deadline_extension/submit.php index 2e46b34a..c4461592 100644 --- a/actions/ajax/deadline_extension/submit.php +++ b/actions/ajax/deadline_extension/submit.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ require_once(dirname(__FILE__) . '/../../../../../config.php'); diff --git a/actions/allocate.php b/actions/allocate.php index bf03b618..1b9fc262 100644 --- a/actions/allocate.php +++ b/actions/allocate.php @@ -18,14 +18,13 @@ * Page that prints a table of all students and all markers so that first marker, second marker, moderators * etc can be allocated manually or automatically. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -use \mod_coursework\models\coursework; -use \mod_coursework\allocation\widget; +use mod_coursework\models\coursework; +use mod_coursework\allocation\widget; require_once(dirname(__FILE__).'/../../../config.php'); @@ -46,12 +45,12 @@ $assessorallocationstrategy = optional_param('assessorallocationstrategy', false, PARAM_TEXT); $moderationruletype = optional_param('addmodsetruletype', 0, PARAM_ALPHAEXT); -$deletemodsetrule = optional_param('delete-mod-set-rule', array(), PARAM_RAW) ; +$deletemodsetrule = optional_param('delete-mod-set-rule', [], PARAM_RAW); // options used for pagination // If a session variable holding page preference for the specific coursework is not set, set default value (0). if (isset($SESSION->allocate_perpage[$coursemoduleid]) && (isset($SESSION->perpage[$coursemoduleid]) && optional_param('per_page', 0, PARAM_INT) != $SESSION->perpage[$coursemoduleid]) - && optional_param('per_page', 0, PARAM_INT) != 0){ // prevent blank pages if not in correct page + && optional_param('per_page', 0, PARAM_INT) != 0) { // prevent blank pages if not in correct page $page = 0; $SESSION->allocate_page[$coursemoduleid] = $page; } else if (!(isset($SESSION->allocate_page[$coursemoduleid]))) { @@ -74,10 +73,10 @@ // SQL sort for allocation table. $sortby = optional_param('sortby', '', PARAM_ALPHA); $sorthow = optional_param('sorthow', '', PARAM_ALPHA); -$options = compact('sortby', 'sorthow','perpage','page'); +$options = compact('sortby', 'sorthow', 'perpage', 'page'); // $_POST['allocatables'] comes as array of arrays which is not supported by optional_param_array, however we clean this later in process_data() function -$formdataarray = isset($_POST['allocatables']) ? $_POST['allocatables'] : array(); +$formdataarray = isset($_POST['allocatables']) ? $_POST['allocatables'] : []; require_login($course, true, $coursemodule); @@ -102,18 +101,16 @@ 'node-base') ); $PAGE->requires->js_init_call('M.mod_coursework.init_allocate_page', - array('wwwroot'=>$CFG->wwwroot,'coursemoduleid'=>$coursemoduleid), + array('wwwroot' => $CFG->wwwroot, 'coursemoduleid' => $coursemoduleid), false, $jsmodule); $PAGE->requires->string_for_js('sameassessorerror', 'coursework'); - - $allocationsmanager = $coursework->get_allocation_manager(); $allocationtable = new mod_coursework\allocation\table\builder($coursework, $options); $allocationtable = new mod_coursework_allocation_table($allocationtable); -$pageurl = $PAGE->url; +$pageurl = $PAGE->url; // 1. Save the rules and settings from the config bits. @@ -129,8 +126,7 @@ $coursework->save(); } - -if ($samplingformsavebutton) { +if ($samplingformsavebutton) { if ($coursework->sampling_enabled()) { $allocationsmanager->save_sample(); } @@ -147,8 +143,6 @@ } } - - // 2. Process the manual allocations // Did we just get the form submitted to us? @@ -159,13 +153,8 @@ $allocationsmanager->auto_generate_sample_set(); } - // 3. Process the auto allocations to fill in the gaps. - - - - // Get the data to render as a moderation set widget. $allocationwidget = new widget($coursework); $allocationwidget = new \mod_coursework_allocation_widget($allocationwidget); @@ -179,22 +168,21 @@ */ $page_renderer = $PAGE->get_renderer('mod_coursework', 'page'); - $warnings = new \mod_coursework\warnings($coursework); $percentage_allocation_not_complete = $warnings->percentage_allocations_not_complete(); $manual_allocation_not_complete = ''; $students_in_multiple_groups = ''; -if ($coursework->allocation_enabled()){ +if ($coursework->allocation_enabled()) { $manual_allocation_not_complete = $warnings->manual_allocation_not_completed(); if ($coursework->use_groups == 1 || $coursework->assessorallocationstrategy == 'group_assessor') { $students_in_multiple_groups = $warnings->students_in_mutiple_grouos(); } } -if ($formsavebutton && $percentage_allocation_not_complete == '' && $manual_allocation_not_complete == ''){ - redirect($CFG->wwwroot.'/mod/coursework/view.php?id='.$coursemoduleid, get_string('changessaved','mod_coursework')); -} elseif ($formsavebutton) { +if ($formsavebutton && $percentage_allocation_not_complete == '' && $manual_allocation_not_complete == '') { + redirect($CFG->wwwroot.'/mod/coursework/view.php?id='.$coursemoduleid, get_string('changessaved', 'mod_coursework')); +} else if ($formsavebutton) { redirect($PAGE->url); } @@ -208,9 +196,7 @@ // Add coursework id etc. echo \html_writer::input_hidden_params($PAGE->url); - - -if ($coursework->sampling_enabled()) { // Do not delete yet - refactoring... +if ($coursework->sampling_enabled()) { // Do not delete yet - refactoring... echo \html_writer::start_tag('form', array('id' => 'sampling_form', 'method' => 'post')); $samplesetwidget = $allocationsmanager->get_sampling_set_widget(); @@ -218,16 +204,11 @@ echo html_writer::end_tag('form'); } - - - - // Start form. The page has now been broken into two forms sampling section and allocation section // Open form tag. echo \html_writer::start_tag('form', array('id' => 'allocation_form', 'method' => 'post')); - if ($coursework->allocation_enabled()) { echo $object_renderer->render($allocationwidget); } @@ -239,9 +220,8 @@ echo html_writer::start_tag('div', $attributes); echo html_writer::end_tag('div'); - echo html_writer::tag('h3', get_string('assessormoderatorgrades', 'mod_coursework')); -echo html_writer::tag('div', get_string('pininfo', 'mod_coursework'), array('class'=>'pininfo')); +echo html_writer::tag('div', get_string('pininfo', 'mod_coursework'), array('class' => 'pininfo')); // Start the form with save button. /* @@ -256,6 +236,4 @@ echo html_writer::end_tag('form'); - - echo $OUTPUT->footer(); diff --git a/actions/allocationsession.php b/actions/allocationsession.php index eb59b009..8e29a1b1 100644 --- a/actions/allocationsession.php +++ b/actions/allocationsession.php @@ -1,42 +1,60 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + require_once("../../../config.php"); global $SESSION; - -$assesorselect = required_param_array('assesorselect',PARAM_RAW); -$assesorselectvalue = required_param_array('assesorselectvalue',PARAM_RAW); -$pinnedchk = optional_param_array('pinned',array(),PARAM_RAW); -$pinnedchkval = optional_param_array('pinnedvalue',array(),PARAM_RAW); -$moderatorselect = optional_param_array('moderatorselect',array(),PARAM_RAW); -$moderatorselectvalue = optional_param_array('moderatorselectvalue',array(),PARAM_RAW); -$samplechk = optional_param_array('sample',array(),PARAM_RAW); -$samplechkvalue = optional_param_array('samplevalue',array(),PARAM_RAW); -$coursemoduleid = required_param('coursemoduleid', PARAM_INT); - -if (!isset($SESSION->coursework_allocationsessions)) { - $SESSION->coursework_allocationsessions = array(); +$assesorselect = required_param_array('assesorselect', PARAM_RAW); +$assesorselectvalue = required_param_array('assesorselectvalue', PARAM_RAW); +$pinnedchk = optional_param_array('pinned', [], PARAM_RAW); +$pinnedchkval = optional_param_array('pinnedvalue', [], PARAM_RAW); +$moderatorselect = optional_param_array('moderatorselect', [], PARAM_RAW); +$moderatorselectvalue = optional_param_array('moderatorselectvalue', [], PARAM_RAW); +$samplechk = optional_param_array('sample', [], PARAM_RAW); +$samplechkvalue = optional_param_array('samplevalue', [], PARAM_RAW); +$coursemoduleid = required_param('coursemoduleid', PARAM_INT); + +if (!isset($SESSION->coursework_allocationsessions)) { + $SESSION->coursework_allocationsessions = []; } -if (!isset($SESSION->coursework_allocationsessions[$coursemoduleid])) { - $SESSION->coursework_allocationsessions[$coursemoduleid] = array(); +if (!isset($SESSION->coursework_allocationsessions[$coursemoduleid])) { + $SESSION->coursework_allocationsessions[$coursemoduleid] = []; } - - -for($i = 0; $i < count($assesorselect); $i++) { - $SESSION->coursework_allocationsessions[$coursemoduleid][$assesorselect[$i]] = $assesorselectvalue[$i]; +for ($i = 0; $i < count($assesorselect); $i++) { + $SESSION->coursework_allocationsessions[$coursemoduleid][$assesorselect[$i]] = $assesorselectvalue[$i]; } -for($i = 0; $i < count($pinnedchk); $i++) { - $SESSION->coursework_allocationsessions[$coursemoduleid][$pinnedchk[$i]] = $pinnedchkval[$i]; +for ($i = 0; $i < count($pinnedchk); $i++) { + $SESSION->coursework_allocationsessions[$coursemoduleid][$pinnedchk[$i]] = $pinnedchkval[$i]; } -for($i = 0; $i < count($moderatorselect); $i++) { - $SESSION->coursework_allocationsessions[$coursemoduleid][$moderatorselect[$i]] = $moderatorselectvalue[$i]; +for ($i = 0; $i < count($moderatorselect); $i++) { + $SESSION->coursework_allocationsessions[$coursemoduleid][$moderatorselect[$i]] = $moderatorselectvalue[$i]; } -for($i = 0; $i < count($samplechk); $i++) { - $SESSION->coursework_allocationsessions[$coursemoduleid][$samplechk[$i]] = $samplechkvalue[$i]; +for ($i = 0; $i < count($samplechk); $i++) { + $SESSION->coursework_allocationsessions[$coursemoduleid][$samplechk[$i]] = $samplechkvalue[$i]; } diff --git a/actions/deadline_extensions/create.php b/actions/deadline_extensions/create.php index 27de4624..25eb856f 100644 --- a/actions/deadline_extensions/create.php +++ b/actions/deadline_extensions/create.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ require_once(dirname(__FILE__) . '/../../../../config.php'); @@ -18,4 +38,4 @@ $PAGE->set_url($link); $controller = new mod_coursework\controllers\deadline_extensions_controller($params); -$controller->create_deadline_extension(); \ No newline at end of file +$controller->create_deadline_extension(); diff --git a/actions/deadline_extensions/edit.php b/actions/deadline_extensions/edit.php index 48a66432..947d01dc 100644 --- a/actions/deadline_extensions/edit.php +++ b/actions/deadline_extensions/edit.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ require_once(dirname(__FILE__) . '/../../../../config.php'); @@ -10,4 +30,4 @@ 'id' => $id, ); $controller = new mod_coursework\controllers\deadline_extensions_controller($params); -$controller->edit_deadline_extension(); \ No newline at end of file +$controller->edit_deadline_extension(); diff --git a/actions/deadline_extensions/new.php b/actions/deadline_extensions/new.php index 43002b8d..aa55f47d 100644 --- a/actions/deadline_extensions/new.php +++ b/actions/deadline_extensions/new.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ require_once(dirname(__FILE__) . '/../../../../config.php'); @@ -14,4 +34,4 @@ 'allocatabletype' => $allocatabletype, ); $controller = new mod_coursework\controllers\deadline_extensions_controller($params); -$controller->new_deadline_extension(); \ No newline at end of file +$controller->new_deadline_extension(); diff --git a/actions/deadline_extensions/show.php b/actions/deadline_extensions/show.php index 5b8f780f..8a872a0a 100644 --- a/actions/deadline_extensions/show.php +++ b/actions/deadline_extensions/show.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ require_once(dirname(__FILE__) . '/../../../../config.php'); @@ -10,4 +30,4 @@ 'id' => $id, ); $controller = new mod_coursework\controllers\deadline_extensions_controller($params); -$controller->show_deadline_extension(); \ No newline at end of file +$controller->show_deadline_extension(); diff --git a/actions/deadline_extensions/update.php b/actions/deadline_extensions/update.php index cc07a0d0..c25265ad 100644 --- a/actions/deadline_extensions/update.php +++ b/actions/deadline_extensions/update.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ require_once(dirname(__FILE__) . '/../../../../config.php'); @@ -14,4 +34,4 @@ $PAGE->set_url($link); $controller = new mod_coursework\controllers\deadline_extensions_controller($params); -$controller->update_deadline_extension(); \ No newline at end of file +$controller->update_deadline_extension(); diff --git a/actions/feedbacks/create.php b/actions/feedbacks/create.php index a7ab4ffa..045f9f51 100644 --- a/actions/feedbacks/create.php +++ b/actions/feedbacks/create.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Creates a feedback instance and redirects to the coursework page. @@ -8,7 +28,6 @@ global $CFG, $USER; - $submissionid = required_param('submissionid', PARAM_INT); $isfinalgrade = optional_param('isfinalgrade', 0, PARAM_INT); $assessorid = optional_param('assessorid', $USER->id, PARAM_INT); @@ -30,4 +49,4 @@ } $controller = new mod_coursework\controllers\feedback_controller($params); -$controller->create_feedback(); \ No newline at end of file +$controller->create_feedback(); diff --git a/actions/feedbacks/edit.php b/actions/feedbacks/edit.php index ee01b238..57ebd485 100644 --- a/actions/feedbacks/edit.php +++ b/actions/feedbacks/edit.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2014 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -25,7 +24,6 @@ global $CFG, $USER; - $feedbackid = optional_param('feedbackid', 0, PARAM_INT); $ajax = optional_param('ajax', 0, PARAM_INT); @@ -34,4 +32,4 @@ 'ajax' => $ajax ); $controller = new mod_coursework\controllers\feedback_controller($params); -$controller->edit_feedback(); \ No newline at end of file +$controller->edit_feedback(); diff --git a/actions/feedbacks/new.php b/actions/feedbacks/new.php index d68afdf1..701a9ea5 100644 --- a/actions/feedbacks/new.php +++ b/actions/feedbacks/new.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/actions/feedbacks/show.php b/actions/feedbacks/show.php index 47d822c0..b74fd868 100644 --- a/actions/feedbacks/show.php +++ b/actions/feedbacks/show.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -34,4 +33,4 @@ ); $controller = new mod_coursework\controllers\feedback_controller($params); -$controller->show_feedback(); \ No newline at end of file +$controller->show_feedback(); diff --git a/actions/feedbacks/update.php b/actions/feedbacks/update.php index d0fe7643..ab1bafad 100644 --- a/actions/feedbacks/update.php +++ b/actions/feedbacks/update.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Creates a feedback instance and redirects to the coursework page. @@ -8,7 +28,6 @@ global $CFG, $USER; - $feedbackid = required_param('feedbackid', PARAM_INT); $finalised = !!optional_param('submitbutton', 0, PARAM_TEXT); $ajax = optional_param('ajax', 0, PARAM_INT); @@ -28,4 +47,4 @@ } $controller = new mod_coursework\controllers\feedback_controller($params); -$controller->update_feedback(); \ No newline at end of file +$controller->update_feedback(); diff --git a/actions/finalgrade.php b/actions/finalgrade.php index 4e36a973..4df8234c 100644 --- a/actions/finalgrade.php +++ b/actions/finalgrade.php @@ -17,8 +17,7 @@ /** * This file displays a moodle form used to create a final grade for a submission * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -146,7 +145,7 @@ } $details = new stdClass(); $details->name = fullname($editor); - $details->time = userdate($teacherfeedback->timemodified,'%a, %d %b %Y, %H:%M'); + $details->time = userdate($teacherfeedback->timemodified, '%a, %d %b %Y, %H:%M'); echo html_writer::tag('p', get_string('lastedited', 'coursework', $details)); } @@ -168,4 +167,3 @@ echo $OUTPUT->footer(); - diff --git a/actions/general_feedback.php b/actions/general_feedback.php index 41c9bcc1..9c96d3d2 100644 --- a/actions/general_feedback.php +++ b/actions/general_feedback.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -25,7 +24,6 @@ require_once(dirname(__FILE__) . '/../../../config.php'); - global $CFG, $PAGE, $DB, $OUTPUT; $course_module_id = required_param('cmid', PARAM_INT); diff --git a/actions/moderations/create.php b/actions/moderations/create.php index d4303031..9b11c938 100644 --- a/actions/moderations/create.php +++ b/actions/moderations/create.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Creates a moderation agreement instance and redirects to the coursework page. @@ -8,7 +28,6 @@ global $CFG, $USER; - $submissionid = required_param('submissionid', PARAM_INT); $feedbackid = required_param('feedbackid', PARAM_INT); $moderatorid = optional_param('moderatorid', $USER->id, PARAM_INT); @@ -21,4 +40,4 @@ 'stage_identifier' => $stage_identifier, ); $controller = new mod_coursework\controllers\moderations_controller($params); -$controller->create_moderation(); \ No newline at end of file +$controller->create_moderation(); diff --git a/actions/moderations/edit.php b/actions/moderations/edit.php index a7d5cac5..8028b076 100644 --- a/actions/moderations/edit.php +++ b/actions/moderations/edit.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -31,4 +30,4 @@ 'moderationid' => $moderationid, ); $controller = new mod_coursework\controllers\moderations_controller($params); -$controller->edit_moderation(); \ No newline at end of file +$controller->edit_moderation(); diff --git a/actions/moderations/new.php b/actions/moderations/new.php index 96bc5abb..ba7a7004 100644 --- a/actions/moderations/new.php +++ b/actions/moderations/new.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -39,4 +38,4 @@ 'stage_identifier' => $stage_identifier, ); $controller = new mod_coursework\controllers\moderations_controller($params); -$controller->new_moderation(); \ No newline at end of file +$controller->new_moderation(); diff --git a/actions/moderations/show.php b/actions/moderations/show.php index 3896ea35..171473ba 100644 --- a/actions/moderations/show.php +++ b/actions/moderations/show.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2018 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -31,4 +30,4 @@ 'moderationid' => $moderationid, ); $controller = new mod_coursework\controllers\moderations_controller($params); -$controller->show_moderation(); \ No newline at end of file +$controller->show_moderation(); diff --git a/actions/moderations/update.php b/actions/moderations/update.php index da792420..627e82ba 100644 --- a/actions/moderations/update.php +++ b/actions/moderations/update.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Creates a moderation instance and redirects to the coursework page. @@ -8,11 +28,10 @@ global $CFG, $USER; - $moderationid = required_param('moderationid', PARAM_INT); $params = array( 'moderationid' => $moderationid, ); $controller = new mod_coursework\controllers\moderations_controller($params); -$controller->update_moderation(); \ No newline at end of file +$controller->update_moderation(); diff --git a/actions/personal_deadline.php b/actions/personal_deadline.php index baf5be4f..e4ed63cc 100644 --- a/actions/personal_deadline.php +++ b/actions/personal_deadline.php @@ -1,41 +1,58 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ require_once(dirname(__FILE__) . '/../../../config.php'); global $CFG, $USER, $PAGE, $DB; - - $courseworkid = required_param('courseworkid', PARAM_INT); $allocatableid_arr = 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); - -$allocatableid = (!empty($allocatableid_arr)) ? $allocatableid_arr : $allocatableid ; +$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); +$allocatableid = (!empty($allocatableid_arr)) ? $allocatableid_arr : $allocatableid; -$coursework_db = $DB->get_record('coursework',array('id'=>$courseworkid)); +$coursework_db = $DB->get_record('coursework', array('id' => $courseworkid)); -$coursework = \mod_coursework\models\coursework::find($coursework_db); +$coursework = \mod_coursework\models\coursework::find($coursework_db); -require_login($coursework->get_course(),false,$coursework->get_course_module()); +require_login($coursework->get_course(), false, $coursework->get_course_module()); $params = array( 'courseworkid' => $courseworkid, 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype, - 'setpersonaldeadlinespage' => $setpersonaldeadlinespage, - 'multipleuserdeadlines' => $multipleuserdeadlines + 'setpersonaldeadlinespage' => $setpersonaldeadlinespage, + 'multipleuserdeadlines' => $multipleuserdeadlines ); if ($selectedtype != 'unfinalise') { $controller = new mod_coursework\controllers\personal_deadlines_controller($params); - if(!empty($personal_deadline_time)) { + if (!empty($personal_deadline_time)) { $result = $controller->insert_update($personal_deadline_time); echo json_encode($result); } else { @@ -48,6 +65,6 @@ redirect($url, $message); } - $controller = new mod_coursework\controllers\submissions_controller($params); + $controller = new mod_coursework\controllers\submissions_controller($params); $controller->unfinalise_submission(); } diff --git a/actions/plagiarism_flagging/create.php b/actions/plagiarism_flagging/create.php index c0572e16..1afc831c 100644 --- a/actions/plagiarism_flagging/create.php +++ b/actions/plagiarism_flagging/create.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Creates a plagiarism flagging instance and redirects to the coursework page. @@ -15,4 +35,4 @@ ); $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); -$controller->create_plagiarism_flag(); \ No newline at end of file +$controller->create_plagiarism_flag(); diff --git a/actions/plagiarism_flagging/edit.php b/actions/plagiarism_flagging/edit.php index 9877ac24..be4b7507 100644 --- a/actions/plagiarism_flagging/edit.php +++ b/actions/plagiarism_flagging/edit.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2018 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -32,4 +31,4 @@ ); $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); -$controller->edit_plagiarism_flag(); \ No newline at end of file +$controller->edit_plagiarism_flag(); diff --git a/actions/plagiarism_flagging/new.php b/actions/plagiarism_flagging/new.php index ca94d660..d1b3a388 100644 --- a/actions/plagiarism_flagging/new.php +++ b/actions/plagiarism_flagging/new.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2018 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -32,4 +31,4 @@ ); $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); -$controller->new_plagiarism_flag(); \ No newline at end of file +$controller->new_plagiarism_flag(); diff --git a/actions/plagiarism_flagging/update.php b/actions/plagiarism_flagging/update.php index bde1335a..903d7245 100644 --- a/actions/plagiarism_flagging/update.php +++ b/actions/plagiarism_flagging/update.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Updates a plagiarism flag instance and redirects to the coursework page. @@ -15,4 +35,4 @@ ); $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); -$controller->update_plagiarism_flag(); \ No newline at end of file +$controller->update_plagiarism_flag(); diff --git a/actions/processallocation.php b/actions/processallocation.php index e5ebd4c3..bbed5f0d 100644 --- a/actions/processallocation.php +++ b/actions/processallocation.php @@ -1,18 +1,36 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +// This stops the page from aborting when an ajax call disconnects ignore_user_abort(true); -//we have to set the time limit to 0 as depending on +// We have to set the time limit to 0 as depending on set_time_limit ( 0 ); -use \mod_coursework\models\coursework; -use \mod_coursework\allocation\widget; +use mod_coursework\models\coursework; +use mod_coursework\allocation\widget; require_once(dirname(__FILE__).'/../../../config.php'); - - global $CFG, $OUTPUT, $DB, $PAGE; require_once($CFG->dirroot.'/mod/coursework/lib.php'); @@ -24,7 +42,6 @@ $coursework = coursework::find($coursework); $assessorallocationstrategy = optional_param('assessorallocationstrategy', false, PARAM_TEXT); - require_login($course, true, $coursemodule); require_capability('mod/coursework:allocate', $PAGE->context, null, true, "Can't allocate here - permission denied."); @@ -41,5 +58,4 @@ $allocator = new \mod_coursework\allocation\auto_allocator($coursework); $allocator->process_allocations(); - - echo $coursework->name. "re-allocated"; \ No newline at end of file + echo $coursework->name. "re-allocated"; diff --git a/actions/revert.php b/actions/revert.php index 0ea6e604..78aff861 100644 --- a/actions/revert.php +++ b/actions/revert.php @@ -18,8 +18,7 @@ * This file will revert the finalised state for one student's submission so that they can alter * files again. Not allowed if they already have feedbacks * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -31,7 +30,6 @@ global $DB, $PAGE, $CFG; - $cmid = required_param('cmid', PARAM_INT); $submission_id = required_param('submissionid', PARAM_INT); diff --git a/actions/selectallallocatables.php b/actions/selectallallocatables.php index 679150bf..e241d770 100644 --- a/actions/selectallallocatables.php +++ b/actions/selectallallocatables.php @@ -1,44 +1,57 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +use mod_coursework\models\coursework; +use mod_coursework\allocation\widget; require_once(dirname(__FILE__).'/../../../config.php'); - - global $CFG, $OUTPUT, $DB, $PAGE; require_once($CFG->dirroot.'/mod/coursework/lib.php'); -$coursemoduleid = required_param('coursemoduleid', PARAM_INT); -$stagenumber = required_param('stage', PARAM_INT); +$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); $coursework = coursework::find($coursework); $assessorallocationstrategy = optional_param('assessorallocationstrategy', false, PARAM_TEXT); - - - -if ($stagenumber > 0) { +if ($stagenumber > 0) { if (!isset($SESSION->allocate_page_selectentirestage[$coursework->id()]['assessor_'.$stagenumber])) { - $SESSION->allocate_page_selectentirestage[$coursework->id()]['assessor_'.$stagenumber] = 0; + $SESSION->allocate_page_selectentirestage[$coursework->id()]['assessor_'.$stagenumber] = 0; } - $SESSION->allocate_page_selectentirestage[$coursework->id()]['assessor_'.$stagenumber] = !$SESSION->allocate_page_selectentirestage[$coursework->id()]['assessor_'.$stagenumber]; + $SESSION->allocate_page_selectentirestage[$coursework->id()]['assessor_'.$stagenumber] = !$SESSION->allocate_page_selectentirestage[$coursework->id()]['assessor_'.$stagenumber]; } else { if (!isset($SESSION->allocate_page_selectentirestage[$coursework->id()]['moderator'])) { - $SESSION->allocate_page_selectentirestage[$coursework->id()]['moderator'] = 0; + $SESSION->allocate_page_selectentirestage[$coursework->id()]['moderator'] = 0; } - $SESSION->allocate_page_selectentirestage[$coursework->id()]['moderator'] = !$SESSION->allocate_page_selectentirestage[$coursework->id()]['moderator']; + $SESSION->allocate_page_selectentirestage[$coursework->id()]['moderator'] = !$SESSION->allocate_page_selectentirestage[$coursework->id()]['moderator']; } - diff --git a/actions/set_personal_deadlines.php b/actions/set_personal_deadlines.php index 2d2a80f5..c6d42bf4 100644 --- a/actions/set_personal_deadlines.php +++ b/actions/set_personal_deadlines.php @@ -17,14 +17,13 @@ /** * Page that prints a table of all students and their personal deadlines in order to change it one by one or in bulk . * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2016 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -use \mod_coursework\models\coursework; -use \mod_coursework\models\personal_deadline; +use mod_coursework\models\coursework; +use mod_coursework\models\personal_deadline; require_once(dirname(__FILE__).'/../../../config.php'); @@ -43,7 +42,6 @@ $sorthow = optional_param('sorthow', '', PARAM_ALPHA); $options = compact('sortby', 'sorthow'); - require_login($course, true, $coursemodule); require_capability('mod/coursework:editpersonaldeadline', $PAGE->context, null, true, "Can't change personal deadlines here - permission denied."); @@ -64,7 +62,7 @@ 'node-base') ); $PAGE->requires->js_init_call('M.mod_coursework.init_personal_deadlines_page', - array(), + [], false, $jsmodule); @@ -78,5 +76,4 @@ echo $object_renderer->render($personal_deadlines_table); - echo $OUTPUT->footer(); diff --git a/actions/submissions/create.php b/actions/submissions/create.php index 37177ad2..336fbf68 100644 --- a/actions/submissions/create.php +++ b/actions/submissions/create.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Creates a submission instance and redirects to the coursework page. @@ -14,7 +34,6 @@ $submissionid = optional_param('submissionid', 0, PARAM_INT); $finalised = !!optional_param('finalisebutton', 0, PARAM_TEXT); - if (!in_array($allocatabletype, array('user', 'group'))) { throw new \mod_coursework\exceptions\access_denied(\mod_coursework\models\coursework::find($courseworkid), 'Bad alloctable type'); @@ -30,4 +49,4 @@ $params['submissionid'] = $submissionid; } $controller = new mod_coursework\controllers\submissions_controller($params); -$controller->create_submission(); \ No newline at end of file +$controller->create_submission(); diff --git a/actions/submissions/edit.php b/actions/submissions/edit.php index 58ebe594..061d591c 100644 --- a/actions/submissions/edit.php +++ b/actions/submissions/edit.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Creates a submission instance and redirects to the coursework page. @@ -12,4 +32,4 @@ 'submissionid' => $submissionid, ); $controller = new mod_coursework\controllers\submissions_controller($params); -$controller->edit_submission(); \ No newline at end of file +$controller->edit_submission(); diff --git a/actions/submissions/finalise.php b/actions/submissions/finalise.php index f729a594..0695511b 100644 --- a/actions/submissions/finalise.php +++ b/actions/submissions/finalise.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Creates a submission instance and redirects to the coursework page. @@ -12,4 +32,4 @@ 'submissionid' => $submissionid, ); $controller = new mod_coursework\controllers\submissions_controller($params); -$controller->finalise_submission(); \ No newline at end of file +$controller->finalise_submission(); diff --git a/actions/submissions/new.php b/actions/submissions/new.php index cf4bb1a5..20a33ba6 100644 --- a/actions/submissions/new.php +++ b/actions/submissions/new.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Creates a submission instance and redirects to the coursework page. @@ -18,4 +38,4 @@ 'allocatabletype' => $allocatabletype, ); $controller = new mod_coursework\controllers\submissions_controller($params); -$controller->new_submission(); \ No newline at end of file +$controller->new_submission(); diff --git a/actions/submissions/update.php b/actions/submissions/update.php index dc7d3593..02bc61b3 100644 --- a/actions/submissions/update.php +++ b/actions/submissions/update.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Creates a submission instance and redirects to the coursework page. @@ -14,4 +34,4 @@ 'finalised' => $finalised, ); $controller = new mod_coursework\controllers\submissions_controller($params); -$controller->update_submission(); \ No newline at end of file +$controller->update_submission(); diff --git a/actions/submitonbehalfofstudent.php b/actions/submitonbehalfofstudent.php index ac2eaa5d..39d23809 100644 --- a/actions/submitonbehalfofstudent.php +++ b/actions/submitonbehalfofstudent.php @@ -18,8 +18,7 @@ * This file provides an interface for someone with the appropriate permissions to submit a file on behalf of a student * who may have problems with their internet access, or who cannot for some reason work out how to use the submission form. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -31,7 +30,6 @@ global $CFG, $DB, $PAGE, $OUTPUT; - $coursemoduleid = required_param('cmid', PARAM_INT); $coursemodule = $DB->get_record('course_modules', array('id' => $coursemoduleid)); $coursework = coursework::find($coursemodule->instance); @@ -92,7 +90,6 @@ $submitform->set_data($submission); } - /** * @var mod_coursework_page_renderer $page_renderer */ diff --git a/actions/upload_allocations.php b/actions/upload_allocations.php index 145c34fc..20842086 100644 --- a/actions/upload_allocations.php +++ b/actions/upload_allocations.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2016 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -24,7 +23,6 @@ use mod_coursework\models\coursework; use mod_coursework\allocation; - require_once(dirname(__FILE__).'/../../../config.php'); global $CFG, $DB, $PAGE, $OUTPUT; @@ -33,7 +31,6 @@ require_once($CFG->libdir.'/csvlib.class.php'); - $coursemoduleid = required_param('cmid', PARAM_INT); $coursemodule = $DB->get_record('course_modules', array('id' => $coursemoduleid)); @@ -49,34 +46,29 @@ $grading_sheet_capabilities = array('mod/coursework:allocate'); - // Bounce anyone who shouldn't be here. if (!has_any_capability($grading_sheet_capabilities, $PAGE->context)) { $message = 'You do not have permission to upload allocations'; redirect(new moodle_url('mod/coursework/view.php'), $message); } - - -$allocationsuploadform = new upload_allocations_form($coursemoduleid); +$allocationsuploadform = new upload_allocations_form($coursemoduleid); if ($allocationsuploadform->is_cancelled()) { redirect("$CFG->wwwroot/mod/coursework/view.php?id=$coursemoduleid"); } +if ($data = $allocationsuploadform->get_data()) { - -if ($data = $allocationsuploadform->get_data()) { - - //perform checks on data + // Perform checks on data $content = $allocationsuploadform->get_file_content('allocationsdata'); - $csvimport = new \mod_coursework\allocation\upload($coursework); + $csvimport = new \mod_coursework\allocation\upload($coursework); - $procsessingresults = $csvimport->validate_csv($content, $data->encoding, $data->delimiter_name); + $procsessingresults = $csvimport->validate_csv($content, $data->encoding, $data->delimiter_name); - //process + // 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); @@ -87,4 +79,4 @@ } else { $page_renderer = $PAGE->get_renderer('mod_coursework', 'page'); echo $page_renderer->csv_upload($allocationsuploadform, $csvtype); -} \ No newline at end of file +} diff --git a/actions/upload_feedback.php b/actions/upload_feedback.php index 62f4e361..fd59f960 100644 --- a/actions/upload_feedback.php +++ b/actions/upload_feedback.php @@ -1,17 +1,28 @@ . + /** - * Created by PhpStorm. - * User: Nigel.Daley - * Date: 11/08/2015 - * Time: 11:32 + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - use mod_coursework\models\coursework; use mod_coursework\export; - - require_once(dirname(__FILE__).'/../../../config.php'); global $CFG, $DB, $PAGE, $OUTPUT; @@ -33,8 +44,7 @@ $PAGE->set_title($title); $PAGE->set_heading($title); -$grading_sheet_capabilities = array('mod/coursework:addinitialgrade','mod/coursework:addagreedgrade','mod/coursework:administergrades'); - +$grading_sheet_capabilities = array('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)) { @@ -42,39 +52,33 @@ redirect(new moodle_url('mod/coursework/view.php'), $message); } - - -$feedbackform = new upload_feedback_form($coursework,$coursemoduleid); +$feedbackform = new upload_feedback_form($coursework, $coursemoduleid); if ($feedbackform->is_cancelled()) { redirect(new moodle_url("$CFG->wwwroot/mod/coursework/view.php", array('id' => $coursemoduleid))); } +if ($data = $feedbackform->get_data()) { - -if ($data = $feedbackform->get_data()) { - - //perform checks on data + // Perform checks on data $courseworktempdir = $CFG->dataroot."/temp/coursework/"; - if (!is_dir($courseworktempdir)) { + if (!is_dir($courseworktempdir)) { mkdir($courseworktempdir); } $filename = clean_param($feedbackform->get_new_filename('feedbackzip'), PARAM_FILE); - $filename = md5(rand(0,1000000).$filename); + $filename = md5(rand(0, 1000000).$filename); $filepath = $courseworktempdir.'/'.$filename.".zip"; $feedbackform->save_file('feedbackzip', $filepath); - $stageidentifier = $data->feedbackstage; + $stageidentifier = $data->feedbackstage; - $fileimporter = new mod_coursework\coursework_file_zip_importer(); + $fileimporter = new mod_coursework\coursework_file_zip_importer(); + $fileimporter->extract_zip_file($filepath, $coursework->get_context_id()); - - $fileimporter->extract_zip_file($filepath,$coursework->get_context_id()); - - $updateresults = $fileimporter->import_zip_files($coursework,$stageidentifier,$data->overwrite); + $updateresults = $fileimporter->import_zip_files($coursework, $stageidentifier, $data->overwrite); $page_renderer = $PAGE->get_renderer('mod_coursework', 'page'); echo $page_renderer->process_feedback_upload($updateresults); @@ -82,4 +86,4 @@ } else { $page_renderer = $PAGE->get_renderer('mod_coursework', 'page'); echo $page_renderer->feedback_upload($feedbackform); -} \ No newline at end of file +} diff --git a/actions/upload_grading_sheet.php b/actions/upload_grading_sheet.php index 57a8acd6..9a43230f 100644 --- a/actions/upload_grading_sheet.php +++ b/actions/upload_grading_sheet.php @@ -1,17 +1,28 @@ . + /** - * Created by PhpStorm. - * User: Nigel.Daley - * Date: 11/08/2015 - * Time: 11:32 + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - use mod_coursework\models\coursework; use mod_coursework\export; - - require_once(dirname(__FILE__).'/../../../config.php'); global $CFG, $DB, $PAGE, $OUTPUT; @@ -20,7 +31,6 @@ require_once($CFG->libdir.'/csvlib.class.php'); - $coursemoduleid = required_param('cmid', PARAM_INT); $coursemodule = $DB->get_record('course_modules', array('id' => $coursemoduleid)); @@ -35,8 +45,7 @@ $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'); - +$grading_sheet_capabilities = array('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)) { @@ -44,33 +53,29 @@ redirect(new moodle_url('mod/coursework/view.php'), $message); } - - -$gradinguploadform = new upload_grading_sheet_form($coursemoduleid); +$gradinguploadform = new upload_grading_sheet_form($coursemoduleid); if ($gradinguploadform->is_cancelled()) { redirect("$CFG->wwwroot/mod/coursework/view.php?id=$coursemoduleid"); } +if ($data = $gradinguploadform->get_data()) { - -if ($data = $gradinguploadform->get_data()) { - - //perform checks on data + // Perform checks on data $content = $gradinguploadform->get_file_content('gradingdata'); - $csv_cells = \mod_coursework\export\grading_sheet::cells_array($coursework); + $csv_cells = \mod_coursework\export\grading_sheet::cells_array($coursework); - $csvimport = new \mod_coursework\export\import($coursework,false,false); + $csvimport = new \mod_coursework\export\import($coursework, false, false); // $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, $csv_cells); - //process + // Process - //if (!empty($procsessingresults)) { + // 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); @@ -78,15 +83,7 @@ // //} - - - - - - - - } else { $page_renderer = $PAGE->get_renderer('mod_coursework', 'page'); echo $page_renderer->csv_upload($gradinguploadform, $csvtype); -} \ No newline at end of file +} diff --git a/backup/moodle2/backup_coursework_activity_task.class.php b/backup/moodle2/backup_coursework_activity_task.class.php index 171f7f67..78a19a15 100644 --- a/backup/moodle2/backup_coursework_activity_task.class.php +++ b/backup/moodle2/backup_coursework_activity_task.class.php @@ -1,31 +1,48 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ require_once($CFG->dirroot . '/mod/coursework/backup/moodle2/backup_coursework_stepslib.php'); -class backup_coursework_activity_task extends backup_activity_task -{ - static public function encode_content_links($content) - { +class backup_coursework_activity_task extends backup_activity_task { + + static public function encode_content_links($content) { global $CFG; $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; } - - protected function define_my_settings() - { + + protected function define_my_settings() { } - protected function define_my_steps() - { + protected function define_my_steps() { $this->add_step(new backup_coursework_activity_structure_step('coursework_structure', 'coursework.xml')); } -} \ No newline at end of file +} diff --git a/backup/moodle2/backup_coursework_stepslib.php b/backup/moodle2/backup_coursework_stepslib.php index e092e90f..104b12e9 100644 --- a/backup/moodle2/backup_coursework_stepslib.php +++ b/backup/moodle2/backup_coursework_stepslib.php @@ -1,18 +1,35 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +class backup_coursework_activity_structure_step extends backup_activity_structure_step { + protected function define_structure() { global $DB; - foreach(array('coursework_submissions', + foreach (array('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'"); @@ -20,7 +37,7 @@ protected function define_structure() $userinfo = $this->get_setting_value('userinfo'); - $coursework=new backup_nested_element('coursework',array('id'), + $coursework = new backup_nested_element('coursework', array('id'), array('formid', 'course', 'name', @@ -91,10 +108,9 @@ protected function define_structure() 'plagiarismflagenabled' )); + $sample_strategies = new backup_nested_element('coursework_sample_set_rules'); - $sample_strategies =new backup_nested_element('coursework_sample_set_rules'); - - $sample_strategy = new backup_nested_element('coursework_sample_set_rule',array('id'), + $sample_strategy = new backup_nested_element('coursework_sample_set_rule', array('id'), array('courseworkid', 'sample_set_plugin_id', 'ruleorder', @@ -108,15 +124,13 @@ protected function define_structure() $sample_strategies->add_child($sample_strategy); $sample_strategy->set_source_table('coursework_sample_set_rules', - array('courseworkid'=>backup::VAR_PARENTID)); - - if($userinfo) - { + array('courseworkid' => backup::VAR_PARENTID)); + if ($userinfo) { - $plagiarism_flags = new backup_nested_element('coursework_plagiarism_flags'); + $plagiarism_flags = new backup_nested_element('coursework_plagiarism_flags'); - $plagiarism_flag = new backup_nested_element('coursework_plagiarism_flag', array('id'), + $plagiarism_flag = new backup_nested_element('coursework_plagiarism_flag', array('id'), array( "courseworkid", "submissiond", @@ -129,11 +143,9 @@ protected function define_structure() "timemodified" )); + $moderation_agreements = new backup_nested_element('coursework_mod_agreements'); - - $moderation_agreements = new backup_nested_element('coursework_mod_agreements'); - - $moderation_agreement = new backup_nested_element('coursework_mod_agreement', array('id'), + $moderation_agreement = new backup_nested_element('coursework_mod_agreement', array('id'), array( "feedbackid", "moderatorid", @@ -145,11 +157,9 @@ protected function define_structure() "modecommentformat" )); + $feedbacks = new backup_nested_element('coursework_feedbacks'); - - $feedbacks=new backup_nested_element('coursework_feedbacks'); - - $feedback= new backup_nested_element('coursework_feedback',array('id'), + $feedback = new backup_nested_element('coursework_feedback', array('id'), array( "submissionid", "assessorid", @@ -169,9 +179,9 @@ protected function define_structure() "finalised" )); - $submissions=new backup_nested_element('coursework_submissions'); + $submissions = new backup_nested_element('coursework_submissions'); - $submission=new backup_nested_element('coursework_submission',array('id'), + $submission = new backup_nested_element('coursework_submission', array('id'), array( "courseworkid", "userid", @@ -190,9 +200,9 @@ protected function define_structure() "lastpublished", "timesubmitted" )); - $reminders=new backup_nested_element('coursework_reminders'); + $reminders = new backup_nested_element('coursework_reminders'); - $reminder=new backup_nested_element('coursework_reminder',array('id'), + $reminder = new backup_nested_element('coursework_reminder', array('id'), array( "userid", "coursework_id", @@ -200,9 +210,9 @@ protected function define_structure() "extension" )); - $pairs=new backup_nested_element('coursework_allocation_pairs'); + $pairs = new backup_nested_element('coursework_allocation_pairs'); - $pair=new backup_nested_element('coursework_allocation_pair',array('id'), + $pair = new backup_nested_element('coursework_allocation_pair', array('id'), array( "courseworkid", "assessorid", @@ -216,9 +226,9 @@ protected function define_structure() 'allocatablegroup' )); - $modsetrules=new backup_nested_element('coursework_mod_set_rules'); + $modsetrules = new backup_nested_element('coursework_mod_set_rules'); - $modsetrule=new backup_nested_element('coursework_mod_set_rule',array('id'), + $modsetrule = new backup_nested_element('coursework_mod_set_rule', array('id'), array( "courseworkid", "rulename", @@ -228,9 +238,9 @@ protected function define_structure() "minimum" )); - $allocation_configs=new backup_nested_element('coursework_allocation_configs'); + $allocation_configs = new backup_nested_element('coursework_allocation_configs'); - $allocation_config=new backup_nested_element('coursework_allocation_config',array('id'), + $allocation_config = new backup_nested_element('coursework_allocation_config', array('id'), array( "courseworkid", "allocationstrategy", @@ -239,9 +249,9 @@ protected function define_structure() "purpose" )); - $modsetmembers= new backup_nested_element('coursework_mod_set_members'); + $modsetmembers = new backup_nested_element('coursework_mod_set_members'); - $modsetmember=new backup_nested_element('coursework_mod_set_member',array('id'), + $modsetmember = new backup_nested_element('coursework_mod_set_member', array('id'), array( "courseworkid", "allocatableid", @@ -251,9 +261,9 @@ protected function define_structure() "stage_identifier" )); - $extensions=new backup_nested_element('coursework_extensions'); + $extensions = new backup_nested_element('coursework_extensions'); - $extension=new backup_nested_element('coursework_extension', array('id'), + $extension = new backup_nested_element('coursework_extension', array('id'), array( "allocatableid", "allocatabletype", @@ -267,10 +277,9 @@ protected function define_structure() "extra_information_format" )); + $personal_deadlines = new backup_nested_element('coursework_person_deadlines'); - $personal_deadlines=new backup_nested_element('coursework_person_deadlines'); - - $personal_deadline=new backup_nested_element('coursework_person_deadline', array('id'), + $personal_deadline = new backup_nested_element('coursework_person_deadline', array('id'), array( "allocatableid", 'allocatableuser', @@ -284,10 +293,9 @@ protected function define_structure() "lastmodifiedbyid" )); + $sample_members = new backup_nested_element('coursework_sample_set_mbrs'); - $sample_members = new backup_nested_element('coursework_sample_set_mbrs'); - - $sample_member = new backup_nested_element('coursework_sample_set_mbr', array('id'), + $sample_member = new backup_nested_element('coursework_sample_set_mbr', array('id'), array( "courseworkid", "allocatableid", @@ -298,32 +306,31 @@ protected function define_structure() "selectiontype" )); - - //A coursework instance has submissions. + // A coursework instance has submissions. $coursework->add_child($submissions); - //Each coursework may have reminders + // Each coursework may have reminders $coursework->add_child($reminders); - //And allocations pairs + // And allocations pairs $coursework->add_child($pairs); - //And moderation sets + // And moderation sets $coursework->add_child($modsetrules); - //And a set of extensionsenabled + // And a set of extensionsenabled $coursework->add_child($extensions); - //And a set of personaldeadlines + // And a set of personaldeadlines $coursework->add_child($personal_deadlines); - //And a set of moderation rule sets + // And a set of moderation rule sets $coursework->add_child($modsetmembers); - //And allocation configs + // And allocation configs $coursework->add_child($allocation_configs); - //And sample members + // And sample members $coursework->add_child($sample_members); - //And submissions are made up from individual submission instances + // And submissions are made up from individual submission instances $submissions->add_child($submission); - //Submissions have multiple feedback items + // Submissions have multiple feedback items $submission->add_child($feedbacks); - //Feedbacks is a set of individual items + // Feedbacks is a set of individual items $feedbacks->add_child($feedback); $feedback->add_child($moderation_agreements); @@ -332,7 +339,7 @@ protected function define_structure() $submission->add_child($plagiarism_flags); $plagiarism_flags->add_child($plagiarism_flag); - //as are reminders, pairs, extensions, modsets and modsetrules, + // as are reminders, pairs, extensions, modsets and modsetrules, // and allocation configs $reminders->add_child($reminder); $pairs->add_child($pair); @@ -344,88 +351,88 @@ protected function define_structure() $allocation_configs->add_child($allocation_config); $submission->set_source_table('coursework_submissions', - array('courseworkid'=>backup::VAR_PARENTID)); + array('courseworkid' => backup::VAR_PARENTID)); $feedback->set_source_table('coursework_feedbacks', - array('submissionid'=>backup::VAR_PARENTID)); + array('submissionid' => backup::VAR_PARENTID)); $plagiarism_flag->set_source_table('coursework_plagiarism_flags', - array('submissionid'=>backup::VAR_PARENTID)); + array('submissionid' => backup::VAR_PARENTID)); $moderation_agreement->set_source_table('coursework_mod_agreements', - array('feedbackid'=>backup::VAR_PARENTID)); + array('feedbackid' => backup::VAR_PARENTID)); $reminder->set_source_table('coursework_reminder', - array('coursework_id'=>backup::VAR_PARENTID)); + array('coursework_id' => backup::VAR_PARENTID)); $pair->set_source_table('coursework_allocation_pairs', - array('courseworkid'=>backup::VAR_PARENTID)); + array('courseworkid' => backup::VAR_PARENTID)); $modsetrule->set_source_table('coursework_mod_set_rules', - array('courseworkid'=>backup::VAR_PARENTID)); + array('courseworkid' => backup::VAR_PARENTID)); $extension->set_source_table('coursework_extensions', - array('courseworkid'=>backup::VAR_PARENTID)); + array('courseworkid' => backup::VAR_PARENTID)); $personal_deadline->set_source_table('coursework_person_deadlines', - array('courseworkid'=>backup::VAR_PARENTID)); + array('courseworkid' => backup::VAR_PARENTID)); $modsetmember->set_source_table('coursework_mod_set_members', - array('courseworkid'=>backup::VAR_PARENTID)); + array('courseworkid' => backup::VAR_PARENTID)); $sample_member->set_source_table('coursework_sample_set_mbrs', - array('courseworkid'=>backup::VAR_PARENTID)); + array('courseworkid' => backup::VAR_PARENTID)); $allocation_config->set_source_table('coursework_allocation_config', - array('courseworkid'=>backup::VAR_PARENTID)); + array('courseworkid' => backup::VAR_PARENTID)); - //Mark important foreign keys - $feedback->annotate_ids('user','assessorid'); - $feedback->annotate_ids('user','lasteditedbyuser'); - $feedback->annotate_ids('user','markernumber'); + // Mark important foreign keys + $feedback->annotate_ids('user', 'assessorid'); + $feedback->annotate_ids('user', 'lasteditedbyuser'); + $feedback->annotate_ids('user', 'markernumber'); - $submission->annotate_ids('user','userid'); - $submission->annotate_ids('user','createdby'); - $submission->annotate_ids('user','lastupdatedby'); - $submission->annotate_ids('user','allocatableuser'); - $submission->annotate_ids('group','allocatablegroup'); + $submission->annotate_ids('user', 'userid'); + $submission->annotate_ids('user', 'createdby'); + $submission->annotate_ids('user', 'lastupdatedby'); + $submission->annotate_ids('user', 'allocatableuser'); + $submission->annotate_ids('group', 'allocatablegroup'); - $reminder->annotate_ids('user','userid'); + $reminder->annotate_ids('user', 'userid'); - $pair->annotate_ids('user','assessorid'); - $pair->annotate_ids('user','allocatableuser'); - $pair->annotate_ids('group','allocatablegroup'); + $pair->annotate_ids('user', 'assessorid'); + $pair->annotate_ids('user', 'allocatableuser'); + $pair->annotate_ids('group', 'allocatablegroup'); - $allocation_config->annotate_ids('user','assessorid'); + $allocation_config->annotate_ids('user', 'assessorid'); - $modsetmember->annotate_ids('user','allocatableuser'); - $modsetmember->annotate_ids('group','allocatablegroup'); + $modsetmember->annotate_ids('user', 'allocatableuser'); + $modsetmember->annotate_ids('group', 'allocatablegroup'); - $extension->annotate_ids('user','allocatableuser'); - $extension->annotate_ids('group','allocatablegroup'); + $extension->annotate_ids('user', 'allocatableuser'); + $extension->annotate_ids('group', 'allocatablegroup'); - $personal_deadline->annotate_ids('user','allocatableuser'); - $personal_deadline->annotate_ids('group','allocatablegroup'); + $personal_deadline->annotate_ids('user', 'allocatableuser'); + $personal_deadline->annotate_ids('group', 'allocatablegroup'); - $sample_member->annotate_ids('user','allocatableuser'); - $sample_member->annotate_ids('group','allocatablegroup'); + $sample_member->annotate_ids('user', 'allocatableuser'); + $sample_member->annotate_ids('group', 'allocatablegroup'); - $moderation_agreement->annotate_ids('user','moderatorid'); - $moderation_agreement->annotate_ids('user','lasteditedby'); + $moderation_agreement->annotate_ids('user', 'moderatorid'); + $moderation_agreement->annotate_ids('user', 'lasteditedby'); - $plagiarism_flag->annotate_ids('user','createdby'); - $plagiarism_flag->annotate_ids('user','lastmodifiedby'); + $plagiarism_flag->annotate_ids('user', 'createdby'); + $plagiarism_flag->annotate_ids('user', 'lastmodifiedby'); - $coursework->annotate_files('mod_coursework','feedback',null); - $coursework->annotate_files('mod_coursework','submission',null); + $coursework->annotate_files('mod_coursework', 'feedback', null); + $coursework->annotate_files('mod_coursework', 'submission', null); } - $coursework->annotate_ids('grouping','grouping_id'); + $coursework->annotate_ids('grouping', 'grouping_id'); - $coursework->set_source_table('coursework',array('id'=>backup::VAR_ACTIVITYID)); + $coursework->set_source_table('coursework', array('id' => backup::VAR_ACTIVITYID)); return $this->prepare_activity_structure($coursework); } -} \ No newline at end of file +} diff --git a/backup/moodle2/restore_coursework_activity_task.class.php b/backup/moodle2/restore_coursework_activity_task.class.php index 7f7310b3..ef1f4528 100644 --- a/backup/moodle2/restore_coursework_activity_task.class.php +++ b/backup/moodle2/restore_coursework_activity_task.class.php @@ -1,20 +1,39 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot . '/mod/coursework/backup/moodle2/restore_coursework_stepslib.php'); -class restore_coursework_activity_task extends restore_activity_task -{ +class restore_coursework_activity_task extends restore_activity_task { + /** * Define the decoding rules for links belonging * to the activity to be executed by the link decoder. * * @return array of restore_decode_rule */ - static public function define_decode_rules() - { - $rules = array(); + static public function define_decode_rules() { + $rules = []; $rules[] = new restore_decode_rule('COURSEWORKBYID', '/mod/coursework/view.php?id=$1', @@ -34,28 +53,26 @@ static public function define_decode_rules() * @return array */ static public function define_decode_contents() { - $contents = array(); + $contents = []; $contents[] = new restore_decode_content('coursework', array('intro'), 'assign'); return $contents; } - + /** * Define (add) particular settings this activity can have. */ - protected function define_my_settings() - { + protected function define_my_settings() { // No particular settings for this activity. } - + /** * Define (add) particular steps this activity can have. */ - protected function define_my_steps() - { + protected function define_my_steps() { // Only has one structure step. $this->add_step(new restore_coursework_activity_structure_step('coursework_structure', 'coursework.xml')); } - -} \ No newline at end of file + +} diff --git a/backup/moodle2/restore_coursework_stepslib.php b/backup/moodle2/restore_coursework_stepslib.php index 0a5d6ecc..4413c35a 100644 --- a/backup/moodle2/restore_coursework_stepslib.php +++ b/backup/moodle2/restore_coursework_stepslib.php @@ -1,18 +1,36 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); -class restore_coursework_activity_structure_step extends restore_activity_structure_step -{ +class restore_coursework_activity_structure_step extends restore_activity_structure_step { + // Just a handy way to spit out debugging info while in the bowels of restore - static function cheaplog($thing,$append=true) - { - if($append) - { - $append=FILE_APPEND; + static function cheaplog($thing, $append = true) { + if ($append) { + $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); } /** @@ -20,9 +38,8 @@ static function cheaplog($thing,$append=true) * * @return restore_path_element $structure */ - protected function define_structure() - { - $paths = array(); + protected function define_structure() { + $paths = []; $paths[] = new restore_path_element('coursework', '/activity/coursework'); $paths[] = new restore_path_element('coursework_sample_set_rule', '/activity/coursework/coursework_sample_set_rules/coursework_sample_set_rule'); @@ -30,58 +47,50 @@ protected function define_structure() // To know if we are including userinfo. $userinfo = $this->get_setting_value('userinfo'); - if($userinfo) - { + if ($userinfo) { // Define each element separated. // Note: when I started the code I didn't realise that the names were arbitrary - // 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', - 'feedback'=>'coursework_submissions/coursework_submission/coursework_feedbacks', - 'reminder'=>'coursework_reminders', - 'allocation_pair'=>'coursework_allocation_pairs', - 'mod_set_rule'=>'coursework_mod_set_rules', - 'allocation_config'=>'coursework_allocation_configs', - 'mod_set_member'=>'coursework_mod_set_members', - 'sample_set_mbr'=>'coursework_sample_set_mbrs', - 'extension'=>'coursework_extensions', - 'person_deadline'=>'coursework_person_deadlines', + // 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', + 'feedback' => 'coursework_submissions/coursework_submission/coursework_feedbacks', + 'reminder' => 'coursework_reminders', + 'allocation_pair' => 'coursework_allocation_pairs', + 'mod_set_rule' => 'coursework_mod_set_rules', + 'allocation_config' => 'coursework_allocation_configs', + 'mod_set_member' => 'coursework_mod_set_members', + 'sample_set_mbr' => 'coursework_sample_set_mbrs', + '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'); - - foreach($bits as $bit=>$bitpath) - { - $p=new restore_path_element("coursework_$bit","/activity/coursework/{$bitpath}/coursework_$bit"); - $paths[]=$p; + foreach ($bits as $bit => $bitpath) { + $p = new restore_path_element("coursework_$bit", "/activity/coursework/{$bitpath}/coursework_$bit"); + $paths[] = $p; } } return $this->prepare_activity_structure($paths); } - protected function fixallocatable(&$data) - { - if(!empty($data->allocatableuser)) - { - $data->allocatableid=$this->get_mappingid('user',$data->allocatableuser); - $data->allocatabletype='user'; - } - else - { - $data->allocatableid=$this->get_mappingid('group',$data->allocatablegroup); - $data->allocatabletype='group'; + protected function fixallocatable(&$data) { + if (!empty($data->allocatableuser)) { + $data->allocatableid = $this->get_mappingid('user', $data->allocatableuser); + $data->allocatabletype = 'user'; + } else { + $data->allocatableid = $this->get_mappingid('group', $data->allocatablegroup); + $data->allocatabletype = 'group'; } } - protected function process_coursework_submission($data) - { + protected function process_coursework_submission($data) { global $DB; - $data=(object)$data; - $oldid=$data->id; + $data = (object)$data; + $oldid = $data->id; - $data->courseworkid=$this->get_new_parentid('coursework'); + $data->courseworkid = $this->get_new_parentid('coursework'); $data->userid = $this->get_mappingid('user', $data->userid); $data->createdby = $this->get_mappingid('user', $data->createdby); $data->lastupdatedby = $this->get_mappingid('user', $data->lastupdatedby); @@ -92,284 +101,267 @@ protected function process_coursework_submission($data) 'timecreated', 'timesubmitted', 'firstpublished', - 'lastpublished',),$data); - - $now=time(); - $this->set_defaults(array('timecreated'=>$now, - 'timemodified'=>$now, - 'firstpublished'=>null, - 'lastpublished'=>null, - 'timesubmitted'=>null, - 'finalised'=>0, - 'manualsrscode'=>''), + 'lastpublished',), $data); + + $now = time(); + $this->set_defaults(array('timecreated' => $now, + 'timemodified' => $now, + 'firstpublished' => null, + 'lastpublished' => null, + 'timesubmitted' => null, + 'finalised' => 0, + 'manualsrscode' => ''), $data); - if (!$DB->record_exists('coursework_submissions', array('courseworkid'=>$data->courseworkid, 'allocatableid' =>$data->allocatableid, 'allocatabletype' => $data->allocatabletype))) { + if (!$DB->record_exists('coursework_submissions', array('courseworkid' => $data->courseworkid, 'allocatableid' => $data->allocatableid, 'allocatabletype' => $data->allocatabletype))) { $newitemid = $DB->insert_record('coursework_submissions', $data); $this->set_mapping('coursework_submission', $oldid, $newitemid); - //Tell system how to map the old submission id to its new one. + // Tell system how to map the old submission id to its new one. $this->set_mapping('coursework_submission', $oldid, $newitemid, false, null, $this->task->get_old_contextid()); } } - protected function process_coursework_feedback($data) - { + protected function process_coursework_feedback($data) { global $DB; - $data=(object)$data; - $oldid=$data->id; + $data = (object)$data; + $oldid = $data->id; - $data->submissionid=$this->get_mappingid('coursework_submission',$data->submissionid); - $data->assessorid=$this->get_mappingid('user',$data->assessorid); - $data->lasteditedbyuser=$this->get_mappingid('user',$data->lasteditedbyuser); - $data->markernumber=$this->get_mappingid('user',$data->markernumber); + $data->submissionid = $this->get_mappingid('coursework_submission', $data->submissionid); + $data->assessorid = $this->get_mappingid('user', $data->assessorid); + $data->lasteditedbyuser = $this->get_mappingid('user', $data->lasteditedbyuser); + $data->markernumber = $this->get_mappingid('user', $data->markernumber); $this->updatedate(array('timemodified', 'timecreated', - 'timepublished'),$data); - - $this->check_grade('grade',$data); - $this->check_grade('cappedgrade',$data); - - $now=time(); - $this->set_defaults(array('assessorid'=>0, - 'timecreated'=>$now, - 'timemodified'=>$now, - 'grade'=>'', - 'cappedgrade'=>'', - 'feedbackcomment'=>'', - 'timepublished'=>$now, - 'lasteditedbyuser'=>0, - 'isfinalgrade'=>0, - 'ismoderation'=>0, - 'feedbackcommentformat'=>FORMAT_HTML, - 'entry_id'=>0, - 'markernumber'=>0, - 'stage_identifier'=>'', - 'finalised'=>0),$data); + 'timepublished'), $data); + + $this->check_grade('grade', $data); + $this->check_grade('cappedgrade', $data); + + $now = time(); + $this->set_defaults(array('assessorid' => 0, + 'timecreated' => $now, + 'timemodified' => $now, + 'grade' => '', + 'cappedgrade' => '', + 'feedbackcomment' => '', + 'timepublished' => $now, + 'lasteditedbyuser' => 0, + 'isfinalgrade' => 0, + 'ismoderation' => 0, + 'feedbackcommentformat' => FORMAT_HTML, + 'entry_id' => 0, + 'markernumber' => 0, + 'stage_identifier' => '', + 'finalised' => 0), $data); $newitemid = $DB->insert_record('coursework_feedbacks', $data); $this->set_mapping('coursework_feedback', $oldid, $newitemid, false, null, $this->task->get_old_contextid()); } - protected function process_coursework_reminder($data) - { - $data=(object)$data; - $oldid=$data->id; + protected function process_coursework_reminder($data) { + $data = (object)$data; + $oldid = $data->id; - $data->coursework_id=$this->get_new_parentid('coursework'); + $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(array('remindernumber' => 0), $data); global $DB; $newitemid = $DB->insert_record('coursework_reminder', $data); } - protected function process_coursework_allocation_pair($data) - { - $data=(object)$data; - $oldid=$data->id; + protected function process_coursework_allocation_pair($data) { + $data = (object)$data; + $oldid = $data->id; - $data->courseworkid=$this->get_new_parentid('coursework'); + $data->courseworkid = $this->get_new_parentid('coursework'); $data->assessorid = $this->get_mappingid('user', $data->assessorid); - $this->updatedate(array('timelocked'),$data); + $this->updatedate(array('timelocked'), $data); $this->fixallocatable($data); - $this->set_defaults(array('assessorid'=>0, - 'manual'=>0, - 'moderator'=>0, - 'timelocked'=>time(), - 'stage_identifier'=>''),$data); + $this->set_defaults(array('assessorid' => 0, + 'manual' => 0, + 'moderator' => 0, + 'timelocked' => time(), + 'stage_identifier' => ''), $data); global $DB; $newitemid = $DB->insert_record('coursework_allocation_pairs', $data); } - protected function process_coursework_mod_set_rule($data) - { - $data=(object)$data; - $oldid=$data->id; + protected function process_coursework_mod_set_rule($data) { + $data = (object)$data; + $oldid = $data->id; - $data->courseworkid=$this->get_new_parentid('coursework'); + $data->courseworkid = $this->get_new_parentid('coursework'); - $this->set_defaults(array('rulename'=>'', - 'ruleorder'=>0, - 'upperlimit'=>0, - 'lowerlimit'=>0, - 'minimum'=>0),$data); + $this->set_defaults(array('rulename' => '', + 'ruleorder' => 0, + 'upperlimit' => 0, + 'lowerlimit' => 0, + 'minimum' => 0), $data); global $DB; $newitemid = $DB->insert_record('coursework_mod_set_members', $data); } - protected function process_coursework_sample_set_rule($data) - { - $data=(object)$data; - $oldid=$data->id; + protected function process_coursework_sample_set_rule($data) { + $data = (object)$data; + $oldid = $data->id; - $data->courseworkid=$this->get_new_parentid('coursework'); + $data->courseworkid = $this->get_new_parentid('coursework'); - $this->set_defaults(array('ruletype'=>'', - 'ruleorder'=>0, - 'upperlimit'=>0, - 'lowerlimit'=>0, - 'sample_set_plugin_id'=>0, - 'stage_identifier'=>''),$data); + $this->set_defaults(array('ruletype' => '', + 'ruleorder' => 0, + 'upperlimit' => 0, + 'lowerlimit' => 0, + 'sample_set_plugin_id' => 0, + 'stage_identifier' => ''), $data); global $DB; $newitemid = $DB->insert_record('coursework_sample_set_rules', $data); } - protected function process_coursework_allocation_config($data) - { - $data=(object)$data; - $oldid=$data->id; + protected function process_coursework_allocation_config($data) { + $data = (object)$data; + $oldid = $data->id; - $data->courseworkid=$this->get_new_parentid('coursework'); + $data->courseworkid = $this->get_new_parentid('coursework'); $data->assessorid = $this->get_mappingid('user', $data->assessorid); - $this->set_defaults(array('allocationstrategy'=>'', - 'value'=>0, - 'purpose'=>''), + $this->set_defaults(array('allocationstrategy' => '', + 'value' => 0, + 'purpose' => ''), $data); global $DB; $newitemid = $DB->insert_record('coursework_allocation_config', $data); } - protected function process_coursework_mod_set_member($data) - { - $data=(object)$data; + protected function process_coursework_mod_set_member($data) { + $data = (object)$data; - $data->courseworkid=$this->get_new_parentid('coursework'); + $data->courseworkid = $this->get_new_parentid('coursework'); $this->fixallocatable($data); - $this->set_defaults(array('stage_identifier'=>''),$data); + $this->set_defaults(array('stage_identifier' => ''), $data); global $DB; $newitemid = $DB->insert_record('coursework_mod_set_members', $data); } - protected function process_coursework_sample_set_mbr($data) - { - $data=(object)$data; + protected function process_coursework_sample_set_mbr($data) { + $data = (object)$data; - $data->courseworkid=$this->get_new_parentid('coursework'); + $data->courseworkid = $this->get_new_parentid('coursework'); $this->fixallocatable($data); - $this->set_defaults(array('allocatableid'=>0, - 'allocatabletype'=>'', - 'allocatableuser'=>0, - 'allocatablegroup'=>0, - 'stage_identifier'=>'', - 'selectiontype'=>''),$data); + $this->set_defaults(array('allocatableid' => 0, + 'allocatabletype' => '', + 'allocatableuser' => 0, + 'allocatablegroup' => 0, + 'stage_identifier' => '', + 'selectiontype' => ''), $data); global $DB; $newitemid = $DB->insert_record('coursework_sample_set_mbrs', $data); } - protected function process_coursework_extension($data) - { - $data=(object)$data; + protected function process_coursework_extension($data) { + $data = (object)$data; - $data->courseworkid=$this->get_new_parentid('coursework'); + $data->courseworkid = $this->get_new_parentid('coursework'); $data->createdbyid = $this->get_mappingid('user', $data->createdbyid); $this->fixallocatable($data); - $this->updatedate(array('extended_deadline'),$data); + $this->updatedate(array('extended_deadline'), $data); - $this->set_defaults(array('extended_deadline'=>0, - 'pre_defined_reason'=>'', - 'extra_information_text'=>'', - 'extra_information_format'=>FORMAT_HTML) - ,$data); + $this->set_defaults(array('extended_deadline' => 0, + 'pre_defined_reason' => '', + 'extra_information_text' => '', + 'extra_information_format' => FORMAT_HTML) + , $data); global $DB; $newitemid = $DB->insert_record('coursework_extensions', $data); } - protected function process_coursework_person_deadline($data) - { - $data=(object)$data; + protected function process_coursework_person_deadline($data) { + $data = (object)$data; - $data->courseworkid=$this->get_new_parentid('coursework'); + $data->courseworkid = $this->get_new_parentid('coursework'); $data->createdbyid = $this->get_mappingid('user', $data->createdbyid); - $data->lastmodifiedbyid=$this->get_mappingid('user',$data->lastmodifiedbyid); + $data->lastmodifiedbyid = $this->get_mappingid('user', $data->lastmodifiedbyid); $this->fixallocatable($data); $this->updatedate(array('personal_deadline', 'timecreated', - 'timemodified'),$data); + 'timemodified'), $data); - $now=time(); - $this->set_defaults(array('personal_deadline'=>0, - 'timecreated'=>$now, - 'timemodified'=>0, - 'lastmodifiedbyid'=>0),$data); + $now = time(); + $this->set_defaults(array('personal_deadline' => 0, + 'timecreated' => $now, + 'timemodified' => 0, + 'lastmodifiedbyid' => 0), $data); global $DB; $newitemid = $DB->insert_record('coursework_person_deadlines', $data); } + protected function process_coursework_mod_agreement($data) { + $data = (object)$data; - - - - protected function process_coursework_mod_agreement($data) - { - $data=(object)$data; - - $data->feedbackid=$this->get_new_parentid('coursework_feedback'); + $data->feedbackid = $this->get_new_parentid('coursework_feedback'); $data->moderatorid = $this->get_mappingid('user', $data->moderatorid); - $data->lastmodifiedby=$this->get_mappingid('user',$data->lastmodifiedby); + $data->lastmodifiedby = $this->get_mappingid('user', $data->lastmodifiedby); $this->fixallocatable($data); $this->updatedate(array('timecreated', - 'timemodified'),$data); + 'timemodified'), $data); - $now=time(); - $this->set_defaults(array('timecreated'=>$now, - 'timemodified'=>$now, - 'lasteditedby'=>0, - 'modcomment'=>'', - 'modcommentformat'=>1),$data); + $now = time(); + $this->set_defaults(array('timecreated' => $now, + 'timemodified' => $now, + 'lasteditedby' => 0, + 'modcomment' => '', + 'modcommentformat' => 1), $data); global $DB; $newitemid = $DB->insert_record('coursework_mod_agreements', $data); } + protected function process_coursework_plagiarism_flag($data) { + $data = (object)$data; - protected function process_coursework_plagiarism_flag($data) - { - $data=(object)$data; - - $data->submissionid=$this->get_new_parentid('coursework_submission'); + $data->submissionid = $this->get_new_parentid('coursework_submission'); $data->createdby = $this->get_mappingid('user', $data->createdby); - $data->lastmodifiedby=$this->get_mappingid('user',$data->lastmodifiedby); + $data->lastmodifiedby = $this->get_mappingid('user', $data->lastmodifiedby); $this->fixallocatable($data); $this->updatedate(array('timecreated', - 'timemodified'),$data); + 'timemodified'), $data); - $now=time(); - $this->set_defaults(array('timecreated'=>$now, - 'timemodified'=>$now, - 'lastmodifieddby'=>0, - 'comment'=>'', - 'comment_format'=>1),$data); + $now = time(); + $this->set_defaults(array('timecreated' => $now, + 'timemodified' => $now, + 'lastmodifieddby' => 0, + 'comment' => '', + 'comment_format' => 1), $data); global $DB; $newitemid = $DB->insert_record('coursework_plagiarism_flags', $data); @@ -381,8 +373,7 @@ protected function process_coursework_plagiarism_flag($data) * @param object $data The data in object form * @return void */ - protected function process_coursework($data) - { + protected function process_coursework($data) { global $DB; $data = (object)$data; @@ -393,80 +384,80 @@ protected function process_coursework($data) 'timecreated', 'startdate', 'generalfeedbacktimepublished', - 'deadline'),$data); - - $now=time(); - //Taken from install.xml - $this->set_defaults(array('formid'=>0, - 'course'=>0, - 'name'=>'', - 'intro'=>'', - 'introformat'=>FORMAT_HTML, - 'timecreated'=>$now, - 'timemodified'=>$now, - 'grade'=>0, - 'deadline'=>0, - 'srsinclude'=>0, - 'numberofmarkers'=>1, - 'blindmarking'=>1, - 'maxbytes'=>100000, - 'generalfeedback'=>0, - 'individualfeedback'=>0, - 'feedbackcomment'=>'', - 'feedbackcommentformat'=>FORMAT_HTML, - 'generalfeedbacktimepublished'=>0, - 'courseworktype'=>0, - 'assessorallocationstrategy'=>'equal', - 'moderationenabled'=>0, - 'allocationenabled'=>0, - 'moderatorallocationstrategy'=>0, - 'viewothersfeedback'=>0, - 'autoreleasefeedback'=>0, - 'retrospectivemoderation'=>0, - 'studentviewcomponentfeedbacks'=>0, - 'studentviewmoderatorfeedbacks'=>0, - 'strictanonymity'=>0, - 'studentviewfinalfeedback'=>1, - 'studentviewcomponentgrades'=>1, - 'studentviewfinalgrade'=>1, - 'studentviewmoderatorgrade'=>0, - 'strictanonymitymoderator'=>0, - 'allowlatesubmissions'=>0, - 'mitigationenabled'=>0, - 'enablegeneralfeedback'=>0, - 'maxfiles'=>1, - 'filetypes'=>'', - 'use_groups'=>0, - 'grouping_id'=>0, - 'allowearlyfinalisation'=>0, - 'showallfeedbacks'=>0, - 'startdate'=>0, - 'samplingenabled'=>0, - 'extensionsenabled'=>0, - 'assessoranonymity'=>0, - 'viewinitialgradeenabled'=>0, - 'automaticagreement'=>0, - 'automaticagreementrange'=>0, - 'automaticagreementstrategy'=>'', - 'averagerounding'=>'mid', - 'feedbackreleaseemail'=>0, - 'gradeeditingtime'=>0, - 'markingdeadlineenabled'=>0, - 'initialmarkingdeadline'=>0, - 'agreedgrademarkingdeadline'=>0, - 'markingreminderenabled'=>0, - 'submissionnotification'=>'', - 'extension'=>0, - 'relativeinitialmarkingdeadline'=>0, - 'relativeagreedmarkingdeadline'=>0, - 'autopopulatefeedbackcomment'=>0, - 'moderationagreementenabled'=>0, - 'draftfeedbackenabled'=>0, - 'processenrol'=>0, - 'plagiarismflagenabled'=>0, - 'processunenrol'=>0), $data); - - $this->check_grade('grade',$data); + 'deadline'), $data); + + $now = time(); + // Taken from install.xml + $this->set_defaults(array('formid' => 0, + 'course' => 0, + 'name' => '', + 'intro' => '', + 'introformat' => FORMAT_HTML, + 'timecreated' => $now, + 'timemodified' => $now, + 'grade' => 0, + 'deadline' => 0, + 'srsinclude' => 0, + 'numberofmarkers' => 1, + 'blindmarking' => 1, + 'maxbytes' => 100000, + 'generalfeedback' => 0, + 'individualfeedback' => 0, + 'feedbackcomment' => '', + 'feedbackcommentformat' => FORMAT_HTML, + 'generalfeedbacktimepublished' => 0, + 'courseworktype' => 0, + 'assessorallocationstrategy' => 'equal', + 'moderationenabled' => 0, + 'allocationenabled' => 0, + 'moderatorallocationstrategy' => 0, + 'viewothersfeedback' => 0, + 'autoreleasefeedback' => 0, + 'retrospectivemoderation' => 0, + 'studentviewcomponentfeedbacks' => 0, + 'studentviewmoderatorfeedbacks' => 0, + 'strictanonymity' => 0, + 'studentviewfinalfeedback' => 1, + 'studentviewcomponentgrades' => 1, + 'studentviewfinalgrade' => 1, + 'studentviewmoderatorgrade' => 0, + 'strictanonymitymoderator' => 0, + 'allowlatesubmissions' => 0, + 'mitigationenabled' => 0, + 'enablegeneralfeedback' => 0, + 'maxfiles' => 1, + 'filetypes' => '', + 'use_groups' => 0, + 'grouping_id' => 0, + 'allowearlyfinalisation' => 0, + 'showallfeedbacks' => 0, + 'startdate' => 0, + 'samplingenabled' => 0, + 'extensionsenabled' => 0, + 'assessoranonymity' => 0, + 'viewinitialgradeenabled' => 0, + 'automaticagreement' => 0, + 'automaticagreementrange' => 0, + 'automaticagreementstrategy' => '', + 'averagerounding' => 'mid', + 'feedbackreleaseemail' => 0, + 'gradeeditingtime' => 0, + 'markingdeadlineenabled' => 0, + 'initialmarkingdeadline' => 0, + 'agreedgrademarkingdeadline' => 0, + 'markingreminderenabled' => 0, + 'submissionnotification' => '', + 'extension' => 0, + 'relativeinitialmarkingdeadline' => 0, + 'relativeagreedmarkingdeadline' => 0, + 'autopopulatefeedbackcomment' => 0, + 'moderationagreementenabled' => 0, + 'draftfeedbackenabled' => 0, + 'processenrol' => 0, + 'plagiarismflagenabled' => 0, + 'processunenrol' => 0), $data); + + $this->check_grade('grade', $data); $newitemid = $DB->insert_record('coursework', $data); @@ -474,53 +465,43 @@ protected function process_coursework($data) } - protected function check_grade($field,&$data) - { - if ($data->$field < 0) // Scale found, get mapping. - { + protected function check_grade($field, &$data) { + if ($data->$field < 0) { // Scale found, get mapping. $data->$field = -($this->get_mappingid('scale', abs($data->$field))); } } - protected function set_defaults($fields,&$data) - { - foreach($fields as $name=>$default) - { - if(!isset($data->$name)) - { - $data->$name=$default; + protected function set_defaults($fields, &$data) { + foreach ($fields as $name => $default) { + if (!isset($data->$name)) { + $data->$name = $default; } } } - protected function updatedate($fields,&$data) - { - foreach($fields as $field) - { - $data->$field=$this->apply_date_offset($data->$field); + protected function updatedate($fields, &$data) { + foreach ($fields as $field) { + $data->$field = $this->apply_date_offset($data->$field); } } - protected function after_execute() - { + protected function after_execute() { global $DB; $this->add_related_files('mod_coursework', 'submission', 'coursework_submission'); $this->add_related_files('mod_coursework', 'feedback', 'coursework_feedback'); - //Fixup names - $fs=get_file_storage(); - $ctx=context::instance_by_id($this->task->get_contextid()); + // Fixup names + $fs = get_file_storage(); + $ctx = context::instance_by_id($this->task->get_contextid()); - $files=$fs->get_area_files($ctx->id,'mod_coursework','submission'); //Array of stored_file + $files = $fs->get_area_files($ctx->id, 'mod_coursework', 'submission'); //Array of stored_file - foreach($files as $file) - { - if(!$file->is_directory()) - { - $itemid=$file->get_itemid(); + foreach ($files as $file) { + if (!$file->is_directory()) { + $itemid = $file->get_itemid(); - $entry=$DB->get_record('coursework_submissions', - array('id'=>$itemid)); + $entry = $DB->get_record('coursework_submissions', + array('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 b45aa042..c24ad60e 100644 --- a/classes/ability.php +++ b/classes/ability.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework; @@ -59,7 +79,6 @@ function (coursework $coursework) { return has_capability('mod/coursework:view', $coursework->get_context(), $this->get_user()); }); - // Submission rules // New submission @@ -71,7 +90,6 @@ function (coursework $coursework) { $this->allow_new_submissions_if_late_submissions_allowed(); $this->allow_new_submissions_if_there_is_an_active_extension(); - // Create submission $this->allow_create_submission_if_can_new_submission(); @@ -87,7 +105,6 @@ function (coursework $coursework) { $this->allow_show_submission_if_user_can_administer_grades(); $this->allow_show_submission_if_user_can_view_all_grades_at_all_times(); - // Edit submission $this->prevent_edit_submission_for_unsaved_records(); $this->allow_edit_submissions_if_can_submit_on_behalf_of(); @@ -107,7 +124,6 @@ function (coursework $coursework) { // Finalise submission $this->allow_finalisation_when_has_permission_and_settings_allow(); - // Resubmit to plagiarism submission $this->allow_resubmit_to_plagiarism_submission_if_user_is_assessor_for_any_stage(); @@ -129,11 +145,9 @@ function (coursework $coursework) { $this->allow_edit_moderation_if_user_is_allocated_to_moderate(); $this->allow_edit_moderation_if_user_can_administer_grades(); - //show moderation + // Show moderation $this->allow_show_moderation_if_user_can_view_grades_at_all_times(); - - // Feedback rules // New feedback @@ -213,7 +227,6 @@ function (coursework $coursework) { // Update $this->allow_update_deadline_extension_if_can_edit(); - // Plagiarism flagging rules for Plagiarism Alert // New @@ -224,7 +237,6 @@ function (coursework $coursework) { $this->prevent_edit_plagiarism_flag_if_not_persisted(); $this->allow_edit_plagiarism_flag_with_capability(); - // Personal deadlines rules $this->prevent_edit_personal_deadline_if_extension_given(); $this->allow_edit_personal_deadline_with_capability(); @@ -428,19 +440,18 @@ function (submission $submission) { }); } - protected function allow_show_submission_if_user_is_agreed_grade_assessor_and_submission_is_ready() { $this->allow('show', 'mod_coursework\models\submission', function (submission $submission) { - $state = $submission->get_state(); + $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)); }); } - protected function allow_show_submission_if_user_can_administer_grades() { + protected function allow_show_submission_if_user_can_administer_grades() { $this->allow('show', 'mod_coursework\models\submission', function (submission $submission) { @@ -449,7 +460,7 @@ function (submission $submission) { }); } - protected function allow_show_submission_if_user_can_view_all_grades_at_all_times() { + protected function allow_show_submission_if_user_can_view_all_grades_at_all_times() { $this->allow('show', 'mod_coursework\models\submission', function (submission $submission) { @@ -457,7 +468,7 @@ function (submission $submission) { $submission->get_coursework()->get_context()); }); } - + protected function prevent_edit_submission_for_unsaved_records() { $this->prevent('edit', @@ -472,15 +483,15 @@ protected function prevent_edit_submission_past_deadline_and_no_extension() { 'mod_coursework\models\submission', function (submission $submission) { // take into account courseworks with personal deadlines - if ($submission->get_coursework()->personal_deadlines_enabled()){ - $deadline_passed = ($submission->submission_personal_deadline() < time())? true : false; + if ($submission->get_coursework()->personal_deadlines_enabled()) { + $deadline_passed = (bool)$submission->submission_personal_deadline() < time(); } else { $deadline_passed = $submission->get_coursework()->deadline_has_passed(); } $ok_to_submit_late = $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 ($deadline_passed && !deadline_extension::allocatable_extension_allows_submission($submitting_allocatable, $coursework)) { if (!$ok_to_submit_late) { $this->set_message('Cannot submit past the deadline'); return true; @@ -562,16 +573,13 @@ function (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(); + $coursework_has_no_deadline = !$submission->get_coursework()->has_deadline(); $allowed_to = $this->can('new', $submission) || $this->can('edit', $submission); - - return $allowed_to && $not_already_finalised && ($early_finalisation_allowed or $coursework_has_no_deadline) ; + return $allowed_to && $not_already_finalised && ($early_finalisation_allowed || $coursework_has_no_deadline); }); } - - protected function allow_resubmit_to_plagiarism_submission_if_user_is_assessor_for_any_stage() { $this->allow('resubmit_to_plagiarism', 'mod_coursework\models\submission', @@ -636,28 +644,25 @@ protected function allow_new_moderation_if_user_is_allocated_to_moderate() { 'mod_coursework\models\moderation', function (moderation $moderation) { $is_allocated = false; - if($moderation->get_coursework()->allocation_enabled()) { + if ($moderation->get_coursework()->allocation_enabled()) { $is_allocated = $moderation->is_moderator_allocated(); } return $is_allocated; }); } - 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; - if($moderation->get_coursework()->allocation_enabled() && !is_siteadmin()) { + if ($moderation->get_coursework()->allocation_enabled() && !is_siteadmin()) { $is_allocated = !$moderation->is_moderator_allocated(); } return $is_allocated; }); } - - protected function allow_edit_moderation_if_user_created_moderation_and_can_edit() { $this->allow('edit', 'mod_coursework\models\moderation', @@ -665,7 +670,7 @@ 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()) ; + return $has_capability && ($is_creator || is_siteadmin()); }); } @@ -678,7 +683,7 @@ function (moderation $moderation) { }); } - protected function allow_edit_moderation_if_user_can_administer_grades(){ + protected function allow_edit_moderation_if_user_can_administer_grades() { $this->allow('edit', 'mod_coursework\models\moderation', function (moderation $moderation) { @@ -698,9 +703,6 @@ function (moderation $moderation) { }); } - - - protected function prevent_new_feedback_with_no_submission() { $this->prevent('new', 'mod_coursework\models\feedback', @@ -837,11 +839,11 @@ protected function allow_new_feedback_from_any_assessor_when_allocation_is_disab 'mod_coursework\models\feedback', function (feedback $feedback) { - $has_editable_feedbacks = false; + $has_editable_feedbacks = false; // find out if the previous grades are editable - if ($feedback->is_agreed_grade()) { - $has_editable_feedbacks = $feedback->get_submission()->editable_feedbacks_exist(); + if ($feedback->is_agreed_grade()) { + $has_editable_feedbacks = $feedback->get_submission()->editable_feedbacks_exist(); } if ((!$feedback->get_coursework()->allocation_enabled() || !$feedback->get_stage()->uses_allocation()) && !$has_editable_feedbacks ) { @@ -899,9 +901,9 @@ function (feedback $feedback) { $is_creator = $feedback->assessorid == $this->get_user()->id; $is_allocated = $feedback->is_assessor_allocated(); - $submission = $feedback->get_submission(); + $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()); + $in_editable_period = (!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); }); @@ -962,7 +964,6 @@ function (feedback $feedback) { }); } - protected function allow_show_feedback_to_other_assessors_when_view_initial_grade_is_enabled() { $this->allow('show', 'mod_coursework\models\feedback', @@ -1129,10 +1130,6 @@ function (grading_table_row_base $grading_table_row) { }); } - - - - protected function allow_show_grading_table_row_if_user_can_export_final_grades() { $this->allow('show', 'mod_coursework\grading_table_row_base', @@ -1161,16 +1158,15 @@ 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; + $has_editable_feedbacks = false; // find out if the previous grades are editable - if ($feedback->is_agreed_grade()) { + if ($feedback->is_agreed_grade()) { - $has_editable_feedbacks = $feedback->get_submission()->editable_feedbacks_exist(); + $has_editable_feedbacks = $feedback->get_submission()->editable_feedbacks_exist(); } - return $feedback->is_agreed_grade() && !$has_editable_feedbacks && (has_capability('mod/coursework:addagreedgrade', $feedback->get_coursework() ->get_context()) @@ -1201,9 +1197,6 @@ function (grading_table_row_base $row) { }); } - - - private function allow_show_grading_table_row_if_user_can_grant_extension_and_no_allocation() { $this->allow('show', 'mod_coursework\grading_table_row_base', @@ -1216,8 +1209,6 @@ function (grading_table_row_base $row) { }); } - - private function allow_edit_feedback_if_user_can_administer_grades() { $this->allow('edit', 'mod_coursework\models\feedback', @@ -1316,7 +1307,7 @@ 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() + return $personal_deadline->get_coursework()->personal_deadlines_enabled() && has_capability('mod/coursework:editpersonaldeadline', $personal_deadline->get_coursework() ->get_context()); @@ -1332,7 +1323,6 @@ function (personal_deadline $personal_deadline) { }); } - private function allow_new_plagiarism_flag_with_capability() { $this->allow('new', 'mod_coursework\models\plagiarism_flag', @@ -1341,7 +1331,6 @@ function (plagiarism_flag $plagiarism_flag) { }); } - private function allow_edit_plagiarism_flag_with_capability() { $this->allow('edit', 'mod_coursework\models\plagiarism_flag', @@ -1352,7 +1341,6 @@ function (plagiarism_flag $plagiarism_flag) { }); } - private function prevent_edit_plagiarism_flag_if_not_persisted() { $this->prevent('edit', 'mod_coursework\models\plagiarism_flag', @@ -1361,4 +1349,4 @@ function (plagiarism_flag $plagiarism_flag) { }); } -} \ No newline at end of file +} diff --git a/classes/ability/rule.php b/classes/ability/rule.php index d9e9fc7f..15272a7e 100644 --- a/classes/ability/rule.php +++ b/classes/ability/rule.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\ability; @@ -97,4 +117,4 @@ protected function class_matches($object) { } return false; } -} \ No newline at end of file +} diff --git a/classes/allocation/allocatable.php b/classes/allocation/allocatable.php index 06fb2a87..7a215d7c 100644 --- a/classes/allocation/allocatable.php +++ b/classes/allocation/allocatable.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\allocation; use mod_coursework\models\coursework; @@ -75,4 +95,4 @@ public function has_all_initial_feedbacks($coursework); * @return submission */ public function get_submission($coursework); -} \ No newline at end of file +} diff --git a/classes/allocation/auto_allocator.php b/classes/allocation/auto_allocator.php index 4caa89ab..97b65961 100644 --- a/classes/allocation/auto_allocator.php +++ b/classes/allocation/auto_allocator.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\allocation; @@ -29,7 +49,7 @@ public function process_allocations() { $this->delete_all_ungraded_auto_allocations(); foreach ($this->marking_stages() as $stage) { - if ($stage->group_assessor_enabled() && $stage->identifier() == 'assessor_1'){ + if ($stage->group_assessor_enabled() && $stage->identifier() == 'assessor_1') { // if allocation strategy 'group_assessor' then assign assessor from that group to stage1 and continue // for the rest of stages with manual allocation $allocatables = $this->get_allocatables(); @@ -117,4 +137,4 @@ private function delete_all_ungraded_auto_allocations() { private function get_coursework() { return $this->coursework; } -} \ No newline at end of file +} diff --git a/classes/allocation/manager.php b/classes/allocation/manager.php index a3a66f11..e25b57af 100644 --- a/classes/allocation/manager.php +++ b/classes/allocation/manager.php @@ -20,8 +20,7 @@ * Page that prints a table of all students and all markers so that first marker, second marker, * moderators etc can be allocated manually or automatically. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -31,13 +30,12 @@ use mod_coursework\models\moderation_set_rule; use mod_coursework\moderation_set_widget; use mod_coursework\sampling_set_widget; -use \mod_coursework\stages\base as stage_base; +use mod_coursework\stages\base as stage_base; use moodle_exception; use mod_coursework\grade_judge; defined('MOODLE_INTERNAL') || die(); - /** * This takes responsibility for managing the allocations of markers to students, both manually and * automatically. Specifically, it processes user input from the allocation screen and performs the allocation @@ -53,12 +51,12 @@ class manager { /** * @var strategy\base */ - private $assessorallocationstrategy; + private $assessorallocationstrategy; /** * @var strategy\base */ - private $moderatorallocationstrategy; + private $moderatorallocationstrategy; /** * New instance created with references to the coursework stored. @@ -71,7 +69,7 @@ public function __construct(coursework $coursework) { $this->coursework = $coursework; // Instantiate the allocation strategies so we can use them. - $strategytypes = array(); + $strategytypes = []; if (!empty($this->coursework->assessorallocationstrategy)) { $strategytypes[] = coursework::ASSESSOR; } @@ -85,7 +83,6 @@ public function __construct(coursework $coursework) { $classname = !empty($coursework->$propertyname) ? '\\mod_coursework\allocation\strategy\\'.$coursework->$propertyname : ''; - if (class_exists($classname)) { $this->$propertyname = new $classname($coursework); if (!($this->$propertyname instanceof strategy\base)) { @@ -113,7 +110,7 @@ public static function get_allocation_classnames($type = coursework::ASSESSOR) { $classdir = $CFG->dirroot . '/mod/coursework/classes/allocation/strategy'; $fullclassnames = glob($classdir . '/*.php'); - $options = array(); + $options = []; foreach ($fullclassnames as $fullclassname) { if (strpos($fullclassname, 'base') !== false) { continue; @@ -125,8 +122,8 @@ 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']); + if (array_key_exists('none', $options)) { + $new_value = array('none' => $options['none']); unset($options['none']); $options = $new_value + $options; } @@ -172,7 +169,7 @@ public function auto_generate_moderation_set() { } // These are the ones we will actually moderate (or which have already been moderated). - $moderation_set = array(); + $moderation_set = []; // Move all the already marked ones into the set. These have to stay in it and ought to // be taken into account so that the other rules just add to them. @@ -187,16 +184,15 @@ public function auto_generate_moderation_set() { } - /** * Returns array of sampling options. This function should be looked upon as a placeholder * in case more complex functionality is defined * * @return array */ - public function get_sampling_options() { - return array('0'=>get_string('manual','mod_coursework'), - '1'=>get_string('automatic','mod_coursework')); + public function get_sampling_options() { + return array('0' => get_string('manual', 'mod_coursework'), + '1' => get_string('automatic', 'mod_coursework')); } @@ -233,19 +229,13 @@ public function get_sampling_set_rules() { */ public function get_sampling_set_widget($requestedrule = false) { - - $rules = $this->get_sampling_set_rules(); - - $widget = new sampling_set_widget($rules, $this->coursework, $requestedrule); return new \mod_coursework_sampling_set_widget($widget); } - - /** * We know a rule came in, so we save it by delegating to the class, which will know what the form submitted. * @@ -256,33 +246,32 @@ public function save_sample_set_rule($assessor_number) { global $CFG, $DB; - $sampleplugins = $DB->get_records('coursework_sample_set_plugin',null,'pluginorder'); - $order = 0; + $sampleplugins = $DB->get_records('coursework_sample_set_plugin', null, 'pluginorder'); + $order = 0; foreach ($sampleplugins as $plugin) { $classname = '\mod_coursework\sample_set_rule\\' . $plugin->rulename; $rule = new $classname($this->coursework); - $rule->save_form_data($assessor_number,$order); + $rule->save_form_data($assessor_number, $order); } } - public function save_sample() { + public function save_sample() { global $DB; - $DB->delete_records('coursework_sample_set_rules',array('courseworkid'=>$this->coursework->id)); - for ($i = 2; $i <= $this->coursework->get_max_markers(); $i++) { + $DB->delete_records('coursework_sample_set_rules', array('courseworkid' => $this->coursework->id)); + for ($i = 2; $i <= $this->coursework->get_max_markers(); $i++) { - $sample_strategy = required_param("assessor_{$i}_samplingstrategy",PARAM_INT); + $sample_strategy = required_param("assessor_{$i}_samplingstrategy", PARAM_INT); - if ($sample_strategy) { + if ($sample_strategy) { $this->save_sample_set_rule($i); } - } $this->auto_generate_sample_set(); } @@ -294,84 +283,76 @@ private function get_coursework() { return $this->coursework; } - - public function auto_generate_sample_set() { + public function auto_generate_sample_set() { global $DB; - $sampleplugins = $DB->get_records('coursework_sample_set_plugin',null,'pluginorder'); - $order = 0; - + $sampleplugins = $DB->get_records('coursework_sample_set_plugin', null, 'pluginorder'); + $order = 0; - $sample_set = array(); + $sample_set = []; $allocatables = $this->get_coursework()->get_allocatables(); - $final_agreed_allocatables = $this->get_allocatables_with_final_agreed(); + $final_agreed_allocatables = $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) { + // 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]); } - for($stage_number = 2; $stage_number <= $this->get_coursework()->get_max_markers(); $stage_number++) { - + for ($stage_number = 2; $stage_number <= $this->get_coursework()->get_max_markers(); $stage_number++) { - $stage = "assessor_{$stage_number}"; + $stage = "assessor_{$stage_number}"; $this->remove_unmarked_automatic_allocatables($stage); - $sql = "SELECT DISTINCT rulename + $sql = "SELECT DISTINCT rulename FROM (SELECT rulename,ruleorder FROM {coursework_sample_set_plugin} p, {coursework_sample_set_rules} r - WHERE p.id = r.sample_set_plugin_id + WHERE p.id = r.sample_set_plugin_id AND r.courseworkid = :courseworkid 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, array('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); - $auto_with_feedback = $this->get_automatic_with_feedback($stage); - - + $auto_with_feedback = $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 - //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 ($auto_with_feedback as $k => $v) { + if (!isset($manual_sample_set[$k])) $manual_sample_set[$k] = $v; } - - $auto_sample_set = array(); + $auto_sample_set = []; foreach ($sampleplugins as $plugin) { $classname = '\mod_coursework\sample_set_rule\\' . $plugin->rulename; $rule = new $classname($this->coursework); - $rule->adjust_sample_set($stage_number,$allocatables,$manual_sample_set,$auto_sample_set); + $rule->adjust_sample_set($stage_number, $allocatables, $manual_sample_set, $auto_sample_set); } - //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 + // 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); } @@ -384,59 +365,57 @@ public function get_include_in_sample_set($stage_number) { global $DB; - $stage = "assessor_{$stage_number}"; + $stage = "assessor_{$stage_number}"; - $sql = "SELECT allocatableid, + $sql = "SELECT allocatableid, courseworkid, allocatabletype, stage_identifier, selectiontype FROM {coursework_sample_set_mbrs} - WHERE courseworkid = :courseworkid - AND stage_identifier = :stage_identifier + WHERE courseworkid = :courseworkid + AND stage_identifier = :stage_identifier AND selectiontype = 'manual'"; - - //get all users in manually selected for stage in coursework + // Get all users in manually selected for stage in coursework return $DB->get_records_sql($sql, - array('courseworkid'=>$this->coursework->id,'stage_identifier'=>$stage)); + array('courseworkid' => $this->coursework->id, 'stage_identifier' => $stage)); } - public function get_automatic_with_feedback($stage) { + public function get_automatic_with_feedback($stage) { global $DB; - $sql = "SELECT s.allocatableid, f.* + $sql = "SELECT s.allocatableid, f.* FROM {coursework_submissions} s, {coursework_feedbacks} f, {coursework_sample_set_mbrs} m - WHERE s.id = f.submissionid + WHERE s.id = f.submissionid AND s.courseworkid = :courseworkid AND f.stage_identifier = :stage AND s.courseworkid = m.courseworkid - AND s.allocatableid = m.allocatableid - AND s.allocatabletype = m.allocatabletype + AND s.allocatableid = m.allocatableid + AND s.allocatabletype = m.allocatabletype 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, array('courseworkid' => $this->coursework->id, 'stage' => $stage)); } - - public function remove_unmarked_automatic_allocatables($stage) { + public function remove_unmarked_automatic_allocatables($stage) { global $DB; - $sql = "DELETE + $sql = "DELETE FROM {coursework_sample_set_mbrs} WHERE selectiontype = 'automatic' AND stage_identifier = '{$stage}' - AND courseworkid = {$this->coursework->id} + AND courseworkid = {$this->coursework->id} AND allocatableid NOT IN ( SELECT s.allocatableid FROM {coursework_submissions} s, {coursework_feedbacks} f - WHERE s.id = f.submissionid + WHERE s.id = f.submissionid AND s.courseworkid = {$this->coursework->id} AND f.stage_identifier = '{$stage}' @@ -444,11 +423,9 @@ public function remove_unmarked_automatic_allocatables($stage) { return $DB->execute($sql); - - } - public function get_allocatables_with_final_agreed() { + public function get_allocatables_with_final_agreed() { global $DB; @@ -459,11 +436,8 @@ 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, array('courseworkid' => $this->coursework->id)); } - - - } diff --git a/classes/allocation/moderatable.php b/classes/allocation/moderatable.php index 8ade7881..5428d896 100644 --- a/classes/allocation/moderatable.php +++ b/classes/allocation/moderatable.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\allocation; @@ -9,6 +29,4 @@ */ interface moderatable { - - -} \ No newline at end of file +} diff --git a/classes/allocation/strategy/base.php b/classes/allocation/strategy/base.php index 1f4a1875..4069fa15 100644 --- a/classes/allocation/strategy/base.php +++ b/classes/allocation/strategy/base.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\allocation\strategy; use mod_coursework\allocation\allocatable; @@ -22,10 +28,8 @@ use mod_coursework\models\user; use mod_coursework\stages\base as stage_base; - defined('MOODLE_INTERNAL') || die(); - /** * This base class is extended to make specific allocation strategies, which when run, will * allocated teachers to mark student work in specific ways. @@ -60,7 +64,7 @@ abstract class base { * * @var array */ - private $settings = array(); + private $settings = []; /** * @var stage_base diff --git a/classes/allocation/strategy/equal.php b/classes/allocation/strategy/equal.php index d9ae7395..114391e4 100644 --- a/classes/allocation/strategy/equal.php +++ b/classes/allocation/strategy/equal.php @@ -19,8 +19,7 @@ /** * Allocation strategy for giving all teachers equal numbers of students to mark * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -29,7 +28,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Allocates all students equally between teachers. */ @@ -88,7 +86,7 @@ public function save_allocation_strategy_options() { * @return mixed */ protected function list_of_allocatable_teachers_and_their_current_number_of_allocations($teachers, $student) { - $teacherids = array(); + $teacherids = []; foreach ($teachers as $id => $teacher) { if ($this->teacher_already_has_an_allocation_for_this_allocatable($student, $teacher)) { diff --git a/classes/allocation/strategy/group_assessor.php b/classes/allocation/strategy/group_assessor.php index 3a4876bc..8219bce1 100644 --- a/classes/allocation/strategy/group_assessor.php +++ b/classes/allocation/strategy/group_assessor.php @@ -19,8 +19,7 @@ /** * Class file for the Group assessor allocation strategy. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2018 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -67,6 +66,6 @@ public function save_allocation_strategy_options() { * @return mixed */ protected function list_of_allocatable_teachers_and_their_current_number_of_allocations($teachers, $student) { - return array(); + return []; } } diff --git a/classes/allocation/strategy/none.php b/classes/allocation/strategy/none.php index eb3ccf62..065fd08d 100644 --- a/classes/allocation/strategy/none.php +++ b/classes/allocation/strategy/none.php @@ -19,8 +19,7 @@ /** * lass file for the default allocation strategy. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -49,10 +48,10 @@ public function autoallocation_enabled() { * @return string */ public function add_form_elements($strategypurpose = 'assessor') { - global $PAGE,$CFG; + global $PAGE, $CFG; $url = "$CFG->wwwroot/mod/coursework/actions/upload_allocations.php?cmid={$PAGE->cm->id}"; - $html = html_writer::link($url,get_string('uploadallocations', 'mod_coursework')); + $html = html_writer::link($url, get_string('uploadallocations', 'mod_coursework')); return $html; } @@ -73,6 +72,6 @@ public function save_allocation_strategy_options() { * @return mixed */ protected function list_of_allocatable_teachers_and_their_current_number_of_allocations($teachers, $student) { - return array(); + return []; } } diff --git a/classes/allocation/strategy/percentages.php b/classes/allocation/strategy/percentages.php index 84e48fa0..a6fc2064 100644 --- a/classes/allocation/strategy/percentages.php +++ b/classes/allocation/strategy/percentages.php @@ -19,8 +19,7 @@ /** * Allocation strategy for giving each teacher a different percentage of work to mark. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -35,7 +34,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Allocates all students equally between teachers. */ @@ -141,7 +139,7 @@ public function save_allocation_strategy_options() { // Get the data from the form. $name = $this->get_name(); - $data = optional_param_array('assessorstrategy'.$name, array(), PARAM_RAW); // Array[teacherid] => value. + $data = optional_param_array('assessorstrategy'.$name, [], PARAM_RAW); // Array[teacherid] => value. if (!is_array($data)) { return true; @@ -200,7 +198,7 @@ public function save_allocation_strategy_options() { * @param $teacher * @return int|mixed */ - private function percentage_for_teacher($teacher){ + private function percentage_for_teacher($teacher) { global $DB; @@ -246,7 +244,7 @@ private function teacher_already_has_maximum_allocations($teacher) { * @return array */ protected function list_of_allocatable_teachers_and_their_current_number_of_allocations($teachers, $student) { - $teacherids = array(); + $teacherids = []; foreach ($teachers as $teacher) { if ($this->teacher_already_has_an_allocation_for_this_allocatable($student, $teacher)) { diff --git a/classes/allocation/table/builder.php b/classes/allocation/table/builder.php index 372beb7f..90e607ef 100644 --- a/classes/allocation/table/builder.php +++ b/classes/allocation/table/builder.php @@ -19,8 +19,7 @@ /** * Class file for the renderable object that makes the table for allocating markerts to students. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -62,7 +61,6 @@ public function __construct($coursework, array $options) { $this->options = $options; } - /** * Takes the raw data, instantiates each row as a new renderable object and returns the whole lot. * @@ -71,12 +69,10 @@ public function __construct($coursework, array $options) { public function get_rows() { $allocatables = $this->get_coursework()->get_allocatables(); - $rows = array(); + $rows = []; foreach ($allocatables as $allocatable) { $rows[] = new row_builder($this, $allocatable); } - - // Sort the rows. $sorting = new mod_coursework\grading_report($this->options, $this->coursework); $method_name = 'sort_by_' . $this->options['sortby']; @@ -86,12 +82,10 @@ public function get_rows() { $method_name)); } - return $rows; } - /** * Counts the total number of students that the current user can see. * @@ -112,12 +106,11 @@ public function get_table_rows_for_page() { $allocatables = $this->get_coursework()->get_allocatables(); - $rows = array(); + $rows = []; foreach ($allocatables as $allocatable) { $rows[] = new row_builder($this, $allocatable); } - // Sort the rows. $sorting = new mod_coursework\grading_report($this->options, $this->coursework); $method_name = 'sort_by_' . $this->options['sortby']; @@ -135,7 +128,7 @@ public function get_table_rows_for_page() { $start = ($this->options['page']) * $this->options['perpage']; // Will start at 0. $end = ($this->options['page'] + 1) * $this->options['perpage']; // Take care of overlap: 0-10, 10-20, 20-30. - $end = (empty($end)) ? count($rows) : $end; + $end = (empty($end)) ? count($rows) : $end; $counter = 0; // Begin from the first one that the user could see. foreach ($rows as $allocatable_id => $row) { @@ -146,15 +139,13 @@ public function get_table_rows_for_page() { } } - $this->totalrows = $rows; - $this->totalcount = $counter; - + $this->totalrows = $rows; + $this->totalcount = $counter; return $this->totalrows; } - /** * Getter for the coursework instance * @@ -194,20 +185,20 @@ public function get_allocatable_cell() { return new user_cell($items); } - public function get_hidden_elements() { + public function get_hidden_elements() { global $SESSION; - $elements = ''; + $elements = ''; - $cm = $this->coursework->get_course_module(); + $cm = $this->coursework->get_course_module(); - if (isset($SESSION->coursework_allocationsessions[$cm->id])) { + if (isset($SESSION->coursework_allocationsessions[$cm->id])) { - foreach($SESSION->coursework_allocationsessions[$cm->id] as $name => $val) { + foreach ($SESSION->coursework_allocationsessions[$cm->id] as $name => $val) { - if(!is_array($val)) { + if (!is_array($val)) { - $elements .= " "; + $elements .= " "; } @@ -217,6 +208,5 @@ public function get_hidden_elements() { return $elements; - } } diff --git a/classes/allocation/table/cell/builder.php b/classes/allocation/table/cell/builder.php index cd86737a..859cb3e6 100644 --- a/classes/allocation/table/cell/builder.php +++ b/classes/allocation/table/cell/builder.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\allocation\table\cell; use mod_coursework\models\allocation; @@ -38,13 +58,12 @@ class builder { * @param stage_base $stage * @param array $data_array incoming data from the allocation form */ - public function __construct($coursework, $allocatable, $stage, $data_array = array()) { + public function __construct($coursework, $allocatable, $stage, $data_array = []) { $this->coursework = $coursework; $this->allocatable = $allocatable; $this->stage = $stage; } - /** * @return \html_table_cell */ @@ -75,13 +94,12 @@ private function get_potential_marker_dropdown() { return $this->get_stage()->potential_marker_dropdown($this->get_allocatable()); - } /** * @return string */ - private function get_potential_moderators_dropdown(){ + private function get_potential_moderators_dropdown() { if ($this->stage_does_not_use_allocation()) { return ''; @@ -96,8 +114,8 @@ private function get_potential_moderators_dropdown(){ /** * @return bool */ - private function has_moderation(){ - if ($this->get_submission()){ + private function has_moderation() { + if ($this->get_submission()) { return $this->get_stage()->has_moderation($this->get_submission()); } else { return false; @@ -118,12 +136,11 @@ private function get_feedback() { return $this->get_stage()->get_feedback_for_allocatable($this->get_allocatable()); } - /** * @return bool|\mod_coursework\models\moderation */ private function get_moderation() { - if ($this->get_submission()){ + if ($this->get_submission()) { return $this->get_stage()->get_moderation($this->get_submission()); } return false; @@ -151,19 +168,19 @@ private function prepare_allocation_table_cell() { $contents = ''; $assessor_dropdown = ''; - if ($this->coursework->sampling_enabled()){ - if ($class == 'final_agreed_1'){ + if ($this->coursework->sampling_enabled()) { + if ($class == 'final_agreed_1') { } else if ($this->get_stage()->uses_sampling()) { - if ($this->has_automatic_sampling()){ + if ($this->has_automatic_sampling()) { $contents .= $this->get_automatically_in_sample_label(); $contents .= $this->sampling_hidden_checkbox(); } else { if ($this->has_feedback()) { $contents .= $this->get_included_in_sample_label(); $contents .= $this->sampling_hidden_checkbox(); - } else{ + } else { $contents .= $this->sampling_set_checkbox(); } } @@ -188,11 +205,10 @@ private function prepare_allocation_table_cell() { $assessor_name .= 'Grade: '; $assessor_name .= $this->get_feedback()->get_grade(); } else if ($this->has_allocation()) { - $assessor_name .= ' '.$this->pinned_checkbox($assessor_dropdown) ; + $assessor_name .= ' '.$this->pinned_checkbox($assessor_dropdown); $assessor_name .= $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()) { $contents .= '
'; @@ -214,7 +230,7 @@ private function prepare_allocation_table_cell() { /** * @return string */ - private function prepare_moderation_table_cell(){ + private function prepare_moderation_table_cell() { $contents = ''; $class = 'moderators'; @@ -239,13 +255,11 @@ private function prepare_moderation_table_cell(){ $moderator_name .= $this->get_stage()->get_allocated_assessor_name($this->get_allocatable()); } - if ($moderator_name) { $contents .= '
'; $contents .= "{$moderator_name}"; } - if ($moderator_dropdown) { $contents .= '
'; $contents .= $moderator_dropdown; @@ -257,7 +271,6 @@ private function prepare_moderation_table_cell(){ '; } - /** * @return allocatable */ @@ -283,12 +296,12 @@ private function sampling_set_checkbox() { $checkbox_checked = 1; } - $checkbox_checked = $this->checkbox_checked_in_session($checkbox_name,$checkbox_checked); + $checkbox_checked = $this->checkbox_checked_in_session($checkbox_name, $checkbox_checked); $checkbox_title = 'Included in sample'; $attributes = array('class' => 'sampling_set_checkbox', - 'id'=>$this->get_allocatable()->type().'_' . $this->get_allocatable()->id() . '_'.$this->get_stage()->identifier() .'_samplecheckbox', + 'id' => $this->get_allocatable()->type().'_' . $this->get_allocatable()->id() . '_'.$this->get_stage()->identifier() .'_samplecheckbox', 'title' => $checkbox_title); // if agreed grade given or grade published to students disable remaining sampling checkbox @@ -317,8 +330,8 @@ private function sampling_hidden_checkbox() { 1, '', array('class' => 'sampling_set_checkbox', - 'id'=>$this->get_allocatable()->type().'_' . $this->get_allocatable()->id() . '_'.$this->get_stage()->identifier() .'_samplecheckbox', - 'title' => $checkbox_title, 'hidden'=>true)); + 'id' => $this->get_allocatable()->type().'_' . $this->get_allocatable()->id() . '_'.$this->get_stage()->identifier() .'_samplecheckbox', + 'title' => $checkbox_title, 'hidden' => true)); } /** @@ -327,18 +340,16 @@ private function sampling_hidden_checkbox() { * @return bool * @throws \coding_exception */ - private function has_automatic_sampling() { + private function has_automatic_sampling() { global $DB; - $params = array('courseworkid'=>$this->coursework->id(), - 'allocatableid'=>$this->get_allocatable()->id(), - 'stage_identifier'=>$this->get_stage()->identifier(), + $params = array('courseworkid' => $this->coursework->id(), + 'allocatableid' => $this->get_allocatable()->id(), + 'stage_identifier' => $this->get_stage()->identifier(), 'selectiontype' => 'automatic'); - - - return $DB->record_exists('coursework_sample_set_mbrs',$params); + return $DB->record_exists('coursework_sample_set_mbrs', $params); } /** @@ -346,8 +357,6 @@ private function has_automatic_sampling() { */ private function pinned_checkbox() { - - $checkbox_name = 'allocatables[' . $this->get_allocatable()->id . '][' . $this->get_stage()->identifier() . '][pinned]'; $checkbox_checked = 0; @@ -357,7 +366,7 @@ private function pinned_checkbox() { } } - $checkbox_checked = $this->checkbox_checked_in_session($checkbox_name,$checkbox_checked); + $checkbox_checked = $this->checkbox_checked_in_session($checkbox_name, $checkbox_checked); $stage = substr($this->get_stage()->identifier(), -1); $checkbox_title = 'Pinned (auto allocations will not alter this)'; @@ -369,21 +378,17 @@ private function pinned_checkbox() { 'title' => $checkbox_title)); } - - - private function checkbox_checked_in_session($checkboxname,$checkboxstate) { + private function checkbox_checked_in_session($checkboxname, $checkboxstate) { global $SESSION; - $cm = $this->coursework->get_course_module(); + $cm = $this->coursework->get_course_module(); - if (!empty($SESSION->coursework_allocationsessions[$cm->id])) { - if (isset($SESSION->coursework_allocationsessions[$cm->id][$checkboxname])) { + if (!empty($SESSION->coursework_allocationsessions[$cm->id])) { + if (isset($SESSION->coursework_allocationsessions[$cm->id][$checkboxname])) { return $SESSION->coursework_allocationsessions[$cm->id][$checkboxname]; } - - } return $checkboxstate; @@ -409,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, array('class' => 'included_in_sample')); } /** @@ -417,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, array('class' => 'included_in_sample')); } /** @@ -431,7 +436,7 @@ private function has_final_feedback() { 'allocatableid-allocatabletype', [$this->allocatable->id(), $this->allocatable->type()] ); - if($submission){ + if ($submission) { $feedbacks = isset(feedback::$pool[$this->coursework->id]['submissionid'][$submission->id]) ? feedback::$pool[$this->coursework->id]['submissionid'][$submission->id] : []; @@ -456,4 +461,4 @@ private function get_submission() { ); return $submission; } -} \ No newline at end of file +} diff --git a/classes/allocation/table/cell/data.php b/classes/allocation/table/cell/data.php index a32765c4..e86f01a1 100644 --- a/classes/allocation/table/cell/data.php +++ b/classes/allocation/table/cell/data.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\allocation\table\cell; use mod_coursework\models\user; @@ -30,7 +50,7 @@ class data { * @param stage_base $stage * @param array $data */ - public function __construct($stage, $data = array()) { + public function __construct($stage, $data = []) { $this->data = $data; $this->stage = $stage; $this->preprocess_data(); @@ -44,7 +64,6 @@ protected function preprocess_data() { $key = $this->assessor_id_key_name(); if (array_key_exists($key, $this->data) && !empty($this->data[$key])) { $assessor = user::find($this->data[$key]); - if ($assessor && $this->stage->user_is_assessor($assessor)) { $this->assessor = $assessor; } @@ -101,4 +120,4 @@ private function moderation_set_key() { private function pinned_key() { return 'pinned'; } -} \ No newline at end of file +} diff --git a/classes/allocation/table/cell/processor.php b/classes/allocation/table/cell/processor.php index b556e00e..f009d81a 100644 --- a/classes/allocation/table/cell/processor.php +++ b/classes/allocation/table/cell/processor.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\allocation\table\cell; use mod_coursework\models\allocation; @@ -36,7 +56,7 @@ class processor { * @param stage_base $stage * @param array $data_array incoming data from the allocation form */ - public function __construct($coursework, $allocatable, $stage, $data_array = array()) { + public function __construct($coursework, $allocatable, $stage, $data_array = []) { $this->coursework = $coursework; $this->allocatable = $allocatable; $this->stage = $stage; @@ -58,7 +78,6 @@ public function process($cell_data) { } } - /** * @param data $data */ @@ -95,8 +114,6 @@ private function get_allocation() { return $this->get_stage()->get_allocation($this->get_allocatable()); } - - /** * @param data $data */ @@ -146,23 +163,22 @@ private function process_pin($cell_data) { } } - /** * returns whether the current record was automatically included in the sample set at the current stage * * @return bool * @throws \coding_exception */ - private function has_automatic_sampling() { + private function has_automatic_sampling() { global $DB; - $params = array('courseworkid'=>$this->coursework->id(), - 'allocatableid'=>$this->get_allocatable()->id(), - 'stage_identifier'=>$this->get_stage()->identifier(), + $params = array('courseworkid' => $this->coursework->id(), + 'allocatableid' => $this->get_allocatable()->id(), + 'stage_identifier' => $this->get_stage()->identifier(), 'selectiontype' => 'automatic'); - return $DB->record_exists('coursework_sample_set_mbrs',$params); + return $DB->record_exists('coursework_sample_set_mbrs', $params); } -} \ No newline at end of file +} diff --git a/classes/allocation/table/processor.php b/classes/allocation/table/processor.php index d89270aa..7b6c5f85 100644 --- a/classes/allocation/table/processor.php +++ b/classes/allocation/table/processor.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * This class is here to take the data from the table on the allocation page and process each @@ -32,7 +52,7 @@ public function __construct($coursework) { /** * @param array $table_data */ - public function process_data($table_data = array()) { + public function process_data($table_data = []) { $clean_data = $this->clean_data($table_data); $allocatables = $this->coursework->get_allocatables(); @@ -40,7 +60,7 @@ public function process_data($table_data = array()) { if (array_key_exists($allocatable->id(), $clean_data)) { $row_data = $clean_data[$allocatable->id()]; } else { - $row_data = array(); + $row_data = []; } $allocatable = $this->get_allocatable_from_id($allocatable->id()); @@ -67,28 +87,28 @@ private function get_row($allocatable) { private function clean_data($raw_data) { // 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 = array(); +// $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. continue; } - $clean_data[$allocatable_id] = array(); + $clean_data[$allocatable_id] = []; foreach ($this->coursework->marking_stages() as $stage) { diff --git a/classes/allocation/table/row/builder.php b/classes/allocation/table/row/builder.php index 35db0429..0fa49e30 100644 --- a/classes/allocation/table/row/builder.php +++ b/classes/allocation/table/row/builder.php @@ -19,8 +19,7 @@ /** * Class file for the renderable object that makes a single row in the marker allocation table. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -120,7 +119,7 @@ public function get_student_firstname() { $allocatable = $this->get_allocatable(); if (empty($allocatable->firstname)) { - $this->allocatable = user::find($allocatable); + $this->allocatable = user::find($allocatable); } return $this->get_allocatable()->firstname; @@ -135,7 +134,7 @@ public function get_student_lastname() { $allocatable = $this->get_allocatable(); if (empty($allocatable->lastname)) { - $this->allocatable = user::find($allocatable); + $this->allocatable = user::find($allocatable); } return $this->get_allocatable()->lastname; @@ -149,13 +148,12 @@ public function get_idnumber() { $allocatable = $this->get_allocatable(); if (empty($allocatable->idnumber)) { - $this->allocatable = user::find($allocatable); + $this->allocatable = user::find($allocatable); } return $this->get_allocatable()->idnumber; } - /** * @return string */ @@ -165,11 +163,10 @@ public function get_email() { $allocatable = $this->get_allocatable(); if (empty($allocatable->email)) { - $this->allocatable = user::find($allocatable); + $this->allocatable = user::find($allocatable); } return $this->get_allocatable()->email; } - } diff --git a/classes/allocation/table/row/processor.php b/classes/allocation/table/row/processor.php index b50784a0..ef6ce9ec 100644 --- a/classes/allocation/table/row/processor.php +++ b/classes/allocation/table/row/processor.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\allocation\table\row; use mod_coursework\allocation\allocatable; @@ -47,5 +67,4 @@ public function process($data) { } } - -} \ No newline at end of file +} diff --git a/classes/allocation/upload.php b/classes/allocation/upload.php index d2b03c8e..3e73df61 100644 --- a/classes/allocation/upload.php +++ b/classes/allocation/upload.php @@ -19,15 +19,13 @@ use mod_coursework\models; /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2016 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); - /** * Class to manage assessor allocations upload */ @@ -46,7 +44,7 @@ public function __construct($coursework) { * @return array|bool * @throws \moodle_exception */ - public function validate_csv($content,$encoding,$delimeter){ + public function validate_csv($content, $encoding, $delimeter) { global $CFG, $DB; $assessor_identifier = $CFG->coursework_allocation_identifier; @@ -71,70 +69,69 @@ public function validate_csv($content,$encoding,$delimeter){ $csvreader->init(); - $errors = array(); + $errors = []; $s = 0; // find out if this is a group or individual coursework $allocatabletype = $this->coursework->get_allocatable_type(); // find all individual users or groups in this coursework $allocatables = $this->coursework->get_allocatables(); - $allocatables = ($allocatabletype == 'group')? array_keys($allocatables) : $allocatables; + $allocatables = ($allocatabletype == 'group') ? array_keys($allocatables) : $allocatables; // find all assessors for this coursework - $assessors = get_enrolled_users($this->coursework->get_context(), 'mod/coursework:addinitialgrade'); - $assessors = array_keys($assessors); // keep only assessors' ids - $allocatablesinfile = array(); + $assessors = get_enrolled_users($this->coursework->get_context(), 'mod/coursework:addinitialgrade'); + $assessors = array_keys($assessors); // keep only assessors' ids + $allocatablesinfile = []; $csv_cells = array('allocatable'); $stages = $this->coursework->get_max_markers(); - for ($i=1; $i<=$stages; $i++){ + for ($i = 1; $i <= $stages; $i++) { $csv_cells[] = 'assessor_'.$i; } while ($line = $csvreader->next()) { $cells = $csv_cells; - $assessorsinfile = array(); + $assessorsinfile = []; - if (sizeof($line) != sizeof($csv_cells)) {$errors = get_string('incorrectfileformat', 'coursework'); break;} + if (count($line) != count($csv_cells)) {$errors = get_string('incorrectfileformat', 'coursework'); break;} foreach ($line as $keynum => $value) { // validate allocatable (user or group) - if ($cells[$keynum] == 'allocatable') { + 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'){ + if ($allocatabletype == 'user') { // get user id - $suballocatable = $DB->get_record('user', array($assessor_identifier=>$value)); - $allocatable = ($suballocatable)? \mod_coursework\models\user::find($suballocatable->id): ''; + $suballocatable = $DB->get_record('user', array($assessor_identifier => $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)); - $allocatable = ($suballocatable)? \mod_coursework\models\group::find($suballocatable->id) : ''; + $suballocatable = $DB->get_record('groups', array('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; } - // validate assessor if exists in the coursework and has one of the capabilities allowing them to grade // in initial stage - if (substr($cells[$keynum],0,8) == 'assessor'){ + 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', array($assessor_identifier => $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 - if($assessor && ($this->coursework->assessor_has_allocation_for_student_not_in_current_stage($allocatable, $assessor->id, $cells[$keynum]) - || in_array($assessor->id, $assessorsinfile))){ + if ($assessor && ($this->coursework->assessor_has_allocation_for_student_not_in_current_stage($allocatable, $assessor->id, $cells[$keynum]) + || in_array($assessor->id, $assessorsinfile))) { $errors[$s] = get_string('assessoralreadyallocated', 'coursework', $keynum); continue; } $assessorsinfile[] = $assessor->id; @@ -144,10 +141,9 @@ public function validate_csv($content,$encoding,$delimeter){ $s++; } - return (!empty($errors)) ? $errors : false ; + return (!empty($errors)) ? $errors : false; } - /** * Process csv and add records to the DB * @@ -159,7 +155,7 @@ public function validate_csv($content,$encoding,$delimeter){ * @return array|bool * @throws \moodle_exception */ - public function process_csv($content, $encoding, $delimiter, $processingresults){ + public function process_csv($content, $encoding, $delimiter, $processingresults) { global $CFG, $DB, $PAGE; @@ -190,21 +186,21 @@ public function process_csv($content, $encoding, $delimiter, $processingresults) $s = 0; $csv_cells = array('allocatable'); $stages = $this->coursework->get_max_markers(); - for ($i=1; $i<=$stages; $i++){ + for ($i = 1; $i <= $stages; $i++) { $csv_cells[] = 'assessor_'.$i; } while ($line = $csvreader->next()) { - //we will not process the content of any line that has been flagged up with an error - if ( is_array($processingresults) && array_key_exists($s,$processingresults) ) { + // We will not process the content of any line that has been flagged up with an error + if ( is_array($processingresults) && array_key_exists($s, $processingresults) ) { $s++; continue; } $cells = $csv_cells; - if (sizeof($line) != sizeof($csv_cells)) {$errors = get_string('incorrectfileformat', 'coursework'); break;} + if (count($line) != count($csv_cells)) {$errors = get_string('incorrectfileformat', 'coursework'); break;} foreach ($line as $keynum => $value) { @@ -212,21 +208,21 @@ public function process_csv($content, $encoding, $delimiter, $processingresults) // or update it // get allocatable - if ($cells[$keynum] == 'allocatable') { - if ($allocatabletype == 'user'){ + if ($cells[$keynum] == 'allocatable') { + if ($allocatabletype == 'user') { // get user id - $suballocatable = $DB->get_record('user', array($assessor_identifier=>$value)); - $allocatable = ($suballocatable)? \mod_coursework\models\user::find($suballocatable->id): ''; + $suballocatable = $DB->get_record('user', array($assessor_identifier => $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)); - $allocatable = ($suballocatable)? \mod_coursework\models\group::find($suballocatable->id): ''; + $suballocatable = $DB->get_record('groups', array('courseid' => $this->coursework->course, + 'name' => $value)); + $allocatable = ($suballocatable) ? \mod_coursework\models\group::find($suballocatable->id) : ''; } } - if (substr($cells[$keynum],0,8) == 'assessor' && !(empty($value))){ + if (substr($cells[$keynum], 0, 8) == 'assessor' && !(empty($value))) { - $assessor = $DB->get_record('user', array($assessor_identifier=>$value)); + $assessor = $DB->get_record('user', array($assessor_identifier => $value)); $params = array('courseworkid' => $this->coursework->id, 'allocatableid' => $allocatable->id, @@ -235,15 +231,15 @@ public function process_csv($content, $encoding, $delimiter, $processingresults) $allocation = $DB->get_record('coursework_allocation_pairs', $params); - if(!$allocation){ + if (!$allocation) { // create allocation $this->add_allocation($assessor->id, $cells[$keynum], $allocatable); } else { // update allocation if submission was not marked yet - $subdbrecord = $DB->get_record('coursework_submissions', array('courseworkid'=>$this->coursework->id, - 'allocatabletype'=>$allocatabletype, - 'allocatableid'=>$allocatable->id)); + $subdbrecord = $DB->get_record('coursework_submissions', array('courseworkid' => $this->coursework->id, + 'allocatabletype' => $allocatabletype, + 'allocatableid' => $allocatable->id)); $submission = \mod_coursework\models\submission::find($subdbrecord); if (!$submission || !$submission->get_assessor_feedback_by_stage($cells[$keynum])) { @@ -257,11 +253,10 @@ public function process_csv($content, $encoding, $delimiter, $processingresults) $s++; } - return (!empty($errors)) ? $errors : false; + return (!empty($errors)) ? $errors : false; } - /** * Add allocation pair * @@ -271,17 +266,17 @@ 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, $stage_identifier, $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(); + $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(); $allocationid = $DB->insert_record('coursework_allocation_pairs', $add_allocation, true); @@ -289,7 +284,6 @@ public function add_allocation($assessorid, $stage_identifier, $allocatable){ } - /** * Update allocation pair * @@ -297,16 +291,16 @@ public function add_allocation($assessorid, $stage_identifier, $allocatable){ * @param $assessorid * @return bool */ - public function update_allocation($allocationid, $assessorid){ + public function update_allocation($allocationid, $assessorid) { global $DB; - $update_allocation = new \stdClass(); - $update_allocation->id = $allocationid; - $update_allocation->manual = 1; - $update_allocation->assessorid = $assessorid; + $update_allocation = new \stdClass(); + $update_allocation->id = $allocationid; + $update_allocation->manual = 1; + $update_allocation->assessorid = $assessorid; $update = $DB->update_record('coursework_allocation_pairs', $update_allocation); return $update; } -} \ No newline at end of file +} diff --git a/classes/allocation/widget.php b/classes/allocation/widget.php index 5e77b5eb..9b3d41a3 100644 --- a/classes/allocation/widget.php +++ b/classes/allocation/widget.php @@ -19,8 +19,7 @@ /** * Rendererable object to make the widget to choose allocation strategy. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -29,7 +28,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Just a placeholder for the renderer really. */ diff --git a/classes/assessor_feedback_row.php b/classes/assessor_feedback_row.php index 2d39a623..d24932d6 100644 --- a/classes/assessor_feedback_row.php +++ b/classes/assessor_feedback_row.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework; use mod_coursework\allocation\allocatable; @@ -24,7 +30,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Class that exists to tell the renderer to use a different function. This one will make the * feedback into a row in the assessor feedbacks table of the grading report. @@ -114,7 +119,7 @@ public function get_assessor() { * * @return user */ - public function get_graded_by(){ + public function get_graded_by() { return $this->get_feedback()->assessor(); } @@ -122,7 +127,7 @@ public function get_graded_by(){ * Gets the grader's name and link to the profile * @return string */ - public function get_graders_name(){ + public function get_graders_name() { return $this->get_graded_by()->profile_link(); } diff --git a/classes/assessor_feedback_table.php b/classes/assessor_feedback_table.php index b0fc867c..2676e3f3 100644 --- a/classes/assessor_feedback_table.php +++ b/classes/assessor_feedback_table.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework; use mod_coursework\allocation\allocatable; @@ -21,7 +27,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Renderable class to represent a table containing assessor feedbacks for a single student submission. * Used in the grading report for multiple assessor courseworks. @@ -73,7 +78,7 @@ public function get_renderable_feedback_rows() { // Makes a new result set every time, so we can modify this array without worrying about // messing up the cache. - $feedbackobjects = array(); + $feedbackobjects = []; foreach ($this->coursework->get_assessor_marking_stages() as $stage) { $renderable_row = new assessor_feedback_row($stage, $this->get_allocatable(), $this->coursework); $feedbackobjects[] = $renderable_row; diff --git a/classes/auto_grader/auto_grader.php b/classes/auto_grader/auto_grader.php index 08f2a843..0bfd7d62 100644 --- a/classes/auto_grader/auto_grader.php +++ b/classes/auto_grader/auto_grader.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\auto_grader; @@ -10,4 +30,4 @@ interface auto_grader { public function __construct($coursework, $allocatable); public function create_auto_grade_if_rules_match(); -} \ No newline at end of file +} diff --git a/classes/auto_grader/average_grade.php b/classes/auto_grader/average_grade.php index e74faaee..149f166b 100644 --- a/classes/auto_grader/average_grade.php +++ b/classes/auto_grader/average_grade.php @@ -1,5 +1,24 @@ . +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\auto_grader; @@ -34,7 +53,7 @@ class average_grade implements auto_grader { * @param coursework $coursework * @param allocatable $allocatable */ - public function __construct($coursework, $allocatable){ + public function __construct($coursework, $allocatable) { $this->coursework = $coursework; $this->roundingrule = $this->coursework->roundingrule; $this->allocatable = $allocatable; @@ -45,7 +64,7 @@ public function __construct($coursework, $allocatable){ * state of the initial assessor grades and make an automatic grade if they do. * */ - public function create_auto_grade_if_rules_match(){ + public function create_auto_grade_if_rules_match() { // bounce out if conditions are not right/ if (!$this->get_allocatable()->has_all_initial_feedbacks($this->get_coursework())) { @@ -55,8 +74,6 @@ public function create_auto_grade_if_rules_match(){ return; } - - if (!$this->get_allocatable()->has_agreed_feedback($this->get_coursework())) { $this->create_final_feedback(); } else { @@ -67,8 +84,6 @@ public function create_auto_grade_if_rules_match(){ } } - - // trigger events? } @@ -76,15 +91,14 @@ public function create_auto_grade_if_rules_match(){ /** * @return coursework */ - private function get_coursework() - { + private function get_coursework() { return $this->coursework; } /** * @return int */ - private function automatic_grade(){ + private function automatic_grade() { $grades = $this->grades_as_percentages(); @@ -94,25 +108,23 @@ private function automatic_grade(){ // round it according to the chosen rule switch ($this->roundingrule) { case 'mid': - $avggrade = round($avggrade); + $avggrade = round($avggrade); break; case 'up': - $avggrade = ceil($avggrade); + $avggrade = ceil($avggrade); break; case 'down': - $avggrade = floor($avggrade); + $avggrade = floor($avggrade); break; } - return $avggrade; } - /** * @return allocatable */ - private function get_allocatable(){ + private function get_allocatable() { return $this->allocatable; } @@ -128,11 +140,10 @@ private function create_final_feedback() { )); } - /** * */ - private function update_final_feedback($feedback){ + private function update_final_feedback($feedback) { global $DB; $updated_feedback = new \stdClass(); @@ -144,7 +155,6 @@ private function update_final_feedback($feedback){ } - /** * @return array */ @@ -156,4 +166,4 @@ private function grades_as_percentages() { $initial_feedbacks); return $grades; } -} \ No newline at end of file +} diff --git a/classes/auto_grader/none.php b/classes/auto_grader/none.php index 13383bd2..882353d2 100644 --- a/classes/auto_grader/none.php +++ b/classes/auto_grader/none.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\auto_grader; @@ -19,4 +39,4 @@ public function __construct($coursework, $allocatable) { public function create_auto_grade_if_rules_match() { } -} \ No newline at end of file +} diff --git a/classes/auto_grader/percentage_distance.php b/classes/auto_grader/percentage_distance.php index 055880d6..92575b51 100644 --- a/classes/auto_grader/percentage_distance.php +++ b/classes/auto_grader/percentage_distance.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\auto_grader; @@ -55,14 +75,13 @@ public function create_auto_grade_if_rules_match() { return; } - if ($this->grades_are_close_enough() ) { if (!$this->get_allocatable()->has_agreed_feedback($this->get_coursework())) { $this->create_final_feedback(); - } else { + } 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) { + if ($agreed_feedback->timecreated == $agreed_feedback->timemodified || $agreed_feedback->lasteditedbyuser == 0) { $this->update_final_feedback($agreed_feedback); } } @@ -119,7 +138,6 @@ private function create_final_feedback() { )); } - /** * */ @@ -135,8 +153,6 @@ private function update_final_feedback($feedback) { } - - /** * @return array */ @@ -148,4 +164,4 @@ private function grades_as_percentages() { $initial_feedbacks); return $grades; } -} \ No newline at end of file +} diff --git a/classes/controllers/allocations_controller.php b/classes/controllers/allocations_controller.php index 5966cb66..c89703e8 100644 --- a/classes/controllers/allocations_controller.php +++ b/classes/controllers/allocations_controller.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\controllers; @@ -8,6 +28,4 @@ */ class allocations_controller extends controller_base { - - -} \ No newline at end of file +} diff --git a/classes/controllers/controller_base.php b/classes/controllers/controller_base.php index 1cc48ef9..a5c4f745 100644 --- a/classes/controllers/controller_base.php +++ b/classes/controllers/controller_base.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\controllers; @@ -141,7 +161,6 @@ protected function prepare_environment() { } - /** * Single accessible method that look for a private method and uses it if its there, after preparing the environment. * @@ -252,4 +271,4 @@ protected function renderer_class() { $renderer_class_name = "\\mod_coursework\\renderers\\{$this->model_name()}_renderer"; return $renderer_class_name; } -} \ No newline at end of file +} diff --git a/classes/controllers/deadline_extensions_controller.php b/classes/controllers/deadline_extensions_controller.php index 7fbc230f..b9b397c5 100644 --- a/classes/controllers/deadline_extensions_controller.php +++ b/classes/controllers/deadline_extensions_controller.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\controllers; use mod_coursework\ability; @@ -136,8 +156,7 @@ protected function update_deadline_extension() { * Set the deadline to default current deadline if the extension was never given before * @return array */ - protected function set_default_current_deadline() - { + protected function set_default_current_deadline() { global $DB; $params = array( 'allocatableid' => $this->params['allocatableid'], @@ -147,8 +166,8 @@ protected function set_default_current_deadline() $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 ($this->coursework->personaldeadlineenabled) { + $personal_deadline = $DB->get_record('coursework_person_deadlines', $params); if ($personal_deadline) { $this->coursework->deadline = $personal_deadline->personal_deadline; } @@ -157,13 +176,10 @@ protected function set_default_current_deadline() return $params; } - - /** * Begin Ajax functions */ - public function ajax_submit_mitigation($data_params) - { + public function ajax_submit_mitigation($data_params) { global $USER, $OUTPUT; $extended_deadline = false; $response = []; @@ -204,18 +220,16 @@ public function ajax_submit_mitigation($data_params) } } - public function validation($data){ + public function validation($data) { global $CFG; $max_deadline = $CFG->coursework_max_extension_deadline; - if ($this->coursework->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()) { $deadline = $personal_deadline->personal_deadline; } else { $deadline = $this->coursework->deadline; } - if ( $data['extended_deadline'] <= $deadline) { return $errors = 'The new deadline must be later than the current deadline'; } @@ -223,7 +237,7 @@ public function validation($data){ return false; } - public function submission_exists($data){ + public function submission_exists($data) { global $DB; return $DB->record_exists('coursework_submissions', array( @@ -233,13 +247,13 @@ public function submission_exists($data){ )); } - public function personal_deadline(){ + public function personal_deadline() { global $DB; $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', array('id' => $extensionid)); $allocatableid = $ext->allocatableid; $allocatabletype = $ext->allocatabletype; $courseworkid = $ext->courseworkid; @@ -247,7 +261,7 @@ public function personal_deadline(){ $allocatableid = required_param('allocatableid', PARAM_INT); $allocatabletype = required_param('allocatabletype', PARAM_ALPHANUMEXT); - $courseworkid = required_param('courseworkid', PARAM_INT); + $courseworkid = required_param('courseworkid', PARAM_INT); } $params = array( @@ -286,18 +300,18 @@ public function ajax_edit_mitigation($data_params) { $time = date('d-m-Y H:i', $this->coursework->deadline); } - if(!empty($deadline_extension->extended_deadline) && $deadline_extension->extended_deadline > 0) { + if (!empty($deadline_extension->extended_deadline) && $deadline_extension->extended_deadline > 0) { $time = date('d-m-Y H:i', $deadline_extension->extended_deadline); } $deadline_extension_transform = [ 'time_content' => $time_content, - 'time' => $time, + 'time' => $time, 'text' => $deadline_extension->extra_information_text, 'allocatableid' => $deadline_extension->allocatableid, 'allocatabletype' => $deadline_extension->allocatabletype, 'courseworkid' => $deadline_extension->courseworkid, - 'id' => $deadline_extension->id, + 'id' => $deadline_extension->id, 'pre_defined_reason' => $deadline_extension->pre_defined_reason, ]; $response = [ @@ -314,7 +328,7 @@ public function ajax_edit_mitigation($data_params) { echo json_encode($response); } - public function ajax_new_mitigation($data_params){ + public function ajax_new_mitigation($data_params) { global $USER, $DB; $response = []; $this->coursework = coursework::find(['id' => $this->params['courseworkid']]); @@ -327,12 +341,12 @@ public function ajax_new_mitigation($data_params){ ); $ability = new ability(user::find($USER), $this->coursework); - $deadline_extension= deadline_extension::build($params); + $deadline_extension = deadline_extension::build($params); $ability->require_can('new', $deadline_extension); $time_content = ''; $time = ''; - if ($this->coursework->deadline){ - $personal_deadline = $DB->get_record('coursework_person_deadlines', $params); + 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); // $this->coursework->deadline = $personal_deadline->personal_deadline; @@ -345,7 +359,7 @@ public function ajax_new_mitigation($data_params){ $deadline_extension_transform = [ 'time_content' => $time_content, - 'time' => $time, + 'time' => $time, ]; $response = [ @@ -356,7 +370,6 @@ public function ajax_new_mitigation($data_params){ echo json_encode($response); } - /** * function table_cell_response * @param array $data_params @@ -375,12 +388,11 @@ public function table_cell_response($data_params) { $row_object = 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)); + $time_submitted_cell = new \mod_coursework\render_helpers\grading_report\cells\time_submitted_cell(array('coursework' => $this->coursework)); $content = $time_submitted_cell->prepare_content_cell($row_object); return $content; } - -} \ No newline at end of file +} diff --git a/classes/controllers/feedback_controller.php b/classes/controllers/feedback_controller.php index 54cd5048..9263496a 100644 --- a/classes/controllers/feedback_controller.php +++ b/classes/controllers/feedback_controller.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\controllers; @@ -50,7 +70,7 @@ protected function show_feedback() { $urlparams = array('feedbackid' => $this->params['feedbackid']); $PAGE->set_url('/mod/coursework/actions/feedbacks/show.php', $urlparams); - $ajax = (isset($this->params['ajax'])) ? $this->params['ajax'] : 0; + $ajax = (isset($this->params['ajax'])) ? $this->params['ajax'] : 0; $teacherfeedback = new feedback($this->params['feedbackid']); @@ -58,11 +78,9 @@ protected function show_feedback() { $ability->require_can('show', $teacherfeedback); $renderer = $this->get_page_renderer(); - $html = $renderer->show_feedback_page($teacherfeedback,$ajax); - - + $html = $renderer->show_feedback_page($teacherfeedback, $ajax); - if (empty($ajax)) { + if (empty($ajax)) { echo $html; } else { echo json_encode(['success' => true, 'formhtml' => $html]); @@ -99,7 +117,7 @@ protected function new_feedback() { $this->check_stage_permissions($this->params['stage_identifier']); - $urlparams = array(); + $urlparams = []; $urlparams['submissionid'] = $teacherfeedback->submissionid; $urlparams['assessorid'] = $teacherfeedback->assessorid; $urlparams['isfinalgrade'] = $teacherfeedback->isfinalgrade; @@ -121,7 +139,6 @@ protected function edit_feedback() { global $DB, $PAGE, $USER; - $teacherfeedback = new feedback($this->params['feedbackid']); $this->check_stage_permissions($teacherfeedback->stage_identifier); @@ -205,18 +222,16 @@ protected function create_feedback() { $form->save_feedback_files($teacherfeedback); - if ($submission->is_published()) { // Keep the gradebook updated $this->coursework->grade_changed_event(); $submission->publish(); } - - //only implement auto feedback (automatic agreement) if the settings is set to disabled otherwise - //we will do this in the cron - //only implement auto feedback (automatic agreement) if the settings is set to disabled otherwise - //we will do this in the cron - $gradeeditingtime = $teacherfeedback->get_coursework()->get_grade_editing_time(); + // Only implement auto feedback (automatic agreement) if the settings is set to disabled otherwise + // We will do this in the cron + // Only implement auto feedback (automatic agreement) if the settings is set to disabled otherwise + // We will do this in the cron + $gradeeditingtime = $teacherfeedback->get_coursework()->get_grade_editing_time(); if (empty($gradeeditingtime) || time() > $teacherfeedback->timecreated + $gradeeditingtime) { $this->try_auto_feedback_creation($teacherfeedback->get_submission()); @@ -231,47 +246,46 @@ protected function create_feedback() { $participant = $submission->get_allocatable(); $cell_class = $this->params['cell_type']; $stage = new assessor($coursework, $teacherfeedback->stage_identifier); - $provisional = new grade_for_gradebook_cell(array('coursework'=>$coursework)); + $provisional = new grade_for_gradebook_cell(array('coursework' => $coursework)); - $jsonarray = array('success' => true); + $jsonarray = array('success' => true); if (strpos($cell_class, 'multi_marker_feedback_sub_rows') !== false) { $feedback_row = new assessor_feedback_row($stage, $participant, $this->coursework); $cell_object = new $cell_class($coursework, $participant); $html = $cell_object->get_grade_cell_content($feedback_row, $this->coursework); - if ($teacherfeedback->stage_identifier == 'assessor_1' || $teacherfeedback->stage_identifier == 'assessor_2') { + if ($teacherfeedback->stage_identifier == 'assessor_1' || $teacherfeedback->stage_identifier == 'assessor_2') { - $jsonarray['assessorname'] = (empty($feedback_row->get_assessor()->id()) && $coursework->allocation_enabled()) ? - get_string('assessornotallocated','mod_coursework') : $cell_object->profile_link($feedback_row); - $jsonarray['assessdate'] = $cell_object->date_for_column($feedback_row); + $jsonarray['assessorname'] = (empty($feedback_row->get_assessor()->id()) && $coursework->allocation_enabled()) ? + get_string('assessornotallocated', 'mod_coursework') : $cell_object->profile_link($feedback_row); + $jsonarray['assessdate'] = $cell_object->date_for_column($feedback_row); - if ($teacherfeedback->stage_identifier == 'assessor_1') { + if ($teacherfeedback->stage_identifier == 'assessor_1') { $ability = new ability(user::find($USER, false), $coursework); $stage = new assessor($coursework, 'assessor_2'); - $assessor_feedback_row = new assessor_feedback_row($stage, $feedback_row->get_allocatable(), $coursework); + $assessor_feedback_row = new assessor_feedback_row($stage, $feedback_row->get_allocatable(), $coursework); - $assessortwocell = $cell_object->get_grade_cell_content($assessor_feedback_row,$coursework,$ability); - //$jsonarray['assessortwo'] =$assessortwocell; - if (strpos($assessortwocell, 'new_feedback') !== false) $jsonarray['assessortwo'] = $assessortwocell; + $assessortwocell = $cell_object->get_grade_cell_content($assessor_feedback_row, $coursework, $ability); + //$jsonarray['assessortwo'] =$assessortwocell; + if (strpos($assessortwocell, 'new_feedback') !== false) $jsonarray['assessortwo'] = $assessortwocell; } - $finalfeedback = $feedback_row->get_submission()->get_final_feedback(); + $finalfeedback = $feedback_row->get_submission()->get_final_feedback(); $finalsubmission = $feedback_row->get_submission(); - - if ($coursework->automaticagreementrange != 'none' && !empty($finalfeedback) && $finalsubmission->all_inital_graded()) { + if ($coursework->automaticagreementrange != 'none' && !empty($finalfeedback) && $finalsubmission->all_inital_graded()) { $finalstage = new assessor($coursework, "final_agreed_1"); $finalfeedback_row = new assessor_feedback_row($finalstage, $participant, $coursework); - $agreed_grade_object = new multiple_agreed_grade_cell(array('coursework'=>$coursework,'stage'=>$finalstage)); + $agreed_grade_object = new multiple_agreed_grade_cell(array('coursework' => $coursework, 'stage' => $finalstage)); $jsonarray['finalhtml'] = $agreed_grade_object->get_table_cell($finalfeedback_row); - $jsonarray['allocatableid'] = $submission->get_allocatable()->id(); + $jsonarray['allocatableid'] = $submission->get_allocatable()->id(); } - } else { + } else { - $jsonarray['extrahtml'] = $provisional->get_table_cell($feedback_row); + $jsonarray['extrahtml'] = $provisional->get_table_cell($feedback_row); } @@ -281,15 +295,11 @@ protected function create_feedback() { $row_object = new $row_class($coursework, $participant); $cell_object = new $cell_class(['coursework' => $coursework, 'stage' => $stage]); $html = $cell_object->get_content($row_object); - $jsonarray['extrahtml'] = $provisional->get_table_cell($row_object); - - - - + $jsonarray['extrahtml'] = $provisional->get_table_cell($row_object); } - $jsonarray['html'] = $html; + $jsonarray['html'] = $html; echo json_encode($jsonarray); } else { @@ -304,7 +314,6 @@ protected function create_feedback() { } } - } /** @@ -312,7 +321,7 @@ protected function create_feedback() { */ protected function update_feedback() { - global $USER, $CFG; + global $USER, $PAGE; $teacherfeedback = new feedback($this->params['feedbackid']); $teacherfeedback->lasteditedbyuser = $USER->id; @@ -323,11 +332,11 @@ protected function update_feedback() { $coursework_page_url = $this->get_path('coursework', array('coursework' => $teacherfeedback->get_coursework())); // remove feedback comments and associated feedback files if 'Remove feedback' button pressed - if($this->params['remove']){ + if ($this->params['remove']) { if (!$this->params['confirm']) { - $urlparams = array('confirm'=>$this->params['confirm'], - 'remove'=>$this->params['remove'],'feedbackid'=>$this->params['feedbackid'],'finalised'=>$this->params['finalised']); + $urlparams = array('confirm' => $this->params['confirm'], + 'remove' => $this->params['remove'], 'feedbackid' => $this->params['feedbackid'], 'finalised' => $this->params['finalised']); $PAGE->set_url('/mod/coursework/actions/feedbacks/edit.php', $urlparams); @@ -335,25 +344,24 @@ protected function update_feedback() { $confirmurl = new \moodle_url('/mod/coursework/actions/feedbacks/update.php'); $confirmurl->param('confirm', 1); $confirmurl->param('removefeedbackbutton', 1); - $confirmurl->param('feedbackid',$this->params['feedbackid']); - $confirmurl->param('finalised',$this->params['finalised']); + $confirmurl->param('feedbackid', $this->params['feedbackid']); + $confirmurl->param('finalised', $this->params['finalised']); $cancelurl = clone $PAGE->url; $cancelurl->param('removefeedbackbutton', 0); - $cancelurl->param('feedbackid',$this->params['feedbackid']); - $cancelurl->param('finalised',$this->params['finalised']); + $cancelurl->param('feedbackid', $this->params['feedbackid']); + $cancelurl->param('finalised', $this->params['finalised']); $renderer = $this->get_page_renderer(); - return $renderer->confirm_feedback_removal_page($teacherfeedback,$confirmurl,$cancelurl); + return $renderer->confirm_feedback_removal_page($teacherfeedback, $confirmurl, $cancelurl); //$OUTPUT->confirm(get_string('confirmremovefeedback', 'mod_coursework'), $confirmurl, $PAGE->url); } else { $teacherfeedback->destroy(); - //remove associated files + // Remove associated files $fs = get_file_storage(); $fs->delete_area_files($teacherfeedback->get_coursework()->get_context()->id, 'mod_coursework', 'feedback', $teacherfeedback->id()); - $ajax = !empty($this->params['ajax']); if ($ajax) { @@ -378,7 +386,7 @@ protected function update_feedback() { $cell_object = new $cell_class(['coursework' => $coursework, 'stage' => $stage]); $html = $cell_object->get_content($row_object); - $finalfeedback = $row_object->get_submission()->get_final_feedback(); + $finalfeedback = $row_object->get_submission()->get_final_feedback(); } @@ -404,8 +412,6 @@ protected function update_feedback() { $teacherfeedback->save(); $form->save_feedback_files($teacherfeedback); - - if (empty($gradeeditingtime) || time() > $teacherfeedback->timecreated + $gradeeditingtime) { $this->try_auto_feedback_creation($teacherfeedback->get_submission()); } @@ -427,44 +433,44 @@ protected function update_feedback() { $participant = $submission->get_allocatable(); $cell_class = $this->params['cell_type']; $stage = new assessor($coursework, $teacherfeedback->stage_identifier); - $provisional = new grade_for_gradebook_cell(array('coursework'=>$coursework)); - $jsonarray = array('success' => true); + $provisional = new grade_for_gradebook_cell(array('coursework' => $coursework)); + $jsonarray = array('success' => true); if (strpos($cell_class, 'multi_marker_feedback_sub_rows') !== false) { $feedback_row = new assessor_feedback_row($stage, $participant, $coursework); $cell_object = new $cell_class($coursework, $participant); $html = $cell_object->get_grade_cell_content($feedback_row, $coursework); - if ($teacherfeedback->stage_identifier == 'assessor_1' || $teacherfeedback->stage_identifier == 'assessor_2') { - $jsonarray['assessorname'] = (empty($feedback_row->get_assessor()->id()) && $coursework->allocation_enabled()) ? - get_string('assessornotallocated','mod_coursework') : $cell_object->profile_link($feedback_row); - $jsonarray['assessdate'] = $cell_object->date_for_column($feedback_row); + if ($teacherfeedback->stage_identifier == 'assessor_1' || $teacherfeedback->stage_identifier == 'assessor_2') { + $jsonarray['assessorname'] = (empty($feedback_row->get_assessor()->id()) && $coursework->allocation_enabled()) ? + get_string('assessornotallocated', 'mod_coursework') : $cell_object->profile_link($feedback_row); + $jsonarray['assessdate'] = $cell_object->date_for_column($feedback_row); - if ($teacherfeedback->stage_identifier == 'assessor_1') { + if ($teacherfeedback->stage_identifier == 'assessor_1') { $ability = new ability(user::find($USER, false), $coursework); $stage = new assessor($coursework, 'assessor_2'); - $assessor_feedback_row = new assessor_feedback_row($stage, $feedback_row->get_allocatable(), $coursework); + $assessor_feedback_row = new assessor_feedback_row($stage, $feedback_row->get_allocatable(), $coursework); - $assessortwocell = $cell_object->get_grade_cell_content($assessor_feedback_row,$coursework,$ability); - //$jsonarray['assessortwo'] =$assessortwocell; - if (strpos($assessortwocell, 'new_feedback') !== false) $jsonarray['assessortwo'] = $assessortwocell; + $assessortwocell = $cell_object->get_grade_cell_content($assessor_feedback_row, $coursework, $ability); + //$jsonarray['assessortwo'] =$assessortwocell; + if (strpos($assessortwocell, 'new_feedback') !== false) $jsonarray['assessortwo'] = $assessortwocell; } - $finalfeedback = $submission->get_final_feedback(); + $finalfeedback = $submission->get_final_feedback(); - if ($coursework->automaticagreementrange != 'none' && !empty($finalfeedback)) { + if ($coursework->automaticagreementrange != 'none' && !empty($finalfeedback)) { $finalstage = new assessor($coursework, "final_agreed_1"); $finalfeedbackrow_object = new \mod_coursework\grading_table_row_multi($coursework, $participant); $agreed_grade_cell = new multiple_agreed_grade_cell(['coursework' => $coursework, 'stage' => $finalstage]); $jsonarray['finalhtml'] = $agreed_grade_cell->get_content($finalfeedbackrow_object); - $jsonarray['allocatableid'] = $submission->get_allocatable()->id(); + $jsonarray['allocatableid'] = $submission->get_allocatable()->id(); } - } else { - $jsonarray['extrahtml'] = strip_tags($provisional->get_table_cell($feedback_row)); + } else { + $jsonarray['extrahtml'] = strip_tags($provisional->get_table_cell($feedback_row)); } } else { @@ -473,10 +479,10 @@ protected function update_feedback() { $row_object = new $row_class($coursework, $participant); $cell_object = new $cell_class(['coursework' => $coursework, 'stage' => $stage]); $html = $cell_object->get_content($row_object); - $jsonarray['extrahtml'] = strip_tags($provisional->get_table_cell($row_object)); + $jsonarray['extrahtml'] = strip_tags($provisional->get_table_cell($row_object)); } - $jsonarray['html'] = $html; + $jsonarray['html'] = $html; echo json_encode($jsonarray); } else { @@ -529,7 +535,7 @@ protected function check_stage_permissions($identifier) { $stage = $this->coursework->get_stage($identifier); if (!$stage->user_is_assessor($USER)) { if (!(has_capability('mod/coursework:administergrades', $this->coursework->get_context()) || - has_capability('mod/coursework:addallocatedagreedgrade', $this->coursework->get_context())) ){ + has_capability('mod/coursework:addallocatedagreedgrade', $this->coursework->get_context())) ) { throw new access_denied($this->coursework, 'You are not authorised to add feedback at this stage'); } } diff --git a/classes/controllers/grading_controller.php b/classes/controllers/grading_controller.php index 1881ce17..a7a57aab 100644 --- a/classes/controllers/grading_controller.php +++ b/classes/controllers/grading_controller.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\controllers; @@ -30,4 +50,4 @@ public function get_remain_rows_grading_table($options) { return $table_html; } -} \ No newline at end of file +} diff --git a/classes/controllers/moderations_controller.php b/classes/controllers/moderations_controller.php index 445c9383..d80c822c 100644 --- a/classes/controllers/moderations_controller.php +++ b/classes/controllers/moderations_controller.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\controllers; @@ -33,7 +53,6 @@ class moderations_controller extends controller_base { */ protected $moderation; - /** * This deals with the page that the assessors see when they want to add component feedbacks. * @@ -50,13 +69,12 @@ protected function new_moderation() { $moderator_agreement->courseworkid = $this->params['courseworkid']; $moderator_agreement->feedbackid = $this->params['feedbackid']; - $ability = new ability(user::find($USER), $this->coursework); $ability->require_can('new', $moderator_agreement); $this->check_stage_permissions($this->params['stage_identifier']); - $urlparams = array(); + $urlparams = []; $urlparams['submissionid'] = $moderator_agreement->submissionid; $urlparams['moderatorid'] = $moderator_agreement->moderatorid; $urlparams['stage_identifier'] = $moderator_agreement->stage_identifier; @@ -77,7 +95,6 @@ protected function edit_moderation() { global $DB, $PAGE, $USER; - $moderation = new moderation($this->params['moderationid']); $this->check_stage_permissions($moderation->stage_identifier); @@ -123,7 +140,6 @@ protected function create_moderation() { $url = $this->get_router()->get_path('new moderation', $path_params, true); $PAGE->set_url($url); - $ability = new ability(user::find($USER), $this->coursework); $ability->require_can('new', $moderatoragreement); @@ -196,7 +212,6 @@ protected function show_moderation() { $renderer->show_moderation_page($moderation); } - /** * Get any feedback-specific stuff. */ @@ -242,9 +257,9 @@ protected function check_stage_permissions($identifier) { $stage = $this->coursework->get_stage($identifier); if (!$stage->user_is_moderator($USER)) { - if (!(has_capability('mod/coursework:moderate', $this->coursework->get_context()) ) ){ + if (!(has_capability('mod/coursework:moderate', $this->coursework->get_context()) ) ) { throw new access_denied($this->coursework, 'You are not authorised to moderte this feedback'); } } } -} \ No newline at end of file +} diff --git a/classes/controllers/personal_deadlines_controller.php b/classes/controllers/personal_deadlines_controller.php index 160e05fe..ddcc6cb3 100644 --- a/classes/controllers/personal_deadlines_controller.php +++ b/classes/controllers/personal_deadlines_controller.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\controllers; use mod_coursework\ability; @@ -17,41 +37,32 @@ * @property personal_deadline_form form * @package mod_coursework\controllers */ -class personal_deadlines_controller extends controller_base{ - - - +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)); - $params = $this->set_default_current_deadline(); - $ability = new ability(user::find($USER), $this->coursework); $ability->require_can('edit', $this->personal_deadline); - $params['allocatableid'] = (!is_array($params['allocatableid'])) ? $params['allocatableid'] - : serialize($params['allocatableid']) ; + $params['allocatableid'] = (!is_array($params['allocatableid'])) + ? $params['allocatableid'] + : serialize($params['allocatableid']); $PAGE->set_url('/mod/coursework/actions/personal_deadline/new.php', $params); $create_url = $this->get_router()->get_path('edit personal deadline'); $this->form = new personal_deadline_form($create_url, array('coursework' => $this->coursework)); - $this->personal_deadline->setpersonaldeadlinespage = $this->params['setpersonaldeadlinespage']; - $this->personal_deadline->multipleuserdeadlines = $this->params['multipleuserdeadlines']; - - $this->personal_deadline->allocatableid = $params['allocatableid']; + $this->personal_deadline->setpersonaldeadlinespage = $this->params['setpersonaldeadlinespage']; + $this->personal_deadline->multipleuserdeadlines = $this->params['multipleuserdeadlines']; + $this->personal_deadline->allocatableid = $params['allocatableid']; $this->form->set_data($this->personal_deadline); - - if ($this->cancel_button_was_pressed()) { redirect($coursework_page_url); } @@ -59,7 +70,7 @@ protected function new_personal_deadline() { $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; @@ -74,13 +85,12 @@ protected function new_personal_deadline() { } } else { + $allocatables = unserialize($data->allocatableid); - $allocatables = unserialize($data->allocatableid); - - foreach($allocatables as $allocatableid) { - $data->allocatableid = $allocatableid; - $data->id = ''; - //$data->id = ''; + foreach ($allocatables as $allocatableid) { + $data->allocatableid = $allocatableid; + $data->id = ''; + //$data->id = ''; $findparams = array( 'allocatableid' => $allocatableid, 'allocatabletype' => $data->allocatabletype, @@ -94,10 +104,9 @@ protected function new_personal_deadline() { $this->personal_deadline = personal_deadline::build($data); $this->personal_deadline->save(); - } else { // update - $data->id = $this->personal_deadline->id; + $data->id = $this->personal_deadline->id; $data->lastmodifiedbyid = $USER->id; $data->timemodified = time(); $this->personal_deadline->update_attributes($data); @@ -105,8 +114,6 @@ protected function new_personal_deadline() { } - - } redirect($coursework_page_url); } @@ -115,27 +122,26 @@ protected function new_personal_deadline() { } - /** * Set the deadline to default coursework deadline if the personal deadline was never given before * @return array */ - protected function set_default_current_deadline() { + protected function set_default_current_deadline() { $params = array( '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 - $params['allocatableid'] = (is_array($this->params['allocatableid'])) ? current($this->params['allocatableid']) : $this->params['allocatableid'] ; + // 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 + $params['allocatableid'] = (is_array($this->params['allocatableid'])) ? current($this->params['allocatableid']) : $this->params['allocatableid']; $this->personal_deadline = personal_deadline::find_or_build($params); - $params['allocatableid'] = $this->params['allocatableid']; + $params['allocatableid'] = $this->params['allocatableid']; - //if the allocatableid is an array then the current page will probably be setting multiple the personal deadlines + // 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; @@ -146,10 +152,10 @@ protected function set_default_current_deadline() { } /** - * Get the personal deadline + * Get the personal deadline * @return mixed */ - protected function get_personal_deadline(){ + protected function get_personal_deadline() { global $DB; $params = array( 'allocatableid' => $this->params['allocatableid'], @@ -168,7 +174,7 @@ protected function get_personal_deadline(){ * @throws \moodle_exception * @throws \require_login_exception */ - public function insert_update($time){ + public function insert_update($time) { global $USER; if (!$this->validated($time)) { return [ @@ -176,14 +182,15 @@ public function insert_update($time){ 'message' => 'The new deadline you chose has already passed. Please select appropriate deadline' ]; } - $this->coursework = coursework::find(['id'=>$this->params['courseworkid']]); + $this->coursework = coursework::find(['id' => $this->params['courseworkid']]); require_login($this->coursework->course); $params = $this->set_default_current_deadline(); $ability = new ability(user::find($USER), $this->coursework); $ability->require_can('edit', $this->personal_deadline); - $params['allocatableid'] = (!is_array($params['allocatableid'])) ? $params['allocatableid'] - : serialize($params['allocatableid']) ; + $params['allocatableid'] = (!is_array($params['allocatableid'])) + ? $params['allocatableid'] + : serialize($params['allocatableid']); $data = (object) $this->params; if (empty($data->multipleuserdeadlines)) { @@ -201,12 +208,12 @@ public function insert_update($time){ $this->personal_deadline->update_attributes($data); } } else { - $allocatables = unserialize($data->allocatableid); + $allocatables = unserialize($data->allocatableid); - foreach ($allocatables as $allocatableid) { - $data->allocatableid = $allocatableid; - $data->id = ''; - //$data->id = ''; + foreach ($allocatables as $allocatableid) { + $data->allocatableid = $allocatableid; + $data->id = ''; + //$data->id = ''; $findparams = array( 'allocatableid' => $allocatableid, 'allocatabletype' => $data->allocatabletype, @@ -221,7 +228,7 @@ public function insert_update($time){ $this->personal_deadline->save(); } else { // update - $data->id = $this->personal_deadline->id; + $data->id = $this->personal_deadline->id; $data->lastmodifiedbyid = $USER->id; $data->timemodified = time(); $this->personal_deadline->update_attributes($data); @@ -242,10 +249,9 @@ public function insert_update($time){ * @return bool */ protected function validated($time) { - if(strtotime($time) <= time()) { + if (strtotime($time) <= time()) { return false; } return true; } } - diff --git a/classes/controllers/plagiarism_flagging_controller.php b/classes/controllers/plagiarism_flagging_controller.php index 6db924eb..30e2bf50 100644 --- a/classes/controllers/plagiarism_flagging_controller.php +++ b/classes/controllers/plagiarism_flagging_controller.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\controllers; @@ -33,7 +53,6 @@ class plagiarism_flagging_controller extends controller_base { */ protected $plagiarism_flag; - /** * This deals with the page that the assessors see when they want to add component feedbacks. * @@ -45,14 +64,12 @@ protected function new_plagiarism_flag() { $plagiarismflag = new plagiarism_flag(); $plagiarismflag->submissionid = $this->params['submissionid']; - $plagiarismflag->courseworkid = $this->coursework->id; - + $plagiarismflag->courseworkid = $this->coursework->id; $ability = new ability(user::find($USER), $this->coursework); $ability->require_can('new', $plagiarismflag); - - $urlparams = array(); + $urlparams = []; $urlparams['submissionid'] = $plagiarismflag->submissionid; $PAGE->set_url('/mod/coursework/actions/moderations/new.php', $urlparams); @@ -90,7 +107,6 @@ protected function edit_plagiarism_flag() { $renderer->edit_plagiarism_flag_page($plagiarism_flag, $creator, $editor); } - /** * Saves the new plagiarism flag for the first time. */ @@ -99,7 +115,7 @@ protected function create_plagiarism_flag() { global $USER, $PAGE; $plagiarismflag = new plagiarism_flag(); - $plagiarismflag->courseworkid = $this->coursework->id(); + $plagiarismflag->courseworkid = $this->coursework->id(); $plagiarismflag->submissionid = $this->params['submissionid']; $plagiarismflag->createdby = $USER->id; @@ -131,7 +147,6 @@ protected function create_plagiarism_flag() { } } - /** * Updates plagiarism flag */ @@ -156,15 +171,15 @@ protected function update_plagiarism_flag() { $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 + $oldstatus = $DB->get_field(plagiarism_flag::get_table_name(), 'status', array('id' => $flagid)); // Retrieve old status before saving new $params = array( 'context' => \context_module::instance($this->coursework->get_course_module()->id), 'courseid' => $this->coursework->get_course()->id, 'objectid' => $this->coursework->id, 'other' => array( - 'courseworkid' => $this->coursework->id, - 'submissionid' => $plagiarismflag->submissionid, - 'flagid' => $flagid, + 'courseworkid' => $this->coursework->id, + 'submissionid' => $plagiarismflag->submissionid, + 'flagid' => $flagid, 'oldstatus' => $oldstatus, 'newstatus' => $plagiarismflag->status ) @@ -178,8 +193,6 @@ protected function update_plagiarism_flag() { redirect($coursework_page_url); } - - /** * Get any plagiarism flag-specific stuff. */ @@ -215,4 +228,4 @@ protected function prepare_environment() { parent::prepare_environment(); } -} \ No newline at end of file +} diff --git a/classes/controllers/submissions_controller.php b/classes/controllers/submissions_controller.php index 14e44b2c..467111d8 100644 --- a/classes/controllers/submissions_controller.php +++ b/classes/controllers/submissions_controller.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\controllers; @@ -60,7 +80,7 @@ protected function new_submission() { 'submission' => $submission )); if ($submit_form->is_submitted()) { - $validation = $submit_form->validate_defined_fields(); + $validation = $submit_form->validate_defined_fields(); } if ($validation != true) { $this->get_page_renderer()->new_submission_page($submit_form, $submission); @@ -82,7 +102,7 @@ protected function create_submission() { $validated = $this->new_submission(); - if ($validated == true){ + if ($validated == true) { return; } @@ -93,17 +113,16 @@ protected function create_submission() { $submission->createdby = $USER->id; $submission->lastupdatedby = $USER->id; $submission->allocatabletype = $this->params['allocatabletype']; - $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->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 - if($this->coursework->personal_deadlines_enabled()){ + 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; } - } elseif($this->coursework->deadline_has_passed() && !$this->has_valid_extension($submission)){ + } else if ($this->coursework->deadline_has_passed() && !$this->has_valid_extension($submission)) { $submission->finalised = 1; } @@ -113,7 +132,7 @@ protected function create_submission() { if (!$ability->can('create', $submission)) { // if submission already exists, redirect user to cw instead of throwing an error - if ($this->submissions_exists($submission)){ + if ($this->submissions_exists($submission)) { redirect($CFG->wwwroot.'/mod/coursework/view.php?id='.$this->coursemodule->id, $ability->get_last_message()); } else { throw new access_denied($this->coursework, $ability->get_last_message()); @@ -142,7 +161,7 @@ protected function create_submission() { $submission->submit_plagiarism(); $mailer = new mailer($this->coursework); - if ($CFG->coursework_allsubmissionreceipt || $submission->finalised) { + if ($CFG->coursework_allsubmissionreceipt || $submission->finalised) { foreach ($submission->get_students() as $student) { $mailer->send_submission_receipt($student, $submission->finalised); } @@ -151,18 +170,16 @@ protected function create_submission() { if ($submission->finalised) { if (!$submission->get_coursework()->has_deadline()) { - $userids = explode(',',$submission->get_coursework()->get_submission_notification_users()); + $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))); + foreach ($userids as $u) { + $notifyuser = $DB->get_record('user', array('id' => trim($u))); if (!empty($notifyuser)) $mailer->send_submission_notification($notifyuser); } } - - } } @@ -199,7 +216,7 @@ protected function edit_submission() { 'submission' => $submission )); if ($submit_form->is_submitted()) { - $validation = $submit_form->validate_defined_fields(); + $validation = $submit_form->validate_defined_fields(); } $submit_form->set_data($submission); @@ -210,7 +227,6 @@ protected function edit_submission() { } } - /** * */ @@ -223,9 +239,9 @@ protected function update_submission() { redirect($coursework_page_url); } - $validated = $this->edit_submission(); + $validated = $this->edit_submission(); - if ($validated == true){ + if ($validated == true) { return; } @@ -263,7 +279,6 @@ protected function update_submission() { $event = assessable_submitted::create($params); $event->trigger(); - $submission->submit_plagiarism(); if ($CFG->coursework_allsubmissionreceipt || $notify_about_finalisation) { @@ -308,45 +323,40 @@ protected function finalise_submission() { redirect($coursework_page_url); } - - protected function unfinalise_submission() { + 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'])) ? array($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'])); + array('id' => $this->coursework->get_coursemodule_id(), 'multipleuserdeadlines' => 1, 'setpersonaldeadlinespage' => 1, + 'courseworkid' => $this->params['courseworkid'], 'allocatabletype' => $this->params['allocatabletype'])); - $changedeadlines = false; + $changedeadlines = false; - foreach($allocatableids as $aid) { + 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); - + if ($submission->can_be_unfinalised()) { $submission->finalised = 0; $submission->save(); - $personaldeadline_page_url->param("allocatableid_arr[$aid]",$aid); - $changedeadlines = true; + $personaldeadline_page_url->param("allocatableid_arr[$aid]", $aid); + $changedeadlines = true; } } } - - if (!empty($changedeadlines)) { redirect($personaldeadline_page_url, 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())); + array('id' => $this->coursework->get_coursemodule_id())); redirect($setpersonaldeadline_page_url); } @@ -389,7 +399,7 @@ protected function check_coursework_is_open($coursework) { */ private function exception_if_late($submission) { $could_have_submitted = has_capability('mod/coursework:submit', $this->coursework->get_context()); - if ($this->coursework->personal_deadlines_enabled()){ + if ($this->coursework->personal_deadlines_enabled()) { $deadline_has_passed = !$this->has_valid_personal_deadline($submission); } else { $deadline_has_passed = $this->coursework->deadline_has_passed(); @@ -404,7 +414,7 @@ private function exception_if_late($submission) { * param submission $submission * return bool true if a matching record exists, else false */ - protected function submissions_exists($submission){ + protected function submissions_exists($submission) { global $DB; $sub_exists = $DB->record_exists('coursework_submissions', @@ -415,12 +425,11 @@ protected function submissions_exists($submission){ return $sub_exists; } - /** * @param $submission * @return bool */ - protected function has_valid_extension($submission){ + protected function has_valid_extension($submission) { global $DB; $valid_extension = false; @@ -442,7 +451,7 @@ protected function has_valid_extension($submission){ * @param $submission * @return bool */ - protected function has_valid_personal_deadline($submission){ + protected function has_valid_personal_deadline($submission) { global $DB; $valid_personal_deadline = false; @@ -459,4 +468,4 @@ protected function has_valid_personal_deadline($submission){ } return $valid_personal_deadline; } -} \ No newline at end of file +} diff --git a/classes/cron.php b/classes/cron.php index 7cb41590..57a7f363 100644 --- a/classes/cron.php +++ b/classes/cron.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework; use context; @@ -54,7 +74,7 @@ private static function send_reminders_to_students() { 'users' => 0 ); - $userswhoneedreminding = array(); + $userswhoneedreminding = []; $raw_courseworks = $DB->get_records('coursework'); foreach ($raw_courseworks as $raw_coursework) { @@ -72,24 +92,22 @@ private static function send_reminders_to_students() { continue; } - $students = $coursework->get_students_who_have_not_yet_submitted(); foreach ($students as $student) { $individual_extension = false; $personal_deadline = false; - if ($coursework->extensions_enabled()){ + if ($coursework->extensions_enabled()) { $individual_extension = \mod_coursework\models\deadline_extension::get_extension_for_student($student, $coursework); } - if ($coursework->personal_deadlines_enabled()){ + if ($coursework->personal_deadlines_enabled()) { $personal_deadline = \mod_coursework\models\personal_deadline::get_personal_deadline_for_student($student, $coursework); } $deadline = $personal_deadline ? $personal_deadline->personal_deadline : $coursework->deadline; - - if ($individual_extension){ + if ($individual_extension) { // 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)) { @@ -105,12 +123,10 @@ private static function send_reminders_to_students() { $student->deadline = $individual_extension->extended_deadline; $student->extension = $individual_extension->extended_deadline; $student->coursework_id = $coursework->id; - $student->nextremindernumber= 2; + $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 if ($coursework->due_to_send_first_reminders($deadline) && $student->has_not_been_sent_reminder($coursework, 1)) { @@ -219,7 +235,7 @@ private static function send_first_reminders_to_admins() { } $user->coursework_name = $coursework_instance->name; - $user->deadline = userdate($coursework_instance->get_deadline(),'%a, %d %b %Y, %H:%M'); + $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()); $subject = get_string('cron_email_subject_admin', 'mod_coursework', $user); @@ -262,7 +278,7 @@ private static function send_first_reminders_to_admins() { * @global $CFG * @return string */ - public static function coursework_debuggable_query($query, $params = array()) { + public static function coursework_debuggable_query($query, $params = []) { global $CFG; @@ -294,7 +310,7 @@ private static function send_email_reminders_to_students(array $users, array &$c global $DB; $emailcounter = 0; - $usercounter = array(); + $usercounter = []; foreach ($users as $user) { @@ -311,7 +327,7 @@ private static function send_email_reminders_to_students(array $users, array &$c $usercounter[$user->id]++; } - $extension = isset($user->extension)? $user->extension : 0; + $extension = isset($user->extension) ? $user->extension : 0; $email_reminder = new stdClass(); $email_reminder->userid = $user->id; $email_reminder->coursework_id = $user->coursework_id; @@ -370,7 +386,6 @@ 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 * FROM {coursework} c JOIN {coursework_submissions} cs @@ -402,8 +417,7 @@ private static function autorelease_feedbacks_where_the_release_date_has_passed( * @param $context * @return array */ - public static function get_admins_and_teachers($context){ - + public static function get_admins_and_teachers($context) { $graders = get_enrolled_users($context, 'mod/coursework:addinitialgrade'); $managers = get_enrolled_users($context, 'mod/coursework:addagreedgrade'); @@ -419,8 +433,5 @@ public static function get_admins_and_teachers($context){ } - - - } diff --git a/classes/decorators/coursework_groups_decorator.php b/classes/decorators/coursework_groups_decorator.php index dcac15fc..2ba104be 100644 --- a/classes/decorators/coursework_groups_decorator.php +++ b/classes/decorators/coursework_groups_decorator.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\decorators; use mod_coursework\framework\decorator; @@ -13,6 +33,4 @@ */ class coursework_groups_decorator extends decorator { - - -} \ No newline at end of file +} diff --git a/classes/decorators/submission_groups_decorator.php b/classes/decorators/submission_groups_decorator.php index 3edfb24f..c67e4db1 100644 --- a/classes/decorators/submission_groups_decorator.php +++ b/classes/decorators/submission_groups_decorator.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\decorators; @@ -32,4 +52,4 @@ public function user_is_in_same_group($user) { return groups_is_member($group->id, $user->id); } -} \ No newline at end of file +} diff --git a/classes/event/assessable_submitted.php b/classes/event/assessable_submitted.php index a0cdeac7..d32319d3 100644 --- a/classes/event/assessable_submitted.php +++ b/classes/event/assessable_submitted.php @@ -33,7 +33,6 @@ */ class assessable_submitted extends \core\event\assessable_submitted { - /** * Init method. * diff --git a/classes/event/assessable_uploaded.php b/classes/event/assessable_uploaded.php index e29adab5..7b3a4cc9 100644 --- a/classes/event/assessable_uploaded.php +++ b/classes/event/assessable_uploaded.php @@ -13,14 +13,16 @@ // // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\event; use mod_coursework\models\submission; defined('MOODLE_INTERNAL') || die(); - class assessable_uploaded extends \core\event\assessable_uploaded { /** @@ -28,7 +30,7 @@ class assessable_uploaded extends \core\event\assessable_uploaded { * * @var array */ - protected $legacyfiles = array(); + protected $legacyfiles = []; /** * Returns description of what happened. diff --git a/classes/event/course_module_instance_list_viewed.php b/classes/event/course_module_instance_list_viewed.php index 1fa6b8f6..eddc7c46 100644 --- a/classes/event/course_module_instance_list_viewed.php +++ b/classes/event/course_module_instance_list_viewed.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ // This file is part of the Certificate module for Moodle - http://moodle.org/ // @@ -15,7 +35,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - namespace mod_coursework\event; defined('MOODLE_INTERNAL') || die(); @@ -27,4 +46,4 @@ * @package mod_coursework\event */ class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { -} \ No newline at end of file +} diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php index ca021329..185374ee 100644 --- a/classes/event/course_module_viewed.php +++ b/classes/event/course_module_viewed.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\event; @@ -24,4 +44,3 @@ public function get_url() { // 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/event/coursework_deadline_changed.php b/classes/event/coursework_deadline_changed.php index 6006a48b..858a42f7 100644 --- a/classes/event/coursework_deadline_changed.php +++ b/classes/event/coursework_deadline_changed.php @@ -17,8 +17,7 @@ /** * coursework_deadline_changed * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2016 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -27,10 +26,8 @@ defined('MOODLE_INTERNAL') || die(); - class coursework_deadline_changed extends \core\event\base { - /** * Init method. * diff --git a/classes/event/coursework_plagiarism_flag_updated.php b/classes/event/coursework_plagiarism_flag_updated.php index f149f009..613afc93 100644 --- a/classes/event/coursework_plagiarism_flag_updated.php +++ b/classes/event/coursework_plagiarism_flag_updated.php @@ -17,8 +17,7 @@ /** * ccoursework_plagiarism_flag_updated * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2016 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -27,7 +26,6 @@ defined('MOODLE_INTERNAL') || die(); - class coursework_plagiarism_flag_updated extends \core\event\base { /** @@ -37,7 +35,7 @@ class coursework_plagiarism_flag_updated extends \core\event\base { */ protected function init() { - $this->data['crud'] = 'u'; //One of [crud] letters - indicating 'c'reate, 'r'ead, 'u'pdate or 'd'elete operation. Statically declared in the event class method init(). + $this->data['crud'] = 'u'; // One of [crud] letters - indicating 'c'reate, 'r'ead, 'u'pdate or 'd'elete operation. Statically declared in the event class method init(). $this->data['edulevel'] = self::LEVEL_TEACHING; $this->data['objecttable'] = 'coursework'; } diff --git a/classes/event/feedback_changed.php b/classes/event/feedback_changed.php index 3874a277..4a0766e3 100644 --- a/classes/event/feedback_changed.php +++ b/classes/event/feedback_changed.php @@ -1,6 +1,24 @@ . - +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\event; @@ -32,7 +50,4 @@ protected function init() { $this->data['objecttable'] = 'coursework_feedbacks'; } - - - -} \ No newline at end of file +} diff --git a/classes/exceptions/access_denied.php b/classes/exceptions/access_denied.php index 9ec3d833..2c8c0620 100644 --- a/classes/exceptions/access_denied.php +++ b/classes/exceptions/access_denied.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\exceptions; @@ -27,4 +47,4 @@ public function __construct($coursework, $message = null) { parent::__construct('access_denied', 'mod_coursework', $link, null, $message); } -} \ No newline at end of file +} diff --git a/classes/exceptions/late_submission.php b/classes/exceptions/late_submission.php index a7f7ed74..07291198 100644 --- a/classes/exceptions/late_submission.php +++ b/classes/exceptions/late_submission.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\exceptions; @@ -26,4 +46,4 @@ public function __construct($coursework, $message = null) { parent::__construct('latesubmissionsnotallowed', 'mod_coursework', $link, null, $message); } -} \ No newline at end of file +} diff --git a/classes/export/csv.php b/classes/export/csv.php index d1fa51db..c0db544a 100644 --- a/classes/export/csv.php +++ b/classes/export/csv.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\export; use csv_export_writer; @@ -21,7 +27,6 @@ use mod_coursework\models\coursework; use mod_coursework\models\submission; - defined('MOODLE_INTERNAL') || die(); global $CFG; @@ -68,12 +73,12 @@ public function __construct($coursework, $csv_cells, $filename) { /** * @throws \coding_exception */ - public function export(){ + public function export() { $this->csvexport = new csv_export_writer(); $this->add_filename($this->filename); - $csv_data = array(); + $csv_data = []; // headers $this->add_headers($this->csv_cells); @@ -86,9 +91,9 @@ public function export(){ usort($submissions, array($this, "sort_by_lastname")); // loop through each submission in the coursework - foreach ($submissions as $submission){ + foreach ($submissions as $submission) { // add data to cvs - $data = $this->add_csv_data($submission); + $data = $this->add_csv_data($submission); $csv_data = array_merge($csv_data, $data); } @@ -105,71 +110,70 @@ public function export(){ * @param $csv_cells * @return array */ - public function add_cells_to_array($submission,$student,$csv_cells){ - $row = array(); - foreach($csv_cells as $csv_cell) { - if(substr($csv_cell,0,8) == 'assessor'){ - $stage_dentifier = 'assessor_'.(substr($csv_cell,-1)); + public function add_cells_to_array($submission, $student, $csv_cells) { + $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); } $class = "mod_coursework\\export\\csv\\cells\\".$csv_cell."_cell"; $cell = new $class($this->coursework); - if(substr($csv_cell,0,8) == 'assessor'){ + if (substr($csv_cell, 0, 8) == 'assessor') { $cell = $cell->get_cell($submission, $student, $stage_dentifier); - if(is_array($cell)){ - $row = array_merge($row,$cell); + 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 ($csv_cell != 'stages' && $csv_cell != 'moderationagreement' && $csv_cell != 'otherassessors') { $cell = $cell->get_cell($submission, $student, false); - if(is_array($cell)){ - $row = array_merge($row,$cell); - } else{ + if (is_array($cell)) { + $row = array_merge($row, $cell); + } else { $row[] = $cell; } } else { $stages = $cell->get_cell($submission, $student, false); - $row = array_merge($row,$stages); + $row = array_merge($row, $stages); } } return $row; } - /** * create headers for CSV * @param $csv_headers */ - public function add_headers($csv_headers){ - $headers = array(); - foreach($csv_headers as $header) { - if(substr($header,0,8) == 'assessor'){ - $stage = (substr($header,-1)); + 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); } $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{ + 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{ + $head = $cell->get_header(false); + if (is_array($head)) { + $headers = array_merge($headers, $head); + } else { $headers[$header] = $head; } } else { $array_headers = $cell->get_header(false); - $headers = array_merge($headers,$array_headers); + $headers = array_merge($headers, $array_headers); } } @@ -182,7 +186,7 @@ public function add_headers($csv_headers){ * @param $filename * @return string */ - public function add_filename($filename){ + public function add_filename($filename) { $filename = clean_filename($filename); return $this->csvexport->filename = $filename.'.csv'; @@ -194,7 +198,7 @@ public function add_filename($filename){ * @param $b * @return int */ - protected function sort_by_lastname($a, $b){ + protected function sort_by_lastname($a, $b) { return strcmp($a->lastname, $b->lastname); @@ -204,7 +208,7 @@ protected function sort_by_lastname($a, $b){ * @param array $csv_data */ private function add_data_to_csv($csv_data) { - foreach ($csv_data as $data){ + foreach ($csv_data as $data) { $this->csvexport->add_data($data); } } @@ -235,9 +239,9 @@ public function get_submissions($groupid = null, $selected_submission_ids = '') * @param submission $submission * @return array */ - public function add_csv_data($submission){ + public function add_csv_data($submission) { - $csv_data = array(); + $csv_data = []; // retrieve all students (even if group coursework) $students = $submission->get_students(); @@ -248,31 +252,24 @@ public function add_csv_data($submission){ return $csv_data; } - public function other_assessors_cells(){ + public function other_assessors_cells() { $cells = 0; if ($this->coursework->is_using_rubric()) { $criterias = $this->coursework->get_rubric_criteria(); - //we will increment by the number of criterias plus 1 for feedback - $increment = (count($criterias) * 2) +1; + // We will increment by the number of criterias plus 1 for feedback + $increment = (count($criterias) * 2) + 1; } else { - $increment = 2; + $increment = 2; } - for ($i = 1; $i < $this->coursework->get_max_markers(); $i++) { $cells = $cells + $increment; // one for grade, one for feedback } - - - - - return $cells; - } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/agreedfeedback_cell.php b/classes/export/csv/cells/agreedfeedback_cell.php index f246bf62..05ca1d9c 100644 --- a/classes/export/csv/cells/agreedfeedback_cell.php +++ b/classes/export/csv/cells/agreedfeedback_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -9,8 +29,7 @@ /** * Class agreedfeedback_cell */ -class agreedfeedback_cell extends cell_base{ - +class agreedfeedback_cell extends cell_base { /** * @param submission$submission @@ -19,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, $stage_identifier) { return $gradedata[] = $submission->get_agreed_grade() == false ? '' : strip_tags($submission->get_agreed_grade()->feedbackcomment); } @@ -28,36 +47,34 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + 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,$stage_identifier='',$uploadedgradecells = array()) { - - global $DB,$PAGE,$USER; + global $DB, $PAGE, $USER; $stage_identifier = 'final_agreed_1'; - $agreedgradecap = array('mod/coursework:addagreedgrade','mod/coursework:editagreedgrade', - 'mod/coursework:addallocatedagreedgrade','mod/coursework:editallocatedagreedgrade'); + $agreedgradecap = array('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)) { + 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', array('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'); + // Is the submission in question ready to grade? + 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 + // 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 you have administer grades you can grade anything + // If you have administer grades you can grade anything 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). + // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). $feedback_params = array( 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, @@ -76,11 +93,11 @@ public function validate_cell($value,$submissionid,$stage_identifier='',$uploade ); $new_feedback = feedback::build($feedback_params); - //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'); + // 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'); } 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'); + // 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'); } } else { @@ -91,4 +108,4 @@ public function validate_cell($value,$submissionid,$stage_identifier='',$uploade } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/agreedgrade_cell.php b/classes/export/csv/cells/agreedgrade_cell.php index 2cc45c1e..1deae83e 100644 --- a/classes/export/csv/cells/agreedgrade_cell.php +++ b/classes/export/csv/cells/agreedgrade_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -9,8 +29,7 @@ /** * Class agreedgrade_cell */ -class agreedgrade_cell extends cell_base{ - +class agreedgrade_cell extends cell_base { /** * @param $submission @@ -19,14 +38,14 @@ 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, $stage_identifier) { $agreedgrade = $submission->get_agreed_grade(); - if($this->coursework->is_using_rubric() && $this->coursework->finalstagegrading != 1){ - $gradedata = array(); + if ($this->coursework->is_using_rubric() && $this->coursework->finalstagegrading != 1) { + $gradedata = []; $this->get_rubric_scores_gradedata($agreedgrade, $gradedata); // multiple parts are handled here } else { - $gradedata = (!$agreedgrade)? '': $this->get_actual_grade($agreedgrade->grade); + $gradedata = (!$agreedgrade) ? '' : $this->get_actual_grade($agreedgrade->grade); } return $gradedata; @@ -37,10 +56,10 @@ public function get_cell($submission, $student, $stage_identifier){ * @return array|mixed|string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { if ($this->coursework->is_using_rubric() && $this->coursework->finalstagegrading != 1) { - $strings = array(); + $strings = []; $criterias = $this->coursework->get_rubric_criteria(); foreach ($criterias as $criteria) { // rubrics can have multiple parts, so let's create header for each of it $strings['agreedgrade'.$criteria['id']] = 'Agreed grade - '.$criteria['description']; @@ -53,24 +72,24 @@ public function get_header($stage){ return $strings; } - public function validate_cell($value,$submissionid,$stage_identifier='', $uploadedgradecells = array()) { + public function validate_cell($value, $submissionid, $stage_identifier='', $uploadedgradecells = []) { - global $DB,$PAGE,$USER; + global $DB, $PAGE, $USER; $stage_identifier = 'final_agreed_1'; - $agreedgradecap = array('mod/coursework:addagreedgrade','mod/coursework:editagreedgrade', - 'mod/coursework:addallocatedagreedgrade','mod/coursework:editallocatedagreedgrade'); + $agreedgradecap = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', + 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade'); if (empty($value)) return true; - if (has_any_capability($agreedgradecap,$PAGE->context) - || has_capability('mod/coursework:administergrades', $PAGE->context)) { + if (has_any_capability($agreedgradecap, $PAGE->context) + || has_capability('mod/coursework:administergrades', $PAGE->context)) { - $errormsg = ''; + $errormsg = ''; if (!$this->coursework->is_using_rubric() || ($this->coursework->is_using_rubric() && $this->coursework->finalstagegrading == 1)) { $gradejudge = new grade_judge($this->coursework); - if (!$gradejudge->grade_in_scale($value)){ + if (!$gradejudge->grade_in_scale($value)) { $errormsg = get_string('valuenotincourseworkscale', 'coursework'); if (is_numeric($value)) { // if scale is numeric get max allowed scale @@ -80,13 +99,13 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload } } else { - //we won't be processing this line if it has no values, empty wont tell us this as it thinks that an array with - //keys isnt. We will use array_filter whhich will return all values from the array if this is empty then we have - //nothing to do + // We won't be processing this line if it has no values, empty wont tell us this as it thinks that an array with + // Keys isnt. We will use array_filter whhich will return all values from the array if this is empty then we have + // Nothing to do - $arrayvalues = array_filter($value); + $arrayvalues = array_filter($value); - //if there are no values we don't need to do anything + // If there are no values we don't need to do anything if (!empty($arrayvalues)) { $i = 0; @@ -96,17 +115,17 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload foreach ($value as $data) { - //check if the value is empty however it can be 0 + // Check if the value is empty however it can be 0 if (empty($data) && $data != 0) { $errormsg .= ' ' . get_string('rubric_grade_cannot_be_empty', 'coursework'); } - //only check grades fields that will be even numbered + // Only check grades fields that will be even numbered if ($i % 2 == 0) { - //get the current criteria + // Get the current criteria $criteria = array_shift($criterias); //lets check if the value given is valid for the current rubric criteria @@ -120,8 +139,8 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload } } else { - //set value to false so that a submission not ready to grade message isn't returned - $value = false; + // Set value to false so that a submission not ready to grade message isn't returned + $value = false; } @@ -129,20 +148,19 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload if (!empty($errormsg)) return $errormsg; - $subdbrecord = $DB->get_record('coursework_submissions',array('id'=>$submissionid)); + $subdbrecord = $DB->get_record('coursework_submissions', array('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'); - //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'); - - //has the submission been published if yes then no further grades are allowed + // 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 you have administer grades you can grade anything + // If you have administer grades you can grade anything 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). + // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). $feedback_params = array( 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, @@ -162,18 +180,13 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload ); $new_feedback = feedback::build($feedback_params); - - //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'); + // 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'); } 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'); + // 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'); } - - - - } else { return get_string('nopermissiontoimportgrade', 'coursework'); } @@ -182,7 +195,6 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload } - /*** * Check that the given value is within the values that can be excepted by the given rubric criteria * @@ -190,13 +202,13 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload * @param $value the value that should be checked to see if it is valid * @return bool */ - function value_in_rubric($criteria, $value) { + function value_in_rubric($criteria, $value) { global $DB; - $valuefound = false; + $valuefound = false; - $levels = $criteria['levels']; + $levels = $criteria['levels']; if (is_numeric($value) ) { foreach ($levels as $level) { @@ -210,7 +222,6 @@ function value_in_rubric($criteria, $value) { } } - return $valuefound; } @@ -218,44 +229,38 @@ function value_in_rubric($criteria, $value) { * Takes the given cells and returns the cells with the singlegrade cell replaced by the rubric headers if the coursework instance * makes use of rubrics * + * @param $coursework * @param $csv_cells - * + * @return array */ - function get_rubrics($coursework,$csv_cells) { - + function get_rubrics($coursework, $csv_cells) { if ($coursework->is_using_rubric() && $this->coursework->finalstagegrading != 1) { - $rubricheaders = array(); + $rubricheaders = []; $criterias = $coursework->get_rubric_criteria(); - foreach ($criterias as $criteria) { - $rubricheaders[] = $criteria['description']; - $rubricheaders[] = $criteria['description']." comment"; + foreach ($criterias as $criteria) { + $rubricheaders[] = $criteria['description']; + $rubricheaders[] = $criteria['description']." comment"; } + // Find out the position of singlegrade + $position = array_search('singlegrade', $csv_cells); + // Get all data from the position of the singlegrade to the length of rubricheaders + // $csv_cells = array_splice($csv_cells,5, 1, $rubricheaders); - //find out the position of singlegrade - $position = array_search('singlegrade',$csv_cells); - //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); - - $cells = array_merge($start_cells,$rubricheaders); - - $cells = array_merge($cells,$end_cells); + $start_cells = array_slice($csv_cells, 0, $position, true); + $end_cells = array_slice($csv_cells, $position + 1, count($csv_cells), true); + $cells = array_merge($start_cells, $rubricheaders); + $cells = array_merge($cells, $end_cells); } - return $cells; } - -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/assessor_cell.php b/classes/export/csv/cells/assessor_cell.php index 96f6b125..ad34049f 100644 --- a/classes/export/csv/cells/assessor_cell.php +++ b/classes/export/csv/cells/assessor_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -6,8 +26,7 @@ /** * Class assessor_cell */ -class assessor_cell extends cell_base{ - +class assessor_cell extends cell_base { /** * @param $submission @@ -16,13 +35,13 @@ class assessor_cell extends cell_base{ * @return string */ - public function get_cell($submission, $student, $stage_identifier){ + public function get_cell($submission, $student, $stage_identifier) { $assessor = ''; $allocation = $this->coursework->get_assessor_allocation($submission, $stage_identifier ); if ($allocation) { $assessor = $this->get_assessor_name($allocation->assessorid); - } else if($this->coursework->sampling_enabled()){ + } else if ($this->coursework->sampling_enabled()) { $assessor = 'Not in sample'; } return $assessor; @@ -33,10 +52,8 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('assessorcsv', 'coursework', $stage); } - - -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/assessorfeedback_cell.php b/classes/export/csv/cells/assessorfeedback_cell.php index c17e026c..6932b32b 100644 --- a/classes/export/csv/cells/assessorfeedback_cell.php +++ b/classes/export/csv/cells/assessorfeedback_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -8,8 +28,7 @@ /** * Class assessorfeedback_cell */ -class assessorfeedback_cell extends cell_base{ - +class assessorfeedback_cell extends cell_base { /** * @param submission$submission @@ -18,12 +37,12 @@ class assessorfeedback_cell extends cell_base{ * @return string */ - public function get_cell($submission, $student, $stage_identifier){ + public function get_cell($submission, $student, $stage_identifier) { global $USER; $grade = $submission->get_assessor_feedback_by_stage($stage_identifier); - if ($grade){ + if ($grade) { // check if user can see initial grades before all of them are completed $ability = new ability(user::find($USER), $this->coursework); @@ -40,7 +59,7 @@ public function get_cell($submission, $student, $stage_identifier){ } } else { - $grade= ''; + $grade = ''; } return $grade; @@ -51,32 +70,31 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('assessorfeedbackcsv', 'coursework', $stage); } - public function validate_cell($value,$submissionid,$stage_identifier='',$uploadedgradecells = array()) { - global $DB,$PAGE,$USER; + public function validate_cell($value, $submissionid, $stage_identifier='', $uploadedgradecells = []) { + global $DB, $PAGE, $USER; - $agreedgradecap = array('mod/coursework:addagreedgrade','mod/coursework:editagreedgrade'); - $initialgradecap = array('mod/coursework:addinitialgrade','mod/coursework:editinitialgrade'); + $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)); + $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); $submission = \mod_coursework\models\submission::find($subdbrecord); - if (has_any_capability($agreedgradecap,$PAGE->context) && has_any_capability($initialgradecap,$PAGE->context) - || has_capability('mod/coursework:administergrades', $PAGE->context)) { + if (has_any_capability($agreedgradecap, $PAGE->context) && has_any_capability($initialgradecap, $PAGE->context) + || has_capability('mod/coursework:administergrades', $PAGE->context)) { + // Is the submission in question ready to grade? + if (!$submission->ready_to_grade()) return get_string('submissionnotreadytograde', 'coursework'); - //is the submission in question ready to grade? - if (!$submission->ready_to_grade()) return get_string('submissionnotreadytograde','coursework'); - - //has the submission been published if yes then no further grades are allowed + // 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 you have administer grades you can grade anything + // If you have administer grades you can grade anything 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). + // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). $feedback_params = array( 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, @@ -87,27 +105,26 @@ public function validate_cell($value,$submissionid,$stage_identifier='',$uploade //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'); + // 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'); } 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'); + // 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 (!$this->coursework->allocation_enabled() && !empty($feedback)) { - //was this user the one who last graded this submission if not then user cannot grade + 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) ) - return get_string('nopermissiontogradesubmission','coursework'); + 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( + if ($this->coursework->allocation_enabled()) { + // Check that the user is allocated to the author of the submission + $allocation_params = array( 'courseworkid' => $this->coursework->id, 'allocatableid' => $submission->allocatableid, 'allocatabletype' => $submission->allocatabletype, @@ -115,32 +132,31 @@ public function validate_cell($value,$submissionid,$stage_identifier='',$uploade ); 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', $allocation_params)) return get_string('nopermissiontogradesubmission', 'coursework'); } - - //check for coursework without allocations - with/without samplings + // Check for coursework without allocations - with/without samplings if (has_capability('mod/coursework:addinitialgrade', $PAGE->context) && !has_capability('mod/coursework:editinitialgrade', $PAGE->context) - && $this->coursework->get_max_markers() > 1 && !$this->coursework->allocation_enabled()){ + && $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', array('submissionid' => $submissionid)); - if ($this->coursework->sampling_enabled()){ + 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)? sizeof($in_sample) + 1 : 1; + $assessors = ($in_sample) ? count($in_sample) + 1 : 1; } else { - //check how many assessors for this coursework + // 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)) { + } 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 + // 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 { @@ -148,4 +164,4 @@ public function validate_cell($value,$submissionid,$stage_identifier='',$uploade } } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/assessorgrade_cell.php b/classes/export/csv/cells/assessorgrade_cell.php index 8abf1a2a..3c2a83b8 100644 --- a/classes/export/csv/cells/assessorgrade_cell.php +++ b/classes/export/csv/cells/assessorgrade_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -10,8 +30,7 @@ /** * Class assessorgrade_cell */ -class assessorgrade_cell extends cell_base{ - +class assessorgrade_cell extends cell_base { /** * @param submission$submission @@ -20,7 +39,7 @@ class assessorgrade_cell extends cell_base{ * @return string */ - public function get_cell($submission, $student, $stage_identifier){ + public function get_cell($submission, $student, $stage_identifier) { global $USER; @@ -37,17 +56,17 @@ public function get_cell($submission, $student, $stage_identifier){ if (($submission->get_agreed_grade() || ($feedback && $ability->can('show', $feedback))) || !$submission->any_editable_feedback_exists() || is_siteadmin($USER->id)) { - if($this->coursework->is_using_rubric()){ - $gradedata = array(); + if ($this->coursework->is_using_rubric()) { + $gradedata = []; $this->get_rubric_scores_gradedata($grade, $gradedata); // multiple parts are handled here - } else{ - $gradedata = (!$grade)? '': $this->get_actual_grade($grade->grade); + } else { + $gradedata = (!$grade) ? '' : $this->get_actual_grade($grade->grade); } } else { - if($this->coursework->is_using_rubric()){ + 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'); @@ -67,25 +86,24 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { if ($this->coursework->is_using_rubric() ) { - $strings = array(); + $strings = []; $criterias = $this->coursework->get_rubric_criteria(); foreach ($criterias as $criteria) { // rubrics can have multiple parts, so let's create header for each of it $strings['assessorgrade'.$stage.'_'.$criteria['id']] = 'Assessor '.$stage.' - '.$criteria['description']; $strings['assessorgrade'.$stage.'_'.$criteria['id'] . 'comment'] = 'Comment for: Assessor '.$stage.' - '.$criteria['description']; } } else { - $strings = get_string('assessorgradecsv', 'coursework', $stage); + $strings = get_string('assessorgradecsv', 'coursework', $stage); } return $strings; } - public function validate_cell($value,$submissionid,$stage_identifier='', $uploadedgradecells = array()) - { + public function validate_cell($value, $submissionid, $stage_identifier='', $uploadedgradecells = []) { global $DB, $PAGE, $USER; if (empty($value)) return true; @@ -99,12 +117,11 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload || has_capability('mod/coursework:administergrades', $PAGE->context) ) { - - $errormsg = ''; + $errormsg = ''; if (!$this->coursework->is_using_rubric()) { $gradejudge = new grade_judge($this->coursework); - if (!$gradejudge->grade_in_scale($value)){ + if (!$gradejudge->grade_in_scale($value)) { $errormsg = get_string('valuenotincourseworkscale', 'coursework'); if (is_numeric($value)) { // if scale is numeric get max allowed scale @@ -113,13 +130,13 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload } } else { - //we won't be processing this line if it has no values, empty wont tell us this as it thinks that an array with - //keys isnt. We will use array_filter whhich will return all values from the array if this is empty then we have - //nothing to do + // We won't be processing this line if it has no values, empty wont tell us this as it thinks that an array with + // Keys isnt. We will use array_filter whhich will return all values from the array if this is empty then we have + // Nothing to do - $arrayvalues = array_filter($value); + $arrayvalues = array_filter($value); - //if there are no values we don't need to do anything + // If there are no values we don't need to do anything if (!empty($arrayvalues)) { $i = 0; @@ -129,17 +146,17 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload foreach ($value as $data) { - //check if the value is empty however it can be 0 + // Check if the value is empty however it can be 0 if (empty($data) && $data != 0) { $errormsg .= ' ' . get_string('rubric_grade_cannot_be_empty', 'coursework'); } - //only check grades fields that will be even numbered + // Only check grades fields that will be even numbered if ($i % 2 == 0) { - //get the current criteria + // Get the current criteria $criteria = array_shift($criterias); //lets check if the value given is valid for the current rubric criteria @@ -157,18 +174,16 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload if (!empty($errormsg)) return $errormsg; - - //is the submission in question ready to grade? + // Is the submission in question ready to grade? if (!$submission->ready_to_grade()) return get_string('submissionnotreadytograde', 'coursework'); - - //has the submission been published if yes then no further grades are allowed + // 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 you have administer grades you can grade anything + // If you have administer grades you can grade anything 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). + // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). $feedback_params = array( 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, @@ -179,26 +194,25 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload //does a feedback exist for this stage if (!empty($feedback)) { - //this is a new feedback check it against the new ability checks + // 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'); } else { - //this is a new feedback check it against the edit ability checks + // 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 (!$this->coursework->allocation_enabled() && !empty($feedback)) { - //was this user the one who last graded this submission if not then user cannot grade + // 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 + // Check that the user is allocated to the author of the submission $allocation_params = array( 'courseworkid' => $this->coursework->id, 'allocatableid' => $submission->allocatableid, @@ -211,8 +225,7 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload ) return get_string('nopermissiontogradesubmission', 'coursework'); } - - //check for coursework without allocations - with/without samplings + // Check for coursework without allocations - with/without samplings if (has_capability('mod/coursework:addinitialgrade', $PAGE->context) && !has_capability('mod/coursework:editinitialgrade', $PAGE->context) && $this->coursework->get_max_markers() > 1 && !$this->coursework->allocation_enabled() ) { @@ -223,19 +236,18 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload 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) ? sizeof($in_sample) + 1 : 1; + $assessors = ($in_sample) ? count($in_sample) + 1 : 1; } else { - //check how many assessors for this coursework + // Check how many assessors for this coursework $assessors = $this->coursework->get_max_markers(); } 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 + // 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 { @@ -250,13 +262,13 @@ public function validate_cell($value,$submissionid,$stage_identifier='', $upload * @param $value the value that should be checked to see if it is valid * @return bool */ - function value_in_rubric($criteria, $value) { + function value_in_rubric($criteria, $value) { global $DB; - $valuefound = false; + $valuefound = false; - $levels = $criteria['levels']; + $levels = $criteria['levels']; if (is_numeric($value) ) { foreach ($levels as $level) { @@ -270,7 +282,6 @@ function value_in_rubric($criteria, $value) { } } - return $valuefound; } @@ -281,41 +292,34 @@ function value_in_rubric($criteria, $value) { * @param $csv_cells * */ - function get_rubrics($coursework,$csv_cells) { - + function get_rubrics($coursework, $csv_cells) { if ($coursework->is_using_rubric()) { - $rubricheaders = array(); + $rubricheaders = []; $criterias = $coursework->get_rubric_criteria(); - foreach ($criterias as $criteria) { - $rubricheaders[] = $criteria['description']; - $rubricheaders[] = $criteria['description']." comment"; + foreach ($criterias as $criteria) { + $rubricheaders[] = $criteria['description']; + $rubricheaders[] = $criteria['description']." comment"; } + // Find out the position of singlegrade + $position = array_search('singlegrade', $csv_cells); + // Get all data from the position of the singlegrade to the length of rubricheaders + // $csv_cells = array_splice($csv_cells,5, 1, $rubricheaders); - //find out the position of singlegrade - $position = array_search('singlegrade',$csv_cells); - //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); - - $cells = array_merge($start_cells,$rubricheaders); - - $cells = array_merge($cells,$end_cells); + $start_cells = array_slice($csv_cells, 0, $position, true); + $end_cells = array_slice($csv_cells, $position + 1, count($csv_cells), true); + $cells = array_merge($start_cells, $rubricheaders); + $cells = array_merge($cells, $end_cells); } - return $cells; } - -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/cell_base.php b/classes/export/csv/cells/cell_base.php index 992b9eef..563f8484 100644 --- a/classes/export/csv/cells/cell_base.php +++ b/classes/export/csv/cells/cell_base.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\coursework; @@ -35,91 +55,83 @@ public function __construct($coursework) { } - /** * Function to check if a user can see real names/usernames even if blind marking is enabled * @return bool * @throws \coding_exception */ - public function can_view_hidden() { + public function can_view_hidden() { - $viewanonymous = has_capability('mod/coursework:viewanonymous',$this->coursework->get_context()); - $exportgrade = has_capability('mod/coursework:canexportfinalgrades',$this->coursework->get_context()); + $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context()); + $exportgrade = has_capability('mod/coursework:canexportfinalgrades', $this->coursework->get_context()); return (!$this->coursework->blindmarking || $viewanonymous || $exportgrade); } - /** * Function to check if the student was given an extension * @param $student * @return bool */ - public function extension_exists($student){ + public function extension_exists($student) { - $extension = $this->extension->get_extension_for_student($student,$this->coursework); + $extension = $this->extension->get_extension_for_student($student, $this->coursework); return ($this->coursework->extensions_enabled() && !empty($extension)); } - /** * Function to get student's extension date * @param $student * @return string */ - public function get_extension_date_for_csv($student){ + public function get_extension_date_for_csv($student) { - $extension = $this->extension->get_extension_for_student($student,$this->coursework); + $extension = $this->extension->get_extension_for_student($student, $this->coursework); return userdate($extension->extended_deadline, $this->dateformat); } - /** * Function to get extra information about student's extension * @param $student * @return string */ - public function get_extension_extra_info_for_csv($student){ + public function get_extension_extra_info_for_csv($student) { - $extension = $this->extension->get_extension_for_student($student,$this->coursework); + $extension = $this->extension->get_extension_for_student($student, $this->coursework); return strip_tags($extension->extra_information_text); } - /** * Function to get student's extension pre-defined reason * @param $student * @return string */ - public function get_extension_reason_for_csv($student){ + public function get_extension_reason_for_csv($student) { - $extension = $this->extension->get_extension_for_student($student,$this->coursework); + $extension = $this->extension->get_extension_for_student($student, $this->coursework); $extension_reasons = $this->get_extension_predefined_reasons(); return (!empty($extension_reasons[$extension->pre_defined_reason])) ? strip_tags($extension_reasons[$extension->pre_defined_reason]) : ""; } - /** * Function to get all pre-defined extension reasons * @return array */ - public function get_extension_predefined_reasons(){ + public function get_extension_predefined_reasons() { return $this->coursework->extension_reasons(); } - - /** * Function to check if the plagiarism has been flagged for the given submission * @param $submission * @return bool */ - public function plagiarism_flagged($submission){ + public function plagiarism_flagged($submission) { $flag = $this->plagiarismflag->get_plagiarism_flag($submission); @@ -131,7 +143,7 @@ public function plagiarism_flagged($submission){ * @param $submission * @return string */ - public function get_plagiarism_flag_status_for_csv($submission){ + public function get_plagiarism_flag_status_for_csv($submission) { $flag = $this->plagiarismflag->get_plagiarism_flag($submission); @@ -143,65 +155,61 @@ public function get_plagiarism_flag_status_for_csv($submission){ * @param $submission * @return string */ - public function get_plagiarism_flag_comment_for_csv($submission){ + public function get_plagiarism_flag_comment_for_csv($submission) { $flag = $this->plagiarismflag->get_plagiarism_flag($submission); return strip_tags($flag->comment); } - /** * Function to get a grade that should be displayed * @param $grade * @return null */ - public function get_actual_grade($grade){ + public function get_actual_grade($grade) { - $judge = new grade_judge($this->coursework); + $judge = new grade_judge($this->coursework); return $judge->grade_to_display($grade); } - /** * Function to get assessor's full name * @param $assessorid * @return string */ - public function get_assessor_name($assessorid){ + public function get_assessor_name($assessorid) { global $DB; - $assessor = $DB->get_record('user',array('id'=>$assessorid),'firstname, lastname'); + $assessor = $DB->get_record('user', array('id' => $assessorid), 'firstname, lastname'); return $assessor->lastname .' '. $assessor->firstname; } - /** * Function to get assessor's username * @param $assessorid * @return string */ - public function get_assessor_username($assessorid) { + public function get_assessor_username($assessorid) { global $DB; - $assessor = $DB->get_record('user',array('id'=>$assessorid),'username'); + $assessor = $DB->get_record('user', array('id' => $assessorid), 'username'); return $assessor->username; } - /** * Function to get a message if submission was made withihn the deadline * @param submission $submission */ - protected function submission_time($submission){ + protected function submission_time($submission) { - if ($submission->is_late() && (!$submission->has_extension() || !$submission->submitted_within_extension())){ - $time = get_string('late', 'coursework'); + if ($submission->is_late() && (!$submission->has_extension() || !$submission->submitted_within_extension())) { + $time = get_string('late', 'coursework'); } else { - $time = get_string('ontime', 'mod_coursework'); + $time = get_string('ontime', 'mod_coursework'); } return $time; @@ -213,13 +221,13 @@ protected function submission_time($submission){ * @param $student * @return string */ - public function get_stage_identifier_for_assessor($submission, $student){ + public function get_stage_identifier_for_assessor($submission, $student) { global $DB, $USER; $stageidentifier = ''; - if ($this->coursework->allocation_enabled()){ + if ($this->coursework->allocation_enabled()) { $stageidentifier = $this->coursework->get_assessors_stage_identifier($student->id, $USER->id); - } else if($this->coursework->get_max_markers()>1) { + } else if ($this->coursework->get_max_markers() > 1) { // get existing feedback $sql = "SELECT * FROM {coursework_feedbacks} @@ -242,18 +250,17 @@ 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 = array()){ + public function validate_cell($value, $submissions, $stage_dentifier='', $uploadedgradecells = []) { return true; } - /** * @param $grade * @param $gradedata */ - public function get_rubric_scores_gradedata($grade, &$gradedata){ + public function get_rubric_scores_gradedata($grade, &$gradedata) { - if($grade) { + if ($grade) { $controller = $this->coursework->get_advanced_grading_active_controller(); $gradinginstance = $controller->get_or_create_instance(0, $grade->assessorid, $grade->id); @@ -276,5 +283,4 @@ public function get_rubric_scores_gradedata($grade, &$gradedata){ } } - -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/cell_interface.php b/classes/export/csv/cells/cell_interface.php index 278ecd97..5df28a06 100644 --- a/classes/export/csv/cells/cell_interface.php +++ b/classes/export/csv/cells/cell_interface.php @@ -1,8 +1,26 @@ . -namespace mod_coursework\export\csv\cells; - +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace mod_coursework\export\csv\cells; /** * Interface cell_interface makes sure that all of the grading report cells are the same. @@ -15,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, $stage_identifier); /** * @param $stage @@ -29,7 +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, $stage_dentifier=''); -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/email_cell.php b/classes/export/csv/cells/email_cell.php index d073488a..f40ebeb8 100644 --- a/classes/export/csv/cells/email_cell.php +++ b/classes/export/csv/cells/email_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -15,9 +35,9 @@ 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, $stage_identifier) { - if ($this->can_view_hidden() || $submission->is_published()){ + if ($this->can_view_hidden() || $submission->is_published()) { $name = $student->email; } else { $name = get_string('hidden', 'coursework'); @@ -31,7 +51,7 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('email'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/extensiondeadline_cell.php b/classes/export/csv/cells/extensiondeadline_cell.php index 355564ac..c8644568 100644 --- a/classes/export/csv/cells/extensiondeadline_cell.php +++ b/classes/export/csv/cells/extensiondeadline_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; @@ -13,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, $stage_identifier) { if ($this->extension_exists($student)) { $deadline = $this->get_extension_date_for_csv($student); @@ -28,8 +48,8 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('extensiondeadline', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/extensionextrainfo_cell.php b/classes/export/csv/cells/extensionextrainfo_cell.php index 5aa9942b..bb57a8a1 100644 --- a/classes/export/csv/cells/extensionextrainfo_cell.php +++ b/classes/export/csv/cells/extensionextrainfo_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; @@ -7,14 +27,13 @@ */ class extensionextrainfo_cell extends cell_base { - /** * @param $submission * @param $student * @param $stage_identifier * @return string */ - public function get_cell($submission, $student, $stage_identifier){ + public function get_cell($submission, $student, $stage_identifier) { if ($this->extension_exists($student)) { $extra_info = $this->get_extension_extra_info_for_csv($student); @@ -29,8 +48,8 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('extensionextrainfo', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/extensionreason_cell.php b/classes/export/csv/cells/extensionreason_cell.php index a3280ef9..e7ca00a3 100644 --- a/classes/export/csv/cells/extensionreason_cell.php +++ b/classes/export/csv/cells/extensionreason_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; @@ -13,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, $stage_identifier) { if ($this->extension_exists($student)) { $reason = $this->get_extension_reason_for_csv($student); @@ -28,8 +48,8 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('extensionreason', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/feedbackcomments_cell.php b/classes/export/csv/cells/feedbackcomments_cell.php index 8bedf42c..e797df56 100644 --- a/classes/export/csv/cells/feedbackcomments_cell.php +++ b/classes/export/csv/cells/feedbackcomments_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -12,18 +32,17 @@ */ class feedbackcomments_cell extends cell_base { - /** * @param submission $submission * @param $student * @param $stage_identifier * @return string */ - public function get_cell($submission, $student, $stage_identifier){ + public function get_cell($submission, $student, $stage_identifier) { $stage_identifier = ($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); - return (!$grade)? '' : strip_tags($grade->feedbackcomment); + return (!$grade) ? '' : strip_tags($grade->feedbackcomment); } /** @@ -31,31 +50,30 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('feedbackcomment', 'coursework'); } - - public function validate_cell($value, $submissionid, $stage_identifier='',$uploadedgradecells = array()) { + public function validate_cell($value, $submissionid, $stage_identifier='', $uploadedgradecells = []) { global $PAGE, $DB, $USER; if (has_capability('mod/coursework:addinitialgrade', $PAGE->context) || has_capability('mod/coursework:editinitialgrade', $PAGE->context) - || has_capability('mod/coursework:administergrades', $PAGE->context)) { + || has_capability('mod/coursework:administergrades', $PAGE->context)) { - $dbrecord = $DB->get_record('coursework_submissions', array('id'=>$submissionid)); + $dbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); - $submission = \mod_coursework\models\submission::find($dbrecord); + $submission = \mod_coursework\models\submission::find($dbrecord); - //is this submission ready to be graded - if (!$submission->ready_to_grade()) return get_string('submissionnotreadytograde','coursework'); + // Is this submission ready to be graded + if (!$submission->ready_to_grade()) return get_string('submissionnotreadytograde', 'coursework'); - //if you have administer grades you can grade anything + // If you have administer grades you can grade anything 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->is_assessor($USER) && !has_capability('mod/coursework:administergrades',$PAGE->context)) - return get_string('nopermissiontogradesubmission','coursework'); + // Is the current user an assessor at any of this submissions grading stages or do they have administer grades + if (!$this->coursework->is_assessor($USER) && !has_capability('mod/coursework:administergrades', $PAGE->context)) + return get_string('nopermissiontogradesubmission', 'coursework'); $ability = new ability(user::find($USER), $this->coursework); @@ -75,12 +93,11 @@ public function validate_cell($value, $submissionid, $stage_identifier='',$uploa ); $new_feedback = feedback::build($feedback_params); - - //this is a new feedback check it against the new ability checks - if (!$ability->can('new',$new_feedback)) return get_string('nopermissiontogradesubmission','coursework'); + // This is a new feedback check it against the new ability checks + if (!$ability->can('new', $new_feedback)) 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'); + // This is a new feedback check it against the edit ability checks + if (!$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework'); } } else { return get_string('nopermissiontoimportgrade', 'coursework'); @@ -89,4 +106,4 @@ public function validate_cell($value, $submissionid, $stage_identifier='',$uploa return true; } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/finalgrade_cell.php b/classes/export/csv/cells/finalgrade_cell.php index 1097d858..6c2926f4 100644 --- a/classes/export/csv/cells/finalgrade_cell.php +++ b/classes/export/csv/cells/finalgrade_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -14,9 +34,9 @@ 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, $stage_identifier) { - return $submission->get_final_grade() == false || $submission->editable_final_feedback_exist()? '' : $this->get_actual_grade($submission->get_final_grade()); + return $submission->get_final_grade() == false || $submission->editable_final_feedback_exist() ? '' : $this->get_actual_grade($submission->get_final_grade()); } @@ -25,8 +45,8 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('provisionalgrade', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/group_cell.php b/classes/export/csv/cells/group_cell.php index 4b4aec77..599f76a3 100644 --- a/classes/export/csv/cells/group_cell.php +++ b/classes/export/csv/cells/group_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; @@ -13,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, $stage_identifier) { return $group->name; } @@ -22,7 +42,7 @@ public function get_cell($submission, $group, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('group', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/idnumber_cell.php b/classes/export/csv/cells/idnumber_cell.php index ac72c005..422cdfbb 100644 --- a/classes/export/csv/cells/idnumber_cell.php +++ b/classes/export/csv/cells/idnumber_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -15,9 +35,9 @@ 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, $stage_identifier) { - if ($this->can_view_hidden() || $submission->is_published()){ + if ($this->can_view_hidden() || $submission->is_published()) { $name = $student->idnumber; } else { $name = get_string('hidden', 'coursework'); @@ -31,7 +51,7 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('idnumber'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/moderationagreement_cell.php b/classes/export/csv/cells/moderationagreement_cell.php index 80ceb071..a989a1e2 100644 --- a/classes/export/csv/cells/moderationagreement_cell.php +++ b/classes/export/csv/cells/moderationagreement_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -15,14 +35,14 @@ 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, $stage_identifier) { global $DB; - $data = array(); + $data = []; $moderation_agreement = ''; $moderation = ''; - if($this->coursework->allocation_enabled()) { + if ($this->coursework->allocation_enabled()) { $allocation = $submission->get_assessor_allocation_by_stage('moderator'); if ($allocation) { $data[] = $this->get_assessor_name($allocation->assessorid); @@ -33,7 +53,7 @@ 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(array('feedbackid' => $feedback->id)); if ($moderation) $moderation_agreement = $moderation->get_moderator_agreement($feedback); @@ -56,10 +76,10 @@ public function get_cell($submission, $student, $stage_identifier){ * @return array * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { - $fields = array(); - if($this->coursework->allocation_enabled()){ + $fields = []; + if ($this->coursework->allocation_enabled()) { $fields['allocatedmoderatorname'] = 'Allocated moderator name'; $fields['allocatedmoderatorusername'] = 'Allocated moderator username'; } @@ -72,4 +92,4 @@ public function get_header($stage){ return $fields; } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/name_cell.php b/classes/export/csv/cells/name_cell.php index da45f97b..23b4b17a 100644 --- a/classes/export/csv/cells/name_cell.php +++ b/classes/export/csv/cells/name_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -15,9 +35,9 @@ 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, $stage_identifier) { - if ($this->can_view_hidden() || $submission->is_published()){ + if ($this->can_view_hidden() || $submission->is_published()) { $name = $student->lastname . ' ' . $student->firstname; } else { $name = get_string('hidden', 'coursework'); @@ -31,7 +51,7 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('studentname', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/otherassessors_cell.php b/classes/export/csv/cells/otherassessors_cell.php index 2594d065..008def5a 100644 --- a/classes/export/csv/cells/otherassessors_cell.php +++ b/classes/export/csv/cells/otherassessors_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -10,8 +30,7 @@ /** * Class otherassessors_cell */ -class otherassessors_cell extends cell_base{ - +class otherassessors_cell extends cell_base { /** * @param submission $submission @@ -19,14 +38,13 @@ 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, $stage_identifier) { global $DB, $USER; // find out current user stage identifier - // $stage_identifier = + // $stage_identifier = // retrieve all feedbacks without currents user feedback - $params = array( 'submissionid' => $submission->id, 'assessorid' => $USER->id, @@ -39,13 +57,13 @@ public function get_cell($submission, $student, $stage_identifier){ AND stage_identifier <> 'final_agreed_1'"; $feedbacks = $DB->get_records_sql($sql, $params); - $gradedata = array(); + $gradedata = []; // $stage_identifier = ($this->coursework->get_max_markers() == 1) ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student); - foreach($feedbacks as $feedback){ + foreach ($feedbacks as $feedback) { $grade = $submission->get_assessor_feedback_by_stage($feedback->stage_identifier); - if ($grade){ + 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; @@ -53,7 +71,7 @@ public function get_cell($submission, $student, $stage_identifier){ 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()){ + if ($this->coursework->is_using_rubric()) { $this->get_rubric_scores_gradedata($grade, $gradedata); // multiple parts are handled here } else { $gradedata[] = $this->get_actual_grade($grade->grade); @@ -66,16 +84,15 @@ public function get_cell($submission, $student, $stage_identifier){ $gradedata[] = ''; } - } else { - if($this->coursework->is_using_rubric()){ + 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'] = ''; } - }else { + } else { $gradedata[] = ''; } $gradedata[] = ''; @@ -83,13 +100,13 @@ public function get_cell($submission, $student, $stage_identifier){ } - $numothereassessorfeedbacks = $submission->max_number_of_feedbacks() -1; + $numothereassessorfeedbacks = $submission->max_number_of_feedbacks() - 1; - if ($numothereassessorfeedbacks - count($feedbacks) != 0 ) { + if ($numothereassessorfeedbacks - count($feedbacks) != 0 ) { - $blankcolumns = $numothereassessorfeedbacks - count($feedbacks); + $blankcolumns = $numothereassessorfeedbacks - count($feedbacks); - for($i = 0; $i < $blankcolumns; $i++) { + for ($i = 0; $i < $blankcolumns; $i++) { 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 @@ -113,11 +130,11 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { - $fields = array(); + $fields = []; - for ($i = 1; $i < $this->stages ; $i++) { + for ($i = 1; $i < $this->stages; $i++) { 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 @@ -132,6 +149,4 @@ public function get_header($stage){ return $fields; } - - -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/personaldeadline_cell.php b/classes/export/csv/cells/personaldeadline_cell.php index 02c455ae..e77dc73d 100644 --- a/classes/export/csv/cells/personaldeadline_cell.php +++ b/classes/export/csv/cells/personaldeadline_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -13,10 +33,10 @@ 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, $stage_identifier) { $personal_deadline = $submission->submission_personal_deadline(); - + return userdate($personal_deadline, $this->dateformat); } @@ -25,8 +45,8 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('personal_deadline', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/plagiarismflagcomment_cell.php b/classes/export/csv/cells/plagiarismflagcomment_cell.php index 24952a62..f7a93314 100644 --- a/classes/export/csv/cells/plagiarismflagcomment_cell.php +++ b/classes/export/csv/cells/plagiarismflagcomment_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; @@ -13,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, $stage_identifier) { if ($this->plagiarism_flagged($submission)) { $flag = $this->get_plagiarism_flag_comment_for_csv($submission); @@ -28,8 +48,8 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('plagiarismcomment', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/plagiarismflagstatus_cell.php b/classes/export/csv/cells/plagiarismflagstatus_cell.php index 801f6280..fdb399e7 100644 --- a/classes/export/csv/cells/plagiarismflagstatus_cell.php +++ b/classes/export/csv/cells/plagiarismflagstatus_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; @@ -13,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, $stage_identifier) { if ($this->plagiarism_flagged($submission)) { $flag = $this->get_plagiarism_flag_status_for_csv($submission); @@ -28,8 +48,8 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('plagiarismstatus', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/singlegrade_cell.php b/classes/export/csv/cells/singlegrade_cell.php index 42e7563c..22c2d721 100644 --- a/classes/export/csv/cells/singlegrade_cell.php +++ b/classes/export/csv/cells/singlegrade_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -10,8 +30,7 @@ /** * Class singlegrade_cell */ -class singlegrade_cell extends cell_base{ - +class singlegrade_cell extends cell_base { /** * @param $submission @@ -19,16 +38,16 @@ 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, $stage_identifier) { $stage_identifier = ($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); - if($this->coursework->is_using_rubric()){ - $gradedata = array(); + if ($this->coursework->is_using_rubric()) { + $gradedata = []; $this->get_rubric_scores_gradedata($grade, $gradedata); // multiple parts are handled here } else { - $gradedata = (!$grade)? '': $this->get_actual_grade($grade->grade); + $gradedata = (!$grade) ? '' : $this->get_actual_grade($grade->grade); } return $gradedata; @@ -39,14 +58,14 @@ public function get_cell($submission, $student, $stage_identifier){ * @return array|mixed|string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { if ($this->coursework->is_using_rubric()) { - $strings = array(); + $strings = []; $criterias = $this->coursework->get_rubric_criteria(); foreach ($criterias as $criteria) { // rubrics can have multiple parts, so let's create header for each of it $strings['singlegrade'.$criteria['id']] = $criteria['description']; - $strings['singlegrade'.$criteria['id'].'comment'] = 'Comment for: '.$criteria['description'] ; + $strings['singlegrade'.$criteria['id'].'comment'] = 'Comment for: '.$criteria['description']; } } else { $strings = get_string('grade', 'coursework'); @@ -54,19 +73,18 @@ public function get_header($stage){ return $strings; } - - public function validate_cell($value,$submissionid,$stage_identifier='',$uploadedgradecells = array()) { + public function validate_cell($value, $submissionid, $stage_identifier='', $uploadedgradecells = []) { global $PAGE, $DB, $USER; if (has_capability('mod/coursework:addinitialgrade', $PAGE->context) || has_capability('mod/coursework:editinitialgrade', $PAGE->context) - || has_capability('mod/coursework:administergrades', $PAGE->context)) { + || has_capability('mod/coursework:administergrades', $PAGE->context)) { - $errormsg = ''; + $errormsg = ''; if (!empty($value) && !$this->coursework->is_using_rubric()) { $gradejudge = new grade_judge($this->coursework); - if (!$gradejudge->grade_in_scale($value)){ + if (!$gradejudge->grade_in_scale($value)) { $errormsg = get_string('valuenotincourseworkscale', 'coursework'); if (is_numeric($value)) { // if scale is numeric get max allowed scale @@ -75,14 +93,13 @@ public function validate_cell($value,$submissionid,$stage_identifier='',$uploade } } else { + // We won't be processing this line if it has no values, empty wont tell us this as it thinks that an array with + // Keys isnt. We will use array_filter whhich will return all values from the array if this is empty then we have + // Nothing to do - //we won't be processing this line if it has no values, empty wont tell us this as it thinks that an array with - //keys isnt. We will use array_filter whhich will return all values from the array if this is empty then we have - //nothing to do - - $arrayvalues = array_filter($value); + $arrayvalues = array_filter($value); - //if there are no values we don't need to do anything + // If there are no values we don't need to do anything if (!empty($arrayvalues)) { $i = 0; @@ -92,15 +109,15 @@ public function validate_cell($value,$submissionid,$stage_identifier='',$uploade foreach ($value as $data) { - //check if the value is empty however it can be 0 + // Check if the value is empty however it can be 0 if (empty($data) && $data != 0) { $errormsg .= ' ' . get_string('rubric_grade_cannot_be_empty', 'coursework'); } - //only check grades fields that will be even numbered + // Only check grades fields that will be even numbered if ($i % 2 == 0) { - //get the current criteria + // Get the current criteria $criteria = array_shift($criterias); //lets check if the value given is valid for the current rubric criteria @@ -116,44 +133,39 @@ public function validate_cell($value,$submissionid,$stage_identifier='',$uploade } - if (!empty($errormsg)) return $errormsg; + $dbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); - $dbrecord = $DB->get_record('coursework_submissions', array('id'=>$submissionid)); + $submission = \mod_coursework\models\submission::find($dbrecord); - $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'); - //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 you have administer grades you can grade anything + // If you have administer grades you can grade anything 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)) - return get_string('nopermissiontogradesubmission','coursework'); + // 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)) + return get_string('nopermissiontogradesubmission', 'coursework'); - //has the submission been published if yes then no further grades are allowed + // Has the submission been published if yes then no further grades are allowed 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). + // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). $feedback_params = array( 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, ); $feedback = feedback::find($feedback_params); - if (!$this->coursework->allocation_enabled() && !empty($feedback)) { - //was this user the one who last graded this submission if not then user cannot grade + 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)) - return get_string('nopermissiontoeditgrade','coursework'); + return get_string('nopermissiontoeditgrade', 'coursework'); } - - - $ability = new ability(user::find($USER), $this->coursework); $feedback_params = array( @@ -162,7 +174,7 @@ public function validate_cell($value,$submissionid,$stage_identifier='',$uploade ); $feedback = feedback::find($feedback_params); - //if (!$ability->can('edit',$feedback)) return get_string('nopermissiontoeditgrade','coursework'); + //if (!$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework'); //does a feedback exist for this stage if (empty($feedback)) { @@ -174,12 +186,11 @@ public function validate_cell($value,$submissionid,$stage_identifier='',$uploade ); $new_feedback = feedback::build($feedback_params); - - //this is a new feedback check it against the new ability checks - if (!$ability->can('new',$new_feedback)) return get_string('nopermissiontogradesubmission','coursework'); + // This is a new feedback check it against the new ability checks + if (!$ability->can('new', $new_feedback)) 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'); + // This is a new feedback check it against the edit ability checks + if (!$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework'); } } else { @@ -196,13 +207,13 @@ public function validate_cell($value,$submissionid,$stage_identifier='',$uploade * @param $value the value that should be checked to see if it is valid * @return bool */ - function value_in_rubric($criteria, $value) { + function value_in_rubric($criteria, $value) { global $DB; - $valuefound = false; + $valuefound = false; - $levels = $criteria['levels']; + $levels = $criteria['levels']; if (is_numeric($value) ) { foreach ($levels as $level) { @@ -216,7 +227,6 @@ function value_in_rubric($criteria, $value) { } } - return $valuefound; } @@ -227,40 +237,34 @@ function value_in_rubric($criteria, $value) { * @param $csv_cells * */ - function get_rubrics($coursework,$csv_cells) { - + function get_rubrics($coursework, $csv_cells) { if ($coursework->is_using_rubric()) { - $rubricheaders = array(); + $rubricheaders = []; $criterias = $coursework->get_rubric_criteria(); - foreach ($criterias as $criteria) { - $rubricheaders[] = $criteria['description']; - $rubricheaders[] = $criteria['description']." comment"; + foreach ($criterias as $criteria) { + $rubricheaders[] = $criteria['description']; + $rubricheaders[] = $criteria['description']." comment"; } + // Find out the position of singlegrade + $position = array_search('singlegrade', $csv_cells); + // Get all data from the position of the singlegrade to the length of rubricheaders + // $csv_cells = array_splice($csv_cells,5, 1, $rubricheaders); - //find out the position of singlegrade - $position = array_search('singlegrade',$csv_cells); - //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); - - $cells = array_merge($start_cells,$rubricheaders); - - $cells = array_merge($cells,$end_cells); + $start_cells = array_slice($csv_cells, 0, $position, true); + $end_cells = array_slice($csv_cells, $position + 1, count($csv_cells), true); + $cells = array_merge($start_cells, $rubricheaders); + $cells = array_merge($cells, $end_cells); } - return $cells; } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/stages_cell.php b/classes/export/csv/cells/stages_cell.php index cd2e7c1c..aa595648 100644 --- a/classes/export/csv/cells/stages_cell.php +++ b/classes/export/csv/cells/stages_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -14,7 +34,7 @@ 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, $stage_identifier) { global $DB; $timecreated = 0; @@ -26,11 +46,9 @@ public function get_cell($submission, $student, $stage_identifier){ $timemodified = $feedback->timemodified; } - - - $gradedata = array(); + $gradedata = []; // go through each stage and get a grade, if grade not present then put a placeholder - for ($i = 1; $i <= $this->stages; $i++){ + for ($i = 1; $i <= $this->stages; $i++) { $stage_identifier = 'assessor_'.$i; $grade = $submission->get_assessor_feedback_by_stage($stage_identifier); @@ -39,7 +57,7 @@ public function get_cell($submission, $student, $stage_identifier){ if ($allocation) { $gradedata[] = $this->get_assessor_name($allocation->assessorid); $gradedata[] = $this->get_assessor_username($allocation->assessorid); - } else if ($i != 1 && $this->coursework->sampling_enabled() && !$submission->sampled_feedback_exists()){ + } else if ($i != 1 && $this->coursework->sampling_enabled() && !$submission->sampled_feedback_exists()) { $gradedata[] = get_string('notincludedinsample', 'mod_coursework'); $gradedata[] = get_string('notincludedinsample', 'mod_coursework'); } else { @@ -48,11 +66,11 @@ public function get_cell($submission, $student, $stage_identifier){ } } - if($this->coursework->is_using_advanced_grading() && $this->coursework->is_using_rubric()){ + if ($this->coursework->is_using_advanced_grading() && $this->coursework->is_using_rubric()) { $this->get_rubric_scores_gradedata($grade, $gradedata); } - if ($grade){ + if ($grade) { $gradedata[] = $this->get_actual_grade($grade->grade); $gradedata[] = $this->get_assessor_name($grade->assessorid); $gradedata[] = $this->get_assessor_username($grade->assessorid); @@ -67,8 +85,8 @@ public function get_cell($submission, $student, $stage_identifier){ if ($this->stages >= 2) { // if there are two or more stages for a submission, we will have agreed grade $grade = $submission->get_assessor_feedback_by_stage('final_agreed_1'); - if($this->coursework->is_using_advanced_grading() && $this->coursework->is_using_rubric()){ - if($this->coursework->is_using_advanced_grading()){ + if ($this->coursework->is_using_advanced_grading() && $this->coursework->is_using_rubric()) { + if ($this->coursework->is_using_advanced_grading()) { $this->get_rubric_scores_gradedata($grade, $gradedata); } } @@ -83,7 +101,6 @@ public function get_cell($submission, $student, $stage_identifier){ $gradedata[] = $submission->get_agreed_grade() == false ? '' : $this->get_assessor_username($submission->get_agreed_grade()->lasteditedbyuser); } - $gradedata[] = $submission->get_agreed_grade() == false ? '' : userdate($submission->get_agreed_grade()->timemodified, $this->dateformat); } @@ -95,9 +112,9 @@ public function get_cell($submission, $student, $stage_identifier){ * @return array * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { - $fields = array(); + $fields = []; for ($i = 1; $i <= $this->stages; $i++) { if ($this->coursework->allocation_enabled()) { @@ -105,9 +122,9 @@ public function get_header($stage){ $fields['allocated' . $i . 'userame'] = 'Allocated assessor ' . $i . ' username'; } - if ($this->coursework->is_using_advanced_grading() && $this->coursework->is_using_rubric()){ + if ($this->coursework->is_using_advanced_grading() && $this->coursework->is_using_rubric()) { $criteria = $this->coursework->get_rubric_criteria(); - foreach ($criteria as $id => $record){ + foreach ($criteria as $id => $record) { $fields['assessor' .$i. 'description' . $id] = 'Assessor '. $i . ' - '.$record['description']; $fields['assessor' .$i. 'description' . $id . 'comment'] = 'Comment for: Assessor '. $i . ' - '.$record['description']; } @@ -120,9 +137,9 @@ public function get_header($stage){ } if ($this->stages >= 2) { // if there are two or more stages for a submission, we will have agreed grade - if($this->coursework->is_using_advanced_grading() && $this->coursework->is_using_rubric()){ + if ($this->coursework->is_using_advanced_grading() && $this->coursework->is_using_rubric()) { $criteria = $this->coursework->get_rubric_criteria(); - foreach ($criteria as $id => $record){ + foreach ($criteria as $id => $record) { $fields['agreedgrade_description_' . $id] = 'Agreed grade - '.$record['description']; $fields['agreedgrade_description_' . $id. 'comment'] = 'Comment for: Agreed grade - '.$record['description']; } @@ -137,10 +154,4 @@ public function get_header($stage){ return $fields; } - - - - - - -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/submissiondate_cell.php b/classes/export/csv/cells/submissiondate_cell.php index a1293316..cf173e10 100644 --- a/classes/export/csv/cells/submissiondate_cell.php +++ b/classes/export/csv/cells/submissiondate_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -8,14 +28,13 @@ */ class submissiondate_cell extends cell_base { - /** * @param submission $submission * @param $student * @param $stage_identifier * @return string */ - public function get_cell($submission, $student, $stage_identifier){ + public function get_cell($submission, $student, $stage_identifier) { return userdate($submission->time_submitted(), $this->dateformat); } @@ -24,8 +43,8 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('submissiondate', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/submissionfileid_cell.php b/classes/export/csv/cells/submissionfileid_cell.php index fa73c56b..36b014b2 100644 --- a/classes/export/csv/cells/submissionfileid_cell.php +++ b/classes/export/csv/cells/submissionfileid_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; @@ -13,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, $stage_identifier) { return $this->coursework->get_username_hash($submission->allocatableid); } @@ -22,24 +42,24 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('submissionfileid', 'coursework'); } - public function validate_cell($value,$submissionid,$stage_dentifier='',$uploadedgradecells = array()) { + public function validate_cell($value, $submissionid, $stage_dentifier='', $uploadedgradecells = []) { global $DB; - if (empty($value)) { + if (empty($value)) { return 'No submission hash value entered'; } - $subdbrecord = $DB->get_record('coursework_submissions',array('id'=>$submissionid)); + $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); $submission = \mod_coursework\models\submission::find($subdbrecord); - $hash = $this->coursework->get_username_hash($submission->allocatableid); + $hash = $this->coursework->get_username_hash($submission->allocatableid); - return ($value == $hash) ? true : get_string('submissionnotfound','coursework'); + return ($value == $hash) ? true : get_string('submissionnotfound', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/submissionid_cell.php b/classes/export/csv/cells/submissionid_cell.php index 4d236f5a..228cae80 100644 --- a/classes/export/csv/cells/submissionid_cell.php +++ b/classes/export/csv/cells/submissionid_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; @@ -13,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, $stage_identifier) { return $submission->id; } @@ -22,13 +42,14 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('submissionid', 'coursework'); } - public function validate_cell($value,$submissionid,$stage_dentifier='',$uploadedgradecells = array()) { + public function validate_cell($value, $submissionid, $stage_dentifier = '', $uploadedgradecells = []) { global $DB; - return ($DB->record_exists('coursework_submissions',array('id'=>$submissionid,'courseworkid'=>$this->coursework->id()))) ? true: get_string('submissionnotfoundincoursework','coursework'); + return $DB->record_exists('coursework_submissions', array('id' => $submissionid, 'courseworkid' => $this->coursework->id())) + ? true + : get_string('submissionnotfoundincoursework', 'coursework'); } - -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/submissiontime_cell.php b/classes/export/csv/cells/submissiontime_cell.php index 0ed18839..a7452bdf 100644 --- a/classes/export/csv/cells/submissiontime_cell.php +++ b/classes/export/csv/cells/submissiontime_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; @@ -7,14 +27,13 @@ */ class submissiontime_cell extends cell_base { - /** * @param $submission * @param $student * @param $stage_identifier * @return string */ - public function get_cell($submission, $student, $stage_identifier){ + public function get_cell($submission, $student, $stage_identifier) { return $this->submission_time($submission); } @@ -23,10 +42,9 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('submissiontime', 'coursework'); } - -} \ No newline at end of file +} diff --git a/classes/export/csv/cells/username_cell.php b/classes/export/csv/cells/username_cell.php index 9869cd40..fa4ce0cc 100644 --- a/classes/export/csv/cells/username_cell.php +++ b/classes/export/csv/cells/username_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export\csv\cells; use mod_coursework\models\submission; @@ -15,9 +35,9 @@ 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, $stage_identifier) { - if ($this->can_view_hidden() || $submission->is_published()){ + if ($this->can_view_hidden() || $submission->is_published()) { $username = $student->username; } else { $username = get_string('hidden', 'coursework'); @@ -31,8 +51,8 @@ public function get_cell($submission, $student, $stage_identifier){ * @return string * @throws \coding_exception */ - public function get_header($stage){ + public function get_header($stage) { return get_string('studentusername', 'coursework'); } -} \ No newline at end of file +} diff --git a/classes/export/grading_sheet.php b/classes/export/grading_sheet.php index d520d2cb..d3ce543d 100644 --- a/classes/export/grading_sheet.php +++ b/classes/export/grading_sheet.php @@ -14,6 +14,11 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\export; use mod_coursework\export\csv; @@ -22,11 +27,9 @@ use mod_coursework\ability; use mod_coursework\models\coursework; -class grading_sheet extends csv{ +class grading_sheet extends csv { - - - public function get_submissions($groupid = null, $selected_submission_ids = ''){ + public function get_submissions($groupid = null, $selected_submission_ids = '') { global $PAGE, $USER; $params = array( 'courseworkid' => $this->coursework->id @@ -36,25 +39,24 @@ public function get_submissions($groupid = null, $selected_submission_ids = ''){ // remove unfinalised submissions foreach ($submissions as $submission) { - if ($submission->get_state() < $submission::FINALISED){ + if ($submission->get_state() < $submission::FINALISED) { unset($submissions[$submission->id]); } } - if (is_siteadmin($USER->id)){ + if (is_siteadmin($USER->id)) { return $submissions; } $ability = new ability(user::find($USER), $this->coursework); - if (!has_capability('mod/coursework:administergrades', $PAGE->context)) { /** * @var submission[] $submissions */ foreach ($submissions as $submission) { - $stage_identifiers = array(); + $stage_identifiers = []; // remove all submissions that a user is not supposed to see // double marking not allocated @@ -74,12 +76,12 @@ public function get_submissions($groupid = null, $selected_submission_ids = ''){ } } // check if any of the submissions still requires marking - for ($i = 0; $i < sizeof($stage_identifiers); $i++) { + 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; - } elseif ($i + 1 < sizeof($stage_identifiers)) { + } else if ($i + 1 < count($stage_identifiers)) { continue; } // if the last submission was already marked remove it from the array @@ -87,8 +89,8 @@ public function get_submissions($groupid = null, $selected_submission_ids = ''){ } } - //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?? + // 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)) @@ -118,11 +120,11 @@ public function get_submissions($groupid = null, $selected_submission_ids = ''){ * @param submission $submission * @return array */ - public function add_csv_data($submission){ + public function add_csv_data($submission) { - $csv_data = array(); + $csv_data = []; // groups - if ($this->coursework->is_configured_to_have_group_submissions()){ + 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); @@ -139,20 +141,19 @@ public function add_csv_data($submission){ return $csv_data; } - /** * Put together cells that will be used in the csv file * @param coursework $coursework * @return array * @throws \coding_exception */ - public static function cells_array($coursework){ + public static function cells_array($coursework) { global $PAGE; // headers and data for csv - $csv_cells = array('submissionid','submissionfileid'); + $csv_cells = array('submissionid', 'submissionfileid'); - if ($coursework->is_configured_to_have_group_submissions()){ + if ($coursework->is_configured_to_have_group_submissions()) { $csv_cells[] = 'group'; } else { $csv_cells[] = 'name'; @@ -164,8 +165,8 @@ public static function cells_array($coursework){ // 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++) { + && $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) @@ -178,31 +179,30 @@ public static function cells_array($coursework){ $csv_cells[] = 'agreedgrade'; $csv_cells[] = 'agreedfeedback'; - } else if (has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && $coursework->get_max_markers() >1){ + } else if (has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && $coursework->get_max_markers() > 1) { $csv_cells[] = 'singlegrade'; $csv_cells[] = 'feedbackcomments'; - //other grades + // Other grades $csv_cells[] = 'otherassessors'; $csv_cells[] = 'agreedgrade'; $csv_cells[] = 'agreedfeedback'; } else if (has_capability('mod/coursework:addinitialgrade', $PAGE->context) - || has_capability('mod/coursework:administergrades', $PAGE->context)){ + || has_capability('mod/coursework:administergrades', $PAGE->context)) { - // if (!$coursework->is_using_rubric()) { + // if (!$coursework->is_using_rubric()) { $csv_cells[] = 'singlegrade'; - /* } else { + /* } else { $criterias = $coursework->get_rubric_criteria(); - foreach ($criterias as $criteria) { - $csv_cells[] = $criteria['description']; - $csv_cells[] = $criteria['description']." comment"; + foreach ($criterias as $criteria) { + $csv_cells[] = $criteria['description']; + $csv_cells[] = $criteria['description']." comment"; } - } */ $csv_cells[] = 'feedbackcomments'; diff --git a/classes/export/import.php b/classes/export/import.php index b79aeb6a..bc8e10e7 100644 --- a/classes/export/import.php +++ b/classes/export/import.php @@ -1,4 +1,25 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\export; use mod_coursework\export\csv; use mod_coursework\grade_judge; @@ -9,20 +30,12 @@ global $CFG; require_once($CFG->libdir . '/csvlib.class.php'); +class import extends grading_sheet { - - - -class import extends grading_sheet{ - - - public function validate_submissionfileid(){ - + public function validate_submissionfileid() { $submissions = $this->get_submissions(); - - } /** @@ -36,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, $csv_cells) { global $DB, $USER; @@ -50,7 +63,6 @@ public function validate_csv($content,$encoding,$delimeter,$csv_cells) { print_error('csvloaderror', '', 'returnurl', $csvloaderror); } - $columns = $csvreader->get_columns(); if (empty($columns)) { @@ -61,14 +73,11 @@ public function validate_csv($content,$encoding,$delimeter,$csv_cells) { $csvreader->init(); - $errors = array(); + $errors = []; $s = 0; $submissions = $this->get_submissions(); - - - while ($line = $csvreader->next()) { $csv = $this->remove_other_assessors_grade($csv_cells, $line); @@ -77,73 +86,67 @@ public function validate_csv($content,$encoding,$delimeter,$csv_cells) { $i = 0; - $id = false; $submissionid = false; - // if the csv headers count is different than expected return error - if ((!$this->coursework->is_using_rubric() && sizeof($line) != sizeof($cells)) || ($this->coursework->is_using_rubric() && !$this->rubric_count_correct($cells,$line))) {$errors = get_string('incorrectfileformat', 'coursework'); break;} - - $offset = 0; + 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;} - //holds details on grades that have been successfully uploaded for the current line - $uploadedgradecells = array(); + $offset = 0; + // Holds details on grades that have been successfully uploaded for the current line + $uploadedgradecells = []; - for($z = 0; $z < count($line); $z++) { + for ($z = 0; $z < count($line); $z++) { - $value = $line[$z]; - $stage_identifier = $this->get_stage_identifier($submissionid,$cells[$i]); + $value = $line[$z]; + $stage_identifier = $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'){ + if (substr($cells[$i], 0, 8) == 'assessor') { $cells[$i] = substr($cells[$i], 0, -1); } $class = "mod_coursework\\export\\csv\\cells\\".$cells[$i]."_cell"; $cell = new $class($this->coursework); - //submission id field should always be first in the csv_cells array + // Submission id field should always be first in the csv_cells array // - if ($cells[$i] == 'submissionid') { - $submissionid = $value; + if ($cells[$i] == 'submissionid') { + $submissionid = $value; } - 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 + 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 if (($cells[$i] == "singlegrade" || $cells[$i] == "assessorgrade" || $cells[$i] == "agreedgrade") && $this->coursework->is_using_rubric() && !($cells[$i] == "agreedgrade" && $this->coursework->finalstagegrading == 1)) { - //get the headers that would contain the rubric grade data - $rubricheaders = $cell->get_header(null); + // Get the headers that would contain the rubric grade data + $rubricheaders = $cell->get_header(null); - //find out the position of singlegrade + // Find out the position of singlegrade $position = $i; - //get all data from the position of the grade to the length of rubricheaders - $rubriclinedata = array_slice($line,$position + $offset, count($rubricheaders), true); + // Get all data from the position of the grade to the length of rubricheaders + $rubriclinedata = array_slice($line, $position + $offset, count($rubricheaders), true); - //pass the rubric data in + // Pass the rubric data in $result = $cell->validate_cell($rubriclinedata, $submissionid, $stage_identifier, $uploadedgradecells); - $z = $z + count($rubricheaders)-1; - $offset = $offset + count($rubricheaders)-1; + $z = $z + count($rubricheaders) - 1; + $offset = $offset + count($rubricheaders)-1; - } else { + } else { $result = $cell->validate_cell($value, $submissionid, $stage_identifier, $uploadedgradecells); } - - if ($result !== true) { + if ($result !== true) { $errors[$s] = $result; - break; //go to next line on error + break; // Go to next line on error } else if ($cells[$i] == "singlegrade" || $cells[$i] == "assessorgrade" || $cells[$i] == "agreedgrade" && !empty($value)) { - $uploadedgradecells[] = $stage_identifier; + $uploadedgradecells[] = $stage_identifier; } $i++; @@ -151,49 +154,48 @@ public function validate_csv($content,$encoding,$delimeter,$csv_cells) { $s++; } - return (!empty($errors)) ? $errors : false ; + return (!empty($errors)) ? $errors : false; } - - function rubric_count_correct($csvheader,$linefromimportedcsv) { + 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 = array("singlegrade", "assessorgrade"); if ($this->coursework->finalstagegrading == 0 ) $types[] = "agreedgrade"; - foreach($types as $type) { + foreach ($types as $type) { - $typefound = false; + $typefound = false; - //$typepositions holds the places in the array of all vcolumns with headers that - //match the type e.g a column named singlegrade1 will match a singlegrade type - $typepositions = false; - $i = 0; + // $typepositions holds the places in the array of all vcolumns with headers that + // Match the type e.g a column named singlegrade1 will match a singlegrade type + $typepositions = false; + $i = 0; - foreach($csvheader as $ch) { + foreach ($csvheader as $ch) { - if (strpos($ch,$type) !== false) { + if (strpos($ch, $type) !== false) { - if (empty($typepositions)) $typepositions = array(); + if (empty($typepositions)) $typepositions = []; - $typefound = true; - $typepositions[] = $i; + $typefound = true; + $typepositions[] = $i; //break; } $i++; } - if(!empty($typefound)) { + if (!empty($typefound)) { - //this var is needed to provide an offset so the positions in the array we are looking for + // This var is needed to provide an offset so the positions in the array we are looking for //are correct even after a splice and add is carried out - $offset = 0; + $offset = 0; - foreach($typepositions as $position) { - //if ($position = array_search($type,$csvheader)) { + foreach ($typepositions as $position) { + //if ($position = array_search($type, $csvheader)) { $class = "mod_coursework\\export\\csv\\cells\\{$type}_cell"; $cell = new $class($this->coursework); @@ -201,14 +203,13 @@ 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('')); -// } +// } $offset = $offset + count($headers) - 1; - $expectedsize = (int)sizeof($csvheader); - $actualsize = (int)sizeof($linefromimportedcsv); - + $expectedsize = (int)count($csvheader); + $actualsize = (int)count($linefromimportedcsv); } @@ -217,18 +218,17 @@ function rubric_count_correct($csvheader,$linefromimportedcsv) { return $expectedsize != $actualsize ? false : true; - } } - function get_rubric_headers($csvheader) { + 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 = array("singlegrade", "assessorgrade"); - foreach($types as $type) { + foreach ($types as $type) { if ($position = array_search($type, $csvheader)) { @@ -243,13 +243,11 @@ function get_rubric_headers($csvheader) { } } - } return $csvheader; } - /** * Process csv and add records to the DB * @@ -261,7 +259,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, $csv_cells, $processingresults) { global $DB, $PAGE, $USER; @@ -275,7 +273,6 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces print_error('csvloaderror', '', 'returnurl', $csvloaderror); } - $columns = $csvreader->get_columns(); if (empty($columns)) { @@ -288,251 +285,222 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces $s = 0; - $submissionid = false; while ($line = $csvreader->next()) { - //we will not process the content of any line that has been flagged up with an error - if ( is_array($processingresults) && array_key_exists($s,$processingresults) ) { + // We will not process the content of any line that has been flagged up with an error + if ( is_array($processingresults) && array_key_exists($s, $processingresults) ) { $s++; continue; } - - - $csv = $this->remove_other_assessors_grade($csv_cells, $line); - //gets the headers that should be being used in the uploaded csv + // Gets the headers that should be being used in the uploaded csv //$cells = $this->get_rubric_headers($csv); $cells = $csv; $i = 0; - $csvline = array(); + $csvline = []; - - //if ((!$this->coursework->is_using_rubric() && sizeof($line) != sizeof($cells)) || ($this->coursework->is_using_rubric() && !$this->rubric_count_correct($csv,$line))) { - //if (sizeof($line) != sizeof($cells)) { - if ((!$this->coursework->is_using_rubric() && sizeof($line) != sizeof($cells)) || ($this->coursework->is_using_rubric() && !$this->rubric_count_correct($csv,$line))) { + //if ((!$this->coursework->is_using_rubric() && count($line) != count($cells)) || ($this->coursework->is_using_rubric() && !$this->rubric_count_correct($csv, $line))) { + //if (count($line) != count($cells)) { + if ((!$this->coursework->is_using_rubric() && count($line) != count($cells)) || ($this->coursework->is_using_rubric() && !$this->rubric_count_correct($csv, $line))) { $errors = get_string('incorrectfileformat', 'coursework'); break; } - $idfound = false; + $idfound = false; foreach ($line as $keynum => $value) { - if (empty($idfound) && $cells[$i] == 'submissionid') { - $submissionid = $value; - $idfound = true; + if (empty($idfound) && $cells[$i] == 'submissionid') { + $submissionid = $value; + $idfound = true; } - //save the value into the csvline with the relevant pointer + // Save the value into the csvline with the relevant pointer if (isset($cells[$i])) $csvline[$cells[$i]] = $value; $i++; } - $subdbrecord = $DB->get_record('coursework_submissions', array('id'=>$submissionid)); + $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); $submission = \mod_coursework\models\submission::find($subdbrecord); + // Is this submission graded? if yes did this user grade it? - //is this submission graded? if yes did this user grade it? - + $coursework = $submission->get_coursework(); - $coursework = $submission->get_coursework(); - - $stages = array(); + $stages = []; if (!$coursework->has_multiple_markers()) { $stages['singlegrade'] = $this->get_stage_identifier($csvline['submissionid'], 'singlegrade'); - if (array_key_exists('agreedgrade',$csvline)) { - $stages['agreedgrade'] = 'final_agreed_1'; + if (array_key_exists('agreedgrade', $csvline)) { + $stages['agreedgrade'] = 'final_agreed_1'; } } else { - 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); - } else if (substr($k,0,11) == 'agreedgrade') { - $stages[$k] = 'final_agreed_1'; + 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); + } else if (substr($k, 0, 11) == 'agreedgrade') { + $stages[$k] = 'final_agreed_1'; } } } - $a = 1; //defines the start offest to be used when searching for a rubric in a uploaded csv, if the format of upload - //csv is changed this will require changing - - $rubricoffset = $rubricoffsetstart = ($coursework->is_configured_to_have_group_submissions()) ? 4 : 5; - + // Csv is changed this will require changing + $rubricoffset = $rubricoffsetstart = ($coursework->is_configured_to_have_group_submissions()) ? 4 : 5; - $numberofstages = count($stages); + $numberofstages = count($stages); - foreach($stages as $k => $stage) { + foreach ($stages as $k => $stage) { - //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; + // 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; } // check for initial grade capability otherwise ignore it if ($stage != 'final_agreed_1' && (!has_capability('mod/coursework:addinitialgrade', $PAGE->context)) && - (!has_capability('mod/coursework:administergrades', $PAGE->context))){ + (!has_capability('mod/coursework:administergrades', $PAGE->context))) { continue; } $grade = $submission->get_assessor_feedback_by_stage($stage); - $feedbackpointer = 'assessorfeedback'.$a; + $feedbackpointer = 'assessorfeedback'.$a; $gradepointer = 'assessorgrade'.$a; if ($k == 'singlegrade') { - $feedbackpointer = 'feedbackcomments'; + $feedbackpointer = 'feedbackcomments'; $gradepointer = 'singlegrade'; } else if ($k == 'agreedgrade') { - $feedbackpointer = 'agreedfeedback'; + $feedbackpointer = 'agreedfeedback'; $gradepointer = 'agreedgrade'; } // if sampling enabled check if this grade should be included in sample - if ($this->coursework->sampling_enabled() && $stage != 'final_agreed_1'){ + 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'){ + if (!$in_sample && $stage != 'assessor_1') { continue; } } - //we need to carry out a further check to see if the coursework is using advanced grades. - //if yes then we may need to generate the grade for the grade pointer as - //they dont have grades - - + // We need to carry out a further check to see if the coursework is using advanced grades. + // If yes then we may need to generate the grade for the grade pointer as + // They dont have grades if ($coursework->is_using_rubric() && !($stage == 'final_agreed_1' && $this->coursework->finalstagegrading == 1)) { - //array that will hold the advanced grade data - $criteriagradedata = array(); - $criteriagradedata['criteria'] = array(); + $criteriagradedata = []; + $criteriagradedata['criteria'] = []; $criterias = $this->coursework->get_rubric_criteria(); $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 + // 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 if ($stage == 'final_agreed_1') { - $stagemultiplier = $numberofstages -1; - - //the calculation below finds the position of the agreed grades in the uploaded csv - + $stagemultiplier = $numberofstages - 1; - $rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier); + // The calculation below finds the position of the agreed grades in the uploaded csv + $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); + $feedbackdata = array_slice($line, $rubricoffset + $numberofrubrics, 1); - $csvline[$feedbackpointer] = $feedbackdata[0]; + $csvline[$feedbackpointer] = $feedbackdata[0]; } else { $rubricdata = array_slice($line, $rubricoffset, $numberofrubrics); - $feedbackdata = array_slice($line, $rubricoffset+$numberofrubrics, 1); + $feedbackdata = array_slice($line, $rubricoffset + $numberofrubrics, 1); - $csvline[$feedbackpointer] = $feedbackdata[0]; + $csvline[$feedbackpointer] = $feedbackdata[0]; - $rubricoffset = $rubricoffset + $numberofrubrics + 1; + $rubricoffset = $rubricoffset + $numberofrubrics + 1; } - - - - $arrayvalues = array_filter($rubricdata); + $arrayvalues = array_filter($rubricdata); 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 + // This assumes that the data in the csv is in the correct criteria order.....it should be foreach ($criterias as $c) { - $criteriagrade = array(); + $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]); - $criteriagrade['levelid'] = $levelid; $criteriagrade['remark'] = $rubricdata[$critidx + 1]; - $criteriagradedata['criteria'][$c['id']] = $criteriagrade; $critidx = $critidx + 2; } } else { - $criteriagradedata = false; + $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; - - //in case there is another rubric to be extracted from the csv set the new value of the rubric offset - + // 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 - } 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(); - $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 - - - $rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier); + // The calculation below finds the position of the agreed grades in the uploaded csv + $rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier); - if ($coursework->allocation_enabled()) $rubricoffset += 1; + if ($coursework->allocation_enabled()) $rubricoffset += 1; $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])) { - $stageusesrubric = ($this->coursework->is_using_rubric() + $stageusesrubric = ($this->coursework->is_using_rubric() && !($stage == 'final_agreed_1' && $this->coursework->finalstagegrading)) ? true : false; if (empty($grade)) { - $cwfeedbackid = $this->add_grade($csvline['submissionid'], $csvline[$k], $csvline[$feedbackpointer], $stage,$stageusesrubric); + $cwfeedbackid = $this->add_grade($csvline['submissionid'], $csvline[$k], $csvline[$feedbackpointer], $stage, $stageusesrubric); } else { $cwfeedbackid = $this->get_coursework_feedback_id($csvline['submissionid'], $stage); @@ -550,13 +518,10 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces $s++; } - return (!empty($errors)) ? $errors : false ; - - + return (!empty($errors)) ? $errors : false; } - /*** * Returns the levelid for the given rubric value * @@ -564,13 +529,13 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces * @param $value the value that we will retrieve the levelid for * @return bool */ - function get_value_rubric_levelid($criteria, $value) { + function get_value_rubric_levelid($criteria, $value) { global $DB; - $idfound = false; + $idfound = false; - $levels = $criteria['levels']; + $levels = $criteria['levels']; if (is_numeric($value) ) { foreach ($levels as $level) { @@ -584,11 +549,9 @@ function get_value_rubric_levelid($criteria, $value) { } } - return $idfound; } - /** * Add grade and feedback record * @@ -598,59 +561,57 @@ 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, $stage_identifier, $uses_rubric=false) { global $DB, $USER; // workout markernumber - if ($stage_identifier == 'assessor_1'){ + if ($stage_identifier == '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)); - $markernumber = $feedbacks +1; + // get all feedbacks and add 1 + $feedbacks = $DB->count_records('coursework_feedbacks', array('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(); - - //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; + $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(); + + // 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; $feedbackid = $DB->insert_record('coursework_feedbacks', $add_grade, true); - if ($uses_rubric) { + if ($uses_rubric) { $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); + // 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; + $add_grade->id = $feedbackid; + $add_grade->grade = $rubricgrade; $DB->update_record('coursework_feedbacks', $add_grade); } - return $feedbackid; } - /** * Get feedbackid of existing feedback * @@ -658,7 +619,7 @@ public function add_grade($submissionid, $grade, $feedback, $stage_identifier,$u * @param $stage_identifier * @return mixed */ - public function get_coursework_feedback_id($submissionid, $stage_identifier){ + public function get_coursework_feedback_id($submissionid, $stage_identifier) { global $DB; $record = $DB->get_record('coursework_feedbacks', array('submissionid' => $submissionid, @@ -676,18 +637,18 @@ 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, $uses_rubric=false) { global $DB, $USER; if (!$uses_rubric) { $gradejudge = new grade_judge($this->coursework); $grade = $gradejudge->get_grade($grade); - } else { + } else { $controller = $this->coursework->get_advanced_grading_active_controller(); - //find out how many criteria there are - $gradinginstance = $controller->get_or_create_instance(0, $USER->id,$cwfeedbackid); - $rubricgrade = $gradinginstance->submit_and_get_grade($grade, $cwfeedbackid); - $grade = $rubricgrade; + // Find out how many criteria there are + $gradinginstance = $controller->get_or_create_instance(0, $USER->id, $cwfeedbackid); + $rubricgrade = $gradinginstance->submit_and_get_grade($grade, $cwfeedbackid); + $grade = $rubricgrade; } @@ -696,7 +657,7 @@ public function edit_grade($cwfeedbackid, $grade, $feedback,$uses_rubric=false){ // update record only if the value of grade or feedback is changed $current_feedback = $DB->get_record('coursework_feedbacks', array('id' => $cwfeedbackid)); - if ($current_feedback->grade != $grade || strip_tags($current_feedback->feedbackcomment) != $feedback){ + if ($current_feedback->grade != $grade || strip_tags($current_feedback->feedbackcomment) != $feedback) { $edit_grade = new \stdClass(); $edit_grade->id = $cwfeedbackid; @@ -727,35 +688,32 @@ 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, $cell_identifier) { global $DB, $USER; - $submission = $DB->get_record('coursework_submissions', array('id'=>$submissionid)); + $submission = $DB->get_record('coursework_submissions', array('id' => $submissionid)); - - $submission = \mod_coursework\models\submission::find($submission); + $submission = \mod_coursework\models\submission::find($submission); // single marked - singlegrade - allocated/notallocated $stage_identifier = 'assessor_1'; - //double marked - singlegrade - allocated - if($this->coursework->get_max_markers()>1 && ($cell_identifier == 'singlegrade' || $cell_identifier == 'feedbackcomments') - && $this->coursework->allocation_enabled()){ + if ($this->coursework->get_max_markers() > 1 && ($cell_identifier == 'singlegrade' || $cell_identifier == 'feedbackcomments') + && $this->coursework->allocation_enabled()) { $dbrecord = $DB->get_record('coursework_allocation_pairs', - array('courseworkid'=>$this->coursework->id, - 'allocatableid'=>$submission->allocatableid, - 'allocatabletype'=>$submission->allocatabletype, + array('courseworkid' => $this->coursework->id, + 'allocatableid' => $submission->allocatableid, + 'allocatabletype' => $submission->allocatabletype, 'assessorid' => $USER->id )); $stage_identifier = $dbrecord->stage_identifier; } - //double marked - singlegrade - notallocated - if($this->coursework->get_max_markers()>1 && ($cell_identifier == 'singlegrade' || $cell_identifier == 'feedbackcomments') - && !$this->coursework->allocation_enabled()){ + if ($this->coursework->get_max_markers() > 1 && ($cell_identifier == 'singlegrade' || $cell_identifier == 'feedbackcomments') + && !$this->coursework->allocation_enabled()) { // if any part of initial submission graded by the user then get stage_identifier from feedback // else workout @@ -766,31 +724,31 @@ public function get_stage_identifier($submissionid,$cell_identifier) { $record = $DB->get_record_sql($sql); if (!empty($record)) { $stage_identifier = $record->stage_identifier; - }else if (!$this->coursework->sampling_enabled()){ //samplings disabled + } else if (!$this->coursework->sampling_enabled()) { // Samplings disabled // workout if any stage is still available $sql = "SELECT count(*) as graded FROM {coursework_feedbacks} WHERE submissionid = $submissionid AND stage_identifier <> 'final_agreed_1'"; $record = $DB->get_record_sql($sql); - if ($this->coursework->get_max_markers()>$record->graded) { - $stage = $record->graded+1; + if ($this->coursework->get_max_markers() > $record->graded) { + $stage = $record->graded + 1; $stage_identifier = 'assessor_' . $stage; } - } else if ($this->coursework->sampling_enabled()){ // samplings enabled - $in_sample = ($subs = $submission->get_submissions_in_sample()) ? sizeof($subs) : 0; - $feedback = $DB->record_exists('coursework_feedbacks', array('submissionid'=>$submissionid, - 'stage_identifier'=>'assessor_1')); + } 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')); // no sample or no feedback for sample yet - if (!$in_sample || ($in_sample && !$feedback)){ + if (!$in_sample || ($in_sample && !$feedback)) { $stage_identifier = '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)); + 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){ + if (!$feedback) { $stage_identifier = $sample->stage_identifier; break; } @@ -800,27 +758,24 @@ public function get_stage_identifier($submissionid,$cell_identifier) { } - // double marked - multiplegrade - allocated/notallocated - if($this->coursework->get_max_markers()>1 && ($cell_identifier != 'singlegrade' && $cell_identifier != 'feedbackcomments')) { + 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)); //$cells[$i] = substr($cells[$i], 0, -1); - } else if(substr($cell_identifier, 0, 6) == 'agreed') { + } else if (substr($cell_identifier, 0, 6) == 'agreed') { $stage_identifier = 'final_agreed_1'; } } - return $stage_identifier; } - /** * Create agreed grade if all initial grade are present * @param $cwfeedbackid */ - public function auto_agreement($cwfeedbackid){ + public function auto_agreement($cwfeedbackid) { global $DB; $feedback = $DB->get_record('coursework_feedbacks', array('id' => $cwfeedbackid)); @@ -836,38 +791,36 @@ public function auto_agreement($cwfeedbackid){ $auto_grader->create_auto_grade_if_rules_match(); } - - public function remove_other_assessors_grade($csv_cells, &$line){ + public function remove_other_assessors_grade($csv_cells, &$line) { $otherassessors = false; - if(in_array('otherassessors', $csv_cells)){ + if (in_array('otherassessors', $csv_cells)) { // find position of otherassesors so we know from which key to unset $key = array_search('otherassessors', $csv_cells); unset($csv_cells[$key]); $othercells = $this->other_assessors_cells(); - if ($this->coursework->is_using_rubric()) { + if ($this->coursework->is_using_rubric()) { $singlegradeposition = array_search('singlegrade', $csv_cells); $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); } - for ($i = $startposition; $i < $startposition+$othercells ; $i++) { + for ($i = $startposition; $i < $startposition+$othercells; $i++) { unset($line[$i]); } - $csv_cells =array_values($csv_cells); + $csv_cells = array_values($csv_cells); $line = array_values($line); } return $csv_cells; - } -} \ No newline at end of file +} diff --git a/classes/feedback_files.php b/classes/feedback_files.php index afbaae5d..87b09a87 100644 --- a/classes/feedback_files.php +++ b/classes/feedback_files.php @@ -19,8 +19,7 @@ /** * Displays the information a student sees when they submit or have submitted work * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -29,7 +28,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Represents the files a student has submitted. */ diff --git a/classes/file_importer.php b/classes/file_importer.php index 576bd3a3..d41f4b5c 100644 --- a/classes/file_importer.php +++ b/classes/file_importer.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework; @@ -8,16 +28,14 @@ defined('MOODLE_INTERNAL') || die(); -class coursework_file_zip_importer { +class coursework_file_zip_importer { - - - public function extract_zip_file($filename,$contextid) { + public function extract_zip_file($filename, $contextid) { global $USER; - //raise_memory_limit(MEMORY_EXTRA); - //@set_time_limit(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME); + // raise_memory_limit(MEMORY_EXTRA); + // @set_time_limit(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME); $packer = get_file_packer('application/zip'); @@ -71,23 +89,22 @@ public function delete_import_files($contextid) { $USER->id); } - /** * Process an uploaded zip file * * @param coursework $coursework * @return string - The html response */ - public function import_zip_files($coursework,$feedbackstage,$overwritecurrent) { + public function import_zip_files($coursework, $feedbackstage, $overwritecurrent) { global $CFG, $PAGE, $DB, $USER; @set_time_limit(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME); - $results = array(); + $results = []; $feedbackfilesupdated = 0; $feedbackfilesadded = 0; - $userswithnewfeedback = array(); + $userswithnewfeedback = []; $contextid = $coursework->get_context_id(); $fs = get_file_storage(); @@ -95,25 +112,24 @@ public function import_zip_files($coursework,$feedbackstage,$overwritecurrent) $participants = $coursework->get_allocatables(); - foreach ($feedbackfiles as $file) { - $filename = $file->get_filename(); + $filename = $file->get_filename(); 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', array('courseworkid' => $coursework->id(), 'allocatableid' => $allocatableid, 'allocatabletype' => $coursework->get_allocatable_type())); - $submission = \mod_coursework\models\submission::find($subdbrecord); + $submission = \mod_coursework\models\submission::find($subdbrecord); if ($submission->get_state() < \mod_coursework\models\submission::PUBLISHED) { - //if only add/edit initial capability then workout stage identifier - if ($feedbackstage == 'initialassessor'){ + // 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', array('submissionid' => $submission->id, 'assessorid' => $USER->id )); - if($feedback){ + if ($feedback) { $feedbackstage = $feedback->stage_identifier; } else { @@ -121,7 +137,6 @@ public function import_zip_files($coursework,$feedbackstage,$overwritecurrent) } } - if ($feedback = $this->feedback_exists($coursework, $submission, $feedbackstage)) { if ($oldfile = $fs->get_file($contextid, @@ -155,7 +170,6 @@ public function import_zip_files($coursework,$feedbackstage,$overwritecurrent) $results[$filename] = get_string('feedbackfilecreated', 'mod_coursework'); } - } else { $results[$filename] = get_string('assessorfeedbacknotfound', 'mod_coursework'); } @@ -164,26 +178,23 @@ public function import_zip_files($coursework,$feedbackstage,$overwritecurrent) } } else { - $results[$filename] = get_string('feedbacknotfound','mod_coursework'); + $results[$filename] = get_string('feedbacknotfound', 'mod_coursework'); } } - //clear up the files that have not been moved to the mod_coursework area + // Clear up the files that have not been moved to the mod_coursework area $this->delete_import_files($contextid); return $results; - } + public function is_valid_feedback_file_filename($coursework, $feedbackfile, $participants) { - public function is_valid_feedback_file_filename($coursework,$feedbackfile,$participants) { - - - $result = false; + $result = false; - $filename = explode('.',$feedbackfile->get_filename()); - $filename = $filename[0]; + $filename = explode('.', $feedbackfile->get_filename()); + $filename = $filename[0]; if ($feedbackfile->is_directory()) { return $result; @@ -198,41 +209,38 @@ public function is_valid_feedback_file_filename($coursework,$feedbackfile,$parti return $result; } - foreach ($participants as $user) { - if ($filename == $coursework->get_username_hash($user->id)) { + foreach ($participants as $user) { + if ($filename == $coursework->get_username_hash($user->id)) { $result = $user->id; break; } } - return $result; } - - public function feedback_exists($coursework,$submission,$stageidentifier) { + public function feedback_exists($coursework, $submission, $stageidentifier) { global $DB, $USER; - $sql = "SELECT * + $sql = "SELECT * FROM {coursework_feedbacks} - WHERE submissionid = :submissionid + WHERE submissionid = :submissionid AND stage_identifier = :stage "; - $params = array('submissionid'=>$submission->id, - 'stage'=>$stageidentifier); + $params = array('submissionid' => $submission->id, + 'stage' => $stageidentifier); - if (!has_capability('mod/coursework:administergrades',$coursework->get_context())) { + if (!has_capability('mod/coursework:administergrades', $coursework->get_context())) { $sql .= "AND (assessorid = :assessorid || lasteditedbyuser = :lasteditedbyuser)"; $params['assessorid'] = $USER->id; $params['lasteditedbyuser'] = $USER->id; } - return $DB->get_record_sql($sql,$params); + return $DB->get_record_sql($sql, $params); } - -} \ No newline at end of file +} diff --git a/classes/files.php b/classes/files.php index 6ab4dfe2..d1504677 100644 --- a/classes/files.php +++ b/classes/files.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework; use Countable; @@ -38,7 +44,7 @@ abstract class files implements countable { /** * @param array $files */ - public function __construct($files = array()) { + public function __construct($files = []) { $this->files = $files; } diff --git a/classes/forms/advance_plugins_form.php b/classes/forms/advance_plugins_form.php index 919519cb..9c2d4932 100644 --- a/classes/forms/advance_plugins_form.php +++ b/classes/forms/advance_plugins_form.php @@ -17,8 +17,7 @@ /** * Creates an mform for final grade * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -48,10 +47,10 @@ public function definition() { $mform =& $this->_form; - $mform->addElement('editor', 'text_element', get_string('comment', 'mod_coursework'), array()); + $mform->addElement('editor', 'text_element', get_string('comment', 'mod_coursework'), []); $mform->setType('editor', PARAM_RAW); - $file_manager_options = array( + $file_manager_options = array( 'subdirs' => false, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL diff --git a/classes/forms/assessor_feedback_mform.php b/classes/forms/assessor_feedback_mform.php index 2ce55c43..fb419e14 100644 --- a/classes/forms/assessor_feedback_mform.php +++ b/classes/forms/assessor_feedback_mform.php @@ -17,8 +17,7 @@ /** * Creates an mform for final grade * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -106,7 +105,7 @@ public function definition() { $mform->addElement('editor', 'feedbackcomment', get_string('comment', 'mod_coursework')); $mform->setType('editor', PARAM_RAW); - $file_manager_options = array( + $file_manager_options = array( 'subdirs' => false, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL @@ -119,7 +118,6 @@ public function definition() { null, $file_manager_options); - $this->add_submit_buttons($coursework->draft_feedback_enabled(), $feedback->id); } @@ -131,26 +129,23 @@ public function get_grading_controller() { return $this->_grading_controller; } - /** * @param $draftenabled */ - public function add_submit_buttons($draftenabled, $feedbackid){ + public function add_submit_buttons($draftenabled, $feedbackid) { - $button_array = array(); + $button_array = []; if ($draftenabled) { $button_array[] = $this->_form->createElement('submit', 'submitfeedbackbutton', get_string('saveasdraft', 'coursework')); } - $button_array[] = $this->_form->createElement('submit', 'submitbutton', get_string('saveandfinalise', 'coursework')); $feedback = $this->_customdata['feedback']; - - $is_published = $feedback->get_submission()->is_published(); + $is_published = $feedback->get_submission()->is_published(); if ($feedbackid && !$is_published) { $button_array[] = $this->_form->createElement('submit', 'removefeedbackbutton', get_string('removefeedback', 'coursework')); @@ -166,7 +161,7 @@ public function add_submit_buttons($draftenabled, $feedbackid){ * @param $data * @return bool */ - public function validate_grade($data){ + public function validate_grade($data) { $result = true; if (!empty($this->_grading_instance) && property_exists($data, 'advancedgrading')) { $result = $this->_grading_instance->validate_grading_element($data->advancedgrading); @@ -199,7 +194,6 @@ public function process_data(feedback $feedback) { $feedback->feedbackcomment = $formdata->feedbackcomment['text']; $feedback->feedbackcommentformat = $formdata->feedbackcomment['format']; - return $feedback; } @@ -236,12 +230,12 @@ public function get_file_options() { $filemanager = $this->_form->getElement('feedback_manager'); if ($filemanager) { $params = (object) [ - 'maxfiles' => $filemanager->getMaxfiles(), - 'subdirs' => $filemanager->getSubdirs(), + 'maxfiles' => $filemanager->getMaxfiles(), + 'subdirs' => $filemanager->getSubdirs(), 'areamaxbytes' => $filemanager->getAreamaxbytes(), - 'target' => 'id_' . $filemanager->getName(), + '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 ee7855d0..78936938 100644 --- a/classes/forms/choose_student_for_submission_mform.php +++ b/classes/forms/choose_student_for_submission_mform.php @@ -54,7 +54,7 @@ protected function definition() { return; } - $options = array(); + $options = []; $allnames = \core_user\fields::get_name_fields(); foreach ($students as $student) { @@ -77,4 +77,4 @@ protected function definition() { $this->add_action_buttons(true, get_string('choosestudent', 'mod_coursework')); } -} \ No newline at end of file +} diff --git a/classes/forms/deadline_extension_form.php b/classes/forms/deadline_extension_form.php index 084c28a0..b6083172 100644 --- a/classes/forms/deadline_extension_form.php +++ b/classes/forms/deadline_extension_form.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\forms; use mod_coursework\models\coursework; @@ -24,16 +44,13 @@ protected function definition() { $this->_form->addElement('hidden', 'id'); $this->_form->settype('id', PARAM_INT); - - if ($this->get_coursework()->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()){ + if ($this->get_coursework()->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()) { $this->_form->addElement('html', '
Personal deadline: '. userdate($personal_deadline->personal_deadline).'
'); } else { // Current deadline for comparison $this->_form->addElement('html', '
Default deadline: ' . userdate($this->get_coursework()->deadline) . '
'); } - - // Date and time picker $this->_form->addElement('date_time_selector', 'extended_deadline', get_string('extended_deadline', 'mod_coursework')); @@ -67,15 +84,13 @@ public function validation($data, $files) { global $CFG; $max_deadline = $CFG->coursework_max_extension_deadline; - - if ($this->get_coursework()->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()){ + if ($this->get_coursework()->personaldeadlineenabled && $personal_deadline = $this->personal_deadline()) { $deadline = $personal_deadline->personal_deadline; } else { $deadline = $this->get_coursework()->deadline; } - - $errors = array(); + $errors = []; if ($data['extended_deadline'] <= $deadline) { $errors['extended_deadline'] = 'The new deadline must be later than the current deadline'; } @@ -85,13 +100,13 @@ public function validation($data, $files) { return $errors; } - public function personal_deadline(){ + public function personal_deadline() { global $DB; - $extensionid = optional_param('id',0, PARAM_INT); + $extensionid = optional_param('id', 0, PARAM_INT); - if($extensionid != 0){ - $ext = $DB->get_record('coursework_extensions', array('id'=>$extensionid)); + if ($extensionid != 0) { + $ext = $DB->get_record('coursework_extensions', array('id' => $extensionid)); $allocatableid = $ext->allocatableid; $allocatabletype = $ext->allocatabletype; $courseworkid = $ext->courseworkid; @@ -100,17 +115,16 @@ public function personal_deadline(){ $allocatableid = required_param('allocatableid', PARAM_INT); $allocatabletype = required_param('allocatabletype', PARAM_ALPHANUMEXT); - $courseworkid = required_param('courseworkid', PARAM_INT); + $courseworkid = required_param('courseworkid', PARAM_INT); } $params = array( 'allocatableid' => $allocatableid, - 'allocatabletype' =>$allocatabletype , - 'courseworkid' =>$courseworkid, + 'allocatabletype' => $allocatabletype , + 'courseworkid' => $courseworkid, ); return $personal_deadline = $DB->get_record('coursework_person_deadlines', $params); } - -} \ No newline at end of file +} diff --git a/classes/forms/general_feedback_form.php b/classes/forms/general_feedback_form.php index 7106ae21..8725a2a2 100644 --- a/classes/forms/general_feedback_form.php +++ b/classes/forms/general_feedback_form.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\forms; use moodleform; diff --git a/classes/forms/moderator_agreement_mform.php b/classes/forms/moderator_agreement_mform.php index 4f14f4a2..9cc67b75 100644 --- a/classes/forms/moderator_agreement_mform.php +++ b/classes/forms/moderator_agreement_mform.php @@ -17,8 +17,7 @@ /** * Creates an mform for moderator agreement * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -66,7 +65,6 @@ public function definition() { $mform->addElement('hidden', 'submissionid', $moderation->get_submission()->id); $mform->setType('submissionid', PARAM_INT); - $mform->addElement('hidden', 'moderatorid', $moderation->moderatorid); $mform->setType('moderatorid', PARAM_INT); @@ -82,19 +80,16 @@ public function definition() { $mform->addElement('hidden', 'courseworkid', $coursework->id); $mform->setType('courseworkid', PARAM_INT); - // moderator agreement - $options = array('agreed'=>get_string('agreed', 'coursework'), 'disagreed'=>get_string('disagreed', 'coursework')); + $options = array('agreed' => get_string('agreed', 'coursework'), 'disagreed' => get_string('disagreed', 'coursework')); $mform->addElement('select', 'agreement', get_string('moderationagreement', 'coursework'), $options, array('id' => 'moderation_agreement')); - $mform->addElement('editor', 'modcomment', get_string('comment', 'mod_coursework'), array('id' => 'moderation_comment')); $mform->setType('editor', PARAM_RAW); - $this->add_action_buttons(); } @@ -114,7 +109,6 @@ public function process_data(moderation $moderation) { $moderation->modcomment = $formdata->modcomment['text']; $moderation->modcommentformat = $formdata->modcomment['format']; - return $moderation; } } diff --git a/classes/forms/personal_deadline_form.php b/classes/forms/personal_deadline_form.php index 78f950f0..73ef6471 100644 --- a/classes/forms/personal_deadline_form.php +++ b/classes/forms/personal_deadline_form.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\forms; use mod_coursework\models\coursework; @@ -28,14 +48,12 @@ protected function definition() { $this->_form->addElement('hidden', 'multipleuserdeadlines'); $this->_form->settype('multipleuserdeadlines', PARAM_INT); - // Current deadline for comparison $this->_form->addElement('html', '
Default deadline: '. userdate($this->get_coursework()->deadline).'
'); // Date and time picker $this->_form->addElement('date_time_selector', 'personal_deadline', get_string('personal_deadline', 'mod_coursework')); - // Submit button $this->add_action_buttons(); } @@ -44,14 +62,13 @@ private function get_coursework() { return $this->_customdata['coursework']; } - /** * @param array $data * @param array $files * @return array */ public function validation($data, $files) { - $errors = array(); + $errors = []; if ($data['personal_deadline'] <= time()) { $errors['personal_deadline'] = 'The new deadline you chose has already passed. Please select appropriate deadline'; } @@ -59,4 +76,4 @@ public function validation($data, $files) { return $errors; } -} \ No newline at end of file +} diff --git a/classes/forms/plagiarism_flagging_mform.php b/classes/forms/plagiarism_flagging_mform.php index 794225e7..b66e8940 100644 --- a/classes/forms/plagiarism_flagging_mform.php +++ b/classes/forms/plagiarism_flagging_mform.php @@ -17,8 +17,7 @@ /** * Creates an mform for moderator agreement * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -44,7 +43,6 @@ class plagiarism_flagging_mform extends moodleform { */ public $submission_id; - /** * Makes the form elements. */ @@ -61,7 +59,7 @@ public function definition() { $mform->setType('submissionid', PARAM_INT); // plagiarism status - $options = array(plagiarism_flag::INVESTIGATION => get_string('plagiarism_'.plagiarism_flag::INVESTIGATION , 'coursework'), + $options = array(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')); diff --git a/classes/forms/publish_form.php b/classes/forms/publish_form.php index 5adca749..8be01f98 100644 --- a/classes/forms/publish_form.php +++ b/classes/forms/publish_form.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\forms; use mod_coursework\grading_report; @@ -38,7 +44,7 @@ public function definition() { $this->_form->addElement('hidden', 'id', $this->_customdata['cmid']); $this->_form->setType('id', PARAM_INT); - $attributes = array(); + $attributes = []; $explaintext = false; $should_release = true; @@ -49,7 +55,7 @@ public function definition() { } else if ($coursework->blindmarking_enabled() && $coursework->has_stuff_to_publish()) { - $allocatable = ($coursework->is_configured_to_have_group_submissions())? 'group' : 'user'; + $allocatable = ($coursework->is_configured_to_have_group_submissions()) ? 'group' : 'user'; $explaintext = '
'.get_string('anonymity_warning_'. $allocatable, 'mod_coursework').'
'; } else if ($coursework->blindmarking_enabled() && diff --git a/classes/forms/student_submission_form.php b/classes/forms/student_submission_form.php index 8c34db3d..ff5bca7f 100644 --- a/classes/forms/student_submission_form.php +++ b/classes/forms/student_submission_form.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -58,7 +57,7 @@ public function definition() { $this->add_hidden_elements_to_form(); // if TII plagiarism enabled check if user agreed/disagreed EULA - if(!$this->get_coursework()->plagiarism_enbled() || has_user_seen_tii_EULA_agreement()) { + if (!$this->get_coursework()->plagiarism_enbled() || has_user_seen_tii_EULA_agreement()) { $this->add_header_to_form(); @@ -176,19 +175,17 @@ public function handle() { if (!$submission->get_coursework()->has_deadline()) { - $userids = explode(',',$submission->get_coursework()->get_submission_notification_users()); + $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))); + foreach ($userids as $u) { + $notifyuser = $DB->get_record('user', array('id' => trim($u))); $mailer = new mailer($coursework); if (!empty($notifyuser)) $mailer->send_submission_notification($notifyuser); } } - - } // Must happen AFTER file attributes have been fiddled with, otherwise we get @@ -230,7 +227,6 @@ public function handle() { } } - /** * Sets the data, tweaking the submission to conform to the form's field names * @@ -264,7 +260,6 @@ public function set_data($submission) { } - /** * @return coursework */ @@ -304,7 +299,7 @@ protected function add_submit_buttons_to_form() { $ability = new ability(user::find($USER), $this->get_coursework()); - $button_array = array(); + $button_array = []; // 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. @@ -359,7 +354,7 @@ protected function add_file_manager_to_form() { $uploadfilestring, null, $this->get_file_manager_options()); - $this->_form->addRule('submission_manager', 'You must upload file(s) into the box below before you can save', 'required', null,'server',false,true); + $this->_form->addRule('submission_manager', 'You must upload file(s) into the box below before you can save', 'required', null, 'server', false, true); } @@ -370,7 +365,7 @@ protected function add_instructions_to_form() { $file_manager_options = $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->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'] != '*') { @@ -387,9 +382,8 @@ protected function add_instructions_to_form() { */ protected function add_header_to_form() { $file_manager_options = $this->get_file_manager_options(); - $files_string = ($file_manager_options['maxfiles'] == 1) ? 'yoursubmissionfile' - : 'yoursubmissionfiles'; - $renamed = ($this->get_coursework()->renamefiles == 1)?get_string('yoursubmissionfile_renamed', 'coursework') : ""; + $files_string = ($file_manager_options['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); @@ -408,7 +402,7 @@ protected function get_file_manager_options() { */ protected function make_plagiarism_instructions() { $plagiarism_helpers = $this->get_coursework()->get_plagiarism_helpers(); - $plagiarism_instructions = array(); + $plagiarism_instructions = []; foreach ($plagiarism_helpers as $helper) { if ($helper->file_submission_instructions()) { $plagiarism_instructions[] = $helper->file_submission_instructions(); diff --git a/classes/forms/upload_allocations_form.php b/classes/forms/upload_allocations_form.php index 503e7a19..795d2847 100644 --- a/classes/forms/upload_allocations_form.php +++ b/classes/forms/upload_allocations_form.php @@ -16,36 +16,33 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2016 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->libdir.'/formslib.php'); - - class upload_allocations_form extends moodleform { private $cmid; - function __construct($cmid) { - $this->cmid = $cmid; + function __construct($cmid) { + $this->cmid = $cmid; parent::__construct(); } - function definition() { + function definition() { $mform =& $this->_form; - $mform->addElement('filepicker', 'allocationsdata', get_string('allocationsfile','coursework'), null, array( 'accepted_types' => '*.csv')); + $mform->addElement('filepicker', 'allocationsdata', get_string('allocationsfile', 'coursework'), null, array( 'accepted_types' => '*.csv')); $mform->addRule('allocationsdata', null, 'required'); - // $mform->addElement('checkbox','overwrite','',get_string('overwritegrades','coursework')); - $mform->addElement('hidden','cmid',$this->cmid); + // $mform->addElement('checkbox', 'overwrite', '', get_string('overwritegrades', 'coursework')); + $mform->addElement('hidden', 'cmid', $this->cmid); - $mform->setType('cmid',PARAM_RAW); + $mform->setType('cmid', PARAM_RAW); $choices = csv_import_reader::get_delimiter_list(); $mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices); @@ -61,12 +58,11 @@ function definition() { $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices); $mform->setDefault('encoding', 'UTF-8'); - - $this->add_action_buttons(true,get_string('uploadallocations','coursework')); + $this->add_action_buttons(true, get_string('uploadallocations', 'coursework')); } - function display() { + function display() { return $this->_form->toHtml(); } -} \ No newline at end of file +} diff --git a/classes/forms/upload_feedback_form.php b/classes/forms/upload_feedback_form.php index 4b01b931..7f49a791 100644 --- a/classes/forms/upload_feedback_form.php +++ b/classes/forms/upload_feedback_form.php @@ -1,49 +1,59 @@ . + /** - * Created by PhpStorm. - * User: Nigel.Daley - * Date: 10/08/2015 - * Time: 18:27 + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - - require_once($CFG->libdir.'/formslib.php'); - - class upload_feedback_form extends moodleform { - private $cmid; - private $coursework; + private $cmid; + private $coursework; - function __construct($coursework, $cmid) { - $this->cmid = $cmid; - $this->coursework = $coursework; + function __construct($coursework, $cmid) { + $this->cmid = $cmid; + $this->coursework = $coursework; parent::__construct(); } - function definition() { + 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, array( 'accepted_types' => '*.zip')); $mform->addRule('feedbackzip', null, 'required'); - $mform->addHelpButton('feedbackzip', 'feedbackzipfile','coursework'); + $mform->addHelpButton('feedbackzip', 'feedbackzipfile', 'coursework'); - $mform->addElement('advcheckbox','overwrite','',get_string('overwritefeedback','coursework'),null,array(0,1)); - $mform->addElement('hidden','cmid',$this->cmid); - $mform->setType('cmid',PARAM_RAW); + $mform->addElement('advcheckbox', 'overwrite', '', get_string('overwritefeedback', 'coursework'), null, array(0, 1)); + $mform->addElement('hidden', 'cmid', $this->cmid); + $mform->setType('cmid', PARAM_RAW); - $options = array(); + $options = []; if ($this->coursework->get_max_markers() > 1) { $capability = array('mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade'); - if (has_any_capability($capability, $this->coursework->get_context()) && !has_capability('mod/coursework:administergrades',$this->coursework->get_context())) { + 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())){ + } 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'); @@ -54,25 +64,24 @@ function definition() { $mform->addElement('select', 'feedbackstage', get_string('feedbackstage', 'coursework'), $options); } else { - $mform->addElement('hidden','feedbackstage','assessor_1'); - $mform->setType('feedbackstage',PARAM_RAW); + $mform->addElement('hidden', 'feedbackstage', 'assessor_1'); + $mform->setType('feedbackstage', PARAM_RAW); } // Disable overwrite current feedback files checkbox if user doesn't have edit capability - if(!has_capability('mod/coursework:editinitialgrade',$this->coursework->get_context())) { + if (!has_capability('mod/coursework:editinitialgrade', $this->coursework->get_context())) { $mform->disabledIf('overwrite', 'feedbackstage', 'eq', 'initialassessor'); } - if(!has_capability('mod/coursework:editagreedgrade',$this->coursework->get_context()) && !has_capability('mod/coursework:administergrades',$this->coursework->get_context()) ) { + if (!has_capability('mod/coursework:editagreedgrade', $this->coursework->get_context()) && !has_capability('mod/coursework:administergrades', $this->coursework->get_context()) ) { $mform->disabledIf('overwrite', 'feedbackstage', 'eq', 'final_agreed_1'); } - - $this->add_action_buttons(true,get_string('uploadfeedbackzip','coursework')); + $this->add_action_buttons(true, get_string('uploadfeedbackzip', 'coursework')); } - function display() { + function display() { return $this->_form->toHtml(); } -} \ No newline at end of file +} diff --git a/classes/forms/upload_grading_sheet_form.php b/classes/forms/upload_grading_sheet_form.php index 564ba116..fd396742 100644 --- a/classes/forms/upload_grading_sheet_form.php +++ b/classes/forms/upload_grading_sheet_form.php @@ -1,37 +1,47 @@ . + /** - * Created by PhpStorm. - * User: Nigel.Daley - * Date: 10/08/2015 - * Time: 18:27 + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - - require_once($CFG->libdir.'/formslib.php'); - - class upload_grading_sheet_form extends moodleform { private $cmid; - function __construct($cmid) { - $this->cmid = $cmid; + function __construct($cmid) { + $this->cmid = $cmid; parent::__construct(); } - function definition() { + 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, array( 'accepted_types' => '*.csv')); $mform->addRule('gradingdata', null, 'required'); - $mform->addElement('checkbox','overwrite','',get_string('overwritegrades','coursework')); - $mform->addElement('hidden','cmid',$this->cmid); + $mform->addElement('checkbox', 'overwrite', '', get_string('overwritegrades', 'coursework')); + $mform->addElement('hidden', 'cmid', $this->cmid); - $mform->setType('cmid',PARAM_RAW); + $mform->setType('cmid', PARAM_RAW); $choices = csv_import_reader::get_delimiter_list(); $mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices); @@ -47,15 +57,11 @@ function definition() { $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices); $mform->setDefault('encoding', 'UTF-8'); - - $this->add_action_buttons(true,get_string('uploadgradingworksheet','coursework')); + $this->add_action_buttons(true, get_string('uploadgradingworksheet', 'coursework')); } - function display() { + function display() { return $this->_form->toHtml(); } - - - -} \ No newline at end of file +} diff --git a/classes/forms/view_all_students_mform.php b/classes/forms/view_all_students_mform.php index 8c90cebe..e014ef43 100644 --- a/classes/forms/view_all_students_mform.php +++ b/classes/forms/view_all_students_mform.php @@ -14,9 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/* - * this is a mform designed to allow the toggling of the displaying of students not allocated to the current user - * +/** + * This is a mform designed to allow the toggling of the displaying of students not allocated to the current user + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace mod_coursework\forms; @@ -29,21 +31,19 @@ require_once($CFG->dirroot.'/lib/formslib.php'); -class view_all_students_mform extends moodleform { +class view_all_students_mform extends moodleform { - function definition() { + function definition() { $this->_form->addElement('hidden', 'id', $this->_customdata['cmid']); $this->_form->setType('id', PARAM_INT); - - $buttontext = (empty($this->_customdata['displayallstudents'])) ? get_string('viewallstudents', 'coursework') : get_string('hideallstudents','coursework'); - $hiddenvalue = (empty($this->_customdata['displayallstudents'])) ? 1 : 0; + $buttontext = (empty($this->_customdata['displayallstudents'])) ? get_string('viewallstudents', 'coursework') : get_string('hideallstudents', 'coursework'); + $hiddenvalue = (empty($this->_customdata['displayallstudents'])) ? 1 : 0; $this->_form->addElement('submit', 'displayallstudentbutton', $buttontext); $this->_form->addElement('hidden', 'displayallstudents', $hiddenvalue); $this->_form->setType('displayallstudents', PARAM_INT); - } /** @@ -55,5 +55,4 @@ public function display() { return $this->_form->toHtml(); } - -} \ No newline at end of file +} diff --git a/classes/framework/ability.php b/classes/framework/ability.php index 94ac93a4..edf38364 100644 --- a/classes/framework/ability.php +++ b/classes/framework/ability.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\framework; use mod_coursework\ability\rule; @@ -34,7 +54,7 @@ abstract class ability { /** * @var rule[] */ - protected $rules = array(); + protected $rules = []; /** * We use a different instance of the class for each user. This makes it a bit cleaner. @@ -138,7 +158,7 @@ protected function get_rule($action, $type) { * @return array */ protected function classname_mappings() { - return array(); + return []; } /** @@ -192,5 +212,4 @@ protected function prevent($action, $class, $function) { $this->rules[] = $rule; } - -} \ No newline at end of file +} diff --git a/classes/framework/decorator.php b/classes/framework/decorator.php index 57d988ae..7ebe0f7d 100644 --- a/classes/framework/decorator.php +++ b/classes/framework/decorator.php @@ -1,12 +1,31 @@ . -namespace mod_coursework\framework; +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace mod_coursework\framework; /** * Class decorator * - * Acts as a decorator around a class. Remember to add the '@mixin' property so that PHPStorm will + * Acts as a decorator around a class. Remember to add the @ mixin property so that PHPStorm will * provide autocompletion of methods and properties. */ class decorator { @@ -63,4 +82,4 @@ public function __set($name, $value) { public function wrapped_object() { return $this->wrapped_object; } -} \ No newline at end of file +} diff --git a/classes/framework/table_base.php b/classes/framework/table_base.php index c79becab..06b93d57 100644 --- a/classes/framework/table_base.php +++ b/classes/framework/table_base.php @@ -14,8 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace mod_coursework\framework;; +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace mod_coursework\framework;; use moodle_database; use stdClass; @@ -108,7 +113,7 @@ public static function find($db_record, $reload = true) { * @return array * @throws \coding_exception */ - public static function find_all($params = array()) { + public static function find_all($params = []) { if (!is_array($params)) { throw new \coding_exception('::all() require an array of parameters'); @@ -119,7 +124,6 @@ public static function find_all($params = array()) { return self::instantiate_objects($params); } - /** * Makes a new object ready to save * @@ -149,7 +153,6 @@ public static function create($params) { return $item; } - /** * Takes the supplied DB record (one row of the table) and applies it to this object. If it's a * number, change it to a DB row and then do it. @@ -179,7 +182,7 @@ protected static function instantiate_objects($params) { global $DB; $raw_records = $DB->get_records(static::get_table_name(), $params); - $objects = array(); + $objects = []; $klass = get_called_class(); foreach ($raw_records as $raw_record) { $objects[$raw_record->id] = new $klass($raw_record); @@ -510,7 +513,7 @@ private function build_data_object_to_save($sneakily = false) { * @param array|table_base $conditions key value pairs of DB columns * @return bool */ - public static function exists($conditions = array()) { + public static function exists($conditions = []) { global $DB; if (is_number($conditions)) { @@ -520,7 +523,7 @@ public static function exists($conditions = array()) { $conditions = $conditions->to_array(); } - foreach($conditions as $colname => $value) { + foreach ($conditions as $colname => $value) { static::ensure_column_exists($colname); } return $DB->record_exists(static::get_table_name(), $conditions); @@ -530,7 +533,7 @@ public static function exists($conditions = array()) { * @param array $conditions * @return int */ - public static function count($conditions = array()) { + public static function count($conditions = []) { global $DB; foreach ($conditions as $colname => $value) { @@ -594,7 +597,7 @@ public function __toString() { * @return array */ public function to_array() { - $data = array(); + $data = []; // Only save the non-null fields. foreach (static::get_column_names() as $column_name) { diff --git a/classes/framework/test/classes/user_table.php b/classes/framework/test/classes/user_table.php index 02fdda36..afc21545 100644 --- a/classes/framework/test/classes/user_table.php +++ b/classes/framework/test/classes/user_table.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Class framework_user_table allows us to test the table_base class on a reasonably stable table @@ -13,4 +33,4 @@ class framework_user_table extends \mod_coursework\framework\table_base { */ protected static $table_name = 'user'; -} \ No newline at end of file +} diff --git a/classes/framework/test/table_base_test.php b/classes/framework/test/table_base_test.php index 846e448e..2f16324e 100644 --- a/classes/framework/test/table_base_test.php +++ b/classes/framework/test/table_base_test.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); @@ -11,7 +31,7 @@ */ class framework_table_base_test extends advanced_testcase { - public function SetUp() { + public function setUp(): void { $this->resetAfterTest(); } @@ -72,12 +92,11 @@ public function test_find_when_false_and_zero_supplied() { $this->assertFalse(framework_user_table::find(0)); } - public function test_exists_when_true() { $generator = testing_util::get_data_generator(); $params = array( - 'username' =>'freddo' + 'username' => 'freddo' ); $generator->create_user($params); @@ -120,4 +139,4 @@ public function test_find_all_returns_specific_records() { $this->assertEquals(2, count(framework_user_table::find_all(array('firstname' => 'Dave')))); } -} \ No newline at end of file +} diff --git a/classes/grade_judge.php b/classes/grade_judge.php index c218c0cf..f4f4187d 100644 --- a/classes/grade_judge.php +++ b/classes/grade_judge.php @@ -1,5 +1,24 @@ . +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework; @@ -141,12 +160,11 @@ public function is_feedback_that_is_promoted_to_gradebook(feedback $feedback) { return $gradebook_feedback && $gradebook_feedback->id == $feedback->id; } - /** * @param allocatable $allocatable * @return bool */ - public function allocatable_needs_more_than_one_feedback ($allocatable){ + public function allocatable_needs_more_than_one_feedback ($allocatable) { if ($this->coursework->sampling_enabled()) { assessment_set_membership::fill_pool_coursework($this->coursework->id); @@ -156,15 +174,14 @@ public function allocatable_needs_more_than_one_feedback ($allocatable){ return $this->coursework->has_multiple_markers(); } - } - public function grade_in_scale($value) { + public function grade_in_scale($value) { if (is_null($value)) { return true; } else if ($this->coursework->grade >= 1) { // Numeric grade - return is_numeric($value) && $value < $this->coursework->grade +1 && $value > 0; + return is_numeric($value) && $value < $this->coursework->grade + 1 && $value > 0; } else if ($this->coursework->grade == 0) { // No grade return true; @@ -172,7 +189,7 @@ public function grade_in_scale($value) { // Scale $scale = \grade_scale::fetch(array('id' => abs($this->coursework->grade))); $scale->load_items(); - return in_array($value,$scale->scale_items); + return in_array($value, $scale->scale_items); } } @@ -182,21 +199,17 @@ public function grade_in_scale($value) { * @param $value * @return mixed */ - public function get_grade($value) { + public function get_grade($value) { if ($this->coursework->grade <= -1) { // Scale $scale = \grade_scale::fetch(array('id' => abs($this->coursework->grade))); $scale->load_items(); - return array_search($value,$scale->scale_items)+1; + return array_search($value, $scale->scale_items) + 1; } else { return $value; } - } - - - -} \ No newline at end of file +} diff --git a/classes/grades/gradeitems.php b/classes/grades/gradeitems.php index 63e7a507..dbc56d1b 100644 --- a/classes/grades/gradeitems.php +++ b/classes/grades/gradeitems.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + /** * Grade item mappings for the activity. * @@ -24,8 +30,8 @@ namespace mod_coursework\grades; -use \core_grades\local\gradeitem\itemnumber_mapping; -use \core_grades\local\gradeitem\advancedgrading_mapping; +use core_grades\local\gradeitem\itemnumber_mapping; +use core_grades\local\gradeitem\advancedgrading_mapping; /** * Grade item mappings for the activity. @@ -58,4 +64,3 @@ public static function get_advancedgrading_itemnames(): array { } } - diff --git a/classes/grading_report.php b/classes/grading_report.php index ace35c2c..b806f21b 100644 --- a/classes/grading_report.php +++ b/classes/grading_report.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework; use mod_coursework\models\allocation; @@ -72,18 +78,18 @@ class grading_report { /** * @var cell_interface[] */ - private $cells; + private $cells; /** * Grades in $data must be already rounded to the set number of decimals or must be null - * (in which later case, the [mod_workshop,nullgrade] string shall be displayed) + * (in which later case, the [mod_workshop, nullgrade] string shall be displayed) * * @param array $options * @param coursework $coursework */ public function __construct(array $options, $coursework) { - $options['courseworkid'] = $coursework->id; + $options['courseworkid'] = $coursework->id; $this->options = $options; $this->coursework = $coursework; @@ -114,7 +120,6 @@ public function get_coursework() { return $this->coursework; } - /** * @param $options * @return string @@ -199,7 +204,6 @@ public function sort_by_firstname($a, $b) { return $sort; } - /** * For use with usort. * Method called dynamically, so don't delete if unused. See construct_sort_function_name(). @@ -251,7 +255,6 @@ public function sort_by_lastname($a, $b) { return $this->sort_by_stringfield($a->get_student_lastname(), $b->get_student_lastname()); } - /** * For use with usort. * Method called dynamically, so don't delete if unused. See construct_sort_function_name(). @@ -264,8 +267,6 @@ public function sort_by_groupname($a, $b) { return $this->sort_by_stringfield($a->get_allocatable()->name, $b->get_allocatable()->name); } - - /** * For use with usort. * Method called dynamically, so don't delete if unused. See construct_sort_function_name(). @@ -340,7 +341,7 @@ public function get_participant_count() { * * @return grading_table_row_base[] row objects */ - public function get_table_rows_for_page($rowcount=false) { + public function get_table_rows_for_page($rowcount = false) { global $USER; @@ -350,20 +351,20 @@ public function get_table_rows_for_page($rowcount=false) { $participants = $this->coursework->get_allocatables(); // Make tablerow objects so we can use the methods to check permissions and set things. - $rows = array(); + $rows = []; $row_class = $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; + $participantsfound = 0; foreach ($participants as $key => $participant) { // 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 (!empty($options['group']) && $options['group'] != -1) { + if ($this->coursework->is_configured_to_have_group_submissions()) { + 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; } } @@ -426,5 +427,4 @@ public function get_options() { return $this->options; } - } diff --git a/classes/grading_table_row_base.php b/classes/grading_table_row_base.php index 9359326e..51532886 100644 --- a/classes/grading_table_row_base.php +++ b/classes/grading_table_row_base.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework; use html_writer; @@ -26,7 +32,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Refactoring the grading table to clarify the logic. There will be two subclasses of this - * one for single row tables and one for multi-row tables. These classes contain all the business @@ -180,7 +185,7 @@ public function get_time_submitted() { /** * Getter for personal deadline time - * + * * @return int|mixed|string */ public function get_personal_deadlines() { @@ -195,18 +200,16 @@ public function get_personal_deadlines() { $personal_deadline = $DB->get_record('coursework_person_deadlines', array('courseworkid' => $this->get_coursework()->id, 'allocatableid' => $allocatable->id(), - 'allocatabletype'=> $allocatable->type())); - if ($personal_deadline){ + 'allocatabletype' => $allocatable->type())); + if ($personal_deadline) { $personal_deadline = $personal_deadline->personal_deadline; } else { $personal_deadline = $this->get_coursework()->deadline; } - + return $personal_deadline; } - - /** * Returns the hash used to name files anonymously for this user/coursework combination */ @@ -260,7 +263,6 @@ public function get_plagiarism_flag() { return plagiarism_flag::find($params); } - /** * Chained getter to prevent tight coupling. * @@ -347,7 +349,7 @@ public function get_student_firstname() { $allocatable = $this->get_allocatable(); if (empty($allocatable->firstname)) { - $this->allocatable = user::find($allocatable); + $this->allocatable = user::find($allocatable); } return $this->get_allocatable()->firstname; @@ -362,7 +364,7 @@ public function get_student_lastname() { $allocatable = $this->get_allocatable(); if (empty($allocatable->lastname)) { - $this->allocatable = user::find($allocatable); + $this->allocatable = user::find($allocatable); } return $this->get_allocatable()->lastname; @@ -390,11 +392,10 @@ public function has_feedback() { /** * @return models\feedback */ - public function get_single_feedback(){ + public function get_single_feedback() { return $this->get_submission()->get_assessor_feedback_by_stage('assessor_1'); } - /** * Check if the extension is given to this row * @@ -406,11 +407,10 @@ public function has_extension() { global $DB; return $DB->record_exists('coursework_extensions', array('courseworkid' => $this->get_coursework()->id, 'allocatableid' => $this->get_allocatable()->id(), - 'allocatabletype'=> $this->get_allocatable()->type())); + 'allocatabletype' => $this->get_allocatable()->type())); } - /** * Getter for row extension * @@ -421,7 +421,7 @@ public function get_extension() { global $DB; return $DB->get_record('coursework_extensions', array('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() { @@ -433,8 +433,7 @@ public function get_user_firstname() { $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->get_coursework()->get_context()); if (!$this->get_coursework()->blindmarking || $viewanonymous || $this->is_published() ) { return $user->firstname; - } - else { + } else { return get_string('hidden', 'mod_coursework'); } } @@ -448,8 +447,7 @@ public function get_user_lastname() { $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->get_coursework()->get_context()); if (!$this->get_coursework()->blindmarking || $viewanonymous || $this->is_published()) { return $user->lastname; - } - else { + } else { return get_string('hidden', 'mod_coursework'); } } diff --git a/classes/grading_table_row_multi.php b/classes/grading_table_row_multi.php index a10bfc7b..d2d1ece9 100644 --- a/classes/grading_table_row_multi.php +++ b/classes/grading_table_row_multi.php @@ -14,17 +14,21 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework; defined('MOODLE_INTERNAL') || die(); - /** * Single row of the grading table for when there are multiple markers. */ class grading_table_row_multi extends grading_table_row_base { - /** * Returns a new table object using the attached submission as a constructor. * @@ -35,5 +39,4 @@ public function get_assessor_feedback_table() { return $table; } - -} \ No newline at end of file +} diff --git a/classes/grading_table_row_single.php b/classes/grading_table_row_single.php index b5c889e4..4c43405c 100644 --- a/classes/grading_table_row_single.php +++ b/classes/grading_table_row_single.php @@ -14,17 +14,21 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework; use coding_exception; defined('MOODLE_INTERNAL') || die(); - /** * Single row of the grading table for when there is just one marker */ class grading_table_row_single extends grading_table_row_base { - } diff --git a/classes/mailer.php b/classes/mailer.php index 99ab0ed3..7d9dee85 100644 --- a/classes/mailer.php +++ b/classes/mailer.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework; use mod_coursework\models\submission; @@ -88,7 +108,7 @@ public function send_late_submission_notification($submission) { foreach ($recipients as $recipient) { // New approach. - $eventdata = new \core\message\message(); + $eventdata = new \core\message\message(); $eventdata->component = 'mod_coursework'; $eventdata->name = 'submission_receipt'; $eventdata->userfrom = \core_user::get_noreply_user(); @@ -110,7 +130,6 @@ public function send_late_submission_notification($submission) { } } - /** * Send feedback notifications to users whose feedback was released * @@ -164,7 +183,7 @@ public function send_feedback_notification($submission) { * @return mixed * @throws \coding_exception */ - public function send_student_deadline_reminder($user) { + public function send_student_deadline_reminder($user) { global $CFG; @@ -175,7 +194,7 @@ public function send_student_deadline_reminder($user) { $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'); + $email_data->human_deadline = userdate($user->deadline, '%a, %d %b %Y, %H:%M'); $secondstodeadline = $user->deadline - time(); $days = floor($secondstodeadline / 86400); @@ -195,7 +214,7 @@ public function send_student_deadline_reminder($user) { $text_body = get_string('cron_email_text', 'mod_coursework', $email_data); $html_body = get_string('cron_email_html', 'mod_coursework', $email_data); - $eventdata = new \core\message\message(); + $eventdata = new \core\message\message(); $eventdata->component = 'mod_coursework'; $eventdata->name = 'student_deadline_reminder'; $eventdata->userfrom = \core_user::get_noreply_user(); @@ -213,9 +232,7 @@ public function send_student_deadline_reminder($user) { return message_send($eventdata); } - - - public function send_submission_notification($userstonotify) { + public function send_submission_notification($userstonotify) { global $CFG; @@ -250,6 +267,5 @@ public function send_submission_notification($userstonotify) { message_send($eventdata); } - } -} \ No newline at end of file +} diff --git a/classes/models/allocation.php b/classes/models/allocation.php index 73b50b53..3b019615 100644 --- a/classes/models/allocation.php +++ b/classes/models/allocation.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\models; use mod_coursework\framework\table_base; diff --git a/classes/models/assessment_set_membership.php b/classes/models/assessment_set_membership.php index 5482ab94..d5f179f9 100644 --- a/classes/models/assessment_set_membership.php +++ b/classes/models/assessment_set_membership.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * This class allows us to add functionality to the users, despite the fact that Moodle has no @@ -9,8 +29,8 @@ namespace mod_coursework\models; use mod_coursework\framework\table_base; -use \mod_coursework\allocation\allocatable; -use \mod_coursework\allocation\moderatable; +use mod_coursework\allocation\allocatable; +use mod_coursework\allocation\moderatable; /** * @property int courseworkid @@ -85,4 +105,4 @@ protected function after_destroy() { self::remove_cache($this->courseworkid); } -} \ No newline at end of file +} diff --git a/classes/models/course_module.php b/classes/models/course_module.php index 26742727..ec329270 100644 --- a/classes/models/course_module.php +++ b/classes/models/course_module.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\models; use mod_coursework\framework\table_base; diff --git a/classes/models/coursework.php b/classes/models/coursework.php index fe942c5f..e13c3e00 100644 --- a/classes/models/coursework.php +++ b/classes/models/coursework.php @@ -18,15 +18,13 @@ * Page that prints a table of all students and all markers so that first marker, second marker, moderators * etc can be allocated manually or automatically. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace mod_coursework\models; - use coding_exception; use context_course; @@ -239,7 +237,7 @@ class coursework extends table_base { /** * @var array */ - protected $stages = array(); + protected $stages = []; /** * @var \context Instance of a moodle context, i.e. that of the coursemodule for this coursework. @@ -381,7 +379,6 @@ class coursework extends table_base { */ public $extensionsenabled; - public $gradeeditingtime; /** @@ -389,13 +386,11 @@ class coursework extends table_base { */ public $markingdeadlineenabled; - /** * @var int */ public $initialmarkingdeadline; - /** * @var int */ @@ -460,8 +455,7 @@ public function get_course_module() { return $this->coursemodule; } - public function cm_object($coursemodule){ - + public function cm_object($coursemodule) { $modinfo = get_fast_modinfo($this->get_course_id()); return $this->coursemodule = $modinfo->get_cm($coursemodule->id); @@ -495,7 +489,6 @@ public function get_coursemodule_idnumber() { return (int)$coursemodule->idnumber; } - /** * Getter function for the coursework's course object. * @@ -593,7 +586,7 @@ public function deadline_has_passed() { return ($this->has_deadline() && $this->deadline < time()); } - public function has_deadline() { + public function has_deadline() { return !empty($this->deadline); } @@ -618,7 +611,7 @@ public function get_participants($groups = array(0)) { // Fetch the list of ids of all participants - this may get really long so fetch just id. $groups = (array)$groups; - $allusers = array(); + $allusers = []; foreach ($groups as $groupdid) { $allusers = array_merge($allusers, get_enrolled_users($this->get_context(), 'mod/coursework:submit', $groupdid, 'u.id')); } @@ -659,8 +652,7 @@ public function get_context_id() { return $this->get_context()->id; } - - function get_grade_editing_time() { + function get_grade_editing_time() { return $this->gradeeditingtime; } @@ -670,17 +662,16 @@ function get_grade_editing_time() { * @return int */ function get_initial_marking_deadline() { - return (!empty($this->initialmarkingdeadline)) ? $this->initialmarkingdeadline : 0; + return (!empty($this->initialmarkingdeadline)) ? $this->initialmarkingdeadline : 0; } - /** * Returns the initial marking deadline timestamp * * @return int */ function get_agreed_grade_marking_deadline() { - return (!empty($this->agreedgrademarkingdeadline)) ? $this->agreedgrademarkingdeadline : 0; + return (!empty($this->agreedgrademarkingdeadline)) ? $this->agreedgrademarkingdeadline : 0; } /** @@ -697,7 +688,7 @@ public function get_file_options() { $turnitinenabled = $this->tii_enabled(); // Turn it in only allows one file. - $max_files = $this->maxfiles; + $max_files = $this->maxfiles; // Turn it in only likes some file types. /* DOC, DOCX, Corel @@ -828,7 +819,7 @@ public function get_allocatable_identifier_hash($allocatable) { */ public function get_plagiarism_helpers() { $enabled_plagiarism_plugins = array_keys(\core_component::get_plugin_list('plagiarism')); - $objects = array(); + $objects = []; foreach ($enabled_plagiarism_plugins as $plugin_name) { $class_name = "\\mod_coursework\\plagiarism_helpers\\{$plugin_name}"; if (class_exists($class_name)) { @@ -870,7 +861,6 @@ public function plagiarism_enbled() { return false; } - /** * @return bool */ @@ -885,7 +875,6 @@ public function early_finalisation_allowed() { return !!$this->allowearlyfinalisation; } - /** * Pushes all grades form the coursework into the gradebook. Will overwrite any older grades. * @@ -957,11 +946,11 @@ public function pack_files() { $ability = new ability(user::find($USER), $this); $submissions = $DB->get_records('coursework_submissions', - array('courseworkid' => $this->id, 'finalised'=>1)); + array('courseworkid' => $this->id, 'finalised' => 1)); if (!$submissions) { return false; } - $files_for_zipping = array(); + $files_for_zipping = []; $fs = get_file_storage(); $grading_sheet = new \mod_coursework\export\grading_sheet($this, null, null); @@ -973,7 +962,6 @@ public function pack_files() { // If allocations are in use, then we don't supply files that are not allocated. $submission = submission::find($submission); - $files = $fs->get_area_files($context->id, 'mod_coursework', 'submission', $submission->id, "id", false); foreach ($files as $f) { @@ -982,26 +970,24 @@ public function pack_files() { $foldername = ''; - if($this->blindmarking == 0 || has_capability('mod/coursework:viewanonymous',$this->get_context())) { + if ($this->blindmarking == 0 || has_capability('mod/coursework:viewanonymous', $this->get_context())) { $submissionuser = $submission->get_allocatable(); if ($this->is_configured_to_have_group_submissions() && $submissionuser->name) { $foldername = $submissionuser->name . '_'; - } elseif(!$this->is_configured_to_have_group_submissions()) { + } else if (!$this->is_configured_to_have_group_submissions()) { $foldername = $submissionuser->firstname . ' ' . $submissionuser->lastname . '_'; } } - $foldername .= $this->get_username_hash($submission->get_allocatable()->id()); + $foldername .= $this->get_username_hash($submission->get_allocatable()->id()); - $filename = $foldername.'/'.$filename; + $filename = $foldername.'/'.$filename; /* @var $f stored_file */ $files_for_zipping[$filename] = $f; } } - - // Create path for new zip file. $temp_zip = tempnam($CFG->dataroot.'/temp/', 'ocm_'); // Zip files. @@ -1012,10 +998,6 @@ public function pack_files() { return false; } - - - - /** * Makes code cleaner than writing MATHS all over the place!! * @return bool @@ -1223,7 +1205,7 @@ public function assessor_has_any_allocation_for_student($allocatable, $userid=fa global $DB, $USER; - if (!$userid){ + if (!$userid) { $userid = $USER->id; } $params = array( @@ -1236,7 +1218,6 @@ public function assessor_has_any_allocation_for_student($allocatable, $userid=fa return $DB->record_exists('coursework_allocation_pairs', $params); } - /** * Check if current assessor is not already allocated for this submission in different stage * @@ -1262,7 +1243,6 @@ public function assessor_has_allocation_for_student_not_in_current_stage($alloca return false; } - /** * Checks whether the current user is an assessor allocated to mark this submission. * @@ -1305,22 +1285,21 @@ public function get_all_submissions() { * @throws \dml_missing_record_exception * @throws \dml_multiple_records_exception */ - public function get_submissions_needing_grading(){ + public function get_submissions_needing_grading() { - $needsgrading = array(); + $needsgrading = []; $submissions = $this->get_finalised_submissions(); foreach ($submissions as $submission) { - $stage_identifier = ($this->has_multiple_markers())? 'final_agreed_1': 'assessor_1'; + $stage_identifier = ($this->has_multiple_markers()) ? 'final_agreed_1' : 'assessor_1'; $submission = submission::find($submission); - if (!$feedback = $submission->get_assessor_feedback_by_stage($stage_identifier)){ + if (!$feedback = $submission->get_assessor_feedback_by_stage($stage_identifier)) { $needsgrading[] = $submission; } } - return $needsgrading; } @@ -1333,14 +1312,14 @@ public function get_submissions_needing_grading(){ * @throws \dml_missing_record_exception * @throws \dml_multiple_records_exception */ - public function get_graded_submissions_by_stage($stage_identifier){ + public function get_graded_submissions_by_stage($stage_identifier) { - $graded = array(); + $graded = []; $submissions = $this->get_finalised_submissions(); foreach ($submissions as $submission) { $submission = submission::find($submission); - if ($feedback = $submission->get_assessor_feedback_by_stage($stage_identifier)){ + if ($feedback = $submission->get_assessor_feedback_by_stage($stage_identifier)) { $graded[$submission->id] = $submission; } } @@ -1354,18 +1333,18 @@ public function get_graded_submissions_by_stage($stage_identifier){ * @return array * @throws \dml_exception */ - public function get_assessor_graded_submissions($assessorid){ + public function get_assessor_graded_submissions($assessorid) { global $DB; - $graded = array(); + $graded = []; $params = array('courseworkid' => $this->id, 'assessorid' => $assessorid); $sql = "SELECT cs.id - FROM {coursework_feedbacks} cf - JOIN {coursework_submissions} cs + FROM {coursework_feedbacks} cf + JOIN {coursework_submissions} cs ON cs.id = cf.submissionid - WHERE cs.courseworkid = :courseworkid + WHERE cs.courseworkid = :courseworkid AND assessorid = :assessorid"; - $submissions = $DB->get_records_sql($sql, $params); + $submissions = $DB->get_records_sql($sql, $params); foreach ($submissions as $submission) { $submission = submission::find($submission); @@ -1375,14 +1354,13 @@ public function get_assessor_graded_submissions($assessorid){ return $graded; } - /** * Get all published submissions in the coursework * * @return array * @throws \dml_exception */ - public function get_published_submissions(){ + public function get_published_submissions() { global $DB; $sql = "SELECT * @@ -1390,14 +1368,13 @@ public function get_published_submissions(){ WHERE courseworkid = :courseworkid AND firstpublished IS NOT NULL"; - $submissions = $DB->get_records_sql($sql, array('courseworkid' => $this->id)); + $submissions = $DB->get_records_sql($sql, array('courseworkid' => $this->id)); foreach ($submissions as &$submission) { $submission = submission::find($submission); } return $submissions; } - /** * Returns a hash of this user's id. Not username as this would be non-unique across * different courseworks, compromising anonymity. @@ -1408,26 +1385,23 @@ public function get_published_submissions(){ * @param int $userid * @return string */ - static function get_name_hash($id,$userid,$time=1440000609) - { + static function get_name_hash($id, $userid, $time=1440000609) { if ($id < 1) { return ''; } - $uhash = $id . $userid; + $uhash = $id . $userid; - //hash with zero have the potential to become changed in outside programs - //so we generate a hash without a leading zero + // Hash with zero have the potential to become changed in outside programs + // So we generate a hash without a leading zero $uhash = substr(md5($uhash), 0, 8); $uhash = 'X' . $uhash; - return $uhash; } - public function get_username_hash($userid) - { - return static::get_name_hash($this->id,$userid,$this->timecreated); + public function get_username_hash($userid) { + return static::get_name_hash($this->id, $userid, $this->timecreated); } /** @@ -1475,16 +1449,15 @@ public function get_assessor_allocation($allocatable, $stage_identifier) { $params = array( 'courseworkid' => $this->id, 'allocatableid' => $allocatable->allocatableid, - 'stage_identifier'=>$stage_identifier, - 'allocatabletype'=> $allocatable->allocatabletype + 'stage_identifier' => $stage_identifier, + 'allocatabletype' => $allocatable->allocatabletype ); $allocation = $DB->get_record('coursework_allocation_pairs', $params); return $allocation; } - - public function get_assessors_stage_identifier($allocatable_id, $assessor_id){ + public function get_assessors_stage_identifier($allocatable_id, $assessor_id) { global $DB; $params = array( @@ -1498,7 +1471,6 @@ public function get_assessors_stage_identifier($allocatable_id, $assessor_id){ return $stage_identifier->stage_identifier; } - /** * Checks settings to see whether the current user (who we assume is a student) can * view their feedback. @@ -1827,7 +1799,6 @@ public function build_own_submission($user) { return submission::build($own_submission_params); } - /** * Uses the knowledge of the Coursework settings to compose the object which the renderer can deal with. * This is the messy wiring for the nice, reusable components in the grading report :) @@ -1845,7 +1816,6 @@ public function renderable_grading_report_factory($report_options) { 'coursework' => $this, ); - // Add the cell objects. These are used to generate the table headers and to render each row. if ($this->is_configured_to_have_group_submissions()) { $report->add_cell(new group_cell($cell_items)); @@ -1886,7 +1856,7 @@ public function renderable_grading_report_factory($report_options) { ); $report->add_cell(new single_assessor_feedback_cell($items_with_stage)); } - if($this->moderation_agreement_enabled()){ + if ($this->moderation_agreement_enabled()) { $items_with_stage = array( 'stage' => $this->get_moderator_grade_stage(), 'coursework' => $this, @@ -1955,7 +1925,7 @@ public function due_to_send_second_reminders($deadline) { * @return user[] */ public function get_students() { - $users = array(); + $users = []; $raw_users = get_enrolled_users($this->get_context(), 'mod/coursework:submit'); // filter students who are restricted from the coursework @@ -1997,7 +1967,7 @@ public function get_students_who_have_not_yet_submitted() { * @return user[] */ public function initial_assessors($student) { - $assessors = array(); + $assessors = []; $stages = $this->get_assessor_marking_stages(); // If allocations, send the allocated teachers. // Otherwise send everyone. @@ -2095,22 +2065,21 @@ public function student_is_in_any_group($student) { /** * @return bool */ - public function sampling_enabled() - { + public function sampling_enabled() { return (bool)$this->samplingenabled; } /** * @return bool */ - public function automaticagreement_enabled(){ + public function automaticagreement_enabled() { return $this->automaticagreementstrategy != null; } /** * @return bool */ - public function autopopulatefeedbackcomment_enabled(){ + public function autopopulatefeedbackcomment_enabled() { return (bool)$this->autopopulatefeedbackcomment; } @@ -2170,11 +2139,11 @@ protected function get_advanced_grading_manager() { * * @return bool */ - public function is_using_rubric(){ + public function is_using_rubric() { $grading_manager = $this->get_advanced_grading_manager(); $method = $grading_manager->get_active_method(); - if ($method == 'rubric'){ + if ($method == 'rubric') { return true; } return false; @@ -2185,7 +2154,7 @@ public function is_using_rubric(){ * * @return mixed */ - public function get_rubric_criteria(){ + public function get_rubric_criteria() { $controller = $this->get_advanced_grading_active_controller(); return $controller->get_definition()->rubric_criteria; } @@ -2209,7 +2178,7 @@ public function marking_stages() { $this->stages[$identifier] = new final_agreed($this, $identifier); } - if ($this->moderation_agreement_enabled()){ + if ($this->moderation_agreement_enabled()) { $identifier = 'moderator'; $this->stages[$identifier] = new moderator($this, $identifier); @@ -2225,12 +2194,12 @@ public function marking_stages() { * @return stage_base[] */ public function get_assessor_marking_stages() { - $stages = array(); + $stages = []; for ($i = 1; $i <= $this->get_max_markers(); $i++) { $stages[] = new assessor($this, 'assessor_' . $i); } - if ($this->moderation_agreement_enabled()){ + if ($this->moderation_agreement_enabled()) { $stages[] = new moderator($this, 'moderator'); } @@ -2261,11 +2230,10 @@ private function get_moderator_grade_stage() { } } - public function get_submission_notification_users() { + public function get_submission_notification_users() { return $this->submissionnotification; } - /** * Utility method that returns an image icon. * @@ -2290,7 +2258,7 @@ public final static function get_image($text, $image_name) { public function get_allocatables() { global $DB; - $allocatables = array(); + $allocatables = []; if ($this->is_configured_to_have_group_submissions()) { if ($this->grouping_id) { @@ -2320,14 +2288,14 @@ public function get_allocatables() { $groups = $DB->get_records_sql($sql, $params); foreach ($groups as $group) { $group = group::find($group); - //find out if members of this group can access this coursework, if group is left without members then remove it + // Find out if members of this group can access this coursework, if group is left without members then remove it $cm = $this->get_course_module(); $cmobject = $this->cm_object($cm); /** * @var group $group */ - $members = $group->get_members($this->get_context(), $cmobject); - if (empty($members)){ + $members = $group->get_members($this->get_context(), $cmobject); + if (empty($members)) { continue; } $allocatables[$group->id] = $group; @@ -2422,25 +2390,25 @@ public function has_stuff_to_publish() { /** * @return bool */ - public function is_general_feedback_enabled(){ + public function is_general_feedback_enabled() { return ($this->generalfeedback != 0); } /** * @return bool */ - public function has_individual_autorelease_feedback_enabled(){ + public function has_individual_autorelease_feedback_enabled() { return ($this->individualfeedback != 0); } /** * @return array */ - public function get_finalised_submissions(){ + public function get_finalised_submissions() { global $DB; $submissions = $DB->get_records('coursework_submissions', - array('courseworkid' => $this->id, 'finalised'=>1), '', 'id'); + array('courseworkid' => $this->id, 'finalised' => 1), '', 'id'); foreach ($submissions as &$submission) { $submission = submission::find($submission); @@ -2461,18 +2429,18 @@ public function finalise_all() { global $DB; $excludesql = ''; // check if any extensions granted for this coursework - if ($this->extensions_enabled() && $this->extension_exists()){ + if ($this->extensions_enabled() && $this->extension_exists()) { $submissions_with_extensions = $this->get_submissions_with_extensions(); - foreach ($submissions_with_extensions as $submission){ + foreach ($submissions_with_extensions as $submission) { // exclude submissions that are still within extended deadline - if ($submission->extended_deadline > time()){ + if ($submission->extended_deadline > time()) { $excludesubmissions[$submission->submissionid] = $submission->submissionid; } } // build exclude sql - if (!empty($excludesubmissions)){ + if (!empty($excludesubmissions)) { $excludesql = ' AND id NOT IN('; - $excludesql .= implode(',',$excludesubmissions); + $excludesql .= implode(',', $excludesubmissions); $excludesql .= ')'; } } @@ -2495,8 +2463,6 @@ public function finalise_all() { $excludesql .= ')'; } - - $DB->execute("UPDATE {coursework_submissions} SET finalised = 1 WHERE courseworkid = ? $excludesql", array($this->id)); @@ -2508,7 +2474,7 @@ public function finalise_all() { public static function extension_reasons() { global $CFG; - $extension_reasons = array(); + $extension_reasons = []; if (!empty($CFG->coursework_extension_reasons_list)) { $extension_reasons = $CFG->coursework_extension_reasons_list; $extension_reasons = explode("\n", $extension_reasons); @@ -2532,13 +2498,13 @@ public function extensions_enabled() { /* * @return bool */ - public function extension_exists(){ + public function extension_exists() { global $DB; - return $DB->record_exists('coursework_extensions',array('courseworkid'=>$this->id)); + return $DB->record_exists('coursework_extensions', array('courseworkid' => $this->id)); } - public function get_submissions_with_extensions(){ + public function get_submissions_with_extensions() { global $DB; $sql = "SELECT *, cs.id as submissionid @@ -2549,13 +2515,13 @@ public function get_submissions_with_extensions(){ AND ce.allocatabletype = cs.allocatabletype AND cs.courseworkid = :courseworkid"; - return $DB->get_records_sql($sql,array('courseworkid'=>$this->id)); + return $DB->get_records_sql($sql, array('courseworkid' => $this->id)); } /** * Get all personal deadline in coursework, they can be coursework deadline-(default) or personal */ - public function get_coursework_submission_personal_deadlines(){ + public function get_coursework_submission_personal_deadlines() { global $DB; $sql = "SELECT cs.id as submissionid, personal_deadline @@ -2565,10 +2531,10 @@ public function get_coursework_submission_personal_deadlines(){ AND pd.allocatabletype = cs.allocatabletype WHERE cs.courseworkid = :courseworkid"; - $submissions = $DB->get_records_sql($sql,array('courseworkid'=>$this->id)); + $submissions = $DB->get_records_sql($sql, array('courseworkid' => $this->id)); // for submissions that don't have a set personal deadline give coursework's default deadline - if($submissions) { + if ($submissions) { foreach ($submissions as $submission) { if (is_null($submission->personal_deadline)) { $submission->personal_deadline = $this->deadline; @@ -2578,53 +2544,42 @@ public function get_coursework_submission_personal_deadlines(){ return $submissions; } - - - - - - /** * Has the given stage got a an automatic sampling rule * * @param $stage * @return bool */ - public function has_automatic_sampling_at_stage($stage) { + public function has_automatic_sampling_at_stage($stage) { global $DB; - return $DB->record_exists('coursework_sample_set_rules',array('courseworkid'=>$this->id,'stage_identifier'=>$stage)); + return $DB->record_exists('coursework_sample_set_rules', array('courseworkid' => $this->id, 'stage_identifier' => $stage)); } - - /** * Returns all allocatables in the current coursework that have feedback * * @return allocatable[] */ - public function get_allocatables_with_feedback($stage, $random = false) { + public function get_allocatables_with_feedback($stage, $random = false) { global $DB, $CFG; $sql = "SELECT cwrsub.allocatableid, cwrfb.* FROM {coursework_submissions} cwrsub, {coursework_feedbacks} cwrfb - WHERE cwrsub.id = cwrfb.submissionid + WHERE cwrsub.id = cwrfb.submissionid AND cwrsub.courseworkid = :coursework_id AND stage_identifier = :stage"; - - if ($random) { - $sql .= ($CFG->dbtype == 'pgsql') ? " ORDER BY RANDOM() " : " ORDER BY RAND() "; + $sql .= ($CFG->dbtype == 'pgsql') ? " ORDER BY RANDOM() " : " ORDER BY RAND() "; } return $DB->get_records_sql($sql, - array('coursework_id' => $this->id, "stage"=>$stage)); + array('coursework_id' => $this->id, "stage" => $stage)); } - /* * Creates automatic feedback * @@ -2676,15 +2631,13 @@ public function create_automatic_feedback() { unset($SESSION->keep_cache_data); feedback::remove_cache($this->id); - } - /** Function to check it Turnitin is enabled for the particular coursework * @return bool * @throws \dml_exception */ - public function tii_enabled(){ + public function tii_enabled() { if (!isset(self::$pool[$this->id]['tii_enabled'][$this->id])) { global $CFG, $DB; @@ -2707,41 +2660,34 @@ public function tii_enabled(){ return self::$pool[$this->id]['tii_enabled'][$this->id]; } - - - - - /** * Lets us know if personal deadlines are enabled in the coursework. * @return bool */ - public function personal_deadlines_enabled(){ + public function personal_deadlines_enabled() { return (bool)$this->personaldeadlineenabled; } - /** * Lets us know if draft feedback is enabled in the coursework. * @return bool */ - public function draft_feedback_enabled(){ + public function draft_feedback_enabled() { return (bool)$this->draftfeedbackenabled; } - /** * Return all allocatables and the allocatables deadline * Note! allocatables are returned irrespective of whether they have submitted. * * @return array */ - public function get_allocatables_and_deadline() { + public function get_allocatables_and_deadline() { - $allocatables = $this->get_allocatables(); + $allocatables = $this->get_allocatables(); if (!empty($allocatables)) { - $allocatables = array_map(array($this,"get_allocatable_personal_deadline"), $allocatables); + $allocatables = array_map(array($this, "get_allocatable_personal_deadline"), $allocatables); } return $allocatables; @@ -2754,12 +2700,12 @@ public function get_allocatables_and_deadline() { * * @return array */ - private function get_allocatable_personal_deadline($allocatable) { + private function get_allocatable_personal_deadline($allocatable) { global $DB; - $allocatable->deadline = $this->deadline; - $allocatable->coursework_id = $this->id; + $allocatable->deadline = $this->deadline; + $allocatable->coursework_id = $this->id; if ($this->personal_deadlines_enabled()) { personal_deadline::fill_pool_coursework($this->id); @@ -2778,7 +2724,7 @@ private function get_allocatable_personal_deadline($allocatable) { * * @return bool */ - public function has_samples(){ + public function has_samples() { global $DB; return $DB->record_exists('coursework_sample_set_mbrs', array('courseworkid' => $this->id)); @@ -2790,7 +2736,7 @@ public function has_samples(){ * * @return bool */ - public function can_submit(){ + public function can_submit() { if (has_capability('mod/coursework:submit', $this->get_context())) { return true; } @@ -2802,7 +2748,7 @@ public function can_submit(){ * * @return bool */ - public function can_grade(){ + public function can_grade() { if (has_capability('mod/coursework:addinitialgrade', $this->get_context()) || has_capability('mod/coursework:addagreedgrade', $this->get_context()) || has_capability('mod/coursework:addallocatedagreedgrade', $this->get_context())) { return true; @@ -2810,12 +2756,11 @@ public function can_grade(){ return false; } - /** * @return bool */ - public function marking_deadline_enabled(){ - return (bool)$this->markingdeadlineenabled ; + public function marking_deadline_enabled() { + return (bool)$this->markingdeadlineenabled; } /** @@ -2826,7 +2771,7 @@ public function marking_deadline_enabled(){ * @return bool * @throws \dml_exception */ - public function student_in_group($studentid, $groupid){ + public function student_in_group($studentid, $groupid) { global $DB; $sql = "SELECT groups.* FROM {groups} groups @@ -2845,7 +2790,7 @@ public function student_in_group($studentid, $groupid){ * * @return submissions */ - function retrieve_submissions_by_coursework(){ + function retrieve_submissions_by_coursework() { global $DB; return $DB->get_records('coursework_submissions', ['courseworkid' => $this->id, 'allocatabletype' => 'user']); } @@ -2855,7 +2800,7 @@ function retrieve_submissions_by_coursework(){ * @param $user_id * @return submissions */ - public function retrieve_submissions_by_user($user_id){ + public function retrieve_submissions_by_user($user_id) { global $DB; return $DB->get_records('coursework_submissions', ['courseworkid' => $this->id, 'authorid' => $user_id, 'allocatabletype' => 'user']); } @@ -2876,7 +2821,7 @@ public function retrieve_feedbacks_by_submission($submission_id) { * * @param $user_id */ - public function remove_submissions_by_user($user_id){ + public function remove_submissions_by_user($user_id) { global $DB; $DB->delete_records('coursework_submissions', ['courseworkid' => $this->id, 'authorid' => $user_id, 'allocatabletype' => 'user']); } @@ -2885,7 +2830,7 @@ public function remove_submissions_by_user($user_id){ * * @return submissions */ - public function remove_submissions_by_coursework(){ + public function remove_submissions_by_coursework() { global $DB; $DB->delete_records('coursework_submissions', ['courseworkid' => $this->id, 'allocatabletype' => 'user']); } @@ -2896,7 +2841,7 @@ public function remove_submissions_by_coursework(){ * @param $item_id * @param $filearea */ - public function remove_corresponding_file($context_id, $item_id, $filearea){ + public function remove_corresponding_file($context_id, $item_id, $filearea) { global $DB; $component = 'mod_coursework'; $fs = get_file_storage(); @@ -2907,7 +2852,7 @@ public function remove_corresponding_file($context_id, $item_id, $filearea){ * * @param $submission_id */ - public function remove_feedbacks_by_submission($submission_id){ + public function remove_feedbacks_by_submission($submission_id) { global $DB; $DB->delete_records('coursework_feedbacks', ['submissionid' => $submission_id]); } @@ -2916,7 +2861,7 @@ public function remove_feedbacks_by_submission($submission_id){ * * @param $feedback_id */ - public function remove_agreements_by_feedback($feedback_id){ + public function remove_agreements_by_feedback($feedback_id) { global $DB; $DB->delete_records('coursework_mod_agreements', ['feedbackid' => $feedback_id]); } @@ -2925,7 +2870,7 @@ public function remove_agreements_by_feedback($feedback_id){ * * @param $user_id */ - public function remove_deadline_extensions_by_user($user_id){ + public function remove_deadline_extensions_by_user($user_id) { global $DB; $DB->execute('DELETE FROM {coursework_extensions} WHERE allocatabletype = ? AND (allocatableid = ? OR allocatableuser = ? ) ', array('user', $user_id, $user_id)); } @@ -2943,23 +2888,22 @@ public function remove_personal_deadlines_by_coursework() { * Function to Remove all deadline extensions by coursework * */ - public function remove_deadline_extensions_by_coursework(){ + public function remove_deadline_extensions_by_coursework() { global $DB; $DB->execute('DELETE FROM {coursework_extensions} WHERE allocatabletype = ? AND courseworkid = ? ', array('user', $this->id)); } - /** * Function to check if Coursework has any final feedback * * @return bool * @throws \dml_exception */ - public function has_any_final_feedback(){ + public function has_any_final_feedback() { global $DB; - $sql = "SELECT * - FROM {coursework_feedbacks} cf + $sql = "SELECT * + FROM {coursework_feedbacks} cf JOIN {coursework_submissions} cs ON cs.id = cf.submissionid WHERE cs.courseworkid = :courseworkid AND cf.stage_identifier = 'final_agreed_1'"; @@ -2976,14 +2920,13 @@ public function has_any_final_feedback(){ public function get_allocatable_deadline($allocatableid) { $deadline = $this->deadline; - if($this->use_groups){ + if ($this->use_groups) { $allocatable = group::find($allocatableid); } else { $allocatable = user::find($allocatableid); } - - if ($this->personal_deadlines_enabled()){ + if ($this->personal_deadlines_enabled()) { // find personal deadline for a user if this option enabled $personal = $this->get_allocatable_personal_deadline($allocatable); if (!empty($personal)) { @@ -2991,7 +2934,7 @@ public function get_allocatable_deadline($allocatableid) { } } - if($this->extensions_enabled()){ // check if coursework allows extensions + if ($this->extensions_enabled()) { // check if coursework allows extensions // check if extension for this user exists $extension = $this->get_allocatable_extension($allocatable); if (!empty($extension)) { @@ -3007,14 +2950,13 @@ public function get_allocatable_deadline($allocatableid) { * @param $allocatable * @return bool/int */ - private function get_allocatable_extension($allocatable) { + private function get_allocatable_extension($allocatable) { global $DB; $extension = false; - if ($this->extensions_enabled() ) { - $extensionrecord = $DB->get_record('coursework_extensions', array('courseworkid' => $this->id,'allocatableid' => $allocatable->id)); + $extensionrecord = $DB->get_record('coursework_extensions', array('courseworkid' => $this->id, 'allocatableid' => $allocatable->id)); if (!empty($extensionrecord)) { $extension = $extensionrecord->extended_deadline; @@ -3024,7 +2966,6 @@ private function get_allocatable_extension($allocatable) { return $extension; } - /** * Function to Remove all plagiarisms by a submission * @@ -3036,34 +2977,32 @@ public function remove_plagiarisms_by_submission($submission_id) { $DB->delete_records('coursework_plagiarism_flags', ['submissionid' => $submission_id]); } - /** * Function to check if Coursework has any submission * * @return bool * @throws \dml_exception */ - public function has_any_submission(){ + public function has_any_submission() { global $DB; - $sql = "SELECT * - FROM {coursework_submissions} cs + $sql = "SELECT * + FROM {coursework_submissions} cs WHERE cs.courseworkid = :courseworkid"; return $DB->record_exists_sql($sql, array('courseworkid' => $this->id)); } - /** * Function to check if coursework or course that a coursework belongs to is hidden * * @return bool * @throws moodle_exception */ - public function is_coursework_visible(){ + public function is_coursework_visible() { $visible = true; - if ($this->get_course_module()->visible == 0 || $this->get_course()->visible == 0){ + if ($this->get_course_module()->visible == 0 || $this->get_course()->visible == 0) { $visible = false; } return $visible; @@ -3083,7 +3022,6 @@ public function clear_stage($stage_index = null) { } } - /** * cache array * @@ -3139,7 +3077,7 @@ public function fill_cache() { global $DB; $coursework_id = $this->id; submission::fill_pool_coursework($coursework_id); - coursework::fill_pool([$this]); + self::fill_pool([$this]); course_module::fill_pool([$this->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'])); diff --git a/classes/models/deadline_extension.php b/classes/models/deadline_extension.php index 465d9af5..1d10e361 100644 --- a/classes/models/deadline_extension.php +++ b/classes/models/deadline_extension.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\models; @@ -138,4 +158,4 @@ protected function after_destroy() { self::remove_cache($this->courseworkid); } -} \ No newline at end of file +} diff --git a/classes/models/feedback.php b/classes/models/feedback.php index 42a2395e..14a07aae 100644 --- a/classes/models/feedback.php +++ b/classes/models/feedback.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\models; use context; @@ -22,7 +28,7 @@ use mod_coursework\ability; use mod_coursework\stages\base as stage_base; use stdClass; -use \mod_coursework\feedback_files; +use mod_coursework\feedback_files; defined('MOODLE_INTERNAL') || die(); @@ -188,10 +194,10 @@ class feedback extends table_base { * @return string assessor's name * @throws \coding_exception */ - public function display_assessor_name(){ + public function display_assessor_name() { // check if assessor's name in this CW is set to hidden - if ($this->is_assessor_anonymity_enabled()){ + if ($this->is_assessor_anonymity_enabled()) { $assessor_name = get_string('hidden', 'mod_coursework'); } else { $assessor_name = $this->get_assesor_username(); @@ -200,7 +206,6 @@ public function display_assessor_name(){ return $assessor_name; } - /** * Real name for display. Allows us to defer the DB call to retrieve first and last name * in case we don't need it. @@ -215,22 +220,22 @@ public function get_assesor_username() { return $this->assessor->name(); } - public function get_assessor_id(){ + public function get_assessor_id() { return $this->assessor->id; } /** * @return string */ - public function get_assessor_stage_no(){ + public function get_assessor_stage_no() { $no = ''; - if (substr($this->stage_identifier,0,9 ) =='assessor_'){ + if (substr($this->stage_identifier, 0, 9 ) == 'assessor_') { $no = substr($this->stage_identifier, -1); } return $no; } - public function get_feedbacks_assessorid(){ + public function get_feedbacks_assessorid() { return $this->assessorid; } /** @@ -267,7 +272,6 @@ public function get_coursemodule_id() { return $this->get_submission()->get_course_module_id(); } - /** * Returns a feedback instance * @todo get rid of this. @@ -307,7 +311,7 @@ public static function get_teacher_feedback(submission $submission, * Check if assessor is allocated to the user in this stage * @return bool */ - public function is_assessor_allocated(){ + public function is_assessor_allocated() { return $this->get_stage()->assessor_has_allocation($this->get_allocatable()); } @@ -338,7 +342,7 @@ public function set_feedback_files($context_id) { public function get_feedback_files() { $this->set_feedback_files($this->get_context_id()); - if ($this->feedbackfiles !=null){ + if ($this->feedbackfiles !=null) { $this->feedback_files = new feedback_files($this->feedbackfiles, $this); return $this->feedback_files; } @@ -346,8 +350,6 @@ public function get_feedback_files() { return false; } - - /** * @return mixed */ @@ -439,7 +441,6 @@ public function get_context() { return $this->get_coursework()->get_context(); } - /** * Is this feedback one of the component grades in a multiple marking scenario? * @@ -569,7 +570,7 @@ public function get_allocatable() { return $this->get_submission()->get_allocatable(); } - public function is_assessor_anonymity_enabled(){ + public function is_assessor_anonymity_enabled() { return $this->get_coursework()->assessoranonymity; } diff --git a/classes/models/group.php b/classes/models/group.php index e75fc939..418d8979 100644 --- a/classes/models/group.php +++ b/classes/models/group.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * This class allows us to add functionality to the users, despite the fact that Moodle has no @@ -9,8 +29,8 @@ namespace mod_coursework\models; use mod_coursework\framework\table_base; -use \mod_coursework\allocation\allocatable; -use \mod_coursework\allocation\moderatable; +use mod_coursework\allocation\allocatable; +use mod_coursework\allocation\moderatable; use mod_coursework\traits\allocatable_functions; /** @@ -66,7 +86,7 @@ public function get_members($context, $cm) { $info = new \core_availability\info_module(\cm_info::create($cm)); $members = $info->filter_user_list($members); - $member_objects = array(); + $member_objects = []; foreach ($members as $member) { // check is member has capability to submit in this coursework (to get rid of assessors if they are placed in the group) if (has_capability('mod/coursework:submit', $context, $member)) { @@ -123,4 +143,4 @@ public static function get_object($id) { } return self::$pool['id'][$id]; } -} \ No newline at end of file +} diff --git a/classes/models/moderation.php b/classes/models/moderation.php index 2a9debb5..ca7808cd 100644 --- a/classes/models/moderation.php +++ b/classes/models/moderation.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\models; use context; @@ -22,7 +28,7 @@ use mod_coursework\ability; use mod_coursework\stages\base as stage_base; use stdClass; -use \mod_coursework\feedback_files; +use mod_coursework\feedback_files; defined('MOODLE_INTERNAL') || die(); @@ -32,8 +38,7 @@ * @property mixed stage_identifier * @property int feedback_manager */ -class moderation extends table_base{ - +class moderation extends table_base { /** * @var int @@ -45,7 +50,6 @@ class moderation extends table_base{ */ public $feedbackid; - /** * @var int */ @@ -76,7 +80,6 @@ class moderation extends table_base{ */ public $modcommentformat; - /** * Chained getter for loose coupling. * @@ -86,41 +89,36 @@ public function get_coursework() { return $this->get_submission()->get_coursework(); } - /** * */ - public function get_feedback(){ + 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 = array('id' => $this->feedbackid); $feedback = $DB->get_record('coursework_feedbacks', $params); return $feedback; } - public function get_agreement(){ + public function get_agreement() { return $this->agreement; - } - /** * Memoized getter * * @return bool|submission */ public function get_submission() { - $feedback = $this->get_feedback(); + $feedback = $this->get_feedback(); $this->submission = submission::find($feedback->submissionid); return $this->submission; } - - /** * @return user */ @@ -141,16 +139,15 @@ public function get_moderator_username() { return fullname($this->moderator); } - public function get_moderator_id(){ + public function get_moderator_id() { return $this->moderator->id; } - /** * Check if assessor is allocated to the user in this stage * @return bool */ - public function is_moderator_allocated(){ + public function is_moderator_allocated() { return $this->get_stage()->assessor_has_allocation($this->get_allocatable()); } @@ -187,4 +184,4 @@ public static function get_moderator_agreement($feedback) { return null; } -} \ No newline at end of file +} diff --git a/classes/models/moderation_set_rule.php b/classes/models/moderation_set_rule.php index dacdd2e3..11d44550 100644 --- a/classes/models/moderation_set_rule.php +++ b/classes/models/moderation_set_rule.php @@ -17,7 +17,7 @@ namespace mod_coursework\models; use mod_coursework\allocation\allocatable; -use \mod_coursework\stages\base as stage_base; +use mod_coursework\stages\base as stage_base; /** * This file keeps track of upgrades to the eassessment module @@ -29,8 +29,7 @@ * it cannot do itself, it will tell you what you need to do. The commands in * here will all be database-neutral, using the functions defined in DLL libraries. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -41,7 +40,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Forms a base for the moderation set rules, which determine various sets of students which * need to be included in the set e.g. lowest 40%. @@ -101,7 +99,6 @@ abstract class moderation_set_rule extends table_base implements renderable { 'minimum' ); - /** * @param bool|int|stdClass $dbrecord */ diff --git a/classes/models/module.php b/classes/models/module.php index 57739a73..c0f91448 100644 --- a/classes/models/module.php +++ b/classes/models/module.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\models; use mod_coursework\framework\table_base; diff --git a/classes/models/null_feedback.php b/classes/models/null_feedback.php index 7cadb816..f63faf74 100644 --- a/classes/models/null_feedback.php +++ b/classes/models/null_feedback.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\models; @@ -21,4 +41,4 @@ public function get_grade() { return ''; } -} \ No newline at end of file +} diff --git a/classes/models/null_user.php b/classes/models/null_user.php index f8dc241c..4a694371 100644 --- a/classes/models/null_user.php +++ b/classes/models/null_user.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\models; @@ -64,10 +84,9 @@ public function has_agreed_feedback($coursework) { * @return feedback[] */ public function get_initial_feedbacks($coursework) { - return array(); + return []; } - /** * @param coursework $coursework * @return bool @@ -76,16 +95,14 @@ public function has_all_initial_feedbacks($coursework) { return false; } - /** * @param coursework $coursework * @return bool */ - public function get_agreed_feedback($coursework){ + public function get_agreed_feedback($coursework) { return false; } - /** * @param coursework $coursework * @return submission @@ -93,4 +110,4 @@ public function get_agreed_feedback($coursework){ public function get_submission($coursework) { } -} \ No newline at end of file +} diff --git a/classes/models/outstanding_marking.php b/classes/models/outstanding_marking.php index 582b4a8b..f6bc8fac 100644 --- a/classes/models/outstanding_marking.php +++ b/classes/models/outstanding_marking.php @@ -1,130 +1,145 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ -class outstanding_marking { +namespace mod_coursework\models; - private $day_in_secs; +class outstanding_marking { + private $day_in_secs; - public function __construct() { + public function __construct() { - $this->day_in_secs = 86400; + $this->day_in_secs = 86400; } - /** * @param $cwkrecord * @param $userid * @return int */ - public function get_to_grade_initial_count($cwkrecord,$userid){ + public function get_to_grade_initial_count($cwkrecord, $userid) { - $coursework = new \mod_coursework\models\coursework($cwkrecord); + $coursework = new \mod_coursework\models\coursework($cwkrecord); - $initialsubmissions = array(); + $initialsubmissions = []; - if($this->should_get_to_mark_initial_grade_info($coursework->id,$userid)){ + if ($this->should_get_to_mark_initial_grade_info($coursework->id, $userid)) { if (!$coursework->has_multiple_markers()) { - $initialsubmissions = $this->get_single_marker_initial_grade_submissions_to_mark($coursework->id, $userid,$coursework->allocation_enabled()); + $initialsubmissions = $this->get_single_marker_initial_grade_submissions_to_mark($coursework->id, $userid, $coursework->allocation_enabled()); } else if ($coursework->sampling_enabled() && !$coursework->allocation_enabled()) { // - $initialsubmissions = $this->get_multiple_to_mark_sampled_initial_grade_submissions($coursework->id,$userid); + $initialsubmissions = $this->get_multiple_to_mark_sampled_initial_grade_submissions($coursework->id, $userid); } else { - $initialsubmissions = $this->get_multiple_to_mark_initial_grade_submissions($coursework->id,$userid,$coursework->get_max_markers(),$coursework->allocation_enabled()); + $initialsubmissions = $this->get_multiple_to_mark_initial_grade_submissions($coursework->id, $userid, $coursework->get_max_markers(), $coursework->allocation_enabled()); } } - return (!empty($initialsubmissions)) ? count($initialsubmissions) : 0 ; + return (!empty($initialsubmissions)) ? count($initialsubmissions) : 0; } - /** * @param $cwkrecord * @param $userid * @return int */ - public function get_to_grade_agreed_count($cwkrecord,$userid) { + public function get_to_grade_agreed_count($cwkrecord, $userid) { - $coursework = new \mod_coursework\models\coursework($cwkrecord); + $coursework = new \mod_coursework\models\coursework($cwkrecord); - $agreedsubmissions = array(); + $agreedsubmissions = []; //AGREED GRADE INFORMATION - if ($this->should_get_to_mark_agreed_grade_info($coursework->id,$userid) && $coursework->has_multiple_markers()) { + 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()); + $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; + return (!empty($agreedsubmissions)) ? count($agreedsubmissions) : 0; } - /** * @param $courseworkid * @param bool $userid * @param bool $allocationenabled * @return array */ - private function get_single_marker_initial_grade_submissions_to_mark($courseworkid, $userid=false, $allocationenabled=false) { + private function get_single_marker_initial_grade_submissions_to_mark($courseworkid, $userid=false, $allocationenabled=false) { global $DB; - $sqlparams = array(); - $sqltable = ""; - $sqlextra = ""; + $sqlparams = []; + $sqltable = ""; + $sqlextra = ""; - if ($allocationenabled) { - //we only have to check for submissions allocated to this user - $sqltable = ", {coursework_allocation_pairs} cap "; + if ($allocationenabled) { + // We only have to check for submissions allocated to this user + $sqltable = ", {coursework_allocation_pairs} cap "; - $sqlextra = " - AND cap.courseworkid = cs.courseworkid + $sqlextra = " AND cap.courseworkid = cs.courseworkid AND cap.allocatableid = cs.allocatableid AND cap.allocatabletype = cs.allocatabletype AND cap.assessorid = :assessorid "; - $sqlparams['assessorid'] = $userid; + $sqlparams['assessorid'] = $userid; } - $sql = "SELECT cs.id as submissionid + $sql = "SELECT cs.id as submissionid FROM {coursework_submissions} cs LEFT JOIN {coursework_feedbacks} f ON cs.id = f.submissionid {$sqltable} WHERE f.id IS NULL AND cs.finalised = 1 - AND cs.courseworkid = :courseworkid - {$sqlextra} + AND cs.courseworkid = :courseworkid + {$sqlextra} "; - $sqlparams['courseworkid'] = $courseworkid; + $sqlparams['courseworkid'] = $courseworkid; return $DB->get_records_sql($sql, $sqlparams); } - /** * @param $courseworkid * @param $userid * @return array */ - private function get_multiple_to_mark_sampled_initial_grade_submissions($courseworkid,$userid) { + private function get_multiple_to_mark_sampled_initial_grade_submissions($courseworkid, $userid) { global $DB; $countsamples = 'CASE WHEN a.id = NULL THEN 0 ELSE COUNT(a.id)+1 END'; - $sql = " SELECT *, + $sql = " SELECT *, $countsamples AS count_samples, COUNT(a.id) AS ssmID FROM( - SELECT cs.id AS csid, f.id AS fid, cs.allocatableid ,ssm.id, COUNT(f.id) AS count_feedback, + SELECT cs.id AS csid, f.id AS fid, cs.allocatableid, ssm.id, COUNT(f.id) AS count_feedback, cs.courseworkid FROM {coursework_submissions} cs LEFT JOIN {coursework_feedbacks} f ON f.submissionid= cs.id @@ -141,16 +156,14 @@ private function get_multiple_to_mark_sampled_initial_grade_submissions($coursew GROUP BY a.allocatableid, a.csid, a.fid, a.id, a.count_feedback, a.courseworkid HAVING (count_feedback < $countsamples )"; - $sqlparams = array(); - $sqlparams['subassessorid'] = $userid; - $sqlparams['subcourseworkid'] = $courseworkid; - $sqlparams['courseworkid'] = $courseworkid; - + $sqlparams = []; + $sqlparams['subassessorid'] = $userid; + $sqlparams['subcourseworkid'] = $courseworkid; + $sqlparams['courseworkid'] = $courseworkid; return $DB->get_records_sql($sql, $sqlparams); } - /** * @param $courseworkid * @param $userid @@ -158,82 +171,75 @@ private function get_multiple_to_mark_sampled_initial_grade_submissions($coursew * @param $allocationenabled * @return array */ - private function get_multiple_to_mark_initial_grade_submissions($courseworkid,$userid,$numberofmarkers,$allocationenabled) { + private function get_multiple_to_mark_initial_grade_submissions($courseworkid, $userid, $numberofmarkers, $allocationenabled) { global $DB; - $sqlparams = array(); - $sqltable = ''; - $sqlextra = ''; + $sqlparams = []; + $sqltable = ''; + $sqlextra = ''; - if ($allocationenabled) { - //we only have to check for submissions allocated to this user - $sqltable = ", {coursework_allocation_pairs} cap "; + if ($allocationenabled) { + // We only have to check for submissions allocated to this user + $sqltable = ", {coursework_allocation_pairs} cap "; - $sqlextra = " + $sqlextra = " AND cap.courseworkid = cs.courseworkid AND cap.allocatableid = cs.allocatableid AND cap.allocatabletype = cs.allocatabletype AND cap.assessorid = :assessorid2 "; - $sqlparams['assessorid2'] = $userid; + $sqlparams['assessorid2'] = $userid; } - - $sql = "SELECT cs.id AS submissionid, COUNT(f.id) AS count_feedback + $sql = "SELECT cs.id AS submissionid, COUNT(f.id) AS count_feedback FROM {coursework_submissions} cs LEFT JOIN {coursework_feedbacks} f ON cs.id = f.submissionid {$sqltable} WHERE cs.finalised = 1 - AND cs.courseworkid = :courseworkid + AND cs.courseworkid = :courseworkid AND (f.assessorid != :assessorid OR f.assessorid IS NULL) {$sqlextra} - AND cs.id NOT IN (SELECT sub.id FROM - {coursework_feedbacks} feed JOIN - {coursework_submissions} sub ON sub.id = feed.submissionid + AND cs.id NOT IN (SELECT sub.id FROM + {coursework_feedbacks} feed + JOIN {coursework_submissions} sub ON sub.id = feed.submissionid WHERE assessorid = :subassessorid AND sub.courseworkid= :subcourseworkid) GROUP BY cs.id, f.id HAVING (COUNT(f.id) < :numofmarkers)"; - - $sqlparams['subassessorid'] = $userid; - $sqlparams['subcourseworkid'] = $courseworkid; - $sqlparams['courseworkid'] = $courseworkid; - $sqlparams['numofmarkers'] = $numberofmarkers; - $sqlparams['assessorid'] = $userid; - + $sqlparams['subassessorid'] = $userid; + $sqlparams['subcourseworkid'] = $courseworkid; + $sqlparams['courseworkid'] = $courseworkid; + $sqlparams['numofmarkers'] = $numberofmarkers; + $sqlparams['assessorid'] = $userid; return $DB->get_records_sql($sql, $sqlparams); } - /** * @param $courseworkid * @param $numberofmarkers * @return array */ - private function get_to_grade_agreed_grade_submissions($courseworkid,$numberofmarkers){ + private function get_to_grade_agreed_grade_submissions($courseworkid, $numberofmarkers) { global $DB; $sql = "SELECT cs.id as submissionid, COUNT(cs.id) AS count_feedback - FROM {coursework_submissions} cs , - {coursework_feedbacks} f + FROM {coursework_submissions} cs , + {coursework_feedbacks} f WHERE f.submissionid= cs.id AND cs.finalised = 1 AND cs.courseworkid = :courseworkid GROUP BY cs.id HAVING (COUNT(cs.id) = :numofmarkers)"; - $sqlparams['numofmarkers'] = $numberofmarkers; $sqlparams['courseworkid'] = $courseworkid; - return $DB->get_records_sql($sql, $sqlparams); } - /** * @param $courseworkid * @return array @@ -243,10 +249,10 @@ private function get_to_grade_agreed_grade_sampled_submissions($courseworkid) { global $DB; $countsamples = 'CASE WHEN a.id = NULL THEN 0 ELSE COUNT(a.id)+1 END'; - $sql = "SELECT *, + $sql = "SELECT *, $countsamples AS count_samples, COUNT(a.id) AS ssmID FROM( - SELECT f.id AS fid, cs.id AS csid, cs.allocatableid ,ssm.id, COUNT(f.id) AS count_feedback, + SELECT f.id AS fid, cs.id AS csid, cs.allocatableid, ssm.id, COUNT(f.id) AS count_feedback, cs.courseworkid FROM {coursework_submissions} cs LEFT JOIN {coursework_feedbacks} f ON f.submissionid= cs.id @@ -256,51 +262,48 @@ private function get_to_grade_agreed_grade_sampled_submissions($courseworkid) { GROUP BY cs.allocatableid, ssm.stage_identifier, f.id, cs.id, ssm.id ) a GROUP BY a.allocatableid, a.csid, a.fid, a.id, a.count_feedback, a.courseworkid - HAVING (count_feedback = $countsamples AND $countsamples > 1 );"; + HAVING (count_feedback = $countsamples AND $countsamples > 1 );"; $sqlparams['courseworkid'] = $courseworkid; return $DB->get_records_sql($sql, $sqlparams); } - /** * @param $course_id * @param $user_id * @return bool */ - private function has_agreed_grade($course_id,$user_id) { + private function has_agreed_grade($course_id, $user_id) { - $coursecontext = \context_course::instance($course_id); + $coursecontext = \context_course::instance($course_id); - return has_capability('mod/coursework:addagreedgrade',$coursecontext,$user_id) || has_capability('mod/coursework:addallocatedagreedgrade',$coursecontext,$user_id); + return has_capability('mod/coursework:addagreedgrade', $coursecontext, $user_id) || has_capability('mod/coursework:addallocatedagreedgrade', $coursecontext, $user_id); } - /** * @param $course_id * @param $user_id * @return bool */ - private function has_initial_grade($course_id,$user_id) { + private function has_initial_grade($course_id, $user_id) { - $coursecontext = \context_course::instance($course_id); + $coursecontext = \context_course::instance($course_id); - return has_capability('mod/coursework:addinitialgrade',$coursecontext,$user_id); + return has_capability('mod/coursework:addinitialgrade', $coursecontext, $user_id); } - /** * @param $courseworkid * @param $userid * @return bool */ - private function should_get_to_mark_initial_grade_info($courseworkid,$userid) { + private function should_get_to_mark_initial_grade_info($courseworkid, $userid) { - $coursework = new \mod_coursework\models\coursework($courseworkid); + $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); + // Findout if the user can create an initial grade + $user_has_initial_grade_capability = $this->has_initial_grade($coursework->get_course()->id, $userid); return $user_has_initial_grade_capability; } @@ -310,12 +313,12 @@ private function should_get_to_mark_initial_grade_info($courseworkid,$userid) * @param $userid * @return bool */ - private function should_get_to_mark_agreed_grade_info($courseworkid,$userid) { + private function should_get_to_mark_agreed_grade_info($courseworkid, $userid) { - $coursework = new \mod_coursework\models\coursework($courseworkid); + $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); + // Findout if the user can create an initial grade + $user_has_agreed_grade_capability = $this->has_agreed_grade($coursework->get_course()->id, $userid); return $user_has_agreed_grade_capability; diff --git a/classes/models/personal_deadline.php b/classes/models/personal_deadline.php index c8349b18..b02713bd 100644 --- a/classes/models/personal_deadline.php +++ b/classes/models/personal_deadline.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\models; @@ -47,7 +67,7 @@ public function get_allocatable() { * Function to check if extension for this personal deadline (alloctable) exists * @return static */ - public function extension_exists(){ + public function extension_exists() { $coursework = $this->get_coursework(); $params = array('courseworkid' => $coursework->id, @@ -76,7 +96,6 @@ public static function get_personal_deadline_for_student($student, $coursework) } } - /** * cache array * @@ -133,4 +152,4 @@ protected function after_destroy() { self::remove_cache($this->courseworkid); } -} \ No newline at end of file +} diff --git a/classes/models/plagiarism_flag.php b/classes/models/plagiarism_flag.php index d5e5bf1b..ec51b741 100644 --- a/classes/models/plagiarism_flag.php +++ b/classes/models/plagiarism_flag.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\models; @@ -29,10 +49,10 @@ class plagiarism_flag extends table_base { /** * Constants with Statuses for Plagiarism flagging */ - const INVESTIGATION = 0; - const RELEASED = 1; - const CLEARED = 2; - const NOTCLEARED = 3; + const INVESTIGATION = 0; + const RELEASED = 1; + const CLEARED = 2; + const NOTCLEARED = 3; /** * @return mixed|\mod_coursework_coursework @@ -71,13 +91,12 @@ public static function get_plagiarism_flag($submission) { return $result; } - /** * @return bool */ - public function can_release_grades(){ + public function can_release_grades() { - switch ($this->status){ + switch ($this->status) { case self::INVESTIGATION: case self::NOTCLEARED: @@ -147,5 +166,4 @@ protected function after_destroy() { self::remove_cache($this->courseworkid); } - -} \ No newline at end of file +} diff --git a/classes/models/reminder.php b/classes/models/reminder.php index 36be80e2..c15c74ab 100644 --- a/classes/models/reminder.php +++ b/classes/models/reminder.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\models; @@ -12,4 +32,4 @@ class reminder extends table_base { protected static $table_name = 'coursework_reminder'; -} \ No newline at end of file +} diff --git a/classes/models/sample_set_rule.php b/classes/models/sample_set_rule.php index b1aa21b8..465bbe23 100644 --- a/classes/models/sample_set_rule.php +++ b/classes/models/sample_set_rule.php @@ -17,7 +17,7 @@ namespace mod_coursework\models; use mod_coursework\allocation\allocatable; -use \mod_coursework\stages\base as stage_base; +use mod_coursework\stages\base as stage_base; /** * This file keeps track of upgrades to the eassessment module @@ -29,8 +29,7 @@ * it cannot do itself, it will tell you what you need to do. The commands in * here will all be database-neutral, using the functions defined in DLL libraries. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -41,7 +40,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Forms a base for the moderation set rules, which determine various sets of students which * need to be included in the set e.g. lowest 40%. @@ -101,15 +99,14 @@ abstract class sample_set_rule extends table_base implements renderable { 'minimum' ); - /** * @param bool|int|stdClass $dbrecord */ public function __construct($coursework) { - $this->coursework = $coursework; + $this->coursework = $coursework; - //parent::__construct($dbrecord); + // parent::__construct($dbrecord); // We cannot set this from outside if we are making a new one. if (!isset($this->ruleorder)) { diff --git a/classes/models/submission.php b/classes/models/submission.php index 37029efb..c6b6a601 100644 --- a/classes/models/submission.php +++ b/classes/models/submission.php @@ -14,6 +14,12 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\models; use context; @@ -21,7 +27,7 @@ use mod_coursework\ability; use mod_coursework\allocation\allocatable; use mod_coursework\grade_judge; -use \mod_coursework\submission_files; +use mod_coursework\submission_files; use mod_coursework\framework\table_base; use moodle_database; use moodle_url; @@ -248,16 +254,16 @@ public static function unfinalised_past_deadline() { $deadline = $submission->deadline; $submission = static::find($submission); - if ($submission->get_coursework()->personal_deadlines_enabled()){ + if ($submission->get_coursework()->personal_deadlines_enabled()) { $deadline = $submission->submission_personal_deadline(); } - - if ($deadline < time()){ + + if ($deadline < time()) { // if deadline passed check if extension exists - if ($submission->has_extension()){ - //check if extension is valid + if ($submission->has_extension()) { + // Check if extension is valid $extension = $submission->submission_extension(); - if($extension->extended_deadline > time()){ + if ($extension->extended_deadline > time()) { //unset as it doesn't need to be autofinalise yet unset($submissions[$submission->id]); } @@ -347,7 +353,6 @@ public function submit_plagiarism($type = null) { $files = $fs->get_area_files($this->get_context_id(), 'mod_coursework', 'submission', $this->id, "id", false); - $params = array( 'context' => \context_module::instance($this->get_coursework()->get_course_module()->id), 'courseid' => $this->get_course_id(), @@ -360,7 +365,6 @@ public function submit_plagiarism($type = null) { ) ); - $event = \mod_coursework\event\assessable_uploaded::create($params); //$event->set_legacy_files($files); $event->trigger(); @@ -380,7 +384,7 @@ public function get_submission_files($reset = false) { } if ($this->id < 1 || $this->get_context_id() < 1) { - return new submission_files(array(), $this); + return new submission_files([], $this); } $submission_files = $this->get_files(); @@ -391,7 +395,7 @@ public function get_submission_files($reset = false) { return $this->submission_files; } - $files = new submission_files(array(), $this); + $files = new submission_files([], $this); return $files; } @@ -457,7 +461,7 @@ public function get_first_feedback() { public function get_assessor_feedbacks() { if (!$this->id) { // No submission - empty placeholder. - return array(); + return []; } if (!isset(feedback::$pool[$this->courseworkid]['submissionid-stage_identifier_index'])) { @@ -505,18 +509,17 @@ public function get_assessor_allocation_by_stage($stage_identifier) { } - /** * @return mixed|feedback|string * @throws \dml_missing_record_exception * @throws \dml_multiple_records_exception */ - public function get_agreed_grade(){ + public function get_agreed_grade() { global $DB; if (!$this->id) { // No submission - empty placeholder. - return array(); + return []; } $params = [ @@ -608,8 +611,6 @@ public function get_state() { $hasfinalfeedback = (bool)$this->get_final_feedback(); $maxfeedbacksreached = count($assessor_feedbacks) >= $this->max_number_of_feedbacks(); - - if ($hasfinalfeedback) { return self::FINAL_GRADED; } @@ -759,7 +760,6 @@ public function user_has_submitted_feedback($userid = 0) { return false; } - /* * As with the author id field this function was created to verify that coursework will work correctly with Turnitin * Plagiarism plugin that requires the author of a submission to @@ -769,11 +769,11 @@ public function get_author_id() { $id = $USER->id; - //if this is a submission on behalf of the student and it is a group submission we have to make sure + // If this is a submission on behalf of the student and it is a group submission we have to make sure // the author is the first member of the group if ($this->is_submission_on_behalf()) { - if ( $this->get_coursework()->is_configured_to_have_group_submissions()) { + if ( $this->get_coursework()->is_configured_to_have_group_submissions()) { $members = groups_get_members($this->allocatableid, 'u.id', 'id'); if ($members) { $id = reset($members)->id; @@ -797,21 +797,21 @@ public function get_author_id() { * @param $groupid * @return array */ - public function get_tii_group_member_with_eula($groupid) { + public function get_tii_group_member_with_eula($groupid) { global $DB; - $sql = " + $sql = " SELECT gm.userid as id FROM {groups_members} gm, {turnitintooltwo_users} tu WHERE tu.userid = gm.userid AND user_agreement_accepted != 0 - AND gm.groupid = ? + AND gm.groupid = ? ORDER BY gm.userid LIMIT 1"; - return $DB->get_record_sql($sql,array($groupid)); + return $DB->get_record_sql($sql, array($groupid)); } /** @@ -825,34 +825,34 @@ public function get_status_text() { switch ($this->get_state()) { - case submission::NOT_SUBMITTED: + case self::NOT_SUBMITTED: $statustext = get_string('statusnotsubmitted', 'coursework'); break; - case submission::SUBMITTED: + case self::SUBMITTED: $allowearlyfinalisation = $this->get_coursework()->allowearlyfinalisation; - $statustext = ($allowearlyfinalisation)?get_string('statusnotfinalised', 'coursework') : get_string('submitted', 'coursework'); + $statustext = ($allowearlyfinalisation) ?get_string('statusnotfinalised', 'coursework') : get_string('submitted', 'coursework'); break; - case submission::FINALISED: + case self::FINALISED: $statustext = get_string('statussubmittedfinalised', 'coursework'); break; - case submission::PARTIALLY_GRADED: + case self::PARTIALLY_GRADED: $statustext = get_string('statuspartiallygraded', 'coursework'); - if($this->any_editable_feedback_exists()){ + if ($this->any_editable_feedback_exists()) { $statustext = get_string('statusfullygraded', 'coursework'). "
"; - $statustext .= get_string('stilleditable', 'coursework'); + $statustext .= get_string('stilleditable', 'coursework'); } break; - case submission::FULLY_GRADED: + case self::FULLY_GRADED: $statustext = get_string('statusfullygraded', 'coursework'); break; - case submission::FINAL_GRADED: + case self::FINAL_GRADED: $spanfinalgraded = html_writer::tag('span', get_string('statusfinalgraded', 'coursework'), array('class' => 'highlight')); @@ -861,12 +861,12 @@ public function get_status_text() { get_string('statusfinalgradedsingle', 'coursework'), array('class' => 'highlight')); $statustext = $this->has_multiple_markers() && $this->sampled_feedback_exists() ? $spanfinalgraded : $spanfinalgradedsingle; - if($this->editable_final_feedback_exist()){ + if ($this->editable_final_feedback_exist()) { $statustext .= "
". get_string('finalgradestilleditable', 'coursework'); } break; - case submission::PUBLISHED: + case self::PUBLISHED: $statustext = get_string('statuspublished', 'coursework'); if (!$this->coursework->deadline_has_passed()) { $statustext .= ' '.get_string('released_early', 'mod_coursework'); @@ -895,35 +895,32 @@ public function belongs_to_user($user) { * @return bool */ public function ready_to_grade() { - return $this->get_state() >= submission::FINALISED; + return $this->get_state() >= self::FINALISED; } /** * @return bool */ public function already_published() { - return $this->get_state() >= submission::PUBLISHED; + return $this->get_state() >= self::PUBLISHED; } - - /** * @return bool */ public function all_inital_graded() { - return $this->get_state() >= submission::FULLY_GRADED; + return $this->get_state() >= self::FULLY_GRADED; } - public function is_finalised() { - return $this->get_state() == submission::FINALISED; + public function is_finalised() { + return $this->get_state() == self::FINALISED; } - /** * @return bool */ public function final_grade_agreed() { - return $this->get_state() >= submission::FINAL_GRADED; + return $this->get_state() >= self::FINAL_GRADED; } /** @@ -941,7 +938,7 @@ public function get_allocatable() { * @return user[] */ public function get_students() { - $allocatables = array(); + $allocatables = []; if ($this->get_coursework()->is_configured_to_have_group_submissions() && $this->allocatabletype == 'group') { /** * @var group $group @@ -972,7 +969,7 @@ public function ready_to_publish() { } $grade_judge = new grade_judge($this->get_coursework()); - if($grade_judge->has_feedback_that_is_promoted_to_gradebook($this) && $this->final_grade_agreed() && !$this->editable_final_feedback_exist()) { + if ($grade_judge->has_feedback_that_is_promoted_to_gradebook($this) && $this->final_grade_agreed() && !$this->editable_final_feedback_exist()) { return true; } @@ -1029,7 +1026,7 @@ private function get_grades_to_update() { // Only updating, not actually creating? $grades = grade_get_grades($this->get_course_id(), 'mod', 'coursework', $this->get_coursework()->id, $student_ids); $grades = $grades->items[0]->grades; - foreach($student_ids as $userid) { + foreach ($student_ids as $userid) { if (!array_key_exists($userid, $grades)) { $grades[$userid] = new stdClass(); } @@ -1052,8 +1049,8 @@ public function get_last_submitter() { */ public function is_late() { // check if submission has personal deadline - if ($this->get_coursework()->personaldeadlineenabled){ - $deadline = $this->submission_personal_deadline(); + if ($this->get_coursework()->personaldeadlineenabled) { + $deadline = $this->submission_personal_deadline(); } else { // if not, use coursework default deadline $deadline = $this->get_coursework()->get_deadline(); } @@ -1121,7 +1118,7 @@ public function extract_extension_from_file_name($file_name) { private function rename_file($file, $counter) { // if a submission was made of behalf of student/group, we need to use owner's id, not the person who submitted it - if ($this->is_submission_on_behalf()){ + if ($this->is_submission_on_behalf()) { $userid = $this->allocatableid; } else { $userid = $this->userid; @@ -1145,7 +1142,7 @@ public function time_submitted() { return $this->timesubmitted; } - public function sampled_feedback_exists(){ + public function sampled_feedback_exists() { global $DB; return $DB->record_exists('coursework_sample_set_mbrs', array('courseworkid' => $this->courseworkid, 'allocatableid' => $this->get_allocatable()->id(), @@ -1153,10 +1150,10 @@ public function sampled_feedback_exists(){ } - public function max_number_of_feedbacks(){ + public function max_number_of_feedbacks() { global $DB; - if ($this->get_coursework()->sampling_enabled()){ + if ($this->get_coursework()->sampling_enabled()) { // calculate how many stages(markers) are enabled for this submission $parameters = array('courseworkid' => $this->coursework->id, 'allocatableid' => $this->get_allocatable()->id(), @@ -1180,7 +1177,7 @@ public function max_number_of_feedbacks(){ * @return array|bool * @throws \coding_exception */ - public function students_for_gradebook(){ + public function students_for_gradebook() { if ($this->get_coursework()->is_configured_to_have_group_submissions()) { $students = groups_get_members($this->allocatableid); return $students; @@ -1207,10 +1204,10 @@ private function students_for_gradng() { /** * @return bool */ - private function is_submission_on_behalf(){ + private function is_submission_on_behalf() { global $USER; - if (($this->allocatableid == $USER->id && $this->allocatabletype != 'group') || groups_is_member($this->allocatableid)){ + if (($this->allocatableid == $USER->id && $this->allocatabletype != 'group') || groups_is_member($this->allocatableid)) { return false; } else { return true; @@ -1230,7 +1227,6 @@ public function get_submissions_in_sample() { return $records; } - /** * Function to get samplings for the submission * @return array @@ -1247,7 +1243,6 @@ public function get_submissions_in_sample_by_stage($stage_identifier) { return $record; } - /** * Check if submission has an extension * @@ -1278,12 +1273,12 @@ public function submission_extension() { * @return mixed * @throws \coding_exception */ - public function submission_personal_deadline(){ + public function submission_personal_deadline() { $allocatableid = $this->get_allocatable()->id(); $allocatabletype = $this->get_allocatable()->type(); $personal_deadline = personal_deadline::get_object($this->courseworkid, 'allocatableid-allocatabletype', [$allocatableid, $allocatabletype]); - if ($personal_deadline){ + if ($personal_deadline) { $personal_deadline = $personal_deadline->personal_deadline; } else { $personal_deadline = $this->get_coursework()->deadline; @@ -1293,14 +1288,12 @@ public function submission_personal_deadline(){ } - - /** * Check if submission was submitted within the extension time * * @return bool */ - public function submitted_within_extension(){ + public function submitted_within_extension() { return $this->time_submitted() < $this->extension_deadline(); } @@ -1308,7 +1301,7 @@ public function submitted_within_extension(){ * Retrieve submission's extended deadline * @return mixed */ - public function extension_deadline(){ + public function extension_deadline() { return $this->submission_extension()->extended_deadline; } @@ -1329,9 +1322,6 @@ public function is_assessor_initial_grader() { return false; } - - - /** * Tells us whether any initial feedbacks for this submission are editable * This is only for double marked courseworks @@ -1359,10 +1349,9 @@ public function editable_feedbacks_exist() { } } - return (empty($editablefeedbacks)) ? false : $editablefeedbacks; + return (empty($editablefeedbacks)) ? false : $editablefeedbacks; } - /** * Tells us whether any final feedback for this submission is editable * @@ -1380,7 +1369,7 @@ public function editable_final_feedback_exist() { if ($final_feedback->timecreated + $grade_editing_time > time()) { $this->editable_final_feedback = true; } - } elseif ($final_feedback->finalised == 0 && $final_feedback->assessorid <> 0) { + } else if ($final_feedback->finalised == 0 && $final_feedback->assessorid <> 0) { $this->editable_final_feedback = true; } } @@ -1399,7 +1388,7 @@ public function final_draft_feedbacks_exist() { $this->get_coursework()->get_grade_editing_time(); - $sql = " + $sql = " SELECT * FROM {coursework} c, {coursework_submissions} cs, @@ -1414,21 +1403,21 @@ public function final_draft_feedbacks_exist() { AND cf.timecreated + c.gradeeditingtime > :time "; - $editablefeedbacks = $DB->get_records_sql($sql,array('submissionid'=>$this->id,'time'=>time())); + $editablefeedbacks = $DB->get_records_sql($sql, array('submissionid' => $this->id, 'time' => time())); - return (empty($editablefeedbacks)) ? false : $editablefeedbacks; + return (empty($editablefeedbacks)) ? false : $editablefeedbacks; } /* * Determines whether the current user is able to add a turnitin grademark to this submission */ - function can_add_tii_grademark() { - $canadd = false; + function can_add_tii_grademark() { + $canadd = false; if ($this->get_coursework()->get_max_markers() == 1) { - $canadd = (has_any_capability(array('mod/coursework:addinitialgrade','mod/coursework:addministergrades'),$this->get_context()) && $this->ready_to_grade()) ; + $canadd = (has_any_capability(array('mod/coursework:addinitialgrade', 'mod/coursework:addministergrades'), $this->get_context()) && $this->ready_to_grade()); } else { - $canadd = (has_any_capability(array('mod/coursework:addagreedgrade','mod/coursework:addallocatedagreedgrade','mod/coursework:addministergrades'),$this->get_context()) && $this->all_inital_graded()) ; + $canadd = (has_any_capability(array('mod/coursework:addagreedgrade', 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:addministergrades'), $this->get_context()) && $this->all_inital_graded()); } return $canadd; @@ -1439,7 +1428,7 @@ function can_add_tii_grademark() { * * @return bool */ - function any_editable_feedback_exists(){ + function any_editable_feedback_exists() { return count($this->get_assessor_feedbacks()) >= $this->max_number_of_feedbacks() && $this->editable_feedbacks_exist(); } @@ -1449,7 +1438,7 @@ function any_editable_feedback_exists(){ * * @return bool */ - function has_valid_extension(){ + function has_valid_extension() { deadline_extension::fill_pool_coursework($this->courseworkid); $extension = deadline_extension::get_object($this->courseworkid, 'allocatableid-allocatabletype', [$this->allocatableid, $this->allocatabletype]); @@ -1461,9 +1450,8 @@ function has_valid_extension(){ return $valid_extension; } - - function can_be_unfinalised() { - return ($this->get_state() == submission::FINALISED); + function can_be_unfinalised() { + return ($this->get_state() == self::FINALISED); } /** @@ -1473,16 +1461,16 @@ function can_be_unfinalised() { * @return bool|false|mixed|stdClass * @throws \dml_exception */ - function has_specific_assessor_feedback($assessorid){ + function has_specific_assessor_feedback($assessorid) { global $DB; - $feedback = $DB->get_record('coursework_feedbacks', array('submissionid'=>$this->id, - 'assessorid'=>$assessorid)); + $feedback = $DB->get_record('coursework_feedbacks', array('submissionid' => $this->id, + 'assessorid' => $assessorid)); - return (empty($feedback)) ? false : $feedback; + return (empty($feedback)) ? false : $feedback; } - //caching + // Caching /** * cache array diff --git a/classes/models/user.php b/classes/models/user.php index 80b6cfc8..d2fd6e47 100644 --- a/classes/models/user.php +++ b/classes/models/user.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * This class allows us to add functionality to the users, despite the fact that Moodle has no @@ -9,8 +29,8 @@ namespace mod_coursework\models; use mod_coursework\framework\table_base; -use \mod_coursework\allocation\allocatable; -use \mod_coursework\allocation\moderatable; +use mod_coursework\allocation\allocatable; +use mod_coursework\allocation\moderatable; use mod_coursework\traits\allocatable_functions; /** @@ -31,7 +51,7 @@ class user extends table_base implements allocatable, moderatable { */ public function __construct($data = false) { $allnames = \core_user\fields::get_name_fields(); - foreach($allnames as $namefield) { + foreach ($allnames as $namefield) { $this->$namefield = ''; } parent::__construct($data); @@ -111,7 +131,6 @@ public function __toString() { return $this->id; } - /** * cache array * @@ -190,5 +209,4 @@ public static function get_object($id) { return self::$pool['id'][$id]; } - -} \ No newline at end of file +} diff --git a/classes/moderation_set_rule/minimum_range_grade_percent.php b/classes/moderation_set_rule/minimum_range_grade_percent.php index e0c32c58..888b48b3 100644 --- a/classes/moderation_set_rule/minimum_range_grade_percent.php +++ b/classes/moderation_set_rule/minimum_range_grade_percent.php @@ -17,8 +17,7 @@ /** * File for a moderation set rule that will include X students from between an upper and lower limit. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -32,7 +31,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Defines a rule that will include all students above or below a particular percentage of * the total grade. @@ -58,7 +56,6 @@ public function adjust_set(array &$moderation_set, array &$potential_allocatable // Convert percentages to raw grades for comparison. global $DB; - $params = array('id' => $this->courseworkid); $maxgrade = $DB->get_field('coursework', 'grade', $params); // Convert percentages to raw grades for comparison. @@ -174,5 +171,4 @@ protected function grade_is_above_lower_limit($grade, $lowerlimit) { return $grade >= $lowerlimit; } - } diff --git a/classes/moderation_set_rule/minimum_range_grade_raw.php b/classes/moderation_set_rule/minimum_range_grade_raw.php index 180ba91c..76985030 100644 --- a/classes/moderation_set_rule/minimum_range_grade_raw.php +++ b/classes/moderation_set_rule/minimum_range_grade_raw.php @@ -17,8 +17,7 @@ /** * File for a moderation set rule that will include X students from between an upper and lower limit. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -31,8 +30,6 @@ defined('MOODLE_INTERNAL') || die(); - - /** * Defines a rule that will include all students above or below a particular percentage of * the total grade. diff --git a/classes/moderation_set_rule/range_grade_percent.php b/classes/moderation_set_rule/range_grade_percent.php index 0502ba61..25cfff42 100644 --- a/classes/moderation_set_rule/range_grade_percent.php +++ b/classes/moderation_set_rule/range_grade_percent.php @@ -18,8 +18,7 @@ * Page that prints a table of all students and all markers so that first marker, second marker, * moderators etc can be allocated manually or automatically. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -32,7 +31,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Defines a rule that will include all students above or below a particular percentage of * the total grade. diff --git a/classes/moderation_set_rule/range_grade_raw.php b/classes/moderation_set_rule/range_grade_raw.php index 2fb23faf..7e4502cf 100644 --- a/classes/moderation_set_rule/range_grade_raw.php +++ b/classes/moderation_set_rule/range_grade_raw.php @@ -18,8 +18,7 @@ * Page that prints a table of all students and all markers so that first marker, second marker, * moderators etc can be allocated manually or automatically. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -32,7 +31,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Defines a rule that will include all students between to raw grade marks. */ @@ -128,5 +126,4 @@ public function get_form_elements() { return $html; } - } diff --git a/classes/moderation_set_rule/range_total_percent.php b/classes/moderation_set_rule/range_total_percent.php index 32e6ba9b..825ed812 100644 --- a/classes/moderation_set_rule/range_total_percent.php +++ b/classes/moderation_set_rule/range_total_percent.php @@ -18,8 +18,7 @@ * Page that prints a table of all students and all markers so that first marker, second marker, * moderators etc can be allocated manually or automatically. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -33,7 +32,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Defines a rule that will include all students between an upper and lower percentage of the total * number. Only really makes sense with lowerlimit as 0. diff --git a/classes/observer.php b/classes/observer.php index 66cecc7e..dba5bcef 100644 --- a/classes/observer.php +++ b/classes/observer.php @@ -17,48 +17,41 @@ /** * Observers * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2016 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - - defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/mod/coursework/lib.php'); class mod_coursework_observer { - - - public static function autoallocate_when_user_added(core\event\role_assigned $event){ + public static function autoallocate_when_user_added(core\event\role_assigned $event) { coursework_role_assigned_event_handler($event); } - public static function autoallocate_when_user_removed(core\event\role_unassigned $event){ + public static function autoallocate_when_user_removed(core\event\role_unassigned $event) { coursework_role_unassigned_event_handler($event); } - public static function coursework_deadline_changed(mod_coursework\event\coursework_deadline_changed $event){ + public static function coursework_deadline_changed(mod_coursework\event\coursework_deadline_changed $event) { coursework_send_deadline_changed_emails($event); } - public static function process_allocation_after_update(core\event\course_module_updated $event){ + public static function process_allocation_after_update(core\event\course_module_updated $event) { coursework_mod_updated($event); } - - - public static function process_allocation_after_creation(core\event\course_module_created $event){ + public static function process_allocation_after_creation(core\event\course_module_created $event) { coursework_mod_updated($event); @@ -67,21 +60,21 @@ public static function process_allocation_after_creation(core\event\course_modul /** * @param \core\event\group_member_added $event */ - public static function process_allocations_when_group_member_added(\core\event\group_member_added $event){ + public static function process_allocations_when_group_member_added(\core\event\group_member_added $event) { course_group_member_added($event); } /** * @param \core\event\group_member_removed $event */ - public static function process_allocations_when_group_member_removed(\core\event\group_member_removed $event){ + public static function process_allocations_when_group_member_removed(\core\event\group_member_removed $event) { course_group_member_removed($event); } /** * @param \core\event\role_assigned $event */ - public static function add_teacher_to_dropdown_when_enrolled(core\event\role_assigned$event){ + public static function add_teacher_to_dropdown_when_enrolled(core\event\role_assigned$event) { teacher_allocation_cache_purge($event); } @@ -89,11 +82,10 @@ public static function add_teacher_to_dropdown_when_enrolled(core\event\role_ass /** * @param \core\event\role_unassigned $event */ - public static function remove_teacher_from_dropdown_when_unenrolled(core\event\role_unassigned$event){ + public static function remove_teacher_from_dropdown_when_unenrolled(core\event\role_unassigned$event) { teacher_removed_allocated_not_graded($event); teacher_allocation_cache_purge($event); } - -} \ No newline at end of file +} diff --git a/classes/personal_deadline/allocatable.php b/classes/personal_deadline/allocatable.php index 919dc25b..b1e0441f 100644 --- a/classes/personal_deadline/allocatable.php +++ b/classes/personal_deadline/allocatable.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\personal_deadline; use mod_coursework\models\coursework; @@ -75,4 +95,4 @@ public function has_all_initial_feedbacks($coursework); * @return submission */ public function get_submission($coursework); -} \ No newline at end of file +} diff --git a/classes/personal_deadline/table/builder.php b/classes/personal_deadline/table/builder.php index 8629555d..ec6d52e2 100644 --- a/classes/personal_deadline/table/builder.php +++ b/classes/personal_deadline/table/builder.php @@ -19,8 +19,7 @@ /** * Class file for the renderable object that makes the table for assigning personal deadlines to students. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -64,7 +63,6 @@ public function __construct($coursework, array $options) { $this->options = $options; } - /** * Takes the raw data, instantiates each row as a new renderable object and returns the whole lot. * @@ -73,7 +71,7 @@ public function __construct($coursework, array $options) { public function get_rows() { $allocatables = $this->get_coursework()->get_allocatables(); - $rows = array(); + $rows = []; foreach ($allocatables as $allocatable) { $rows[] = new row_builder($this, $allocatable); } @@ -87,7 +85,6 @@ public function get_rows() { $method_name)); } - return $rows; } @@ -124,7 +121,6 @@ public function get_allocatable_cell() { return new user_cell($items); } - /** * @return personal_deadline_cell */ diff --git a/classes/personal_deadline/table/row/builder.php b/classes/personal_deadline/table/row/builder.php index 0f9f3a87..f6e8bb89 100644 --- a/classes/personal_deadline/table/row/builder.php +++ b/classes/personal_deadline/table/row/builder.php @@ -19,8 +19,7 @@ /** * Class file for the renderable object that makes a single row in the marker personal deadline table. * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -60,7 +59,6 @@ public function __construct($personal_deadline_table, $allocatable) { $this->allocatable = $allocatable; } - /** * @return allocatable */ @@ -121,7 +119,7 @@ public function get_student_firstname() { $allocatable = $this->get_allocatable(); if (empty($allocatable->firstname)) { - $this->allocatable = user::find($allocatable); + $this->allocatable = user::find($allocatable); } return $this->get_allocatable()->firstname; @@ -136,7 +134,7 @@ public function get_student_lastname() { $allocatable = $this->get_allocatable(); if (empty($allocatable->lastname)) { - $this->allocatable = user::find($allocatable); + $this->allocatable = user::find($allocatable); } return $this->get_allocatable()->lastname; @@ -151,13 +149,12 @@ public function get_idnumber() { $allocatable = $this->get_allocatable(); if (empty($allocatable->idnumber)) { - $this->allocatable = user::find($allocatable); + $this->allocatable = user::find($allocatable); } return $this->get_allocatable()->idnumber; } - /** * @return string */ @@ -167,7 +164,7 @@ public function get_email() { $allocatable = $this->get_allocatable(); if (empty($allocatable->email)) { - $this->allocatable = user::find($allocatable); + $this->allocatable = user::find($allocatable); } return $this->get_allocatable()->email; @@ -190,8 +187,8 @@ public function get_personal_deadlines() { $personal_deadline = $DB->get_record('coursework_person_deadlines', array('courseworkid' => $this->get_coursework()->id, 'allocatableid' => $this->allocatable->id(), - 'allocatabletype'=> $this->allocatable->type())); - if ($personal_deadline){ + 'allocatabletype' => $this->allocatable->type())); + if ($personal_deadline) { $personal_deadline = $personal_deadline->personal_deadline; } else { $personal_deadline = $this->get_coursework()->deadline; @@ -200,27 +197,24 @@ public function get_personal_deadlines() { return $personal_deadline; } - - public function get_submission_status() { + public function get_submission_status() { global $DB; - $submission_db = $DB->get_record('coursework_submissions', + $submission_db = $DB->get_record('coursework_submissions', array('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($submission_db); - $statustext = get_string('statusnotsubmitted','mod_coursework'); + $statustext = get_string('statusnotsubmitted', 'mod_coursework'); - if (!empty($submission) && $submission->is_finalised()) { - $statustext = get_string('finalisedsubmission','mod_coursework'); + if (!empty($submission) && $submission->is_finalised()) { + $statustext = get_string('finalisedsubmission', 'mod_coursework'); } else if (!empty($submission)) { - $statustext = $submission->get_status_text(); + $statustext = $submission->get_status_text(); } return $statustext; } - - } diff --git a/classes/plagiarism_helpers/base.php b/classes/plagiarism_helpers/base.php index 4fc98e52..60c2ce80 100644 --- a/classes/plagiarism_helpers/base.php +++ b/classes/plagiarism_helpers/base.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\plagiarism_helpers; use mod_coursework\models\coursework; @@ -43,4 +63,4 @@ abstract public function enabled(); */ abstract public function human_readable_name(); -} \ No newline at end of file +} diff --git a/classes/plagiarism_helpers/turnitin.php b/classes/plagiarism_helpers/turnitin.php index ca03191d..ec2c23b8 100644 --- a/classes/plagiarism_helpers/turnitin.php +++ b/classes/plagiarism_helpers/turnitin.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\plagiarism_helpers; @@ -48,4 +68,4 @@ public function enabled() { public function human_readable_name() { return get_string('turnitin', 'plagiarism_turnitin'); } -} \ No newline at end of file +} diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 96537ecb..acc79b7a 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -13,16 +13,23 @@ // // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace mod_coursework\privacy; defined('MOODLE_INTERNAL') || die(); -use \core_privacy\local\metadata\collection; -use \core_privacy\local\request\contextlist; -use \core_privacy\local\request\writer; -use \core_privacy\local\request\approved_contextlist; -use \core_privacy\local\request\transform; -use \core_privacy\local\request\helper; -use \core_privacy\local\request\userlist; -use \core_privacy\local\request\approved_userlist; +use core_privacy\local\metadata\collection; +use core_privacy\local\request\contextlist; +use core_privacy\local\request\writer; +use core_privacy\local\request\approved_contextlist; +use core_privacy\local\request\transform; +use core_privacy\local\request\helper; +use core_privacy\local\request\userlist; +use core_privacy\local\request\approved_userlist; /** * Privacy Subsystem implementation for coursework. * @@ -42,48 +49,48 @@ class provider implements */ 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' + 'assessorid' => 'privacy:metadata:assessorid', + 'timecreated' => 'privacy:metadata:timecreated', + 'timemodified' => 'timemodified', + 'grade' => 'privacy:metadata:grade', + 'submissionid' => 'privacy:metadata:submissionid', + 'feedbackcomment' => 'privacy:metadata:feedbackcomment' ]; $submissions = [ - 'authorid' => 'privacy:metadata:authorid', - 'userid' => 'privacy:metadata:userid', - 'timecreated' => 'privacy:metadata:timecreated', - 'timemodified' => 'timemodified', - 'createdby' => 'createdby', - 'timesubmitted' => 'timesubmitted' + 'authorid' => 'privacy:metadata:authorid', + 'userid' => 'privacy:metadata:userid', + 'timecreated' => 'privacy:metadata:timecreated', + 'timemodified' => 'timemodified', + 'createdby' => 'createdby', + 'timesubmitted' => 'timesubmitted' ]; $extensions = [ 'allocatableid' => 'privacy:metadata:allocatableid', - 'createdbyid' => 'privacy:metadata:createdbyid', + 'createdbyid' => 'privacy:metadata:createdbyid', 'extra_information_text' => 'privacy:metadata:extra_information_text', 'extended_deadline' => 'privacy:metadata:extended_deadline', - 'allocatableuser' => 'privacy:metadata:userid', - 'allocatablegroup' => 'privacy:metadata:groupid' + 'allocatableuser' => 'privacy:metadata:userid', + 'allocatablegroup' => 'privacy:metadata:groupid' ]; $persondeadlines = [ - 'allocatableid' => 'privacy:metadata:allocatableid', - 'createdbyid' => 'privacy:metadata:createdbyid', + 'allocatableid' => 'privacy:metadata:allocatableid', + 'createdbyid' => 'privacy:metadata:createdbyid', 'personal_deadline' => 'privacy:metadata:personal_deadline', - 'allocatableuser' => 'privacy:metadata:userid', - 'allocatablegroup' => 'privacy:metadata:groupid' + 'allocatableuser' => 'privacy:metadata:userid', + 'allocatablegroup' => 'privacy:metadata:groupid' ]; $modagreements = [ - 'moderatorid' => 'privacy:metadata:moderatorid', - 'agreement' => 'privacy:metadata:agreement', - 'modcomment' => 'privacy:metadata:modcomment', - 'timecreated' => 'privacy:metadata:timecreated', - 'timemodified' => 'timemodified' + 'moderatorid' => 'privacy:metadata:moderatorid', + 'agreement' => 'privacy:metadata:agreement', + 'modcomment' => 'privacy:metadata:modcomment', + 'timecreated' => 'privacy:metadata:timecreated', + 'timemodified' => 'timemodified' ]; $plagiarismflags = [ - 'createdby' => 'privacy:metadata:createdby', - 'comment' => 'privacy:metadata:comment', - 'timecreated' => 'privacy:metadata:timecreated', - 'timemodified' => 'timemodified' + 'createdby' => 'privacy:metadata:createdby', + 'comment' => 'privacy:metadata:comment', + 'timecreated' => 'privacy:metadata:timecreated', + 'timemodified' => 'timemodified' ]; $collection->add_database_table('coursework_feedbacks', $feedbacks, 'privacy:metadata:feedbacks'); $collection->add_database_table('coursework_submissions', $submissions, 'privacy:metadata:submissions'); @@ -167,7 +174,6 @@ public static function get_users_in_context(userlist $userlist) { WHERE ctx.id = :contextid AND ctx.contextlevel = :contextlevel"; $userlist->add_from_sql('createdby', $sql, $params); - } /** * Returns all of the contexts that has information relating to the userid. @@ -623,4 +629,4 @@ protected static function export_mod_agreement_data($agreement, $context, $path) writer::with_context($context) ->export_data(array_merge($path, [get_string('privacy:moderator', 'mod_coursework')]), (object) $agreementData); } -} \ No newline at end of file +} diff --git a/classes/render_helpers/grading_report/base_renderer.php b/classes/render_helpers/grading_report/base_renderer.php index ed4ec4e7..bce70543 100644 --- a/classes/render_helpers/grading_report/base_renderer.php +++ b/classes/render_helpers/grading_report/base_renderer.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\render_helpers\grading_report; @@ -14,4 +34,4 @@ public function render_grading_report() { } -} \ No newline at end of file +} diff --git a/classes/render_helpers/grading_report/cells/_user_cell.php b/classes/render_helpers/grading_report/cells/_user_cell.php index 2ed15136..def69931 100644 --- a/classes/render_helpers/grading_report/cells/_user_cell.php +++ b/classes/render_helpers/grading_report/cells/_user_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\render_helpers\grading_report\cells; use core_user; @@ -47,16 +67,16 @@ public function get_table_cell($rowobject) { * @param array $options * @return string */ - public function get_table_header($options = array()) { + public function get_table_header($options = []) { $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'] : '' ; + // 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) { + if ($viewanonymous || !$this->coursework->blindmarking) { $sort_by_first_name = $this->helper_sortable_heading(get_string('firstname'), 'firstname', $options['sorthow'], @@ -83,7 +103,7 @@ public function get_table_header($options = array()) { /** * @return string */ - public function get_table_header_class(){ + public function get_table_header_class() { return 'studentname'; } @@ -110,4 +130,4 @@ private function fullname_format() { public function header_group() { return 'empty'; } -} \ No newline at end of file +} diff --git a/classes/render_helpers/grading_report/cells/allocatable_cell.php b/classes/render_helpers/grading_report/cells/allocatable_cell.php index 8be27a7c..2e801f75 100644 --- a/classes/render_helpers/grading_report/cells/allocatable_cell.php +++ b/classes/render_helpers/grading_report/cells/allocatable_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\render_helpers\grading_report\cells; @@ -8,4 +28,4 @@ */ interface allocatable_cell extends cell_interface { -} \ No newline at end of file +} diff --git a/classes/render_helpers/grading_report/cells/cell_base.php b/classes/render_helpers/grading_report/cells/cell_base.php index 82db8731..d3fdb5a6 100644 --- a/classes/render_helpers/grading_report/cells/cell_base.php +++ b/classes/render_helpers/grading_report/cells/cell_base.php @@ -1,7 +1,26 @@ . -namespace mod_coursework\render_helpers\grading_report\cells; +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace mod_coursework\render_helpers\grading_report\cells; use html_writer; use mod_coursework\models\coursework; @@ -20,7 +39,7 @@ abstract class cell_base implements cell_interface { /** * @param array $items */ - public function __construct($items = array()) { + public function __construct($items = []) { $this->coursework = $items['coursework']; $this->after_initialisation($items); } @@ -34,13 +53,13 @@ public function __construct($items = array()) { * @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($display_name, $field, $sort_how, $sortby = '', $tablename='') { global $PAGE; $params = array('id' => optional_param('id', 0, PARAM_INT)); - $tablename = (!empty($tablename)) ? $tablename.'_' : '' ; + $tablename = (!empty($tablename)) ? $tablename.'_' : ''; if (optional_param($tablename.'page', 0, PARAM_INT) > 0) { $params[$tablename.'page'] = optional_param($tablename.'page', 0, PARAM_INT); @@ -53,15 +72,13 @@ protected function helper_sortable_heading($display_name, $field, $sort_how, $so $params[$tablename.'sorthow'] = 'ASC'; } - - // $url = clone($PAGE->url); // $url->params($params); // Need a little icon to show ASC or DESC. // if ($field == $sortby) { - // $display_name .= ' '; // Keep them on the same line. - // $display_name .= $sort_how == 'ASC' ? '▲' : '▼'; // Small unicode triangles. + // $display_name .= ' '; // Keep them on the same line. + // $display_name .= $sort_how == 'ASC' ? '▲' : '▼'; // Small unicode triangles. // } // return html_writer::link($url, $display_name); @@ -125,9 +142,8 @@ protected function after_initialisation($items) { /** * Override for the header help message */ - public function get_table_header_help_icon(){ + public function get_table_header_help_icon() { } - } diff --git a/classes/render_helpers/grading_report/cells/cell_interface.php b/classes/render_helpers/grading_report/cells/cell_interface.php index 921480db..0dd5bb2d 100644 --- a/classes/render_helpers/grading_report/cells/cell_interface.php +++ b/classes/render_helpers/grading_report/cells/cell_interface.php @@ -1,7 +1,26 @@ . -namespace mod_coursework\render_helpers\grading_report\cells; +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace mod_coursework\render_helpers\grading_report\cells; use html_table_cell; use mod_coursework\grading_table_row_base; @@ -22,8 +41,7 @@ public function get_table_cell($rowobject); * @param array $options * @return string */ - public function get_table_header($options = array()); - + public function get_table_header($options = []); /** * @return string @@ -46,4 +64,4 @@ public function header_group(); * @return mixed */ public function get_table_header_help_icon(); -} \ No newline at end of file +} diff --git a/classes/render_helpers/grading_report/cells/email_cell.php b/classes/render_helpers/grading_report/cells/email_cell.php index cfb4059d..2615fceb 100644 --- a/classes/render_helpers/grading_report/cells/email_cell.php +++ b/classes/render_helpers/grading_report/cells/email_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\render_helpers\grading_report\cells; use core_user; @@ -30,14 +50,14 @@ public function get_table_cell($rowobject) { * @param array $options * @return string */ - public function get_table_header($options = array()) { + public function get_table_header($options = []) { return "Email"; } /** * @return string */ - public function get_table_header_class(){ + public function get_table_header_class() { return 'email_cell'; } @@ -47,4 +67,4 @@ public function get_table_header_class(){ public function header_group() { return 'empty'; } -} \ No newline at end of file +} diff --git a/classes/render_helpers/grading_report/cells/first_name_cell.php b/classes/render_helpers/grading_report/cells/first_name_cell.php index 9f390a1e..3528de99 100644 --- a/classes/render_helpers/grading_report/cells/first_name_cell.php +++ b/classes/render_helpers/grading_report/cells/first_name_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\render_helpers\grading_report\cells; use core_user; @@ -30,14 +50,14 @@ public function get_table_cell($rowobject) { * @param array $options * @return string */ - public function get_table_header($options = array()) { + public function get_table_header($options = []) { return "First Name"; } /** * @return string */ - public function get_table_header_class(){ + public function get_table_header_class() { return 'firstname_cell'; } @@ -47,4 +67,4 @@ public function get_table_header_class(){ public function header_group() { return 'empty'; } -} \ No newline at end of file +} diff --git a/classes/render_helpers/grading_report/cells/first_name_letter_cell.php b/classes/render_helpers/grading_report/cells/first_name_letter_cell.php index 9cf7d910..b6145057 100644 --- a/classes/render_helpers/grading_report/cells/first_name_letter_cell.php +++ b/classes/render_helpers/grading_report/cells/first_name_letter_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\render_helpers\grading_report\cells; use core_user; @@ -38,14 +58,14 @@ public function get_table_cell($rowobject) { * @param array $options * @return string */ - public function get_table_header($options = array()) { + public function get_table_header($options = []) { return "First Letter - First Name"; } /** * @return string */ - public function get_table_header_class(){ + public function get_table_header_class() { return 'firstname_letter_cell'; } @@ -55,4 +75,4 @@ public function get_table_header_class(){ public function header_group() { return 'empty'; } -} \ No newline at end of file +} 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 1c801899..d11947e2 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 @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\render_helpers\grading_report\cells; use coding_exception; @@ -35,14 +55,14 @@ public function get_table_cell($row_object) { * @throws coding_exception * @return string */ - public function get_table_header($options = array()) { + public function get_table_header($options = []) { return get_string('provisionalgrade', 'mod_coursework'); } /** * @return string */ - public function get_table_header_class(){ + public function get_table_header_class() { return 'provisionalgrade'; } @@ -56,9 +76,9 @@ public function header_group() { /** * @return string */ - public function get_table_header_help_icon(){ + public function get_table_header_help_icon() { global $OUTPUT; return ($OUTPUT->help_icon('provisionalgrade', 'mod_coursework')); } -} \ No newline at end of file +} diff --git a/classes/render_helpers/grading_report/cells/group_cell.php b/classes/render_helpers/grading_report/cells/group_cell.php index fa75824e..93fb8e2b 100644 --- a/classes/render_helpers/grading_report/cells/group_cell.php +++ b/classes/render_helpers/grading_report/cells/group_cell.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\render_helpers\grading_report\cells; use coding_exception; @@ -28,11 +48,10 @@ public function get_table_cell($row_object) { $content .= '
'; $content .= '"; + $table->head = $assessorheaders; - $table->head = $assessorheaders; + $assessor1cell = html_writer::start_tag('div', array('class' => 'samples_strategy')); + $assessor1cell .= get_string('assessoronedefault', 'mod_coursework'); + $assessor1cell .= html_writer::end_tag('div'); - $assessor1cell = html_writer::start_tag('div',array('class'=>'samples_strategy')); - $assessor1cell .= get_string('assessoronedefault','mod_coursework'); - $assessor1cell .= html_writer::end_tag('div'); + $columndata = array(new html_table_cell($assessor1cell)); - $columndata = array(new html_table_cell($assessor1cell)); + $percentage_options = []; - $percentage_options = array(); - - for($i = 0;$i < 110; $i = $i + 10) { + for ($i = 0;$i < 110; $i = $i + 10) { $percentage_options[$i] = "{$i}%"; } - $javascript = false; + $javascript = false; - for ($i = 2; $i <= $samplingwidget->get_coursework()->get_max_markers(); $i++) { + for ($i = 2; $i <= $samplingwidget->get_coursework()->get_max_markers(); $i++) { - //create the secon + // Create the secon - $sampling_strategies = array('0' => get_string('sampling_manual','mod_coursework'), - '1' => get_string('sampling_automatic','mod_coursework')); + $sampling_strategies = array('0' => get_string('sampling_manual', 'mod_coursework'), + '1' => get_string('sampling_automatic', 'mod_coursework')); - //check whether any rules have been saved for this stage - $selected = ($samplingwidget->get_coursework()->has_automatic_sampling_at_stage('assessor_'.$i)) ? '1' : false; + // Check whether any rules have been saved for this stage + $selected = ($samplingwidget->get_coursework()->has_automatic_sampling_at_stage('assessor_'.$i)) ? '1' : false; - $sampling_cell = html_writer::start_tag('div',array('class'=>'samples_strategy')); - $sampling_cell .= html_writer::label(get_string('sampletype', 'mod_coursework'), "assessor_{$i}_samplingstrategy"); + $sampling_cell = html_writer::start_tag('div', array('class' => 'samples_strategy')); + $sampling_cell .= html_writer::label(get_string('sampletype', 'mod_coursework'), "assessor_{$i}_samplingstrategy"); - $sampling_cell .= html_writer::select($sampling_strategies, + $sampling_cell .= html_writer::select($sampling_strategies, "assessor_{$i}_samplingstrategy", $selected, false, - array('id'=>"assessor_{$i}_samplingstrategy",'class'=>"assessor_sampling_strategy sampling_strategy_detail")); + array('id' => "assessor_{$i}_samplingstrategy", 'class' => "assessor_sampling_strategy sampling_strategy_detail")); - $sampling_cell .= html_writer::end_tag('div'); + $sampling_cell .= html_writer::end_tag('div'); - if ($i == $samplingwidget->get_coursework()->get_max_markers()) $javascript = true; + if ($i == $samplingwidget->get_coursework()->get_max_markers()) $javascript = true; $graderules = @@ -851,21 +847,18 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin $graderules .= get_string('graderules', 'mod_coursework'); $graderules .= html_writer::end_tag('h4'); + $graderules .= $this->get_sampling_strategy_form_elements($samplingwidget->get_coursework(), $i, $javascript); - $graderules .= $this->get_sampling_strategy_form_elements($samplingwidget->get_coursework(),$i,$javascript); - + $sampling_cell .= html_writer::div($graderules, '', array('id' => "assessor_{$i}_automatic_rules")); - $sampling_cell .= html_writer::div($graderules,'', array('id'=>"assessor_{$i}_automatic_rules")); - - $columndata[] = new html_table_cell($sampling_cell); + $columndata[] = new html_table_cell($sampling_cell); } - $table->data[] = $columndata; - - //= array($asessoronecell,$asessortwocell); + $table->data[] = $columndata; - $html .= html_writer::table($table); + //= array($asessoronecell, $asessortwocell); + $html .= html_writer::table($table); // End the form with save button. $attributes = array('name' => 'save_sampling', @@ -882,11 +875,11 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin * returning 0 or 1 depending on whether and error was found. (Was that verbose...yeah...oh well) - ND */ - $script = " + $script = " - $('#save_manual_sampling').on('click', function (e) { + $('#save_manual_sampling').on('click', function (e) { - validationresults = Array(); + validationresults = []; $.each(samplingValidateHdl, function(i,functionname) { validationresults.push(eval(functionname+'()')); @@ -897,8 +890,6 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin "; - - $html .= html_writer::script($script); $html .= html_writer::end_tag('div'); @@ -910,30 +901,29 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin return $html; } + private function sampling_strategy_column($samplingwidget, $suffix = '') { - private function sampling_strategy_column($samplingwidget,$suffix = '') { - - $percentage_options = array(); + $percentage_options = []; - for($i = 0;$i < 110; $i = $i + 10) { + for ($i = 0;$i < 110; $i = $i + 10) { $percentage_options[$i] = "{$i}%"; } - //hidden input containing scale values - $scale = array(); - $sampling_column = ""; + // Hidden input containing scale values + $scale = []; + $sampling_column = ""; - $sampling_column .= html_writer::tag('br',''); - $sampling_column .= html_writer::tag('strong',get_string('selectrules','mod_coursework')); - $sampling_column .= html_writer::tag('br',''); + $sampling_column .= html_writer::tag('br', ''); + $sampling_column .= html_writer::tag('strong', get_string('selectrules', 'mod_coursework')); + $sampling_column .= html_writer::tag('br', ''); $sampling_column .= html_writer::start_tag('div'); - for($i = 0; $i < 1; $i++) { + for ($i = 0; $i < 1; $i++) { $sampling_column .= html_writer::start_tag('span', array('class' => "assessor_{$suffix}_grade_rules", 'id' => "assessor_{$suffix}_grade_rules")); $sampling_column .= html_writer::checkbox("assessor_{$suffix}_samplerules[]", 1, false, get_string('grade', 'mod_coursework'), - array('id' => "assessor_{$suffix}_samplerules_{$i}", 'class'=>"assessor_{$suffix} sampling_strategy_detail")); + array('id' => "assessor_{$suffix}_samplerules_{$i}", 'class' => "assessor_{$suffix} sampling_strategy_detail")); $options = array('0' => get_string('percentagesign', 'mod_coursework'), '1' => get_string('gradescale', 'mod_coursework')); @@ -942,7 +932,7 @@ private function sampling_strategy_column($samplingwidget,$suffix = '') { "assessor_{$suffix}_sampletype[]", $samplingwidget->get_sampling_strategy(), false, - array('id' => "assessor_{$suffix}_sampletype_{$i}", 'class'=>"grade_type assessor_{$suffix} sampling_strategy_detail")); + array('id' => "assessor_{$suffix}_sampletype_{$i}", 'class' => "grade_type assessor_{$suffix} sampling_strategy_detail")); $sampling_column .= html_writer::label(get_string('from', 'mod_coursework'), 'assessortwo_samplefrom[0]'); @@ -952,7 +942,7 @@ private function sampling_strategy_column($samplingwidget,$suffix = '') { "assessor_{$suffix}_samplefrom[]", $samplingwidget->get_sampling_strategy(), false, - array('id' => "assessor_{$suffix}_samplefrom_{$i}", 'class'=>"assessor_{$suffix} sampling_strategy_detail")); + array('id' => "assessor_{$suffix}_samplefrom_{$i}", 'class' => "assessor_{$suffix} sampling_strategy_detail")); $sampling_column .= html_writer::label(get_string('to', 'mod_coursework'), "assessor_{$suffix}_sampleto[0]"); @@ -960,32 +950,27 @@ private function sampling_strategy_column($samplingwidget,$suffix = '') { "assessor_{$suffix}_sampleto[]", $samplingwidget->get_sampling_strategy(), false, - array('id' => "assessor_{$suffix}_sampleto_{$i}", 'class'=>"assessor_{$suffix} sampling_strategy_detail")); - + array('id' => "assessor_{$suffix}_sampleto_{$i}", 'class' => "assessor_{$suffix} sampling_strategy_detail")); $sampling_column .= html_writer::end_tag('span', ''); } $sampling_column .= html_writer::end_tag('div'); + $sampling_column .= html_writer::link('#', get_string('addgraderule', 'mod_coursework'), array('id' => "assessor_{$suffix}_addgradderule", 'class' => 'addgradderule sampling_strategy_detail')); + $sampling_column .= html_writer::link('#', get_string('removegraderule', 'mod_coursework'), array('id' => "assessor_{$suffix}_removegradderule", 'class' => 'removegradderule sampling_strategy_detail')); - $sampling_column .= html_writer::link('#',get_string('addgraderule','mod_coursework'),array('id'=>"assessor_{$suffix}_addgradderule", 'class'=>'addgradderule sampling_strategy_detail')); - $sampling_column .= html_writer::link('#',get_string('removegraderule','mod_coursework'),array('id'=>"assessor_{$suffix}_removegradderule", 'class'=>'removegradderule sampling_strategy_detail')); - - - $sampling_column .= html_writer::checkbox("assessor_{$suffix}_samplertopup",1,false,get_string('topupto','mod_coursework'), - array('id'=>"assessor_{$suffix}_samplerules[]",'class'=>"assessor_{$suffix} sampling_strategy_detail")); - - + $sampling_column .= html_writer::checkbox("assessor_{$suffix}_samplertopup", 1, false, get_string('topupto', 'mod_coursework'), + array('id' => "assessor_{$suffix}_samplerules[]", 'class' => "assessor_{$suffix} sampling_strategy_detail")); - $sampling_column .= html_writer::select($percentage_options, + $sampling_column .= html_writer::select($percentage_options, "assessor_{$suffix}_sampletopup", $samplingwidget->get_sampling_strategy(), false, - array('id'=>"assessor_{$suffix}_sampletopup", 'class' => "assessor_{$suffix} sampling_strategy_detail")); - $sampling_column .= html_writer::label(get_string('ofallstudents', 'mod_coursework'),'assessortwo_sampleto[]'); + array('id' => "assessor_{$suffix}_sampletopup", 'class' => "assessor_{$suffix} sampling_strategy_detail")); + $sampling_column .= html_writer::label(get_string('ofallstudents', 'mod_coursework'), 'assessortwo_sampleto[]'); - return $sampling_column ; + return $sampling_column; } @@ -1087,7 +1072,7 @@ protected function get_allocation_strategy_form_elements($coursework) { $strategy = new $full_class_name($coursework); $attributes = array( - 'class' => 'assessor-strategy-options', + 'class' => 'assessor-strategy-options', 'id' => 'assessor-strategy-' . $classname ); // Hide this if it's not currently selected. @@ -1103,18 +1088,15 @@ protected function get_allocation_strategy_form_elements($coursework) { return $html; } - - protected function get_sampling_strategy_form_elements($coursework,$assessor_number,$load_javascript=false) { + protected function get_sampling_strategy_form_elements($coursework, $assessor_number, $load_javascript=false) { global $CFG, $DB; $html = ''; - $javascript = ''; + $javascript = ''; $classdir = $CFG->dirroot . '/mod/coursework/classes/sample_set_rule/'; - $sampleplugins = $DB->get_records('coursework_sample_set_plugin',null,'pluginorder'); - - + $sampleplugins = $DB->get_records('coursework_sample_set_plugin', null, 'pluginorder'); //$fullclasspaths = glob($classdir . '/*.php'); foreach ($sampleplugins as $plugin) { @@ -1129,8 +1111,7 @@ protected function get_sampling_strategy_form_elements($coursework,$assessor_num $html .= $sampling_rule->add_form_elements($assessor_number); - if ($load_javascript) $javascript .= $sampling_rule->add_form_elements_js($assessor_number); - + if ($load_javascript) $javascript .= $sampling_rule->add_form_elements_js($assessor_number); } @@ -1138,7 +1119,6 @@ protected function get_sampling_strategy_form_elements($coursework,$assessor_num } - /** * @param coursework $coursework * @param submission $submission @@ -1146,10 +1126,9 @@ protected function get_sampling_strategy_form_elements($coursework,$assessor_num * @return string */ protected function resubmit_to_plagiarism_button($coursework, $submission) { - global $PAGE; $html = ''; $html .= html_writer::start_tag('form', - array('action' => $PAGE->url, + array('action' => $this->page->url, 'method' => 'POST')); $html .= html_writer::empty_tag('input', array('type' => 'hidden', @@ -1159,7 +1138,7 @@ protected function resubmit_to_plagiarism_button($coursework, $submission) { array('type' => 'hidden', 'name' => 'id', 'value' => $coursework->get_coursemodule_id())); - $plagiarism_plugin_names = array(); + $plagiarism_plugin_names = []; foreach ($coursework->get_plagiarism_helpers() as $helper) { $plagiarism_plugin_names[] = $helper->human_readable_name(); } @@ -1201,13 +1180,13 @@ protected function render_file_plagiarism_information($file, $coursework) { * @return string */ protected function make_file_link($files, $file, $class_name = 'submissionfile') { - global $CFG, $OUTPUT; + global $CFG; $url = "{$CFG->wwwroot}/pluginfile.php/{$file->get_contextid()}" . "/mod_coursework/{$files->get_file_area_name()}"; $filename = $file->get_filename(); - $image = $OUTPUT->pix_icon(file_file_icon($file), + $image = $this->output->pix_icon(file_file_icon($file), $filename, 'moodle', array('class' => 'submissionfileicon')); @@ -1239,7 +1218,7 @@ protected function render_resubmit_to_plagiarism_button($coursework, $submission * @throws coding_exception */ protected function coursework_deadlines_table(mod_coursework_coursework $coursework) { - global $PAGE, $USER; + global $USER; $dealine_extension = \mod_coursework\models\deadline_extension::get_extension_for_student(user::find($USER), $coursework); @@ -1249,11 +1228,11 @@ protected function coursework_deadlines_table(mod_coursework_coursework $coursew $normaldeadline = $coursework->deadline; - if ($personal_deadline){ + if ($personal_deadline) { $normaldeadline = $personal_deadline->personal_deadline; } $deadline_header_text = get_string('deadline', 'coursework'); - if($coursework->personal_deadlines_enabled() && (!has_capability('mod/coursework:submit', $PAGE->context) || is_siteadmin($USER))){ + if ($coursework->personal_deadlines_enabled() && (!has_capability('mod/coursework:submit', $this->page->context) || is_siteadmin($USER))) { $deadline_header_text .= "
". get_string('default_deadline', 'coursework'); } $deadline_date = ''; @@ -1263,7 +1242,7 @@ protected function coursework_deadlines_table(mod_coursework_coursework $coursew $deadline_date .= userdate($normaldeadline, '%a, %d %b %Y, %H:%M'); $deadline_date .= ''; } else if ($coursework->has_deadline()) { - $deadline_date .= userdate($normaldeadline,'%a, %d %b %Y, %H:%M'); + $deadline_date .= userdate($normaldeadline, '%a, %d %b %Y, %H:%M'); } else { $deadline_date .= get_string('nocourseworkdeadline', 'mod_coursework'); } @@ -1288,18 +1267,18 @@ protected function coursework_deadlines_table(mod_coursework_coursework $coursew $deadline_extension_message = ''; if ($dealine_extension) { $deadline_extension_message .= html_writer::start_tag('div'); - $deadline_extension_message .= 'You have an extension!
Your deadine is: '.userdate($dealine_extension->extended_deadline).''; + $deadline_extension_message .= 'You have an extension!
Your deadine is: ' + . userdate($dealine_extension->extended_deadline); $deadline_extension_message .= html_writer::end_tag('div'); } if ($coursework->has_deadline()) { $deadline_message .= html_writer::start_tag('div', array('class' => 'autofinalise_info')); - $deadline_message .= ($coursework->personal_deadlines_enabled() && (!has_capability('mod/coursework:submit', $PAGE->context) || is_siteadmin($USER)))? - get_string('personal_deadline_warning', 'mod_coursework') : get_string('deadline_warning', 'mod_coursework'); + $deadline_message .= ($coursework->personal_deadlines_enabled() && (!has_capability('mod/coursework:submit', $this->page->context) || is_siteadmin($USER))) + ? get_string('personal_deadline_warning', 'mod_coursework') : get_string('deadline_warning', 'mod_coursework'); $deadline_message .= html_writer::end_tag('div'); } - $table_html = ' @@ -1314,7 +1293,8 @@ protected function coursework_deadlines_table(mod_coursework_coursework $coursew if ($coursework->is_general_feedback_enabled() && $coursework->generalfeedback) { $general_feedback_header = get_string('generalfeedbackdeadline', 'coursework') . ': '; $general_feedback_deadline = $coursework->get_general_feedback_deadline(); - $general_feedback_deadline_message = $general_feedback_deadline ? userdate($general_feedback_deadline,'%a, %d %b %Y, %H:%M') + $general_feedback_deadline_message = $general_feedback_deadline + ? userdate($general_feedback_deadline, '%a, %d %b %Y, %H:%M') : get_string('notset', 'coursework'); $table_html .= ' @@ -1330,7 +1310,8 @@ protected function coursework_deadlines_table(mod_coursework_coursework $coursew $individual_feedback_header = get_string('individualfeedback', 'coursework'); $individual_feedback_deadline = $coursework->get_individual_feedback_deadline(); - $indivisual_feedback_message = $individual_feedback_deadline ? userdate($individual_feedback_deadline,'%a, %d %b %Y, %H:%M') + $indivisual_feedback_message = $individual_feedback_deadline + ? userdate($individual_feedback_deadline, '%a, %d %b %Y, %H:%M') : get_string('notset', 'coursework'); $table_html .= ' @@ -1370,7 +1351,7 @@ private function render_allocation_table_row($allocation_row) { } // moderator - if($allocation_row->get_coursework()->moderation_agreement_enabled()) { + if ($allocation_row->get_coursework()->moderation_agreement_enabled()) { $row_html .= $stage->get_moderation_table_cell($allocation_row->get_allocatable()); } @@ -1385,35 +1366,29 @@ private function render_allocation_table_row($allocation_row) { * @param mod_coursework_personal_deadlines_table $personal_deadlines_table * @return string */ - protected function render_mod_coursework_personal_deadlines_table(mod_coursework_personal_deadlines_table $personal_deadlines_table){ - global $PAGE; - - $coursework_page_url = $this->get_router()->get_path('coursework', array('coursework' => $personal_deadlines_table->get_coursework())) ; - $table_html = '
'.html_writer::link($coursework_page_url,get_string('returntocourseworkpage','mod_coursework')).'
'; - - $table_html .= '
'.get_string('nopersonaldeadlineforextensionwarning','mod_coursework').'
'; + protected function render_mod_coursework_personal_deadlines_table(mod_coursework_personal_deadlines_table $personal_deadlines_table) { + $coursework_page_url = $this->get_router()->get_path('coursework', array('coursework' => $personal_deadlines_table->get_coursework())); + $table_html = '
'.html_writer::link($coursework_page_url, get_string('returntocourseworkpage', 'mod_coursework')).'
'; + $table_html .= '
'.get_string('nopersonaldeadlineforextensionwarning', 'mod_coursework').'
'; + $usergroups = $personal_deadlines_table->get_coursework()->get_allocatable_type(); - $usergroups = $personal_deadlines_table->get_coursework()->get_allocatable_type(); + $table_html .= ''; - $table_html .= ''; - - - if (has_capability('mod/coursework:revertfinalised', $PAGE->context)) { + if (has_capability('mod/coursework:revertfinalised', $this->page->context)) { $table_html .= ''; } - $table_html .= '
'; - $url = $this->get_router()->get_path('edit personal deadline', array()); - - $table_html .= ''; + $table_html .= '
'; + $url = $this->get_router()->get_path('edit personal deadline', []); - $table_html .= ''; - $table_html .= ''; - $table_html .= ''; - $table_html .= ''; - $table_html .= ''; + $table_html .= ''; + $table_html .= ''; + $table_html .= ''; + $table_html .= ''; + $table_html .= ''; + $table_html .= ''; $table_html .= ' @@ -1423,7 +1398,6 @@ protected function render_mod_coursework_personal_deadlines_table(mod_coursework '; - $allocatable_cell_helper = $personal_deadlines_table->get_allocatable_cell(); $personaldeadlines_cell_helper = $personal_deadlines_table->get_personal_deadline_cell(); $table_html .= ''; $table_html .= ''; - - $table_html .= ' @@ -1457,11 +1429,10 @@ protected function render_mod_coursework_personal_deadlines_table(mod_coursework
'; @@ -1436,11 +1410,9 @@ protected function render_mod_coursework_personal_deadlines_table(mod_coursework $table_html .= $personaldeadlines_cell_helper->get_table_header($personal_deadlines_table->get_options()); $table_html .= ''; - $table_html .= get_string('tableheadstatus','mod_coursework'); + $table_html .= get_string('tableheadstatus', 'mod_coursework'); $table_html .= '
'; - $table_html .= ''; + $table_html .= ''; return $table_html; - } /** @@ -1470,9 +1441,9 @@ protected function render_mod_coursework_personal_deadlines_table(mod_coursework */ private function render_personal_deadline_table_row($personal_deadline_row) { - global $OUTPUT, $USER; + global $USER; - $coursework = $personal_deadline_row->get_coursework(); + $coursework = $personal_deadline_row->get_coursework(); $new_personal_deadline_params = array( 'allocatableid' => $personal_deadline_row->get_allocatable()->id(), @@ -1485,67 +1456,59 @@ private function render_personal_deadline_table_row($personal_deadline_row) { $personal_deadline = \mod_coursework\models\personal_deadline::get_personal_deadline_for_student(user::find($personal_deadline_row->get_allocatable()->id()), $coursework); - - if (!$personal_deadline) { - $personal_deadline = \mod_coursework\models\personal_deadline::build($new_personal_deadline_params); + $personal_deadline = \mod_coursework\models\personal_deadline::build($new_personal_deadline_params); } - $ability = new ability(user::find($USER), $coursework); - $disabledelement = (!$personal_deadline ||($personal_deadline && $ability->can('edit', $personal_deadline)) ) ? "" : " disabled='disabled' "; - + $disabledelement = (!$personal_deadline ||($personal_deadline && $ability->can('edit', $personal_deadline)) ) ? "" : " disabled='disabled' "; $row_html = ''; $row_html .= ''; $row_html .= ''; - $row_html .= ''; + $row_html .= ''; $row_html .= ''; $new_personal_deadline_params = array( 'allocatableid' => $personal_deadline_row->get_allocatable()->id(), 'allocatabletype' => $personal_deadline_row->get_allocatable()->type(), 'courseworkid' => $personal_deadline_row->get_coursework()->id, - 'setpersonaldeadlinespage' => '1' + 'setpersonaldeadlinespage' => '1' ); - $allocatable_cell_helper = $personal_deadline_row->get_allocatable_cell(); $personaldeadlines_cell_helper = $personal_deadline_row->get_personal_deadline_cell(); $row_html .= $allocatable_cell_helper->get_table_cell($personal_deadline_row); - $row_html .= $personaldeadlines_cell_helper->get_table_cell($personal_deadline_row); - $row_html .= '' ; - $row_html .= "".$personal_deadline_row->get_submission_status().""; + $row_html .= $personaldeadlines_cell_helper->get_table_cell($personal_deadline_row); + $row_html .= ''; + $row_html .= "".$personal_deadline_row->get_submission_status().""; $row_html .= ''; return $row_html; } - /** * @param mod_coursework_coursework $coursework * @return string * @throws coding_exception */ protected function coursework_grading_summary_table(mod_coursework_coursework $coursework) { - global $PAGE, $USER; + global $USER; $gradedHeader = ""; $warning_message = ""; - $stagename = $coursework->has_multiple_markers()? ' (Agreed grade)' : ''; - + $stagename = $coursework->has_multiple_markers() ? ' (Agreed grade)' : ''; $participants = 0; $submitted = 0; - $needsgrading = 0; + $needsgrading = 0; $graded = 0; $finalgrade = 0; $published = 0; - - if (!$coursework->has_multiple_markers() && !$coursework->allocation_enabled() && !has_capability('mod/coursework:addinitialgrade',$coursework->get_context()) - && has_capability('mod/coursework:addagreedgrade',$coursework->get_context())){ + if (!$coursework->has_multiple_markers() && !$coursework->allocation_enabled() && !has_capability('mod/coursework:addinitialgrade', $coursework->get_context()) + && has_capability('mod/coursework:addagreedgrade', $coursework->get_context())) { $warning_message = "You don't have a capability to grade anyone in this Coursework"; @@ -1559,17 +1522,16 @@ protected function coursework_grading_summary_table(mod_coursework_coursework $c $assessable_submitted_submissions = $this->remove_unfinalised_submissions($assessable_submitted_submissions); - $assessable_submitted_submissions = $this->remove_ungradable_submissions($assessable_submitted_submissions); + $assessable_submitted_submissions = $this->remove_ungradable_submissions($assessable_submitted_submissions); - //remove all submission with final grade + // Remove all submission with final grade $assessable_submitted_submissions = $this->removed_final_graded_submissions($assessable_submitted_submissions); - - //if has addagreedgrade or administergrade or addallocatedagreedgrade+initialgrade + // If has addagreedgrade or administergrade or addallocatedagreedgrade+initialgrade if (has_any_capability(array('mod/coursework:addagreedgrade', 'mod/coursework:administergrades'), $coursework->get_context()) || (has_capability('mod/coursework:addinitialgrade', $coursework->get_context()) && has_capability('mod/coursework:addallocatedagreedgrade', $coursework->get_context()))) { - //count number of submissions at final grade stage + // Count number of submissions at final grade stage $numberofassessable = count($assessable_submitted_submissions); $assessable_submitted_submissions = $this->remove_final_gradable_submissions($assessable_submitted_submissions); @@ -1577,7 +1539,7 @@ protected function coursework_grading_summary_table(mod_coursework_coursework $c $needsgrading = $numberofassessable - count($assessable_submitted_submissions); } - //if has initialgrade + // If has initialgrade if (has_any_capability(array('mod/coursework:addinitialgrade', 'mod/coursework:administergrades'), $coursework->get_context())) { $assessable_submitted_submissions = $this->remove_final_gradable_submissions($assessable_submitted_submissions); @@ -1587,7 +1549,6 @@ protected function coursework_grading_summary_table(mod_coursework_coursework $c $graded_submissions = $this->get_submissions_with_final_grade($this->get_submissions_for_assessor($coursework, $allsubmissions)); $graded = count($graded_submissions); - $finalgrade = $graded; // display breakdown of marks for initial stages if ($coursework->has_multiple_markers() && has_capability('mod/coursework:administergrades', $coursework->get_context())) { @@ -1608,25 +1569,23 @@ protected function coursework_grading_summary_table(mod_coursework_coursework $c } - // BUILD table $table_html = ''; $table_html .= $warning_message; // participants row - $table_html .= ''; + $table_html .= ''; // number of submission row - $table_html .= ''; + $table_html .= ''; // submissions needs grading row - $table_html .= ''; + $table_html .= ''; // submissions graded - if (has_capability('mod/coursework:addinitialgrade', $coursework->get_context()) && !is_siteadmin($USER)){ + if (has_capability('mod/coursework:addinitialgrade', $coursework->get_context()) && !is_siteadmin($USER)) { $table_html .= ''; } else { $table_html .= ''; } // submissions graded and published - $table_html .= ''; - + $table_html .= ''; $table_html .= '
'.get_string('participants','mod_coursework').''.$participants.'
'.get_string('participants', 'mod_coursework').''.$participants.'
'.get_string('submitted','mod_coursework').''.$submitted.'
'.get_string('submitted', 'mod_coursework').''.$submitted.'
'.get_string('needsgrading','mod_coursework').''.$needsgrading.'
'.get_string('needsgrading', 'mod_coursework').''.$needsgrading.'
' . get_string('graded', 'mod_coursework') . $stagename . $gradedHeader . '' . $graded . '
' . get_string('graded', 'mod_coursework') . $stagename . $gradedHeader . '' . $finalgrade . '
'.get_string('gradedandpublished','mod_coursework').''.$published.'
'.get_string('gradedandpublished', 'mod_coursework').''.$published.'
'; @@ -1637,23 +1596,22 @@ protected function coursework_grading_summary_table(mod_coursework_coursework $c * Get number of participants assessor can see on the grading page * @param coursework $coursework */ - public function get_allocatables_count_per_assessor($coursework){ + public function get_allocatables_count_per_assessor($coursework) { global $USER; $participant = 0; $allocatables = $coursework->get_allocatables(); if (!$coursework->has_multiple_markers() && has_capability('mod/coursework:addagreedgrade', $coursework->get_context()) && - !has_capability('mod/coursework:addinitialgrade', $coursework->get_context()) ) { - + !has_capability('mod/coursework:addinitialgrade', $coursework->get_context()) ) { $submissions = $coursework->get_all_submissions(); - foreach($submissions as $sub) { + foreach ($submissions as $sub) { $submission = submission::find($sub); - if ( $submission->final_grade_agreed()){ + if ( $submission->final_grade_agreed()) { continue; - } else if ( count($submission->get_assessor_feedbacks()) < $submission->max_number_of_feedbacks()){ + } else if ( count($submission->get_assessor_feedbacks()) < $submission->max_number_of_feedbacks()) { unset($submissions[$submission->id]); } } @@ -1666,9 +1624,9 @@ public function get_allocatables_count_per_assessor($coursework){ foreach ($allocatables as $allocatable) { $submission = $allocatable->get_submission($coursework); - if($coursework->assessor_has_any_allocation_for_student($allocatable) || has_capability('mod/coursework:addagreedgrade', $coursework->get_context()) + if ($coursework->assessor_has_any_allocation_for_student($allocatable) || has_capability('mod/coursework:addagreedgrade', $coursework->get_context()) && !empty($submission) && (($submission->all_inital_graded() && !$coursework->sampling_enabled()) - || ($coursework->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() >1 ))){ + || ($coursework->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() >1 ))) { $participant ++; } } @@ -1677,20 +1635,19 @@ public function get_allocatables_count_per_assessor($coursework){ return $participant; } - /** * Remove submissions that have not been finalised * * @param $submissions * @return mixed */ - public function remove_unfinalised_submissions($submissions) { + public function remove_unfinalised_submissions($submissions) { - foreach($submissions as $sub) { + foreach ($submissions as $sub) { $submission = submission::find($sub); - if (empty($submission->finalised)) { + if (empty($submission->finalised)) { unset($submissions[$sub->id]); } } @@ -1704,13 +1661,13 @@ public function remove_unfinalised_submissions($submissions) { * @param $submissions * @return mixed */ - public function removed_final_graded_submissions($submissions) { + public function removed_final_graded_submissions($submissions) { - foreach($submissions as $sub) { + foreach ($submissions as $sub) { $submission = submission::find($sub); - if (!empty($submission->get_final_grade() )) { + if (!empty($submission->get_final_grade() )) { unset($submissions[$sub->id]); } } @@ -1718,7 +1675,6 @@ public function removed_final_graded_submissions($submissions) { return $submissions; } - /** * Remove submissions that can't be graded * @@ -1726,13 +1682,13 @@ public function removed_final_graded_submissions($submissions) { * @return mixed * @throws coding_exception */ - public function remove_ungradable_submissions($submissions) { + public function remove_ungradable_submissions($submissions) { - foreach($submissions as $sub) { + foreach ($submissions as $sub) { $submission = submission::find($sub); - if (has_capability('mod/coursework:addallocatedagreedgrade',$submission->get_coursework()->get_context()) && !$submission->is_assessor_initial_grader() && $submission->all_inital_graded()) { + if (has_capability('mod/coursework:addallocatedagreedgrade', $submission->get_coursework()->get_context()) && !$submission->is_assessor_initial_grader() && $submission->all_inital_graded()) { unset($submissions[$sub->id]); } } @@ -1746,12 +1702,12 @@ public function remove_ungradable_submissions($submissions) { * @param $submissions * @return mixed */ - public function remove_final_gradable_submissions($submissions) { + public function remove_final_gradable_submissions($submissions) { - foreach($submissions as $sub) { + foreach ($submissions as $sub) { $submission = submission::find($sub); - if (!empty($submission->all_inital_graded()) ) { + if (!empty($submission->all_inital_graded()) ) { unset($submissions[$sub->id]); } } @@ -1767,17 +1723,17 @@ public function remove_final_gradable_submissions($submissions) { * @return mixed * @throws coding_exception */ - public function get_assessor_initial_graded_submissions($submissions) { + public function get_assessor_initial_graded_submissions($submissions) { global $USER; - foreach($submissions as $sub) { + foreach ($submissions as $sub) { $submission = submission::find($sub); if (count($submission->get_assessor_feedbacks()) >= $submission->max_number_of_feedbacks() || $submission->is_assessor_initial_grader() - && (!has_capability('mod/coursework:administergrades',$submission->get_coursework()->get_context()) && !is_siteadmin($USER->id))) { + && (!has_capability('mod/coursework:administergrades', $submission->get_coursework()->get_context()) && !is_siteadmin($USER->id))) { - //is this submission assessable by this user at an inital gradig stage + // Is this submission assessable by this user at an inital gradig stage unset($submissions[$sub->id]); } } @@ -1785,7 +1741,6 @@ public function get_assessor_initial_graded_submissions($submissions) { return $submissions; } - /** * Get submissions that have final feedback * @@ -1793,13 +1748,13 @@ public function get_assessor_initial_graded_submissions($submissions) { * @return mixed * @throws exception */ - public function get_submissions_with_final_grade($submissions){ + public function get_submissions_with_final_grade($submissions) { - foreach($submissions as $sub) { + foreach ($submissions as $sub) { $submission = submission::find($sub); - if(!$submission->get_final_feedback()){ + if (!$submission->get_final_feedback()) { unset($submissions[$sub->id]); } @@ -1808,8 +1763,6 @@ public function get_submissions_with_final_grade($submissions){ return $submissions; } - - /** * Get submissions an assessor can see on the grading page or will be able to mark * @@ -1818,18 +1771,17 @@ public function get_submissions_with_final_grade($submissions){ * @return array * @throws coding_exception */ - public function get_submissions_for_assessor($coursework, $submissions){ + public function get_submissions_for_assessor($coursework, $submissions) { global $USER; - $gradeblesub = array(); + $gradeblesub = []; if (!$coursework->has_multiple_markers() && has_capability('mod/coursework:addagreedgrade', $coursework->get_context()) && - !has_capability('mod/coursework:addinitialgrade', $coursework->get_context()) ) { - + !has_capability('mod/coursework:addinitialgrade', $coursework->get_context()) ) { - foreach($submissions as $sub) { + foreach ($submissions as $sub) { $submission = submission::find($sub); - if ( $submission->final_grade_agreed()){ + if ( $submission->final_grade_agreed()) { continue; } else if (count($submission->get_assessor_feedbacks()) < $submission->max_number_of_feedbacks()) { unset($submissions[$submission->id]); @@ -1840,7 +1792,7 @@ public function get_submissions_for_assessor($coursework, $submissions){ } else if (is_siteadmin($USER) || !$coursework->allocation_enabled() || has_any_capability(array('mod/coursework:administergrades'), $coursework->get_context())) { - foreach($submissions as $sub) { + foreach ($submissions as $sub) { $submission = submission::find($sub); $gradeblesub[$submission->id] = $submission; } @@ -1848,9 +1800,9 @@ public function get_submissions_for_assessor($coursework, $submissions){ } else { foreach ($submissions as $sub) { $submission = submission::find($sub); - if($coursework->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) || (has_capability('mod/coursework:addagreedgrade', $coursework->get_context())) + if ($coursework->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) || (has_capability('mod/coursework:addagreedgrade', $coursework->get_context())) && !empty($submission) && (($submission->all_inital_graded() && !$submission->get_coursework()->sampling_enabled()) - || ($submission->get_coursework()->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() >1))){ + || ($submission->get_coursework()->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() > 1))) { $gradeblesub[$submission->id] = $submission; } @@ -1860,6 +1812,4 @@ public function get_submissions_for_assessor($coursework, $submissions){ return $gradeblesub; } - - -} \ No newline at end of file +} diff --git a/renderers/page_renderer.php b/renderers/page_renderer.php index 1566c745..02367814 100644 --- a/renderers/page_renderer.php +++ b/renderers/page_renderer.php @@ -1,4 +1,25 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + use mod_coursework\ability; use mod_coursework\forms\assessor_feedback_mform; use mod_coursework\forms\student_submission_form; @@ -22,39 +43,32 @@ class mod_coursework_page_renderer extends plugin_renderer_base { /** * @param feedback $feedback */ - public function show_feedback_page($feedback,$ajax) { - global $OUTPUT; - + public function show_feedback_page($feedback, $ajax) { $html = ''; $object_renderer = $this->get_object_renderer(); - - if (empty($ajax)) $html .= $OUTPUT->header(); + if (empty($ajax)) $html .= $this->output->header(); $html .= $object_renderer->render_feedback($feedback); - if (empty($ajax)) $html .= $OUTPUT->header(); + if (empty($ajax)) $html .= $this->output->header(); return $html; } - /** * @param moderation $moderation */ public function show_moderation_page($moderation) { - global $OUTPUT; - $html = ''; $object_renderer = $this->get_object_renderer(); $html .= $object_renderer->render_moderation($moderation); - echo $OUTPUT->header(); + echo $this->output->header(); echo $html; - echo $OUTPUT->footer(); + echo $this->output->footer(); } - /** * Renders the HTML for the edit page * @@ -64,24 +78,24 @@ public function show_moderation_page($moderation) { */ public function edit_feedback_page(feedback $teacher_feedback, $assessor, $editor, $ajax = false) { - global $PAGE, $SITE, $OUTPUT; + global $SITE; $grading_title = get_string('gradingfor', 'coursework', $teacher_feedback->get_submission()->get_allocatable_name()); - $PAGE->set_pagelayout('standard'); - $PAGE->navbar->add($grading_title); - $PAGE->set_title($SITE->fullname); - $PAGE->set_heading($SITE->fullname); + $this->page->set_pagelayout('standard'); + $this->page->navbar->add($grading_title); + $this->page->set_title($SITE->fullname); + $this->page->set_heading($SITE->fullname); $html = ''; - $gradedby = ($teacher_feedback->assessorid == 0)? get_string('automaticagreement', 'mod_coursework') : fullname($assessor); + $gradedby = ($teacher_feedback->assessorid == 0) ? get_string('automaticagreement', 'mod_coursework') : fullname($assessor); $lasteditedby = ((!$teacher_feedback->get_coursework()->sampling_enabled() || $teacher_feedback->get_submission()->sampled_feedback_exists()) - && $teacher_feedback->assessorid == 0 && $teacher_feedback->timecreated == $teacher_feedback->timemodified )? - get_string('automaticagreement', 'mod_coursework') : fullname($editor); + && $teacher_feedback->assessorid == 0 && $teacher_feedback->timecreated == $teacher_feedback->timemodified ) + ? get_string('automaticagreement', 'mod_coursework') : fullname($editor); - $html .= $OUTPUT->heading($grading_title); + $html .= $this->output->heading($grading_title); $html .= ''; $html .= ''; $html .= '
' . get_string('gradedby', 'coursework') . '' . $gradedby . '
' . get_string('lasteditedby', 'coursework') . '' . $lasteditedby . ' on ' . @@ -121,35 +135,33 @@ public function edit_feedback_page(feedback $teacher_feedback, $assessor, $edito echo json_encode(['formhtml' => $html . $formhtml, 'filemanageroptions' => $filemanageroptions, 'editoroptions' => $editoroptions, 'commentoptions' => $commentoptions]); } else { - $PAGE->set_pagelayout('standard'); - $PAGE->navbar->add($grading_title); - $PAGE->set_title($SITE->fullname); - $PAGE->set_heading($SITE->fullname); - echo $OUTPUT->header(); + $this->page->set_pagelayout('standard'); + $this->page->navbar->add($grading_title); + $this->page->set_title($SITE->fullname); + $this->page->set_heading($SITE->fullname); + echo $this->output->header(); echo $html; $simple_form->display(); - echo $OUTPUT->footer(); + echo $this->output->footer(); } } - public function confirm_feedback_removal_page(feedback $teacher_feedback, $confirmurl) { - global $PAGE, $SITE, $OUTPUT; + public function confirm_feedback_removal_page(feedback $teacher_feedback, $confirmurl) { + global $SITE; $grading_title = get_string('gradingfor', 'coursework', $teacher_feedback->get_submission()->get_allocatable_name()); - $PAGE->set_pagelayout('standard'); - $PAGE->navbar->add($grading_title); - $PAGE->set_title($SITE->fullname); - $PAGE->set_heading($SITE->fullname); - + $this->page->set_pagelayout('standard'); + $this->page->navbar->add($grading_title); + $this->page->set_title($SITE->fullname); + $this->page->set_heading($SITE->fullname); - echo $OUTPUT->header(); - echo $OUTPUT->confirm(get_string('confirmremovefeedback', 'mod_coursework'), $confirmurl, $PAGE->url); - echo $OUTPUT->footer(); + echo $this->output->header(); + echo $this->output->confirm(get_string('confirmremovefeedback', 'mod_coursework'), $confirmurl, $this->page->url); + echo $this->output->footer(); } - /** * Renders the HTML for the edit page * @@ -159,22 +171,22 @@ public function confirm_feedback_removal_page(feedback $teacher_feedback, $confi */ public function edit_moderation_page(moderation $moderator_agreement, $assessor, $editor) { - global $PAGE, $SITE, $OUTPUT; + global $SITE; $title = get_string('moderationfor', 'coursework', $moderator_agreement->get_submission()->get_allocatable_name()); - $PAGE->set_pagelayout('standard'); - $PAGE->navbar->add($title); - $PAGE->set_title($SITE->fullname); - $PAGE->set_heading($SITE->fullname); + $this->page->set_pagelayout('standard'); + $this->page->navbar->add($title); + $this->page->set_title($SITE->fullname); + $this->page->set_heading($SITE->fullname); $html = ''; $moderatedby = fullname($assessor); $lasteditedby = fullname($editor); - $html .= $OUTPUT->heading($title); + $html .= $this->output->heading($title); $html .= ''; $html .= ''; $html .= '
' . get_string('moderatedby', 'coursework') . '' . $moderatedby . '
' . get_string('lasteditedby', 'coursework') . '' . $lasteditedby . ' on ' . @@ -187,13 +199,12 @@ public function edit_moderation_page(moderation $moderator_agreement, $assessor, $moderator_agreement->modcomment = array('text' => $moderator_agreement->modcomment, 'format' => $moderator_agreement->modcommentformat); - $simple_form->set_data($moderator_agreement); - echo $OUTPUT->header(); + echo $this->output->header(); echo $html; $simple_form->display(); - echo $OUTPUT->footer(); + echo $this->output->footer(); } /** @@ -265,7 +276,7 @@ public function student_view_page($coursework, $student) { $ability = new ability($student, $coursework); $plagdisclosure = plagiarism_similarity_information($course_module); - $html .= $plagdisclosure; + $html .= $plagdisclosure; // if TII plagiarism enabled check if user agreed/disagreed EULA $shouldseeEULA = has_user_seen_tii_EULA_agreement(); @@ -301,14 +312,11 @@ public function student_view_page($coursework, $student) { * @return string HTML */ public function choose_student_to_submit_for($coursemoduleid, $chooseform) { - - global $OUTPUT; - // Drop down to choose the student if we have no student id. // We don't really need to process this form, we just get the studentid as a param and use it. $html = ''; - $html .= $OUTPUT->header(); + $html .= $this->output->header(); $chooseform->set_data(array('cmid' => $coursemoduleid)); ob_start(); // Forms library echos stuff. @@ -316,7 +324,7 @@ public function choose_student_to_submit_for($coursemoduleid, $chooseform) { $html .= ob_get_contents(); ob_end_clean(); - $html .= $OUTPUT->footer(); + $html .= $this->output->footer(); return $html; } @@ -326,16 +334,16 @@ public function choose_student_to_submit_for($coursemoduleid, $chooseform) { * @param bool $ajax * @throws coding_exception */ - public function new_feedback_page($new_feedback , $ajax = false) { - global $PAGE, $OUTPUT, $SITE, $DB; + public function new_feedback_page($new_feedback, $ajax = false) { + global $SITE, $DB; $submission = $new_feedback->get_submission(); $grading_title = get_string('gradingfor', 'coursework', $submission->get_allocatable_name()); - $PAGE->set_pagelayout('standard'); - $PAGE->navbar->add($grading_title); - $PAGE->set_title($SITE->fullname); - $PAGE->set_heading($SITE->fullname); + $this->page->set_pagelayout('standard'); + $this->page->navbar->add($grading_title); + $this->page->set_title($SITE->fullname); + $this->page->set_heading($SITE->fullname); $html = ''; @@ -346,7 +354,7 @@ public function new_feedback_page($new_feedback , $ajax = false) { $html .= '
Another user has already submitted feedback for this student. Your changes will not be saved.
'; } - $html .= $OUTPUT->heading($grading_title); + $html .= $this->output->heading($grading_title); $html .= ''; $assessor = $DB->get_record('user', array('id' => $new_feedback->assessorid)); $html .= ''; @@ -369,10 +377,10 @@ public function new_feedback_page($new_feedback , $ajax = false) { // get all initial stages feedbacks for this submission $initial_feedbacks = $DB->get_records('coursework_feedbacks', array('submissionid' => $new_feedback->submissionid)); - $teacher_feedback = new feedback(); + $teacher_feedback = new feedback(); $feedbackcomment = ''; $count = 1; - foreach($initial_feedbacks as $initial_feedback){ + foreach ($initial_feedbacks as $initial_feedback) { // put all initial feedbacks together for the comment field $feedbackcomment .= get_string('assessorcomments', 'mod_coursework', $count); $feedbackcomment .= $initial_feedback->feedbackcomment; @@ -393,21 +401,18 @@ public function new_feedback_page($new_feedback , $ajax = false) { $commentoptions = $this->get_comment_options($simple_form); echo json_encode(['formhtml' => $html . $formhtml, 'filemanageroptions' => $filemanageroptions, 'editoroptions' => $editoroptions, 'commentoptions' => $commentoptions]); - } else { - $PAGE->set_pagelayout('standard'); - $PAGE->navbar->add($grading_title); - $PAGE->set_title($SITE->fullname); - $PAGE->set_heading($SITE->fullname); - echo $OUTPUT->header(); + $this->page->set_pagelayout('standard'); + $this->page->navbar->add($grading_title); + $this->page->set_title($SITE->fullname); + $this->page->set_heading($SITE->fullname); + echo $this->output->header(); echo $html; $simple_form->display(); - echo $OUTPUT->footer(); + echo $this->output->footer(); } } - - /** * * @param $simple_form @@ -435,27 +440,25 @@ private function get_comment_options($simple_form) { return $commentoptions; } - - /** * @param moderation $new_moderation * @throws coding_exception */ - public function new_moderation_page($new_moderation){ + public function new_moderation_page($new_moderation) { - global $PAGE, $OUTPUT, $SITE, $DB; + global $SITE, $DB; $submission = $new_moderation->get_submission(); $grading_title = get_string('moderationfor', 'coursework', $submission->get_allocatable_name()); - $PAGE->set_pagelayout('standard'); - $PAGE->navbar->add($grading_title); - $PAGE->set_title($SITE->fullname); - $PAGE->set_heading($SITE->fullname); + $this->page->set_pagelayout('standard'); + $this->page->navbar->add($grading_title); + $this->page->set_title($SITE->fullname); + $this->page->set_heading($SITE->fullname); $html = ''; - $html .= $OUTPUT->heading($grading_title); + $html .= $this->output->heading($grading_title); $html .= '
' . get_string('assessor', 'coursework') . '' . fullname($assessor) . '
'; $moderator = $DB->get_record('user', array('id' => $new_moderation->moderatorid)); $html .= ''; @@ -463,69 +466,63 @@ public function new_moderation_page($new_moderation){ $submit_url = $this->get_router()->get_path('create moderation agreement', array('moderation' => $new_moderation)); $simple_form = new moderator_agreement_mform($submit_url, array('moderation' => $new_moderation)); - echo $OUTPUT->header(); + echo $this->output->header(); echo $html; $simple_form->display(); - echo $OUTPUT->footer(); + echo $this->output->footer(); } - - /** * @param plagiarism_flag $new_plagiarism_flag * @throws coding_exception */ - public function new_plagiarism_flag_page($new_plagiarism_flag){ + public function new_plagiarism_flag_page($new_plagiarism_flag) { - global $PAGE, $OUTPUT, $SITE, $DB; + global $SITE, $DB; $submission = $new_plagiarism_flag->get_submission(); $grading_title = get_string('plagiarismflaggingfor', 'coursework', $submission->get_allocatable_name()); - $PAGE->set_pagelayout('standard'); - $PAGE->navbar->add($grading_title); - $PAGE->set_title($SITE->fullname); - $PAGE->set_heading($SITE->fullname); + $this->page->set_pagelayout('standard'); + $this->page->navbar->add($grading_title); + $this->page->set_title($SITE->fullname); + $this->page->set_heading($SITE->fullname); $html = ''; - $html .= $OUTPUT->heading($grading_title); + $html .= $this->output->heading($grading_title); $submit_url = $this->get_router()->get_path('create plagiarism flag', array('plagiarism_flag' => $new_plagiarism_flag)); $simple_form = new plagiarism_flagging_mform($submit_url, array('plagiarism_flag' => $new_plagiarism_flag)); - echo $OUTPUT->header(); + echo $this->output->header(); echo $html; $simple_form->display(); - echo $OUTPUT->footer(); - + echo $this->output->footer(); } - - - /** * @param plagiarism_flag $plagiarism_flag * @throws coding_exception */ - public function edit_plagiarism_flag_page(plagiarism_flag $plagiarism_flag, $creator, $editor){ + public function edit_plagiarism_flag_page(plagiarism_flag $plagiarism_flag, $creator, $editor) { - global $PAGE, $OUTPUT, $SITE, $DB; + global $SITE, $DB; $submission = $plagiarism_flag->get_submission(); $grading_title = get_string('plagiarismflaggingfor', 'coursework', $submission->get_allocatable_name()); - $PAGE->set_pagelayout('standard'); - $PAGE->navbar->add($grading_title); - $PAGE->set_title($SITE->fullname); - $PAGE->set_heading($SITE->fullname); + $this->page->set_pagelayout('standard'); + $this->page->navbar->add($grading_title); + $this->page->set_title($SITE->fullname); + $this->page->set_heading($SITE->fullname); $html = ''; $createddby = fullname($creator); $lasteditedby = fullname($editor); - $html .= $OUTPUT->heading($grading_title); + $html .= $this->output->heading($grading_title); $html .= '
' . get_string('moderator', 'coursework') . '' . fullname($moderator) . '
'; $html .= ''; @@ -533,8 +530,7 @@ public function edit_plagiarism_flag_page(plagiarism_flag $plagiarism_flag, $cre userdate($plagiarism_flag->timemodified, '%a, %d %b %Y, %H:%M') . ''; $html .= '
' . get_string('createdby', 'coursework') . '' . $createddby . '
'; - - if($submission->is_published()) { + if ($submission->is_published()) { $html .= '
' . get_string('gradereleasedtostudent', 'coursework') . '
'; } @@ -544,18 +540,14 @@ public function edit_plagiarism_flag_page(plagiarism_flag $plagiarism_flag, $cre $plagiarism_flag->plagiarismcomment = array('text' => $plagiarism_flag->comment, 'format' => $plagiarism_flag->comment_format); - $simple_form->set_data($plagiarism_flag); - echo $OUTPUT->header(); + echo $this->output->header(); echo $html; $simple_form->display(); - echo $OUTPUT->footer(); - - + echo $this->output->footer(); } - /** * @param coursework $coursework * @param $page @@ -571,17 +563,14 @@ public function edit_plagiarism_flag_page(plagiarism_flag $plagiarism_flag, $cre * @throws moodle_exception */ public function teacher_grading_page($coursework, $page, $perpage, $sortby, $sorthow, $group, $firstnamealpha, $lastnamealpha, $groupnamealpha) { - - global $PAGE, $OUTPUT; - $html = ''; // Grading report display options. - $report_options = array(); + $report_options = []; $report_options['page'] = $page; $report_options['group'] = $group; $report_options['perpage'] = $perpage; - $report_options['mode'] = 2; //load first number of records specified by perpage first + $report_options['mode'] = 2; //load first number of records specified by perpage first $report_options['sortby'] = $sortby; $report_options['sorthow'] = $sorthow; $report_options['showsubmissiongrade'] = false; @@ -597,7 +586,7 @@ public function teacher_grading_page($coursework, $page, $perpage, $sortby, $sor /** * @var mod_coursework_grading_report_renderer $grading_report_renderer */ - $grading_report_renderer = $PAGE->get_renderer('mod_coursework', 'grading_report'); + $grading_report_renderer = $this->page->get_renderer('mod_coursework', 'grading_report'); $html .= $grading_report_renderer->submissions_header(); $warnings = new warnings($coursework); @@ -608,19 +597,19 @@ public function teacher_grading_page($coursework, $page, $perpage, $sortby, $sor $html .= $warnings->percentage_allocations_not_complete(); $html .= $warnings->student_in_no_group(); - $pageurl = $PAGE->url; - $params = $PAGE->url->params(); - $links = array(); + $pageurl = $this->page->url; + $params = $this->page->url->params(); + $links = []; // display 'Group mode' with the relevant groups $currenturl = new moodle_url('/mod/coursework/view.php', array('id' => $coursework->get_course_module()->id)); $html .= groups_print_activity_menu($coursework->get_course_module(), $currenturl->out(), true); if (groups_get_activity_groupmode($coursework->get_course_module()) != 0 && $group != 0) { - $html .= '
'.get_string('groupmodechosenalert','mod_coursework').'
'; + $html .= '
'.get_string('groupmodechosenalert', 'mod_coursework').'
'; } // reset table preferences - if($firstnamealpha || $lastnamealpha || $groupnamealpha) { + if ($firstnamealpha || $lastnamealpha || $groupnamealpha) { $url = new moodle_url('/mod/coursework/view.php', array('id' => $coursework->get_course_module()->id, 'treset' => 1)); $html .= html_writer::start_div('mdl-right'); @@ -628,42 +617,39 @@ public function teacher_grading_page($coursework, $page, $perpage, $sortby, $sor $html .= html_writer::end_div(); } - $finalised_submissions = submission::$pool[$coursework->id]['finalised'][1] ?? []; if ($finalised_submissions && !empty($grading_report->get_table_rows_for_page()) && !empty($submissions)) { $url = $pageurl.'&download=1'; - $links[$url] = get_string('download_submitted_files', 'coursework'); + $links[$url] = get_string('download_submitted_files', 'coursework'); } // export final grades button if (has_capability('mod/coursework:viewallgradesatalltimes', - $PAGE->context) && has_capability('mod/coursework:canexportfinalgrades', $PAGE->context) + $this->page->context) && has_capability('mod/coursework:canexportfinalgrades', $this->page->context) && $coursework->get_finalised_submissions() ) { $url = $pageurl.'&export=1'; $links[$url] = get_string('exportfinalgrades', 'mod_coursework'); } - if (!empty($grading_report->get_table_rows_for_page()) && !empty($submissions) - &&(has_capability('mod/coursework:addinitialgrade', $PAGE->context) - || has_capability('mod/coursework:addagreedgrade', $PAGE->context) - || has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) - || has_capability('mod/coursework:administergrades', $PAGE->context)) - && $coursework->get_finalised_submissions()){ - //export grading sheet + &&(has_capability('mod/coursework:addinitialgrade', $this->page->context) + || has_capability('mod/coursework:addagreedgrade', $this->page->context) + || has_capability('mod/coursework:addallocatedagreedgrade', $this->page->context) + || has_capability('mod/coursework:administergrades', $this->page->context)) + && $coursework->get_finalised_submissions()) { + // Export grading sheet $url = $pageurl.'&export_grading_sheet=1'; - $links[$url] = get_string('exportgradingsheets','mod_coursework'); - //import grading sheet - $url = '/mod/coursework/actions/upload_grading_sheet.php?cmid='.$PAGE->cm->id; - $links[$url] = get_string('uploadgradingworksheet','mod_coursework'); - //import annotated submissions - $url = '/mod/coursework/actions/upload_feedback.php?cmid='.$PAGE->cm->id; - $links[$url] = get_string('uploadfeedbackfiles','mod_coursework'); + $links[$url] = get_string('exportgradingsheets', 'mod_coursework'); + // Import grading sheet + $url = '/mod/coursework/actions/upload_grading_sheet.php?cmid='.$this->page->cm->id; + $links[$url] = get_string('uploadgradingworksheet', 'mod_coursework'); + // Import annotated submissions + $url = '/mod/coursework/actions/upload_feedback.php?cmid='.$this->page->cm->id; + $links[$url] = get_string('uploadfeedbackfiles', 'mod_coursework'); } - // don't show dropdown if there are no submissions if (!empty($submissions) && !empty($links)) { $gradingactions = new url_select($links); @@ -671,12 +657,10 @@ public function teacher_grading_page($coursework, $page, $perpage, $sortby, $sor $html .= $this->render($gradingactions);; } - if($firstnamealpha || $lastnamealpha || $groupnamealpha || $group != -1) { + if ($firstnamealpha || $lastnamealpha || $groupnamealpha || $group != -1) { $html .= $warnings->filters_warning(); } - - /** * @var mod_coursework_grading_report_renderer $grading_report_renderer */ @@ -686,7 +670,7 @@ public function teacher_grading_page($coursework, $page, $perpage, $sortby, $sor $html .= html_writer::end_tag('div'); // Publish button if appropriate. - if ($coursework->has_stuff_to_publish() && has_capability('mod/coursework:publish', $PAGE->context)) { + if ($coursework->has_stuff_to_publish() && has_capability('mod/coursework:publish', $this->page->context)) { $customdata = array('cmid' => $coursework->get_course_module()->id, 'gradingreport' => $grading_report, 'coursework' => $coursework); @@ -712,18 +696,14 @@ public function teacher_grading_page($coursework, $page, $perpage, $sortby, $sor * @throws coding_exception * @throws moodle_exception */ - public function non_teacher_allocated_grading_page($coursework,$viewallstudents_page,$viewallstudents_perpage,$viewallstudents_sortby,$viewallstudents_sorthow,$group,$displayallstudents,$firstnamealpha,$lastnamealpha,$groupnamealpha) { - - global $PAGE, $OUTPUT; - - $pageurl = $PAGE->url; + public function non_teacher_allocated_grading_page($coursework, $viewallstudents_page, $viewallstudents_perpage, $viewallstudents_sortby, $viewallstudents_sorthow, $group, $displayallstudents, $firstnamealpha, $lastnamealpha, $groupnamealpha) { + $pageurl = $this->page->url; $html = ''; - if (has_capability('mod/coursework:viewallstudents', $PAGE->context)) { - + if (has_capability('mod/coursework:viewallstudents', $this->page->context)) { - $report_options = array(); + $report_options = []; $report_options['page'] = $viewallstudents_page; $report_options['group'] = $group; $report_options['perpage'] = $viewallstudents_perpage; @@ -745,7 +725,6 @@ public function non_teacher_allocated_grading_page($coursework,$viewallstudents_ $customdata = array('cmid' => $coursework->get_course_module()->id, 'displayallstudents' => $displayallstudents); - $displayvalue = (empty($displayallstudents)) ? 1 : 0; $buttontext = (empty($displayallstudents)) ? get_string('showallstudents', 'coursework') : get_string('hideallstudents', 'coursework'); $buttontclass = (empty($displayallstudents)) ? 'show-students-btn' : 'hide-students-btn'; @@ -757,23 +736,17 @@ public function non_teacher_allocated_grading_page($coursework,$viewallstudents_ /** * @var mod_coursework_grading_report_renderer $grading_report_renderer */ - $grading_report_renderer = $PAGE->get_renderer('mod_coursework', 'grading_report'); + $grading_report_renderer = $this->page->get_renderer('mod_coursework', 'grading_report'); $html .= $grading_report_renderer->submissions_header(get_string('submissionnotallocatedtoassessor', 'coursework')); - /** * @var mod_coursework_grading_report_renderer $grading_report_renderer */ $html .= html_writer::start_tag('div', array('class' => 'wrapper_table_submissions')); - $html .= $grading_report_renderer->render_grading_report($grading_report,$coursework->has_multiple_markers(),true); + $html .= $grading_report_renderer->render_grading_report($grading_report, $coursework->has_multiple_markers(), true); $html .= html_writer::end_tag('div'); - - - - - /** * @var mod_coursework_grading_report_renderer $grading_report_renderer */ @@ -783,8 +756,6 @@ public function non_teacher_allocated_grading_page($coursework,$viewallstudents_ } - - /** * @param submission $submission * @param student_submission_form $submit_form @@ -792,8 +763,6 @@ public function non_teacher_allocated_grading_page($coursework,$viewallstudents_ * @throws coding_exception */ protected function file_submission_form($submission, $submit_form) { - global $OUTPUT, $PAGE; - $files = $submission->get_submission_files(); $coursework = $submission->get_coursework(); @@ -803,9 +772,9 @@ protected function file_submission_form($submission, $submit_form) { $html .= get_string('submissioninstructionstitle', 'coursework'); $html .= html_writer::end_tag('h1'); - $html .= $OUTPUT->box_start('generalbox instructions'); + $html .= $this->output->box_start('generalbox instructions'); $html .= html_writer::tag('p', get_string('submissioninstructions', 'coursework')); - $html .= $OUTPUT->box_end(); + $html .= $this->output->box_end(); $files_string = 'yoursubmissionstatus';//$files->has_multiple_files() ? 'yoursubmissionfiles' : 'yoursubmissionfile'; @@ -830,7 +799,7 @@ protected function file_submission_form($submission, $submit_form) { $draft_item_id = file_get_submitted_draft_itemid('submission'); // Put them into a draft area. file_prepare_draft_area($draft_item_id, - $PAGE->context->id, + $this->page->context->id, 'mod_coursework', 'submission', $submission->id, @@ -950,12 +919,10 @@ protected function submission_as_readonly_table($submission) { $row->cells[] = $submitted_time_cell; $table->data[] = $row; - - if ($submission->is_late() && (!$submission->has_extension() || !$submission->submitted_within_extension())) { // It was late. // check if submission has personal deadline - if ($coursework->personaldeadlineenabled ){ + if ($coursework->personaldeadlineenabled ) { $deadline = $submission->submission_personal_deadline(); } else { // if not, use coursework default deadline $deadline = $coursework->deadline; @@ -963,7 +930,7 @@ protected function submission_as_readonly_table($submission) { $deadline = ($submission->has_extension()) ? $submission->extension_deadline() : $deadline; - $lateseconds = $submission->time_submitted() - $deadline; + $lateseconds = $submission->time_submitted() - $deadline; $days = floor($lateseconds / 86400); $hours = floor($lateseconds / 3600) % 24; @@ -1009,16 +976,12 @@ protected function submission_as_readonly_table($submission) { } - /** * @param student_submission_form $submit_form * @param submission $own_submission * @throws \coding_exception */ public function new_submission_page($submit_form, $own_submission) { - - global $OUTPUT; - $html = ''; $html .= html_writer::start_tag('h3'); @@ -1036,9 +999,9 @@ public function new_submission_page($submit_form, $own_submission) { $submit_form->display(); $html .= ob_get_clean(); - echo $OUTPUT->header(); + echo $this->output->header(); echo $html; - echo $OUTPUT->footer(); + echo $this->output->footer(); } /** @@ -1047,9 +1010,6 @@ public function new_submission_page($submit_form, $own_submission) { * @throws \coding_exception */ public function edit_submission_page($submit_form, $submission) { - - global $OUTPUT; - $html = ''; $html .= html_writer::start_tag('h3'); @@ -1072,10 +1032,9 @@ public function edit_submission_page($submit_form, $submission) { $submit_form->display(); $html .= ob_get_clean(); - - echo $OUTPUT->header(); + echo $this->output->header(); echo $html; - echo $OUTPUT->footer(); + echo $this->output->footer(); } /** @@ -1093,13 +1052,10 @@ protected function get_router() { * @return string */ public function submit_on_behalf_of_student_interface($student, $submitform) { - - global $OUTPUT; - // Allow submission on behalf of the student. $html = ''; - $html .= $OUTPUT->header(); + $html .= $this->output->header(); $title = get_string('submitonbehalfofstudent', 'mod_coursework', fullname($student)); $html .= html_writer::start_tag('h3'); @@ -1111,7 +1067,7 @@ public function submit_on_behalf_of_student_interface($student, $submitform) { $html .= ob_get_contents(); ob_end_clean(); - $html .= $OUTPUT->footer(); + $html .= $this->output->footer(); return $html; } @@ -1120,8 +1076,7 @@ public function submit_on_behalf_of_student_interface($student, $submitform) { * @return mod_coursework_object_renderer */ private function get_object_renderer() { - global $PAGE; - return $PAGE->get_renderer('mod_coursework', 'object'); + return $this->page->get_renderer('mod_coursework', 'object'); } /** @@ -1131,7 +1086,6 @@ private function get_object_renderer() { * @throws coding_exception */ protected function finalise_submission_button($coursework, $submission) { - global $OUTPUT; $html = '
'; $string_name = $coursework->is_configured_to_have_group_submissions() ? 'finalisegroupsubmission' : 'finaliseyoursubmission'; @@ -1140,7 +1094,7 @@ protected function finalise_submission_button($coursework, $submission) { $button = new \single_button($finalise_submission_path, get_string($string_name, 'mod_coursework')); $button->class = 'finalisesubmissionbutton'; $button->add_confirm_action(get_string('finalise_button_confirm', 'mod_coursework')); - $html .= $OUTPUT->render($button); + $html .= $this->output->render($button); $html .= $this->finalise_warning(); $html .= '
'; @@ -1164,15 +1118,13 @@ public function finalise_warning() { * @throws coding_exception */ protected function edit_submission_button($coursework, $submission) { - global $OUTPUT; - $html = ''; $string_name = $coursework->is_configured_to_have_group_submissions() ? 'editgroupsubmission' : 'edityoursubmission'; $button = new \single_button($this->get_router() ->get_path('edit submission', array('submission' => $submission), true), get_string($string_name, 'mod_coursework'), 'get'); $button->class = 'editsubmissionbutton'; - $html .= $OUTPUT->render($button); + $html .= $this->output->render($button); return $html; } @@ -1182,8 +1134,6 @@ protected function edit_submission_button($coursework, $submission) { * @throws coding_exception */ protected function new_submission_button($submission) { - global $OUTPUT; - $html = ''; $string_name = $submission->get_coursework()->is_configured_to_have_group_submissions() ? 'addgroupsubmission' : 'addyoursubmission'; @@ -1191,7 +1141,7 @@ protected function new_submission_button($submission) { $label = get_string($string_name, 'mod_coursework'); $button = new \single_button($url, $label, 'get'); $button->class = 'newsubmissionbutton'; - $html .= $OUTPUT->render($button); + $html .= $this->output->render($button); return $html; } @@ -1201,13 +1151,11 @@ protected function new_submission_button($submission) { * @throws coding_exception */ protected function marking_preview_html($own_submission) { - global $PAGE; - $html = ''; if ($own_submission->get_coursework()->is_using_advanced_grading()) { $controller = $own_submission->get_coursework()->get_advanced_grading_active_controller(); - $preview_html = $controller->render_preview($PAGE); + $preview_html = $controller->render_preview($this->page); if (!empty($preview_html)) { $html .= '

'; $html .= get_string('marking_guide_preview', 'mod_coursework'); @@ -1230,27 +1178,23 @@ protected function marking_preview_html($own_submission) { */ function csv_upload($uploadform, $csvtype) { - global $OUTPUT, $PAGE; - $html = ''; - $html .= $OUTPUT->header(); + $html .= $this->output->header(); $title = get_string($csvtype, 'mod_coursework'); $html .= html_writer::start_tag('h3'); $html .= $title; $html .= html_writer::end_tag('h3'); - $html .= $uploadform->display(); - $html .= $OUTPUT->footer(); + $html .= $this->output->footer(); return $html; } - /** * Information about upload results, errors etc * @@ -1260,13 +1204,11 @@ function csv_upload($uploadform, $csvtype) { * @return string * @throws coding_exception */ - function process_csv_upload($processingresults,$csvcontent, $csvtype) { - - global $OUTPUT, $PAGE; + function process_csv_upload($processingresults, $csvcontent, $csvtype) { $html = ''; - $html .= $OUTPUT->header(); + $html .= $this->output->header(); $title = get_string('process'.$csvtype, 'mod_coursework'); $html .= html_writer::start_tag('h3'); @@ -1281,8 +1223,8 @@ function process_csv_upload($processingresults,$csvcontent, $csvtype) { if (!empty($processingresults)) { $html .= get_string('followingerrors', 'mod_coursework')."
"; - if (!is_array($processingresults)){ - $html .= $processingresults . "
"; + if (!is_array($processingresults)) { + $html .= $processingresults . "
"; } else { foreach ($processingresults as $line => $error) { $line = $line + 1; @@ -1294,51 +1236,42 @@ function process_csv_upload($processingresults,$csvcontent, $csvtype) { $html .= get_string('noallocationerrorsfound', 'mod_coursework'); } - $html .= html_writer::tag('p',html_writer::link('/mod/coursework/view.php?id='.$PAGE->cm->id, get_string('continuetocoursework', 'coursework'))); + $html .= html_writer::tag('p',html_writer::link('/mod/coursework/view.php?id='.$this->page->cm->id, get_string('continuetocoursework', 'coursework'))); - $html .= $OUTPUT->footer(); + $html .= $this->output->footer(); return $html; } - function feedback_upload($form) { - global $OUTPUT; - $html = ''; - $html .= $OUTPUT->header(); + $html .= $this->output->header(); $title = get_string('feedbackupload', 'mod_coursework'); $html .= html_writer::start_tag('h3'); $html .= $title; $html .= html_writer::end_tag('h3'); - $html .= $form->display(); - $html .= $OUTPUT->footer(); + $html .= $this->output->footer(); return $html; } function process_feedback_upload($processingresults) { - - global $OUTPUT, $PAGE,$OUTPUT; - $title = get_string('feedbackuploadresults', 'mod_coursework'); - $PAGE->set_pagelayout('standard'); - $PAGE->navbar->add($title); - + $this->page->set_pagelayout('standard'); + $this->page->navbar->add($title); $html = ''; - $html .= $OUTPUT->header($title); - + $html .= $this->output->header($title); $html .= html_writer::start_tag('h3'); $html .= $title; @@ -1354,16 +1287,16 @@ function process_feedback_upload($processingresults) { $html .= get_string('fileuploadresults', 'mod_coursework')."
"; foreach ($processingresults as $file => $result) { - $html .= get_string('fileuploadresult', 'mod_coursework',array('filename'=>$file,'result'=>$result)). "
"; + $html .= get_string('fileuploadresult', 'mod_coursework', array('filename' => $file, 'result' => $result)). "
"; } $html .= html_writer::end_tag('p'); } else { $html .= get_string('nofilesfound', 'mod_coursework'); } - $html .= html_writer::tag('p',html_writer::link('/mod/coursework/view.php?id='.$PAGE->cm->id, get_string('continuetocoursework', 'coursework'))); + $html .= html_writer::tag('p',html_writer::link('/mod/coursework/view.php?id='.$this->page->cm->id, get_string('continuetocoursework', 'coursework'))); - $html .= $OUTPUT->footer(); + $html .= $this->output->footer(); return $html; @@ -1376,7 +1309,7 @@ function process_feedback_upload($processingresults) { function view_course_index($courseid) { global $CFG, $DB, $USER; $o = ''; - $course = $DB->get_record('course', array('id'=>$courseid)); + $course = $DB->get_record('course', array('id' => $courseid)); $strplural = get_string('modulenameplural', 'assign'); if (!$cms = get_coursemodules_in_course('coursework', $course->id, 'm.deadline')) { $o .= $this->get_renderer()->notification(get_string('thereareno', 'moodle', $strplural)); @@ -1391,7 +1324,7 @@ function view_course_index($courseid) { $table = new html_table(); // table headers $format_name = course_get_format($course)->get_format(); - $table->head = array (ucfirst($format_name), 'Courseworks', 'Deadline', 'Submission', 'Grade'); + $table->head = array (ucfirst($format_name), 'Courseworks', 'Deadline', 'Submission', 'Grade'); $currentsection = ''; $printsection = ''; @@ -1414,11 +1347,11 @@ function view_course_index($courseid) { } $submitted = ''; - $timedue = ($coursework->deadline)? date('l, d F Y, h:i A', $coursework->deadline) : "No deadline"; + $timedue = ($coursework->deadline) ? date('l, d F Y, h:i A', $coursework->deadline) : "No deadline"; if ($coursework->can_grade()) { // teachers $submitted = count($coursework->get_all_submissions()); - } else if ($coursework->can_submit()) { //students - if($coursework->use_groups){ + } else if ($coursework->can_submit()) { // Students + if ($coursework->use_groups) { $allocatable = $coursework->get_student_group($USER); } else { $allocatable = $USER; @@ -1426,7 +1359,7 @@ function view_course_index($courseid) { } if ($allocatable) { $timedue = $coursework->get_allocatable_deadline($allocatable->id); // get deadline based on user taking into considerations personal deadline and extension - $timedue = ($timedue)? date('l, d F Y, h:i A', $timedue) : "No deadline"; + $timedue = ($timedue) ? date('l, d F Y, h:i A', $timedue) : "No deadline"; $usersubmission = $coursework->get_user_submission($allocatable); if ($usersubmission) { $submitted = $usersubmission->get_status_text(); @@ -1446,18 +1379,18 @@ function view_course_index($courseid) { } $url = $CFG->wwwroot.'/mod/coursework/view.php'; $link = "coursemodule->id}\">{$coursework->name}"; - $table->data[] = array(//'cmid'=>$cm->id, - 'sectionname'=>$printsection, - 'cmname'=>$link, - 'timedue'=>$timedue, - 'submissioninfo'=>$submitted, - 'gradeinfo'=>$grade); + $table->data[] = array(//'cmid' => $cm->id, + 'sectionname' => $printsection, + 'cmname' => $link, + 'timedue' => $timedue, + 'submissioninfo' => $submitted, + 'gradeinfo' => $grade); } - $o = html_writer::table($table); + $o = html_writer::table($table); return $o; } - public function datatables_render($coursework){ + public function datatables_render($coursework) { global $CFG; $lang_messages = [ @@ -1472,15 +1405,15 @@ public function datatables_render($coursework){ 'alert_personaldeadline_save_successful' => str_replace(' ', '_', get_string('alert_personaldeadline_save_successful', 'mod_coursework')), 'alert_validate_deadline' => str_replace(' ', '_', get_string('alert_validate_deadline', 'mod_coursework')), 'url_root' => $CFG->wwwroot, - 'alert_feedback_save_successful'=>str_replace(' ', '_', get_string('alert_feedback_save_successful', 'mod_coursework')), - 'alert_feedback_remove_successful'=>str_replace(' ', '_', get_string('alert_feedback_remove_successful', 'mod_coursework')), - 'alert_request_error'=>str_replace(' ', '_', get_string('alert_request_error', 'mod_coursework')), + 'alert_feedback_save_successful' => str_replace(' ', '_', get_string('alert_feedback_save_successful', 'mod_coursework')), + 'alert_feedback_remove_successful' => str_replace(' ', '_', get_string('alert_feedback_remove_successful', 'mod_coursework')), + 'alert_request_error' => str_replace(' ', '_', get_string('alert_request_error', 'mod_coursework')), 'alert_feedback_draft_save_successful' => str_replace(' ', '_', get_string('alert_feedback_draft_save_successful', 'mod_coursework')) ]; - $modal_header = html_writer::tag('h5','new Extension', array( + $modal_header = html_writer::tag('h5', 'new Extension', array( 'class' => 'modal-title', - 'id' => 'extension-modal-title', + 'id' => 'extension-modal-title', )); $modal_header .= html_writer::start_tag('button', array( 'type' => 'button', @@ -1488,119 +1421,119 @@ public function datatables_render($coursework){ 'aria-label' => 'Close', 'data-dismiss' => 'modal' )); - $modal_header .= html_writer::span('×','',array('aria-hidden'=>'true')); + $modal_header .= html_writer::span('×', '', array('aria-hidden' => 'true')); $modal_header .= html_writer::end_tag('button'); - $modal_body = html_writer::start_tag('form', array('id'=>'form-extension')); - $content = html_writer::empty_tag('input',array( - 'name'=>'allocatabletype', - 'type'=>'hidden', - 'value'=>'', - 'id'=>'extension-allocatabletype' + $modal_body = html_writer::start_tag('form', array('id' => 'form-extension')); + $content = html_writer::empty_tag('input', array( + 'name' => 'allocatabletype', + 'type' => 'hidden', + 'value' => '', + 'id' => 'extension-allocatabletype' )); - $content .= html_writer::empty_tag('input',array( - 'name'=>'allocatableid', - 'type'=>'hidden', - 'value'=>'', - 'id'=>'extension-allocatableid' + $content .= html_writer::empty_tag('input', array( + 'name' => 'allocatableid', + 'type' => 'hidden', + 'value' => '', + 'id' => 'extension-allocatableid' )); - $content .= html_writer::empty_tag('input',array( - 'name'=>'courseworkid', - 'type'=>'hidden', - 'value'=>'', - 'id'=>'extension-courseworkid' + $content .= html_writer::empty_tag('input', array( + 'name' => 'courseworkid', + 'type' => 'hidden', + 'value' => '', + 'id' => 'extension-courseworkid' )); - $content .= html_writer::empty_tag('input',array( - 'name'=>'id', - 'type'=>'hidden', - 'value'=>'', - 'id'=>'extension-id' + $content .= html_writer::empty_tag('input', array( + 'name' => 'id', + 'type' => 'hidden', + 'value' => '', + 'id' => 'extension-id' )); - $content .= html_writer::empty_tag('input',array( - 'name'=>'submissionid', - 'type'=>'hidden', - 'value'=>'', - 'id'=>'extension-submissionid' + $content .= html_writer::empty_tag('input', array( + 'name' => 'submissionid', + 'type' => 'hidden', + 'value' => '', + 'id' => 'extension-submissionid' )); - $content .= html_writer::empty_tag('input',array( - 'name'=>'name', - 'type'=>'hidden', - 'id'=>'extension-name', - 'value'=>'', + $content .= html_writer::empty_tag('input', array( + 'name' => 'name', + 'type' => 'hidden', + 'id' => 'extension-name', + 'value' => '', )); - $content .= html_writer::empty_tag('input',array( - 'name'=>'aid', - 'type'=>'hidden', - 'value'=>'', - 'id'=>'button-id' + $content .= html_writer::empty_tag('input', array( + 'name' => 'aid', + 'type' => 'hidden', + 'value' => '', + 'id' => 'button-id' )); - $modal_body .= html_writer::div($content,'display-none'); + $modal_body .= html_writer::div($content, 'display-none'); if ($coursework->deadline) { $content_default_deadline = 'Default deadline: ' . userdate($coursework->deadline); - $content_default_deadline = html_writer::div($content_default_deadline,'col-md-12', array('id'=>'extension-time-content')); - $modal_body .= html_writer::div($content_default_deadline,'form-group row fitem'); + $content_default_deadline = html_writer::div($content_default_deadline, 'col-md-12', array('id' => 'extension-time-content')); + $modal_body .= html_writer::div($content_default_deadline, 'form-group row fitem'); - $content_extended_deadline = html_writer::tag('label',get_string('extended_deadline', 'mod_coursework')); - $content_extended_deadline_div = html_writer::div($content_extended_deadline,'col-md-3'); + $content_extended_deadline = html_writer::tag('label', get_string('extended_deadline', 'mod_coursework')); + $content_extended_deadline_div = html_writer::div($content_extended_deadline, 'col-md-3'); $input = ''; - $content_extended_deadline_div .= html_writer::div($input,'col-md-6'); - $modal_body .= html_writer::div($content_extended_deadline_div,'form-group row fitem'); + $content_extended_deadline_div .= html_writer::div($input, 'col-md-6'); + $modal_body .= html_writer::div($content_extended_deadline_div, 'form-group row fitem'); $extension_reasons = coursework::extension_reasons(); if (!empty($extension_reasons)) { - $select_extension_reasons = html_writer::tag('label',get_string('extension_reason', 'mod_coursework')); - $select_extension_reasons_div = html_writer::div($select_extension_reasons,'col-md-3'); - $select_extension_reasons = html_writer::select($extension_reasons,'','',false, array( + $select_extension_reasons = html_writer::tag('label', get_string('extension_reason', 'mod_coursework')); + $select_extension_reasons_div = html_writer::div($select_extension_reasons, 'col-md-3'); + $select_extension_reasons = html_writer::select($extension_reasons, '', '', false, array( 'id' => 'extension-reason-select', 'class' => 'form-control' )); - $select_extension_reasons_div .= html_writer::div($select_extension_reasons,'col-md-9 form-inline felement', array('data-fieldtype'=>'select')); - $modal_body .= html_writer::div($select_extension_reasons_div,'form-group row fitem'); + $select_extension_reasons_div .= html_writer::div($select_extension_reasons, 'col-md-9 form-inline felement', array('data-fieldtype' => 'select')); + $modal_body .= html_writer::div($select_extension_reasons_div, 'form-group row fitem'); } - $content_extra_information = html_writer::tag('label',get_string('extra_information', 'mod_coursework'), array( - 'class'=>'col-form-label d-inline', 'for'=>'id_extra_information' + $content_extra_information = html_writer::tag('label', get_string('extra_information', 'mod_coursework'), array( + 'class' => 'col-form-label d-inline', 'for' => 'id_extra_information' )); - $content_extra_information_div = html_writer::div($content_extra_information,'col-md-3'); + $content_extra_information_div = html_writer::div($content_extra_information, 'col-md-3'); $content_extra_information = html_writer::tag('textarea', '', array( 'class' => 'form-control', 'rows' => '8', 'spellcheck' => 'true', 'id' => 'id_extra_information' )); - $content_extra_information_div .= html_writer::div($content_extra_information,'col-md-9 form-inline felement', array('data-fieldtype'=>'editor')); - $modal_body .= html_writer::div($content_extra_information_div,'form-group row fitem', array('id' => 'fitem_id_extra_information')); + $content_extra_information_div .= html_writer::div($content_extra_information, 'col-md-9 form-inline felement', array('data-fieldtype' => 'editor')); + $modal_body .= html_writer::div($content_extra_information_div, 'form-group row fitem', array('id' => 'fitem_id_extra_information')); } $modal_body .= html_writer::end_tag('form'); $modal_footer = html_writer::empty_tag('img', array( - 'src'=> $CFG->wwwroot . '/mod/coursework/pix/loadding.gif', - 'alt'=>'Load...', - 'width'=>'25', - 'class'=>'loading_moderation icon', - 'style'=>'visibility: hidden;' + 'src' => $CFG->wwwroot . '/mod/coursework/pix/loadding.gif', + 'alt' => 'Load...', + 'width' => '25', + 'class' => 'loading_moderation icon', + 'style' => 'visibility: hidden;' )); $modal_footer .= html_writer::tag('button', 'Save', array( - 'type'=>'button', - 'class'=>'btn btn-primary', - 'id'=>'extension-submit' + 'type' => 'button', + 'class' => 'btn btn-primary', + 'id' => 'extension-submit' )); $modal_footer .= html_writer::tag('button', 'Close', array( - 'type'=>'button', - 'class'=>'btn btn-secondary btn-extension-close', - 'data-dismiss'=>'modal' + 'type' => 'button', + 'class' => 'btn btn-secondary btn-extension-close', + 'data-dismiss' => 'modal' )); $modal_footer .= html_writer::tag('button', 'Back', array( - 'type'=>'button', - 'class'=>'btn btn-secondary', - 'id'=>'extension-back' + 'type' => 'button', + 'class' => 'btn btn-secondary', + 'id' => 'extension-back' )); $modal_footer .= html_writer::tag('button', 'Next', array( - 'type'=>'button', - 'class'=>'btn btn-secondary', - 'id'=>'extension-next' + 'type' => 'button', + 'class' => 'btn btn-secondary', + 'id' => 'extension-next' )); $html = html_writer::div($modal_header, 'modal-header'); @@ -1616,11 +1549,11 @@ public function datatables_render($coursework){ 'aria-labelledby' => 'modelTitleId', 'aria-hidden' => 'true' )); - $html .= html_writer::empty_tag('input',array( - 'name'=>'', - 'type'=>'hidden', - 'data-lang'=>json_encode($lang_messages), - 'id'=>'datatables_lang_messages' + $html .= html_writer::empty_tag('input', array( + 'name' => '', + 'type' => 'hidden', + 'data-lang' => json_encode($lang_messages), + 'id' => 'datatables_lang_messages' )); $html = html_writer::div($html); @@ -1642,8 +1575,7 @@ protected function render_advance_plugins_form() { /** * @return string */ - public function modal_grading_render() - { + public function modal_grading_render() { $this->page->requires->string_for_js('insertcomment', 'gradingform_guide'); $html = ' @@ -1666,5 +1597,4 @@ public function modal_grading_render() return $html; } - } diff --git a/settings.php b/settings.php index 86d1c5a2..b6ec8765 100644 --- a/settings.php +++ b/settings.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -28,22 +27,21 @@ if ($ADMIN->fulltree) { require_once($CFG->dirroot.'/mod/coursework/lib.php'); - $settings_header = new admin_setting_heading('settings_header','' ,get_string('settings_header', 'mod_coursework')); + $settings_header = new admin_setting_heading('settings_header', '', get_string('settings_header', 'mod_coursework')); $settings->add($settings_header); // Set site-wide option for late submission - $availability_header = new admin_setting_heading('availability_header', get_string('availability', 'mod_coursework'),''); + $availability_header = new admin_setting_heading('availability_header', get_string('availability', 'mod_coursework'), ''); $settings->add($availability_header); - $allow_late_submission_name = get_string('allowlatesubmissions', 'coursework'); + $allow_late_submission_name = get_string('allowlatesubmissions', 'coursework'); $allow_late_submission_description = get_string('allowlatesubmissions_desc', 'coursework'); $options = array( 0 => get_string('no'), 1 => get_string('yes')); $settings->add(new admin_setting_configselect('coursework_allowlatesubmissions', - $allow_late_submission_name, $allow_late_submission_description, 0,$options)); - + $allow_late_submission_name, $allow_late_submission_description, 0, $options)); // Set site-wide limit on submissions sizes. if (isset($CFG->maxbytes)) { - $submissions_header = new admin_setting_heading('submissions_header', get_string('submissions', 'mod_coursework'),''); + $submissions_header = new admin_setting_heading('submissions_header', get_string('submissions', 'mod_coursework'), ''); $settings->add($submissions_header); $configmaxbytesstring = get_string('configmaxbytes', 'coursework'); $maximumsizestring = get_string('maximumsize', 'coursework'); @@ -55,45 +53,41 @@ $settings->add($maxbytessetting); } - // Submissions - $submissions_header = new admin_setting_heading('submissions_header', get_string('submissions', 'mod_coursework'),''); + $submissions_header = new admin_setting_heading('submissions_header', get_string('submissions', 'mod_coursework'), ''); $settings->add($submissions_header); - $options = array( 0 => get_string('no'), 1 => get_string('yes')); + $options = array( 0 => get_string('no'), 1 => get_string('yes')); $settings->add(new admin_setting_configselect('coursework_plagiarismflag', get_string('plagiarism_flag_enable', 'mod_coursework'), get_string('plagiarism_flag_enable_desc', 'mod_coursework'), 0, $options)); - // Submission receipt - $submissionreceipt_header = new admin_setting_heading('submissionreceipt_header', get_string('submissionreceipt', 'mod_coursework'),''); + $submissionreceipt_header = new admin_setting_heading('submissionreceipt_header', get_string('submissionreceipt', 'mod_coursework'), ''); $settings->add($submissionreceipt_header); - $options = array( 0 => get_string('no'), 1 => get_string('yes')); + $options = array( 0 => get_string('no'), 1 => get_string('yes')); $settings->add(new admin_setting_configselect('coursework_allsubmissionreceipt', get_string('allsubmission', 'mod_coursework'), get_string('allsubmission_desc', 'mod_coursework'), 0, $options)); - - // Blind marking - $blindmarking_header = new admin_setting_heading('blindmarking_header', get_string('blindmarking', 'mod_coursework'),''); + $blindmarking_header = new admin_setting_heading('blindmarking_header', get_string('blindmarking', 'mod_coursework'), ''); $settings->add($blindmarking_header); - $blind_marking_name = get_string('blindmarking', 'coursework'); + $blind_marking_name = get_string('blindmarking', 'coursework'); $blind_marking_description = get_string('blindmarking_desc', 'coursework'); - $options = array( 0 => get_string('no'), 1 => get_string('yes')); + $options = array( 0 => get_string('no'), 1 => get_string('yes')); $settings->add(new admin_setting_configselect('coursework_blindmarking', $blind_marking_name, $blind_marking_description, 0, $options)); $settings->add(new admin_setting_configcheckbox('coursework_forceblindmarking', get_string('forceblindmarking', 'mod_coursework'), get_string('forceblindmarking_desc', 'mod_coursework'), 0)); // Assessor anonymity - $assessoranonymity_header = new admin_setting_heading('assessoranonymity_header', get_string('assessoranonymity', 'mod_coursework'),''); + $assessoranonymity_header = new admin_setting_heading('assessoranonymity_header', get_string('assessoranonymity', 'mod_coursework'), ''); $settings->add($assessoranonymity_header); - $assessor_anonymity_name = get_string('assessoranonymity', 'coursework'); + $assessor_anonymity_name = get_string('assessoranonymity', 'coursework'); $assessor_anonymity_description = get_string('assessoranonymity_desc', 'coursework'); - $options = array( 0 => get_string('no'), 1 => get_string('yes')); + $options = array( 0 => get_string('no'), 1 => get_string('yes')); $settings->add(new admin_setting_configselect('coursework_assessoranonymity', $assessor_anonymity_name, $assessor_anonymity_description, 0, $options)); // Set site-wide options for when feedback is due. - $weeks = array(); + $weeks = []; for ($i = 1; $i <= 10; $i++) { $weeks[$i] = $i; } - $feedbacktypes_header = new admin_setting_heading('feedbacktypes_header', get_string('feedbacktypes', 'mod_coursework'),''); + $feedbacktypes_header = new admin_setting_heading('feedbacktypes_header', get_string('feedbacktypes', 'mod_coursework'), ''); $settings->add($feedbacktypes_header); $generalfeedbackstring = get_string('generalfeedback', 'coursework'); $configgeneralfeedbackstring = get_string('configgeneralfeedback', 'coursework'); @@ -104,13 +98,12 @@ $settings->add($generalfeedbacksetting); // enable auto-release of individual feedback - $individual_feedback_auto_release_name = get_string('individual_feedback_auto_release', 'coursework'); + $individual_feedback_auto_release_name = get_string('individual_feedback_auto_release', 'coursework'); $individual_feedback_auto_release_name_description = get_string('individual_feedback_auto_release_desc', 'coursework'); - $options = array( 0 => get_string('no'), 1 => get_string('yes')); + $options = array( 0 => get_string('no'), 1 => get_string('yes')); $settings->add(new admin_setting_configselect('coursework_auto_release_individual_feedback', $individual_feedback_auto_release_name, $individual_feedback_auto_release_name_description, 0, $options)); $settings->add(new admin_setting_configcheckbox('coursework_forceauto_release_individual_feedback', get_string('forceautoauto_release_individual_feedback', 'mod_coursework'), get_string('forceautoauto_release_individual_feedback_desc', 'mod_coursework'), 0)); - $individualfeedbackstring = get_string('individualfeedback', 'coursework'); $configindfeedbackstring = get_string('configindividualfeedback', 'coursework'); $individualfeedbacksetting = new admin_setting_configselect('coursework_individualfeedback', @@ -120,18 +113,16 @@ $settings->add($individualfeedbacksetting); // Feedback release email - $feedbackreleaseemail_name = get_string('feedbackreleaseemail', 'coursework'); + $feedbackreleaseemail_name = get_string('feedbackreleaseemail', 'coursework'); $feedbackreleaseemail_description = get_string('feedbackreleaseemail_help', 'coursework'); - $options = array( 0 => get_string('no'), 1 => get_string('yes')); + $options = array( 0 => get_string('no'), 1 => get_string('yes')); $settings->add(new admin_setting_configselect('coursework_feedbackreleaseemail', $feedbackreleaseemail_name, $feedbackreleaseemail_description, 1, $options)); - - - $day_reminder = array(); + $day_reminder = []; for ($i = 2; $i <= 7; $i++) { $day_reminder[$i] = $i; } - $studentreminder_header = new admin_setting_heading('studentreminder_header', get_string('studentreminder', 'mod_coursework'),''); + $studentreminder_header = new admin_setting_heading('studentreminder_header', get_string('studentreminder', 'mod_coursework'), ''); $settings->add($studentreminder_header); $reminderstring = get_string('coursework_reminder', 'coursework'); $confreminderstring = get_string('config_coursework_reminder', 'coursework'); @@ -143,33 +134,30 @@ $settings->add(new admin_setting_configselect('coursework_day_second_reminder', $secondreminderstring, $confsecondreminderstring, 3, $day_reminder)); - // Sitewide message that students will see and agree to before submitting or editing. - $termsagreement_header = new admin_setting_heading('termsagreement_header', get_string('termsagreement', 'mod_coursework'),''); + $termsagreement_header = new admin_setting_heading('termsagreement_header', get_string('termsagreement', 'mod_coursework'), ''); $settings->add($termsagreement_header); $agree_terms_name = get_string('agreeterms', 'coursework'); $agree_terms_description = get_string('agreetermsdescription', 'coursework'); $options = array( 0 => get_string('no'), 1 => get_string('yes')); $settings->add(new admin_setting_configselect('coursework_agree_terms', - $agree_terms_name, $agree_terms_description, 0,$options)); + $agree_terms_name, $agree_terms_description, 0, $options)); $agree_terms_text = get_string('agreetermstext', 'coursework'); $settings->add(new admin_setting_confightmleditor('coursework_agree_terms_text', $agree_terms_text, '', '')); - // Extensions $extensions_header = new admin_setting_heading('extensions_header', get_string('extensions', 'mod_coursework'), ''); $settings->add($extensions_header); // Enable coursework individual extensions - $individual_extension_name = get_string('individual_extension', 'coursework'); + $individual_extension_name = get_string('individual_extension', 'coursework'); $individual_extension_description = get_string('individual_extension_desc', 'coursework'); - $options = array( 0 => get_string('no'), 1 => get_string('yes')); + $options = array( 0 => get_string('no'), 1 => get_string('yes')); $settings->add(new admin_setting_configselect('coursework_individual_extension', $individual_extension_name, $individual_extension_description, 1, $options)); - // Allow people to specify a list of extension reasons here so that they can be quickly chosen $extension_list_label = get_string('extension_reasons', 'coursework'); $extension_list_description = get_string('extension_reasons_desc', 'coursework'); @@ -177,47 +165,43 @@ $extension_list_label, $extension_list_description, '')); // maximum extension deadline - $settings->add(new admin_setting_configtext('coursework_max_extension_deadline',get_string('maximum_extension_deadline', 'coursework'), + $settings->add(new admin_setting_configtext('coursework_max_extension_deadline', get_string('maximum_extension_deadline', 'coursework'), get_string('maximum_extension_deadline_desc', 'coursework'), 18, PARAM_INT, 2)); // Default per page - $options = array('3'=>'3', '10'=>'10', '20'=>'20', '30'=>'30', '40'=>'40', '50'=>'50', '100'=>'100'); - + $options = array('3' => '3', '10' => '10', '20' => '20', '30' => '30', '40' => '40', '50' => '50', '100' => '100'); - $grading_page_header = new admin_setting_heading('grading_page_header', get_string('grading_page', 'mod_coursework'),''); + $grading_page_header = new admin_setting_heading('grading_page_header', get_string('grading_page', 'mod_coursework'), ''); $settings->add($grading_page_header); - $per_page = get_string('per_page', 'coursework'); + $per_page = get_string('per_page', 'coursework'); $per_page_description = get_string('per_page_desc', 'coursework'); $settings->add(new admin_setting_configselect('coursework_per_page', $per_page, $per_page_description, '10', $options)); - //automatic agreement delay + // Automatic agreement delay - $options = array('0'=>get_string('disabled', 'mod_coursework')); - $options['1800'] = get_string('timedminutes', 'mod_coursework','30'); - $options['3600'] = get_string('timedhour', 'mod_coursework','1'); - $options['7200'] = get_string('timedhours', 'mod_coursework','2'); - $options['18000'] = get_string('timedhours', 'mod_coursework','5'); - $options['43200'] = get_string('timedhours', 'mod_coursework','12'); - $options['86400'] = get_string('aday', 'mod_coursework'); - - - $grade_editing_header = new admin_setting_heading('grade_editing_header', get_string('grade_editing', 'mod_coursework'),''); + $options = array('0' => get_string('disabled', 'mod_coursework')); + $options['1800'] = get_string('timedminutes', 'mod_coursework', '30'); + $options['3600'] = get_string('timedhour', 'mod_coursework', '1'); + $options['7200'] = get_string('timedhours', 'mod_coursework', '2'); + $options['18000'] = get_string('timedhours', 'mod_coursework', '5'); + $options['43200'] = get_string('timedhours', 'mod_coursework', '12'); + $options['86400'] = get_string('aday', 'mod_coursework'); + + $grade_editing_header = new admin_setting_heading('grade_editing_header', get_string('grade_editing', 'mod_coursework'), ''); $settings->add($grade_editing_header); - $grade_editing_name = get_string('grade_editing_enabled', 'coursework'); + $grade_editing_name = get_string('grade_editing_enabled', 'coursework'); $grade_editing_description = get_string('grade_editing_enabled_desc', 'coursework'); $settings->add(new admin_setting_configselect('coursework_grade_editing', $grade_editing_name, $grade_editing_description, '0', $options)); - - //deadline defaults + // Deadline defaults $deadline_defaults_header = new admin_setting_heading('deadline_defaults_header', get_string('deadline_defaults', 'mod_coursework'), ''); $settings->add($deadline_defaults_header); - - //marking deadline + // Marking deadline $options = array('0' => get_string('disabled', 'mod_coursework')); $options['7'] = get_string('oneweekoption', 'mod_coursework'); $options['14'] = get_string('twoweeksoption', 'mod_coursework'); @@ -229,7 +213,7 @@ $marking_deadline_description = get_string('marking_deadline_enabled_desc', 'coursework'); $settings->add(new admin_setting_configselect('coursework_marking_deadline', $marking_deadline_name, $marking_deadline_description, '0', $options)); - //marking deadline + // Marking deadline $options = array('0' => get_string('disabled', 'mod_coursework')); $options['7'] = get_string('oneweekoption', 'mod_coursework'); $options['14'] = get_string('twoweeksoption', 'mod_coursework'); @@ -242,8 +226,7 @@ $agreed_marking_deadline_description = get_string('agreed_marking_deadline_default_desc', 'coursework'); $settings->add(new admin_setting_configselect('coursework_agreed_marking_deadline', $agreed_marking_deadline_name, $agreed_marking_deadline_description, '0', $options)); - - //start date + // Start date $options = array('0' => get_string('disabled', 'mod_coursework')); $options['1'] = get_string('today', 'mod_coursework'); @@ -251,7 +234,7 @@ $start_date_description = get_string('start_date_enabled_desc', 'coursework'); $settings->add(new admin_setting_configselect('coursework_start_date', $start_date_name, $start_date_description, '0', $options)); - //submission deadline + // Submission deadline $options = array('0' => get_string('disabled', 'mod_coursework')); $options['1'] = get_string('today', 'mod_coursework'); $options['7'] = get_string('sevendays', 'mod_coursework'); @@ -266,7 +249,7 @@ $assessor_allocations_header = new admin_setting_heading('assessor_allocations_header_header', get_string('assessorallocations', 'mod_coursework'), ''); $settings->add($assessor_allocations_header); - $options = array( 'username' => get_string('username'), 'email' => get_string('email')); + $options = array( 'username' => get_string('username'), 'email' => get_string('email')); $settings->add(new admin_setting_configselect('coursework_allocation_identifier', get_string('allocationidentifier', 'coursework'), get_string('allocationidentifier_desc', 'coursework'), 'username', $options)); } diff --git a/tests/behat/behat_mod_coursework.php b/tests/behat/behat_mod_coursework.php index 944eb227..4f2e930c 100644 --- a/tests/behat/behat_mod_coursework.php +++ b/tests/behat/behat_mod_coursework.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Step definitions for the Coursework module Behat tests. @@ -19,7 +39,7 @@ require_once(__DIR__ . '/../../../../vendor/phpunit/phpunit/src/Framework/Assert/Functions.php'); $files = glob(dirname(__FILE__) . '/steps/*.php'); -foreach($files as $filename) { +foreach ($files as $filename) { require_once($filename); } @@ -64,7 +84,7 @@ protected function get_page($page_name) { if (file_exists($file_path)) { require_once($file_path); - $class_name = 'mod_coursework_behat_' . $page_name ; + $class_name = 'mod_coursework_behat_' . $page_name; return new $class_name($this); } @@ -207,10 +227,10 @@ public function theCronRuns() { * @Then /^I should( not)? see( the)? (.*)'s name on the page$/ * @param bool $negate */ - public function iShouldSeeTheStudentSNameOnThePage($negate = false,$negate2=false,$studentrole) { + public function iShouldSeeTheStudentSNameOnThePage($negate = false, $negate2=false, $studentrole) { $page = $this->get_page('coursework page'); - $student = ($studentrole == "another student") ? $this->other_student : $this->student; + $student = ($studentrole == "another student") ? $this->other_student : $this->student; $studentname = fullname($student); @@ -245,7 +265,6 @@ private function get_first_assesor_stage() { return reset($stages); } - /** * * @@ -616,7 +635,7 @@ public function theGroupIsPartOfAGroupingForTheCoursework() { $generator = testing_util::get_data_generator(); $grouping = new stdClass(); $grouping->courseid = $this->course->id; - $grouping = $generator->create_grouping($grouping); + $grouping = $generator->create_grouping($grouping); groups_assign_grouping($grouping->id, $this->group->id); $this->get_coursework()->update_attribute('grouping_id', $grouping->id); } @@ -705,18 +724,16 @@ public function managersDoNotHaveTheManageCapability() { /** * @Given /^I am allowed to view all students$/ */ - public function iAmAllowedToViewAllStudents() { + public function iAmAllowedToViewAllStudents() { global $DB; - $teacher_role = $DB->get_record('role', array('shortname' => 'teacher')); - $params = array('roleid' => $teacher_role->id, - 'capability' => 'mod/coursework:viewallstudents'); - $permission_setting = CAP_ALLOW; + $teacher_role = $DB->get_record('role', array('shortname' => 'teacher')); + $params = array('roleid' => $teacher_role->id, + 'capability' => 'mod/coursework:viewallstudents'); + $permission_setting = CAP_ALLOW; $DB->set_field('role_capabilities', 'permission', $permission_setting, $params); } - - /** * IMPORTANT: CI server borks if this is not done *before* the manager * logs in! @@ -797,7 +814,6 @@ public function iShouldNotSeeTheAddFinalFeedbackButton($negate = false) { */ $page = $this->get_page('multiple grading interface'); - if ($negate) { $page->should_not_have_add_button_for_final_feedback($this->student->id()); } else { @@ -806,9 +822,6 @@ public function iShouldNotSeeTheAddFinalFeedbackButton($negate = false) { } - - - /** * @Then /^I should not see the edit final feedback button on the multiple marker page$/ */ @@ -883,8 +896,7 @@ public function iAgreeToTheConfirmMessage() { /** * @Given /^the coursework allocation option is disabled$/ */ - public function theCourseworkAllocationOptionIsDisabled() - { + public function theCourseworkAllocationOptionIsDisabled() { $coursework = $this->get_coursework(); $coursework->allocationenabled = 0; @@ -894,8 +906,7 @@ public function theCourseworkAllocationOptionIsDisabled() /** * @Given /^the manager has a capability to allocate students in samplings$/ */ - public function theManagerHasACapabilityToAllocateStudentsInSamplings() - { + public function theManagerHasACapabilityToAllocateStudentsInSamplings() { global $DB; $manager_role = $DB->get_record('role', array('shortname' => 'manager')); @@ -907,8 +918,7 @@ public function theManagerHasACapabilityToAllocateStudentsInSamplings() /** * @Given /^I (de)?select (a|another) student as a part of the sample for the second stage$/ */ - public function iSelectTheStudentAsAPartOfTheSample($negate = false,$other) - { + public function iSelectTheStudentAsAPartOfTheSample($negate = false, $other) { /** * @var mod_coursework_behat_allocations_page $page */ @@ -916,7 +926,7 @@ public function iSelectTheStudentAsAPartOfTheSample($negate = false,$other) $student = $other ? 'other_student' : 'student'; $page = $this->get_page('allocations page'); - if ($negate){ + if ($negate) { $page->deselect_for_sample($this->$student, 'assessor_2'); } else { $page->select_for_sample($this->$student, 'assessor_2'); @@ -926,8 +936,7 @@ public function iSelectTheStudentAsAPartOfTheSample($negate = false,$other) /** * @Given /^the teacher has a capability to mark submissions$/ */ - public function theTeacherHasACapabilityToMarkSubmissions() - { + public function theTeacherHasACapabilityToMarkSubmissions() { global $DB; $teacher_role = $DB->get_record('role', array('shortname' => 'teacher')); @@ -941,8 +950,7 @@ public function theTeacherHasACapabilityToMarkSubmissions() /** * @Given /^the teacher has a capability to edit their own initial feedbacks$/ */ - public function theTeacherHasACapabilityToEditOwnFeedbacks() - { + public function theTeacherHasACapabilityToEditOwnFeedbacks() { global $DB; $teacher_role = $DB->get_record('role', array('shortname' => 'teacher')); @@ -968,30 +976,27 @@ public function theTeacherHasACapabilityToEditOwnAgreedFeedbacks() { /** * @Given /^the coursework has sampling enabled$/ */ - public function theCourseworkHasSamplingEnabled() - { + public function theCourseworkHasSamplingEnabled() { $this->get_coursework()->update_attribute('samplingenabled', '1'); } /** * @Given /^there is feedback for the submission from the other teacher$/ */ - public function thereIsFeedbackForTheSubmissionFromTheOtherTeacher() - { + public function thereIsFeedbackForTheSubmissionFromTheOtherTeacher() { $this->feedback = feedback::create(array( - 'submissionid'=>$this->submission->id, + 'submissionid' => $this->submission->id, 'assessorid' => $this->other_teacher->id, - 'grade'=> '78', - 'feedbackcomment'=>'Blah', - 'stage_identifier'=>'assessor_1' + 'grade' => '78', + 'feedbackcomment' => 'Blah', + 'stage_identifier' => 'assessor_1' )); } /** * @Then /^I should (not )?be able to add the second grade for this student$/ */ - public function iShouldNotBeAbleToAddTheSecondGradeForThisStudent($negate = false) - { + public function iShouldNotBeAbleToAddTheSecondGradeForThisStudent($negate = false) { /** * @var mod_coursework_behat_multiple_grading_interface $page */ @@ -1008,8 +1013,7 @@ public function iShouldNotBeAbleToAddTheSecondGradeForThisStudent($negate = fals /** * @Then /^I should see the grade given by the initial teacher in the provisional grade column$/ */ - public function iShouldSeeTheGradeGivenByTheInitialTeacherInTheProvisionalGradeColumn() - { + public function iShouldSeeTheGradeGivenByTheInitialTeacherInTheProvisionalGradeColumn() { /** * @var mod_coursework_behat_multiple_grading_interface $page @@ -1056,7 +1060,6 @@ public function iAddANewExtensionForTheStudent() { $multigrader_page = $this->get_page('multiple grading interface'); $multigrader_page->click_new_extension_button_for($this->student); - /** * @var mod_coursework_behat_new_extension_page $new_extension_page */ @@ -1204,8 +1207,7 @@ public function iClickOnTheEditSubmissionButtonForTheStudent() { /** * @Given /^the coursework individual extension option is enabled$/ */ - public function theCourseworkIndividualExtensionOptionIsEnabled() - { + public function theCourseworkIndividualExtensionOptionIsEnabled() { $coursework = $this->get_coursework(); $coursework->extensionsenabled = 1; @@ -1318,8 +1320,6 @@ public function running_javascript() { return parent::running_javascript(); } - - // Course steps /** @@ -1500,9 +1500,6 @@ public function theSitewideSettingIs($setting_name, $setting_value) { set_config($setting_name, $setting_value); } - - - // Allocation steps /** @@ -1714,7 +1711,6 @@ public function theStudentShouldBeAllocatedToAnAssessor() { assertNotEmpty($result); } - // Feedback steps /** @@ -1939,9 +1935,9 @@ public function iShouldSeeTheModeratorGradeOnThePage() { */ $page = $this->get_page('multiple grading interface'); $page->should_have_moderator_grade_for($this->student, '56'); -// if (!$this->find('xpath', $this->xpath_tag_class_contains_text('td', 'moderated', '56'))) { -// throw new ExpectationException('Could not find the moderated grade', $this->getSession()); -// } +// if (!$this->find('xpath', $this->xpath_tag_class_contains_text('td', 'moderated', '56'))) { +// throw new ExpectationException('Could not find the moderated grade', $this->getSession()); +// } } /** @@ -2110,11 +2106,11 @@ public function iShouldSeeTheGradeOnThePage() { */ $page = $this->get_page('multiple grading interface'); $page->assessor_grade_should_be_present($this->student, 1, 56); -// $xpath = $this->xpath_tag_class_contains_text('td', 'cfeedbackcomment', '56'); -// if (!$this->getSession()->getPage()->has('xpath', $xpath)) { -// throw new ExpectationException('Should have seen the grade ("56"), but it was not there', -// $this->getSession()); -// } +// $xpath = $this->xpath_tag_class_contains_text('td', 'cfeedbackcomment', '56'); +// if (!$this->getSession()->getPage()->has('xpath', $xpath)) { +// throw new ExpectationException('Should have seen the grade ("56"), but it was not there', +// $this->getSession()); +// } } /** @@ -2139,7 +2135,6 @@ public function iGradeTheSubmissionUsingTheSimpleForm($grade = 56, $withoutcomme $nodeElement->selectOption($grade); } - if (empty($withoutcomments)) { $nodeElement1 = $this->find('css', '#feedback_comment'); if ($nodeElement1) { @@ -2294,7 +2289,6 @@ public function iShouldNotSeeALinkToAddFeedback() { $grading_interface->there_should_not_be_a_feedback_icon($this->student); } - // General web steps /** @@ -2325,7 +2319,7 @@ public function i_should_be_on_the_page($page_name, $ignore_params = false) { // possibly be a new id in there. if ($ignore_params) { $current_path = parse_url($currentUrl, PHP_URL_PATH); -// $desired_path = parse_url($desirtedUrl, PHP_URL_PATH); +// $desired_path = parse_url($desirtedUrl, PHP_URL_PATH); $message = "Should be on the " . $desirtedUrl . " page but instead the url is " . $current_path; assertEquals($current_path, $desirtedUrl, $message); } else { @@ -2374,15 +2368,11 @@ public function waitForSeconds($seconds) { $this->getSession()->wait($seconds * 1000); } - // And I click on ".moodle-dialogue-focused.filepicker .yui3-button.closebutton" "css_element" + // And I click on ".moodle-dialogue-focused.filepicker .yui3-button.closebutton" "css_element" public function dismiss() { $this->find('css', ".moodle-dialogue-focused.filepicker .yui3-button.closebutton")->click(); } - - - - // Submission steps /** @@ -2415,7 +2405,6 @@ public function anotherStudentHasAnotherSubmission() { $this->other_submission = $generator->create_submission($submission, $this->coursework); } - /** * @Given /^the group has a submission$/ */ @@ -2504,7 +2493,7 @@ public function iShouldNotSeeTheEditSubmissionButton($negate = false, $action = ->findAll('xpath', "//div[@class='{$action}submissionbutton']//input[@type='submit']"); $button = $this->getSession()->getPage() ->findAll('xpath', "//div[@class='{$action}submissionbutton']//button[@type='submit']"); - $buttons = ($input)? $input : $button;// check how element was created and use it to find the button + $buttons = ($input) ? $input : $button;// check how element was created and use it to find the button assertCount(($negate ? 0 : 1), $buttons); } @@ -2535,9 +2524,6 @@ public function iShouldSeeThatTheSubmissionWasMadeByTheOtherStudent($role_name) $student_page->should_show_the_submitter_as($role_name); } - - - // User steps /** @@ -2642,7 +2628,6 @@ public function iAmAMemberOfAGroup() { $group = $generator->create_group($group); $this->group = group::find($group); - $membership = new stdClass(); $membership->groupid = $this->group->id; $membership->userid = $this->student->id; @@ -2730,8 +2715,6 @@ public function iShouldSeeTheFirstInitialAssessorsGradeAndComment() { $page->should_have_grade('67'); } - - /** * @return mixed */ @@ -2778,41 +2761,37 @@ public function iClickOnShowAllStudentsButton() { $page->show_hide_non_allocated_students(); - } - /** * * @When /^I enable automatic sampling for stage ([1-3])$/ * */ - public function IEnableAutomaticSamplingForStage($stage) { + public function IEnableAutomaticSamplingForStage($stage) { $page = $this->get_page('allocations page'); $page->enable_atomatic_sampling_for($stage); } - /** * @Given /^I enable total rule for stage (\d+)$/ * * @param $stage * @throws coding_exception */ - public function IEnableTotalRuleForStage($stage) { + public function IEnableTotalRuleForStage($stage) { $page = $this->get_page('allocations page'); $page->enable_total_rule_for_stage($stage); } - /** * @Given /^I add grade range rule for stage (\d+)$/ * * @param $stage * @throws coding_exception */ - public function IAddGradeRangeRuleForStage($stage) { + public function IAddGradeRangeRuleForStage($stage) { $page = $this->get_page('allocations page'); $page->add_grade_range_rule_for_stage($stage); } @@ -2824,13 +2803,12 @@ public function IAddGradeRangeRuleForStage($stage) { * @param $stage * @throws coding_exception */ - public function IEnableGradeRangeRuleForStage($ruleno, $stage) { + public function IEnableGradeRangeRuleForStage($ruleno, $stage) { $ruleno = $ruleno - 1; $page = $this->get_page('allocations page'); $page->enable_grade_range_rule_for_stage($stage, $ruleno); } - /** * @Then /^I select limit type for grade range rule (\d+) in stage (\d+) as "([\w]*)"$/ * @@ -2839,13 +2817,12 @@ public function IEnableGradeRangeRuleForStage($ruleno, $stage) { * @param $type * @throws coding_exception */ - public function ISelectLimitTypeForGradeRangeRuleInStageAs($ruleno, $stage, $type) { + public function ISelectLimitTypeForGradeRangeRuleInStageAs($ruleno, $stage, $type) { $ruleno = $ruleno - 1; $page = $this->get_page('allocations page'); $page->select_type_of_grade_range_rule_for_stage($stage, $ruleno, $type); } - /** * @Then /^I select "([\w]*)" grade limit for grade range rule (\d+) in stage (\d+) as "(\d+)"$/ * @@ -2855,13 +2832,12 @@ public function ISelectLimitTypeForGradeRangeRuleInStageAs($ruleno, $stage, $typ * @param $value * @throws coding_exception */ - public function ISelectGradeLimitTypeForGradeRangeRuleInStageAs($range, $ruleno, $stage, $value) { + public function ISelectGradeLimitTypeForGradeRangeRuleInStageAs($range, $ruleno, $stage, $value) { $ruleno = $ruleno - 1; $page = $this->get_page('allocations page'); $page->select_range_for_grade_range_rule_for_stage($range, $stage, $ruleno, $value); } - /** * @Given /^I select (\d+)% of total students in stage (\d+)$/ * @@ -2869,9 +2845,9 @@ public function ISelectGradeLimitTypeForGradeRangeRuleInStageAs($range, $ruleno, * @param $stage * @throws coding_exception */ - public function ISelectTotalSubmissionsInStage($percentage,$stage) { + public function ISelectTotalSubmissionsInStage($percentage, $stage) { $page = $this->get_page('allocations page'); - $page->select_total_percentage_for_stage($percentage,$stage); + $page->select_total_percentage_for_stage($percentage, $stage); } /** @@ -2880,16 +2856,15 @@ public function ISelectTotalSubmissionsInStage($percentage,$stage) { * @param $stage * @throws coding_exception */ - public function StudentAutomaticallyIncludedInSampleForStage($other,$another,$negate,$stage) { + public function StudentAutomaticallyIncludedInSampleForStage($other, $another, $negate, $stage) { $page = $this->get_page('allocations page'); - $another = (!empty($another))? $this->other_student: ''; + $another = (!empty($another)) ? $this->other_student: ''; $other = ($other == 'another'); $student = $other ? 'other_student' : 'student'; - $page->automatically_included_in_sample($this->coursework,$this->$student,$another,$stage,$negate); + $page->automatically_included_in_sample($this->coursework, $this->$student, $another, $stage, $negate); } - /** * @Given /^I save sampling strategy$/ */ @@ -2922,27 +2897,27 @@ public function teachersHavaACapabilityToAdministerGrades() { * @AfterStep * @param \Behat\Behat\Event\StepEvent $event */ -// public function takeScreenshotAfterFailedStep(Behat\Behat\Event\StepEvent $event) { -// if ($event->getResult() === Behat\Behat\Event\StepEvent::FAILED) { +// public function takeScreenshotAfterFailedStep(Behat\Behat\Event\StepEvent $event) { +// if ($event->getResult() === Behat\Behat\Event\StepEvent::FAILED) { // -// $step = $event->getStep(); -// $path = array( -// 'date' => date("Ymd-Hi"), -// 'feature' => $step->getParent()->getFeature()->getTitle(), -// 'scenario' => $step->getParent()->getTitle(), -// 'step' => $step->getType() . ' ' . $step->getText(), -// ); -// $path = preg_replace('/[^\-\.\w]/', '_', $path); -// $filename = implode($path); +// $step = $event->getStep(); +// $path = array( +// 'date' => date("Ymd-Hi"), +// 'feature' => $step->getParent()->getFeature()->getTitle(), +// 'scenario' => $step->getParent()->getTitle(), +// 'step' => $step->getType() . ' ' . $step->getText(), +// ); +// $path = preg_replace('/[^\-\.\w]/', '_', $path); +// $filename = implode($path); // -// $driver = $this->getSession()->getDriver(); -// if ($driver instanceof Behat\Mink\Driver\Selenium2Driver) { -// $filename .= '_screenshot.jpg'; -// $this->show_me_a_screenshot($filename); -// } else { -// $filename .= '_page.html'; -// $this->show_me_the_page($filename); -// } -// } -// } -} \ No newline at end of file +// $driver = $this->getSession()->getDriver(); +// if ($driver instanceof Behat\Mink\Driver\Selenium2Driver) { +// $filename .= '_screenshot.jpg'; +// $this->show_me_a_screenshot($filename); +// } else { +// $filename .= '_page.html'; +// $this->show_me_the_page($filename); +// } +// } +// } +} diff --git a/tests/behat/pages/allocations_page.php b/tests/behat/pages/allocations_page.php index a39978bd..1dfb3db3 100644 --- a/tests/behat/pages/allocations_page.php +++ b/tests/behat/pages/allocations_page.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ use mod_coursework\allocation\allocatable; use mod_coursework\models\user; @@ -9,7 +29,6 @@ require_once($CFG->dirroot . '/mod/coursework/tests/behat/pages/page_base.php'); - /** * Holds the functions that know about the HTML structure of the student page. * @@ -62,7 +81,7 @@ public function manually_allocate($allocatable, $assessor, $stage_identifier) { * @param allocatable $student * @param string $stage_identifier */ - public function select_for_sample($student, $stage_identifier){ + public function select_for_sample($student, $stage_identifier) { $elementid = $this->sampling_checkbox_id($student, $stage_identifier); $node = $this->getPage()->find('css', $elementid); $node->check(); @@ -111,8 +130,7 @@ public function should_have_moderator_allocated($allocatable, $assessor) { * @param $stage_identifier * @throws \Behat\Mink\Exception\ElementException */ - public function deselect_for_sample($student, $stage_identifier) - { + public function deselect_for_sample($student, $stage_identifier) { $elementid = $this->sampling_checkbox_id($student, $stage_identifier); $node = $this->getPage()->find('css', $elementid); $node->uncheck(); @@ -123,8 +141,7 @@ public function deselect_for_sample($student, $stage_identifier) * @param $stage_identifier * @return string */ - public function sampling_checkbox_id($student, $stage_identifier) - { + public function sampling_checkbox_id($student, $stage_identifier) { $elementid = '#' . $student->type() . '_' . $student->id . '_' . $stage_identifier . '_samplecheckbox'; return $elementid; } @@ -137,8 +154,8 @@ public function student_should_have_allocation($student, $teacher, $string) { * @param $stage * @throws \Behat\Mink\Exception\ElementNotFoundException */ - public function enable_atomatic_sampling_for($stage) { - $elementid = '#assessor_'.$stage.'_samplingstrategy'; + public function enable_atomatic_sampling_for($stage) { + $elementid = '#assessor_'.$stage.'_samplingstrategy'; $node = $this->getPage()->find('css', $elementid); $node->selectOption('Automatic'); @@ -210,12 +227,12 @@ public function select_range_for_grade_range_rule_for_stage($range, $stage, $rul * @param $stage * @throws \Behat\Mink\Exception\ElementNotFoundException */ - public function select_total_percentage_for_stage($percentage,$stage) { + public function select_total_percentage_for_stage($percentage, $stage) { - //increment stage as the this will match the id of the element; + // Increment stage as the this will match the id of the element; $stage++; - $elementid = '#assessor_'.$stage.'_sampletotal'; + $elementid = '#assessor_'.$stage.'_sampletotal'; $node = $this->getPage()->find('css', $elementid); $node->selectOption($percentage); @@ -226,26 +243,25 @@ public function select_total_percentage_for_stage($percentage,$stage) { * @param $user * @param $stage_number */ - public function automatically_included_in_sample($coursework,$user,$other_user,$stage_number,$negate) { + public function automatically_included_in_sample($coursework, $user, $other_user, $stage_number, $negate) { global $DB; - $other_sql = (!empty($other_user))? "OR allocatableid = $other_user->id" : ''; + $other_sql = (!empty($other_user)) ? "OR allocatableid = $other_user->id" : ''; - $sql = "SELECT * + $sql = "SELECT * FROM {coursework_sample_set_mbrs} WHERE courseworkid = :courseworkid AND stage_identifier = :stage AND (allocatableid = :user $other_sql)"; + $stage = "assessor_".$stage_number; - $stage = "assessor_".$stage_number; - - $params = array('courseworkid'=>$coursework->id, - 'user'=>$user->id, + $params = array('courseworkid' => $coursework->id, + 'user' => $user->id, 'stage' => $stage); - if (empty($negate)){ - assertTrue($DB->record_exists_sql($sql,$params)); + if (empty($negate)) { + assertTrue($DB->record_exists_sql($sql, $params)); } else { assertFalse($DB->record_exists_sql($sql, $params)); } @@ -267,13 +283,10 @@ public function thereIsAnotherTeacher($other, $role_name) { $this->$role_name_to_save = $this->create_user($role_name, $role_name_to_save); } - - public function save_sampling_strategy() { + public function save_sampling_strategy() { $this->getPage()->pressButton('save_manual_sampling'); } - - -} \ No newline at end of file +} diff --git a/tests/behat/pages/coursework_page.php b/tests/behat/pages/coursework_page.php index c5dd71b9..1e2ca213 100644 --- a/tests/behat/pages/coursework_page.php +++ b/tests/behat/pages/coursework_page.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ use mod_coursework\allocation\allocatable; use mod_coursework\models\user; @@ -9,7 +29,6 @@ require_once($CFG->dirroot . '/mod/coursework/tests/behat/pages/page_base.php'); - /** * Holds the functions that know about the HTML structure of the student page. * @@ -43,7 +62,6 @@ public function confirm() { } } - public function show_hide_non_allocated_students() { if ($this->getPage()->hasLink('Show submissions for other students')) { $this->getPage()->clickLink('Show submissions for other students'); @@ -72,4 +90,4 @@ public function get_coursework_student_name($studentName) { return false; } -} \ No newline at end of file +} diff --git a/tests/behat/pages/edit_extension_page.php b/tests/behat/pages/edit_extension_page.php index 12270535..95f749fa 100644 --- a/tests/behat/pages/edit_extension_page.php +++ b/tests/behat/pages/edit_extension_page.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Class mod_coursework_behat_new_extension_page is responsible for representing the new @@ -50,4 +70,4 @@ public function should_show_extra_information_for_allocatable($string) { $field = $this->getPage()->findField('extra_information[text]'); assertContains($string, $field->getValue()); } -} \ No newline at end of file +} diff --git a/tests/behat/pages/gradebook_page.php b/tests/behat/pages/gradebook_page.php index 7538287d..0035ffd3 100644 --- a/tests/behat/pages/gradebook_page.php +++ b/tests/behat/pages/gradebook_page.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); @@ -6,7 +26,6 @@ require_once($CFG->dirroot . '/mod/coursework/tests/behat/pages/page_base.php'); - /** * Holds the functions that know about the HTML structure of the student page. * @@ -32,4 +51,4 @@ public function should_have_coursework_grade_for_student($coursework, $student, $cell_contents = $grade_cell->getText(); assertEquals($grade, $cell_contents, "Expected the gradebook grade to be '{$grade}', but got '{$cell_contents}'"); } -} \ No newline at end of file +} diff --git a/tests/behat/pages/login_page.php b/tests/behat/pages/login_page.php index 84e9268e..1cac2511 100644 --- a/tests/behat/pages/login_page.php +++ b/tests/behat/pages/login_page.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ use Behat\Mink\Exception\ExpectationException; @@ -8,7 +28,6 @@ require_once($CFG->dirroot . '/mod/coursework/tests/behat/pages/page_base.php'); - /** * Holds the functions that know about the HTML structure of the student page. * @@ -50,4 +69,4 @@ public function login($user) { } -} \ No newline at end of file +} diff --git a/tests/behat/pages/multiple_grading_interface.php b/tests/behat/pages/multiple_grading_interface.php index 0f06cb91..e359ed4c 100644 --- a/tests/behat/pages/multiple_grading_interface.php +++ b/tests/behat/pages/multiple_grading_interface.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ use mod_coursework\allocation\allocatable; use mod_coursework\models\coursework; @@ -82,7 +102,6 @@ private function allocatable_row_id($allocatable) { return '#allocatable_' . $this->allocatable_identifier_hash($allocatable); } - /** * @param allocatable $allocatable * @return string @@ -91,8 +110,6 @@ private function assessor_feedback_table_id($allocatable) { return '#assessorfeedbacktable_' . $this->allocatable_identifier_hash($allocatable); } - - /** * @param allocatable $allocatable * @throws Behat\Mink\Exception\ElementException @@ -171,15 +188,12 @@ public function press_publish_button() { public function confirm_publish_action() { - - if ($this->getPage()->hasButton('Continue')) { $this->getPage()->pressButton('Continue'); } else { echo "failed"; } - if ($this->getPage()->hasLink('Continue')) { $this->getPage()->clickLink('Continue'); } else { @@ -262,8 +276,6 @@ public function should_have_add_button_for_final_feedback($studentid) { $this->should_have_css($identifier); } - - /** * @param feedback $feedback */ @@ -272,12 +284,10 @@ public function should_not_have_edit_link_for_final_feedback($allocatable) { $this->should_not_have_css($identifier); } - /** * @param submission $submission */ - public function should_not_have_new_feedback_button($submission) - { + public function should_not_have_new_feedback_button($submission) { $elementid = $this->new_feedback_button_css($submission); $this->should_not_have_css($elementid); } @@ -308,7 +318,7 @@ protected function new_feedback_button_css($submission) { public function get_provisional_grade_field($submission) { $elementid = '#allocatable_' . $submission->get_coursework() ->get_allocatable_identifier_hash($submission->get_allocatable()). ' .assessor_feedback_grade'; - $grade_field = $this->getPage()->find('css', $elementid); + $grade_field = $this->getPage()->find('css', $elementid); return $grade_field ? $grade_field->getValue() : false; } @@ -316,10 +326,10 @@ public function get_provisional_grade_field($submission) { * @param submission $submission * @return string */ - public function get_grade_field($submission){ + public function get_grade_field($submission) { $elementid = '#assessorfeedbacktable_' . $submission->get_coursework() ->get_allocatable_identifier_hash($submission->get_allocatable()). ' .grade_for_gradebook_cell'; - $grade_field = $this->getPage()->find('css', $elementid); + $grade_field = $this->getPage()->find('css', $elementid); return $grade_field ? $grade_field->getValue() : false; } @@ -359,7 +369,6 @@ public function should_show_extension_reason_for_allocatable($student) { $this->should_have_css($element_selector, $reasons[1]); } - /** * @param allocatable $allocatable * @throws \Behat\Mink\Exception\ElementException @@ -377,4 +386,4 @@ public function click_edit_submission_button_for($allocatable) { $element_selector = $this->allocatable_row_id($allocatable) . ' .edit_submission'; $this->getPage()->find('css', $element_selector)->click(); } -} \ No newline at end of file +} diff --git a/tests/behat/pages/new_extension_page.php b/tests/behat/pages/new_extension_page.php index 760c0188..55484c53 100644 --- a/tests/behat/pages/new_extension_page.php +++ b/tests/behat/pages/new_extension_page.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Class mod_coursework_behat_new_extension_page is responsible for representing the new @@ -29,7 +49,6 @@ public function add_active_extension($time) { // Delegates to the field class. $field->set_value('Extra info here'); - $this->submit_form(); } @@ -37,4 +56,4 @@ public function submit_form() { $this->getPage()->find('css', '#id_submitbutton')->click(); } -} \ No newline at end of file +} diff --git a/tests/behat/pages/page_base.php b/tests/behat/pages/page_base.php index 89c5c4b6..6a97dc78 100644 --- a/tests/behat/pages/page_base.php +++ b/tests/behat/pages/page_base.php @@ -1,4 +1,25 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + use Behat\Mink\Element\NodeElement; use Behat\Mink\Exception\ElementNotFoundException; use Behat\Mink\Exception\ExpectationException; @@ -107,7 +128,7 @@ protected function click_that_thing($thing_css, $text = '') { * @var $things NodeElement[] */ $things = $this->getPage()->findAll('css', $thing_css); - foreach($things as $thing) { + foreach ($things as $thing) { if (empty($text) || $thing->getText() == $text || $thing->getValue() == $text) { $thing->click(); $ok = true; @@ -185,7 +206,7 @@ protected function pressButtonXpath($locator) { $inputtype = $this->getPage()->find('xpath', $locator ."//input[@type='submit']"); $buttontype = $this->getPage()->find('xpath', $locator ."//button[@type='submit']"); - $button = ($inputtype !== null)? $inputtype : $buttontype;// check how element was created and use it to find the button + $button = ($inputtype !== null) ? $inputtype : $buttontype;// check how element was created and use it to find the button if (null === $button) { throw new ElementNotFoundException( @@ -195,4 +216,4 @@ protected function pressButtonXpath($locator) { $button->press(); } -} \ No newline at end of file +} diff --git a/tests/behat/pages/show_feedback_page.php b/tests/behat/pages/show_feedback_page.php index 06697038..1888447a 100644 --- a/tests/behat/pages/show_feedback_page.php +++ b/tests/behat/pages/show_feedback_page.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); @@ -60,4 +80,4 @@ private function get_feedback() { } return $this->feedback; } -} \ No newline at end of file +} diff --git a/tests/behat/pages/single_grading_interface.php b/tests/behat/pages/single_grading_interface.php index c735e1fc..46c1db3a 100644 --- a/tests/behat/pages/single_grading_interface.php +++ b/tests/behat/pages/single_grading_interface.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ use mod_coursework\allocation\allocatable; use mod_coursework\models\coursework; @@ -124,4 +144,4 @@ public function should_have_assessor_name_in_assessor_feedback_cell($assessor) { private function allocatable_row_id(\mod_coursework\allocation\allocatable $allocatable) { return '#allocatable_' . $this->allocatable_identifier_hash($allocatable); } -} \ No newline at end of file +} diff --git a/tests/behat/pages/student_page.php b/tests/behat/pages/student_page.php index 16bce570..77907b4e 100644 --- a/tests/behat/pages/student_page.php +++ b/tests/behat/pages/student_page.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); @@ -101,4 +121,4 @@ public function click_on_the_save_submission_button() { $locator = "//div[@class='newsubmissionbutton']"; $this->pressButtonXpath($locator); } -} \ No newline at end of file +} diff --git a/tests/behat/pages/student_submission_form.php b/tests/behat/pages/student_submission_form.php index 6eb47ecc..35902fd0 100644 --- a/tests/behat/pages/student_submission_form.php +++ b/tests/behat/pages/student_submission_form.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); @@ -6,7 +26,6 @@ require_once($CFG->dirroot . '/mod/coursework/tests/behat/pages/page_base.php'); - /** * Holds the functions that know about the HTML structure of the student page. * @@ -26,4 +45,4 @@ public function should_not_have_the_save_and_finalise_button() { $buttons = $this->getPage()->findAll('css', '#id_finalisebutton'); assertEmpty($buttons); } -} \ No newline at end of file +} diff --git a/tests/classes/ability_test.php b/tests/classes/ability_test.php index 9bf27102..d105edec 100644 --- a/tests/classes/ability_test.php +++ b/tests/classes/ability_test.php @@ -1,5 +1,24 @@ . +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ use mod_coursework\ability; @@ -9,7 +28,7 @@ */ class ability_test extends advanced_testcase { - use \mod_coursework\test_helpers\factory_mixin; + use mod_coursework\test_helpers\factory_mixin; public function setUp() { $this->setAdminUser(); @@ -26,4 +45,4 @@ public function test_ridiculous_things_are_banned_by_default_if_not_mentioned() $this->assertFalse($ability->can('set_fire_to', $this->get_coursework())); } -} \ No newline at end of file +} diff --git a/tests/classes/allocation/auto_allocator_test.php b/tests/classes/allocation/auto_allocator_test.php index b6bf80e1..f986409f 100644 --- a/tests/classes/allocation/auto_allocator_test.php +++ b/tests/classes/allocation/auto_allocator_test.php @@ -1,4 +1,25 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + use mod_coursework\models\coursework; /** @@ -160,10 +181,6 @@ public function test_process_allocations_does_not_alter_non_manual_allocations_w $this->assertTrue(\mod_coursework\models\allocation::exists($allocation_params)); } - - - - private function set_coursework_to_single_marker() { $this->coursework->update_attribute('numberofmarkers', 1); } @@ -171,4 +188,4 @@ private function set_coursework_to_single_marker() { private function disable_moderation() { $this->coursework->update_attribute('moderationenabled', 0); } -} \ No newline at end of file +} diff --git a/tests/classes/allocation/form/table_processor_test.php b/tests/classes/allocation/form/table_processor_test.php index ebb11995..78a76fa9 100644 --- a/tests/classes/allocation/form/table_processor_test.php +++ b/tests/classes/allocation/form/table_processor_test.php @@ -1,10 +1,30 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + use mod_coursework\allocation\table\processor; use mod_coursework\models\coursework; global $CFG; - /** * This class takes the manual data about the teachers who should be allocated to various * students and saves it. We want to keep this separate from the processing of the auto allocations @@ -45,7 +65,6 @@ public function setUp() { $this->delete_all_auto_allocations_caused_by_enrol_hooks(); } - public function test_process_rows_makes_a_new_assessor_allocation() { global $DB; @@ -144,7 +163,7 @@ public function test_process_rows_alters_an_existing_allocation() { public function test_that_missing_columns_dont_mess_it_up() { $processor = new processor($this->coursework); - $processor->process_data(array($this->student->id => array())); + $processor->process_data(array($this->student->id => [])); } public function test_that_missing_rows_dont_mess_it_up() { @@ -196,4 +215,4 @@ private function delete_all_auto_allocations_caused_by_enrol_hooks() { $DB->delete_records('coursework_allocation_pairs'); } -} \ No newline at end of file +} diff --git a/tests/classes/allocation/strategy/percentages_test.php b/tests/classes/allocation/strategy/percentages_test.php index b8aa9ffd..df08c461 100644 --- a/tests/classes/allocation/strategy/percentages_test.php +++ b/tests/classes/allocation/strategy/percentages_test.php @@ -1,7 +1,26 @@ . -global $CFG; +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +global $CFG; /** * Class mod_coursework_allocation_strategy_percentages_test @@ -144,4 +163,4 @@ private function delete_all_allocations() { $DB->delete_records('coursework_allocation_pairs'); } -} \ No newline at end of file +} diff --git a/tests/classes/allocation/strategy_test.php b/tests/classes/allocation/strategy_test.php index 688c5574..1ad960c6 100644 --- a/tests/classes/allocation/strategy_test.php +++ b/tests/classes/allocation/strategy_test.php @@ -14,11 +14,16 @@ // 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} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + defined('MOODLE_INTERNAL') || die(); global $CFG; - /** * Unit tests for the base allocation strategy class. * @group mod_coursework @@ -76,5 +81,4 @@ public function test_allocate_all_ungraded() { } - } diff --git a/tests/classes/auto_grader/percentage_distance_test.php b/tests/classes/auto_grader/percentage_distance_test.php index b64b1107..a73a5567 100644 --- a/tests/classes/auto_grader/percentage_distance_test.php +++ b/tests/classes/auto_grader/percentage_distance_test.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_coursework\auto_grader; @@ -10,7 +30,7 @@ */ class percentage_distance_test extends \advanced_testcase { - use \mod_coursework\test_helpers\factory_mixin; + use mod_coursework\test_helpers\factory_mixin; public function setUp() { $this->setAdminUser(); @@ -117,7 +137,7 @@ public function test_that_a_new_record_is_not_created_when_all_initial_feedbacks $object->create_auto_grade_if_rules_match($user); - $created_feedback = $DB->get_record('coursework_feedbacks', array()); + $created_feedback = $DB->get_record('coursework_feedbacks', []); $this->assertEquals($created_feedback->grade, 55); // Right grade $this->assertEquals($created_feedback->submissionid, 234234); // Right submission diff --git a/tests/classes/controllers/deadline_extensions_controller_test.php b/tests/classes/controllers/deadline_extensions_controller_test.php index a398f6d2..01737e1b 100644 --- a/tests/classes/controllers/deadline_extensions_controller_test.php +++ b/tests/classes/controllers/deadline_extensions_controller_test.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Class deadline_extensions_controller_test is responsible for testing the deadline_extensions controller @@ -8,9 +28,8 @@ class deadline_extensions_controller_test extends basic_testcase { public function test_model_name() { - $controller = new \mod_coursework\controllers\deadline_extensions_controller(array()); + $controller = new \mod_coursework\controllers\deadline_extensions_controller([]); $this->assertEquals('deadline_extension', $controller->model_name()); } - -} \ No newline at end of file +} diff --git a/tests/classes/cron_test.php b/tests/classes/cron_test.php index eed71d49..42827e22 100644 --- a/tests/classes/cron_test.php +++ b/tests/classes/cron_test.php @@ -1,4 +1,25 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + use mod_coursework\models\submission; use mod_coursework\cron; @@ -75,7 +96,6 @@ public function test_admins_and_graders() { $this->assertEquals(array($teacher), $cron_class->get_admins_and_teachers($this->coursework->get_context())); } - public function test_auto_finalising_does_not_alter_time_submitted() { $this->create_a_course(); $coursework = $this->create_a_coursework(); @@ -132,8 +152,6 @@ public function test_auto_releasing_happens_after_deadline() { $this->assertNotEmpty($submission->reload()->firstpublished); } - - /** * Was throwing an error when the allocatable could not be found. */ @@ -152,4 +170,4 @@ public function test_cron_auto_releasing_when_the_user_is_not_there() { $this->assertEmpty($submission->reload()->firstpublished); } -} \ No newline at end of file +} diff --git a/tests/classes/export/csv_test.php b/tests/classes/export/csv_test.php index dbd06160..d1b15e07 100644 --- a/tests/classes/export/csv_test.php +++ b/tests/classes/export/csv_test.php @@ -23,7 +23,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - use mod_coursework\export\csv; use mod_coursework\models\submission; use mod_coursework\models\deadline_extension; @@ -39,13 +38,9 @@ */ class csv_test extends advanced_testcase { - use mod_coursework\test_helpers\factory_mixin; - - - - public function setUp() { + public function setUp():void { $this->resetAfterTest(); @@ -64,7 +59,7 @@ public function setUp() { * One stage only, extension enabled * @throws coding_exception */ - public function test_one_stage(){ + public function test_one_stage() { $dateformat = '%a, %d %b %Y, %H:%M'; $generator = $this->getDataGenerator()->get_plugin_generator('mod_coursework'); @@ -73,14 +68,13 @@ public function test_one_stage(){ $this->coursework = $generator->create_instance(array('course' => $this->course->id, 'grade' => 100, 'numberofmarkers' => 1, - 'deadline'=>time()+86400, - 'extensionsenabled'=>1)); + 'deadline' => time()+86400, + 'extensionsenabled' => 1)); $this->submission = new stdClass(); $this->submission->userid = $this->student->id; $this->submission->allocatableid = $this->student->id; $this->submission = $generator->create_submission($this->submission, $this->coursework); - $student = $this->student; $assessor = $this->teacher; $submission = $this->submission; @@ -91,7 +85,7 @@ public function test_one_stage(){ $feedback_data->stage_identifier = 'assessor_1'; $feedback = $generator->create_feedback($feedback_data); - $extendion_deadline = time(); + $extendion_deadline = time(); $params = array('allocatableid' => $this->student->id, 'allocatabletype' => 'user', 'courseworkid' => $this->coursework->id, @@ -103,21 +97,20 @@ public function test_one_stage(){ $extension = deadline_extension::create($params); - $extension_reasons = $this->coursework->extension_reasons(); + $extension_reasons = $this->coursework->extension_reasons(); if (empty($extension_reasons)) { - set_config('coursework_extension_reasons_list',"coursework extension \n sick leave"); - $extension_reasons = $this->coursework->extension_reasons(); + set_config('coursework_extension_reasons_list', "coursework extension \n sick leave"); + $extension_reasons = $this->coursework->extension_reasons(); } - // headers and data for csv - $csv_cells = array('name','username','submissiondate','submissiontime', + $csv_cells = array('name', 'username', 'submissiondate', 'submissiontime', 'submissionfileid'); - if ($this->coursework->extensions_enabled()){ + if ($this->coursework->extensions_enabled()) { $csv_cells[] = 'extensiondeadline'; $csv_cells[] = 'extensionreason'; $csv_cells[] = 'extensionextrainfo'; @@ -125,21 +118,19 @@ public function test_one_stage(){ $csv_cells[] = 'stages'; $csv_cells[] = 'finalgrade'; - $timestamp = date('d_m_y @ H-i'); $filename = get_string('finalgradesfor', 'coursework'). $this->coursework->name .' '.$timestamp; $csv = new \mod_coursework\export\csv($this->coursework, $csv_cells, $filename); - $csv_grades = $csv->add_cells_to_array($submission,$student,$csv_cells); + $csv_grades = $csv->add_cells_to_array($submission, $student, $csv_cells); // build an array $studentname = $student->lastname .' '.$student->firstname; $assessorname = $assessor->lastname .' '. $assessor->firstname; - $assessorusername = $assessor->username; - + $assessorusername = $assessor->username; $one_assessor_grades = array('0' => $studentname, '1' => $student->username, - '2' => userdate(time(),$dateformat), + '2' => userdate(time(), $dateformat), '3' => 'On time', '4' => $this->coursework->get_username_hash($submission->allocatableid), '5' => userdate($extension->extended_deadline, $dateformat), @@ -148,17 +139,16 @@ public function test_one_stage(){ '8' => $feedback->grade, '9' => $assessorname, '10' => $assessorusername, - '11' => userdate(time(),$dateformat), + '11' => userdate(time(), $dateformat), '12' => $feedback->grade); $this->assertEquals($one_assessor_grades, $csv_grades); } - /** * Two stages with final agreed grade, extension not enabled */ - public function test_two_stages(){ + public function test_two_stages() { $dateformat = '%a, %d %b %Y, %H:%M'; $generator = $this->getDataGenerator()->get_plugin_generator('mod_coursework'); @@ -167,12 +157,11 @@ public function test_two_stages(){ $this->coursework = $generator->create_instance(array('course' => $this->course->id, 'grade' => 100, 'numberofmarkers' => 2, - 'deadline'=>time()-86400)); + 'deadline' => time()-86400)); $this->submission = new stdClass(); $this->submission->userid = $this->student->id; $this->submission = $generator->create_submission($this->submission, $this->coursework); - $student = $this->student; $assessor1 = $this->teacher; $assessor2 = $this->other_teacher; @@ -204,10 +193,10 @@ public function test_two_stages(){ $feedback3 = $generator->create_feedback($feedback_data3); // headers and data for csv - $csv_cells = array('name','username','submissiondate','submissiontime', + $csv_cells = array('name', 'username', 'submissiondate', 'submissiontime', 'submissionfileid'); - if ($this->coursework->extensions_enabled()){ + if ($this->coursework->extensions_enabled()) { $csv_cells[] = 'extensiondeadline'; $csv_cells[] = 'extensionreason'; $csv_cells[] = 'extensionextrainfo'; @@ -215,11 +204,10 @@ public function test_two_stages(){ $csv_cells[] = 'stages'; $csv_cells[] = 'finalgrade'; - $timestamp = date('d_m_y @ H-i'); $filename = get_string('finalgradesfor', 'coursework'). $this->coursework->name .' '.$timestamp; $csv = new \mod_coursework\export\csv($this->coursework, $csv_cells, $filename); - $csv_grades = $csv->add_cells_to_array($submission,$student,$csv_cells); + $csv_grades = $csv->add_cells_to_array($submission, $student, $csv_cells); // build an array $studentname = $student->lastname .' '.$student->firstname; @@ -231,31 +219,30 @@ public function test_two_stages(){ $two_assessors_grades = array('0' => $studentname, '1' => $student->username, - '2' => userdate(time(),$dateformat), + '2' => userdate(time(), $dateformat), '3' => 'Late', '4' => $this->coursework->get_username_hash($submission->allocatableid), '5' => $feedback1->grade, '6' => $assessorname1, '7' => $assessorusername1, - '8' => userdate(time(),$dateformat), + '8' => userdate(time(), $dateformat), '9' => $feedback2->grade, '10' => $assessorname2, '11' => $assessorusername2, - '12' => userdate(time(),$dateformat), + '12' => userdate(time(), $dateformat), '13' => $feedback3->grade, '14' => $assessorname1, '15' => $assessorusername1, - '16' => userdate(time(),$dateformat), + '16' => userdate(time(), $dateformat), '17' => $feedback3->grade); $this->assertEquals($two_assessors_grades, $csv_grades); } - /** * Sampling enabled, student not in sample, extension not enabled */ - public function test_student_not_in_sample(){ + public function test_student_not_in_sample() { $dateformat = '%a, %d %b %Y, %H:%M'; $generator = $this->getDataGenerator()->get_plugin_generator('mod_coursework'); @@ -265,7 +252,7 @@ public function test_student_not_in_sample(){ 'grade' => 100, 'numberofmarkers' => 2, 'samplingenabled' => 1, - 'deadline'=>time()+86400)); + 'deadline' => time()+86400)); $this->submission = new stdClass(); $this->submission->userid = $this->student->id; $this->submission = $generator->create_submission($this->submission, $this->coursework); @@ -283,10 +270,10 @@ public function test_student_not_in_sample(){ $feedback = $generator->create_feedback($feedback_data); // headers and data for csv - $csv_cells = array('name','username','submissiondate','submissiontime', + $csv_cells = array('name', 'username', 'submissiondate', 'submissiontime', 'submissionfileid'); - if ($this->coursework->extensions_enabled()){ + if ($this->coursework->extensions_enabled()) { $csv_cells[] = 'extensiondeadline'; $csv_cells[] = 'extensionreason'; $csv_cells[] = 'extensionextrainfo'; @@ -294,11 +281,10 @@ public function test_student_not_in_sample(){ $csv_cells[] = 'stages'; $csv_cells[] = 'finalgrade'; - $timestamp = date('d_m_y @ H-i'); $filename = get_string('finalgradesfor', 'coursework'). $this->coursework->name .' '.$timestamp; $csv = new \mod_coursework\export\csv($this->coursework, $csv_cells, $filename); - $csv_grades = $csv->add_cells_to_array($submission,$student,$csv_cells); + $csv_grades = $csv->add_cells_to_array($submission, $student, $csv_cells); // build an array $studentname = $student->lastname .' '.$student->firstname; @@ -306,16 +292,15 @@ public function test_student_not_in_sample(){ $assessorusername1 = $assessor1->username; - $grades = array('0' => $studentname, '1' => $student->username, - '2' => userdate(time(),$dateformat), + '2' => userdate(time(), $dateformat), '3' => 'On time', '4' => $this->coursework->get_username_hash($submission->allocatableid), '5' => $feedback->grade, '6' => $assessorname1, '7' => $assessorusername1, - '8' => userdate(time(),$dateformat), + '8' => userdate(time(), $dateformat), '9' => '', '10' => '', '11' => '', @@ -332,7 +317,7 @@ public function test_student_not_in_sample(){ /** * Two students but only one is double marked and should have agreed grade, extension not enabled */ - public function test_two_students_one_in_sample(){ + public function test_two_students_one_in_sample() { global $DB; $dateformat = '%a, %d %b %Y, %H:%M'; $generator = $this->getDataGenerator()->get_plugin_generator('mod_coursework'); @@ -342,7 +327,7 @@ public function test_two_students_one_in_sample(){ 'grade' => 100, 'numberofmarkers' => 2, 'samplingenabled' => 1, - 'deadline'=>time()+86400)); + 'deadline' => time()+86400)); $student1 = $this->student; $assessor1 = $this->teacher; $assessor2 = $this->other_teacher; @@ -351,14 +336,12 @@ public function test_two_students_one_in_sample(){ $submission1->allocatableid = $student1->id; $submission1 = $generator->create_submission($submission1, $this->coursework); - $student2 = $this->create_a_student(); $submission2 = new stdClass(); $submission2->userid = $student2->id; $submission2->allocatableid = $student2->id; $submission2 = $generator->create_submission($submission2, $this->coursework); - // student 2 manual sampling enabled $set_members_data = new stdClass(); $set_members_data->courseworkid = $this->coursework->id; @@ -368,8 +351,6 @@ public function test_two_students_one_in_sample(){ $DB->insert_record('coursework_sample_set_mbrs', $set_members_data); - - // Assessor one feedback for student 1 $feedback_data1 = new stdClass(); $feedback_data1->submissionid = $submission1->id; @@ -404,10 +385,10 @@ public function test_two_students_one_in_sample(){ $feedback4 = $generator->create_feedback($feedback_data4); // headers and data for csv - $csv_cells = array('name','username','submissiondate','submissiontime', + $csv_cells = array('name', 'username', 'submissiondate', 'submissiontime', 'submissionfileid'); - if ($this->coursework->extensions_enabled()){ + if ($this->coursework->extensions_enabled()) { $csv_cells[] = 'extensiondeadline'; $csv_cells[] = 'extensionreason'; $csv_cells[] = 'extensionextrainfo'; @@ -415,12 +396,11 @@ public function test_two_students_one_in_sample(){ $csv_cells[] = 'stages'; $csv_cells[] = 'finalgrade'; - $timestamp = date('d_m_y @ H-i'); $filename = get_string('finalgradesfor', 'coursework'). $this->coursework->name .' '.$timestamp; $csv = new \mod_coursework\export\csv($this->coursework, $csv_cells, $filename); - $array1 = $csv->add_cells_to_array($submission1,$student1,$csv_cells); - $array2 = $csv->add_cells_to_array($submission2,$student2,$csv_cells); + $array1 = $csv->add_cells_to_array($submission1, $student1, $csv_cells); + $array2 = $csv->add_cells_to_array($submission2, $student2, $csv_cells); $csv_grades = array_merge($array1, $array2); @@ -430,18 +410,18 @@ public function test_two_students_one_in_sample(){ $assessorname1 = $assessor1->lastname .' '. $assessor1->firstname; $assessorname2 = $assessor2->lastname .' '. $assessor2->firstname; - $assessorusername1 = $assessor1->username; - $assessorusername2 = $assessor2->username; + $assessorusername1 = $assessor1->username; + $assessorusername2 = $assessor2->username; $assessors_grades = array('0' => $studentname1, '1' => $student1->username, - '2' => userdate(time(),$dateformat), + '2' => userdate(time(), $dateformat), '3' => 'On time', '4' => $this->coursework->get_username_hash($submission1->allocatableid), '5' => $feedback1->grade, '6' => $assessorname1, '7' => $assessorusername1, - '8' => userdate(time(),$dateformat), + '8' => userdate(time(), $dateformat), '9' => '', '10' => '', '11' => '', @@ -453,25 +433,24 @@ public function test_two_students_one_in_sample(){ '17' => $feedback1->grade, '18' => $studentname2, '19' => $student2->username, - '20' => userdate(time(),$dateformat), + '20' => userdate(time(), $dateformat), '21' => 'On time', '22' => $this->coursework->get_username_hash($submission2->allocatableid), '23' => $feedback2->grade, '24' => $assessorname1, '25' => $assessorusername1, - '26' => userdate(time(),$dateformat), + '26' => userdate(time(), $dateformat), '27' => $feedback3->grade, '28' => $assessorname2, '29' => $assessorusername2, - '30' => userdate(time(),$dateformat), + '30' => userdate(time(), $dateformat), '31' => $feedback4->grade, '32' => $assessorname2, '33' => $assessorusername2, - '34' => userdate(time(),$dateformat), - '35'=> $feedback4->grade); + '34' => userdate(time(), $dateformat), + '35' => $feedback4->grade); $this->assertEquals($assessors_grades, $csv_grades); } } - diff --git a/tests/classes/export/grading_sheet_download_test.php b/tests/classes/export/grading_sheet_download_test.php index a04374a5..01cf13b9 100644 --- a/tests/classes/export/grading_sheet_download_test.php +++ b/tests/classes/export/grading_sheet_download_test.php @@ -22,8 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - - defined('MOODLE_INTERNAL') || die(); global $CFG; @@ -35,7 +33,6 @@ */ class grading_sheet_download_test extends advanced_testcase { - use mod_coursework\test_helpers\factory_mixin; public function setUp() { @@ -57,7 +54,7 @@ public function setUp() { * One stage only, no allocation, one student, coursework submitted but not graded * @throws coding_exception */ - public function test_one_stage_no_allocations(){ + public function test_one_stage_no_allocations() { $generator = $this->getDataGenerator()->get_plugin_generator('mod_coursework'); @@ -65,7 +62,7 @@ public function test_one_stage_no_allocations(){ $this->coursework = $generator->create_instance(array('course' => $this->course->id, 'grade' => 100, 'numberofmarkers' => 1, - 'deadline'=>time()+86400)); + 'deadline' => time()+86400)); $this->submission = new stdClass(); $this->submission->userid = $this->student->id; $this->submission->allocatableid = $this->student->id; @@ -75,12 +72,12 @@ public function test_one_stage_no_allocations(){ $submission = $this->submission; // headers and data for csv - $csv_cells = array('submissionid','submissionfileid','name','username','submissiontime','singlegrade','feedbackcomments'); + $csv_cells = array('submissionid', 'submissionfileid', 'name', 'username', 'submissiontime', 'singlegrade', 'feedbackcomments'); $timestamp = date('d_m_y @ H-i'); $filename = get_string('gradingsheetfor', 'coursework'). $this->coursework->name .' '.$timestamp; $grading_sheet = new \mod_coursework\export\grading_sheet($this->coursework, $csv_cells, $filename); - $actual_submission = $grading_sheet->add_cells_to_array($submission,$student,$csv_cells); + $actual_submission = $grading_sheet->add_cells_to_array($submission, $student, $csv_cells); $studentname = $student->lastname .' '.$student->firstname; @@ -101,16 +98,15 @@ public function test_one_stage_no_allocations(){ * student1 graded by assessor2, student2 graded by assessor1 and assessor2 * @throws coding_exception */ - public function test_two_stages_with_allocations(){ + public function test_two_stages_with_allocations() { $generator = $this->getDataGenerator()->get_plugin_generator('mod_coursework'); - /* @var mod_coursework_generator $generator */ $this->coursework = $generator->create_instance(array('course' => $this->course->id, 'grade' => 100, 'numberofmarkers' => 2, 'allocationenabled' => 1, - 'deadline'=>time()+86400)); + 'deadline' => time()+86400)); // 2 assessors $assessor1 = $this->teacher; @@ -130,8 +126,6 @@ public function test_two_stages_with_allocations(){ $submission2->allocatableid = $student2->id; $submission2 = $generator->create_submission($submission2, $this->coursework); - - // Assessor2 feedback for student1 $feedback_data1 = new stdClass(); $feedback_data1->submissionid = $submission1->id; @@ -159,7 +153,6 @@ public function test_two_stages_with_allocations(){ $feedback_data3->stage_identifier = 'assessor_2'; $feedback3 = $generator->create_feedback($feedback_data3); - // Agreed grade feedback $feedback_data4 = new stdClass(); $feedback_data4->submissionid = $submission2->id; @@ -169,17 +162,16 @@ public function test_two_stages_with_allocations(){ $feedback_data4->stage_identifier = 'final_agreed_1'; $feedback4 = $generator->create_feedback($feedback_data4); - // headers and data for csv - $csv_cells = array('submissionid','submissionfileid','name','username','submissiontime', - 'assessor1','assessorgrade1','assessorfeedback1','assessor2','assessorgrade2','assessorfeedback2', - 'agreedgrade','agreedfeedback'); + $csv_cells = array('submissionid', 'submissionfileid', 'name', 'username', 'submissiontime', + 'assessor1', 'assessorgrade1', 'assessorfeedback1', 'assessor2', 'assessorgrade2', 'assessorfeedback2', + 'agreedgrade', 'agreedfeedback'); $timestamp = date('d_m_y @ H-i'); $filename = get_string('gradingsheetfor', 'coursework'). $this->coursework->name .' '.$timestamp; $grading_sheet = new \mod_coursework\export\grading_sheet($this->coursework, $csv_cells, $filename); - $actual_submission1 = $grading_sheet->add_cells_to_array($submission1,$student1,$csv_cells); - $actual_submission2 = $grading_sheet->add_cells_to_array($submission2,$student2,$csv_cells); + $actual_submission1 = $grading_sheet->add_cells_to_array($submission1, $student1, $csv_cells); + $actual_submission2 = $grading_sheet->add_cells_to_array($submission2, $student2, $csv_cells); $actual_submission = array_merge($actual_submission1, $actual_submission2); $studentname1 = $student1->lastname .' '.$student1->firstname; @@ -221,4 +213,3 @@ public function test_two_stages_with_allocations(){ } } - diff --git a/tests/classes/grade_judge_test.php b/tests/classes/grade_judge_test.php index 150b2e85..118b3d42 100644 --- a/tests/classes/grade_judge_test.php +++ b/tests/classes/grade_judge_test.php @@ -1,5 +1,24 @@ . +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ use mod_coursework\grade_judge; @@ -9,15 +28,13 @@ */ class grade_judge_test extends advanced_testcase { - - use \mod_coursework\test_helpers\factory_mixin; + use mod_coursework\test_helpers\factory_mixin; public function setUp() { $this->setAdminUser(); $this->resetAfterTest(); } - public function test_get_feedbck_that_is_promoted_to_gradebook_returns_initial_feedback() { $coursework = $this->create_a_coursework(); $grade_judge = new grade_judge($coursework); @@ -31,7 +48,6 @@ public function test_get_feedbck_that_is_promoted_to_gradebook_returns_initial_f $this->assertEquals($feedback->id, $grade_judge->get_feedback_that_is_promoted_to_gradebook($submission)->id); } - public function test_sampling_disabled_one_marker() { $coursework = $this->create_a_coursework(); $grade_judge = new grade_judge($coursework); @@ -45,4 +61,4 @@ public function test_sampling_disabled_one_marker() { $this->assertEquals($feedback->id, $grade_judge->get_feedback_that_is_promoted_to_gradebook($submission)->id); } -} \ No newline at end of file +} diff --git a/tests/classes/models/coursework_test.php b/tests/classes/models/coursework_test.php index 5a0b1787..af7d2ab5 100644 --- a/tests/classes/models/coursework_test.php +++ b/tests/classes/models/coursework_test.php @@ -17,8 +17,7 @@ /** * Unit tests for the coursework class * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -30,7 +29,6 @@ global $CFG; - /** * Class that will make sure the allocation_manager works. * @@ -283,7 +281,7 @@ public function test_individual_feedback_deadline_has_passed_when_not_set() { $coursework->update_attribute('individualfeedback', 0); $this->assertTrue($coursework->individual_feedback_deadline_has_passed()); } - + public function test_finalise_all_leaves_other_submissions_alone() { $coursework = $this->get_coursework(); $submission = $this->create_a_submission_for_the_student(); diff --git a/tests/classes/models/deadline_extension_test.php b/tests/classes/models/deadline_extension_test.php index 0c00557d..cd57bc09 100644 --- a/tests/classes/models/deadline_extension_test.php +++ b/tests/classes/models/deadline_extension_test.php @@ -1,4 +1,25 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + use mod_coursework\models\deadline_extension; /** @@ -8,7 +29,7 @@ */ class mod_coursework_models_deadline_extension_test extends advanced_testcase { - use \mod_coursework\test_helpers\factory_mixin; + use mod_coursework\test_helpers\factory_mixin; public function setUp() { $this->resetAfterTest(); @@ -56,4 +77,4 @@ public function test_get_coursework() { $this->assertEquals($extension->get_coursework(), $coursework); } -} \ No newline at end of file +} diff --git a/tests/classes/models/group_test.php b/tests/classes/models/group_test.php index 9590cda1..77d9b5d3 100644 --- a/tests/classes/models/group_test.php +++ b/tests/classes/models/group_test.php @@ -1,4 +1,25 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + use mod_coursework\models\group; /** @@ -23,5 +44,4 @@ public function test_find() { $this->assertNotEmpty($group->name); $this->assertEquals($group->name, group::find($group->id)->name); } - -} \ No newline at end of file +} diff --git a/tests/classes/models/moderation_set_membership_test.php b/tests/classes/models/moderation_set_membership_test.php index a6c60d6a..6ff07bd3 100644 --- a/tests/classes/models/moderation_set_membership_test.php +++ b/tests/classes/models/moderation_set_membership_test.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Class coursework_user_test @@ -21,4 +41,4 @@ public function test_find() { $this->assertEquals(22, \mod_coursework\models\assessment_set_membership::find($record->id)->allocatableid); } -} \ No newline at end of file +} diff --git a/tests/classes/models/submission_test.php b/tests/classes/models/submission_test.php index 911dda02..dd373995 100644 --- a/tests/classes/models/submission_test.php +++ b/tests/classes/models/submission_test.php @@ -17,8 +17,7 @@ /** * Unit tests for the coursework class * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -30,7 +29,6 @@ global $CFG; - /** * Class that will make sure the allocation_manager works. * @group mod_coursework @@ -181,7 +179,6 @@ public function test_publish_updates_grade_timemodified() { $grade = $DB->get_record('grade_grades', array('itemid' => $grade_item->id, 'userid' => $student->id)); $grade_time_modified = $grade->timemodified; - $this->assertNotEquals($initial_time, $grade_time_modified); } diff --git a/tests/classes/models/user_test.php b/tests/classes/models/user_test.php index 364b043f..8f7d1811 100644 --- a/tests/classes/models/user_test.php +++ b/tests/classes/models/user_test.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * Class coursework_user_test @@ -82,5 +102,4 @@ public function test_has_all_initial_feedbacks_returns_false_when_all_are_presen // get_initial_feedbacks() - -} \ No newline at end of file +} diff --git a/tests/classes/router_test.php b/tests/classes/router_test.php index eadd67d7..cb02d402 100644 --- a/tests/classes/router_test.php +++ b/tests/classes/router_test.php @@ -1,4 +1,25 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + use mod_coursework\models\submission; use mod_coursework\router; @@ -59,7 +80,7 @@ protected function get_coursework() { * @return stdClass */ private function get_course() { - $this->course = $this->getDataGenerator()->create_course(); + $this->course = $this->getDataGenerator()->create_course(); return $this->course; } -} \ No newline at end of file +} diff --git a/tests/classes/rule_test.php b/tests/classes/rule_test.php index 1d11ce2d..68fcd3b6 100644 --- a/tests/classes/rule_test.php +++ b/tests/classes/rule_test.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ use mod_coursework\ability\rule; @@ -83,6 +103,4 @@ public function test_prevents_when_prevent_and_rule_returns_false() { $rule = new rule('set on fire', 'mod_coursework\models\coursework', $rule_function, false); $this->assertFalse($rule->prevents($coursework)); } - - -} \ No newline at end of file +} diff --git a/tests/classes/stages/assessor_test.php b/tests/classes/stages/assessor_test.php index 89849ac3..d7ac0385 100644 --- a/tests/classes/stages/assessor_test.php +++ b/tests/classes/stages/assessor_test.php @@ -1,11 +1,31 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * @group mod_coursework */ class assessor_test extends advanced_testcase { - use \mod_coursework\test_helpers\factory_mixin; + use mod_coursework\test_helpers\factory_mixin; public function setUp() { $this->resetAfterTest(); @@ -52,4 +72,4 @@ public function test_type() { $this->assertEquals('assessor', $stage->type()); } -} \ No newline at end of file +} diff --git a/tests/classes/stages/final_agreed_test.php b/tests/classes/stages/final_agreed_test.php index 6b253a05..b01e986a 100644 --- a/tests/classes/stages/final_agreed_test.php +++ b/tests/classes/stages/final_agreed_test.php @@ -1,11 +1,31 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ /** * @group mod_coursework */ class final_agreed_test extends advanced_testcase { - use \mod_coursework\test_helpers\factory_mixin; + use mod_coursework\test_helpers\factory_mixin; public function setUp() { $this->resetAfterTest(); @@ -60,4 +80,4 @@ public function test_prerequisite_stages_is_true_with_two_assessor_feedbacks() { $this->assertTrue($stage->prerequisite_stages_have_feedback($student)); } -} \ No newline at end of file +} diff --git a/tests/cron_tester.php b/tests/cron_tester.php index cffac8c6..2ea7a424 100644 --- a/tests/cron_tester.php +++ b/tests/cron_tester.php @@ -1,4 +1,24 @@ . + +/** + * @package mod_coursework + * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ define('CLI_SCRIPT', true); @@ -8,4 +28,4 @@ require_once($CFG->dirroot.'/mod/coursework/lib.php'); -coursework_cron(); \ No newline at end of file +coursework_cron(); diff --git a/tests/generator/lib.php b/tests/generator/lib.php index 7309be0b..fe449eae 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -17,8 +17,7 @@ /** * mod_coursework data generator * - * @package mod - * @subpackage coursework + * @package mod_coursework * @category phpunit * @copyright 2012 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -201,8 +200,6 @@ public function create_feedback($feedback) { return $feedback; } - - /** * Makes a submission for testing. * @@ -261,5 +258,4 @@ public function create_submission($submission, $coursework) { return $submission; } - } diff --git a/tests/generator_test.php b/tests/generator_test.php index a57dcc59..c98e4bb8 100644 --- a/tests/generator_test.php +++ b/tests/generator_test.php @@ -17,8 +17,7 @@ /** * PHPUnit data generator tests * - * @package mod - * @subpackage coursework + * @package mod_coursework * @category phpunit * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -187,5 +186,4 @@ public function test_create_submission() { $this->assertEquals($user->id, $submission->userid); } - } diff --git a/tests/renderer_test.php b/tests/renderer_test.php index eadb50d2..400fa4e9 100644 --- a/tests/renderer_test.php +++ b/tests/renderer_test.php @@ -34,4 +34,4 @@ public function test_equals() { $this->assertEquals(1, 1); } -} \ No newline at end of file +} diff --git a/version.php b/version.php index f96c0f7f..6c14b700 100644 --- a/version.php +++ b/version.php @@ -15,21 +15,19 @@ // along with Moodle. If not, see . /** - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); - $plugin->component = 'mod_coursework'; -$plugin->version = 2022061000; // If version == 0 then module will not be installed +$plugin->version = 2024080600; // If version == 0 then module will not be installed $plugin->requires = 2021051700; // Requires this Moodle version 3.11 -$plugin->cron = 300; // Period for cron to check this module (secs). +$plugin->cron = 300; // Period for cron to check this module (secs). -$plugin->release = "3.11"; -$plugin->maturity = MATURITY_STABLE; +$plugin->release = "3.11"; +$plugin->maturity = MATURITY_STABLE; diff --git a/view.php b/view.php index b4197421..51bb866e 100644 --- a/view.php +++ b/view.php @@ -17,8 +17,7 @@ /** * Prints a particular instance of coursework * - * @package mod - * @subpackage coursework + * @package mod_coursework * @copyright 2011 University of London Computer Centre {@link ulcc.ac.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -48,12 +47,11 @@ 'fullpath' => '/mod/coursework/module.js', 'requires' => array('base', 'node-base'), - 'strings' => array() + 'strings' => [] ); $PAGE->requires->yui_module('moodle-core-notification', 'notification_init'); - // Course_module ID, or coursework instance ID - it should be named as the first character of the module. $course_module_id = optional_param('id', 0, PARAM_INT); $coursework_id = optional_param('e', 0, PARAM_INT); @@ -73,8 +71,6 @@ $resettable = optional_param('treset', 0, PARAM_INT); $allresettable = optional_param('alltreset', 0, PARAM_INT); - - if (!isset($SESSION->displayallstudents[$course_module_id])) { $SESSION->displayallstudents[$course_module_id] = optional_param('displayallstudents', false, PARAM_BOOL); @@ -84,10 +80,9 @@ $SESSION->displayallstudents[$course_module_id] = $displayallstudents; } - // If a session variable holding page preference for the specific coursework is not set, set default value (0). if (isset($SESSION->perpage[$course_module_id]) && optional_param('per_page', 0, PARAM_INT) != $SESSION->perpage[$course_module_id] - && optional_param('per_page', 0, PARAM_INT) != 0){ // prevent blank pages if not in correct page + && optional_param('per_page', 0, PARAM_INT) != 0) { // prevent blank pages if not in correct page $page = 0; $SESSION->page[$course_module_id] = $page; } else if (!(isset($SESSION->page[$course_module_id]))) { @@ -107,7 +102,6 @@ $SESSION->perpage[$course_module_id] = $perpage; } - // If a session variable holding sortby preference for the specific coursework is not set, set default value ('lastname'). if (!(isset($SESSION->sortby[$course_module_id]))) { $SESSION->sortby[$course_module_id] = optional_param('sortby', 'lastname', PARAM_ALPHA); @@ -126,49 +120,47 @@ $SESSION->sorthow[$course_module_id] = $sorthow; } -// first name alpha +// First name alpha if (!(isset($SESSION->coursework_firstname_alpha[$course_module_id]))) { - $SESSION->coursework_firstname_alpha[$course_module_id] = optional_param('coursework_firstname_alpha','',PARAM_ALPHA); + $SESSION->coursework_firstname_alpha[$course_module_id] = optional_param('coursework_firstname_alpha', '', PARAM_ALPHA); $coursework_firstname_alpha = $SESSION->coursework_firstname_alpha[$course_module_id]; } else { - $coursework_firstname_alpha = optional_param('coursework_firstname_alpha', $SESSION->coursework_firstname_alpha[$course_module_id],PARAM_ALPHA); + $coursework_firstname_alpha = optional_param('coursework_firstname_alpha', $SESSION->coursework_firstname_alpha[$course_module_id], PARAM_ALPHA); $SESSION->coursework_firstname_alpha[$course_module_id] = $coursework_firstname_alpha; } -// last name alpha +// Last name alpha if (!(isset($SESSION->coursework_lastname_alpha[$course_module_id]))) { - $SESSION->coursework_lastname_alpha[$course_module_id] = optional_param('coursework_lastname_alpha','', PARAM_ALPHA); - $coursework_lastname_alpha= $SESSION->coursework_lastname_alpha[$course_module_id]; + $SESSION->coursework_lastname_alpha[$course_module_id] = optional_param('coursework_lastname_alpha', '', PARAM_ALPHA); + $coursework_lastname_alpha = $SESSION->coursework_lastname_alpha[$course_module_id]; } else { - $coursework_lastname_alpha = optional_param('coursework_lastname_alpha', $SESSION->coursework_lastname_alpha[$course_module_id],PARAM_ALPHA); + $coursework_lastname_alpha = optional_param('coursework_lastname_alpha', $SESSION->coursework_lastname_alpha[$course_module_id], PARAM_ALPHA); $SESSION->coursework_lastname_alpha[$course_module_id] = $coursework_lastname_alpha; } -// group name alpha +// Group name alpha if (!(isset($SESSION->coursework_groupname_alpha[$course_module_id]))) { - $SESSION->coursework_groupname_alpha[$course_module_id] = optional_param('coursework_groupname_alpha','', PARAM_ALPHA); + $SESSION->coursework_groupname_alpha[$course_module_id] = optional_param('coursework_groupname_alpha', '', PARAM_ALPHA); $coursework_groupname_alpha = $SESSION->coursework_groupname_alpha[$course_module_id]; } else { - $coursework_groupname_alpha= optional_param('coursework_groupname_alpha', $SESSION->coursework_groupname_alpha[$course_module_id],PARAM_ALPHA); + $coursework_groupname_alpha = optional_param('coursework_groupname_alpha', $SESSION->coursework_groupname_alpha[$course_module_id], PARAM_ALPHA); $SESSION->coursework_groupname_alpha[$course_module_id] = $coursework_groupname_alpha; } - - -//we will use the same defaults as page (above) defaulting to page setting if no specific viewallstudents_page has been set +// We will use the same defaults as page (above) defaulting to page setting if no specific viewallstudents_page has been set if (isset($SESSION->viewallstudents_perpage[$course_module_id]) && optional_param('viewallstudents_per_page', 0, PARAM_INT) != $SESSION->viewallstudents_perpage[$course_module_id] - && optional_param('viewallstudents_per_page', 0, PARAM_INT) != 0){ // prevent blank pages if not in correct page + && optional_param('viewallstudents_per_page', 0, PARAM_INT) != 0) { // prevent blank pages if not in correct page $viewallstudents_page = 0; $SESSION->viewallstudents_page[$course_module_id] = $viewallstudents_page; } else if (!(isset($SESSION->viewallstudents_page[$course_module_id]))) { - $SESSION->viewallstudents_page[$course_module_id] = optional_param('viewallstudents_page', 0, PARAM_INT); + $SESSION->viewallstudents_page[$course_module_id] = optional_param('viewallstudents_page', 0, PARAM_INT); $viewallstudents_page = $SESSION->viewallstudents_page[$course_module_id]; } else { $viewallstudents_page = optional_param('viewallstudents_page', $SESSION->viewallstudents_page[$course_module_id], PARAM_INT); $SESSION->viewallstudents_page[$course_module_id] = $viewallstudents_page; } -//we will use the same defaults as perpage (above) defaulting to perpage setting if no specific viewallstudents_perpage has been set +// We will use the same defaults as perpage (above) defaulting to perpage setting if no specific viewallstudents_perpage has been set if (!(isset($SESSION->viewallstudents_perpage[$course_module_id]))) { $SESSION->viewallstudents_perpage[$course_module_id] = optional_param('viewallstudents_per_page', $perpage, PARAM_INT); $viewallstudents_perpage = $SESSION->viewallstudents_perpage[$course_module_id]; @@ -177,7 +169,7 @@ $SESSION->viewallstudents_perpage[$course_module_id] = $viewallstudents_perpage; } -//we will use the same defaults as sortby (above) defaulting to sortby setting if no specific viewallstudents_sortby has been set +// We will use the same defaults as sortby (above) defaulting to sortby setting if no specific viewallstudents_sortby has been set if (!(isset($SESSION->viewallstudents_sortby[$course_module_id]))) { $SESSION->viewallstudents_sortby[$course_module_id] = optional_param('viewallstudents_sortby', $sortby, PARAM_ALPHA); $viewallstudents_sortby = $SESSION->viewallstudents_sortby[$course_module_id]; @@ -186,7 +178,7 @@ $SESSION->viewallstudents_sortby[$course_module_id] = $viewallstudents_sortby; } -//we will use the same defaults as sorthow (above) defaulting to sorthow setting if no specific viewallstudents_sorthow has been set +// We will use the same defaults as sorthow (above) defaulting to sorthow setting if no specific viewallstudents_sorthow has been set if (!(isset($SESSION->viewallstudents_sorthow[$course_module_id]))) { $SESSION->viewallstudents_sorthow[$course_module_id] = optional_param('viewallstudents_sorthow', $sorthow, PARAM_ALPHA); $viewallstudents_sorthow = $SESSION->viewallstudents_sorthow[$course_module_id]; @@ -195,35 +187,33 @@ $SESSION->viewallstudents_sorthow[$course_module_id] = $viewallstudents_sorthow; } -// first name alpha +// First name alpha if (!(isset($SESSION->viewallstudents_firstname_alpha[$course_module_id]))) { - $SESSION->viewallstudents_firstname_alpha[$course_module_id] = optional_param('viewallstudents_firstname_alpha','',PARAM_ALPHA); + $SESSION->viewallstudents_firstname_alpha[$course_module_id] = optional_param('viewallstudents_firstname_alpha', '', PARAM_ALPHA); $viewallstudents_firstname_alpha = $SESSION->coursework_firstname_alpha[$course_module_id]; } else { - $viewallstudents_firstname_alpha = optional_param('viewallstudents_firstname_alpha', $SESSION->viewallstudents_firstname_alpha[$course_module_id],PARAM_ALPHA); + $viewallstudents_firstname_alpha = optional_param('viewallstudents_firstname_alpha', $SESSION->viewallstudents_firstname_alpha[$course_module_id], PARAM_ALPHA); $SESSION->viewallstudents_firstname_alpha[$course_module_id] = $viewallstudents_firstname_alpha; } -// last name alpha +// Last name alpha if (!(isset($SESSION->viewallstudents_lastname_alpha[$course_module_id]))) { - $SESSION->viewallstudents_lastname_alpha[$course_module_id] = optional_param('viewallstudents_lastname_alpha','', PARAM_ALPHA); + $SESSION->viewallstudents_lastname_alpha[$course_module_id] = optional_param('viewallstudents_lastname_alpha', '', PARAM_ALPHA); $viewallstudents_lastname_alpha = $SESSION->viewallstudents_lastname_alpha[$course_module_id]; } else { - $viewallstudents_lastname_alpha = optional_param('viewallstudents_lastname_alpha', $SESSION->viewallstudents_lastname_alpha[$course_module_id],PARAM_ALPHA); + $viewallstudents_lastname_alpha = optional_param('viewallstudents_lastname_alpha', $SESSION->viewallstudents_lastname_alpha[$course_module_id], PARAM_ALPHA); $SESSION->viewallstudents_lastname_alpha[$course_module_id] = $viewallstudents_lastname_alpha; } -// group name alpha +// Group name alpha if (!(isset($SESSION->viewallstudents_groupname_alpha[$course_module_id]))) { - $SESSION->viewallstudents_groupname_alpha[$course_module_id] = optional_param('viewallstudents_groupname_alpha','', PARAM_ALPHA); + $SESSION->viewallstudents_groupname_alpha[$course_module_id] = optional_param('viewallstudents_groupname_alpha', '', PARAM_ALPHA); $viewallstudents_groupname_alpha = $SESSION->viewallstudents_groupname_alpha[$course_module_id]; } else { - $viewallstudents_groupname_alpha= optional_param('viewallstudents_groupname_alpha', $SESSION->viewallstudents_groupname_alpha[$course_module_id],PARAM_ALPHA); + $viewallstudents_groupname_alpha = optional_param('viewallstudents_groupname_alpha', $SESSION->viewallstudents_groupname_alpha[$course_module_id], PARAM_ALPHA); $SESSION->viewallstudents_groupname_alpha[$course_module_id] = $viewallstudents_groupname_alpha; } - - if (!($sorthow === 'ASC' || $sorthow === 'DESC')) { $sorthow = 'ASC'; } @@ -263,34 +253,33 @@ $coursework = mod_coursework\models\coursework::find($coursework_record); -// check if group is in session and use it no group available in url -if (groups_get_activity_groupmode($coursework->get_course_module()) != 0 && $group == -1){ - // check if a group is in SESSION +// Check if group is in session and use it no group available in url +if (groups_get_activity_groupmode($coursework->get_course_module()) != 0 && $group == -1) { + // Check if a group is in SESSION $group = groups_get_activity_group($coursework->get_course_module()); } -// commented out the redirection for Release1 #108535552, this will be revisited for Release2 -/*if (has_capability('mod/coursework:allocate', $coursework->get_context())) { +// Commented out the redirection for Release1 #108535552, this will be revisited for Release2 +/*if (has_capability('mod/coursework:allocate', $coursework->get_context())) { $warnings = new \mod_coursework\warnings($coursework); $percentage_allocation_not_complete = $warnings->percentage_allocations_not_complete(); $manual_allocation_not_complete = ''; - if ($coursework->allocation_enabled()){ + if ($coursework->allocation_enabled()) { $manual_allocation_not_complete = $warnings->manual_allocation_not_completed(); } + if (!empty($percentage_allocation_not_complete) || !empty($manual_allocation_not_complete)) { - if (!empty($percentage_allocation_not_complete) || !empty($manual_allocation_not_complete)) { + $redirectdetail = new \stdClass(); + $redirectdetail->percentage = $percentage_allocation_not_complete; + $redirectdetail->manual = $manual_allocation_not_complete; - $redirectdetail = new \stdClass(); - $redirectdetail->percentage = $percentage_allocation_not_complete; - $redirectdetail->manual = $manual_allocation_not_complete; - - redirect($CFG->wwwroot.'/mod/coursework/actions/allocate.php?id='.$course_module_id,get_string('configuration_needed','coursework',$redirectdetail)); + redirect($CFG->wwwroot.'/mod/coursework/actions/allocate.php?id='.$course_module_id, get_string('configuration_needed', 'coursework', $redirectdetail)); } }*/ -// change default sortby to Date (timesubmitted) if CW is set to blind marking and a user doesn't have capability to view anonymous +// Change default sortby to Date (timesubmitted) if CW is set to blind marking and a user doesn't have capability to view anonymous $viewanonymous = has_capability('mod/coursework:viewanonymous', $coursework->get_context()); if (($coursework->blindmarking && !$viewanonymous )) { $sortby = optional_param('sortby', 'timesubmitted', PARAM_ALPHA); @@ -310,13 +299,12 @@ send_temp_file($zip_file, $filename); // Send file and delete after sending. } +if ($export_grades) { -if ($export_grades){ - - // headers and data for csv - $csv_cells = array('name','username','idnumber','email'); + // Headers and data for csv + $csv_cells = array('name', 'username', 'idnumber', 'email'); - if ($coursework->personal_deadlines_enabled()){ + if ($coursework->personal_deadlines_enabled()) { $csv_cells[] = 'personaldeadline'; } @@ -324,36 +312,34 @@ $csv_cells[] = 'submissiontime'; $csv_cells[] = 'submissionfileid'; - if ($coursework->extensions_enabled() && ($coursework->has_deadline()) || $coursework->personal_deadlines_enabled()){ + if ($coursework->extensions_enabled() && ($coursework->has_deadline()) || $coursework->personal_deadlines_enabled()) { $csv_cells[] = 'extensiondeadline'; $csv_cells[] = 'extensionreason'; $csv_cells[] = 'extensionextrainfo'; } - if ($coursework->plagiarism_flagging_enbled()){ + if ($coursework->plagiarism_flagging_enbled()) { $csv_cells[] = 'plagiarismflagstatus'; $csv_cells[] = 'plagiarismflagcomment'; } $csv_cells[] = 'stages'; - if ($coursework->moderation_agreement_enabled()){ + if ($coursework->moderation_agreement_enabled()) { $csv_cells[] = 'moderationagreement'; } $csv_cells[] = 'finalgrade'; - $timestamp = date('d_m_y @ H-i'); $filename = get_string('finalgradesfor', 'coursework'). $coursework->name .' '.$timestamp; $csv = new \mod_coursework\export\csv($coursework, $csv_cells, $filename); $csv->export(); - } -if ($download_grading_sheet){ +if ($download_grading_sheet) { - $csv_cells = \mod_coursework\export\grading_sheet::cells_array($coursework); + $csv_cells = \mod_coursework\export\grading_sheet::cells_array($coursework); $timestamp = date('d_m_y @ H-i'); $filename = get_string('gradingsheetfor', 'coursework'). $coursework->name .' '.$timestamp; @@ -408,8 +394,8 @@ // Print the page header. -// sort group by groupname (default) -if ($coursework->is_configured_to_have_group_submissions()){ +// Sort group by groupname (default) +if ($coursework->is_configured_to_have_group_submissions()) { $sortby = optional_param('sortby', 'groupname', PARAM_ALPHA); $viewallstudents_sortby = optional_param('viewallstudents_sortby', 'groupname', PARAM_ALPHA); @@ -420,19 +406,16 @@ 'per_page' => $perpage, 'group' => $group); -if (!empty($SESSION->displayallstudents[$course_module_id])) { - $params['viewallstudents_sorthow'] = $viewallstudents_sorthow; - $params['viewallstudents_sortby'] = $viewallstudents_sortby; - $params['viewallstudents_per_page'] = $viewallstudents_perpage; +if (!empty($SESSION->displayallstudents[$course_module_id])) { + $params['viewallstudents_sorthow'] = $viewallstudents_sorthow; + $params['viewallstudents_sortby'] = $viewallstudents_sortby; + $params['viewallstudents_per_page'] = $viewallstudents_perpage; } - $PAGE->set_url('/mod/coursework/view.php', $params); $PAGE->set_title($coursework->name); $PAGE->set_heading($course->shortname); -//$PAGE->set_button($OUTPUT->update_module_button($course_module->id, 'coursework')); // deprecated from 3.2 (MDL-53765 core) - // Auto publish after the deadline if ($coursework->has_individual_autorelease_feedback_enabled() && $coursework->individual_feedback_deadline_has_passed() && @@ -442,10 +425,8 @@ $coursework->publish_grades(); } - - -//Create automatic feedback -if ($coursework->automaticagreement_enabled()) { +// Create automatic feedback +if ($coursework->automaticagreement_enabled()) { $coursework->create_automatic_feedback(); } @@ -530,20 +511,20 @@ } } else { - if($resettable){ + if ($resettable) { $coursework_firstname_alpha = $SESSION->coursework_firstname_alpha[$course_module_id] = ""; $coursework_lastname_alpha = $SESSION->coursework_lastname_alpha[$course_module_id] = ""; $coursework_groupname_alpha = $SESSION->coursework_groupname_alpha[$course_module_id] = ""; } - if($allresettable){ + if ($allresettable) { $viewallstudents_firstname_alpha = $SESSION->viewallstudents_firstname_alpha[$course_module_id] = ""; $viewallstudents_lastname_alpha = $SESSION->viewallstudents_lastname_alpha[$course_module_id] = ""; $viewallstudents_groupname_alpha = $SESSION->viewallstudents_groupname_alpha[$course_module_id] = ""; } - $html .= $page_renderer->teacher_grading_page($coursework, $page, $perpage, $sortby, $sorthow, $group,$coursework_firstname_alpha,$coursework_lastname_alpha,$coursework_groupname_alpha, $resettable); - $html .= $page_renderer->non_teacher_allocated_grading_page($coursework,$viewallstudents_page,$viewallstudents_perpage,$viewallstudents_sortby,$viewallstudents_sorthow,$group,$displayallstudents,$viewallstudents_firstname_alpha,$viewallstudents_lastname_alpha,$viewallstudents_groupname_alpha); + $html .= $page_renderer->teacher_grading_page($coursework, $page, $perpage, $sortby, $sorthow, $group, $coursework_firstname_alpha, $coursework_lastname_alpha, $coursework_groupname_alpha, $resettable); + $html .= $page_renderer->non_teacher_allocated_grading_page($coursework, $viewallstudents_page, $viewallstudents_perpage, $viewallstudents_sortby, $viewallstudents_sorthow, $group, $displayallstudents, $viewallstudents_firstname_alpha, $viewallstudents_lastname_alpha, $viewallstudents_groupname_alpha); $html .= $page_renderer->datatables_render($coursework); $html .= $page_renderer->render_modal(); } @@ -560,8 +541,8 @@ '; -//$PAGE->requires->js('/mod/coursework/datatables/js/jquery-3.3.1.min.js'); -//$PAGE->requires->js('/mod/coursework/datatables/js/jquery.datatables.js'); +// $PAGE->requires->js('/mod/coursework/datatables/js/jquery-3.3.1.min.js'); +// $PAGE->requires->js('/mod/coursework/datatables/js/jquery.datatables.js'); // Finish the page. echo $OUTPUT->footer();