Compare commits
5 Commits
9ee75fe4cc
...
5.0.7
| Author | SHA1 | Date | |
|---|---|---|---|
| 090cb88573 | |||
| 95bcefc3a9 | |||
| f24f4311e8 | |||
| 89913d7473 | |||
| 079c869477 |
+10
-3
@@ -528,10 +528,17 @@ $routes->post('grading/decisions/generate', 'View\GradingController::generateAll
|
||||
$routes->get('grading/below-60/decisions', 'View\GradingController::belowSixtyDecisions', ['filter' => 'auth:read']);
|
||||
$routes->post('grading/below-60/decisions/save', 'View\GradingController::saveBelowSixtyDecision', ['filter' => 'auth:read']);
|
||||
$routes->get('grading/below-60/decisions/student-details', 'View\GradingController::studentDecisionDetails', ['filter' => 'auth:read']);
|
||||
$routes->get('grading/below-60/decisions/email/preview', 'View\GradingController::previewDecisionEmail', ['filter' => 'auth:read']);
|
||||
$routes->get('grading/below-60/decisions/email/edit', 'View\GradingController::editDecisionEmail', ['filter' => 'auth:read']);
|
||||
$routes->post('grading/below-60/decisions/email', 'View\GradingController::sendDecisionEmail', ['filter' => 'auth:read']);
|
||||
$routes->get(
|
||||
'grading/below-60/decisions/email/preview',
|
||||
'View\GradingController::previewBelowSixtyDecisionEmail',
|
||||
['filter' => 'auth:read']
|
||||
);
|
||||
|
||||
$routes->post(
|
||||
'grading/below-60/decisions/email',
|
||||
'View\GradingController::sendBelowSixtyDecisionEmail',
|
||||
['filter' => 'auth:read']
|
||||
);
|
||||
|
||||
// Final part
|
||||
$routes->get('grading/(:segment)/(:num)/(:num)', 'View\GradingController::show/$1/$2/$3');
|
||||
|
||||
@@ -1068,37 +1068,67 @@ class GradingController extends Controller
|
||||
return $scores;
|
||||
}
|
||||
|
||||
public function belowSixty()
|
||||
{
|
||||
$configuredYear = (string) $this->schoolYear;
|
||||
public function belowSixty()
|
||||
{
|
||||
$configuredYear = (string) $this->schoolYear;
|
||||
|
||||
$requestedSemester = strtolower(trim((string)($this->request->getGet('semester') ?? '')));
|
||||
$requestedYear = trim((string)($this->request->getGet('school_year') ?? ''));
|
||||
$schoolYear = trim((string)($this->request->getGet('school_year') ?? ''));
|
||||
|
||||
// This page intentionally supports only Fall and Whole Year.
|
||||
// Spring is still used internally for the Whole Year calculation, but it is not selectable here.
|
||||
$isYearMode = ($requestedSemester === 'year');
|
||||
$semester = $isYearMode ? 'year' : 'Fall';
|
||||
$schoolYear = $requestedYear !== '' ? $requestedYear : $configuredYear;
|
||||
|
||||
$schoolYears = $this->getSchoolYearsForScores($schoolYear);
|
||||
$rows = $this->fetchBelowSixtyRows($schoolYear, $semester);
|
||||
|
||||
$canViewGrading = $this->userHasMenuUrl('grading');
|
||||
|
||||
return view('grading/below_sixty', [
|
||||
'rows' => $rows,
|
||||
'semester' => $semester,
|
||||
'schoolYear' => $schoolYear,
|
||||
'schoolYears' => $schoolYears,
|
||||
'canViewGrading' => $canViewGrading,
|
||||
'isYearMode' => $isYearMode,
|
||||
'semesterOptions' => ['Fall'],
|
||||
'showAllSemesterOption' => true,
|
||||
]);
|
||||
if ($schoolYear === '') {
|
||||
$schoolYear = $configuredYear;
|
||||
}
|
||||
|
||||
// This page is Fall only.
|
||||
$semester = 'fall';
|
||||
$isYearMode = false;
|
||||
|
||||
$schoolYears = $this->getSchoolYearsForScores($schoolYear);
|
||||
|
||||
/*
|
||||
* Use your existing below-60 fetcher.
|
||||
* Do NOT query below_sixty_status. That table does not exist.
|
||||
*/
|
||||
$rows = $this->fetchBelowSixtyRows($schoolYear, $semester);
|
||||
|
||||
/*
|
||||
* Hard guard:
|
||||
* Keep only Fall semester rows with semester_score < 60.
|
||||
* This prevents whole-year rows or accidental other semester rows
|
||||
* from sneaking into this Fall-only page.
|
||||
*/
|
||||
$rows = array_values(array_filter($rows, static function ($row) {
|
||||
$semesterValue = strtolower(trim((string)($row['semester'] ?? 'fall')));
|
||||
$scoreRaw = $row['semester_score'] ?? null;
|
||||
|
||||
if ($semesterValue !== '' && $semesterValue !== 'fall') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_numeric($scoreRaw)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (float)$scoreRaw < 60;
|
||||
}));
|
||||
|
||||
foreach ($rows as &$row) {
|
||||
$row['status'] = $row['status'] ?? 'Open';
|
||||
$row['note'] = $row['note'] ?? '';
|
||||
}
|
||||
|
||||
unset($row);
|
||||
|
||||
$canViewGrading = $this->userHasMenuUrl('grading');
|
||||
|
||||
return view('grading/below_sixty', [
|
||||
'rows' => $rows,
|
||||
'semester' => $semester,
|
||||
'schoolYear' => $schoolYear,
|
||||
'schoolYears' => $schoolYears,
|
||||
'isYearMode' => $isYearMode,
|
||||
'canViewGrading' => $canViewGrading,
|
||||
]);
|
||||
}
|
||||
public function editBelowSixtyEmail()
|
||||
{
|
||||
$studentId = (int)$this->request->getGet('student_id');
|
||||
@@ -2298,87 +2328,185 @@ class GradingController extends Controller
|
||||
return 50000;
|
||||
}
|
||||
|
||||
public function belowSixtyDecisions()
|
||||
public function belowSixtyDecisions()
|
||||
{
|
||||
$configuredSemester = (string) $this->semester;
|
||||
$configuredYear = (string) $this->schoolYear;
|
||||
$configuredYear = (string) $this->schoolYear;
|
||||
|
||||
$semester = trim((string)($this->request->getGet('semester') ?? ''));
|
||||
$schoolYear = trim((string)($this->request->getGet('school_year') ?? ''));
|
||||
|
||||
if ($semester === '') {
|
||||
$semester = $configuredSemester !== '' ? $configuredSemester : 'Fall';
|
||||
}
|
||||
|
||||
if ($schoolYear === '') {
|
||||
$schoolYear = $configuredYear;
|
||||
}
|
||||
|
||||
// This page is whole-year only.
|
||||
$semester = 'year';
|
||||
|
||||
$schoolYears = $this->getSchoolYearsForScores($schoolYear);
|
||||
$rows = $this->fetchBelowSixtyRows($schoolYear, $semester);
|
||||
|
||||
$studentIds = array_values(array_unique(array_filter(
|
||||
array_map(static fn($r) => (int)($r['student_id'] ?? 0), $rows),
|
||||
static fn($id) => $id > 0
|
||||
)));
|
||||
$db = $this->db;
|
||||
|
||||
// ── Load manual below-60 semester decisions ─────────────────────────────
|
||||
//
|
||||
// This table still uses semester, because below-60 decisions are tied to
|
||||
// the selected below-60 screen/term.
|
||||
$decisionModel = new BelowSixtyDecisionModel();
|
||||
/*
|
||||
* Whole-year score source:
|
||||
* Fall semester_score + Spring semester_score / 2
|
||||
*
|
||||
* Only students with BOTH Fall and Spring scores are included.
|
||||
* Only students with year_score < 60 are listed.
|
||||
*/
|
||||
$scoreRows = $db->table('semester_scores ss')
|
||||
->select([
|
||||
's.id AS student_id',
|
||||
's.firstname',
|
||||
's.lastname',
|
||||
's.school_id',
|
||||
'cs.class_section_name',
|
||||
'LOWER(TRIM(ss.semester)) AS sem_key',
|
||||
'ss.semester_score',
|
||||
])
|
||||
->join('students s', 's.id = ss.student_id', 'inner')
|
||||
->join('classSection cs', 'cs.class_section_id = ss.class_section_id', 'left')
|
||||
->where('s.is_active', 1)
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->whereIn('LOWER(TRIM(ss.semester))', ['fall', 'spring'])
|
||||
->where('ss.semester_score IS NOT NULL', null, false)
|
||||
->orderBy('cs.class_section_name', 'ASC')
|
||||
->orderBy('s.lastname', 'ASC')
|
||||
->orderBy('s.firstname', 'ASC')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$decisionMap = [];
|
||||
$studentMap = [];
|
||||
|
||||
if (!empty($studentIds)) {
|
||||
$dRows = $decisionModel
|
||||
->whereIn('student_id', $studentIds)
|
||||
->where('semester', $semester)
|
||||
->where('school_year', $schoolYear)
|
||||
->findAll();
|
||||
foreach ($scoreRows as $row) {
|
||||
$sid = (int)($row['student_id'] ?? 0);
|
||||
|
||||
foreach ($dRows as $d) {
|
||||
$decisionMap[(int)$d['student_id']] = $d;
|
||||
if ($sid <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($studentMap[$sid])) {
|
||||
$studentMap[$sid] = [
|
||||
'student_id' => $sid,
|
||||
'school_id' => $row['school_id'] ?? '',
|
||||
'firstname' => $row['firstname'] ?? '',
|
||||
'lastname' => $row['lastname'] ?? '',
|
||||
'class_section_name' => $row['class_section_name'] ?? '',
|
||||
'fall_score' => null,
|
||||
'spring_score' => null,
|
||||
'year_score' => null,
|
||||
];
|
||||
}
|
||||
|
||||
$semKey = strtolower(trim((string)($row['sem_key'] ?? '')));
|
||||
$score = is_numeric($row['semester_score']) ? (float)$row['semester_score'] : null;
|
||||
|
||||
if ($score === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($semKey === 'fall') {
|
||||
$studentMap[$sid]['fall_score'] = $score;
|
||||
} elseif ($semKey === 'spring') {
|
||||
$studentMap[$sid]['spring_score'] = $score;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rows as &$row) {
|
||||
$sid = (int)($row['student_id'] ?? 0);
|
||||
$rows = [];
|
||||
|
||||
foreach ($studentMap as $sid => $student) {
|
||||
$fall = $student['fall_score'];
|
||||
$spring = $student['spring_score'];
|
||||
|
||||
// Whole-year result requires both semesters.
|
||||
if ($fall === null || $spring === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$yearScore = round(($fall + $spring) / 2, 2);
|
||||
|
||||
if ($yearScore >= 60) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$student['year_score'] = $yearScore;
|
||||
$rows[$sid] = $student;
|
||||
}
|
||||
|
||||
$studentIds = array_keys($rows);
|
||||
|
||||
/*
|
||||
* Load saved below-60 manual decisions.
|
||||
* These are year-level decisions now.
|
||||
*/
|
||||
$decisionMap = [];
|
||||
|
||||
if (!empty($studentIds)) {
|
||||
$belowDecModel = new BelowSixtyDecisionModel();
|
||||
|
||||
$decisionRows = $belowDecModel
|
||||
->whereIn('student_id', $studentIds)
|
||||
->where('semester', 'year')
|
||||
->where('school_year', $schoolYear)
|
||||
->findAll();
|
||||
|
||||
foreach ($decisionRows as $d) {
|
||||
$sid = (int)($d['student_id'] ?? 0);
|
||||
|
||||
if ($sid > 0) {
|
||||
$decisionMap[$sid] = $d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rows as $sid => &$row) {
|
||||
$row['decision'] = $decisionMap[$sid]['decision'] ?? '';
|
||||
$row['decision_notes'] = $decisionMap[$sid]['notes'] ?? '';
|
||||
}
|
||||
|
||||
unset($row);
|
||||
|
||||
// ── Load consolidated YEAR decisions from student_decisions ─────────────
|
||||
//
|
||||
// IMPORTANT:
|
||||
// student_decisions no longer has semester or semester_score.
|
||||
// It is now one row per student per school_year using year_score.
|
||||
$sdMap = [];
|
||||
/*
|
||||
* Load final generated whole-year decisions from student_decisions.
|
||||
* This table is now year-based, so do NOT filter by semester.
|
||||
*/
|
||||
$finalDecisionMap = [];
|
||||
|
||||
if (!empty($studentIds)) {
|
||||
$sdRows = $this->db->table('student_decisions')
|
||||
$finalRows = $db->table('student_decisions')
|
||||
->whereIn('student_id', $studentIds)
|
||||
->where('school_year', $schoolYear)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
foreach ($sdRows as $sd) {
|
||||
$sid = (int)($sd['student_id'] ?? 0);
|
||||
foreach ($finalRows as $fr) {
|
||||
$sid = (int)($fr['student_id'] ?? 0);
|
||||
|
||||
if ($sid > 0) {
|
||||
$sdMap[$sid] = $sd;
|
||||
$finalDecisionMap[$sid] = $fr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Load the most recent certificate per student for this school year ───
|
||||
foreach ($rows as $sid => &$row) {
|
||||
$row['consolidated_decision'] = $finalDecisionMap[$sid]['decision'] ?? null;
|
||||
|
||||
if (
|
||||
isset($finalDecisionMap[$sid]['year_score'])
|
||||
&& $finalDecisionMap[$sid]['year_score'] !== ''
|
||||
&& is_numeric($finalDecisionMap[$sid]['year_score'])
|
||||
) {
|
||||
$row['year_score'] = round((float)$finalDecisionMap[$sid]['year_score'], 2);
|
||||
}
|
||||
}
|
||||
|
||||
unset($row);
|
||||
|
||||
/*
|
||||
* Load certificate numbers.
|
||||
*/
|
||||
$certMap = [];
|
||||
|
||||
if (!empty($studentIds)) {
|
||||
$certRows = $this->db->table('certificate_records')
|
||||
$certRows = $db->table('certificate_records')
|
||||
->select('student_id, certificate_number, issued_at')
|
||||
->where('school_year', $schoolYear)
|
||||
->whereIn('student_id', $studentIds)
|
||||
@@ -2395,16 +2523,15 @@ class GradingController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rows as &$row) {
|
||||
$sid = (int)($row['student_id'] ?? 0);
|
||||
|
||||
$row['consolidated_decision'] = $sdMap[$sid]['decision'] ?? null;
|
||||
$row['year_score'] = $sdMap[$sid]['year_score'] ?? null;
|
||||
$row['certificate_number'] = $certMap[$sid] ?? '';
|
||||
foreach ($rows as $sid => &$row) {
|
||||
$row['certificate_number'] = $certMap[$sid] ?? '';
|
||||
}
|
||||
|
||||
unset($row);
|
||||
|
||||
// Re-index for the view.
|
||||
$rows = array_values($rows);
|
||||
|
||||
$canViewGrading = $this->userHasMenuUrl('grading');
|
||||
|
||||
return view('grading/below_sixty_decisions', [
|
||||
@@ -2416,51 +2543,148 @@ class GradingController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function saveBelowSixtyDecision()
|
||||
{
|
||||
$studentId = (int)$this->request->getPost('student_id');
|
||||
$semester = trim((string)$this->request->getPost('semester'));
|
||||
$schoolYear = trim((string)$this->request->getPost('school_year'));
|
||||
$decision = trim((string)$this->request->getPost('decision'));
|
||||
$notes = trim((string)$this->request->getPost('notes'));
|
||||
public function saveBelowSixtyDecision()
|
||||
{
|
||||
$studentId = (int)($this->request->getPost('student_id') ?? 0);
|
||||
$semester = strtolower(trim((string)($this->request->getPost('semester') ?? 'year')));
|
||||
$schoolYear = trim((string)($this->request->getPost('school_year') ?? ''));
|
||||
$decision = trim((string)($this->request->getPost('decision') ?? ''));
|
||||
$notes = trim((string)($this->request->getPost('notes') ?? ''));
|
||||
|
||||
if ($studentId <= 0 || $semester === '' || $schoolYear === '') {
|
||||
return redirect()->back()->with('error', 'Missing required data.');
|
||||
}
|
||||
|
||||
$allowed = ['', 'Pass', 'Repeat Class', 'Make-up exam in fall', 'Deferred decision', 'Expel', 'Withdrawn'];
|
||||
if (!in_array($decision, $allowed, true)) {
|
||||
return redirect()->back()->with('error', 'Invalid decision value.');
|
||||
}
|
||||
|
||||
$decisionModel = new BelowSixtyDecisionModel();
|
||||
$existing = $decisionModel
|
||||
->where('student_id', $studentId)
|
||||
->where('semester', $semester)
|
||||
->where('school_year', $schoolYear)
|
||||
->first();
|
||||
|
||||
$userId = (int)(session()->get('user_id') ?? 0) ?: null;
|
||||
$payload = [
|
||||
'decision' => $decision !== '' ? $decision : null,
|
||||
'notes' => $notes !== '' ? $notes : null,
|
||||
'decided_by' => $userId,
|
||||
];
|
||||
|
||||
if ($existing) {
|
||||
$decisionModel->update((int)$existing['id'], $payload);
|
||||
} else {
|
||||
$payload['student_id'] = $studentId;
|
||||
$payload['semester'] = $semester;
|
||||
$payload['school_year'] = $schoolYear;
|
||||
$decisionModel->insert($payload);
|
||||
}
|
||||
|
||||
$query = http_build_query(['semester' => $semester, 'school_year' => $schoolYear]);
|
||||
return redirect()->to(base_url('grading/below-60/decisions') . ($query ? '?' . $query : ''))
|
||||
->with('status', 'Decision saved.');
|
||||
if ($studentId <= 0 || $schoolYear === '') {
|
||||
return redirect()->back()->with('error', 'Missing student or school year.');
|
||||
}
|
||||
|
||||
// This decision page should feed certificate decisions as whole-year decisions.
|
||||
// Force year mode here so certificate logic receives final year decision.
|
||||
$semester = 'year';
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
/*
|
||||
* 1. Save/update the manual decision in below_sixty_decisions.
|
||||
* This keeps your below-60 page history working.
|
||||
*/
|
||||
$belowModel = new \App\Models\BelowSixtyDecisionModel();
|
||||
|
||||
$existingBelow = $belowModel
|
||||
->where('student_id', $studentId)
|
||||
->where('semester', $semester)
|
||||
->where('school_year', $schoolYear)
|
||||
->first();
|
||||
|
||||
$belowPayload = [
|
||||
'student_id' => $studentId,
|
||||
'semester' => $semester,
|
||||
'school_year' => $schoolYear,
|
||||
'decision' => $decision,
|
||||
'notes' => $notes,
|
||||
];
|
||||
|
||||
if ($existingBelow) {
|
||||
$belowModel->update((int)$existingBelow['id'], $belowPayload);
|
||||
} else {
|
||||
$belowModel->insert($belowPayload);
|
||||
}
|
||||
|
||||
/*
|
||||
* 2. Calculate the student's whole-year score.
|
||||
* Certificate page uses student_decisions.year_score.
|
||||
*/
|
||||
$scoreRows = $db->table('semester_scores ss')
|
||||
->select([
|
||||
'LOWER(TRIM(ss.semester)) AS sem_key',
|
||||
'ss.semester_score',
|
||||
'cs.class_section_name',
|
||||
])
|
||||
->join('classSection cs', 'cs.class_section_id = ss.class_section_id', 'left')
|
||||
->where('ss.student_id', $studentId)
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->whereIn('LOWER(TRIM(ss.semester))', ['fall', 'spring'])
|
||||
->where('ss.semester_score IS NOT NULL', null, false)
|
||||
->orderBy('ss.updated_at', 'DESC')
|
||||
->orderBy('ss.id', 'DESC')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$fallScore = null;
|
||||
$springScore = null;
|
||||
$classSectionName = null;
|
||||
|
||||
foreach ($scoreRows as $sr) {
|
||||
$semKey = strtolower(trim((string)($sr['sem_key'] ?? '')));
|
||||
$score = is_numeric($sr['semester_score'] ?? null) ? (float)$sr['semester_score'] : null;
|
||||
|
||||
if ($classSectionName === null && !empty($sr['class_section_name'])) {
|
||||
$classSectionName = (string)$sr['class_section_name'];
|
||||
}
|
||||
|
||||
if ($semKey === 'fall' && $fallScore === null) {
|
||||
$fallScore = $score;
|
||||
}
|
||||
|
||||
if ($semKey === 'spring' && $springScore === null) {
|
||||
$springScore = $score;
|
||||
}
|
||||
}
|
||||
|
||||
if ($fallScore !== null && $springScore !== null) {
|
||||
$yearScore = round(($fallScore + $springScore) / 2, 2);
|
||||
} elseif ($fallScore !== null) {
|
||||
$yearScore = round($fallScore, 2);
|
||||
} elseif ($springScore !== null) {
|
||||
$yearScore = round($springScore, 2);
|
||||
} else {
|
||||
$yearScore = null;
|
||||
}
|
||||
|
||||
/*
|
||||
* 3. Sync into student_decisions.
|
||||
* This is the part your certificate page needs.
|
||||
*
|
||||
* student_decisions is now year-based:
|
||||
* - no semester
|
||||
* - no semester_score
|
||||
* - uses year_score
|
||||
*/
|
||||
$source = $decision === '' ? 'pending' : 'manual';
|
||||
|
||||
$studentDecisionPayload = [
|
||||
'student_id' => $studentId,
|
||||
'school_year' => $schoolYear,
|
||||
'class_section_name' => $classSectionName,
|
||||
'year_score' => $yearScore,
|
||||
'decision' => $decision !== '' ? $decision : null,
|
||||
'source' => $source,
|
||||
'notes' => $notes !== '' ? $notes : null,
|
||||
'generated_by' => (int)(session()->get('user_id') ?? 0) ?: null,
|
||||
];
|
||||
|
||||
$existingStudentDecision = $db->table('student_decisions')
|
||||
->where('student_id', $studentId)
|
||||
->where('school_year', $schoolYear)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if ($existingStudentDecision) {
|
||||
$db->table('student_decisions')
|
||||
->where('id', (int)$existingStudentDecision['id'])
|
||||
->update($studentDecisionPayload);
|
||||
} else {
|
||||
$db->table('student_decisions')
|
||||
->insert($studentDecisionPayload);
|
||||
}
|
||||
|
||||
$query = http_build_query([
|
||||
'semester' => 'year',
|
||||
'school_year' => $schoolYear,
|
||||
]);
|
||||
|
||||
return redirect()
|
||||
->to(base_url('grading/below-60/decisions') . '?' . $query)
|
||||
->with('status', 'Decision saved and certificate decision updated.');
|
||||
}
|
||||
|
||||
public function studentDecisionDetails()
|
||||
{
|
||||
$studentId = (int)$this->request->getGet('student_id');
|
||||
@@ -2475,6 +2699,469 @@ class GradingController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function previewBelowSixtyDecisionEmail()
|
||||
{
|
||||
$studentId = (int)($this->request->getGet('student_id') ?? 0);
|
||||
$schoolYear = trim((string)($this->request->getGet('school_year') ?? ''));
|
||||
|
||||
if ($studentId <= 0 || $schoolYear === '') {
|
||||
return $this->response->setJSON([
|
||||
'error' => 'Missing student or school year.',
|
||||
]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Whole-year decision email.
|
||||
* Do NOT query semester_scores.semester = "year".
|
||||
* The Details button uses fetchAllSemestersForStudent(), so this email does too.
|
||||
*/
|
||||
$context = $this->getBelowSixtyDecisionEmailContext($studentId, $schoolYear);
|
||||
|
||||
if (empty($context['student'])) {
|
||||
return $this->response->setJSON([
|
||||
'error' => 'Student not found.',
|
||||
]);
|
||||
}
|
||||
|
||||
if (empty($context['decision_row']) || trim((string)($context['decision_row']['decision'] ?? '')) === '') {
|
||||
return $this->response->setJSON([
|
||||
'error' => 'No saved decision found for this student. Save a decision first.',
|
||||
]);
|
||||
}
|
||||
|
||||
$studentName = (string)($context['student_name'] ?? 'Student');
|
||||
$classSectionName = (string)($context['class_section_name'] ?? '');
|
||||
$decisionRow = $context['decision_row'];
|
||||
|
||||
$decision = trim((string)($decisionRow['decision'] ?? ''));
|
||||
$notes = trim((string)($decisionRow['notes'] ?? ''));
|
||||
|
||||
$fallScore = $context['fall_score'] ?? null;
|
||||
$springScore = $context['spring_score'] ?? null;
|
||||
$yearScore = $context['year_score'] ?? null;
|
||||
|
||||
/*
|
||||
* Same data used by the Details modal.
|
||||
*/
|
||||
$allSemesters = $context['all_semesters'] ?? [];
|
||||
|
||||
if (empty($allSemesters)) {
|
||||
$allSemesters = $this->fetchAllSemestersForStudent($studentId, $schoolYear);
|
||||
}
|
||||
|
||||
$fallText = $fallScore !== null
|
||||
? number_format((float)$fallScore, 2)
|
||||
: 'N/A';
|
||||
|
||||
$springText = $springScore !== null
|
||||
? number_format((float)$springScore, 2)
|
||||
: 'N/A';
|
||||
|
||||
$yearText = $yearScore !== null
|
||||
? number_format((float)$yearScore, 2)
|
||||
: 'N/A';
|
||||
|
||||
$subject = 'Whole Year Academic Decision — ' . $studentName . ' (' . $schoolYear . ')';
|
||||
|
||||
$html = '
|
||||
<p>Dear Parent/Guardian,</p>
|
||||
|
||||
<p>
|
||||
This message is regarding <strong>' . esc($studentName) . '</strong>
|
||||
for the <strong>' . esc($schoolYear) . '</strong> school year.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Class: <strong>' . esc($classSectionName !== '' ? $classSectionName : 'N/A') . '</strong><br>
|
||||
Fall Score: <strong>' . esc($fallText) . '</strong><br>
|
||||
Spring Score: <strong>' . esc($springText) . '</strong><br>
|
||||
Whole-Year Score: <strong>' . esc($yearText) . '</strong><br>
|
||||
Decision: <strong>' . esc($decision) . '</strong>
|
||||
</p>
|
||||
';
|
||||
|
||||
if ($notes !== '') {
|
||||
$html .= '
|
||||
<p>
|
||||
<strong>Decision Notes:</strong><br>
|
||||
' . nl2br(esc($notes)) . '
|
||||
</p>
|
||||
';
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the exact Details-button score/comment content into the email.
|
||||
*/
|
||||
$html .= $this->buildDecisionEmailDetailsHtml($allSemesters);
|
||||
|
||||
$html .= '
|
||||
<p>
|
||||
Please contact the school administration if you have any questions.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Regards,<br>
|
||||
Al Rahma Sunday School
|
||||
</p>
|
||||
';
|
||||
|
||||
return $this->response->setJSON([
|
||||
'ok' => true,
|
||||
'subject' => $subject,
|
||||
'html' => $html,
|
||||
'decision' => $decision,
|
||||
'score' => $yearScore,
|
||||
]);
|
||||
}
|
||||
|
||||
private function buildDecisionEmailDetailsHtml(array $semesters): string
|
||||
{
|
||||
if (empty($semesters)) {
|
||||
return '
|
||||
<p><strong>Detailed Scores and Comments</strong></p>
|
||||
<p>No detailed score data found.</p>
|
||||
';
|
||||
}
|
||||
|
||||
$scoreLabels = [
|
||||
'homework_avg' => 'Homework Avg',
|
||||
'project_avg' => 'Project Avg',
|
||||
'participation_score' => 'Participation',
|
||||
'test_avg' => 'Test Avg',
|
||||
'ptap_score' => 'PTAP Score',
|
||||
'attendance_score' => 'Attendance',
|
||||
'midterm_exam_score' => 'Midterm Score',
|
||||
'final_exam_score' => 'Final Exam',
|
||||
'semester_score' => 'Semester Score',
|
||||
];
|
||||
|
||||
$commentTypeLabels = [
|
||||
'general' => 'General',
|
||||
'attendance' => 'Attendance',
|
||||
'attendance_comment' => 'Attendance',
|
||||
'midterm' => 'Midterm',
|
||||
'final' => 'Final Exam',
|
||||
'ptap' => 'PTAP',
|
||||
];
|
||||
|
||||
$html = '
|
||||
<hr>
|
||||
<p><strong>Detailed Scores and Comments</strong></p>
|
||||
';
|
||||
|
||||
foreach ($semesters as $sem) {
|
||||
$semesterName = trim((string)($sem['semester'] ?? ''));
|
||||
|
||||
if ($semesterName === '') {
|
||||
$semesterName = 'Semester';
|
||||
}
|
||||
|
||||
$classSectionName = trim((string)($sem['class_section_name'] ?? ''));
|
||||
|
||||
$html .= '
|
||||
<p style="margin-top:16px;margin-bottom:6px;">
|
||||
<strong>' . esc($semesterName) . ' Semester</strong>';
|
||||
|
||||
if ($classSectionName !== '') {
|
||||
$html .= ' — ' . esc($classSectionName);
|
||||
}
|
||||
|
||||
$html .= '
|
||||
</p>
|
||||
|
||||
<table border="1"
|
||||
cellpadding="6"
|
||||
cellspacing="0"
|
||||
style="border-collapse:collapse;width:100%;margin-bottom:10px;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left" style="background:#f2f2f2;">Item</th>
|
||||
<th align="right" style="background:#f2f2f2;">Score</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
|
||||
$hasScoreRow = false;
|
||||
|
||||
foreach ($scoreLabels as $key => $label) {
|
||||
if (!array_key_exists($key, $sem)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $sem[$key];
|
||||
|
||||
if ($value === null || $value === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$scoreText = is_numeric($value)
|
||||
? number_format((float)$value, 2)
|
||||
: (string)$value;
|
||||
|
||||
$fontWeight = $key === 'semester_score' ? 'font-weight:bold;' : '';
|
||||
|
||||
$html .= '
|
||||
<tr>
|
||||
<td>' . esc($label) . '</td>
|
||||
<td align="right" style="' . $fontWeight . '">' . esc($scoreText) . '</td>
|
||||
</tr>
|
||||
';
|
||||
|
||||
$hasScoreRow = true;
|
||||
}
|
||||
|
||||
if (!$hasScoreRow) {
|
||||
$html .= '
|
||||
<tr>
|
||||
<td colspan="2">No scores recorded.</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
|
||||
$html .= '
|
||||
</tbody>
|
||||
</table>
|
||||
';
|
||||
|
||||
$comments = $sem['comments'] ?? [];
|
||||
|
||||
if (is_array($comments) && !empty($comments)) {
|
||||
$deduped = [];
|
||||
$seen = [];
|
||||
|
||||
foreach ($comments as $type => $text) {
|
||||
$text = trim((string)$text);
|
||||
|
||||
if ($text === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$label = $commentTypeLabels[$type] ?? (string)$type;
|
||||
$key = $label . '|' . $text;
|
||||
|
||||
if (isset($seen[$key])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$seen[$key] = true;
|
||||
$deduped[] = [
|
||||
'label' => $label,
|
||||
'text' => $text,
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($deduped)) {
|
||||
$html .= '
|
||||
<p style="margin:8px 0 4px;"><strong>Comments</strong></p>
|
||||
';
|
||||
|
||||
foreach ($deduped as $comment) {
|
||||
$html .= '
|
||||
<p style="margin:4px 0 8px;padding:8px;background:#f8f9fa;border-left:4px solid #999;">
|
||||
<strong>' . esc($comment['label']) . ':</strong><br>
|
||||
' . nl2br(esc($comment['text'])) . '
|
||||
</p>
|
||||
';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function sendBelowSixtyDecisionEmail()
|
||||
{
|
||||
$studentId = (int)($this->request->getPost('student_id') ?? 0);
|
||||
$schoolYear = trim((string)($this->request->getPost('school_year') ?? ''));
|
||||
$subjectInput = trim((string)($this->request->getPost('subject') ?? ''));
|
||||
$htmlInput = (string)($this->request->getPost('html') ?? '');
|
||||
|
||||
if ($studentId <= 0 || $schoolYear === '') {
|
||||
return redirect()->back()->with('error', 'Missing student or school year.');
|
||||
}
|
||||
|
||||
/*
|
||||
* Whole-year decision email.
|
||||
* Do NOT use sendBelowSixtyEmail(), because that one is semester-score based.
|
||||
*/
|
||||
$semester = 'year';
|
||||
|
||||
$context = $this->getBelowSixtyDecisionEmailContext($studentId, $schoolYear);
|
||||
|
||||
if (empty($context['student'])) {
|
||||
return redirect()->back()->with('error', 'Student not found.');
|
||||
}
|
||||
|
||||
if (empty($context['decision_row']) || trim((string)($context['decision_row']['decision'] ?? '')) === '') {
|
||||
return redirect()->back()->with('error', 'No saved decision found for this student.');
|
||||
}
|
||||
|
||||
$studentName = $context['student_name'];
|
||||
$classSectionName = $context['class_section_name'];
|
||||
$decisionRow = $context['decision_row'];
|
||||
|
||||
$subject = $subjectInput !== ''
|
||||
? $subjectInput
|
||||
: 'Whole Year Academic Decision — ' . $studentName . ' (' . $schoolYear . ')';
|
||||
|
||||
$payload = [
|
||||
'student_id' => $studentId,
|
||||
'student_name' => $studentName,
|
||||
'class_section_name' => $classSectionName,
|
||||
'semester' => 'year',
|
||||
'school_year' => $schoolYear,
|
||||
'decision' => (string)($decisionRow['decision'] ?? ''),
|
||||
'notes' => (string)($decisionRow['notes'] ?? ''),
|
||||
'subject' => $subject,
|
||||
'scores' => [
|
||||
'fall_score' => $context['fall_score'],
|
||||
'spring_score' => $context['spring_score'],
|
||||
'year_score' => $context['year_score'],
|
||||
],
|
||||
'all_semesters' => $context['all_semesters'],
|
||||
];
|
||||
|
||||
if (trim($htmlInput) !== '') {
|
||||
$payload['html'] = $htmlInput;
|
||||
}
|
||||
|
||||
Events::trigger('below60.decision_email', $payload);
|
||||
|
||||
$query = http_build_query([
|
||||
'semester' => 'year',
|
||||
'school_year' => $schoolYear,
|
||||
]);
|
||||
|
||||
return redirect()
|
||||
->to(base_url('grading/below-60/decisions') . '?' . $query)
|
||||
->with('status', 'Decision email sent to parent(s).');
|
||||
}
|
||||
|
||||
|
||||
private function getBelowSixtyDecisionEmailContext(int $studentId, string $schoolYear): array
|
||||
{
|
||||
$student = $this->db->table('students s')
|
||||
->select([
|
||||
's.id',
|
||||
's.firstname',
|
||||
's.lastname',
|
||||
's.is_active',
|
||||
])
|
||||
->where('s.id', $studentId)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
/*
|
||||
* Do not require is_active = 1 here.
|
||||
* You were getting "Student not found" even though the student ID exists.
|
||||
* If the record exists, let the email preview work.
|
||||
*/
|
||||
if (!$student) {
|
||||
return [
|
||||
'student' => null,
|
||||
'decision_row' => null,
|
||||
'student_name' => '',
|
||||
'class_section_name' => '',
|
||||
'fall_score' => null,
|
||||
'spring_score' => null,
|
||||
'year_score' => null,
|
||||
'all_semesters' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$studentName = trim((string)($student['firstname'] ?? '') . ' ' . (string)($student['lastname'] ?? ''));
|
||||
|
||||
if ($studentName === '') {
|
||||
$studentName = 'Student';
|
||||
}
|
||||
|
||||
$decisionRow = $this->db->table('below_sixty_decisions')
|
||||
->where('student_id', $studentId)
|
||||
->where('school_year', $schoolYear)
|
||||
->where('semester', 'year')
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
$scoreRows = $this->db->table('semester_scores ss')
|
||||
->select([
|
||||
'LOWER(TRIM(ss.semester)) AS sem_key',
|
||||
'ss.semester',
|
||||
'ss.semester_score',
|
||||
'ss.class_section_id',
|
||||
'cs.class_section_name',
|
||||
])
|
||||
->join('classSection cs', 'cs.class_section_id = ss.class_section_id', 'left')
|
||||
->where('ss.student_id', $studentId)
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->whereIn('LOWER(TRIM(ss.semester))', ['fall', 'spring'])
|
||||
->where('ss.semester_score IS NOT NULL', null, false)
|
||||
->orderBy('ss.updated_at', 'DESC')
|
||||
->orderBy('ss.id', 'DESC')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$fallScore = null;
|
||||
$springScore = null;
|
||||
$classSectionName = '';
|
||||
|
||||
foreach ($scoreRows as $sr) {
|
||||
$semKey = strtolower(trim((string)($sr['sem_key'] ?? '')));
|
||||
$score = is_numeric($sr['semester_score'] ?? null) ? (float)$sr['semester_score'] : null;
|
||||
|
||||
if ($classSectionName === '' && !empty($sr['class_section_name'])) {
|
||||
$classSectionName = (string)$sr['class_section_name'];
|
||||
}
|
||||
|
||||
if ($score === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($semKey === 'fall' && $fallScore === null) {
|
||||
$fallScore = $score;
|
||||
}
|
||||
|
||||
if ($semKey === 'spring' && $springScore === null) {
|
||||
$springScore = $score;
|
||||
}
|
||||
}
|
||||
|
||||
if ($classSectionName === '') {
|
||||
$enrollment = $this->db->table('student_class sc')
|
||||
->select('cs.class_section_name')
|
||||
->join('classSection cs', 'cs.class_section_id = sc.class_section_id', 'left')
|
||||
->where('sc.student_id', $studentId)
|
||||
->where('sc.school_year', $schoolYear)
|
||||
->orderBy('sc.id', 'DESC')
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
$classSectionName = (string)($enrollment['class_section_name'] ?? '');
|
||||
}
|
||||
|
||||
if ($fallScore !== null && $springScore !== null) {
|
||||
$yearScore = round(($fallScore + $springScore) / 2, 2);
|
||||
} elseif ($fallScore !== null) {
|
||||
$yearScore = round($fallScore, 2);
|
||||
} elseif ($springScore !== null) {
|
||||
$yearScore = round($springScore, 2);
|
||||
} else {
|
||||
$yearScore = null;
|
||||
}
|
||||
|
||||
return [
|
||||
'student' => $student,
|
||||
'decision_row' => $decisionRow,
|
||||
'student_name' => $studentName,
|
||||
'class_section_name' => $classSectionName,
|
||||
'fall_score' => $fallScore,
|
||||
'spring_score' => $springScore,
|
||||
'year_score' => $yearScore,
|
||||
'all_semesters' => $this->fetchAllSemestersForStudent($studentId, $schoolYear),
|
||||
];
|
||||
}
|
||||
|
||||
public function previewDecisionEmail()
|
||||
{
|
||||
$studentId = (int)$this->request->getGet('student_id');
|
||||
|
||||
@@ -317,18 +317,27 @@ class ReportCardsController extends PrintablesBaseController
|
||||
$examCommentTypes = $isSecond
|
||||
? ['final']
|
||||
: ($isFirst ? ['midterm'] : ['midterm', 'final']);
|
||||
$commentTypes = array_merge($examCommentTypes, ['ptap', 'attendance', 'attendance_comment']);
|
||||
$wantedCommentTypes = array_merge($examCommentTypes, ['ptap', 'attendance']);
|
||||
$hasCommentReview = $this->db->fieldExists('comment_review', 'score_comments');
|
||||
$commentSelect = $hasCommentReview
|
||||
? 'student_id, score_type, comment, comment_review'
|
||||
: 'student_id, score_type, comment';
|
||||
$hasCommentSemester = $this->db->fieldExists('semester', 'score_comments');
|
||||
$hasCommentUpdatedAt = $this->db->fieldExists('updated_at', 'score_comments');
|
||||
$commentSelectParts = ['student_id', 'score_type', 'comment'];
|
||||
if ($hasCommentReview) {
|
||||
$commentSelectParts[] = 'comment_review';
|
||||
}
|
||||
if ($hasCommentSemester) {
|
||||
$commentSelectParts[] = 'semester';
|
||||
}
|
||||
|
||||
// Do NOT filter comments by score_type or semester here.
|
||||
// A single bad row like "Attendance Comment", "attendance-comment", or a blank semester
|
||||
// should not make one student look incomplete while the PDF can still print the comment.
|
||||
$commentBuilder = $this->scoreCommentModel
|
||||
->select($commentSelect)
|
||||
->select(implode(', ', $commentSelectParts))
|
||||
->whereIn('student_id', $studentIds)
|
||||
->where('school_year', $year)
|
||||
->whereIn('score_type', $commentTypes);
|
||||
if ($sem !== '') {
|
||||
$this->applySemesterFilter($commentBuilder, $sem, 'semester');
|
||||
->where('school_year', $year);
|
||||
if ($hasCommentUpdatedAt) {
|
||||
$commentBuilder->orderBy('updated_at', 'DESC');
|
||||
}
|
||||
$commentRows = [];
|
||||
try {
|
||||
@@ -336,25 +345,92 @@ class ReportCardsController extends PrintablesBaseController
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
|
||||
$cleanComment = static function ($value): string {
|
||||
$text = (string)($value ?? '');
|
||||
$text = str_replace("\xc2\xa0", ' ', $text); // normalize non-breaking spaces
|
||||
return trim($text);
|
||||
};
|
||||
|
||||
$normalizeCommentType = static function ($value) use ($cleanComment): string {
|
||||
$type = strtolower($cleanComment($value));
|
||||
$type = preg_replace('/[^a-z0-9]+/', '_', $type);
|
||||
$type = trim((string)$type, '_');
|
||||
|
||||
$map = [
|
||||
'attendance_comment' => 'attendance',
|
||||
'attendance_comments' => 'attendance',
|
||||
'attendance' => 'attendance',
|
||||
'attendence' => 'attendance',
|
||||
'attendence_comment' => 'attendance',
|
||||
'attendence_comments' => 'attendance',
|
||||
'ptap_comment' => 'ptap',
|
||||
'ptap_comments' => 'ptap',
|
||||
'ptap' => 'ptap',
|
||||
'midterm_comment' => 'midterm',
|
||||
'midterm_comments' => 'midterm',
|
||||
'midterm' => 'midterm',
|
||||
'final_comment' => 'final',
|
||||
'final_comments' => 'final',
|
||||
'final' => 'final',
|
||||
];
|
||||
|
||||
return $map[$type] ?? $type;
|
||||
};
|
||||
|
||||
$normalizeSemester = static function ($value) use ($cleanComment): string {
|
||||
$v = strtolower($cleanComment($value));
|
||||
$v = preg_replace('/[^a-z0-9]+/', ' ', $v);
|
||||
$v = trim((string)$v);
|
||||
if (in_array($v, ['fall', 'first', 'first semester', 'semester 1', '1'], true)) {
|
||||
return 'fall';
|
||||
}
|
||||
if (in_array($v, ['spring', 'second', 'second semester', 'semester 2', '2'], true)) {
|
||||
return 'spring';
|
||||
}
|
||||
return $v;
|
||||
};
|
||||
$wantedSemester = $normalizeSemester($sem);
|
||||
|
||||
$commentsByStudent = [];
|
||||
$commentPriorityByStudent = [];
|
||||
foreach ($commentRows as $row) {
|
||||
$sid = (int)($row['student_id'] ?? 0);
|
||||
if ($sid <= 0) {
|
||||
continue;
|
||||
}
|
||||
$typeRaw = strtolower(trim((string)($row['score_type'] ?? '')));
|
||||
if ($typeRaw === '') {
|
||||
|
||||
$typeRaw = $normalizeCommentType($row['score_type'] ?? '');
|
||||
if ($typeRaw === '' || !in_array($typeRaw, $wantedCommentTypes, true)) {
|
||||
continue;
|
||||
}
|
||||
if ($typeRaw === 'attendance_comment') {
|
||||
$typeRaw = 'attendance';
|
||||
|
||||
$rawVal = $cleanComment($row['comment'] ?? '');
|
||||
if ($typeRaw === 'attendance') {
|
||||
// Attendance comments are stored in score_comments.comment.
|
||||
// Do not use comment_review here, because it can be blank while the PDF comment exists.
|
||||
$commentVal = $rawVal;
|
||||
} else {
|
||||
// For non-attendance comments, prefer reviewed text but fall back to the saved comment.
|
||||
$reviewVal = $hasCommentReview ? $cleanComment($row['comment_review'] ?? '') : '';
|
||||
$commentVal = $reviewVal !== '' ? $reviewVal : $rawVal;
|
||||
}
|
||||
$reviewVal = $hasCommentReview ? trim((string)($row['comment_review'] ?? '')) : '';
|
||||
$commentVal = $hasCommentReview ? $reviewVal : trim((string)($row['comment'] ?? ''));
|
||||
if ($commentVal === '') {
|
||||
continue;
|
||||
}
|
||||
$commentsByStudent[$sid][$typeRaw] = $commentVal;
|
||||
|
||||
$rowSemester = $hasCommentSemester ? $normalizeSemester($row['semester'] ?? '') : '';
|
||||
$priority = 1;
|
||||
if ($wantedSemester !== '' && $rowSemester === $wantedSemester) {
|
||||
$priority = 3;
|
||||
} elseif ($rowSemester === '') {
|
||||
$priority = 2;
|
||||
}
|
||||
|
||||
$existingPriority = $commentPriorityByStudent[$sid][$typeRaw] ?? 0;
|
||||
if (!isset($commentsByStudent[$sid][$typeRaw]) || $priority >= $existingPriority) {
|
||||
$commentsByStudent[$sid][$typeRaw] = $commentVal;
|
||||
$commentPriorityByStudent[$sid][$typeRaw] = $priority;
|
||||
}
|
||||
}
|
||||
|
||||
$isNumeric = static fn($v) => $v !== null && $v !== '' && is_numeric($v);
|
||||
@@ -467,6 +543,20 @@ class ReportCardsController extends PrintablesBaseController
|
||||
if (trim((string)($commentSet['ptap'] ?? '')) === '') {
|
||||
$missing[] = 'PTAP comment';
|
||||
}
|
||||
|
||||
// Keep completeness consistent with the PDF report generation:
|
||||
// the report can auto-generate an attendance comment from attendance_score.
|
||||
if (trim((string)($commentSet['attendance'] ?? '')) === '' && $isNumeric($attendanceScore)) {
|
||||
$autoAttendance = attendance_comment_from_score(
|
||||
(float)$attendanceScore,
|
||||
trim((string)($student['firstname'] ?? ''))
|
||||
);
|
||||
if ($autoAttendance !== null && trim((string)$autoAttendance) !== '') {
|
||||
$commentSet['attendance'] = $autoAttendance;
|
||||
$warnings[] = 'Attendance comment computed from attendance score';
|
||||
}
|
||||
}
|
||||
|
||||
if (trim((string)($commentSet['attendance'] ?? '')) === '') {
|
||||
$missing[] = 'Attendance comment';
|
||||
}
|
||||
@@ -1014,9 +1104,9 @@ $drawRankCell = static function (
|
||||
$pdf->Rect($x, $y, $w, $h);
|
||||
$pdf->SetXY($x + $pad, $y + 3);
|
||||
$pdf->SetFont('Helvetica', 'B', 11);
|
||||
$pdf->Write(5, ' Rank: ');
|
||||
$pdf->Write(5, ' Class Rank: ');
|
||||
|
||||
$labelWidth = $pdf->GetStringWidth(' Rank: ');
|
||||
$labelWidth = $pdf->GetStringWidth(' Class Rank: ');
|
||||
$pdf->SetFont('Helvetica', '', 12);
|
||||
$pdf->SetXY($x + 2 + $labelWidth, $y + 3);
|
||||
$pdf->Write(5, $rankValue);
|
||||
@@ -1531,10 +1621,16 @@ $scoresEndY = $pdf->GetY();
|
||||
if ($typeRaw === 'attendance_comment') {
|
||||
$typeRaw = 'attendance';
|
||||
}
|
||||
$reviewVal = trim((string)($row['comment_review'] ?? ''));
|
||||
$commentVal = $this->db->fieldExists('comment_review', 'score_comments')
|
||||
? $reviewVal
|
||||
: trim((string)($row['comment'] ?? ''));
|
||||
$rawComment = trim((string)($row['comment'] ?? ''));
|
||||
if ($typeRaw === 'attendance') {
|
||||
// Attendance comments must come from score_comments.comment.
|
||||
$commentVal = $rawComment;
|
||||
} else {
|
||||
$reviewVal = trim((string)($row['comment_review'] ?? ''));
|
||||
$commentVal = $this->db->fieldExists('comment_review', 'score_comments') && $reviewVal !== ''
|
||||
? $reviewVal
|
||||
: $rawComment;
|
||||
}
|
||||
if ($commentVal === '') {
|
||||
continue;
|
||||
}
|
||||
@@ -1732,161 +1828,200 @@ $scoresEndY = $pdf->GetY();
|
||||
];
|
||||
}
|
||||
|
||||
private function calculateTermRanking(
|
||||
int $studentId,
|
||||
int $sectionCode,
|
||||
?int $sectionId,
|
||||
string $schoolYear,
|
||||
?string $semester,
|
||||
?float $studentScore
|
||||
): ?array {
|
||||
if ($studentId <= 0 || $schoolYear === '' || $studentScore === null) {
|
||||
return null;
|
||||
private function calculateTermRanking(
|
||||
int $studentId,
|
||||
int $sectionCode,
|
||||
?int $sectionId,
|
||||
string $schoolYear,
|
||||
?string $semester,
|
||||
?float $studentScore
|
||||
): ?array {
|
||||
if ($studentId <= 0 || $schoolYear === '' || $studentScore === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sectionIds = array_values(array_unique(array_filter([
|
||||
$sectionCode > 0 ? $sectionCode : null,
|
||||
$sectionId && $sectionId > 0 ? $sectionId : null,
|
||||
])));
|
||||
|
||||
if (empty($sectionIds)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$semesterForRank = trim((string)$semester);
|
||||
$rankByFinalScore = $this->normalizeSemester($semesterForRank) === 'spring';
|
||||
|
||||
$builder = $this->db->table('semester_scores ss')
|
||||
->select('ss.student_id, ss.semester, ss.semester_score, ss.updated_at, ss.id, s.firstname, s.lastname')
|
||||
->join('students s', 's.id = ss.student_id', 'inner')
|
||||
->where('s.is_active', 1)
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->whereIn('ss.class_section_id', $sectionIds)
|
||||
->orderBy('ss.updated_at', 'DESC')
|
||||
->orderBy('ss.id', 'DESC');
|
||||
|
||||
if ($semesterForRank !== '') {
|
||||
$this->applySemesterFilter($builder, $semesterForRank, 'ss.semester');
|
||||
}
|
||||
|
||||
$rows = $builder->get()->getResultArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$scoresByStudent = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$sid = (int)($row['student_id'] ?? 0);
|
||||
|
||||
if ($sid <= 0 || isset($scoresByStudent[$sid])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sectionIds = array_values(array_unique(array_filter([
|
||||
$sectionCode > 0 ? $sectionCode : null,
|
||||
$sectionId && $sectionId > 0 ? $sectionId : null,
|
||||
])));
|
||||
$scoreVal = $row['semester_score'] ?? null;
|
||||
|
||||
if (empty($sectionIds)) {
|
||||
return null;
|
||||
if (!is_numeric($scoreVal)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$semesterForRank = trim((string)$semester);
|
||||
$rankByFinalScore = $this->normalizeSemester($semesterForRank) === 'spring';
|
||||
$rawScore = (float)$scoreVal;
|
||||
|
||||
$builder = $this->db->table('semester_scores ss')
|
||||
->select('ss.student_id, ss.semester, ss.semester_score, ss.updated_at, ss.id, s.firstname, s.lastname')
|
||||
->join('students s', 's.id = ss.student_id', 'inner')
|
||||
->where('s.is_active', 1)
|
||||
$scoresByStudent[$sid] = [
|
||||
'student_id' => $sid,
|
||||
'score' => $rawScore,
|
||||
'rank_score' => round($rawScore, 1),
|
||||
'firstname' => trim((string)($row['firstname'] ?? '')),
|
||||
'lastname' => trim((string)($row['lastname'] ?? '')),
|
||||
];
|
||||
}
|
||||
|
||||
if (empty($scoresByStudent) || !isset($scoresByStudent[$studentId])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// For Spring, rank by final year average:
|
||||
// (first semester score + second semester score) / 2.
|
||||
if ($rankByFinalScore) {
|
||||
$studentIds = array_keys($scoresByStudent);
|
||||
|
||||
$firstRowsBuilder = $this->db->table('semester_scores ss')
|
||||
->select('ss.student_id, ss.semester, ss.semester_score, ss.updated_at, ss.id')
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->whereIn('ss.student_id', $studentIds)
|
||||
->whereIn('ss.class_section_id', $sectionIds)
|
||||
->orderBy('ss.updated_at', 'DESC')
|
||||
->orderBy('ss.id', 'DESC');
|
||||
|
||||
if ($semesterForRank !== '') {
|
||||
$this->applySemesterFilter($builder, $semesterForRank, 'ss.semester');
|
||||
$this->applySemesterExclusion($firstRowsBuilder, $semesterForRank, 'ss.semester');
|
||||
}
|
||||
|
||||
$rows = $builder->get()->getResultArray();
|
||||
if (empty($rows)) {
|
||||
return null;
|
||||
}
|
||||
$firstRows = $firstRowsBuilder->get()->getResultArray();
|
||||
|
||||
$scoresByStudent = [];
|
||||
$studentIds = [];
|
||||
foreach ($rows as $row) {
|
||||
$firstScoresByStudent = [];
|
||||
|
||||
foreach ($firstRows as $row) {
|
||||
$sid = (int)($row['student_id'] ?? 0);
|
||||
if ($sid <= 0 || isset($scoresByStudent[$sid])) {
|
||||
|
||||
if ($sid <= 0 || isset($firstScoresByStudent[$sid])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$scoreVal = $row['semester_score'] ?? null;
|
||||
|
||||
if (!is_numeric($scoreVal)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$scoresByStudent[$sid] = [
|
||||
'student_id' => $sid,
|
||||
'score' => round((float)$scoreVal, 4),
|
||||
'firstname' => trim((string)($row['firstname'] ?? '')),
|
||||
'lastname' => trim((string)($row['lastname'] ?? '')),
|
||||
];
|
||||
$studentIds[] = $sid;
|
||||
$firstScoresByStudent[$sid] = (float)$scoreVal;
|
||||
}
|
||||
|
||||
foreach ($scoresByStudent as $sid => &$rankRow) {
|
||||
if (!isset($firstScoresByStudent[$sid])) {
|
||||
unset($scoresByStudent[$sid]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$avg = ((float)$firstScoresByStudent[$sid] + (float)$rankRow['score']) / 2;
|
||||
|
||||
$rankRow['score'] = $avg;
|
||||
$rankRow['rank_score'] = round($avg, 1);
|
||||
}
|
||||
|
||||
unset($rankRow);
|
||||
|
||||
if (empty($scoresByStudent) || !isset($scoresByStudent[$studentId])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($rankByFinalScore) {
|
||||
$firstRowsBuilder = $this->db->table('semester_scores ss')
|
||||
->select('ss.student_id, ss.semester_score, ss.updated_at, ss.id')
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->whereIn('ss.class_section_id', $sectionIds)
|
||||
->whereIn('ss.student_id', $studentIds)
|
||||
->orderBy('ss.updated_at', 'DESC')
|
||||
->orderBy('ss.id', 'DESC');
|
||||
|
||||
if ($semesterForRank !== '') {
|
||||
$this->applySemesterExclusion($firstRowsBuilder, $semesterForRank, 'ss.semester');
|
||||
}
|
||||
|
||||
$firstRows = $firstRowsBuilder->get()->getResultArray();
|
||||
$firstScoresByStudent = [];
|
||||
foreach ($firstRows as $row) {
|
||||
$sid = (int)($row['student_id'] ?? 0);
|
||||
if ($sid <= 0 || isset($firstScoresByStudent[$sid])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$scoreVal = $row['semester_score'] ?? null;
|
||||
if (!is_numeric($scoreVal)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$firstScoresByStudent[$sid] = (float)$scoreVal;
|
||||
}
|
||||
|
||||
foreach ($scoresByStudent as $sid => &$rankRow) {
|
||||
if (!isset($firstScoresByStudent[$sid])) {
|
||||
unset($scoresByStudent[$sid]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$rankRow['score'] = round(((float)$firstScoresByStudent[$sid] + (float)$rankRow['score']) / 2, 4);
|
||||
}
|
||||
unset($rankRow);
|
||||
|
||||
if (empty($scoresByStudent) || !isset($scoresByStudent[$studentId])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$scoresByStudent[$studentId]['score'] = round((float)$studentScore, 4);
|
||||
}
|
||||
|
||||
$rankable = array_values($scoresByStudent);
|
||||
usort($rankable, static function (array $a, array $b): int {
|
||||
$scoreCmp = $b['score'] <=> $a['score'];
|
||||
if ($scoreCmp !== 0) {
|
||||
return $scoreCmp;
|
||||
}
|
||||
|
||||
$lastCmp = strcasecmp($a['lastname'], $b['lastname']);
|
||||
if ($lastCmp !== 0) {
|
||||
return $lastCmp;
|
||||
}
|
||||
|
||||
$firstCmp = strcasecmp($a['firstname'], $b['firstname']);
|
||||
if ($firstCmp !== 0) {
|
||||
return $firstCmp;
|
||||
}
|
||||
|
||||
return $a['student_id'] <=> $b['student_id'];
|
||||
});
|
||||
|
||||
$position = null;
|
||||
$previousScore = null;
|
||||
foreach ($rankable as $index => $row) {
|
||||
if ($previousScore === null || abs($row['score'] - $previousScore) > 0.0001) {
|
||||
$position = $index + 1;
|
||||
$previousScore = $row['score'];
|
||||
}
|
||||
|
||||
if ((int)$row['student_id'] === $studentId) {
|
||||
$total = count($rankable);
|
||||
return [
|
||||
'position' => $position,
|
||||
'total' => $total,
|
||||
'display' => $this->formatOrdinal($position) . ' out of ' . $total,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
// Force the selected student to use the exact score already computed for the report.
|
||||
// Then rank using the displayed precision: one decimal.
|
||||
$scoresByStudent[$studentId]['score'] = (float)$studentScore;
|
||||
$scoresByStudent[$studentId]['rank_score'] = round((float)$studentScore, 1);
|
||||
} else {
|
||||
// Fall: also force selected student to match the report-card computed score.
|
||||
$scoresByStudent[$studentId]['score'] = (float)$studentScore;
|
||||
$scoresByStudent[$studentId]['rank_score'] = round((float)$studentScore, 1);
|
||||
}
|
||||
|
||||
$rankable = array_values($scoresByStudent);
|
||||
|
||||
usort($rankable, static function (array $a, array $b): int {
|
||||
// Highest displayed/rank score first.
|
||||
$scoreCmp = $b['rank_score'] <=> $a['rank_score'];
|
||||
|
||||
if ($scoreCmp !== 0) {
|
||||
return $scoreCmp;
|
||||
}
|
||||
|
||||
// Tie-breakers only control display order.
|
||||
// They do NOT change rank.
|
||||
$lastCmp = strcasecmp($a['lastname'], $b['lastname']);
|
||||
|
||||
if ($lastCmp !== 0) {
|
||||
return $lastCmp;
|
||||
}
|
||||
|
||||
$firstCmp = strcasecmp($a['firstname'], $b['firstname']);
|
||||
|
||||
if ($firstCmp !== 0) {
|
||||
return $firstCmp;
|
||||
}
|
||||
|
||||
return $a['student_id'] <=> $b['student_id'];
|
||||
});
|
||||
|
||||
$position = null;
|
||||
$previousScore = null;
|
||||
|
||||
foreach ($rankable as $index => $row) {
|
||||
$currentScore = (float)$row['rank_score'];
|
||||
|
||||
// Competition ranking:
|
||||
// 1, 1, 3, 4...
|
||||
// Same score = same rank.
|
||||
if ($previousScore === null || abs($currentScore - $previousScore) > 0.0001) {
|
||||
$position = $index + 1;
|
||||
$previousScore = $currentScore;
|
||||
}
|
||||
|
||||
if ((int)$row['student_id'] === $studentId) {
|
||||
$total = count($rankable);
|
||||
|
||||
return [
|
||||
'position' => $position,
|
||||
'total' => $total,
|
||||
'score' => $currentScore,
|
||||
'display' => $this->formatOrdinal($position) . ' out of ' . $total,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function formatOrdinal(?int $value): string
|
||||
{
|
||||
$n = (int)$value;
|
||||
|
||||
@@ -14,6 +14,47 @@ $totalConfirmed = array_sum(array_column($classResults, 'confirmed'));
|
||||
$totalSurprise = array_sum(array_column($classResults, 'surprises'));
|
||||
$totalMissed = array_sum(array_column($classResults, 'missed'));
|
||||
$overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted * 100) : ($totalActual === 0 ? 100 : 0);
|
||||
|
||||
// Winner gender breakdown.
|
||||
// "Winner" means actual year-end trophy winner.
|
||||
$totalWinnerBoys = 0;
|
||||
$totalWinnerGirls = 0;
|
||||
$totalWinnerOther = 0;
|
||||
|
||||
// Sticker names.
|
||||
// 2 columns x 10 rows = 20 stickers per page.
|
||||
// Stickers print NAME ONLY.
|
||||
$winnerStickerNames = [];
|
||||
|
||||
foreach ($classResults as $cls) {
|
||||
foreach (($cls['students'] ?? []) as $s) {
|
||||
if (empty($s['actual'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$gender = strtolower(trim((string)($s['gender'] ?? '')));
|
||||
|
||||
if (in_array($gender, ['male', 'm', 'boy', 'boys'], true)) {
|
||||
$totalWinnerBoys++;
|
||||
} elseif (in_array($gender, ['female', 'f', 'girl', 'girls'], true)) {
|
||||
$totalWinnerGirls++;
|
||||
} else {
|
||||
$totalWinnerOther++;
|
||||
}
|
||||
|
||||
$name = trim((string)($s['name'] ?? ''));
|
||||
|
||||
if ($name !== '') {
|
||||
$winnerStickerNames[] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$totalWinners = $totalWinnerBoys + $totalWinnerGirls + $totalWinnerOther;
|
||||
|
||||
$winnerBoysPct = $totalWinners > 0 ? round(($totalWinnerBoys / $totalWinners) * 100, 1) : 0;
|
||||
$winnerGirlsPct = $totalWinners > 0 ? round(($totalWinnerGirls / $totalWinners) * 100, 1) : 0;
|
||||
$winnerOtherPct = $totalWinners > 0 ? round(($totalWinnerOther / $totalWinners) * 100, 1) : 0;
|
||||
?>
|
||||
|
||||
<style>
|
||||
@@ -23,23 +64,141 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
.status-none { color:#adb5bd; }
|
||||
|
||||
.print-only { display: none !important; }
|
||||
.winner-sticker-print-area { display: none; }
|
||||
|
||||
@page {
|
||||
size: Letter portrait;
|
||||
margin: 0.35in;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.no-print { display: none !important; }
|
||||
.print-only { display: block !important; }
|
||||
.screen-only { display: none !important; }
|
||||
|
||||
body { font-size: 11px; }
|
||||
.container-fluid { padding: 0 !important; }
|
||||
h2, h3 { font-size: 13px; margin-bottom: .3rem; }
|
||||
.print-page-break { break-before: page; }
|
||||
|
||||
table { width: 100%; border-collapse: collapse; font-size: 10px; }
|
||||
table th, table td { border: 1px solid #bbb; padding: 3px 5px; }
|
||||
table thead { background: #333 !important; color: #fff !important;
|
||||
-webkit-print-color-adjust: exact; print-color-adjust: exact; }
|
||||
table thead th { position: static !important; top: auto !important; box-shadow: none !important; }
|
||||
table thead {
|
||||
background: #333 !important;
|
||||
color: #fff !important;
|
||||
-webkit-print-color-adjust: exact;
|
||||
print-color-adjust: exact;
|
||||
}
|
||||
table thead th {
|
||||
position: static !important;
|
||||
top: auto !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.s-confirmed { color: #198754; font-weight: bold; }
|
||||
.s-surprise { color: #0d6efd; font-weight: bold; }
|
||||
.s-missed { color: #fd7e14; font-weight: bold; }
|
||||
|
||||
body.print-stickers-mode {
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
background: #fff !important;
|
||||
}
|
||||
|
||||
body.print-stickers-mode * {
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
body.print-stickers-mode header,
|
||||
body.print-stickers-mode nav,
|
||||
body.print-stickers-mode aside,
|
||||
body.print-stickers-mode footer,
|
||||
body.print-stickers-mode .navbar,
|
||||
body.print-stickers-mode .sidebar,
|
||||
body.print-stickers-mode .topbar,
|
||||
body.print-stickers-mode .app-header,
|
||||
body.print-stickers-mode .main-header,
|
||||
body.print-stickers-mode .layout-header,
|
||||
body.print-stickers-mode .management-header,
|
||||
body.print-stickers-mode .page-header,
|
||||
body.print-stickers-mode .breadcrumb,
|
||||
body.print-stickers-mode .brand,
|
||||
body.print-stickers-mode .logo,
|
||||
body.print-stickers-mode .header,
|
||||
body.print-stickers-mode .no-print,
|
||||
body.print-stickers-mode .screen-only,
|
||||
body.print-stickers-mode .print-only {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
body.print-stickers-mode .container-fluid > *:not(#winnerStickerPrintArea) {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
body.print-stickers-mode .container-fluid {
|
||||
display: block !important;
|
||||
visibility: visible !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
width: 100% !important;
|
||||
max-width: none !important;
|
||||
}
|
||||
|
||||
body.print-stickers-mode #winnerStickerPrintArea {
|
||||
display: block !important;
|
||||
visibility: visible !important;
|
||||
position: static !important;
|
||||
width: 100% !important;
|
||||
height: auto !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
body.print-stickers-mode #winnerStickerPrintArea,
|
||||
body.print-stickers-mode #winnerStickerPrintArea * {
|
||||
visibility: visible !important;
|
||||
}
|
||||
|
||||
body.print-stickers-mode .sticker-page {
|
||||
display: grid !important;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
grid-template-rows: repeat(10, 1fr);
|
||||
gap: 0;
|
||||
width: 100%;
|
||||
height: 10.3in;
|
||||
page-break-after: always;
|
||||
break-after: page;
|
||||
}
|
||||
|
||||
body.print-stickers-mode .sticker-page:last-child {
|
||||
page-break-after: auto;
|
||||
break-after: auto;
|
||||
}
|
||||
|
||||
body.print-stickers-mode .sticker-cell {
|
||||
display: flex !important;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
border: none;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body.print-stickers-mode .sticker-name {
|
||||
display: block !important;
|
||||
font-size: 20pt;
|
||||
font-weight: 700;
|
||||
line-height: 1.1;
|
||||
color: #000 !important;
|
||||
}
|
||||
|
||||
body.print-stickers-mode .sticker-empty {
|
||||
visibility: hidden !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -57,10 +216,16 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
with the <strong>year-end result</strong> based on the average of Fall & Spring scores.
|
||||
</p>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
|
||||
<div class="d-flex gap-2 flex-wrap">
|
||||
<button onclick="printWithCharts()" class="btn btn-outline-secondary btn-sm">
|
||||
<i class="bi bi-printer-fill me-1"></i>Print
|
||||
</button>
|
||||
|
||||
<button onclick="printWinnerStickers()" class="btn btn-warning btn-sm">
|
||||
<i class="bi bi-tags-fill me-1"></i>Print Winner Stickers
|
||||
</button>
|
||||
|
||||
<a href="<?= site_url('administrator/trophy?' . http_build_query(['school_year' => $selectedYear, 'percentile' => $selectedPercentile])) ?>"
|
||||
class="btn btn-outline-secondary btn-sm">
|
||||
<i class="bi bi-arrow-left me-1"></i>Back
|
||||
@@ -75,18 +240,27 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<label class="form-label mb-1 small fw-semibold">School Year</label>
|
||||
<select name="school_year" class="form-select form-select-sm" style="min-width:130px;">
|
||||
<?php foreach ($years as $yr): ?>
|
||||
<option value="<?= esc($yr) ?>" <?= $yr === $selectedYear ? 'selected' : '' ?>><?= esc($yr) ?></option>
|
||||
<option value="<?= esc($yr) ?>" <?= $yr === $selectedYear ? 'selected' : '' ?>>
|
||||
<?= esc($yr) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-auto">
|
||||
<label class="form-label mb-1 small fw-semibold">Percentile</label>
|
||||
<div class="input-group input-group-sm" style="width:110px;">
|
||||
<input type="number" name="percentile" class="form-control"
|
||||
min="1" max="99" step="1" value="<?= (int)$selectedPercentile ?>">
|
||||
<input type="number"
|
||||
name="percentile"
|
||||
class="form-control"
|
||||
min="1"
|
||||
max="99"
|
||||
step="1"
|
||||
value="<?= (int)$selectedPercentile ?>">
|
||||
<span class="input-group-text">%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-primary btn-sm">Apply</button>
|
||||
</div>
|
||||
@@ -111,7 +285,7 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<div class="row g-3 mb-4">
|
||||
<?php foreach ([
|
||||
[$totalPredicted, 'Predicted (Fall)', 'primary', null, $totalStudents > 0 ? round($totalPredicted / $totalStudents * 100) . '% of students' : '—'],
|
||||
[$totalActual, 'Actual (Year)', 'warning', 'dark', $totalStudents > 0 ? round($totalActual / $totalStudents * 100) . '% of students' : '—'],
|
||||
[$totalActual, 'Actual (Year)', 'warning', 'dark', $totalStudents > 0 ? round($totalActual / $totalStudents * 100) . '% of students' : '—'],
|
||||
[$totalConfirmed, 'Confirmed', 'success', null, $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted * 100) . '% of predicted' : '—'],
|
||||
[$totalSurprise, 'Surprises', 'info', 'dark', 'Not in prediction'],
|
||||
[$totalMissed, 'Missed', 'orange', null, 'Were predicted'],
|
||||
@@ -147,19 +321,29 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<span class="fw-bold fs-6"><?= esc($cls['section_name']) ?></span>
|
||||
<span class="badge bg-primary"><?= $cls['predicted_count'] ?> predicted</span>
|
||||
<span class="badge bg-warning text-dark"><?= $cls['actual_count'] ?> actual</span>
|
||||
|
||||
<?php if ($cls['confirmed'] > 0): ?>
|
||||
<span class="badge bg-success"><?= $cls['confirmed'] ?> confirmed</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($cls['surprises'] > 0): ?>
|
||||
<span class="badge bg-info text-dark"><?= $cls['surprises'] ?> surprise<?= $cls['surprises'] > 1 ? 's' : '' ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($cls['missed'] > 0): ?>
|
||||
<span class="badge" style="background:#fd7e14"><?= $cls['missed'] ?> missed</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-3 small align-items-center">
|
||||
<span class="text-muted">Fall ≥ <strong><?= $cls['fall_threshold'] !== null ? number_format((float)$cls['fall_threshold'], 1) : '—' ?></strong></span>
|
||||
<span class="text-muted">Year ≥ <strong><?= $cls['year_threshold'] !== null ? number_format((float)$cls['year_threshold'], 1) : '—' ?></strong></span>
|
||||
<span class="text-muted">
|
||||
Fall ≥
|
||||
<strong><?= $cls['fall_threshold'] !== null ? number_format((float)$cls['fall_threshold'], 1) : '—' ?></strong>
|
||||
</span>
|
||||
<span class="text-muted">
|
||||
Year ≥
|
||||
<strong><?= $cls['year_threshold'] !== null ? number_format((float)$cls['year_threshold'], 1) : '—' ?></strong>
|
||||
</span>
|
||||
<span class="fw-semibold">
|
||||
Accuracy:
|
||||
<span class="<?= $cls['accuracy'] >= 80 ? 'text-success' : ($cls['accuracy'] >= 50 ? 'text-warning' : 'text-danger') ?>">
|
||||
@@ -168,6 +352,7 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-sm table-hover mb-0 align-middle" data-no-mgmt-sticky>
|
||||
<thead class="table-light">
|
||||
@@ -183,12 +368,16 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<th class="text-center">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php $rank = 0; foreach ($cls['students'] as $s):
|
||||
if ($s['status'] === 'none') continue;
|
||||
$rank++;
|
||||
$isMale = strtolower($s['gender'] ?? '') === 'male';
|
||||
$rowBg = match ($s['status']) {
|
||||
|
||||
$genderNorm = strtolower(trim((string)($s['gender'] ?? '')));
|
||||
$isMale = in_array($genderNorm, ['male', 'm', 'boy'], true);
|
||||
|
||||
$rowBg = match ($s['status']) {
|
||||
'confirmed' => 'table-success',
|
||||
'surprise' => 'table-primary',
|
||||
'missed' => 'table-warning',
|
||||
@@ -203,9 +392,9 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<?= $isMale ? 'M' : 'F' ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-end small"><?= $s['fall_score'] !== null ? number_format($s['fall_score'], 1) : '<span class="text-muted">—</span>' ?></td>
|
||||
<td class="text-end small"><?= $s['fall_score'] !== null ? number_format($s['fall_score'], 1) : '<span class="text-muted">—</span>' ?></td>
|
||||
<td class="text-end small"><?= $s['spring_score'] !== null ? number_format($s['spring_score'], 1) : '<span class="text-muted">—</span>' ?></td>
|
||||
<td class="text-end small fw-semibold"><?= $s['year_score'] !== null ? number_format($s['year_score'], 1) : '<span class="text-muted">—</span>' ?></td>
|
||||
<td class="text-end small fw-semibold"><?= $s['year_score'] !== null ? number_format($s['year_score'], 1) : '<span class="text-muted">—</span>' ?></td>
|
||||
<td class="text-center small">
|
||||
<?= $s['predicted']
|
||||
? '<span class="badge bg-primary">Yes</span>'
|
||||
@@ -237,6 +426,7 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<div class="card-header bg-dark text-white fw-semibold py-2">
|
||||
<i class="bi bi-bar-chart-fill me-2"></i>Prediction Accuracy Summary — <?= esc($selectedYear) ?>
|
||||
</div>
|
||||
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-sm table-bordered mb-0 align-middle" data-no-mgmt-sticky>
|
||||
<thead class="table-dark">
|
||||
@@ -253,6 +443,7 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<th class="text-end pe-2">Year ≥</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($classResults as $cls): ?>
|
||||
<tr>
|
||||
@@ -271,6 +462,7 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
||||
<tfoot class="table-secondary fw-semibold">
|
||||
<tr>
|
||||
<td class="ps-2">Total</td>
|
||||
@@ -292,7 +484,6 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
|
||||
<!-- Charts -->
|
||||
<div class="row g-4 mt-1 mb-4">
|
||||
<!-- Grouped bar: predicted / actual / confirmed / surprises / missed per class -->
|
||||
<div class="col-12 col-lg-8">
|
||||
<div class="border rounded p-3 h-100">
|
||||
<div class="small fw-semibold text-muted mb-2">
|
||||
@@ -301,7 +492,7 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<canvas id="chart-counts" style="max-height:280px;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Bar: accuracy % per class + doughnut overall breakdown -->
|
||||
|
||||
<div class="col-12 col-lg-4">
|
||||
<div class="row g-3 h-100">
|
||||
<div class="col-12">
|
||||
@@ -312,6 +503,7 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<canvas id="chart-accuracy" style="max-height:130px;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="border rounded p-3">
|
||||
<div class="small fw-semibold text-muted mb-2">
|
||||
@@ -324,6 +516,93 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Winner gender summary -->
|
||||
<div class="card shadow-sm mt-2 mb-4">
|
||||
<div class="card-header bg-dark text-white fw-semibold py-2">
|
||||
<i class="bi bi-gender-ambiguous me-2"></i>Winner Gender Breakdown
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="row g-3 align-items-stretch">
|
||||
<div class="col-12 col-lg-3">
|
||||
<div class="border rounded p-3 text-center h-100">
|
||||
<div class="text-muted small mb-1">Total Winners</div>
|
||||
<div class="display-6 fw-bold"><?= (int)$totalWinners ?></div>
|
||||
<div class="small text-muted">Actual year-end trophy winners</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-6 col-lg-3">
|
||||
<div class="border rounded p-3 text-center h-100">
|
||||
<div class="text-muted small mb-1">Boys</div>
|
||||
<div class="display-6 fw-bold text-primary"><?= (int)$totalWinnerBoys ?></div>
|
||||
<div class="fw-semibold"><?= number_format($winnerBoysPct, 1) ?>%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-6 col-lg-3">
|
||||
<div class="border rounded p-3 text-center h-100">
|
||||
<div class="text-muted small mb-1">Girls</div>
|
||||
<div class="display-6 fw-bold" style="color:#E47AB0;"><?= (int)$totalWinnerGirls ?></div>
|
||||
<div class="fw-semibold"><?= number_format($winnerGirlsPct, 1) ?>%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-lg-3">
|
||||
<div class="border rounded p-3 text-center h-100">
|
||||
<div class="text-muted small mb-1">Unknown / Other</div>
|
||||
<div class="display-6 fw-bold text-secondary"><?= (int)$totalWinnerOther ?></div>
|
||||
<div class="fw-semibold"><?= number_format($winnerOtherPct, 1) ?>%</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<div class="progress" style="height:26px;">
|
||||
<?php if ($totalWinners > 0): ?>
|
||||
<div class="progress-bar bg-primary"
|
||||
role="progressbar"
|
||||
style="width: <?= $winnerBoysPct ?>%;"
|
||||
aria-valuenow="<?= $winnerBoysPct ?>"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100">
|
||||
Boys <?= number_format($winnerBoysPct, 1) ?>%
|
||||
</div>
|
||||
|
||||
<div class="progress-bar"
|
||||
role="progressbar"
|
||||
style="width: <?= $winnerGirlsPct ?>%; background:#E47AB0;"
|
||||
aria-valuenow="<?= $winnerGirlsPct ?>"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100">
|
||||
Girls <?= number_format($winnerGirlsPct, 1) ?>%
|
||||
</div>
|
||||
|
||||
<?php if ($totalWinnerOther > 0): ?>
|
||||
<div class="progress-bar bg-secondary"
|
||||
role="progressbar"
|
||||
style="width: <?= $winnerOtherPct ?>%;"
|
||||
aria-valuenow="<?= $winnerOtherPct ?>"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100">
|
||||
Other <?= number_format($winnerOtherPct, 1) ?>%
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<div class="progress-bar bg-secondary"
|
||||
role="progressbar"
|
||||
style="width: 100%;"
|
||||
aria-valuenow="0"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100">
|
||||
No winners
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- /screen-only -->
|
||||
|
||||
<!-- ══ PRINT VIEW ════════════════════════════════════════════════════════ -->
|
||||
@@ -340,7 +619,6 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- All students flat table -->
|
||||
<h3 style="margin-bottom:4px;">Student Detail</h3>
|
||||
<table data-no-mgmt-sticky>
|
||||
<thead>
|
||||
@@ -357,6 +635,7 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<th style="text-align:center;">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
$rank = 0;
|
||||
@@ -364,7 +643,8 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
foreach ($cls['students'] as $s):
|
||||
if (!in_array($s['status'], ['confirmed', 'surprise'], true)) continue;
|
||||
$rank++;
|
||||
$isMale = strtolower($s['gender'] ?? '') === 'male';
|
||||
$genderNorm = strtolower(trim((string)($s['gender'] ?? '')));
|
||||
$isMale = in_array($genderNorm, ['male', 'm', 'boy'], true);
|
||||
$statusLabel = match ($s['status']) {
|
||||
'confirmed' => '✓ Confirmed',
|
||||
'surprise' => '↑ Surprise',
|
||||
@@ -378,18 +658,17 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<td><?= esc($cls['section_name']) ?></td>
|
||||
<td><strong><?= esc($s['name']) ?></strong></td>
|
||||
<td style="text-align:center;"><?= $isMale ? 'M' : 'F' ?></td>
|
||||
<td style="text-align:right;"><?= $s['fall_score'] !== null ? number_format($s['fall_score'], 1) : '—' ?></td>
|
||||
<td style="text-align:right;"><?= $s['fall_score'] !== null ? number_format($s['fall_score'], 1) : '—' ?></td>
|
||||
<td style="text-align:right;"><?= $s['spring_score'] !== null ? number_format($s['spring_score'], 1) : '—' ?></td>
|
||||
<td style="text-align:right;font-weight:bold;"><?= $s['year_score'] !== null ? number_format($s['year_score'], 1) : '—' ?></td>
|
||||
<td style="text-align:right;font-weight:bold;"><?= $s['year_score'] !== null ? number_format($s['year_score'], 1) : '—' ?></td>
|
||||
<td style="text-align:center;"><?= $s['predicted'] ? 'Yes' : 'No' ?></td>
|
||||
<td style="text-align:center;"><?= $s['actual'] ? 'Yes' : 'No' ?></td>
|
||||
<td style="text-align:center;"><?= $s['actual'] ? 'Yes' : 'No' ?></td>
|
||||
<td style="text-align:center;" class="<?= $statusClass ?>"><?= $statusLabel ?></td>
|
||||
</tr>
|
||||
<?php endforeach; endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Accuracy summary (new page) -->
|
||||
<div class="print-page-break"></div>
|
||||
<h3 style="margin-bottom:4px;">Prediction Accuracy Summary</h3>
|
||||
<table data-no-mgmt-sticky style="margin-bottom:14px;">
|
||||
@@ -407,6 +686,7 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
<th style="text-align:right;">Year ≥</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($classResults as $cls): ?>
|
||||
<tr>
|
||||
@@ -423,6 +703,7 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td style="font-weight:bold;">Total</td>
|
||||
@@ -438,17 +719,18 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<!-- Charts as images (populated by JS before printing) -->
|
||||
<div class="print-page-break"></div>
|
||||
<h3 style="margin-bottom:6px;">Charts</h3>
|
||||
|
||||
<div style="margin-bottom:14px;">
|
||||
<p style="font-size:10px;font-weight:bold;margin:0 0 4px;">Trophy Counts per Class</p>
|
||||
<img id="print-chart-counts" style="width:100%;max-height:220px;object-fit:contain;" src="" alt="">
|
||||
<img id="print-chart-counts" style="width:100%;max-height:220px;object-fit:contain;" src="" alt="">
|
||||
</div>
|
||||
|
||||
<div style="display:flex;gap:16px;margin-bottom:14px;">
|
||||
<div style="flex:1;">
|
||||
<p style="font-size:10px;font-weight:bold;margin:0 0 4px;">Prediction Accuracy per Class</p>
|
||||
<img id="print-chart-accuracy" style="width:100%;max-height:160px;object-fit:contain;" src="" alt="">
|
||||
<img id="print-chart-accuracy" style="width:100%;max-height:160px;object-fit:contain;" src="" alt="">
|
||||
</div>
|
||||
<div style="flex:1;">
|
||||
<p style="font-size:10px;font-weight:bold;margin:0 0 4px;">Overall Outcome Breakdown</p>
|
||||
@@ -456,8 +738,69 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top:10px;border:1px solid #bbb;padding:8px;">
|
||||
<p style="font-size:11px;font-weight:bold;margin:0 0 6px;">Winner Gender Breakdown</p>
|
||||
|
||||
<table data-no-mgmt-sticky>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Group</th>
|
||||
<th style="text-align:center;">Winners</th>
|
||||
<th style="text-align:center;">Percentage</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Boys</td>
|
||||
<td style="text-align:center;"><?= (int)$totalWinnerBoys ?></td>
|
||||
<td style="text-align:center;"><?= number_format($winnerBoysPct, 1) ?>%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Girls</td>
|
||||
<td style="text-align:center;"><?= (int)$totalWinnerGirls ?></td>
|
||||
<td style="text-align:center;"><?= number_format($winnerGirlsPct, 1) ?>%</td>
|
||||
</tr>
|
||||
<?php if ($totalWinnerOther > 0): ?>
|
||||
<tr>
|
||||
<td>Unknown / Other</td>
|
||||
<td style="text-align:center;"><?= (int)$totalWinnerOther ?></td>
|
||||
<td style="text-align:center;"><?= number_format($winnerOtherPct, 1) ?>%</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td style="font-weight:bold;">Total Winners</td>
|
||||
<td style="text-align:center;font-weight:bold;"><?= (int)$totalWinners ?></td>
|
||||
<td style="text-align:center;font-weight:bold;"><?= $totalWinners > 0 ? '100.0%' : '0.0%' ?></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div><!-- /print-only -->
|
||||
|
||||
<!-- Winner sticker print area: names only, no header, no score, no class -->
|
||||
<div id="winnerStickerPrintArea" class="winner-sticker-print-area">
|
||||
<?php if (!empty($winnerStickerNames)): ?>
|
||||
<?php foreach (array_chunk($winnerStickerNames, 20) as $chunk): ?>
|
||||
<div class="sticker-page">
|
||||
<?php foreach ($chunk as $winnerName): ?>
|
||||
<div class="sticker-cell">
|
||||
<div class="sticker-name"><?= esc($winnerName) ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php for ($i = 0, $remaining = 20 - count($chunk); $i < $remaining; $i++): ?>
|
||||
<div class="sticker-cell sticker-empty"></div>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
@@ -473,6 +816,7 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
$cSurprise = [];
|
||||
$cMissed = [];
|
||||
$cAccuracy = [];
|
||||
|
||||
foreach ($classResults as $cls) {
|
||||
$cLabels[] = $cls['section_name'];
|
||||
$cPredicted[] = $cls['predicted_count'];
|
||||
@@ -483,94 +827,105 @@ $overallAccuracy = $totalPredicted > 0 ? round($totalConfirmed / $totalPredicted
|
||||
$cAccuracy[] = $cls['accuracy'];
|
||||
}
|
||||
?>
|
||||
var labels = <?= json_encode($cLabels) ?>;
|
||||
|
||||
var labels = <?= json_encode($cLabels) ?>;
|
||||
var predicted = <?= json_encode($cPredicted) ?>;
|
||||
var actual = <?= json_encode($cActual) ?>;
|
||||
var actual = <?= json_encode($cActual) ?>;
|
||||
var confirmed = <?= json_encode($cConfirmed) ?>;
|
||||
var surprises = <?= json_encode($cSurprise) ?>;
|
||||
var missed = <?= json_encode($cMissed) ?>;
|
||||
var accuracy = <?= json_encode($cAccuracy) ?>;
|
||||
var surprises = <?= json_encode($cSurprise) ?>;
|
||||
var missed = <?= json_encode($cMissed) ?>;
|
||||
var accuracy = <?= json_encode($cAccuracy) ?>;
|
||||
|
||||
/* ── Chart 1: grouped bar – counts per class ── */
|
||||
new Chart(document.getElementById('chart-counts'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{ label: 'Predicted', data: predicted, backgroundColor: '#4A90E2', borderRadius: 3 },
|
||||
{ label: 'Actual', data: actual, backgroundColor: '#f0a500', borderRadius: 3 },
|
||||
{ label: 'Confirmed', data: confirmed, backgroundColor: '#28a745', borderRadius: 3 },
|
||||
{ label: 'Surprises', data: surprises, backgroundColor: '#17a2b8', borderRadius: 3 },
|
||||
{ label: 'Missed', data: missed, backgroundColor: '#fd7e14', borderRadius: 3 },
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: true,
|
||||
plugins: { legend: { position: 'bottom' } },
|
||||
scales: {
|
||||
x: { grid: { color: '#f0f0f0' } },
|
||||
y: { beginAtZero: true, ticks: { stepSize: 1 }, grid: { color: '#f0f0f0' } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* ── Chart 2: accuracy % per class ── */
|
||||
new Chart(document.getElementById('chart-accuracy'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Accuracy %',
|
||||
data: accuracy,
|
||||
backgroundColor: accuracy.map(function(a) {
|
||||
return a >= 80 ? '#28a745' : a >= 50 ? '#f0a500' : '#dc3545';
|
||||
}),
|
||||
borderRadius: 3
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: true,
|
||||
plugins: { legend: { display: false } },
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true, max: 100,
|
||||
ticks: { callback: function(v) { return v + '%'; } },
|
||||
grid: { color: '#f0f0f0' }
|
||||
if (document.getElementById('chart-counts')) {
|
||||
new Chart(document.getElementById('chart-counts'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{ label: 'Predicted', data: predicted, backgroundColor: '#4A90E2', borderRadius: 3 },
|
||||
{ label: 'Actual', data: actual, backgroundColor: '#f0a500', borderRadius: 3 },
|
||||
{ label: 'Confirmed', data: confirmed, backgroundColor: '#28a745', borderRadius: 3 },
|
||||
{ label: 'Surprises', data: surprises, backgroundColor: '#17a2b8', borderRadius: 3 },
|
||||
{ label: 'Missed', data: missed, backgroundColor: '#fd7e14', borderRadius: 3 },
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: true,
|
||||
plugins: { legend: { position: 'bottom' } },
|
||||
scales: {
|
||||
x: { grid: { color: '#f0f0f0' } },
|
||||
y: { beginAtZero: true, ticks: { stepSize: 1 }, grid: { color: '#f0f0f0' } }
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* ── Chart 3: doughnut overall outcome breakdown ── */
|
||||
new Chart(document.getElementById('chart-breakdown'), {
|
||||
type: 'doughnut',
|
||||
data: {
|
||||
labels: ['Confirmed', 'Surprises', 'Missed'],
|
||||
datasets: [{
|
||||
data: [<?= $totalConfirmed ?>, <?= $totalSurprise ?>, <?= $totalMissed ?>],
|
||||
backgroundColor: ['#28a745', '#17a2b8', '#fd7e14'],
|
||||
borderWidth: 2
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: true,
|
||||
plugins: {
|
||||
legend: { position: 'bottom' },
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
label: function(ctx) {
|
||||
var total = ctx.dataset.data.reduce(function(a, b) { return a + b; }, 0);
|
||||
var pct = total > 0 ? Math.round(ctx.parsed / total * 100) : 0;
|
||||
return ctx.label + ': ' + ctx.parsed + ' (' + pct + '%)';
|
||||
if (document.getElementById('chart-accuracy')) {
|
||||
new Chart(document.getElementById('chart-accuracy'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Accuracy %',
|
||||
data: accuracy,
|
||||
backgroundColor: accuracy.map(function(a) {
|
||||
return a >= 80 ? '#28a745' : a >= 50 ? '#f0a500' : '#dc3545';
|
||||
}),
|
||||
borderRadius: 3
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: true,
|
||||
plugins: { legend: { display: false } },
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
max: 100,
|
||||
ticks: {
|
||||
callback: function(v) {
|
||||
return v + '%';
|
||||
}
|
||||
},
|
||||
grid: { color: '#f0f0f0' }
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (document.getElementById('chart-breakdown')) {
|
||||
new Chart(document.getElementById('chart-breakdown'), {
|
||||
type: 'doughnut',
|
||||
data: {
|
||||
labels: ['Confirmed', 'Surprises', 'Missed'],
|
||||
datasets: [{
|
||||
data: [<?= $totalConfirmed ?>, <?= $totalSurprise ?>, <?= $totalMissed ?>],
|
||||
backgroundColor: ['#28a745', '#17a2b8', '#fd7e14'],
|
||||
borderWidth: 2
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: true,
|
||||
plugins: {
|
||||
legend: { position: 'bottom' },
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
label: function(ctx) {
|
||||
var total = ctx.dataset.data.reduce(function(a, b) {
|
||||
return a + b;
|
||||
}, 0);
|
||||
var pct = total > 0 ? Math.round(ctx.parsed / total * 100) : 0;
|
||||
return ctx.label + ': ' + ctx.parsed + ' (' + pct + '%)';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
function captureCharts() {
|
||||
@@ -579,19 +934,40 @@ function captureCharts() {
|
||||
'chart-accuracy': 'print-chart-accuracy',
|
||||
'chart-breakdown': 'print-chart-breakdown',
|
||||
};
|
||||
|
||||
Object.keys(map).forEach(function(canvasId) {
|
||||
var canvas = document.getElementById(canvasId);
|
||||
var img = document.getElementById(map[canvasId]);
|
||||
if (canvas && img) img.src = canvas.toDataURL('image/png');
|
||||
|
||||
if (canvas && img) {
|
||||
img.src = canvas.toDataURL('image/png');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function printWithCharts() {
|
||||
document.body.classList.remove('print-stickers-mode');
|
||||
captureCharts();
|
||||
window.print();
|
||||
}
|
||||
|
||||
window.addEventListener('beforeprint', captureCharts);
|
||||
function printWinnerStickers() {
|
||||
document.body.classList.add('print-stickers-mode');
|
||||
|
||||
setTimeout(function () {
|
||||
window.print();
|
||||
|
||||
setTimeout(function () {
|
||||
document.body.classList.remove('print-stickers-mode');
|
||||
}, 1000);
|
||||
}, 250);
|
||||
}
|
||||
|
||||
window.addEventListener('beforeprint', function () {
|
||||
if (!document.body.classList.contains('print-stickers-mode')) {
|
||||
captureCharts();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
@@ -1,28 +1,71 @@
|
||||
<?= $this->extend('layout/management_layout') ?>
|
||||
<?= $this->section('content') ?>
|
||||
|
||||
<?php
|
||||
// This page is Fall semester only.
|
||||
// Do not expose Whole Year mode here.
|
||||
$semester = 'fall';
|
||||
$actionSemester = 'fall';
|
||||
|
||||
$schoolYear = $schoolYear ?? '';
|
||||
$schoolYears = $schoolYears ?? [];
|
||||
|
||||
if (empty($schoolYears) && $schoolYear !== '') {
|
||||
$schoolYears = [$schoolYear];
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="wrapper below-sixty-wrapper">
|
||||
<h2 class="text-center mt-4 mb-4 below-sixty-title">Below 60 Summary</h2>
|
||||
|
||||
<?= $this->include('partials/academic_filter') ?>
|
||||
<!-- School year filter only -->
|
||||
<div class="card shadow-sm mb-3">
|
||||
<div class="card-body py-3">
|
||||
<form method="get"
|
||||
action="<?= site_url('grading/below-60') ?>"
|
||||
class="row g-2 align-items-end justify-content-center">
|
||||
|
||||
<input type="hidden" name="semester" value="fall">
|
||||
|
||||
<div class="col-12 col-sm-auto">
|
||||
<label class="form-label mb-1 small fw-semibold">School Year</label>
|
||||
|
||||
<?php if (!empty($schoolYears)): ?>
|
||||
<select name="school_year"
|
||||
class="form-select form-select-sm"
|
||||
style="min-width:160px;">
|
||||
<?php foreach ($schoolYears as $yr): ?>
|
||||
<option value="<?= esc($yr) ?>" <?= (string)$yr === (string)$schoolYear ? 'selected' : '' ?>>
|
||||
<?= esc($yr) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php else: ?>
|
||||
<input type="text"
|
||||
name="school_year"
|
||||
class="form-control form-control-sm"
|
||||
style="min-width:160px;"
|
||||
value="<?= esc($schoolYear) ?>"
|
||||
placeholder="2025-2026">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-sm-auto">
|
||||
<button type="submit" class="btn btn-sm btn-primary">
|
||||
<i class="bi bi-funnel me-1"></i>Apply
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-3 flex-wrap gap-2">
|
||||
<div class="text-muted">
|
||||
<?= !empty($isYearMode) ? 'Whole Year' : 'Fall' ?> • <?= esc($schoolYear ?? '') ?>
|
||||
Fall • <?= esc($schoolYear) ?>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<?php if (!empty($isYearMode)): ?>
|
||||
<a class="btn btn-outline-primary btn-sm"
|
||||
href="<?= site_url('grading/below-60/decisions?' . http_build_query([
|
||||
'semester' => 'year',
|
||||
'school_year' => $schoolYear ?? '',
|
||||
])) ?>">
|
||||
Decisions
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($canViewGrading)): ?>
|
||||
<a class="btn btn-outline-secondary btn-sm" href="<?= base_url('grading') ?>">
|
||||
Back to Grading
|
||||
@@ -43,15 +86,11 @@
|
||||
|
||||
return esc($value);
|
||||
};
|
||||
|
||||
// Fall mode uses Fall.
|
||||
// Whole Year mode uses year.
|
||||
$actionSemester = !empty($isYearMode) ? 'year' : 'fall';
|
||||
?>
|
||||
|
||||
<?php if (empty($rows)): ?>
|
||||
<div class="alert alert-success text-center d-inline-block">
|
||||
No students below 60 for this selection.
|
||||
No students below 60 for Fall in <?= esc($schoolYear) ?>.
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="table-responsive below-sixty-table">
|
||||
@@ -62,7 +101,7 @@
|
||||
<tr>
|
||||
<th>Student Name</th>
|
||||
<th>Section</th>
|
||||
<th class="text-center">Score</th>
|
||||
<th class="text-center">Fall Score</th>
|
||||
<th>Status</th>
|
||||
<th>Email Parent</th>
|
||||
<th>Schedule Meeting</th>
|
||||
@@ -72,6 +111,7 @@
|
||||
<tbody>
|
||||
<?php foreach ($rows as $row): ?>
|
||||
<?php
|
||||
// Fall-only page: use semester_score.
|
||||
$scoreRaw = $row['semester_score'] ?? null;
|
||||
$scoreVal = is_numeric($scoreRaw) ? (float)$scoreRaw : null;
|
||||
|
||||
@@ -102,7 +142,7 @@
|
||||
style="font-size:0.72rem;padding:1px 7px;"
|
||||
data-student-id="<?= (int)($row['student_id'] ?? 0) ?>"
|
||||
data-student-name="<?= esc($studentLabel) ?>"
|
||||
data-school-year="<?= esc((string)($schoolYear ?? '')) ?>">
|
||||
data-school-year="<?= esc((string)$schoolYear) ?>">
|
||||
Details
|
||||
</button>
|
||||
</td>
|
||||
@@ -119,15 +159,15 @@
|
||||
|
||||
<input type="hidden"
|
||||
name="semester"
|
||||
value="<?= esc($actionSemester) ?>">
|
||||
value="fall">
|
||||
|
||||
<input type="hidden"
|
||||
name="school_year"
|
||||
value="<?= esc((string)($schoolYear ?? '')) ?>">
|
||||
value="<?= esc((string)$schoolYear) ?>">
|
||||
|
||||
<select name="status"
|
||||
class="form-select form-select-sm"
|
||||
style="width: 110px;">
|
||||
style="width:110px;">
|
||||
<option value="Open" <?= ($row['status'] ?? 'Open') === 'Open' ? 'selected' : '' ?>>
|
||||
Open
|
||||
</option>
|
||||
@@ -139,7 +179,7 @@
|
||||
<input type="text"
|
||||
name="note"
|
||||
class="form-control form-control-sm"
|
||||
style="width: 140px;"
|
||||
style="width:140px;"
|
||||
placeholder="Note (optional)"
|
||||
value="<?= esc((string)($row['note'] ?? '')) ?>">
|
||||
|
||||
@@ -156,7 +196,11 @@
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<a class="btn btn-sm btn-outline-primary"
|
||||
href="<?= site_url('grading/below-60/email/edit?student_id=' . (int)($row['student_id'] ?? 0) . '&semester=' . rawurlencode($actionSemester) . '&school_year=' . rawurlencode((string)($schoolYear ?? ''))) ?>">
|
||||
href="<?= site_url('grading/below-60/email/edit?' . http_build_query([
|
||||
'student_id' => (int)($row['student_id'] ?? 0),
|
||||
'semester' => 'fall',
|
||||
'school_year' => (string)$schoolYear,
|
||||
])) ?>">
|
||||
Send Email
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
@@ -169,7 +213,11 @@
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<a class="btn btn-sm btn-outline-secondary"
|
||||
href="<?= site_url('grading/below-60/schedule?student_id=' . (int)($row['student_id'] ?? 0) . '&semester=' . rawurlencode($actionSemester) . '&school_year=' . rawurlencode((string)($schoolYear ?? ''))) ?>">
|
||||
href="<?= site_url('grading/below-60/schedule?' . http_build_query([
|
||||
'student_id' => (int)($row['student_id'] ?? 0),
|
||||
'semester' => 'fall',
|
||||
'school_year' => (string)$schoolYear,
|
||||
])) ?>">
|
||||
Schedule
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
@@ -246,21 +294,6 @@
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
function normalizeSemesterFilter() {
|
||||
const semesterSelect = document.querySelector('select[name="semester"]');
|
||||
|
||||
if (!semesterSelect) return;
|
||||
|
||||
const wholeYearSelected = <?= !empty($isYearMode) ? 'true' : 'false' ?>;
|
||||
|
||||
semesterSelect.innerHTML = '';
|
||||
semesterSelect.add(new Option('Fall', 'fall', !wholeYearSelected, !wholeYearSelected));
|
||||
semesterSelect.add(new Option('Whole Year', 'year', wholeYearSelected, wholeYearSelected));
|
||||
semesterSelect.value = wholeYearSelected ? 'year' : 'fall';
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', normalizeSemesterFilter);
|
||||
|
||||
if (window.$ && $.fn && $.fn.DataTable) {
|
||||
$(function () {
|
||||
const table = $('.below-sixty-dt');
|
||||
|
||||
@@ -5,29 +5,77 @@
|
||||
// This page is Whole Year only.
|
||||
// Do not expose semester filter here.
|
||||
$semester = 'year';
|
||||
|
||||
$schoolYear = $schoolYear ?? '';
|
||||
$schoolYears = $schoolYears ?? [];
|
||||
|
||||
if (empty($schoolYears) && $schoolYear !== '') {
|
||||
$schoolYears = [$schoolYear];
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="wrapper below-sixty-decisions-wrapper">
|
||||
<h2 class="text-center mt-4 mb-4">Below 60 — Whole Year Decisions</h2>
|
||||
<h2 class="text-center mt-4 mb-4">School Year Decisions</h2>
|
||||
|
||||
<!-- School year filter -->
|
||||
<div class="card shadow-sm mb-3">
|
||||
<div class="card-body py-3">
|
||||
<form method="get"
|
||||
action="<?= site_url('grading/below-60/decisions') ?>"
|
||||
class="row g-2 align-items-end justify-content-center">
|
||||
|
||||
<input type="hidden" name="semester" value="year">
|
||||
|
||||
<div class="col-12 col-sm-auto">
|
||||
<label class="form-label mb-1 small fw-semibold">School Year</label>
|
||||
|
||||
<?php if (!empty($schoolYears)): ?>
|
||||
<select name="school_year"
|
||||
class="form-select form-select-sm"
|
||||
style="min-width: 160px;">
|
||||
<?php foreach ($schoolYears as $yr): ?>
|
||||
<option value="<?= esc($yr) ?>" <?= (string)$yr === (string)$schoolYear ? 'selected' : '' ?>>
|
||||
<?= esc($yr) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php else: ?>
|
||||
<input type="text"
|
||||
name="school_year"
|
||||
class="form-control form-control-sm"
|
||||
style="min-width: 160px;"
|
||||
value="<?= esc($schoolYear) ?>"
|
||||
placeholder="2025-2026">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-sm-auto">
|
||||
<button type="submit" class="btn btn-sm btn-primary">
|
||||
<i class="bi bi-funnel me-1"></i>Apply
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-3 flex-wrap gap-2">
|
||||
<div class="text-muted">
|
||||
Whole Year • <?= esc($schoolYear ?? '') ?>
|
||||
Whole Year • <?= esc($schoolYear) ?>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2 flex-wrap">
|
||||
<a class="btn btn-outline-secondary btn-sm"
|
||||
href="<?= site_url('grading/below-60?' . http_build_query([
|
||||
'semester' => 'year',
|
||||
'school_year' => $schoolYear ?? '',
|
||||
'school_year' => $schoolYear,
|
||||
])) ?>">
|
||||
← Back to Below 60
|
||||
</a>
|
||||
|
||||
<a class="btn btn-outline-primary btn-sm"
|
||||
href="<?= site_url('grading/decisions?' . http_build_query([
|
||||
'school_year' => $schoolYear ?? '',
|
||||
'school_year' => $schoolYear,
|
||||
])) ?>">
|
||||
All Decisions
|
||||
</a>
|
||||
@@ -89,7 +137,7 @@ $semester = 'year';
|
||||
|
||||
<?php if (empty($rows)): ?>
|
||||
<div class="alert alert-success text-center d-inline-block">
|
||||
No students below 60 for the whole year.
|
||||
No students below 60 for the whole year in <?= esc($schoolYear) ?>.
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="table-responsive">
|
||||
@@ -99,21 +147,19 @@ $semester = 'year';
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="min-width:160px">Student Name</th>
|
||||
<th>Section</th>
|
||||
<th>Class-Section</th>
|
||||
<th class="text-center">Year Score</th>
|
||||
<th style="min-width:300px">Comments / Rationale & Decision</th>
|
||||
<th style="min-width:150px" class="text-center">Below-60 Decision</th>
|
||||
<th style="min-width:130px" class="text-center">Final Decision</th>
|
||||
<th style="min-width:130px" class="text-center">Certificate</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($rows as $row): ?>
|
||||
<?php
|
||||
// Whole-year score. Prefer year_score if the controller provides it.
|
||||
// Fall/Spring details remain available through the Details modal.
|
||||
$scoreRaw = $row['year_score'] ?? $row['semester_score'] ?? null;
|
||||
// Whole-year page: use year_score only.
|
||||
// Do not fall back to semester_score, because this page should not display semester results.
|
||||
$scoreRaw = $row['year_score'] ?? null;
|
||||
$scoreVal = is_numeric($scoreRaw) ? (float)$scoreRaw : null;
|
||||
|
||||
$rowClass = '';
|
||||
@@ -126,11 +172,6 @@ $semester = 'year';
|
||||
$currentDecision = (string)($row['decision'] ?? '');
|
||||
$currentNotes = (string)($row['decision_notes'] ?? '');
|
||||
$badge = $decisionBadge[$currentDecision] ?? null;
|
||||
|
||||
$finalDecision = $row['consolidated_decision'] ?? null;
|
||||
$finalBadge = $finalDecision !== null ? ($decisionBadge[$finalDecision] ?? 'secondary') : null;
|
||||
|
||||
$certNumber = (string)($row['certificate_number'] ?? '');
|
||||
?>
|
||||
|
||||
<tr class="<?= esc($rowClass) ?>">
|
||||
@@ -146,7 +187,7 @@ $semester = 'year';
|
||||
style="font-size:0.72rem;padding:1px 7px;"
|
||||
data-student-id="<?= (int)($row['student_id'] ?? 0) ?>"
|
||||
data-student-name="<?= esc($studentLabel) ?>"
|
||||
data-school-year="<?= esc((string)($schoolYear ?? '')) ?>">
|
||||
data-school-year="<?= esc((string)$schoolYear) ?>">
|
||||
Details
|
||||
</button>
|
||||
</td>
|
||||
@@ -165,7 +206,7 @@ $semester = 'year';
|
||||
|
||||
<input type="hidden"
|
||||
name="school_year"
|
||||
value="<?= esc((string)($schoolYear ?? '')) ?>">
|
||||
value="<?= esc((string)$schoolYear) ?>">
|
||||
|
||||
<textarea name="notes"
|
||||
class="form-control form-control-sm decision-notes"
|
||||
@@ -199,41 +240,13 @@ $semester = 'year';
|
||||
class="btn btn-sm btn-outline-primary btn-send-email"
|
||||
data-student-id="<?= (int)($row['student_id'] ?? 0) ?>"
|
||||
data-semester="year"
|
||||
data-school-year="<?= esc((string)($schoolYear ?? '')) ?>">
|
||||
data-school-year="<?= esc((string)$schoolYear) ?>">
|
||||
Send Email
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<span class="text-muted small">Pending</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td class="text-center align-middle">
|
||||
<?php if ($finalDecision !== null && $finalDecision !== ''): ?>
|
||||
<span class="badge bg-<?= esc($finalBadge) ?> px-2 py-1">
|
||||
<?= esc($finalDecision) ?>
|
||||
</span>
|
||||
<?php else: ?>
|
||||
<a href="<?= site_url('grading/decisions?' . http_build_query([
|
||||
'school_year' => $schoolYear ?? '',
|
||||
])) ?>"
|
||||
class="text-muted small">
|
||||
Generate
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td class="text-center align-middle">
|
||||
<?php if ($certNumber !== ''): ?>
|
||||
<a href="<?= site_url('administrator/certificates/reprint/' . rawurlencode($certNumber)) ?>"
|
||||
target="_blank"
|
||||
class="font-monospace text-decoration-none fw-semibold"
|
||||
title="Click to reprint certificate">
|
||||
<?= esc($certNumber) ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span class="text-muted small">—</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user