diff --git a/classes/export/csv/cells/agreedfeedback_cell.php b/classes/export/csv/cells/agreedfeedback_cell.php index dba213b..398ec64 100644 --- a/classes/export/csv/cells/agreedfeedback_cell.php +++ b/classes/export/csv/cells/agreedfeedback_cell.php @@ -48,16 +48,26 @@ public function get_cell($submission, $student, $stageidentifier) { * @throws \coding_exception */ public function get_header($stage) { - return get_string('agreedgradefeedback', 'coursework'); + return get_string('agreedgradefeedback', 'coursework'); } - public function validate_cell($value, $submissionid, $stageidentifier='', $uploadedgradecells = []) { - + /** + * Validate cell. + * @param string $value + * @param int $submissionid + * @param string $stageidentifier + * @param array $uploadedgradecells + * @return \lang_string|mixed|string|true + * @throws \coding_exception + * @throws \dml_exception + */ + public function validate_cell($value, $submissionid, $stageidentifier = '', $uploadedgradecells = []) { global $DB, $PAGE, $USER; - - $stageidentifier = 'final_agreed_1'; - $agreedgradecap = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', - 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade']; + $stageidentfinal = 'final_agreed_1'; + $agreedgradecap = [ + 'mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', + 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade', + ]; if (has_any_capability($agreedgradecap, $PAGE->context) || has_capability('mod/coursework:administergrades', $PAGE->context)) { @@ -70,12 +80,12 @@ public function validate_cell($value, $submissionid, $stageidentifier='', $uploa return get_string('submissionnotreadyforagreedgrade', 'coursework'); } - // Has the submission been published if yes then no further grades are allowed + // Has the submission been published if yes then no further grades are allowed. if ($submission->get_state() >= submission::PUBLISHED) { return $submission->get_status_text(); } - // If you have administer grades you can grade anything + // If you have administer grades you can grade anything. if (has_capability('mod/coursework:administergrades', $PAGE->context)) { return true; } @@ -83,39 +93,37 @@ public function validate_cell($value, $submissionid, $stageidentifier='', $uploa // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). $feedbackparams = [ 'submissionid' => $submission->id, - 'stage_identifier' => $stageidentifier, + 'stage_identifier' => $stageidentfinal, ]; $feedback = feedback::find($feedbackparams); $ability = new ability(user::find($USER), $this->coursework); - // Does a feedback exist for this stage + // Does a feedback exist for this stage. if (empty($feedback)) { $feedbackparams = [ 'submissionid' => $submissionid, 'assessorid' => $USER->id, - 'stage_identifier' => $stageidentifier, + 'stage_identifier' => $stageidentfinal, ]; $newfeedback = feedback::build($feedbackparams); - // This is a new feedback check it against the new ability checks - if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && !$ability->can('new', $newfeedback)) { + // This is a new feedback check it against the new ability checks. + if (!has_capability('mod/coursework:administergrades', $PAGE->context) + && !has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) + && !$ability->can('new', $newfeedback)) { return get_string('nopermissiontogradesubmission', 'coursework'); } } else { - // This is a new feedback check it against the edit ability checks + // This is a new feedback check it against the edit ability checks. if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) { return get_string('nopermissiontoeditgrade', 'coursework'); } } - } else { return get_string('nopermissiontoimportgrade', 'coursework'); } - return true; - } - } diff --git a/classes/export/csv/cells/feedbackcomments_cell.php b/classes/export/csv/cells/feedbackcomments_cell.php index 8cbb7ae..1e71625 100644 --- a/classes/export/csv/cells/feedbackcomments_cell.php +++ b/classes/export/csv/cells/feedbackcomments_cell.php @@ -40,9 +40,10 @@ class feedbackcomments_cell extends cell_base { */ public function get_cell($submission, $student, $stageidentifier) { - $stageidentifier = ($this->coursework->get_max_markers() == 1) - ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student); - $grade = $submission->get_assessor_feedback_by_stage($stageidentifier); + $stageident = ($this->coursework->get_max_markers() == 1) + ? "assessor_1" + : $this->get_stage_identifier_for_assessor($submission, $student); + $grade = $submission->get_assessor_feedback_by_stage($stageident); return (!$grade || !isset($grade->feedbackcomment)) ? '' : strip_tags($grade->feedbackcomment); } diff --git a/classes/export/csv/cells/singlegrade_cell.php b/classes/export/csv/cells/singlegrade_cell.php index 4b5fc0f..16f72c7 100644 --- a/classes/export/csv/cells/singlegrade_cell.php +++ b/classes/export/csv/cells/singlegrade_cell.php @@ -39,17 +39,16 @@ class singlegrade_cell extends cell_base { * @return array|mixed|null|string */ public function get_cell($submission, $student, $stageidentifier) { + $stageident = ($this->coursework->get_max_markers() == 1) + ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student); - $stageidentifier = ($this->coursework->get_max_markers() == 1) ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student); - - $grade = $submission->get_assessor_feedback_by_stage($stageidentifier); + $grade = $submission->get_assessor_feedback_by_stage($stageident); if ($this->coursework->is_using_rubric()) { $gradedata = []; - $this->get_rubric_scores_gradedata($grade, $gradedata); // multiple parts are handled here + $this->get_rubric_scores_gradedata($grade, $gradedata); // Multiple parts are handled here. } else { $gradedata = (!$grade) ? '' : $this->get_actual_grade($grade->grade); } - return $gradedata; }