score submit fix for spring semester
This commit is contained in:
@@ -1 +1,2 @@
|
||||
*.log
|
||||
writable/session/
|
||||
|
||||
@@ -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.');
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user