diff --git a/api/pexels.php b/api/pexels.php new file mode 100644 index 0000000..3b0638a --- /dev/null +++ b/api/pexels.php @@ -0,0 +1,29 @@ + 'assets/images/pexels/'.$p['id'].'.jpg', + 'photographer' => $p['photographer'] ?? 'Unknown', + 'photographer_url' => $p['photographer_url'] ?? '', + ]; + } else { + // Fallback: Picsum + $out[] = [ + 'src' => 'https://picsum.photos/1200/800', + 'photographer' => 'Random Picsum', + 'photographer_url' => 'https://picsum.photos/' + ]; + } +} +echo json_encode($out); +?> \ No newline at end of file diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..8869617 --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,51 @@ +body { + background-color: #F3F4F6; + font-family: 'Inter', sans-serif; +} + +.sidebar { + background-color: #FFFFFF; + height: 100vh; + position: fixed; + top: 0; + left: 0; + width: 250px; + padding-top: 1rem; +} + +.sidebar .nav-link { + color: #4B5563; + font-weight: 500; +} + +.sidebar .nav-link.active, +.sidebar .nav-link:hover { + color: #4F46E5; + background-color: #E0E7FF; +} + +.main-content { + margin-left: 250px; + padding: 2rem; +} + +.card { + border: none; + border-radius: 0.5rem; + box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); +} + +#welcomeCarousel .carousel-item { + height: 500px; +} + +#welcomeCarousel .carousel-item img { + height: 100%; + object-fit: cover; +} + +#welcomeCarousel .carousel-caption { + background-color: rgba(0, 0, 0, 0.5); + border-radius: 0.5rem; + padding: 1rem; +} diff --git a/assets/images/pexels/1462630.jpg b/assets/images/pexels/1462630.jpg new file mode 100644 index 0000000..6371fa3 Binary files /dev/null and b/assets/images/pexels/1462630.jpg differ diff --git a/assets/images/pexels/159844.jpg b/assets/images/pexels/159844.jpg new file mode 100644 index 0000000..742276e Binary files /dev/null and b/assets/images/pexels/159844.jpg differ diff --git a/assets/images/pexels/5185074.jpg b/assets/images/pexels/5185074.jpg new file mode 100644 index 0000000..77c867d Binary files /dev/null and b/assets/images/pexels/5185074.jpg differ diff --git a/assets/images/pexels/714699.jpg b/assets/images/pexels/714699.jpg new file mode 100644 index 0000000..48770b6 Binary files /dev/null and b/assets/images/pexels/714699.jpg differ diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..1ea638b --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1 @@ +console.log('main.js loaded'); \ No newline at end of file diff --git a/db/setup.php b/db/setup.php new file mode 100644 index 0000000..165519b --- /dev/null +++ b/db/setup.php @@ -0,0 +1,23 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $sql = "CREATE TABLE IF NOT EXISTS users ( + id INT AUTO_INCREMENT PRIMARY KEY, + email VARCHAR(255) NOT NULL UNIQUE, + password VARCHAR(255) NOT NULL, + role ENUM('teacher', 'student') NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + )"; + + $pdo->exec($sql); + echo "Table 'users' created successfully."; +} catch (PDOException $e) { + die("ERROR: Could not execute $sql. " . $e->getMessage()); +} + +unset($pdo); +?> \ No newline at end of file diff --git a/db/setup_part2.php b/db/setup_part2.php new file mode 100644 index 0000000..62c0a1b --- /dev/null +++ b/db/setup_part2.php @@ -0,0 +1,99 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + // Create courses table + $sql_courses = "CREATE TABLE IF NOT EXISTS courses ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + teacher_id INT NOT NULL, + FOREIGN KEY (teacher_id) REFERENCES users(id) + )"; + $pdo->exec($sql_courses); + echo "Table 'courses' created successfully.\n"; + + // Create enrollments table + $sql_enrollments = "CREATE TABLE IF NOT EXISTS enrollments ( + id INT AUTO_INCREMENT PRIMARY KEY, + student_id INT NOT NULL, + course_id INT NOT NULL, + FOREIGN KEY (student_id) REFERENCES users(id), + FOREIGN KEY (course_id) REFERENCES courses(id) + )"; + $pdo->exec($sql_enrollments); + echo "Table 'enrollments' created successfully.\n"; + + // Create activities table + $sql_activities = "CREATE TABLE IF NOT EXISTS activities ( + id INT AUTO_INCREMENT PRIMARY KEY, + enrollment_id INT NOT NULL, + activity_name VARCHAR(255) NOT NULL, + grade INT, + activity_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (enrollment_id) REFERENCES enrollments(id) + )"; + $pdo->exec($sql_activities); + echo "Table 'activities' created successfully.\n"; + + // Sample Data + // Hash a default password + $password = password_hash('password', PASSWORD_DEFAULT); + + // Truncate tables before inserting sample data to avoid duplicates on re-run + $pdo->exec("SET FOREIGN_KEY_CHECKS = 0"); + $pdo->exec("TRUNCATE TABLE activities"); + $pdo->exec("TRUNCATE TABLE enrollments"); + $pdo->exec("TRUNCATE TABLE courses"); + $pdo->exec("TRUNCATE TABLE users"); + $pdo->exec("SET FOREIGN_KEY_CHECKS = 1"); + echo "Tables truncated successfully.\n"; + + // Insert a teacher + $pdo->exec("INSERT INTO users (email, password, role) VALUES ('teacher@example.com', '$password', 'teacher')"); + $teacher_id = $pdo->lastInsertId(); + echo "Sample teacher inserted.\n"; + + // Insert courses for the teacher + $stmt = $pdo->prepare("INSERT INTO courses (name, teacher_id) VALUES (?, ?)"); + $stmt->execute(['Algebra 101', $teacher_id]); + $course1_id = $pdo->lastInsertId(); + $stmt->execute(['History of Algebra', $teacher_id]); + $course2_id = $pdo->lastInsertId(); + echo "Sample courses inserted.\n"; + + // Insert students + $stmt = $pdo->prepare("INSERT INTO users (email, password, role) VALUES (?, ?, ?)"); + $stmt->execute(['student1@example.com', $password, 'student']); + $student1_id = $pdo->lastInsertId(); + $stmt->execute(['student2@example.com', $password, 'student']); + $student2_id = $pdo->lastInsertId(); + echo "Sample students inserted.\n"; + + // Enroll students in courses + $stmt = $pdo->prepare("INSERT INTO enrollments (student_id, course_id) VALUES (?, ?)"); + $stmt->execute([$student1_id, $course1_id]); + $enrollment1_id = $pdo->lastInsertId(); + $stmt->execute([$student2_id, $course1_id]); + $enrollment2_id = $pdo->lastInsertId(); + $stmt->execute([$student1_id, $course2_id]); + $enrollment3_id = $pdo->lastInsertId(); + echo "Students enrolled in courses.\n"; + + // Add student activities + $stmt = $pdo->prepare("INSERT INTO activities (enrollment_id, activity_name, grade) VALUES (?, ?, ?)"); + $stmt->execute([$enrollment1_id, 'Homework 1', 95]); + $stmt->execute([$enrollment1_id, 'Quiz 1', 88]); + $stmt->execute([$enrollment2_id, 'Homework 1', 72]); + $stmt->execute([$enrollment3_id, 'Research Paper', 92]); + echo "Student activities added.\n"; + + +} catch (PDOException $e) { + die("ERROR: Could not able to execute script. " . $e->getMessage()); +} + +unset($pdo); +?> diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..e3145ed --- /dev/null +++ b/footer.php @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/footer_login.php b/footer_login.php new file mode 100644 index 0000000..b1c58a3 --- /dev/null +++ b/footer_login.php @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/header.php b/header.php new file mode 100644 index 0000000..bd8f6cf --- /dev/null +++ b/header.php @@ -0,0 +1,51 @@ + + + + + + + AlgebraEase + + + + + +
+
+ + AlgebraEase + +
+ +
+
diff --git a/header_login.php b/header_login.php new file mode 100644 index 0000000..c26ce56 --- /dev/null +++ b/header_login.php @@ -0,0 +1,14 @@ + + + + + + + Classroom - Login + + + + +
\ No newline at end of file diff --git a/includes/pexels.php b/includes/pexels.php new file mode 100644 index 0000000..823ea99 --- /dev/null +++ b/includes/pexels.php @@ -0,0 +1,26 @@ + 0 ? $k : 'Vc99rnmOhHhJAbgGQoKLZtsaIVfkeownoQNbTj78VemUjKh08ZYRbf18'; +} +function pexels_get($url) { + $ch = curl_init(); + curl_setopt_array($ch, [ + CURLOPT_URL => $url, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPHEADER => [ 'Authorization: '. pexels_key() ], + CURLOPT_TIMEOUT => 15, + ]); + $resp = curl_exec($ch); + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + if ($code >= 200 && $code < 300 && $resp) return json_decode($resp, true); + return null; +} +function download_to($srcUrl, $destPath) { + $data = file_get_contents($srcUrl); + if ($data === false) return false; + if (!is_dir(dirname($destPath))) mkdir(dirname($destPath), 0775, true); + return file_put_contents($destPath, $data) !== false; +} +?> \ No newline at end of file diff --git a/index.php b/index.php index 7205f3d..08d6427 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,119 @@ - -$phpVersion = PHP_VERSION; -$now = date('Y-m-d H:i:s'); -?> - - - - - - New Style - - - - - - - - - - - - - - - - - - - - - -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
-
- Page updated: (UTC) -
- - +
+ +
+

