score submit fix for spring semester

This commit is contained in:
root
2026-02-27 15:26:23 -05:00
parent 3cc5546733
commit 253be573ac
3 changed files with 45 additions and 2 deletions
+31
View File
@@ -339,6 +339,37 @@ class ScoreController extends Controller
);
}
try {
$students = $this->getStudentScores($classSectionId, $semester, $schoolYear, $teacherId);
} catch (\Throwable $e) {
log_message('error', 'ScoreController::submitScoresLock missing check failed: ' . $e->getMessage());
return redirect()->back()->with('error', 'Unable to validate missing scores. Please try again.');
}
$missingRows = [];
foreach ($students as $student) {
$missingItems = $student['missing_items'] ?? [];
if (empty($missingItems)) {
continue;
}
$studentId = (int) ($student['student_id'] ?? 0);
$studentName = trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? ''));
if ($studentName === '') {
$studentName = $studentId > 0 ? ('Student #' . $studentId) : 'Student';
}
$missingRows[] = $studentName . ': ' . implode(', ', $missingItems);
}
if (!empty($missingRows)) {
$sample = array_slice($missingRows, 0, 8);
$message = sprintf(
'Missing entries found for %d student(s). Fill them or mark "Missing ok" before submitting. %s',
count($missingRows),
$sample ? ('Examples: ' . implode(' | ', $sample)) : ''
);
return redirect()->back()->with('error', trim($message));
}
$existing = $this->gradingLockModel->getLock($classSectionId, $semester, $schoolYear);
if (!empty($existing) && !empty($existing['is_locked'])) {
return redirect()->back()->with('status', 'Scores already submitted and locked.');