From 7a517224e6a7478fa7db90288fff47f2809608ac Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 30 Jan 2026 15:02:53 +0000 Subject: [PATCH] v5 --- admin.php | 5 +- analytics.php | 122 ++++++++++++ collaboration.php | 244 ++++++++++++++++++++++++ db/migrations/003_collaboration_hub.sql | 35 ++++ db/migrations/004_event_scheduling.sql | 15 ++ events.php | 229 ++++++++++++++++++++++ includes/header.php | 18 ++ parent.php | 33 +++- sw.js | 5 +- 9 files changed, 702 insertions(+), 4 deletions(-) create mode 100644 analytics.php create mode 100644 collaboration.php create mode 100644 db/migrations/003_collaboration_hub.sql create mode 100644 db/migrations/004_event_scheduling.sql create mode 100644 events.php diff --git a/admin.php b/admin.php index 91677e8..c26c2e6 100644 --- a/admin.php +++ b/admin.php @@ -138,6 +138,9 @@ include 'includes/header.php'; Bulk Upload Learners + + Schedule School Event + Academic Reports @@ -151,4 +154,4 @@ include 'includes/header.php'; - \ No newline at end of file + diff --git a/analytics.php b/analytics.php new file mode 100644 index 0000000..174ccd4 --- /dev/null +++ b/analytics.php @@ -0,0 +1,122 @@ +prepare($query); +$stmt->execute(['school_id' => $school_id]); +$grade_stats = $stmt->fetchAll(); + +$pageTitle = "Grade Performance Analytics"; +include 'includes/header.php'; +?> + +
+
+

Grade Performance Analytics

+ +
+ +
+
+
+
+
Grade-Level Comparison
+ +
No assessment data available for comparison yet.
+ +
+ + + + + + + + + + + + + = 70 ? 'bg-success' : ($avg >= 50 ? 'bg-warning text-dark' : 'bg-danger'); + ?> + + + + + + + + + +
GradeAvg. PerformanceStudentsAssessmentsStatus
+
+
+
+
+ % +
+
+ + = 70 ? 'Excellent' : ($avg >= 50 ? 'Satisfactory' : 'Critical'); ?> + +
+
+ +
+
+
+
+ +
+
+
+
+
Insights
+

+ This data represents the average score across all subjects and assessments for each grade level in your school. + Use this to identify grades that may require additional resources or intervention. +

+
+
+
+
+
+
+
Recommendations
+
    +
  • Grades below 50% should be flagged for curriculum review.
  • +
  • High-performing grades can serve as models for peer-teacher coaching.
  • +
+
+
+
+
+
+ + diff --git a/collaboration.php b/collaboration.php new file mode 100644 index 0000000..8cec1e9 --- /dev/null +++ b/collaboration.php @@ -0,0 +1,244 @@ +prepare("INSERT INTO resources (title, description, teacher_id, school_id, grade, subject) VALUES (?, ?, ?, ?, ?, ?)"); + $stmt->execute([$title, $description, $user_id, $school_id, $grade, $subject]); + $success = "Resource shared successfully!"; + } catch (PDOException $e) { + $error = "Failed to share resource: " . $e->getMessage(); + } +} + +// Handle Forum Post +if (isset($_POST['create_post'])) { + $title = $_POST['title']; + $content = $_POST['content']; + + try { + $stmt = db()->prepare("INSERT INTO forum_posts (title, content, author_id, school_id) VALUES (?, ?, ?, ?)"); + $stmt->execute([$title, $content, $user_id, $school_id]); + $success = "Topic posted successfully!"; + } catch (PDOException $e) { + $error = "Failed to post topic: " . $e->getMessage(); + } +} + +// Fetch Resources +$resources = db()->prepare("SELECT r.*, u.email as teacher_email FROM resources r JOIN users u ON r.teacher_id = u.id WHERE r.school_id = ? ORDER BY r.created_at DESC"); +$resources->execute([$school_id]); +$resources = $resources->fetchAll(); + +// Fetch Forum Posts +$posts = db()->prepare("SELECT p.*, u.email as author_email, (SELECT COUNT(*) FROM forum_comments WHERE post_id = p.id) as comment_count FROM forum_posts p JOIN users u ON p.author_id = u.id WHERE p.school_id = ? ORDER BY p.created_at DESC"); +$posts->execute([$school_id]); +$posts = $posts->fetchAll(); + +$pageTitle = "Teacher Collaboration Hub"; +include 'includes/header.php'; +?> + +
+
+

Collaboration Hub

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

No resources shared yet. Be the first!

+
+ + +
+
+
+
+ + Grade +
+
+

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

Start a conversation with your colleagues.

+
+ + + +
+
+
+

