score submit fix for spring semester
This commit is contained in:
@@ -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.');
|
||||
|
||||
Reference in New Issue
Block a user