fix parent and teacher pages to follow year filter
Tests / PHPUnit (push) Failing after 1m15s

This commit is contained in:
root
2026-07-15 20:03:36 -04:00
parent feb1b29a32
commit 5f27dccd0f
32 changed files with 582 additions and 364 deletions
+12 -2
View File
@@ -1,12 +1,17 @@
<?= $this->extend('layout/main_layout') ?>
<?= $this->section('content') ?>
<?php $isSchoolYearReadonly = (bool) ($isSchoolYearReadonly ?? false); ?>
<div class="container py-4">
<div class="d-flex align-items-center justify-content-between mb-3">
<div>
<h3 class="mb-0">Class Progress Reports</h3>
<div class="text-muted">Review weekly submissions and compare Islamic Studies with Quran/Arabic.</div>
</div>
<a href="<?= base_url('teacher/progress/submit') ?>" class="btn btn-outline-secondary">Submit New Report</a>
<?php if ($isSchoolYearReadonly): ?>
<span class="btn btn-outline-secondary disabled" aria-disabled="true">Submit New Report</span>
<?php else: ?>
<a href="<?= base_url('teacher/progress/submit') ?>" class="btn btn-outline-secondary">Submit New Report</a>
<?php endif; ?>
</div>
<?php
@@ -15,6 +20,9 @@
$classSectionOptions = $classSectionOptions ?? [];
$selectedSectionId = $selectedSectionId ?? null;
?>
<?php if ($isSchoolYearReadonly): ?>
<div class="alert alert-warning">This school year is read-only. Progress submissions can be viewed but not changed.</div>
<?php endif; ?>
<?php if (!empty($classSectionOptions)): ?>
<form method="get" class="mb-3 row g-2 align-items-center">
<div class="col-auto">
@@ -90,7 +98,9 @@
<td class="text-end">
<?php if ($exampleReport): ?>
<a href="<?= base_url('teacher/progress/view/' . $exampleReport['id']) ?>" class="btn btn-sm btn-outline-primary">View Weekly Details</a>
<a href="<?= base_url('teacher/progress/edit/' . $exampleReport['id']) ?>" class="btn btn-sm btn-outline-secondary ms-1">Edit</a>
<?php if (!$isSchoolYearReadonly): ?>
<a href="<?= base_url('teacher/progress/edit/' . $exampleReport['id']) ?>" class="btn btn-sm btn-outline-secondary ms-1">Edit</a>
<?php endif; ?>
<?php endif; ?>
</td>
</tr>
+13 -7
View File
@@ -11,6 +11,7 @@
$weekStartSelected = set_value('week_start', $defaultWeekStart);
$weekEndValue = set_value('week_end', $existingWeekEnd ?? '');
$existingReports = $existingReports ?? [];
$isSchoolYearReadonly = (bool) ($isSchoolYearReadonly ?? false);
if (!$weekEndValue && $weekStartSelected) {
try {
$dt = new \DateTime($weekStartSelected);
@@ -58,6 +59,9 @@
<?php if (session()->getFlashdata('error')): ?>
<div class="alert alert-danger"><?= esc(session()->getFlashdata('error')) ?></div>
<?php endif; ?>
<?php if ($isSchoolYearReadonly): ?>
<div class="alert alert-warning">This school year is read-only. Progress submissions are disabled.</div>
<?php endif; ?>
<?php if (session()->getFlashdata('errors')): ?>
<div class="alert alert-danger">
<ul class="mb-0">
@@ -142,7 +146,8 @@
<button type="button"
class="btn btn-sm btn-outline-dark"
data-add-unit-chapter
data-subject="<?= esc($slug) ?>">
data-subject="<?= esc($slug) ?>"
<?= $isSchoolYearReadonly ? 'disabled' : '' ?>>
<?= $slug === 'quran' ? '+ Add Surah, Arabic Subject' : '+ Add Unit, Chapter' ?>
</button>
<div class="subject-curriculum-list position-absolute d-none border rounded shadow-sm bg-white mt-1" id="curriculumList-<?= esc($slug) ?>" style="min-width: 220px; z-index: 5;">
@@ -170,7 +175,8 @@
data-subject="<?= esc($slug) ?>"
data-unit-number="<?= esc($unitNumber) ?>"
data-unit-title="<?= esc($unitTitle) ?>"
data-chapter="<?= esc($chapterName) ?>">
data-chapter="<?= esc($chapterName) ?>"
<?= $isSchoolYearReadonly ? 'disabled' : '' ?>>
<?= esc($display) ?>
</button>
<?php endforeach; ?>
@@ -179,7 +185,7 @@
<div class="px-2 py-2 border-top">
<div class="input-group input-group-sm">
<input type="text" class="form-control" placeholder="Custom Surah" data-custom-input data-subject="<?= esc($slug) ?>">
<button type="button" class="btn btn-outline-secondary" data-custom-entry data-subject="<?= esc($slug) ?>">Add</button>
<button type="button" class="btn btn-outline-secondary" data-custom-entry data-subject="<?= esc($slug) ?>" <?= $isSchoolYearReadonly ? 'disabled' : '' ?>>Add</button>
</div>
<div class="form-text small text-muted">Add a custom Surah or Arabic target.</div>
</div>
@@ -187,7 +193,7 @@
<div class="px-2 py-2 border-top">
<div class="input-group input-group-sm">
<input type="text" class="form-control" placeholder="Type subject or topic" data-custom-input data-subject="<?= esc($slug) ?>">
<button type="button" class="btn btn-outline-secondary" data-custom-entry data-subject="<?= esc($slug) ?>">Add</button>
<button type="button" class="btn btn-outline-secondary" data-custom-entry data-subject="<?= esc($slug) ?>" <?= $isSchoolYearReadonly ? 'disabled' : '' ?>>Add</button>
</div>
<div class="form-text small text-muted">Add a subject or unit not listed above (e.g. Seerah, Fiqh, Akhlaq).</div>
</div>
@@ -206,7 +212,7 @@
<input type="text" name="chapter_<?= esc($slug) ?>[]" class="form-control form-control-sm" placeholder="Chapter" value="<?= esc($chapterValues[$i] ?? '') ?>" readonly>
</div>
<div class="col-auto">
<button type="button" class="btn btn-outline-danger btn-sm" data-remove-unit-chapter aria-label="Remove entry">X</button>
<button type="button" class="btn btn-outline-danger btn-sm" data-remove-unit-chapter aria-label="Remove entry" <?= $isSchoolYearReadonly ? 'disabled' : '' ?>>X</button>
</div>
</div>
<?php endfor; ?>
@@ -232,7 +238,7 @@
<div class="col">
<div class="card shadow-sm">
<div class="card-body d-flex flex-column">
<button class="btn btn-primary w-100 mt-auto" type="submit" <?= $hasClass ? '' : 'disabled' ?>><?= esc($submitLabel) ?></button>
<button class="btn btn-primary w-100 mt-auto" type="submit" <?= ($hasClass && !$isSchoolYearReadonly) ? '' : 'disabled' ?>><?= esc($submitLabel) ?></button>
<?php if (! $hasClass): ?>
<div class="text-muted small mt-2">
You are not assigned to a class. Contact the administrator to submit progress.
@@ -288,7 +294,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="confirmOverwriteButton">Override</button>
<button type="button" class="btn btn-primary" id="confirmOverwriteButton" <?= $isSchoolYearReadonly ? 'disabled' : '' ?>>Override</button>
</div>
</div>
</div>
+10 -4
View File
@@ -10,6 +10,7 @@ $examTypes = $examTypes ?? [];
$schoolYear = $schoolYear ?? '';
$semester = $semester ?? '';
$maxUploadBytes = $maxUploadBytes ?? (12 * 1024 * 1024);
$isSchoolYearReadonly = (bool) ($isSchoolYearReadonly ?? false);
?>
<style>
.teacher-drafts-page,
@@ -48,6 +49,11 @@ $maxUploadBytes = $maxUploadBytes ?? (12 * 1024 * 1024);
<?php if (session()->getFlashdata('error')): ?>
<div class="alert alert-danger"><?= esc(session()->getFlashdata('error')) ?></div>
<?php endif; ?>
<?php if ($isSchoolYearReadonly): ?>
<div class="alert alert-warning">
This school year is read-only. Exam draft submissions are disabled.
</div>
<?php endif; ?>
<div class="card mb-4">
<div class="card-body">
@@ -55,7 +61,7 @@ $maxUploadBytes = $maxUploadBytes ?? (12 * 1024 * 1024);
<?= csrf_field() ?>
<div class="col-md-6">
<label class="form-label" for="exam_type">Exam type <span class="text-danger">*</span></label>
<select name="exam_type" id="exam_type" class="form-select" required>
<select name="exam_type" id="exam_type" class="form-select" required <?= $isSchoolYearReadonly ? 'disabled' : '' ?>>
<option value="">— Select —</option>
<?php foreach ($examTypes as $t): ?>
<option value="<?= esc($t) ?>" <?= old('exam_type') === $t ? 'selected' : '' ?>><?= esc($t) ?></option>
@@ -64,15 +70,15 @@ $maxUploadBytes = $maxUploadBytes ?? (12 * 1024 * 1024);
</div>
<div class="col-8">
<label class="form-label" for="author_comment">Author comment</label>
<textarea name="author_comment" id="author_comment" class="form-control" rows="2" placeholder="Optional note for reviewers"><?= esc(old('author_comment') ?? '') ?></textarea>
<textarea name="author_comment" id="author_comment" class="form-control" rows="2" placeholder="Optional note for reviewers" <?= $isSchoolYearReadonly ? 'disabled' : '' ?>><?= esc(old('author_comment') ?? '') ?></textarea>
</div>
<div class="col-md-8">
<label class="form-label" for="draft_file">File (Word) <span class="text-danger">*</span></label>
<input type="file" name="draft_file" id="draft_file" class="form-control" accept=".doc,.docx" required>
<input type="file" name="draft_file" id="draft_file" class="form-control" accept=".doc,.docx" required <?= $isSchoolYearReadonly ? 'disabled' : '' ?>>
<div class="form-text">Max <?= esc(number_format($maxUploadBytes / 1048576, 1)) ?> MB.</div>
</div>
<div class="col-12 d-flex flex-wrap gap-2">
<button type="submit" class="btn btn-primary">Submit for review</button>
<button type="submit" class="btn btn-primary" <?= $isSchoolYearReadonly ? 'disabled' : '' ?>>Submit for review</button>
</div>
<?= form_close() ?>
<?php if ($schoolYear !== '' || $semester !== ''): ?>
+30 -8
View File
@@ -32,7 +32,9 @@
<?php
$classSectionId = (int)($class_section_id ?? 0);
$scoresLocked = !empty($scoresLocked);
$lockAttr = $scoresLocked ? 'disabled' : '';
$isSchoolYearReadonly = !empty($isSchoolYearReadonly);
$editingDisabled = $scoresLocked || $isSchoolYearReadonly;
$lockAttr = $editingDisabled ? 'disabled' : '';
$displayScore = static function ($value) {
return ($value === null || $value === '') ? '' : esc($value);
};
@@ -94,6 +96,11 @@
Scores are submitted and locked for this semester.
</div>
<?php endif; ?>
<?php if ($isSchoolYearReadonly): ?>
<div class="alert alert-info mt-3 mb-0">
This school year is read-only. You can view scores, but changes are disabled.
</div>
<?php endif; ?>
<div class="mt-3">
<a href="<?= base_url('/teacher/scores?choose_semester=1') ?>" class="btn btn-outline-secondary btn-sm">Choose another semester</a>
</div>
@@ -291,14 +298,29 @@
</div>
<div class="scores-action-bar d-flex flex-wrap gap-2 mt-3">
<a href="<?= base_url('/teacher/addHomework?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Homework</a>
<a href="<?= base_url('/teacher/addQuiz?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Quiz</a>
<a href="<?= base_url('/teacher/addProject?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Project</a>
<a href="<?= base_url('/teacher/addParticipation?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Participation</a>
<?php if ($isSchoolYearReadonly): ?>
<button type="button" class="btn btn-secondary" disabled>Add Homework</button>
<button type="button" class="btn btn-secondary" disabled>Add Quiz</button>
<button type="button" class="btn btn-secondary" disabled>Add Project</button>
<button type="button" class="btn btn-secondary" disabled>Add Participation</button>
<?php else: ?>
<a href="<?= base_url('/teacher/addHomework?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Homework</a>
<a href="<?= base_url('/teacher/addQuiz?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Quiz</a>
<a href="<?= base_url('/teacher/addProject?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Project</a>
<a href="<?= base_url('/teacher/addParticipation?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Participation</a>
<?php endif; ?>
<?php if ($semester === 'fall'): ?>
<a href="<?= base_url('/teacher/addMidtermExam?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Midterm</a>
<?php if ($isSchoolYearReadonly): ?>
<button type="button" class="btn btn-secondary" disabled>Add Midterm</button>
<?php else: ?>
<a href="<?= base_url('/teacher/addMidtermExam?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Midterm</a>
<?php endif; ?>
<?php elseif ($semester === 'spring'): ?>
<a href="<?= base_url('/teacher/addFinalExam?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Final</a>
<?php if ($isSchoolYearReadonly): ?>
<button type="button" class="btn btn-secondary" disabled>Add Final</button>
<?php else: ?>
<a href="<?= base_url('/teacher/addFinalExam?class_section_id=' . $classSectionId) ?>" class="btn btn-secondary">Add Final</a>
<?php endif; ?>
<?php endif; ?>
<button type="submit" class="btn btn-info" <?= $lockAttr ?>>Save Comments</button>
@@ -309,7 +331,7 @@
formaction="<?= base_url('/teacher/submit-scores-lock') ?>"
formmethod="post"
data-confirm-message="Once you submit, you cannot add any scores or comments. Do you want to continue?"
<?= $scoresLocked ? 'disabled' : '' ?>>
<?= $editingDisabled ? 'disabled' : '' ?>>
<?= $scoresLocked ? 'Scores Locked' : 'Submit Semester Scores' ?>
</button>
</div>