diff --git a/actions/upload_grading_sheet.php b/actions/upload_grading_sheet.php index 9a43230f..1dbae1e1 100644 --- a/actions/upload_grading_sheet.php +++ b/actions/upload_grading_sheet.php @@ -69,7 +69,7 @@ $csvimport = new \mod_coursework\export\import($coursework, false, false); - // $csv_cells = $csvimport->csv_columns(); //all columns from spreadsheet + // $csv_cells = $csvimport->csv_columns(); //all columns from spreadsheet $procsessingresults = $csvimport->validate_csv($content, $data->encoding, $data->delimiter_name, $csv_cells); diff --git a/backup/moodle2/backup_coursework_activity_task.class.php b/backup/moodle2/backup_coursework_activity_task.class.php index 78a19a15..c3654be1 100644 --- a/backup/moodle2/backup_coursework_activity_task.class.php +++ b/backup/moodle2/backup_coursework_activity_task.class.php @@ -24,25 +24,25 @@ class backup_coursework_activity_task extends backup_activity_task { - static public function encode_content_links($content) { - global $CFG; + static public function encode_content_links($content) { + global $CFG; - $base = preg_quote($CFG->wwwroot, "/"); + $base = preg_quote($CFG->wwwroot, "/"); - // These have to be picked up by the restore code COURSEWORK... are arbitrary - $search = "/(".$base."\/mod\/coursework\/index.php\?id\=)([0-9]+)/"; - $content = preg_replace($search, '$@COURSEWORKINDEX*$2@$', $content); + // These have to be picked up by the restore code COURSEWORK... are arbitrary + $search = "/(".$base."\/mod\/coursework\/index.php\?id\=)([0-9]+)/"; + $content = preg_replace($search, '$@COURSEWORKINDEX*$2@$', $content); - $search = "/(".$base."\/mod\/coursework\/view.php\?id\=)([0-9]+)/"; - $content = preg_replace($search, '$@COURSEWORKBYID*$2@$', $content); + $search = "/(".$base."\/mod\/coursework\/view.php\?id\=)([0-9]+)/"; + $content = preg_replace($search, '$@COURSEWORKBYID*$2@$', $content); - return $content; - } + return $content; + } - protected function define_my_settings() { - } + protected function define_my_settings() { + } - protected function define_my_steps() { - $this->add_step(new backup_coursework_activity_structure_step('coursework_structure', 'coursework.xml')); - } + protected function define_my_steps() { + $this->add_step(new backup_coursework_activity_structure_step('coursework_structure', 'coursework.xml')); + } } diff --git a/classes/ability.php b/classes/ability.php index c24ad60e..681e8a98 100644 --- a/classes/ability.php +++ b/classes/ability.php @@ -152,7 +152,7 @@ function (coursework $coursework) { // New feedback $this->prevent_new_feedback_with_no_submission(); - $this->prevent_new_feedback_when_submission_not_finalised(); + $this->prevent_new_feedback_when_submission_not_finalised(); $this->prevent_new_feedback_when_prerequisite_stages_have_no_feedback(); $this->prevent_new_feedback_with_empty_stage(); $this->prevent_new_feedback_when_allocatable_already_has_feedback_for_this_stage(); @@ -163,7 +163,7 @@ function (coursework $coursework) { $this->prevent_new_feedback_when_not_assessor_for_stage(); $this->prevent_new_feedback_from_non_allocated_assessors(); $this->allow_new_feedback_by_allocated_assessor(); - $this->allow_new_feedback_from_any_assessor_when_allocation_is_disabled_for_stage_or_instance(); + $this->allow_new_feedback_from_any_assessor_when_allocation_is_disabled_for_stage_or_instance(); $this->allow_new_feedback_if_agreed_feedback_and_user_can_add_agreed_feedback(); // Create feedback @@ -230,7 +230,7 @@ function (coursework $coursework) { // Plagiarism flagging rules for Plagiarism Alert // New - // $this->prevent_new_plagiarism_flag_if_already_exists(); + // $this->prevent_new_plagiarism_flag_if_already_exists(); $this->allow_new_plagiarism_flag_with_capability(); // Edit @@ -425,7 +425,7 @@ function (submission $submission) { } protected function allow_show_submission_to_graders_after_feedback_release() { -// Show to graders after release + // Show to graders after release $this->allow('show', 'mod_coursework\models\submission', function (submission $submission) { @@ -485,8 +485,8 @@ function (submission $submission) { // take into account courseworks with personal deadlines if ($submission->get_coursework()->personal_deadlines_enabled()) { $deadline_passed = (bool)$submission->submission_personal_deadline() < time(); - } else { - $deadline_passed = $submission->get_coursework()->deadline_has_passed(); + } else { + $deadline_passed = $submission->get_coursework()->deadline_has_passed(); } $ok_to_submit_late = $submission->get_coursework()->allow_late_submissions(); $coursework = $submission->get_coursework(); @@ -1202,7 +1202,7 @@ private function allow_show_grading_table_row_if_user_can_grant_extension_and_no 'mod_coursework\grading_table_row_base', function (grading_table_row_base $row) { - return (!$row->get_coursework()->allocation_enabled() && has_capability('mod/coursework:grantextensions', + return (!$row->get_coursework()->allocation_enabled() && has_capability('mod/coursework:grantextensions', $row->get_coursework() ->get_context())); diff --git a/classes/allocation/manager.php b/classes/allocation/manager.php index e25b57af..b4dd472f 100644 --- a/classes/allocation/manager.php +++ b/classes/allocation/manager.php @@ -344,18 +344,18 @@ public function auto_generate_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 - $DB->insert_record("coursework_sample_set_mbrs", $sample); - - } + 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); + + } } } } diff --git a/classes/allocation/table/cell/builder.php b/classes/allocation/table/cell/builder.php index 859cb3e6..6ffeb3a3 100644 --- a/classes/allocation/table/cell/builder.php +++ b/classes/allocation/table/cell/builder.php @@ -191,9 +191,9 @@ private function prepare_allocation_table_cell() { } $contents .= '
'; - if ($this->coursework->allocation_enabled()) { - $assessor_dropdown = $this->get_potential_marker_dropdown(); - } + if ($this->coursework->allocation_enabled()) { + $assessor_dropdown = $this->get_potential_marker_dropdown(); + } $assessor_name = ''; if ($this->has_feedback()) { $class .= ' has-assessor-feedback '; @@ -210,7 +210,7 @@ private function prepare_allocation_table_cell() { } if ($assessor_name) { - if ($this->get_stage()->uses_sampling() && !$this->get_feedback() && !$this->has_automatic_sampling()) { + if ($this->get_stage()->uses_sampling() && !$this->get_feedback() && !$this->has_automatic_sampling()) { $contents .= '
'; } $contents .= "{$assessor_name}"; @@ -437,15 +437,15 @@ private function has_final_feedback() { [$this->allocatable->id(), $this->allocatable->type()] ); if ($submission) { - $feedbacks = isset(feedback::$pool[$this->coursework->id]['submissionid'][$submission->id]) ? + $feedbacks = isset(feedback::$pool[$this->coursework->id]['submissionid'][$submission->id]) ? feedback::$pool[$this->coursework->id]['submissionid'][$submission->id] : []; - foreach ($feedbacks as $feedback) { - if ($feedback->stage_identifier == 'final_agreed_1') { - return true; + foreach ($feedbacks as $feedback) { + if ($feedback->stage_identifier == 'final_agreed_1') { + return true; + } } } - } return false; } diff --git a/classes/allocation/table/processor.php b/classes/allocation/table/processor.php index 7b6c5f85..fd329886 100644 --- a/classes/allocation/table/processor.php +++ b/classes/allocation/table/processor.php @@ -87,19 +87,19 @@ 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, -// ) -// ) -// ); + // $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) { @@ -117,7 +117,7 @@ private function clean_data($raw_data) { $clean_data[$allocatable_id][$stage->identifier()] = $stage_data; } } - /* if (array_key_exists('moderator', $datarrays)) { + /* if (array_key_exists('moderator', $datarrays)) { $moderator_data = $datarrays['moderator']; $clean_data[$allocatable_id]['moderator'] = $moderator_data; }*/ diff --git a/classes/assessor_feedback_row.php b/classes/assessor_feedback_row.php index d24932d6..be98e9b5 100644 --- a/classes/assessor_feedback_row.php +++ b/classes/assessor_feedback_row.php @@ -128,7 +128,7 @@ public function get_graded_by() { * @return string */ public function get_graders_name() { - return $this->get_graded_by()->profile_link(); + return $this->get_graded_by()->profile_link(); } /** diff --git a/classes/controllers/feedback_controller.php b/classes/controllers/feedback_controller.php index 86410e7f..92c95d2b 100644 --- a/classes/controllers/feedback_controller.php +++ b/classes/controllers/feedback_controller.php @@ -591,7 +591,7 @@ private function next_available_stage($feedback) { * @param $submission */ protected function try_auto_feedback_creation($submission) { -// automatic agreement if necessary + // automatic agreement if necessary $auto_feedback_classname = '\mod_coursework\auto_grader\\' . $this->coursework->automaticagreementstrategy; /** * @var auto_grader $auto_grader diff --git a/classes/controllers/personal_deadlines_controller.php b/classes/controllers/personal_deadlines_controller.php index 6774813b..ab60f0e3 100644 --- a/classes/controllers/personal_deadlines_controller.php +++ b/classes/controllers/personal_deadlines_controller.php @@ -87,33 +87,33 @@ protected function new_personal_deadline() { $allocatables = unserialize($data->allocatableid); - foreach ($allocatables as $allocatableid) { - $data->allocatableid = $allocatableid; - $data->id = ''; - //$data->id = ''; - $findparams = array( - 'allocatableid' => $allocatableid, - 'allocatabletype' => $data->allocatabletype, - 'courseworkid' => $data->courseworkid, - ); - $this->personal_deadline = personal_deadline::find_or_build($findparams); - - if (empty($this->personal_deadline->personal_deadline)) { // personal deadline doesnt exist - // add new - $data->createdbyid = $USER->id; - $this->personal_deadline = personal_deadline::build($data); - $this->personal_deadline->save(); - - } else { - // update - $data->id = $this->personal_deadline->id; - $data->lastmodifiedbyid = $USER->id; - $data->timemodified = time(); - $this->personal_deadline->update_attributes($data); - } - + foreach ($allocatables as $allocatableid) { + $data->allocatableid = $allocatableid; + $data->id = ''; + //$data->id = ''; + $findparams = array( + 'allocatableid' => $allocatableid, + 'allocatabletype' => $data->allocatabletype, + 'courseworkid' => $data->courseworkid, + ); + $this->personal_deadline = personal_deadline::find_or_build($findparams); + + if (empty($this->personal_deadline->personal_deadline)) { // personal deadline doesnt exist + // add new + $data->createdbyid = $USER->id; + $this->personal_deadline = personal_deadline::build($data); + $this->personal_deadline->save(); + + } else { + // update + $data->id = $this->personal_deadline->id; + $data->lastmodifiedbyid = $USER->id; + $data->timemodified = time(); + $this->personal_deadline->update_attributes($data); } + } + } redirect($coursework_page_url); } @@ -143,10 +143,10 @@ protected function set_default_current_deadline() { // If the allocatableid is an array then the current page will probably be setting multiple the personal deadlines // of multiple allocatable ids in which case set the personal deadline to the coursework default - if (is_array($this->params['allocatableid']) || !$this->get_personal_deadline()) { // if no personal deadline then use coursework deadline - $this->personal_deadline->personal_deadline = $this->coursework->deadline; + if (is_array($this->params['allocatableid']) || !$this->get_personal_deadline()) { // if no personal deadline then use coursework deadline + $this->personal_deadline->personal_deadline = $this->coursework->deadline; - } + } return $params; } diff --git a/classes/controllers/submissions_controller.php b/classes/controllers/submissions_controller.php index b2320ea2..c26a4011 100644 --- a/classes/controllers/submissions_controller.php +++ b/classes/controllers/submissions_controller.php @@ -116,12 +116,12 @@ protected function create_submission() { $submission->authorid = $submission->get_author_id(); // Create new function to get the author id depending on whether the current user is submitting on behalf $submission->timesubmitted = time(); - // Automatically finalise any submissions that's past the deadline/personal deadline and doesn't have valid extension + // Automatically finalise any submissions that's past the deadline/personal deadline and doesn't have valid extension if ($this->coursework->personal_deadlines_enabled()) { // Check is submission has a valid personal deadline or a valid extension - if (!$this->has_valid_personal_deadline($submission) && !$this->has_valid_extension($submission)) { - $submission->finalised = 1; - } + if (!$this->has_valid_personal_deadline($submission) && !$this->has_valid_extension($submission)) { + $submission->finalised = 1; + } } else if ($this->coursework->deadline_has_passed() && !$this->has_valid_extension($submission)) { $submission->finalised = 1; } @@ -167,7 +167,7 @@ protected function create_submission() { } } - if ($submission->finalised) { + if ($submission->finalised) { if (!$submission->get_coursework()->has_deadline()) { $userids = explode(',', $submission->get_coursework()->get_submission_notification_users()); @@ -221,11 +221,11 @@ protected function edit_submission() { $submit_form->set_data($submission); - if ($validation != true) { + if ($validation != true) { $this->get_page_renderer()->edit_submission_page($submit_form, $submission); return true; - } - } + } + } /** * @@ -399,11 +399,11 @@ 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()) { - $deadline_has_passed = !$this->has_valid_personal_deadline($submission); - } else { - $deadline_has_passed = $this->coursework->deadline_has_passed(); - } + if ($this->coursework->personal_deadlines_enabled()) { + $deadline_has_passed = !$this->has_valid_personal_deadline($submission); + } else { + $deadline_has_passed = $this->coursework->deadline_has_passed(); + } if ($could_have_submitted && $deadline_has_passed && !$this->has_valid_extension($submission) && !$this->coursework->allow_late_submissions()) { throw new late_submission($this->coursework); diff --git a/classes/cron.php b/classes/cron.php index 894cfa51..b04ee7df 100644 --- a/classes/cron.php +++ b/classes/cron.php @@ -51,7 +51,7 @@ public static function run() { echo "Starting coursework cron functions...\n"; self::finalise_any_submissions_where_the_deadline_has_passed(); self::send_reminders_to_students(); - // self::send_first_reminders_to_admins(); #90211934 + // self::send_first_reminders_to_admins(); #90211934 self::autorelease_feedbacks_where_the_release_date_has_passed(); return true; } @@ -109,7 +109,7 @@ private static function send_reminders_to_students() { 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) && + if ($coursework->due_to_send_first_reminders($individual_extension->extended_deadline) && $student->has_not_been_sent_reminder($coursework, 1, $individual_extension->extended_deadline)) { $student->deadline = $individual_extension->extended_deadline; $student->extension = $individual_extension->extended_deadline; @@ -117,15 +117,15 @@ private static function send_reminders_to_students() { $student->nextremindernumber = 1; $userswhoneedreminding[$student->id().'_'.$coursework->id] = $student; - // check if 2nd reminder is due to be sent but has not been sent yet - } else if ($coursework->due_to_send_second_reminders($individual_extension->extended_deadline) && + // check if 2nd reminder is due to be sent but has not been sent yet + } else if ($coursework->due_to_send_second_reminders($individual_extension->extended_deadline) && $student->has_not_been_sent_reminder($coursework, 2, $individual_extension->extended_deadline)) { $student->deadline = $individual_extension->extended_deadline; $student->extension = $individual_extension->extended_deadline; $student->coursework_id = $coursework->id; $student->nextremindernumber = 2; $userswhoneedreminding[$student->id().'_'.$coursework->id] = $student; - } + } } else if ($deadline > time()) { // coursework or personal deadline hasn't passed // check if 1st reminder is due to be sent but has not been sent yet @@ -386,7 +386,7 @@ private static function autorelease_feedbacks_where_the_release_date_has_passed( global $DB; echo 'Auto releasing feedbacks for courseworks where the release date have passed...'; - $sql = "SELECT * + $sql = "SELECT * FROM {coursework} c JOIN {coursework_submissions} cs ON c.id = cs.courseworkid diff --git a/classes/export/csv.php b/classes/export/csv.php index c0db544a..704f9498 100644 --- a/classes/export/csv.php +++ b/classes/export/csv.php @@ -128,11 +128,11 @@ public function add_cells_to_array($submission, $student, $csv_cells) { } } 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 { - $row[] = $cell; - } + if (is_array($cell)) { + $row = array_merge($row, $cell); + } else { + $row[] = $cell; + } } else { $stages = $cell->get_cell($submission, $student, false); @@ -147,50 +147,50 @@ public function add_cells_to_array($submission, $student, $csv_cells) { * create headers for CSV * @param $csv_headers */ - public function add_headers($csv_headers) { - $headers = []; - foreach ($csv_headers as $header) { - if (substr($header, 0, 8) == 'assessor') { - $stage = (substr($header, -1)); - $header = substr($header, 0, -1); + public function add_headers($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 { + $headers[$header.$stage] = $head; } - $class = "mod_coursework\\export\\csv\\cells\\".$header."_cell"; - $cell = new $class($this->coursework); - if (substr($header, 0, 8) == 'assessor') { - $head = $cell->get_header($stage); - if (is_array($head)) { - $headers = array_merge($headers, $head); - } else { - $headers[$header.$stage] = $head; - } - - } else if ($header != 'stages' && $header != 'moderationagreement' && $header != 'otherassessors' ) { - $head = $cell->get_header(false); - if (is_array($head)) { - $headers = array_merge($headers, $head); - } else { - $headers[$header] = $head; - } + + } else if ($header != 'stages' && $header != 'moderationagreement' && $header != 'otherassessors' ) { + $head = $cell->get_header(false); + if (is_array($head)) { + $headers = array_merge($headers, $head); } else { - $array_headers = $cell->get_header(false); - $headers = array_merge($headers, $array_headers); + $headers[$header] = $head; } + } else { + $array_headers = $cell->get_header(false); + $headers = array_merge($headers, $array_headers); } + } - $this->csvexport->add_data($headers); + $this->csvexport->add_data($headers); - } + } /** * Add filename to the CSV * @param $filename * @return string */ - public function add_filename($filename) { + public function add_filename($filename) { - $filename = clean_filename($filename); - return $this->csvexport->filename = $filename.'.csv'; - } + $filename = clean_filename($filename); + return $this->csvexport->filename = $filename.'.csv'; + } /** * Function to sort array in order of submission's lastname @@ -264,9 +264,9 @@ public function other_assessors_cells() { $increment = 2; } - for ($i = 1; $i < $this->coursework->get_max_markers(); $i++) { - $cells = $cells + $increment; // one for grade, one for feedback - } + for ($i = 1; $i < $this->coursework->get_max_markers(); $i++) { + $cells = $cells + $increment; // one for grade, one for feedback + } return $cells; diff --git a/classes/export/csv/cells/assessorfeedback_cell.php b/classes/export/csv/cells/assessorfeedback_cell.php index e3062990..d1be9117 100644 --- a/classes/export/csv/cells/assessorfeedback_cell.php +++ b/classes/export/csv/cells/assessorfeedback_cell.php @@ -125,7 +125,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } 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', $modulecontext) ) return get_string('nopermissiontogradesubmission', 'coursework'); diff --git a/classes/export/csv/cells/assessorgrade_cell.php b/classes/export/csv/cells/assessorgrade_cell.php index 081148f0..ef991bbb 100644 --- a/classes/export/csv/cells/assessorgrade_cell.php +++ b/classes/export/csv/cells/assessorgrade_cell.php @@ -205,7 +205,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } 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'); @@ -246,9 +246,9 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } else if (has_any_capability($agreedgradecap, $PAGE->context)) { - // If you have the add agreed or edit agreed grades capabilities then you may have the grades on your export sheet - // We will return true as we will ignore them - return true; + // If you have the add agreed or edit agreed grades capabilities then you may have the grades on your export sheet + // We will return true as we will ignore them + return true; } else { return get_string('nopermissiontoimportgrade', 'coursework'); diff --git a/classes/export/csv/cells/cell_base.php b/classes/export/csv/cells/cell_base.php index 563f8484..ff72d309 100644 --- a/classes/export/csv/cells/cell_base.php +++ b/classes/export/csv/cells/cell_base.php @@ -230,7 +230,7 @@ public function get_stage_identifier_for_assessor($submission, $student) { } else if ($this->coursework->get_max_markers() > 1) { // get existing feedback - $sql = "SELECT * FROM {coursework_feedbacks} + $sql = "SELECT * FROM {coursework_feedbacks} WHERE submissionid= $submission->id AND assessorid = $USER->id AND stage_identifier <> 'final_agreed_1'"; diff --git a/classes/export/csv/cells/moderationagreement_cell.php b/classes/export/csv/cells/moderationagreement_cell.php index a989a1e2..12795ed6 100644 --- a/classes/export/csv/cells/moderationagreement_cell.php +++ b/classes/export/csv/cells/moderationagreement_cell.php @@ -62,12 +62,12 @@ public function get_cell($submission, $student, $stage_identifier) { $data[] = $this->get_assessor_name($moderation_agreement->moderatorid); $data[] = $this->get_assessor_username($moderation_agreement->moderatorid); $data[] = userdate($moderation_agreement->timemodified, $this->dateformat); - } else { - $data[] = ''; - $data[] = ''; - $data[] = ''; - $data[] = ''; - } + } else { + $data[] = ''; + $data[] = ''; + $data[] = ''; + $data[] = ''; + } return $data; } diff --git a/classes/export/csv/cells/otherassessors_cell.php b/classes/export/csv/cells/otherassessors_cell.php index 66caf981..5b6bffda 100644 --- a/classes/export/csv/cells/otherassessors_cell.php +++ b/classes/export/csv/cells/otherassessors_cell.php @@ -42,8 +42,8 @@ public function get_cell($submission, $student, $stage_identifier) { global $DB, $USER; // find out current user stage identifier - // $stage_identifier = - // retrieve all feedbacks without currents user feedback + // $stage_identifier = + // retrieve all feedbacks without currents user feedback $params = array( 'submissionid' => $submission->id, @@ -59,7 +59,7 @@ public function get_cell($submission, $student, $stage_identifier) { $feedbacks = $DB->get_records_sql($sql, $params); $gradedata = []; - // $stage_identifier = ($this->coursework->get_max_markers() == 1) ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student); + // $stage_identifier = ($this->coursework->get_max_markers() == 1) ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student); foreach ($feedbacks as $feedback) { $grade = $submission->get_assessor_feedback_by_stage($feedback->stage_identifier); @@ -146,7 +146,7 @@ public function get_header($stage) { } $fields['otherassessorfeedback' . $i] = get_string('otherassessorfeedback', 'coursework', $i); } - return $fields; + return $fields; } } diff --git a/classes/export/csv/cells/singlegrade_cell.php b/classes/export/csv/cells/singlegrade_cell.php index 22c2d721..d56da8f4 100644 --- a/classes/export/csv/cells/singlegrade_cell.php +++ b/classes/export/csv/cells/singlegrade_cell.php @@ -160,7 +160,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo $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 + // 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'); @@ -253,7 +253,7 @@ function get_rubrics($coursework, $csv_cells) { // 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); + // $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); diff --git a/classes/export/csv/cells/submissiontime_cell.php b/classes/export/csv/cells/submissiontime_cell.php index a7452bdf..205c186d 100644 --- a/classes/export/csv/cells/submissiontime_cell.php +++ b/classes/export/csv/cells/submissiontime_cell.php @@ -34,7 +34,7 @@ class submissiontime_cell extends cell_base { * @return string */ public function get_cell($submission, $student, $stage_identifier) { - return $this->submission_time($submission); + return $this->submission_time($submission); } /** diff --git a/classes/export/grading_sheet.php b/classes/export/grading_sheet.php index 1c8ea7aa..e3166847 100644 --- a/classes/export/grading_sheet.php +++ b/classes/export/grading_sheet.php @@ -35,7 +35,7 @@ public function get_submissions($groupid = null, $selected_submission_ids = '') 'courseworkid' => $this->coursework->id, ); - $submissions = submission::find_all($params); + $submissions = submission::find_all($params); // remove unfinalised submissions foreach ($submissions as $submission) { @@ -55,44 +55,44 @@ public function get_submissions($groupid = null, $selected_submission_ids = '') /** * @var submission[] $submissions */ - foreach ($submissions as $submission) { - $stage_identifiers = []; - // remove all submissions that a user is not supposed to see - - // double marking not allocated - $stages = $this->coursework->get_max_markers(); - if ($stages > 1 && !$this->coursework->allocation_enabled() && !has_capability('mod/coursework:addagreedgrade', $PAGE->context)) { - // if samplings enabled, work out how many per submission - if ($this->coursework->sampling_enabled()) { - $stage_identifiers[] = 'assessor_1'; // always have at least one assessor - // check how many other assessors for this submission - $in_sample = $submission->get_submissions_in_sample(); - foreach ($in_sample as $i) { - $stage_identifiers[] = $i->stage_identifier; - } - } else { // if sampling not enabled, everyone is marked in all stages - for ($i = 1; $i <= $stages; $i++) { - $stage_identifiers[] = 'assessor_' . $i; - } - } - // check if any of the submissions still requires marking - for ($i = 0; $i < count($stage_identifiers); $i++) { - $feedback = $submission->get_assessor_feedback_by_stage($stage_identifiers[$i]); - // if no feedback or feedback belongs to current user don't remove submission - if (!$feedback || $feedback->assessorid == $USER->id) { - break; - } else if ($i + 1 < count($stage_identifiers)) { - continue; - } - // if the last submission was already marked remove it from the array - unset($submissions[$submission->id]); - } - } - - // TODO - decide if already marked submissions should be displayed in single marking - // if not marked by a user than dont display it as it would allow them to edit it?? - // || $submission->get_state() == submission::FINAL_GRADED - if (!$ability->can('show', $submission) + foreach ($submissions as $submission) { + $stage_identifiers = []; + // remove all submissions that a user is not supposed to see + + // double marking not allocated + $stages = $this->coursework->get_max_markers(); + if ($stages > 1 && !$this->coursework->allocation_enabled() && !has_capability('mod/coursework:addagreedgrade', $PAGE->context)) { + // if samplings enabled, work out how many per submission + if ($this->coursework->sampling_enabled()) { + $stage_identifiers[] = 'assessor_1'; // always have at least one assessor + // check how many other assessors for this submission + $in_sample = $submission->get_submissions_in_sample(); + foreach ($in_sample as $i) { + $stage_identifiers[] = $i->stage_identifier; + } + } else { // if sampling not enabled, everyone is marked in all stages + for ($i = 1; $i <= $stages; $i++) { + $stage_identifiers[] = 'assessor_' . $i; + } + } + // check if any of the submissions still requires marking + for ($i = 0; $i < count($stage_identifiers); $i++) { + $feedback = $submission->get_assessor_feedback_by_stage($stage_identifiers[$i]); + // if no feedback or feedback belongs to current user don't remove submission + if (!$feedback || $feedback->assessorid == $USER->id) { + break; + } else if ($i + 1 < count($stage_identifiers)) { + continue; + } + // if the last submission was already marked remove it from the array + unset($submissions[$submission->id]); + } + } + + // TODO - decide if already marked submissions should be displayed in single marking + // if not marked by a user than dont display it as it would allow them to edit it?? + // || $submission->get_state() == submission::FINAL_GRADED + if (!$ability->can('show', $submission) || ($stages == 1 && !has_capability('mod/coursework:addinitialgrade', $PAGE->context)) || ($this->coursework->allocation_enabled() && !$this->coursework ->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) @@ -105,12 +105,12 @@ public function get_submissions($groupid = null, $selected_submission_ids = '') && (has_capability('mod/coursework:addagreedgrade', $PAGE->context) || has_capability('mod/coursework:editagreedgrade', $PAGE->context))) || ((has_capability('mod/coursework:addagreedgrade', $PAGE->context) && $submission->get_state() < submission::FULLY_GRADED )) - ) { - unset($submissions[$submission->id]); - continue; - } - } - } + ) { + unset($submissions[$submission->id]); + continue; + } + } + } return $submissions; } @@ -166,15 +166,15 @@ 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++) { - // extra column with allocated assessor name - if ($coursework->allocation_enabled() && $coursework->get_max_markers() > 1 + for ($i = 1; $i <= $coursework->get_max_markers(); $i++) { + // extra column with allocated assessor name + if ($coursework->allocation_enabled() && $coursework->get_max_markers() > 1 && (has_capability('mod/coursework:addinitialgrade', $PAGE->context) || has_capability('mod/coursework:editinitialgrade', $PAGE->context))) { - $csv_cells[] = 'assessor' . $i; - } - $csv_cells[] = 'assessorgrade'.$i; - $csv_cells[] = 'assessorfeedback'.$i; + $csv_cells[] = 'assessor' . $i; + } + $csv_cells[] = 'assessorgrade'.$i; + $csv_cells[] = 'assessorfeedback'.$i; } $csv_cells[] = 'agreedgrade'; $csv_cells[] = 'agreedfeedback'; @@ -192,9 +192,9 @@ public static function cells_array($coursework) { } else if (has_capability('mod/coursework:addinitialgrade', $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(); @@ -204,7 +204,7 @@ public static function cells_array($coursework) { } } - */ + */ $csv_cells[] = 'feedbackcomments'; } diff --git a/classes/export/import.php b/classes/export/import.php index 5a8c87a5..05eab201 100644 --- a/classes/export/import.php +++ b/classes/export/import.php @@ -141,15 +141,15 @@ public function validate_csv($content, $encoding, $delimeter, $csv_cells) { $result = $cell->validate_cell($value, $submissionid, $stage_identifier, $uploadedgradecells); } - if ($result !== true) { - $errors[$s] = $result; - break; // Go to next line on error - } else if ($cells[$i] == "singlegrade" || $cells[$i] == "assessorgrade" || $cells[$i] == "agreedgrade" && !empty($value)) { + if ($result !== true) { + $errors[$s] = $result; + break; // Go to next line on error + } else if ($cells[$i] == "singlegrade" || $cells[$i] == "assessorgrade" || $cells[$i] == "agreedgrade" && !empty($value)) { - $uploadedgradecells[] = $stage_identifier; + $uploadedgradecells[] = $stage_identifier; - } - $i++; + } + $i++; } $s++; } @@ -203,10 +203,10 @@ function rubric_count_correct($csvheader, $linefromimportedcsv) { unset($csvheader[$position + $offset]); unset($linefromimportedcsv[$position + $offset]); -// if ($type == 'agreedgrade' && $this->coursework->finalstagegrading == 0) { + // if ($type == 'agreedgrade' && $this->coursework->finalstagegrading == 0) { array_splice($csvheader, $position + $offset, 0, array_keys($headers)); array_splice($linefromimportedcsv, $position + $offset, 0, array('')); -// } + // } $offset = $offset + count($headers) - 1; $expectedsize = (int)count($csvheader); $actualsize = (int)count($linefromimportedcsv); @@ -344,9 +344,9 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces foreach ($csvline as $k => $v) { if (substr($k, 0, 13) == 'assessorgrade' || substr($k, 0, 11) == 'singlegrade') { - $stages[$k] = $this->get_stage_identifier($csvline['submissionid'], $k); + $stages[$k] = $this->get_stage_identifier($csvline['submissionid'], $k); } else if (substr($k, 0, 11) == 'agreedgrade') { - $stages[$k] = 'final_agreed_1'; + $stages[$k] = 'final_agreed_1'; } } } @@ -362,7 +362,7 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces foreach ($stages as $k => $stage) { - // When allocation is enabled + // When allocation is enabled if (has_capability('mod/coursework:administergrades', $PAGE->context) && $coursework->allocation_enabled() && $stage != 'final_agreed_1' && $coursework->has_multiple_markers() == true) { $rubricoffset += 1; if ($a == 1) $rubricoffsetstart += 1; @@ -438,29 +438,29 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces $arrayvalues = array_filter($rubricdata); - if (!empty($arrayvalues)) { + if (!empty($arrayvalues)) { - //for ( $critidx < $numberofrubrics; ) { - $critidx = 0; - // This assumes that the data in the csv is in the correct criteria order.....it should be - foreach ($criterias as $c) { - $criteriagrade = []; + //for ( $critidx < $numberofrubrics; ) { + $critidx = 0; + // This assumes that the data in the csv is in the correct criteria order.....it should be + foreach ($criterias as $c) { + $criteriagrade = []; - // We need to get the levelid for the value that the criteria has been given + // We need to get the levelid for the value that the criteria has been given - $levelid = $this->get_value_rubric_levelid($c, $rubricdata[$critidx]); + $levelid = $this->get_value_rubric_levelid($c, $rubricdata[$critidx]); - $criteriagrade['levelid'] = $levelid; - $criteriagrade['remark'] = $rubricdata[$critidx + 1]; + $criteriagrade['levelid'] = $levelid; + $criteriagrade['remark'] = $rubricdata[$critidx + 1]; - $criteriagradedata['criteria'][$c['id']] = $criteriagrade; + $criteriagradedata['criteria'][$c['id']] = $criteriagrade; - $critidx = $critidx + 2; + $critidx = $critidx + 2; - } - } else { - $criteriagradedata = false; } + } else { + $criteriagradedata = false; + } // Need to decide where the grade instance submit and get grade should be put as in order @@ -469,29 +469,29 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces // In case there is another rubric to be extracted from the csv set the new value of the rubric offset - } else if ($coursework->is_using_rubric() && ($stage == 'final_agreed_1' && $this->coursework->finalstagegrading == 1)) { + } else if ($coursework->is_using_rubric() && ($stage == 'final_agreed_1' && $this->coursework->finalstagegrading == 1)) { - if (!isset($numberofrubrics)) { + if (!isset($numberofrubrics)) { - $criterias = $this->coursework->get_rubric_criteria(); + $criterias = $this->coursework->get_rubric_criteria(); - $numberofrubrics = count($criterias) * 2; + $numberofrubrics = count($criterias) * 2; - } - $stagemultiplier = $numberofstages - 1; + } + $stagemultiplier = $numberofstages - 1; - // The calculation below finds the position of the agreed grades in the uploaded csv + // The calculation below finds the position of the agreed grades in the uploaded csv - $rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier); + $rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier); - if ($coursework->allocation_enabled()) $rubricoffset += 1; + if ($coursework->allocation_enabled()) $rubricoffset += 1; - $gradearrvalue = array_slice($line, $rubricoffset, 2); + $gradearrvalue = array_slice($line, $rubricoffset, 2); - $csvline[$gradepointer] = $gradearrvalue[0]; - $csvline[$feedbackpointer] = $gradearrvalue[1]; + $csvline[$gradepointer] = $gradearrvalue[0]; + $csvline[$feedbackpointer] = $gradearrvalue[1]; - } + } // don't create/update feedback if grade is empty if (!empty($csvline[$gradepointer])) { @@ -566,7 +566,7 @@ public function add_grade($submissionid, $grade, $feedback, $stage_identifier, $ // workout markernumber if ($stage_identifier == 'assessor_1') { - // assessor_1 is always marker 1 + // assessor_1 is always marker 1 $markernumber = 1; } else { // get all feedbacks and add 1 @@ -670,9 +670,9 @@ public function edit_grade($cwfeedbackid, $grade, $feedback, $uses_rubric=false) $update = $DB->update_record('coursework_feedbacks', $edit_grade); // if record updated and coursework has automatic grading enabled update agreedgrade - if ($update && $this->coursework->automaticagreement_enabled()) { - $this->auto_agreement($cwfeedbackid); - } + if ($update && $this->coursework->automaticagreement_enabled()) { + $this->auto_agreement($cwfeedbackid); + } } return $update; @@ -741,19 +741,19 @@ public function get_stage_identifier($submissionid, $cell_identifier) { 'stage_identifier' => 'assessor_1')); // no sample or no feedback for sample yet if (!$in_sample || ($in_sample && !$feedback)) { - $stage_identifier = 'assessor_1'; + $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, + $samples = $submission->get_submissions_in_sample(); + foreach ($samples as $sample) { + $feedback = $DB->record_exists('coursework_feedbacks', array('submissionid' => $submissionid, 'stage_identifier' => $sample->stage_identifier)); - // if feedback doesn't exist, we'll use this stage identifier for a new feedback - if (!$feedback) { - $stage_identifier = $sample->stage_identifier; - break; - } - } - } + // if feedback doesn't exist, we'll use this stage identifier for a new feedback + if (!$feedback) { + $stage_identifier = $sample->stage_identifier; + break; + } + } + } } } @@ -791,9 +791,9 @@ 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; + $otherassessors = false; if (in_array('otherassessors', $csv_cells)) { // find position of otherassesors so we know from which key to unset @@ -820,7 +820,7 @@ public function remove_other_assessors_grade($csv_cells, &$line) { } - return $csv_cells; + return $csv_cells; } } diff --git a/classes/file_importer.php b/classes/file_importer.php index d41f4b5c..b73413ee 100644 --- a/classes/file_importer.php +++ b/classes/file_importer.php @@ -177,7 +177,7 @@ public function import_zip_files($coursework, $feedbackstage, $overwritecurrent) $results[$filename] = get_string('feedbacksubmissionpublished', 'mod_coursework'); } - } else { + } else { $results[$filename] = get_string('feedbacknotfound', 'mod_coursework'); } } diff --git a/classes/forms/deadline_extension_form.php b/classes/forms/deadline_extension_form.php index b6083172..5ea0553d 100644 --- a/classes/forms/deadline_extension_form.php +++ b/classes/forms/deadline_extension_form.php @@ -124,7 +124,7 @@ public function personal_deadline() { 'courseworkid' => $courseworkid, ); - return $personal_deadline = $DB->get_record('coursework_person_deadlines', $params); + return $personal_deadline = $DB->get_record('coursework_person_deadlines', $params); } } diff --git a/classes/forms/student_submission_form.php b/classes/forms/student_submission_form.php index ff5bca7f..3c4695ac 100644 --- a/classes/forms/student_submission_form.php +++ b/classes/forms/student_submission_form.php @@ -183,7 +183,7 @@ public function handle() { $mailer = new mailer($coursework); if (!empty($notifyuser)) $mailer->send_submission_notification($notifyuser); - } + } } } diff --git a/classes/forms/upload_allocations_form.php b/classes/forms/upload_allocations_form.php index 795d2847..be524829 100644 --- a/classes/forms/upload_allocations_form.php +++ b/classes/forms/upload_allocations_form.php @@ -39,7 +39,7 @@ function definition() { $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('checkbox', 'overwrite', '', get_string('overwritegrades', 'coursework')); $mform->addElement('hidden', 'cmid', $this->cmid); $mform->setType('cmid', PARAM_RAW); diff --git a/classes/grading_table_row_base.php b/classes/grading_table_row_base.php index 1752b4ee..6c9a71c1 100644 --- a/classes/grading_table_row_base.php +++ b/classes/grading_table_row_base.php @@ -255,7 +255,7 @@ public function get_submission() { */ public function get_plagiarism_flag() { - $submission = $this->get_submission(); + $submission = $this->get_submission(); $params = array( 'submissionid' => $submission->id, ); diff --git a/classes/models/coursework.php b/classes/models/coursework.php index fd57d41e..98adf7ef 100644 --- a/classes/models/coursework.php +++ b/classes/models/coursework.php @@ -954,7 +954,7 @@ public function pack_files() { $fs = get_file_storage(); $grading_sheet = new \mod_coursework\export\grading_sheet($this, null, null); - // get only submissions that user can grade + // get only submissions that user can grade $submissions = $grading_sheet->get_submissions(); foreach ($submissions as $submission) { @@ -1298,7 +1298,7 @@ public function get_submissions_needing_grading() { $needsgrading[] = $submission; } - } + } return $needsgrading; @@ -1368,7 +1368,7 @@ 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); } @@ -1928,7 +1928,7 @@ public function get_students() { $users = []; $raw_users = get_enrolled_users($this->get_context(), 'mod/coursework:submit'); - // filter students who are restricted from the coursework + // filter students who are restricted from the coursework $cm = $this->get_course_module(); $cmobject = $this->cm_object($cm); @@ -2066,7 +2066,7 @@ public function student_is_in_any_group($student) { * @return bool */ public function sampling_enabled() { - return (bool)$this->samplingenabled; + return (bool)$this->samplingenabled; } /** @@ -2480,7 +2480,7 @@ public static function extension_reasons() { $extension_reasons = explode("\n", $extension_reasons); $extension_reasons = array_map(function ($i) { return trim($i); - }, + }, $extension_reasons); $extension_reasons = array_merge(array('' => 'Not specified'), $extension_reasons); } @@ -2496,8 +2496,8 @@ public function extensions_enabled() { } /* -* @return bool -*/ + * @return bool + */ public function extension_exists() { global $DB; diff --git a/classes/models/feedback.php b/classes/models/feedback.php index afec6ea0..4502acec 100644 --- a/classes/models/feedback.php +++ b/classes/models/feedback.php @@ -312,7 +312,7 @@ public static function get_teacher_feedback(submission $submission, * @return bool */ public function is_assessor_allocated() { - return $this->get_stage()->assessor_has_allocation($this->get_allocatable()); + return $this->get_stage()->assessor_has_allocation($this->get_allocatable()); } /** diff --git a/classes/models/moderation.php b/classes/models/moderation.php index ca7808cd..db962a11 100644 --- a/classes/models/moderation.php +++ b/classes/models/moderation.php @@ -48,7 +48,7 @@ class moderation extends table_base { /** * @var int */ - public $feedbackid; + public $feedbackid; /** * @var int @@ -113,8 +113,8 @@ public function get_agreement() { * @return bool|submission */ public function get_submission() { - $feedback = $this->get_feedback(); - $this->submission = submission::find($feedback->submissionid); + $feedback = $this->get_feedback(); + $this->submission = submission::find($feedback->submissionid); return $this->submission; } diff --git a/classes/models/outstanding_marking.php b/classes/models/outstanding_marking.php index f6bc8fac..2d7d8a93 100644 --- a/classes/models/outstanding_marking.php +++ b/classes/models/outstanding_marking.php @@ -73,13 +73,13 @@ public function get_to_grade_agreed_count($cwkrecord, $userid) { //AGREED GRADE INFORMATION - if ($this->should_get_to_mark_agreed_grade_info($coursework->id, $userid) && $coursework->has_multiple_markers()) { - if (!$coursework->sampling_enabled()) { - $agreedsubmissions = $this->get_to_grade_agreed_grade_submissions($coursework->id, $coursework->get_max_markers()); - } else { - $agreedsubmissions = $this->get_to_grade_agreed_grade_sampled_submissions($coursework->id); - } + if ($this->should_get_to_mark_agreed_grade_info($coursework->id, $userid) && $coursework->has_multiple_markers()) { + if (!$coursework->sampling_enabled()) { + $agreedsubmissions = $this->get_to_grade_agreed_grade_submissions($coursework->id, $coursework->get_max_markers()); + } else { + $agreedsubmissions = $this->get_to_grade_agreed_grade_sampled_submissions($coursework->id); } + } return (!empty($agreedsubmissions)) ? count($agreedsubmissions) : 0; } diff --git a/classes/models/submission.php b/classes/models/submission.php index f2dfd0e9..c132f7d6 100644 --- a/classes/models/submission.php +++ b/classes/models/submission.php @@ -761,20 +761,20 @@ public function get_author_id() { // 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()) { - $members = groups_get_members($this->allocatableid, 'u.id', 'id'); - if ($members) { - $id = reset($members)->id; - } + if ($this->is_submission_on_behalf()) { + 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; + } - if ($this->get_coursework()->plagiarism_enbled()) { - $groupmember = $this->get_tii_group_member_with_eula($this->allocatableid); - if (!empty($groupmember)) $id = $groupmember->id; - } - } else { - $id = $this->allocatableid; + if ($this->get_coursework()->plagiarism_enbled()) { + $groupmember = $this->get_tii_group_member_with_eula($this->allocatableid); + if (!empty($groupmember)) $id = $groupmember->id; } + } else { + $id = $this->allocatableid; + } } return $id; @@ -786,7 +786,7 @@ 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; @@ -1143,7 +1143,7 @@ public function max_number_of_feedbacks() { global $DB; if ($this->get_coursework()->sampling_enabled()) { - // calculate how many stages(markers) are enabled for this submission + // calculate how many stages(markers) are enabled for this submission $parameters = array('courseworkid' => $this->coursework->id, 'allocatableid' => $this->get_allocatable()->id(), 'allocatabletype' => $this->get_allocatable()->type()); @@ -1398,9 +1398,9 @@ public function final_draft_feedbacks_exist() { return (empty($editablefeedbacks)) ? false : $editablefeedbacks; } -/* - * Determines whether the current user is able to add a turnitin grademark to this submission - */ + /* + * Determines whether the current user is able to add a turnitin grademark to this submission + */ function can_add_tii_grademark() { $canadd = false; diff --git a/classes/render_helpers/grading_report/cells/_user_cell.php b/classes/render_helpers/grading_report/cells/_user_cell.php index def69931..213a3428 100644 --- a/classes/render_helpers/grading_report/cells/_user_cell.php +++ b/classes/render_helpers/grading_report/cells/_user_cell.php @@ -48,7 +48,7 @@ public function get_table_cell($rowobject) { */ $user = $rowobject->get_allocatable(); - /* if ($rowobject->can_view_username()) { + /* if ($rowobject->can_view_username()) { $content .= $OUTPUT->user_picture($user->get_raw_record()); } else { $renderer = $PAGE->get_renderer('core'); @@ -69,28 +69,28 @@ public function get_table_cell($rowobject) { */ public function get_table_header($options = []) { - $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context()); + $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context()); //adding this line so that the sortable heading function will make a sortable link unique to the table // If tablename is set $tablename = (!empty($options['tablename'])) ? $options['tablename'] : ''; - // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous - if ($viewanonymous || !$this->coursework->blindmarking) { - $sort_by_first_name = $this->helper_sortable_heading(get_string('firstname'), + // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous + if ($viewanonymous || !$this->coursework->blindmarking) { + $sort_by_first_name = $this->helper_sortable_heading(get_string('firstname'), 'firstname', $options['sorthow'], $options['sortby'], $tablename); - $sort_by_last_name = $this->helper_sortable_heading(get_string('lastname'), + $sort_by_last_name = $this->helper_sortable_heading(get_string('lastname'), 'lastname', $options['sorthow'], $options['sortby'], $tablename); - } else { // otherwise display header without sorting - $sort_by_first_name = get_string('firstname'); - $sort_by_last_name =get_string('lastname'); - } + } else { // otherwise display header without sorting + $sort_by_first_name = get_string('firstname'); + $sort_by_last_name =get_string('lastname'); + } if ($this->fullname_format() == 'lf') { $sort_by_name = $sort_by_last_name . ' / ' . $sort_by_first_name; diff --git a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php index 07b72e25..1ab3ac31 100644 --- a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php +++ b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php @@ -162,7 +162,7 @@ private function new_moderation_button($rowobject, $assessor) { // moderation only done for single marking courseworks $feedback = $rowobject->get_submission()->get_assessor_feedback_by_stage('assessor_1'); - $moderation_params = array( + $moderation_params = array( 'submission' => $rowobject->get_submission(), 'assessor' => $assessor, 'stage' => $this->stage, diff --git a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php index 3b01688b..d0dc6ed4 100644 --- a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php +++ b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php @@ -79,8 +79,8 @@ public function get_content($rowobject) { if ($finalfeedback !== false) { $grade_judge = new grade_judge($this->coursework); $content .= $grade_judge->grade_to_display($finalfeedback->get_grade()); - // $content .= html_writer::empty_tag('br'); - // $content .= ' by: ' . $finalfeedback->get_assesor_username(); + // $content .= html_writer::empty_tag('br'); + // $content .= ' by: ' . $finalfeedback->get_assesor_username(); } // Edit/new link @@ -150,13 +150,13 @@ public function get_content($rowobject) { if ($finalfeedback !== false) { $content .= html_writer::empty_tag('br'); - if ((!$this->coursework->sampling_enabled() || $rowobject->get_submission()->sampled_feedback_exists()) && ($finalfeedback->get_feedbacks_assessorid() == 0 + if ((!$this->coursework->sampling_enabled() || $rowobject->get_submission()->sampled_feedback_exists()) && ($finalfeedback->get_feedbacks_assessorid() == 0 && $finalfeedback->timecreated == $finalfeedback->timemodified) || $finalfeedback->lasteditedbyuser == 0) { // if the grade was automatically agreed - $content .= "(".get_string('automaticagreement', 'coursework').")"; - } else { - $content .= ' by: ' . $finalfeedback->get_assesor_username(); - } + $content .= "(".get_string('automaticagreement', 'coursework').")"; + } else { + $content .= ' by: ' . $finalfeedback->get_assesor_username(); + } } return $content; } diff --git a/classes/render_helpers/grading_report/cells/user_cell.php b/classes/render_helpers/grading_report/cells/user_cell.php index 6eddeab0..acf601fd 100644 --- a/classes/render_helpers/grading_report/cells/user_cell.php +++ b/classes/render_helpers/grading_report/cells/user_cell.php @@ -43,7 +43,7 @@ public function get_table_cell($rowobject) { $content = ''; - /* if ($rowobject->can_view_username()) { + /* if ($rowobject->can_view_username()) { $content .= $OUTPUT->user_picture($user->get_raw_record()); } else { $renderer = $PAGE->get_renderer('core'); @@ -56,7 +56,7 @@ public function get_table_cell($rowobject) { $content .= ' ' . $rowobject->get_user_name(true); $content .= "
".$rowobject->get_email(); $user = $rowobject->get_allocatable(); -/* + /* $candidatenumber = $user->candidate_number(); if (!empty($candidatenumber)) { @@ -65,7 +65,7 @@ public function get_table_cell($rowobject) { } -*/ + */ return $this->get_new_cell_with_class($content); } @@ -76,35 +76,35 @@ public function get_table_cell($rowobject) { */ public function get_table_header($options = []) { - $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context()); + $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context()); //adding this line so that the sortable heading function will make a sortable link unique to the table // If tablename is set $tablename = (!empty($options['tablename'])) ? $options['tablename'] : ''; - // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous - if ($viewanonymous || !$this->coursework->blindmarking) { - $sort_by_first_name = $this->helper_sortable_heading(get_string('firstname'), + // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous + if ($viewanonymous || !$this->coursework->blindmarking) { + $sort_by_first_name = $this->helper_sortable_heading(get_string('firstname'), 'firstname', $options['sorthow'], $options['sortby'], $tablename); - $sort_by_last_name = $this->helper_sortable_heading(get_string('lastname'), + $sort_by_last_name = $this->helper_sortable_heading(get_string('lastname'), 'lastname', $options['sorthow'], $options['sortby'], $tablename); - $sort_by_email = $this->helper_sortable_heading(get_string('email', 'mod_coursework'), + $sort_by_email = $this->helper_sortable_heading(get_string('email', 'mod_coursework'), 'email', $options['sorthow'], $options['sortby'], $tablename); - } else { // otherwise display header without sorting - $sort_by_first_name = get_string('firstname'); - $sort_by_last_name = get_string('lastname'); - $sort_by_email = get_string('email', 'mod_coursework'); - } + } else { // otherwise display header without sorting + $sort_by_first_name = get_string('firstname'); + $sort_by_last_name = get_string('lastname'); + $sort_by_email = get_string('email', 'mod_coursework'); + } if ($this->fullname_format() == 'lf') { $sort_by_first_name = ' / ' . $sort_by_first_name; diff --git a/classes/render_helpers/grading_report/sub_rows/multi_marker_feedback_sub_rows.php b/classes/render_helpers/grading_report/sub_rows/multi_marker_feedback_sub_rows.php index 35646de9..ebdd57c8 100644 --- a/classes/render_helpers/grading_report/sub_rows/multi_marker_feedback_sub_rows.php +++ b/classes/render_helpers/grading_report/sub_rows/multi_marker_feedback_sub_rows.php @@ -118,7 +118,7 @@ protected function render_assessor_feedback_table(assessor_feedback_table $asses // Don't show empty rows with nothing in them // As a part of Release 1 we decided to show all rows to apply styling correctly, // this is expected to be rewritten for Release 2 - /* if (!$feedback_row->get_assessor()->id() && (!$feedback_row->get_submission() || + /* if (!$feedback_row->get_assessor()->id() && (!$feedback_row->get_submission() || !$feedback_row->get_submission()->ready_to_grade() || $this->already_shown_a_new_buton)) { continue; @@ -149,7 +149,7 @@ protected function render_assessor_feedback_table(assessor_feedback_table $asses $allocation_string = ($coursework->allocation_enabled()) ? get_string('allocatedtoassessor', 'mod_coursework') : get_string('assessor', 'mod_coursework'); -/* + /* $table_html = ' @@ -168,7 +168,7 @@ protected function render_assessor_feedback_table(assessor_feedback_table $asses '; -*/ + */ $table_html = ' diff --git a/classes/sample_set_rule/range_sample_type.php b/classes/sample_set_rule/range_sample_type.php index 303fc868..bfb5f8f9 100644 --- a/classes/sample_set_rule/range_sample_type.php +++ b/classes/sample_set_rule/range_sample_type.php @@ -105,7 +105,7 @@ public function range_elements($assessor_number, $sequence, $dbrecord=false) { if ($dbrecord) { $selected_type = array($dbrecord->ruletype => get_string($dbrecord->ruletype, 'mod_coursework')); - $selected_to = ($dbrecord->ruletype == 'scale') ? array($dbrecord->upperlimit => $scale[$dbrecord->upperlimit]) : array($dbrecord->upperlimit => $dbrecord->upperlimit); + $selected_to = ($dbrecord->ruletype == 'scale') ? array($dbrecord->upperlimit => $scale[$dbrecord->upperlimit]) : array($dbrecord->upperlimit => $dbrecord->upperlimit); $selected_from = ($dbrecord->ruletype == 'scale') ? array($dbrecord->lowerlimit => $scale[$dbrecord->lowerlimit]) : array($dbrecord->lowerlimit => $dbrecord->lowerlimit); @@ -337,23 +337,23 @@ public function save_form_data($assessor_number=0, &$order=0) { $sample_plugin = $DB->get_record('coursework_sample_set_plugin', array('rulename' => 'range_sample_type')); - if ($sample_rules) { - foreach ($sample_rules as $i => $val) { + if ($sample_rules) { + foreach ($sample_rules as $i => $val) { - $dbrecord = new \stdClass(); + $dbrecord = new \stdClass(); - $dbrecord->ruletype = $sample_type[$i]; - $dbrecord->lowerlimit = $sample_from[$i]; - $dbrecord->upperlimit = $sample_to[$i]; - $dbrecord->sample_set_plugin_id = $sample_plugin->id; - $dbrecord->courseworkid = $this->coursework->id; - $dbrecord->ruleorder = $order; - $dbrecord->stage_identifier = "assessor_{$assessor_number}"; + $dbrecord->ruletype = $sample_type[$i]; + $dbrecord->lowerlimit = $sample_from[$i]; + $dbrecord->upperlimit = $sample_to[$i]; + $dbrecord->sample_set_plugin_id = $sample_plugin->id; + $dbrecord->courseworkid = $this->coursework->id; + $dbrecord->ruleorder = $order; + $dbrecord->stage_identifier = "assessor_{$assessor_number}"; - $DB->insert_record("coursework_sample_set_rules", $dbrecord); - $order++; - } + $DB->insert_record("coursework_sample_set_rules", $dbrecord); + $order++; } + } } @@ -404,35 +404,35 @@ private function rationalise($ruletype, $limit1, $limit2) { $limits[0] = ($limit1>$limit2) ? $limit2 : $limit1; $limits[1] = ($limit1>$limit2) ? $limit1 : $limit2; - if ($ruletype == 'scale') { - ++$limits[0]; - ++$limits[1]; - } - - if ($ruletype == 'percentage') { - if ($this->coursework->grade > 0) { - $limits[0] = $this->coursework->grade * $limits[0] / 100; - $limits[1] = $this->coursework->grade * $limits[1] / 100; - } else { - $scale = $DB->get_record("scale", array('id' => abs($this->coursework->grade))); + if ($ruletype == 'scale') { + ++$limits[0]; + ++$limits[1]; + } - if ($scale) { + if ($ruletype == 'percentage') { + if ($this->coursework->grade > 0) { + $limits[0] = $this->coursework->grade * $limits[0] / 100; + $limits[1] = $this->coursework->grade * $limits[1] / 100; + } else { + $scale = $DB->get_record("scale", array('id' => abs($this->coursework->grade))); - $coursework_scale = explode(",", $scale->scale); + if ($scale) { - $number_of_items = count($coursework_scale); + $coursework_scale = explode(",", $scale->scale); - $weighting = 100 / $number_of_items; // shall we round it???? + $number_of_items = count($coursework_scale); - $limits[0] = ceil($limits[0]/$weighting); // element of array - $limits[1] = ceil($limits[1]/$weighting); // element of array + $weighting = 100 / $number_of_items; // shall we round it???? - // Note we have to add one as the values are not stored in there element positions + $limits[0] = ceil($limits[0]/$weighting); // element of array + $limits[1] = ceil($limits[1]/$weighting); // element of array - } + // Note we have to add one as the values are not stored in there element positions } + } + } return $limits; } @@ -453,7 +453,7 @@ private function get_allocatables_in_range($stage, $limit1, $limit2) { // Note as things stand limit1 and limit2 can not be params as the type of the grade field (varchar) //means the values are cast as strings - return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id, + return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id, 'stage' => $stage)); } diff --git a/classes/sample_set_rule/total_sample_type.php b/classes/sample_set_rule/total_sample_type.php index f1993680..38bb27a4 100644 --- a/classes/sample_set_rule/total_sample_type.php +++ b/classes/sample_set_rule/total_sample_type.php @@ -219,15 +219,15 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample if (!is_array($array_keys)) $array_keys = array($array_keys); //use the allocatables array to get other ungraded allocatables - foreach ($array_keys as $id) { + foreach ($array_keys as $id) { - if (!isset($published[$id]) && !isset($finalised[$id]) - && !isset($auto_sample_set[$id]) && !isset($manual_sample_set[$id]) - ) - $auto_sample_set[$id] = $allocatables[$id]; + if (!isset($published[$id]) && !isset($finalised[$id]) + && !isset($auto_sample_set[$id]) && !isset($manual_sample_set[$id]) + ) + $auto_sample_set[$id] = $allocatables[$id]; - if (count($auto_sample_set) == $total_to_return) break; - } + if (count($auto_sample_set) == $total_to_return) break; + } } diff --git a/classes/warnings.php b/classes/warnings.php index b05f450c..5f86c68b 100644 --- a/classes/warnings.php +++ b/classes/warnings.php @@ -224,41 +224,41 @@ public function manual_allocation_not_completed() { for ($i = 1; $i <= $coursework_stages; $i++) { $assessor = 'assessor_'.$i; - if ($coursework->samplingenabled == 0 || $assessor == 'assessor_1') { - $allocatables = $coursework->get_allocatables(); + if ($coursework->samplingenabled == 0 || $assessor == 'assessor_1') { + $allocatables = $coursework->get_allocatables(); - foreach ($allocatables as $allocatable) { + foreach ($allocatables as $allocatable) { - $params = array('courseworkid' => $coursework->id, - 'stageidentifier' => $assessor, - 'allocatableid' => $allocatable->id); + $params = array('courseworkid' => $coursework->id, + 'stageidentifier' => $assessor, + 'allocatableid' => $allocatable->id); - $existing_allocations = $this->check_existing_allocations($params); + $existing_allocations = $this->check_existing_allocations($params); - if ($existing_allocations == false) { - return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework')); - } - } - } else { + if ($existing_allocations == false) { + return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework')); + } + } + } else { - $params = array('courseworkid' => $coursework->id); - $sql = "SELECT id, stage_identifier, allocatableid + $params = array('courseworkid' => $coursework->id); + $sql = "SELECT id, stage_identifier, allocatableid FROM {coursework_sample_set_mbrs} WHERE courseworkid = :courseworkid"; - $stage_identifiers = $DB->get_records_sql($sql, $params); - foreach ($stage_identifiers as $stage_identifier) { - $params = array('courseworkid' => $coursework->id, - 'stageidentifier' => $stage_identifier->stage_identifier, - 'allocatableid' => $stage_identifier->allocatableid); + $stage_identifiers = $DB->get_records_sql($sql, $params); + foreach ($stage_identifiers as $stage_identifier) { + $params = array('courseworkid' => $coursework->id, + 'stageidentifier' => $stage_identifier->stage_identifier, + 'allocatableid' => $stage_identifier->allocatableid); - $existing_allocations = $this->check_existing_allocations($params); + $existing_allocations = $this->check_existing_allocations($params); - if ($existing_allocations == false) { - return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework')); - } - } - } + if ($existing_allocations == false) { + return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework')); + } + } + } } return ''; } @@ -275,7 +275,7 @@ public function check_existing_allocations($params) { AND stage_identifier = :stageidentifier AND allocatableid = :allocatableid"; - return $existing_allocations = $DB->get_records_sql($sql, $params); + return $existing_allocations = $DB->get_records_sql($sql, $params); } diff --git a/db/upgrade.php b/db/upgrade.php index 11960664..b41f65c1 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -2496,7 +2496,7 @@ function xmldb_coursework_upgrade($oldversion) { $cwk->renamefiles = ($cwk->blindmarking == 1 || $courseworkhassubmissions) ? 1 : 0; $DB->update_record('coursework', $cwk); - } + } // Coursework savepoint reached. upgrade_mod_savepoint(true, 2019121403, 'coursework'); diff --git a/lib.php b/lib.php index 1fb5062a..5dc3b10d 100644 --- a/lib.php +++ b/lib.php @@ -276,21 +276,21 @@ function mod_coursework_core_calendar_provide_event_action(calendar_event $event if ($marker) { // For markers // Check how many submissions to mark - $outstandingmarking = new outstanding_marking(); + $outstandingmarking = new outstanding_marking(); - if ($event->eventtype == 'initialgradingdue') { - // Initial grades - $togradeinitialcount = $outstandingmarking->get_to_grade_initial_count($dbcoursework, $user->id()); - $name = ($coursework->has_multiple_markers()) ? get_string('initialgrade', 'coursework') : get_string('grade', 'mod_coursework'); - $itemcount = $togradeinitialcount; + if ($event->eventtype == 'initialgradingdue') { + // Initial grades + $togradeinitialcount = $outstandingmarking->get_to_grade_initial_count($dbcoursework, $user->id()); + $name = ($coursework->has_multiple_markers()) ? get_string('initialgrade', 'coursework') : get_string('grade', 'mod_coursework'); + $itemcount = $togradeinitialcount; - } else if ($event->eventtype == 'agreedgradingdue') { - // Agreed grades - $togradeagreedcount = $outstandingmarking->get_to_grade_agreed_count($dbcoursework, $user->id()); - $name = get_string('agreedgrade', 'coursework'); - $itemcount = $togradeagreedcount; + } else if ($event->eventtype == 'agreedgradingdue') { + // Agreed grades + $togradeagreedcount = $outstandingmarking->get_to_grade_agreed_count($dbcoursework, $user->id()); + $name = get_string('agreedgrade', 'coursework'); + $itemcount = $togradeagreedcount; - } + } $submission_url = new \moodle_url('/mod/coursework/view.php', array('id' => $cm->id)); @@ -517,45 +517,45 @@ function coursework_update_instance($coursework) { * * @param $coursework */ - function coursework_update_events($coursework, $eventtype) { - global $DB; - - $event = ""; - $eventid = $DB->get_record('event', array('modulename' => 'coursework', 'instance' => $coursework->id, 'eventtype' => $eventtype)); - - if ($eventid) { - $event = calendar_event::load($eventid->id); - } - - // Update/create event for coursework deadline [due] - if ($eventtype == 'due') { - $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->deadline); - if ($event) { - $event->update($data); //update if event exists - } else { - calendar_event::create($data); // Create new event as it doesn't exist - } - } - - // Update/create event for coursework initialmarking deadline [initialgradingdue] - if ($eventtype == 'initialgradingdue') { - $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->initialmarkingdeadline); - if ($event) { - $event->update($data); //update if event exists - } else { - calendar_event::create($data); // Create new event as it doesn't exist - } - } - - // Update/create event for coursework agreedgrademarking deadline [agreedgradingdue] - if ($eventtype == 'agreedgradingdue') { - $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->agreedgrademarkingdeadline); - if ($event) { - $event->update($data); //update if event exists - } else { - calendar_event::create($data); // Create new event as it doesn't exist - } - } +function coursework_update_events($coursework, $eventtype) { + global $DB; + + $event = ""; + $eventid = $DB->get_record('event', array('modulename' => 'coursework', 'instance' => $coursework->id, 'eventtype' => $eventtype)); + + if ($eventid) { + $event = calendar_event::load($eventid->id); + } + + // Update/create event for coursework deadline [due] + if ($eventtype == 'due') { + $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->deadline); + if ($event) { + $event->update($data); //update if event exists + } else { + calendar_event::create($data); // Create new event as it doesn't exist + } + } + + // Update/create event for coursework initialmarking deadline [initialgradingdue] + if ($eventtype == 'initialgradingdue') { + $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->initialmarkingdeadline); + if ($event) { + $event->update($data); //update if event exists + } else { + calendar_event::create($data); // Create new event as it doesn't exist + } + } + + // Update/create event for coursework agreedgrademarking deadline [agreedgradingdue] + if ($eventtype == 'agreedgradingdue') { + $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->agreedgrademarkingdeadline); + if ($event) { + $event->update($data); //update if event exists + } else { + calendar_event::create($data); // Create new event as it doesn't exist + } + } } /** @@ -837,7 +837,7 @@ function coursework_extend_settings_navigation(settings_navigation $settings, na function coursework_role_assigned_event_handler($roleassignment) { global $DB; -// return true; // Until we fix the auto allocator. The stuff below causes an infinite loop. + // return true; // Until we fix the auto allocator. The stuff below causes an infinite loop. $courseworkids = coursework_get_coursework_ids_from_context_id($roleassignment->contextid); @@ -992,7 +992,7 @@ function coursework_send_deadline_changed_emails($eventdata) { // No need to send emails if none of the deadlines have changed. - // echo 'Starting to send Coursework deadline changed emails...'; + // echo 'Starting to send Coursework deadline changed emails...'; $counter = 0; $coursework = coursework::find($eventdata->other['courseworkid']); @@ -1074,7 +1074,7 @@ function coursework_send_deadline_changed_emails($eventdata) { message_send($messagedata); } - // echo 'Sent '.$counter.' messages.'; + // echo 'Sent '.$counter.' messages.'; return true; } @@ -1286,39 +1286,39 @@ function course_group_member_removed($event_data) { } } else { // find all individual students in the group - $students = get_enrolled_users($coursework->get_context(), 'mod/coursework:submit', $groupid); - if ($students) { - foreach ($students as $student) { - if (can_delete_allocation($coursework->id(), $student->id)) { - $DB->delete_records('coursework_allocation_pairs', array('courseworkid' => $coursework->id(), 'assessorid' => $removeduserid, 'allocatableid' => $student->id, 'stage_identifier' => 'assessor_1')); - } - } - } else { - continue; - } + $students = get_enrolled_users($coursework->get_context(), 'mod/coursework:submit', $groupid); + if ($students) { + foreach ($students as $student) { + if (can_delete_allocation($coursework->id(), $student->id)) { + $DB->delete_records('coursework_allocation_pairs', array('courseworkid' => $coursework->id(), 'assessorid' => $removeduserid, 'allocatableid' => $student->id, 'stage_identifier' => 'assessor_1')); + } + } + } else { + continue; + } } // check if there are any other assessor in the group, at this point the removed member should no longer be in the group $assessors_in_group = get_enrolled_users($coursework->get_context(), 'mod/coursework:addinitialgrade', $groupid); - if ($assessors_in_group) { // if another assessor found, assign all allocatables in this group to the other assessor - if ($coursework->is_configured_to_have_group_submissions()) {// yes - assign the assessor to a allocatable group - $stage_1->make_auto_allocation_if_necessary(group::find($groupid)); - } else { - $allocatables = $coursework->get_allocatables(); - if ($allocatables) { - // yes - assign this assessor to every allocatable student in the appropriate course group - foreach ($allocatables as $allocatable) { - // process students allocations - $stage_1->make_auto_allocation_if_necessary($allocatable); - } - } else {// no - do nothing, return true - continue; - } - } - } else { - continue; - } + if ($assessors_in_group) { // if another assessor found, assign all allocatables in this group to the other assessor + if ($coursework->is_configured_to_have_group_submissions()) {// yes - assign the assessor to a allocatable group + $stage_1->make_auto_allocation_if_necessary(group::find($groupid)); + } else { + $allocatables = $coursework->get_allocatables(); + if ($allocatables) { + // yes - assign this assessor to every allocatable student in the appropriate course group + foreach ($allocatables as $allocatable) { + // process students allocations + $stage_1->make_auto_allocation_if_necessary($allocatable); + } + } else {// no - do nothing, return true + continue; + } + } + } else { + continue; + } } else if ($student) { if ($coursework->is_configured_to_have_group_submissions()) { // check if student was the only student member in the group @@ -1385,7 +1385,7 @@ function can_delete_allocation($courseworkid, $allocatableid) { * @param $course_module_id * @return string */ - function plagiarism_similarity_information($course_module) { +function plagiarism_similarity_information($course_module) { $html = ''; ob_start(); @@ -1451,7 +1451,7 @@ function coursework_personal_deadline_passed($courseworkid) { WHERE courseworkid = :courseworkid AND personal_deadline < :now"; - return $DB->record_exists_sql($sql, array('courseworkid' => $courseworkid, 'now' => time())); + return $DB->record_exists_sql($sql, array('courseworkid' => $courseworkid, 'now' => time())); } diff --git a/mod_form.php b/mod_form.php index a2caea1b..d584ca28 100644 --- a/mod_form.php +++ b/mod_form.php @@ -69,13 +69,13 @@ public function definition() { $this->add_submission_deadline_field(); $this->add_personal_deadline_field(); - // if (coursework_is_ulcc_digest_coursework_plugin_installed()) { + // if (coursework_is_ulcc_digest_coursework_plugin_installed()) { $this->add_marking_deadline_field(); $this->add_initial_marking_deadline_field(); $this->add_agreed_grade_marking_deadline_field(); $this->add_relative_initial_marking_deadline_field(); $this->add_relative_agreed_grade_marking_deadline_field(); - // } + // } $this->add_allow_early_finalisation_field(); $this->add_allow_late_submissions_field(); @@ -191,11 +191,11 @@ public function validation($data, $files) { $errors = []; - if ($data['startdate'] != 0 && !empty($data['deadline']) && $data['startdate'] > $data['deadline']) { - $errors['startdate'] = get_string('must_be_before_dealdine', 'mod_coursework'); - } + if ($data['startdate'] != 0 && !empty($data['deadline']) && $data['startdate'] > $data['deadline']) { + $errors['startdate'] = get_string('must_be_before_dealdine', 'mod_coursework'); + } - if ($data['individualfeedback'] != 0 && !empty($data['deadline']) && $data['individualfeedback'] < $data['deadline']) { + if ($data['individualfeedback'] != 0 && !empty($data['deadline']) && $data['individualfeedback'] < $data['deadline']) { $errors['individualfeedback'] = get_string('must_be_after_dealdine', 'mod_coursework'); } @@ -262,7 +262,7 @@ function get_data() { } if ($this->forceblindmarking() == 1) { - $data->blindmarking = $CFG->coursework_blindmarking; + $data->blindmarking = $CFG->coursework_blindmarking; } if ($data->numberofmarkers > 1) { @@ -522,7 +522,7 @@ protected function add_agreed_grade_marking_deadline_field() { array('optional' => true, 'disabled' => $disabled) ); - // $moodle_form->disabledIf('agreedgrademarkingdeadline', 'numberofmarkers', 'eq', '1'); + // $moodle_form->disabledIf('agreedgrademarkingdeadline', 'numberofmarkers', 'eq', '1'); if (!empty($CFG->coursework_agreed_marking_deadline)) $moodle_form->setDefault('agreedgrademarkingdeadline', $default_timestamp); $moodle_form->addHelpButton('agreedgrademarkingdeadline', 'agreedgrademarkingdeadline', 'mod_coursework'); @@ -715,7 +715,7 @@ protected function add_max_file_size_field() { get_string('maximumsize', 'coursework'), $choices); $moodle_form->setDefault('maxbytes', $CFG->coursework_maxbytes); - /* $moodle_form->addElement('static', + /* $moodle_form->addElement('static', 'maxbyteslabel', '', get_string('maximumsizelabel', 'coursework'));*/ @@ -1039,7 +1039,7 @@ protected function add_individual_feedback_release_date_field() { $moodle_form->disabledIf('individualfeedback', 'forceautorelease', 'eq', 1); } $moodle_form->disabledIf('individualfeedback', 'deadline[enabled]', 'notchecked'); -// $moodle_form->addRule(array('individualfeedback', 'deadline'), get_string('must_be_after_dealdine', 'mod_coursework'), 'compare', 'gt'); + // $moodle_form->addRule(array('individualfeedback', 'deadline'), get_string('must_be_after_dealdine', 'mod_coursework'), 'compare', 'gt'); } /** @@ -1112,16 +1112,16 @@ protected function add_tweaks_to_standard_grading_form_elements() { $moodle_form->disabledIf('finalstagegrading', 'feedbackexists', 'eq', 1); // Don't think this belongs here... -// $options = array(0 => get_string('no'), 1 => get_string('yes')); -// $moodle_form->addElement('select', 'automaticagreement', get_string('automaticagreement', 'mod_coursework'), $options); -// $moodle_form->addHelpButton('automaticagreement', 'automaticagreement', 'mod_coursework'); -// $moodle_form->setDefault('automaticagreement',0); -// $moodle_form->disabledIf('automaticagreement', 'numberofmarkers', 'eq', '1'); -// -// $moodle_form->addElement('text', 'automaticagreementrange', get_string('automaticagreementrange', 'mod_coursework'), array('size' => 3)); -// $moodle_form->addHelpButton('automaticagreementrange', 'automaticagreementrange', 'mod_coursework'); -// $moodle_form->setDefault('automaticagreementrange',0); -// $moodle_form->disabledIf('automaticagreementrange', 'automaticagreement', 'eq', '0'); + // $options = array(0 => get_string('no'), 1 => get_string('yes')); + // $moodle_form->addElement('select', 'automaticagreement', get_string('automaticagreement', 'mod_coursework'), $options); + // $moodle_form->addHelpButton('automaticagreement', 'automaticagreement', 'mod_coursework'); + // $moodle_form->setDefault('automaticagreement',0); + // $moodle_form->disabledIf('automaticagreement', 'numberofmarkers', 'eq', '1'); + // + // $moodle_form->addElement('text', 'automaticagreementrange', get_string('automaticagreementrange', 'mod_coursework'), array('size' => 3)); + // $moodle_form->addHelpButton('automaticagreementrange', 'automaticagreementrange', 'mod_coursework'); + // $moodle_form->setDefault('automaticagreementrange',0); + // $moodle_form->disabledIf('automaticagreementrange', 'automaticagreement', 'eq', '0'); } diff --git a/module.js b/module.js index fa58cc59..7f055c72 100644 --- a/module.js +++ b/module.js @@ -540,7 +540,7 @@ M.mod_coursework = { $('#selectedtype').val('unfinalise'); - $('#coursework_personal_deadline_form').submit(); + $('#coursework_personal_deadline_form').submit(); } else { alert('You must make at least one selection'); } diff --git a/renderers/object_renderer.php b/renderers/object_renderer.php index ae12d656..f7e6f71f 100644 --- a/renderers/object_renderer.php +++ b/renderers/object_renderer.php @@ -791,10 +791,10 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin $comma = ""; - for ($i = 0; $i <= $samplingwidget->get_coursework()->grade; $i++) { - $scale .= $comma.$i; - $comma = ","; - } + for ($i = 0; $i <= $samplingwidget->get_coursework()->grade; $i++) { + $scale .= $comma.$i; + $comma = ","; + } } else { $grade_scale = \grade_scale::fetch(array('id' => abs($samplingwidget->get_coursework()->grade))); $scale = $grade_scale->scale; @@ -1100,7 +1100,7 @@ protected function get_sampling_strategy_form_elements($coursework, $assessor_nu //$fullclasspaths = glob($classdir . '/*.php'); foreach ($sampleplugins as $plugin) { - /* if (strpos($fullclassname, 'base') !== false) { + /* if (strpos($fullclassname, 'base') !== false) { continue; }*/ preg_match('/([^\/]+).php/', $classdir."/".$plugin->rulename.".php", $matches); @@ -1792,22 +1792,22 @@ 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) { - $submission = submission::find($sub); - $gradeblesub[$submission->id] = $submission; - } + foreach ($submissions as $sub) { + $submission = submission::find($sub); + $gradeblesub[$submission->id] = $submission; + } - } else { - foreach ($submissions as $sub) { - $submission = submission::find($sub); - if ($coursework->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) || (has_capability('mod/coursework:addagreedgrade', $coursework->get_context())) - && !empty($submission) && (($submission->all_inital_graded() && !$submission->get_coursework()->sampling_enabled()) - || ($submission->get_coursework()->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() > 1))) { + } else { + foreach ($submissions as $sub) { + $submission = submission::find($sub); + if ($coursework->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) || (has_capability('mod/coursework:addagreedgrade', $coursework->get_context())) + && !empty($submission) && (($submission->all_inital_graded() && !$submission->get_coursework()->sampling_enabled()) + || ($submission->get_coursework()->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() > 1))) { - $gradeblesub[$submission->id] = $submission; - } + $gradeblesub[$submission->id] = $submission; } } + } return $gradeblesub; } diff --git a/renderers/page_renderer.php b/renderers/page_renderer.php index 44c11990..0f20ecab 100644 --- a/renderers/page_renderer.php +++ b/renderers/page_renderer.php @@ -381,7 +381,7 @@ public function new_feedback_page($new_feedback, $ajax = false) { $feedbackcomment = ''; $count = 1; foreach ($initial_feedbacks as $initial_feedback) { - // put all initial feedbacks together for the comment field + // put all initial feedbacks together for the comment field $feedbackcomment .= get_string('assessorcomments', 'mod_coursework', $count); $feedbackcomment .= $initial_feedback->feedbackcomment; $feedbackcomment .= '
'; @@ -1226,10 +1226,10 @@ function process_csv_upload($processingresults, $csvcontent, $csvtype) { if (!is_array($processingresults)) { $html .= $processingresults . "
"; } else { - foreach ($processingresults as $line => $error) { - $line = $line + 1; - if ($error !== true) $html .= "Record " . $line . ": " . $error . "
"; - } + foreach ($processingresults as $line => $error) { + $line = $line + 1; + if ($error !== true) $html .= "Record " . $line . ": " . $error . "
"; + } } $html .= html_writer::end_tag('p'); } else { diff --git a/settings.php b/settings.php index b6ec8765..996c28b1 100644 --- a/settings.php +++ b/settings.php @@ -169,7 +169,7 @@ get_string('maximum_extension_deadline_desc', 'coursework'), 18, PARAM_INT, 2)); - // Default per page + // Default per page $options = array('3' => '3', '10' => '10', '20' => '20', '30' => '30', '40' => '40', '50' => '50', '100' => '100'); diff --git a/tests/behat/behat_mod_coursework.php b/tests/behat/behat_mod_coursework.php index 39f3279b..daf618a1 100644 --- a/tests/behat/behat_mod_coursework.php +++ b/tests/behat/behat_mod_coursework.php @@ -1935,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()); + // } } /** @@ -2106,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()); + // } } /** @@ -2319,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 { @@ -2757,7 +2757,7 @@ private function open_html_page($file_and_path) { public function iClickOnShowAllStudentsButton() { //$this->find('id', "id_displayallstudentbutton")->click(); $page = $this->get_page('coursework page'); - // $page->clickLink("Show submissions for other students"); + // $page->clickLink("Show submissions for other students"); $page->show_hide_non_allocated_students(); @@ -2897,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) { -// -// $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); -// } -// } -// } + // 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); + // + // $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/multiple_grading_interface.php b/tests/behat/pages/multiple_grading_interface.php index e359ed4c..14d9bd49 100644 --- a/tests/behat/pages/multiple_grading_interface.php +++ b/tests/behat/pages/multiple_grading_interface.php @@ -191,7 +191,7 @@ public function confirm_publish_action() { if ($this->getPage()->hasButton('Continue')) { $this->getPage()->pressButton('Continue'); } else { -echo "failed"; + echo "failed"; } if ($this->getPage()->hasLink('Continue')) { @@ -316,10 +316,10 @@ protected function new_feedback_button_css($submission) { * @return string */ public function get_provisional_grade_field($submission) { - $elementid = '#allocatable_' . $submission->get_coursework() + $elementid = '#allocatable_' . $submission->get_coursework() ->get_allocatable_identifier_hash($submission->get_allocatable()). ' .assessor_feedback_grade'; - $grade_field = $this->getPage()->find('css', $elementid); - return $grade_field ? $grade_field->getValue() : false; + $grade_field = $this->getPage()->find('css', $elementid); + return $grade_field ? $grade_field->getValue() : false; } /** diff --git a/tests/behat/pages/student_page.php b/tests/behat/pages/student_page.php index 77907b4e..eeb535b9 100644 --- a/tests/behat/pages/student_page.php +++ b/tests/behat/pages/student_page.php @@ -98,8 +98,8 @@ public function should_have_visible_feedback($feedback_text) { } public function click_on_the_edit_submission_button() { - $locator = "//div[@class='editsubmissionbutton']"; - $this->pressButtonXpath($locator); + $locator = "//div[@class='editsubmissionbutton']"; + $this->pressButtonXpath($locator); } public function click_on_the_finalise_submission_button() { diff --git a/tests/classes/export/csv_test.php b/tests/classes/export/csv_test.php index d1b15e07..a85092bb 100644 --- a/tests/classes/export/csv_test.php +++ b/tests/classes/export/csv_test.php @@ -46,7 +46,7 @@ public function setUp():void { $this->course = $this->getDataGenerator()->create_course(); - // $generator = $this->getDataGenerator()->get_plugin_generator('mod_coursework'); + // $generator = $this->getDataGenerator()->get_plugin_generator('mod_coursework'); $this->setAdminUser(); $this->student = $this->create_a_student(); @@ -123,7 +123,7 @@ public function test_one_stage() { $csv = new \mod_coursework\export\csv($this->coursework, $csv_cells, $filename); $csv_grades = $csv->add_cells_to_array($submission, $student, $csv_cells); - // build an array + // build an array $studentname = $student->lastname .' '.$student->firstname; $assessorname = $assessor->lastname .' '. $assessor->firstname; $assessorusername = $assessor->username; diff --git a/view.php b/view.php index 90805981..af5a7c82 100644 --- a/view.php +++ b/view.php @@ -339,7 +339,7 @@ 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;