From d987612018753469af332e8935954e08ba3932d6 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 30 Jan 2026 14:44:46 +0000 Subject: [PATCH] v3 --- includes/header.php | 23 +++- parent.php | 82 +++++++++++-- reports.php | 290 ++++++++++++++++++++++++++++++++++++++++++++ sw.js | 5 +- 4 files changed, 383 insertions(+), 17 deletions(-) create mode 100644 reports.php diff --git a/includes/header.php b/includes/header.php index 3e53a30..aa5560b 100644 --- a/includes/header.php +++ b/includes/header.php @@ -27,10 +27,17 @@ $is_logged_in = isset($_SESSION['user_id']); + - \ No newline at end of file diff --git a/parent.php b/parent.php index d1e0e92..a13f2c7 100644 --- a/parent.php +++ b/parent.php @@ -7,6 +7,7 @@ $pageTitle = 'Parent Portal | SOMS'; $learner = null; $school = null; $attendance_history = []; +$assessment_results = []; $search_id = $_GET['student_id'] ?? ''; if ($search_id) { @@ -23,6 +24,17 @@ if ($search_id) { $stmt = $db->prepare("SELECT * FROM attendance WHERE learner_id = ? ORDER BY date DESC LIMIT 30"); $stmt->execute([$learner['id']]); $attendance_history = $stmt->fetchAll(); + + // Fetch Assessment Results + $stmt = $db->prepare(" + SELECT a.name, a.type, a.total_marks, m.marks_obtained, a.created_at + FROM marks m + JOIN assessments a ON m.assessment_id = a.id + WHERE m.learner_id = ? + ORDER BY a.created_at DESC + "); + $stmt->execute([$learner['id']]); + $assessment_results = $stmt->fetchAll(); } } @@ -68,11 +80,11 @@ include 'includes/header.php';
-
+

Grade

-
+

Attendance (30d)

%
-

Status

- Enrolled +

Academic Avg

+ 0 ? round($total_perc / $count, 1) : 0; + ?> +
%
-
-
-
Recent Attendance
-
-
+ + + +
+
@@ -125,6 +153,40 @@ include 'includes/header.php';
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
AssessmentScorePercentage
No assessment results recorded yet.
+ +
() +
/ + % +
+
+
@@ -136,4 +198,4 @@ include 'includes/header.php';
- \ No newline at end of file + diff --git a/reports.php b/reports.php new file mode 100644 index 0000000..7bb6c26 --- /dev/null +++ b/reports.php @@ -0,0 +1,290 @@ +prepare("SELECT * FROM schools WHERE id = ?"); +$stmt->execute([$school_id]); +$school = $stmt->fetch(); + +$report_type = $_GET['type'] ?? null; +$learner_id = $_GET['learner_id'] ?? null; +$assessment_id = $_GET['assessment_id'] ?? null; + +$report_data = null; +$learner_info = null; +$assessment_info = null; + +if ($report_type === 'learner' && $learner_id) { + // Fetch learner transcript + $stmt = $db->prepare("SELECT * FROM learners WHERE id = ? AND school_id = ?"); + $stmt->execute([$learner_id, $school_id]); + $learner_info = $stmt->fetch(); + + if ($learner_info) { + $stmt = $db->prepare(" + SELECT a.name, a.type, a.total_marks, m.marks_obtained, a.created_at + FROM marks m + JOIN assessments a ON m.assessment_id = a.id + WHERE m.learner_id = ? + ORDER BY a.created_at DESC + "); + $stmt->execute([$learner_id]); + $report_data = $stmt->fetchAll(); + } +} elseif ($report_type === 'class' && $assessment_id) { + // Fetch class report for an assessment + $stmt = $db->prepare("SELECT * FROM assessments WHERE id = ? AND school_id = ?"); + $stmt->execute([$assessment_id, $school_id]); + $assessment_info = $stmt->fetch(); + + if ($assessment_info) { + $stmt = $db->prepare(" + SELECT l.full_name, l.student_id, m.marks_obtained + FROM learners l + LEFT JOIN marks m ON l.id = m.learner_id AND m.assessment_id = ? + WHERE l.school_id = ? AND l.grade = ? + ORDER BY l.full_name ASC + "); + $stmt->execute([$assessment_id, $school_id, $assessment_info['grade']]); + $report_data = $stmt->fetchAll(); + } +} + +// Fetch lists for selection +$stmt = $db->prepare("SELECT id, full_name, grade, student_id FROM learners WHERE school_id = ? ORDER BY grade, full_name"); +$stmt->execute([$school_id]); +$all_learners = $stmt->fetchAll(); + +$stmt = $db->prepare("SELECT id, name, grade, type FROM assessments WHERE school_id = ? ORDER BY created_at DESC"); +$stmt->execute([$school_id]); +$all_assessments = $stmt->fetchAll(); + +include 'includes/header.php'; +?> + +
+
+
+

Reporting Center

+

Generate academic transcripts and class performance reports

+
+
+ +
+ +
+
+
+ +
Learner Transcript
+

Academic history for a specific student

+
+ +
+ +
+ +
+
+
+
+ + +
+
+
+ +
Class Performance
+

Full class results for a specific assessment

+
+ +
+ +
+ +
+
+
+
+
+ + +
+
+
+ +
+
+

+

+

Generated on:

+
+
+ +
+
+ + +
+

ACADEMIC TRANSCRIPT

+
+
+

Name:

+

Student ID:

+
+
+

Grade:

+

Status: Active

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + 0): ?> + + + + + + + +
DateAssessmentTypeScorePercentage
/ %
Average Performance:%
+ + + +
+

CLASS PERFORMANCE REPORT

+
+
+

Grade | | Max Marks:

+
+
+ + + + + + + + + + + + + + + + + + + + + + 0): ?> + + + + + + + + +
Student IDLearner NameMarks ObtainedPercentageStatus
N/A' ?>'.round($perc, 1).'%' : '-' ?> + + + = 50 ? 'Pass' : 'Fail' ?> + + + = 50 ? 'Pass' : 'Fail' ?> + + + Absent/Pending + +
Class Average:%
+ + +
+
+
+
+ Teacher Signature +
+
+
+
+
+ Principal Signature +
+
+
+
+
+
+
+ +
+ + diff --git a/sw.js b/sw.js index a5feafe..fb4a1b2 100644 --- a/sw.js +++ b/sw.js @@ -1,4 +1,4 @@ -const CACHE_NAME = 'township-schools-v3'; +const CACHE_NAME = 'township-schools-v4'; const STATIC_ASSETS = [ '/', '/index.php', @@ -8,6 +8,7 @@ const STATIC_ASSETS = [ '/admin.php', '/learners.php', '/assessments.php', + '/reports.php', '/parent.php', '/assets/css/custom.css', '/assets/js/main.js', @@ -62,4 +63,4 @@ self.addEventListener('fetch', (event) => { }); }) ); -}); +}); \ No newline at end of file