+
+ + +
+
+
+ + + +
+
+
+ + +
+
+
+
+
+ + + + + + + + diff --git a/db/migrations/003_collaboration_hub.sql b/db/migrations/003_collaboration_hub.sql new file mode 100644 index 0000000..70ccd46 --- /dev/null +++ b/db/migrations/003_collaboration_hub.sql @@ -0,0 +1,35 @@ +-- Migration: Add tables for Teacher Collaboration Hub +CREATE TABLE IF NOT EXISTS resources ( + id INT AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + description TEXT, + file_path VARCHAR(255), + teacher_id INT NOT NULL, + school_id INT NOT NULL, + grade VARCHAR(20), + subject VARCHAR(100), + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (teacher_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (school_id) REFERENCES schools(id) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS forum_posts ( + id INT AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + content TEXT NOT NULL, + author_id INT NOT NULL, + school_id INT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (school_id) REFERENCES schools(id) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS forum_comments ( + id INT AUTO_INCREMENT PRIMARY KEY, + post_id INT NOT NULL, + author_id INT NOT NULL, + content TEXT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (post_id) REFERENCES forum_posts(id) ON DELETE CASCADE, + FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE +); diff --git a/db/migrations/004_event_scheduling.sql b/db/migrations/004_event_scheduling.sql new file mode 100644 index 0000000..5563f6e --- /dev/null +++ b/db/migrations/004_event_scheduling.sql @@ -0,0 +1,15 @@ +-- Migration: Add events table for scheduling +CREATE TABLE IF NOT EXISTS events ( + id INT AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + description TEXT, + event_type ENUM('Meeting', 'Conference', 'Workshop', 'Holiday', 'Other') NOT NULL DEFAULT 'Meeting', + start_datetime DATETIME NOT NULL, + end_datetime DATETIME NOT NULL, + location VARCHAR(255), + created_by INT NOT NULL, + school_id INT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (school_id) REFERENCES schools(id) ON DELETE CASCADE +); diff --git a/events.php b/events.php new file mode 100644 index 0000000..37b25eb --- /dev/null +++ b/events.php @@ -0,0 +1,229 @@ +prepare("INSERT INTO events (title, description, event_type, start_datetime, end_datetime, location, created_by, school_id) + VALUES (:title, :description, :event_type, :start_datetime, :end_datetime, :location, :created_by, :school_id)"); + $stmt->execute([ + 'title' => $title, + 'description' => $description, + 'event_type' => $event_type, + 'start_datetime' => $start_datetime, + 'end_datetime' => $end_datetime, + 'location' => $location, + 'created_by' => $user_id, + 'school_id' => $school_id + ]); + $message = "Event created successfully!"; + } catch (Exception $e) { + $message = "Error: " . $e->getMessage(); + } + } else { + $message = "Please fill in all required fields."; + } + } +} + +// Fetch Upcoming Events +$stmt = $db->prepare("SELECT e.*, u.email as creator_email + FROM events e + JOIN users u ON e.created_by = u.id + WHERE e.school_id = :school_id AND e.end_datetime >= NOW() + ORDER BY e.start_datetime ASC"); +$stmt->execute(['school_id' => $school_id]); +$upcoming_events = $stmt->fetchAll(); + +// Fetch Past Events +$stmt = $db->prepare("SELECT e.*, u.email as creator_email + FROM events e + JOIN users u ON e.created_by = u.id + WHERE e.school_id = :school_id AND e.end_datetime < NOW() + ORDER BY e.start_datetime DESC LIMIT 10"); +$stmt->execute(['school_id' => $school_id]); +$past_events = $stmt->fetchAll(); + +include 'includes/header.php'; +?> + +
+
+
+

School Events & Scheduling

+

Stay updated with meetings, conferences, and school holidays.

+
+ +
+ +
+ +
+ + + + + +
+ +
+
+
+
Upcoming Events
+
+
+ +
+ +

No upcoming events scheduled.

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

+
+ - + + + + +
+
+ +
+ +
+
+
+ + +
+
+
+
Recently Concluded
+
+
+ +
+ No past events found. +
+ +
+ +
+
+
+
+ +
+ +
+
+ +
+
+
Need a Private Meeting?
+

Parents can request specific slots for parent-teacher conferences via the direct message system in the Hub.

+
+
+
+
+
+ + + + + + + diff --git a/includes/header.php b/includes/header.php index d5d0b15..d975b2b 100644 --- a/includes/header.php +++ b/includes/header.php @@ -61,6 +61,12 @@ $is_logged_in = isset($_SESSION['user_id']); + + @@ -73,6 +79,12 @@ $is_logged_in = isset($_SESSION['user_id']); + + @@ -89,6 +101,12 @@ $is_logged_in = isset($_SESSION['user_id']); Parent Portal + + + +
diff --git a/parent.php b/parent.php index a13f2c7..3b3b2fa 100644 --- a/parent.php +++ b/parent.php @@ -8,6 +8,7 @@ $learner = null; $school = null; $attendance_history = []; $assessment_results = []; +$school_events = []; $search_id = $_GET['student_id'] ?? ''; if ($search_id) { @@ -35,6 +36,11 @@ if ($search_id) { "); $stmt->execute([$learner['id']]); $assessment_results = $stmt->fetchAll(); + + // Fetch Upcoming School Events + $stmt = $db->prepare("SELECT * FROM events WHERE school_id = ? AND end_datetime >= NOW() ORDER BY start_datetime ASC LIMIT 3"); + $stmt->execute([$learner['school_id']]); + $school_events = $stmt->fetchAll(); } } @@ -51,7 +57,7 @@ include 'includes/header.php';
-
+
Find My Child
@@ -64,6 +70,29 @@ include 'includes/header.php';
+ +
+
+
Upcoming School Events
+
+
+
+ +
+
+
+ +
+
+ +
+ +
+
+ +
No learner found with ID . Please contact the school office. @@ -198,4 +227,4 @@ include 'includes/header.php';
- + \ No newline at end of file diff --git a/sw.js b/sw.js index 63d6110..88fe8d8 100644 --- a/sw.js +++ b/sw.js @@ -1,4 +1,4 @@ -const CACHE_NAME = 'township-schools-v5'; +const CACHE_NAME = 'township-schools-v7'; const STATIC_ASSETS = [ '/', '/index.php', @@ -11,6 +11,9 @@ const STATIC_ASSETS = [ '/reports.php', '/bulk-upload.php', '/notifications.php', + '/analytics.php', + '/collaboration.php', + '/events.php', '/parent.php', '/assets/css/custom.css', '/assets/js/main.js',