fix score submission, and class progress
This commit is contained in:
@@ -383,13 +383,18 @@ class ClassProgressController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sundayOptions = $this->buildSundayOptions();
|
||||||
|
if (!in_array($row['week_start'], $sundayOptions, true)) {
|
||||||
|
array_unshift($sundayOptions, $row['week_start']);
|
||||||
|
}
|
||||||
|
|
||||||
return view('teacher/class_progress_submit', [
|
return view('teacher/class_progress_submit', [
|
||||||
'subjectSections' => self::SUBJECT_SECTIONS,
|
'subjectSections' => self::SUBJECT_SECTIONS,
|
||||||
'subjectCurriculum' => $subjectCurriculum,
|
'subjectCurriculum' => $subjectCurriculum,
|
||||||
'classSectionId' => $row['class_section_id'],
|
'classSectionId' => $row['class_section_id'],
|
||||||
'classSectionName' => $classSectionName,
|
'classSectionName' => $classSectionName,
|
||||||
'classId' => $classId,
|
'classId' => $classId,
|
||||||
'sundayOptions' => [$row['week_start']],
|
'sundayOptions' => $sundayOptions,
|
||||||
'defaultWeekStart' => $row['week_start'],
|
'defaultWeekStart' => $row['week_start'],
|
||||||
'existingWeekEnd' => $row['week_end'],
|
'existingWeekEnd' => $row['week_end'],
|
||||||
'existingReports' => $subjectReports,
|
'existingReports' => $subjectReports,
|
||||||
@@ -458,6 +463,32 @@ class ClassProgressController extends BaseController
|
|||||||
return redirect()->back()->withInput()->with('error', 'No class assignment found for this report.');
|
return redirect()->back()->withInput()->with('error', 'No class assignment found for this report.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$confirmOverwrite = (bool) $this->request->getPost('confirm_overwrite');
|
||||||
|
if ($weekStart && $weekStart !== (string) ($row['week_start'] ?? '')) {
|
||||||
|
$conflicts = $this->reportModel
|
||||||
|
->select('id')
|
||||||
|
->where('class_section_id', $classSectionId)
|
||||||
|
->where('week_start', $weekStart)
|
||||||
|
->where('teacher_id', $teacherId)
|
||||||
|
->findAll();
|
||||||
|
if (! $confirmOverwrite && ! empty($conflicts)) {
|
||||||
|
return redirect()->back()
|
||||||
|
->withInput()
|
||||||
|
->with('warning', 'A progress report already exists for this week, are you sure you want to override it?')
|
||||||
|
->with('confirm_overwrite', true);
|
||||||
|
}
|
||||||
|
if ($confirmOverwrite && ! empty($conflicts)) {
|
||||||
|
$conflictIds = array_values(array_filter(array_map(
|
||||||
|
static fn (array $row): int => (int) ($row['id'] ?? 0),
|
||||||
|
$conflicts
|
||||||
|
)));
|
||||||
|
if (! empty($conflictIds)) {
|
||||||
|
$this->attachmentModel->whereIn('report_id', $conflictIds)->delete();
|
||||||
|
$this->reportModel->whereIn('id', $conflictIds)->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$weeklyReports = $this->reportModel
|
$weeklyReports = $this->reportModel
|
||||||
->select('class_progress_reports.*')
|
->select('class_progress_reports.*')
|
||||||
->whereIn('teacher_id', $allowedTeacherIds)
|
->whereIn('teacher_id', $allowedTeacherIds)
|
||||||
|
|||||||
@@ -1287,14 +1287,14 @@ class ScoreController extends Controller
|
|||||||
public function viewStudentScore()
|
public function viewStudentScore()
|
||||||
{
|
{
|
||||||
$parentId = session()->get('user_id');
|
$parentId = session()->get('user_id');
|
||||||
$userType = $_SESSION['user_type'];
|
$userType = session()->get('user_type') ?? '';
|
||||||
$firstParentId = null;
|
$firstParentId = null;
|
||||||
$releaseFall = $this->getParentScoresReleasedForSemester('Fall');
|
$releaseFall = $this->getParentScoresReleasedForSemester('Fall');
|
||||||
$releaseSpring = $this->getParentScoresReleasedForSemester('Spring');
|
$releaseSpring = $this->getParentScoresReleasedForSemester('Spring');
|
||||||
$releaseAny = $releaseFall || $releaseSpring;
|
$releaseAny = $releaseFall || $releaseSpring;
|
||||||
|
|
||||||
// Identify the firstparent based on user type
|
// Identify the firstparent based on user type
|
||||||
if ($userType === 'primary') {
|
if ($userType === 'primary' || $userType === '') {
|
||||||
$firstParentId = $parentId;
|
$firstParentId = $parentId;
|
||||||
} elseif ($userType === 'secondary') {
|
} elseif ($userType === 'secondary') {
|
||||||
$parentData = $this->db->table('parents')
|
$parentData = $this->db->table('parents')
|
||||||
|
|||||||
@@ -77,21 +77,8 @@
|
|||||||
<div class="card shadow-sm mb-3">
|
<div class="card shadow-sm mb-3">
|
||||||
<div class="card-header bg-white d-flex flex-wrap align-items-center justify-content-between gap-3">
|
<div class="card-header bg-white d-flex flex-wrap align-items-center justify-content-between gap-3">
|
||||||
<strong class="mb-0">Date Selection</strong>
|
<strong class="mb-0">Date Selection</strong>
|
||||||
<?php if ($isEdit): ?>
|
|
||||||
<div class="text-muted small">
|
|
||||||
<?php
|
|
||||||
try {
|
|
||||||
$displayStart = (new \DateTime($weekStartSelected))->format('M d, Y');
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$displayStart = $weekStartSelected;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
Week of <?= esc($displayStart ?: 'N/A') ?>
|
|
||||||
</div>
|
|
||||||
<input type="hidden" name="week_start" value="<?= esc($weekStartSelected) ?>">
|
|
||||||
<?php else: ?>
|
|
||||||
<div class="d-flex align-items-center gap-2">
|
<div class="d-flex align-items-center gap-2">
|
||||||
<select id="weekStartSelect" name="week_start" class="form-select form-select-sm" required>
|
<select id="weekStartSelect" name="week_start" class="form-select form-select-sm" required <?= $isEdit ? 'data-original-week="' . esc($weekStartSelected) . '"' : '' ?>>
|
||||||
<option value="">Select week</option>
|
<option value="">Select week</option>
|
||||||
<?php foreach ($sundayOptions as $sunday): ?>
|
<?php foreach ($sundayOptions as $sunday): ?>
|
||||||
<?php
|
<?php
|
||||||
@@ -109,7 +96,6 @@
|
|||||||
</select>
|
</select>
|
||||||
<div class="invalid-feedback">Week start is required.</div>
|
<div class="invalid-feedback">Week start is required.</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<input type="hidden" name="week_end" id="weekEndInput" value="<?= esc($weekEndValue) ?>" required>
|
<input type="hidden" name="week_end" id="weekEndInput" value="<?= esc($weekEndValue) ?>" required>
|
||||||
@@ -306,6 +292,19 @@
|
|||||||
const forms = document.querySelectorAll('.needs-validation');
|
const forms = document.querySelectorAll('.needs-validation');
|
||||||
Array.from(forms).forEach(form => {
|
Array.from(forms).forEach(form => {
|
||||||
form.addEventListener('submit', event => {
|
form.addEventListener('submit', event => {
|
||||||
|
const originalWeek = weekStartSelect?.dataset.originalWeek || '';
|
||||||
|
if (originalWeek && weekStartSelect && weekStartSelect.value && weekStartSelect.value !== originalWeek) {
|
||||||
|
const ok = confirm('A progress report already exists for the original week. Change the week and override any existing report for the new date?');
|
||||||
|
if (!ok) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const confirmInput = document.getElementById('confirmOverwriteInput');
|
||||||
|
if (confirmInput) {
|
||||||
|
confirmInput.value = '1';
|
||||||
|
}
|
||||||
|
}
|
||||||
const islamicUnits = form.querySelectorAll('input[name="unit_islamic[]"]');
|
const islamicUnits = form.querySelectorAll('input[name="unit_islamic[]"]');
|
||||||
const hasIslamicUnit = Array.from(islamicUnits).some(input => input.value.trim() !== '');
|
const hasIslamicUnit = Array.from(islamicUnits).some(input => input.value.trim() !== '');
|
||||||
if (!hasIslamicUnit) {
|
if (!hasIslamicUnit) {
|
||||||
|
|||||||
@@ -308,6 +308,7 @@
|
|||||||
id="submitScoresLockBtn"
|
id="submitScoresLockBtn"
|
||||||
formaction="<?= base_url('/teacher/submit-scores-lock') ?>"
|
formaction="<?= base_url('/teacher/submit-scores-lock') ?>"
|
||||||
formmethod="post"
|
formmethod="post"
|
||||||
|
data-confirm-message="Once you submit, you cannot add any scores or comments. Do you want to continue?"
|
||||||
<?= $scoresLocked ? 'disabled' : '' ?>>
|
<?= $scoresLocked ? 'disabled' : '' ?>>
|
||||||
<?= $scoresLocked ? 'Scores Locked' : 'Submit Semester Scores' ?>
|
<?= $scoresLocked ? 'Scores Locked' : 'Submit Semester Scores' ?>
|
||||||
</button>
|
</button>
|
||||||
@@ -430,6 +431,14 @@
|
|||||||
|
|
||||||
form.addEventListener('submit', function(event) {
|
form.addEventListener('submit', function(event) {
|
||||||
syncCsrfToken();
|
syncCsrfToken();
|
||||||
|
const submitter = event.submitter;
|
||||||
|
if (submitter && submitter.id === 'submitScoresLockBtn') {
|
||||||
|
const message = submitter.dataset.confirmMessage || 'Submit semester scores?';
|
||||||
|
if (!confirm(message)) {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
const errors = [];
|
const errors = [];
|
||||||
form.querySelectorAll('textarea[data-first-name]').forEach(function(field) {
|
form.querySelectorAll('textarea[data-first-name]').forEach(function(field) {
|
||||||
const value = field.value.trim();
|
const value = field.value.trim();
|
||||||
|
|||||||
Reference in New Issue
Block a user