213 lines
10 KiB
PHP
213 lines
10 KiB
PHP
<?= $this->extend('layout/management_layout') ?>
|
|
<?= $this->section('content') ?>
|
|
|
|
<div class="container-fluid">
|
|
<div class="wrapper">
|
|
<h2 class="text-center mt-4 mb-4">Student Decisions — All Students</h2>
|
|
|
|
<!-- School Year filter only -->
|
|
<form method="get" class="row g-2 align-items-center justify-content-center mb-3">
|
|
<div class="col-auto"><label class="form-label mb-0">School year</label></div>
|
|
<div class="col-auto">
|
|
<select name="school_year" class="form-select form-select-sm" style="min-width: 180px;">
|
|
<?php $years = isset($schoolYears) && is_array($schoolYears) ? $schoolYears : []; ?>
|
|
<?php foreach ($years as $y):
|
|
$val = is_array($y) && isset($y['school_year']) ? (string)$y['school_year'] : (string)$y; ?>
|
|
<option value="<?= esc($val) ?>" <?= ($schoolYear === $val ? 'selected' : '') ?>><?= esc($val) ?></option>
|
|
<?php endforeach; ?>
|
|
<?php if (empty($years) && $schoolYear !== ''): ?>
|
|
<option value="<?= esc($schoolYear) ?>" selected><?= esc($schoolYear) ?></option>
|
|
<?php endif; ?>
|
|
</select>
|
|
</div>
|
|
<div class="col-auto">
|
|
<button type="submit" class="btn btn-secondary btn-sm">Apply</button>
|
|
<a class="btn btn-outline-secondary btn-sm" href="?">Reset</a>
|
|
</div>
|
|
</form>
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-3 flex-wrap gap-2">
|
|
<div class="text-muted">
|
|
<?= esc($schoolYear ?? '') ?>
|
|
<?php if ($generated): ?>
|
|
<span class="badge bg-success ms-2">Saved</span>
|
|
<?php else: ?>
|
|
<span class="badge bg-warning text-dark ms-2">Not yet generated</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="d-flex gap-2 flex-wrap">
|
|
<a class="btn btn-outline-secondary btn-sm" href="<?= base_url('grading') ?>">
|
|
Grading
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (!empty(session()->getFlashdata('status'))): ?>
|
|
<div class="alert alert-success alert-dismissible fade show">
|
|
<?= esc(session()->getFlashdata('status')) ?>
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty(session()->getFlashdata('error'))): ?>
|
|
<div class="alert alert-danger alert-dismissible fade show">
|
|
<?= esc(session()->getFlashdata('error')) ?>
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- Generate / Regenerate button -->
|
|
<form method="post" action="<?= site_url('grading/decisions/generate') ?>" class="mb-3">
|
|
<?= csrf_field() ?>
|
|
<input type="hidden" name="school_year" value="<?= esc($schoolYear ?? '') ?>">
|
|
<button type="submit" class="btn btn-primary">
|
|
<?= $generated ? 'Regenerate Decisions' : 'Generate Decisions' ?>
|
|
</button>
|
|
<span class="text-muted small ms-2">
|
|
Year score ≥ 60 → <strong>Pass</strong> (auto) |
|
|
Year score < 60 → pulled from below-60 decisions
|
|
</span>
|
|
</form>
|
|
|
|
<?php if (empty($rows)): ?>
|
|
<div class="alert alert-info">No semester scores found for this school year.</div>
|
|
<?php else: ?>
|
|
|
|
<?php
|
|
$decisionBadge = [
|
|
'Pass' => 'success',
|
|
'Repeat Class' => 'danger',
|
|
'Make-up exam in fall' => 'info',
|
|
'Deferred decision' => 'info',
|
|
'Expel' => 'danger',
|
|
'Withdrawn' => 'secondary',
|
|
];
|
|
$sourceBadge = [
|
|
'auto' => ['bg-success-subtle text-success-emphasis', 'Auto'],
|
|
'manual' => ['bg-primary-subtle text-primary-emphasis', 'Manual'],
|
|
'pending' => ['bg-warning-subtle text-warning-emphasis', 'Pending'],
|
|
];
|
|
|
|
$stats = ['Pass' => 0, 'Other' => 0, 'Pending' => 0];
|
|
foreach ($rows as $r) {
|
|
if ($r['decision'] === 'Pass') $stats['Pass']++;
|
|
elseif ($r['decision'] === '' || $r['source'] === 'pending') $stats['Pending']++;
|
|
else $stats['Other']++;
|
|
}
|
|
?>
|
|
|
|
<!-- Summary cards -->
|
|
<div class="d-flex gap-3 mb-3 flex-wrap">
|
|
<div class="card text-center px-4 py-2 border-success">
|
|
<div class="fs-4 fw-bold text-success"><?= $stats['Pass'] ?></div>
|
|
<div class="text-muted small">Pass</div>
|
|
</div>
|
|
<div class="card text-center px-4 py-2 border-primary">
|
|
<div class="fs-4 fw-bold text-primary"><?= $stats['Other'] ?></div>
|
|
<div class="text-muted small">Other decision</div>
|
|
</div>
|
|
<div class="card text-center px-4 py-2 border-warning">
|
|
<div class="fs-4 fw-bold text-warning"><?= $stats['Pending'] ?></div>
|
|
<div class="text-muted small">Pending</div>
|
|
</div>
|
|
<div class="card text-center px-4 py-2">
|
|
<div class="fs-4 fw-bold"><?= count($rows) ?></div>
|
|
<div class="text-muted small">Total</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered table-striped align-middle w-100 all-decisions-dt"
|
|
data-no-mgmt-sticky data-no-dt-fixedheader>
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Student Name</th>
|
|
<th>Section</th>
|
|
<th class="text-center">Fall Score</th>
|
|
<th class="text-center">Spring Score</th>
|
|
<th class="text-center">Year Score</th>
|
|
<th class="text-center">Decision</th>
|
|
<th class="text-center">Source</th>
|
|
<th>Notes</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($rows as $row): ?>
|
|
<?php
|
|
$yearScore = $row['year_score'];
|
|
$decision = (string)($row['decision'] ?? '');
|
|
$source = (string)($row['source'] ?? 'pending');
|
|
$yearVal = is_numeric($yearScore) ? (float)$yearScore : null;
|
|
$rowClass = '';
|
|
if ($yearVal !== null && $yearVal < 60) {
|
|
$rowClass = $yearVal < 50 ? 'grade-red' : 'grade-orange';
|
|
}
|
|
$badge = $decisionBadge[$decision] ?? null;
|
|
[$srcCls, $srcLabel] = $sourceBadge[$source] ?? ['bg-light text-muted', $source];
|
|
$studentName = trim((string)($row['firstname'] ?? '') . ' ' . (string)($row['lastname'] ?? ''));
|
|
$fmt = fn($v) => is_numeric($v) ? number_format((float)$v, 2) : '—';
|
|
?>
|
|
<tr class="<?= esc($rowClass) ?>">
|
|
<td><?= esc($studentName ?: 'N/A') ?></td>
|
|
<td><?= esc($row['class_section_name'] ?? '—') ?></td>
|
|
<td class="text-center"><?= esc($fmt($row['fall_score'] ?? null)) ?></td>
|
|
<td class="text-center"><?= esc($fmt($row['spring_score'] ?? null)) ?></td>
|
|
<td class="text-center fw-semibold">
|
|
<?= esc($fmt($yearVal)) ?>
|
|
</td>
|
|
<td class="text-center">
|
|
<?php if ($decision !== '' && $badge): ?>
|
|
<span class="badge bg-<?= esc($badge) ?>"><?= esc($decision) ?></span>
|
|
<?php elseif ($decision !== ''): ?>
|
|
<span class="badge bg-secondary"><?= esc($decision) ?></span>
|
|
<?php else: ?>
|
|
<span class="text-muted small">—</span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="badge <?= esc($srcCls) ?>"><?= esc($srcLabel) ?></span>
|
|
</td>
|
|
<td class="text-muted small"><?= nl2br(esc((string)($row['notes'] ?? ''))) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Legend -->
|
|
<div class="mt-2 mb-4 d-flex gap-2 flex-wrap align-items-center">
|
|
<?php foreach ($decisionBadge as $label => $color): ?>
|
|
<span class="badge bg-<?= esc($color) ?> px-2 py-1"><?= esc($label) ?></span>
|
|
<?php endforeach; ?>
|
|
<span class="text-muted small ms-2">— decision colour key</span>
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?= $this->endSection() ?>
|
|
|
|
<?= $this->section('scripts') ?>
|
|
<style>
|
|
.grade-orange td { background: #fff3cd !important; color: #8a5d00; }
|
|
.grade-red td { background: #f8d7da !important; color: #842029; }
|
|
</style>
|
|
<script>
|
|
(function () {
|
|
if (!window.$ || !$.fn || !$.fn.DataTable) return;
|
|
$(function () {
|
|
const tbl = $('.all-decisions-dt');
|
|
if (!tbl.length) return;
|
|
try {
|
|
tbl.DataTable({
|
|
order: [[1, 'asc'], [0, 'asc']],
|
|
pageLength: 100,
|
|
lengthMenu: [25, 50, 100, 200],
|
|
columnDefs: [{ orderable: false, targets: [7] }]
|
|
});
|
|
} catch (_) {}
|
|
});
|
|
})();
|
|
</script>
|
|
<?= $this->endSection() ?>
|