fix assessment import and exams draft
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 51s
Tests / PHPUnit (push) Failing after 1m26s

This commit is contained in:
root
2026-09-12 02:39:47 -04:00
parent 4b2dd4bdf8
commit ce504c933e
7 changed files with 1397 additions and 109 deletions
+34 -11
View File
@@ -24,6 +24,7 @@ $renderBadge = static function (string $status, array $badges): string {
};
$fileAccept = implode(',', array_map(static fn ($x) => '.' . $x, $allowedExtensions));
$legacyFileAccept = $fileAccept;
?>
<div class="container-fluid px-4 py-4">
<div class="d-flex flex-column flex-lg-row justify-content-between align-items-lg-center gap-3 mb-4">
@@ -48,12 +49,12 @@ $fileAccept = implode(',', array_map(static fn ($x) => '.' . $x, $allowedExtensi
<ul class="nav nav-pills mb-3" id="examDraftTabs" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="submissions-tab" data-bs-toggle="pill" data-bs-target="#submissions" type="button" role="tab" aria-controls="submissions" aria-selected="true">
Submissions
<?= esc($schoolYear ?: 'Current year') ?> submissions
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="legacy-tab" data-bs-toggle="pill" data-bs-target="#legacy" type="button" role="tab" aria-controls="legacy" aria-selected="false">
Legacy exams
Final &amp; legacy exams
</button>
</li>
</ul>
@@ -62,6 +63,7 @@ $fileAccept = implode(',', array_map(static fn ($x) => '.' . $x, $allowedExtensi
<div class="tab-pane fade show active" id="submissions" role="tabpanel" aria-labelledby="submissions-tab">
<div class="card mb-4">
<div class="card-body">
<p class="text-muted small mb-3">All teacher submissions for the selected school year are shown here, including accepted exams.</p>
<?php if (empty($visibleClasses)): ?>
<p class="text-muted mb-0">No classes with enrolled students are available for this term.</p>
<?php else: ?>
@@ -204,6 +206,7 @@ $fileAccept = implode(',', array_map(static fn ($x) => '.' . $x, $allowedExtensi
<div class="mt-2">
<?php $fileInputId = 'review_file_' . (int) ($draft['id'] ?? 0); ?>
<input type="file" name="final_file" id="<?= esc($fileInputId) ?>" class="form-control form-control-sm" accept="<?= esc($fileAccept) ?>" form="<?= esc($formId) ?>">
<div class="form-text">Accepted DOC/DOCX files are converted to PDF with Stirling-PDF; uploaded PDFs are preserved as-is.</div>
<button type="submit" class="btn btn-sm btn-outline-primary mt-2" form="<?= esc($formId) ?>">Upload review file</button>
</div>
</td>
@@ -274,7 +277,7 @@ $fileAccept = implode(',', array_map(static fn ($x) => '.' . $x, $allowedExtensi
<div class="card-header bg-light d-flex justify-content-between align-items-center">
<div>
<strong>Upload old / legacy exam</strong>
<div class="small text-muted">Store historic exams as accepted records.</div>
<div class="small text-muted">Store historic exams in the grade-based final archive.</div>
</div>
<span class="badge bg-primary-subtle text-primary">Admin only</span>
</div>
@@ -309,8 +312,8 @@ $fileAccept = implode(',', array_map(static fn ($x) => '.' . $x, $allowedExtensi
</div>
<div class="col-12">
<label class="form-label small">Upload file</label>
<input type="file" name="old_exam_file" class="form-control" accept="<?= esc($fileAccept) ?>" required>
<div class="form-text">Allowed: <?= esc(implode(', ', $allowedExtensions)) ?> • Max <?= number_format($maxUploadBytes / 1024 / 1024, 0) ?> MB</div>
<input type="file" name="old_exam_file" class="form-control" accept="<?= esc($legacyFileAccept) ?>" required>
<div class="form-text">DOC/DOCX files are converted with Stirling-PDF and saved in the archive as PDF • Max <?= number_format($maxUploadBytes / 1024 / 1024, 0) ?> MB</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">Upload legacy exam</button>
@@ -322,14 +325,20 @@ $fileAccept = implode(',', array_map(static fn ($x) => '.' . $x, $allowedExtensi
<div class="card mb-4">
<div class="card-body">
<?php if (empty($legacyByClass)): ?>
<p class="text-muted mb-0">No legacy exams uploaded yet.</p>
<p class="text-muted mb-0">No final or legacy exams are available yet.</p>
<?php else: ?>
<?php foreach ($legacyByClass as $group): ?>
<div class="mb-4">
<h6 class="mb-2"><?= esc($group['class_section_name'] ?? 'Class') ?></h6>
<div class="list-group">
<?php foreach ($group['items'] ?? [] as $item): ?>
<?php $lst = strtolower((string) ($item['status'] ?? '')); ?>
<?php
$lst = strtolower((string) ($item['status'] ?? ''));
$archivePdfFile = trim((string) ($item['final_pdf_file'] ?? ''));
if ($archivePdfFile === '' && strtolower(pathinfo((string) ($item['final_file'] ?? ''), PATHINFO_EXTENSION)) === 'pdf') {
$archivePdfFile = (string) $item['final_file'];
}
?>
<div class="list-group-item d-flex justify-content-between align-items-start flex-wrap gap-2">
<div class="me-3">
<div class="fw-semibold"><?= esc($item['draft_title'] ?? 'Legacy exam') ?></div>
@@ -337,14 +346,28 @@ $fileAccept = implode(',', array_map(static fn ($x) => '.' . $x, $allowedExtensi
<?= esc($item['exam_type'] ?? 'N/A') ?> •
<?= esc($item['semester'] ?? '') ?> <?= esc($item['school_year'] ?? '') ?>
</div>
<?php if (!empty($item['class_section_names'])): ?>
<div class="small text-muted">Sections: <?= esc(implode(', ', $item['class_section_names'])) ?></div>
<?php endif; ?>
<div class="small mt-1"><?= $renderBadge($lst, $statusBadges) ?></div>
</div>
<div class="text-end d-flex flex-wrap gap-2 justify-content-end">
<?php if (!empty($item['final_file'])): ?>
<a class="btn btn-sm btn-outline-primary" href="<?= base_url('exam-drafts/files/final/' . $item['final_file']) ?>" target="_blank" rel="noopener">View</a>
<a class="btn btn-sm btn-outline-secondary" href="<?= base_url('exam-drafts/files/final/' . $item['final_file']) ?>" target="_blank" rel="noopener" download>Download</a>
<?php if ($archivePdfFile !== ''): ?>
<a class="btn btn-sm btn-outline-primary" href="<?= base_url('exam-drafts/files/final/' . $archivePdfFile) ?>" target="_blank" rel="noopener">View PDF</a>
<a class="btn btn-sm btn-outline-secondary" href="<?= base_url('exam-drafts/files/final/' . $archivePdfFile) ?>" target="_blank" rel="noopener" download>Download PDF</a>
<?php else: ?>
<span class="text-muted small">File missing</span>
<div class="text-start">
<div class="text-danger small mb-2">A formatting-safe PDF is required.</div>
<?= form_open_multipart($reviewActionUrl, ['class' => 'd-flex flex-wrap gap-2 align-items-center']) ?>
<?= csrf_field() ?>
<input type="hidden" name="draft_id" value="<?= (int) ($item['id'] ?? 0) ?>">
<input type="hidden" name="review_status" value="accepted">
<input type="hidden" name="acceptance_type" value="<?= esc($item['acceptance_type'] ?? 'as_is') ?>">
<input type="file" name="final_file" class="form-control form-control-sm" accept=".pdf,application/pdf" required>
<button type="submit" class="btn btn-sm btn-primary">Upload replacement PDF</button>
<?= form_close() ?>
<div class="form-text">Upload a PDF exported from Word if automatic conversion is unavailable.</div>
</div>
<?php endif; ?>
</div>
</div>