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
+1
View File
@@ -1 +1,2 @@
*.log
writable/session/
+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.');
+13 -2
View File
@@ -32,9 +32,20 @@ document.addEventListener('DOMContentLoaded', function () {
toggleCommentCheckbox(wrapper);
});
let lastSubmitterId = null;
form.addEventListener('click', function (event) {
const target = event.target.closest('button, input[type="submit"]');
if (!target || target.form !== form) return;
lastSubmitterId = target.id || null;
});
form.addEventListener('submit', function (event) {
const submitter = event.submitter;
if (!submitter || submitter.id !== 'submitScoresLockBtn') {
const activeEl = document.activeElement;
const submitterId = event.submitter
? event.submitter.id
: (activeEl && activeEl.form === form ? activeEl.id : lastSubmitterId);
lastSubmitterId = null;
if (submitterId !== 'submitScoresLockBtn') {
return;
}