Dashboard

+
+ Welcome, ! +
+
+ + prepare("SELECT id, name FROM courses WHERE teacher_id = ?"); + $stmt->execute([$teacher_id]); + return $stmt->fetchAll(PDO::FETCH_ASSOC); + } + + // Function to get student activities for a course + function getStudentActivities($course_id) { + $pdo = db(); + $stmt = $pdo->prepare(" + SELECT u.email, a.activity_name, a.grade, a.activity_date + FROM activities a + JOIN enrollments e ON a.enrollment_id = e.id + JOIN users u ON e.student_id = u.id + WHERE e.course_id = ? + ORDER BY a.activity_date DESC + "); + $stmt->execute([$course_id]); + return $stmt->fetchAll(PDO::FETCH_ASSOC); + } + + $courses = getTeacherCourses($_SESSION['user_id']); + $activities = []; + foreach ($courses as $course) { + $activities[$course['name']] = getStudentActivities($course['id']); + } + } + ?> + +
+
+
+
+
My Classes
+
    + + " . htmlspecialchars($course['name']) . ""; + endforeach; ?> + +
  • No classes found.
  • + +
+
+
+
+
+
+
+
Upcoming Assignments
+

No upcoming assignments.

+
+
+
+
+ +
+
+
+
+
Assignment Submissions
+ + $studentActivities): ?> +
+ + + + + + + + + + + + + + + + + + + + +
StudentAssignmentGradeDate
+ +

