Skip to content

Commit

Permalink
CTP-3700 undefined vars (ULCC#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
watson8 authored Oct 21, 2024
1 parent d9eebf3 commit 4e9c125
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions classes/allocation/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function validate_csv($content, $encoding, $delimeter) {
}

while ($line = $csvreader->next()) {
$allocatable = null;

$cells = $csvcells;
$assessorsinfile = [];
Expand Down Expand Up @@ -140,11 +141,17 @@ public function validate_csv($content, $encoding, $delimeter) {
$errors[$s] = get_string('assessornotincoursework', 'coursework', $keynum ); continue;
}

// check if current assessor is not already allocated for this allocatable in different stage
// or is not already in the file in previous stage
if ($assessor && ($this->coursework->assessor_has_allocation_for_student_not_in_current_stage($allocatable, $assessor->id, $cells[$keynum])
|| in_array($assessor->id, $assessorsinfile))) {
$errors[$s] = get_string('assessoralreadyallocated', 'coursework', $keynum); continue;
// Check if current assessor is not already allocated for this allocatable in different stage.
// Or is not already in the file in previous stage.
if ($assessor) {
$iserror = ($allocatable
&& $this->coursework->assessor_has_allocation_for_student_not_in_current_stage(
$allocatable, $assessor->id, $cells[$keynum])
)
|| in_array($assessor->id, $assessorsinfile);
if ($iserror) {
$errors[$s] = get_string('assessoralreadyallocated', 'coursework', $keynum); continue;
}
}
$assessorsinfile[] = $assessor->id;

Expand Down Expand Up @@ -216,6 +223,7 @@ public function process_csv($content, $encoding, $delimiter, $processingresults)
}

foreach ($line as $keynum => $value) {
$allocatable = null;

// create record in coursework_allocation_pairs
// or update it
Expand All @@ -233,7 +241,7 @@ public function process_csv($content, $encoding, $delimiter, $processingresults)
$allocatable = ($suballocatable) ? \mod_coursework\models\group::find($suballocatable->id) : '';
}
}
if (substr($cells[$keynum], 0, 8) == 'assessor' && !(empty($value))) {
if ($allocatable && substr($cells[$keynum], 0, 8) == 'assessor' && !(empty($value))) {

$assessor = $DB->get_record('user', [$assessoridentifier => $value]);

Expand Down

0 comments on commit 4e9c125

Please sign in to comment.