Skip to content

Commit

Permalink
CTP-3796 avoid var names re-use
Browse files Browse the repository at this point in the history
  • Loading branch information
watson8 committed Sep 23, 2024
1 parent f2bf125 commit 3d94332
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 27 deletions.
46 changes: 27 additions & 19 deletions classes/export/csv/cells/agreedfeedback_cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -70,52 +80,50 @@ 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;
}

// 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;

}

}
7 changes: 4 additions & 3 deletions classes/export/csv/cells/feedbackcomments_cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
9 changes: 4 additions & 5 deletions classes/export/csv/cells/singlegrade_cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 3d94332

Please sign in to comment.