No assignment submissions for this course.

+ + + +

No assignment submissions.

+ +
+
+
+
+ + +
+ + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..9bcbdec --- /dev/null +++ b/login.php @@ -0,0 +1,66 @@ +prepare("SELECT id, password FROM users WHERE email = ? AND role = ?"); + $stmt->execute([$email, $role]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user_id'] = $user['id']; + $_SESSION['role'] = $role; + header("Location: index.php"); + exit; + } else { + $error = "Invalid credentials!"; + } + } catch (PDOException $e) { + $error = "Database error: " . $e->getMessage(); + } +} +?> + +
+
+
+
+

Login

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

Don't have an account? Register here

+
+
+
+
+
+ + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..2d2c92f --- /dev/null +++ b/logout.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/register.php b/register.php new file mode 100644 index 0000000..a308d53 --- /dev/null +++ b/register.php @@ -0,0 +1,73 @@ +prepare("SELECT id FROM users WHERE email = ?"); + $stmt->execute([$email]); + if ($stmt->fetch()) { + $error = 'User with this email already exists!'; + } else { + $stmt = $pdo->prepare("INSERT INTO users (email, password, role) VALUES (?, ?, ?)"); + if ($stmt->execute([$email, $hashed_password, $role])) { + $success = 'Registration successful! You can now login.'; + } else { + $error = 'Something went wrong. Please try again.'; + } + } + } catch (PDOException $e) { + $error = "Database error: " . $e->getMessage(); + } +} +?> + +
+
+
+
+

Register

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

Already have an account? Login here

+
+
+
+
+
+ + \ No newline at end of file