270 lines
13 KiB
PHP
270 lines
13 KiB
PHP
<?= $this->extend('layout/management_layout') ?>
|
|
<?= $this->section('content') ?>
|
|
<div class="container-fluid px-4 py-4 teacher-submissions-page">
|
|
<div class="card shadow-sm">
|
|
<div class="card-header bg-light d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<strong>Teacher Submission Dashboard</strong>
|
|
</div>
|
|
<?php if (!empty($semester) || !empty($schoolYear)): ?>
|
|
<span class="small text-muted">
|
|
<?= esc(ucfirst($semester)) ?> <?= esc($schoolYear) ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php
|
|
$notificationHistory = $notificationHistory ?? [];
|
|
$summary = $summary ?? [];
|
|
$completionPercent = max(0, min(100, (int)($summary['submission_percentage'] ?? 0)));
|
|
$missingItemsCount = max(0, (int)($summary['missing_items'] ?? 0));
|
|
$submittedItems = max(0, (int)($summary['submitted_items'] ?? 0));
|
|
$totalItems = max(0, (int)($summary['total_items'] ?? 0));
|
|
?>
|
|
<div class="card-body">
|
|
<?php
|
|
$termExamLabel = (isset($semester) && strtolower((string) $semester) === 'spring') ? 'Final' : 'Midterm';
|
|
?>
|
|
<?php if (session()->getFlashdata('success')): ?>
|
|
<div class="alert alert-success">
|
|
<?= esc(session()->getFlashdata('success')) ?>
|
|
</div>
|
|
<?php elseif (session()->getFlashdata('warning')): ?>
|
|
<div class="alert alert-warning">
|
|
<?= esc(session()->getFlashdata('warning')) ?>
|
|
</div>
|
|
<?php elseif (session()->getFlashdata('info')): ?>
|
|
<div class="alert alert-info">
|
|
<?= esc(session()->getFlashdata('info')) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php $lowProgressSectionIds = $lowProgressSectionIds ?? []; ?>
|
|
<?php if (!empty($lowProgressSectionIds)): ?>
|
|
<div class="alert alert-warning">
|
|
Showing teachers for class sections with progress submissions below 50%.
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="border rounded-3 p-3 mb-4 bg-light">
|
|
<div class="d-flex flex-wrap gap-4 align-items-center">
|
|
<div>
|
|
<div class="text-uppercase small text-muted">Submission completion</div>
|
|
<div class="h4 fw-semibold mb-1"><?= esc($completionPercent) ?>%</div>
|
|
<div class="progress" style="height:6px;">
|
|
<div
|
|
class="progress-bar bg-primary"
|
|
role="progressbar"
|
|
style="width: <?= esc($completionPercent) ?>%;"
|
|
aria-valuenow="<?= esc($completionPercent) ?>"
|
|
aria-valuemin="0"
|
|
aria-valuemax="100"
|
|
></div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="text-uppercase small text-muted">Missing items</div>
|
|
<div class="h4 fw-semibold text-danger mb-0"><?= esc($missingItemsCount) ?></div>
|
|
</div>
|
|
<div class="text-muted small">
|
|
<?= esc($submittedItems) ?> submitted / <?= esc($totalItems) ?> total items
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<form method="post" action="<?= site_url('administrator/teacher-submissions/notify') ?>">
|
|
<?= csrf_field() ?>
|
|
<div class="table-responsive">
|
|
<table
|
|
class="table table-striped table-bordered m-0 align-middle teacher-submissions-table"
|
|
data-no-mgmt-sticky
|
|
data-no-dt-fixedheader
|
|
>
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Class-Section</th>
|
|
<th>Teachers Name</th>
|
|
<th class="text-center">
|
|
<?= esc($termExamLabel) ?> Score
|
|
<div class="form-check d-inline-flex align-items-center gap-1 ms-2">
|
|
<input class="form-check-input" type="checkbox" name="notify_midterm_score" id="notifyMidtermScore" value="1">
|
|
<label class="form-check-label small" for="notifyMidtermScore">Include</label>
|
|
</div>
|
|
</th>
|
|
<th class="text-center">
|
|
<?= esc($termExamLabel) ?> Comment
|
|
<div class="form-check d-inline-flex align-items-center gap-1 ms-2">
|
|
<input class="form-check-input" type="checkbox" name="notify_midterm_comment" id="notifyMidtermComment" value="1">
|
|
<label class="form-check-label small" for="notifyMidtermComment">Include</label>
|
|
</div>
|
|
</th>
|
|
<th class="text-center">
|
|
Participation
|
|
<div class="form-check d-inline-flex align-items-center gap-1 ms-2">
|
|
<input class="form-check-input" type="checkbox" name="notify_participation" id="notifyParticipation" value="1">
|
|
<label class="form-check-label small" for="notifyParticipation">Include</label>
|
|
</div>
|
|
</th>
|
|
<th class="text-center">
|
|
PTAP Comment
|
|
<div class="form-check d-inline-flex align-items-center gap-1 ms-2">
|
|
<input class="form-check-input" type="checkbox" name="notify_ptap_comment" id="notifyPtapComment" value="1">
|
|
<label class="form-check-label small" for="notifyPtapComment">Include</label>
|
|
</div>
|
|
</th>
|
|
<th class="text-center">
|
|
Class Progress
|
|
<div class="form-check d-inline-flex align-items-center gap-1 ms-2">
|
|
<input class="form-check-input" type="checkbox" name="notify_class_progress" id="notifyClassProgress" value="1">
|
|
<label class="form-check-label small" for="notifyClassProgress">Include</label>
|
|
</div>
|
|
</th>
|
|
<th class="text-center">
|
|
Exam Draft
|
|
<div class="form-check d-inline-flex align-items-center gap-1 ms-2">
|
|
<input class="form-check-input" type="checkbox" name="notify_exam_draft" id="notifyExamDraft" value="1">
|
|
<label class="form-check-label small" for="notifyExamDraft">Include</label>
|
|
</div>
|
|
</th>
|
|
<th class="text-center">
|
|
Homework
|
|
<div class="form-check d-inline-flex align-items-center gap-1 ms-2">
|
|
<input class="form-check-input" type="checkbox" name="homework_notify_all" id="homeworkNotifyAll" value="1">
|
|
<label class="form-check-label small" for="homeworkNotifyAll">Include</label>
|
|
</div>
|
|
</th>
|
|
<th class="text-center">Notifications</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (!empty($rows)): ?>
|
|
<?php $homeworkToggleRendered = false; ?>
|
|
<?php foreach ($rows as $row): ?>
|
|
<tr>
|
|
<td><?= esc($row['class_section']) ?></td>
|
|
<td>
|
|
<?php if (!empty($row['teachers'])): ?>
|
|
<?php foreach ($row['teachers'] as $teacher): ?>
|
|
<div><?= esc($teacher['label'] ?? 'Teacher') ?></div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<span class="text-muted small">Unassigned</span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<?php foreach ([
|
|
'midterm_score_status',
|
|
'midterm_comment_status',
|
|
'participation_status',
|
|
'ptap_comment_status',
|
|
'class_progress_status',
|
|
'exam_draft_status',
|
|
] as $statusKey): ?>
|
|
<?php $status = $row[$statusKey] ?? ['label' => 'N/A', 'badge' => 'bg-secondary']; ?>
|
|
<td class="text-center">
|
|
<span class="badge <?= esc($status['badge'] ?? 'bg-secondary') ?>">
|
|
<?= esc($status['label'] ?? 'N/A') ?>
|
|
</span>
|
|
<?php if (!empty($status['detail'])): ?>
|
|
<div class="small text-muted"><?= esc($status['detail']) ?></div>
|
|
<?php endif; ?>
|
|
</td>
|
|
<?php endforeach; ?>
|
|
<?php $homeworkStatus = $row['homework_status'] ?? ['label' => 'N/A', 'badge' => 'bg-secondary']; ?>
|
|
<td class="text-center">
|
|
<span class="badge <?= esc($homeworkStatus['badge'] ?? 'bg-secondary') ?>">
|
|
<?= esc($homeworkStatus['label'] ?? 'N/A') ?>
|
|
</span>
|
|
<?php if (!empty($homeworkStatus['detail'])): ?>
|
|
<div class="small text-muted"><?= esc($homeworkStatus['detail']) ?></div>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td>
|
|
<?php if (!empty($row['teachers'])): ?>
|
|
<?php $missingPayload = base64_encode(json_encode($row['missing_items'] ?? [])); ?>
|
|
<?php foreach ($row['teachers'] as $teacher): ?>
|
|
<?php $history = $notificationHistory[$row['class_section_id']][$teacher['id']] ?? []; ?>
|
|
<?php $lastEntry = $history[0] ?? null; ?>
|
|
<div class="mb-2">
|
|
<label class="d-flex align-items-center gap-2 mb-1">
|
|
<input
|
|
type="checkbox"
|
|
class="form-check-input"
|
|
name="notify[<?= esc($row['class_section_id']) ?>][<?= esc($teacher['id']) ?>]"
|
|
value="1"
|
|
/>
|
|
<span class="fw-semibold"><?= esc($teacher['label'] ?? 'Teacher') ?></span>
|
|
</label>
|
|
<input
|
|
type="hidden"
|
|
name="missing_items[<?= esc($row['class_section_id']) ?>][<?= esc($teacher['id']) ?>]"
|
|
value="<?= esc($missingPayload) ?>"
|
|
/>
|
|
<div class="small text-muted">
|
|
<?php if ($lastEntry !== null): ?>
|
|
<span>
|
|
Last <?= esc($lastEntry['status'] === 'sent' ? 'sent' : 'attempted') ?> on <?= esc($lastEntry['sent_at_text'] ?: 'N/A') ?>
|
|
by <?= esc($lastEntry['admin_name'] ?? '') ?>
|
|
</span>
|
|
<?php if (count($history) > 1): ?>
|
|
<div>History: <?= count($history) ?> entries</div>
|
|
<?php endif; ?>
|
|
<?php else: ?>
|
|
<span>No notifications sent yet</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<span class="text-muted small">No teacher assigned</span>
|
|
<?php endif; ?>
|
|
<?php if (!empty($row['missing_items'])): ?>
|
|
<div class="small text-danger mt-1">
|
|
Outstanding: <?= esc(implode(', ', $row['missing_items'])) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<tr>
|
|
<td colspan="7" class="text-center">No teacher-class assignments found for this term.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="mt-3 text-end">
|
|
<button type="submit" class="btn btn-primary" <?= empty($rows) ? 'disabled' : '' ?>>
|
|
Send notifications to selected teachers
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?= $this->endSection() ?>
|
|
|
|
<?= $this->section('styles') ?>
|
|
<style>
|
|
.teacher-submissions-page {
|
|
width: 100%;
|
|
max-width: 100%;
|
|
}
|
|
.teacher-submissions-page .card {
|
|
width: 100%;
|
|
}
|
|
.teacher-submissions-page .table-responsive {
|
|
max-width: none;
|
|
}
|
|
.card-body .table-responsive table thead th {
|
|
position: static !important;
|
|
top: auto !important;
|
|
}
|
|
.card-body .table-responsive .teacher-submissions-table {
|
|
width: 100% !important;
|
|
min-width: 100%;
|
|
table-layout: auto;
|
|
}
|
|
.card-body .table-responsive .teacher-submissions-table th,
|
|
.card-body .table-responsive .teacher-submissions-table td {
|
|
white-space: normal;
|
|
}
|
|
</style>
|
|
<?= $this->endSection() ?>
|