add assessment feature
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="enrollmentTable" class="table table-bordered table-striped mt-4 align-middle w-100">
|
||||
<table id="enrollmentTable" class="table table-bordered table-striped mt-4 align-middle w-100 no-mgmt-sticky" data-no-mgmt-sticky>
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -30,6 +30,7 @@
|
||||
<th>Actual Status</th>
|
||||
<th>Age</th> <!-- NEW -->
|
||||
<th>Registration Date</th> <!-- NEW -->
|
||||
<th>Assessment</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
|
||||
@@ -107,6 +108,20 @@
|
||||
<td><?= esc($student['age'] ?? '-') ?></td>
|
||||
<td><?= esc(!empty($student['registration_date']) ? local_date($student['registration_date'], 'm-d-Y') : '-') ?></td>
|
||||
|
||||
<td>
|
||||
<?php $studentAssessment = ($assessmentByStudent ?? [])[$sid] ?? null; ?>
|
||||
<?php if (!$studentAssessment): ?>
|
||||
<form method="post" action="<?= site_url('administrator/assessments/students/' . $sid . '/start') ?>"><?= csrf_field() ?><button class="btn btn-sm btn-outline-primary">Assign Assessment</button></form>
|
||||
<?php elseif (in_array($studentAssessment['status'], ['not_started', 'in_progress'], true)): ?>
|
||||
<a class="btn btn-sm btn-outline-secondary" href="<?= site_url('administrator/assessments/students/' . $sid) ?>">View Status</a>
|
||||
<div class="small text-muted mt-1"><?= esc(ucwords(str_replace('_', ' ', $studentAssessment['status']))) ?></div>
|
||||
<?php elseif ($studentAssessment['status'] === 'completed'): ?>
|
||||
<a class="btn btn-sm btn-warning" href="<?= site_url('administrator/assessments/review/' . $studentAssessment['id']) ?>">Review</a>
|
||||
<?php else: ?>
|
||||
<a class="btn btn-sm btn-success" href="<?= site_url('administrator/assessments/results/' . $studentAssessment['id']) ?>">View Results</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td class="d-flex gap-2">
|
||||
<!-- Contact info modal trigger ONLY -->
|
||||
<button class="btn btn-warning btn-sm" data-bs-toggle="modal" data-bs-target="#<?= esc($modalIdContact) ?>">
|
||||
@@ -156,7 +171,7 @@
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="8" class="text-center">No students found.</td>
|
||||
<td colspan="9" class="text-center">No students found.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
@@ -169,52 +184,7 @@
|
||||
<?= $this->section('scripts') ?>
|
||||
<script>
|
||||
$(function() {
|
||||
function getFixedHeaderOffset() {
|
||||
let total = 0;
|
||||
const stack = [];
|
||||
const header = document.querySelector('header.navbar.sticky-top, header.navbar.fixed-top');
|
||||
if (header) stack.push(header);
|
||||
const mgmt = document.getElementById('navbarManagement');
|
||||
if (mgmt && (mgmt.classList.contains('sticky-top') || mgmt.classList.contains('fixed-top'))) stack.push(mgmt);
|
||||
document.querySelectorAll('.navbar.sticky-top, .navbar.fixed-top').forEach(el => { if (!stack.includes(el)) stack.push(el); });
|
||||
stack.forEach(el => { const h = el.offsetHeight || el.getBoundingClientRect().height || 0; total += Math.max(0, Math.round(h)); });
|
||||
return total;
|
||||
}
|
||||
|
||||
function loadScript(src, id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (id && document.getElementById(id)) return resolve();
|
||||
const s = document.createElement('script');
|
||||
if (id) s.id = id;
|
||||
s.src = src;
|
||||
s.onload = resolve;
|
||||
s.onerror = reject;
|
||||
document.head.appendChild(s);
|
||||
});
|
||||
}
|
||||
function loadCss(href, id) {
|
||||
return new Promise((resolve) => {
|
||||
if (id && document.getElementById(id)) return resolve();
|
||||
const l = document.createElement('link');
|
||||
if (id) l.id = id;
|
||||
l.rel = 'stylesheet';
|
||||
l.href = href;
|
||||
l.onload = resolve;
|
||||
document.head.appendChild(l);
|
||||
});
|
||||
}
|
||||
|
||||
function ensureFixedHeaderAssets() {
|
||||
const hasFH = !!($.fn.dataTable && $.fn.dataTable.FixedHeader);
|
||||
if (hasFH) return Promise.resolve();
|
||||
return Promise.all([
|
||||
loadScript('https://cdn.jsdelivr.net/npm/datatables.net-fixedheader@3.4.0/js/dataTables.fixedHeader.min.js', 'dt-fixedheader'),
|
||||
loadCss('https://cdn.jsdelivr.net/npm/datatables.net-fixedheader-bs5@3.4.0/css/fixedHeader.bootstrap5.min.css', 'dt-fixedheader-css')
|
||||
]).catch(() => {});
|
||||
}
|
||||
|
||||
function initTable() {
|
||||
$('#enrollmentTable').DataTable({
|
||||
$('#enrollmentTable').DataTable({
|
||||
pageLength: 100,
|
||||
lengthMenu: [10, 25, 50, 100],
|
||||
stateSave: true,
|
||||
@@ -222,18 +192,8 @@
|
||||
columnDefs: [
|
||||
{ targets: [1, 2, 3], searchable: false }
|
||||
],
|
||||
fixedHeader: {
|
||||
header: true,
|
||||
headerOffset: getFixedHeaderOffset()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($.fn.dataTable && $.fn.dataTable.FixedHeader) {
|
||||
initTable();
|
||||
} else {
|
||||
ensureFixedHeaderAssets().then(() => initTable()).catch(() => initTable());
|
||||
}
|
||||
fixedHeader: false
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
Reference in New Issue
Block a user