fix the exam draft

This commit is contained in:
root
2026-04-02 00:03:59 -04:00
parent ed67836701
commit 61facee902
6 changed files with 111 additions and 39 deletions
+26 -5
View File
@@ -168,12 +168,33 @@
$weekLabel .= ' ' . date('M d, Y', strtotime($group['week_end']));
}
$reports = $group['reports'] ?? [];
$teacherName = '';
$teacherCounts = [];
$teacherLatest = [];
foreach ($reports as $report) {
if (! empty($report['teacher_name'])) {
$teacherName = $report['teacher_name'];
break;
$name = trim((string) ($report['teacher_name'] ?? ''));
if ($name === '') {
continue;
}
$teacherCounts[$name] = ($teacherCounts[$name] ?? 0) + 1;
$stamp = (string) ($report['updated_at'] ?? $report['created_at'] ?? '');
if ($stamp !== '' && (!isset($teacherLatest[$name]) || $stamp > $teacherLatest[$name])) {
$teacherLatest[$name] = $stamp;
}
}
$teacherLabel = '-';
if (!empty($teacherCounts)) {
$bestName = '';
$bestCount = -1;
$bestStamp = '';
foreach ($teacherCounts as $name => $count) {
$stamp = $teacherLatest[$name] ?? '';
if ($count > $bestCount || ($count === $bestCount && $stamp > $bestStamp)) {
$bestName = $name;
$bestCount = $count;
$bestStamp = $stamp;
}
}
$teacherLabel = $bestName ?: '-';
}
$exampleId = $reports ? reset($reports)['id'] : null;
?>
@@ -198,7 +219,7 @@
<?php endforeach; ?>
</div>
</td>
<td><?= esc($teacherName ?: '-') ?></td>
<td><?= esc($teacherLabel) ?></td>
<td class="text-end">
<?php if ($exampleId): ?>
<a class="btn btn-sm btn-outline-primary" href="<?= base_url('admin/progress/view/' . $exampleId) ?>">View</a>