-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudent_dashboard.php
135 lines (120 loc) · 4.72 KB
/
student_dashboard.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
session_start();
require_once 'db.php';
if (!isset($_SESSION['User_id']) || $_SESSION['user_role'] !== 'student') {
header("Location: ../login.php");
}
$user_id = $_SESSION['User_id'];
$studentId = "SELECT student_id from student AS s JOIN Users AS u ON s.user_id = u.User_id WHERE u.User_id = '$user_id'";
$studentName = "SELECT s.name FROM student AS s
JOIN Users AS u ON s.user_id = u.User_id
WHERE u.User_id = '$user_id'";
$_SESSION['student_id'] = $studentId;
$_SESSION['student_name'] = $studentName;
$semesterQuery = "SELECT semester FROM students WHERE id = '$studentId'";
$semesterResult = mysqli_query($connection, $semesterQuery);
$semesterData = mysqli_fetch_assoc($semesterResult);
$semester = $semesterData['semester'];
$coursesTakenQuery = "SELECT c.course_id, c.course_name, f.faculty_id, f.faculty_name, e.evaluated
FROM course c
JOIN course_faculty cf ON c.course_id = cf.course_id
JOIN faculty f ON cf.faculty_id = f.faculty_id
JOIN enrollment e ON c.course_id = e.course_id
JOIN student s ON e.student_id = s.student_id
WHERE s.section = (
SELECT s.section
FROM student s
WHERE s.student_id = $studentId
) AND e.evaluated IN ('evaluated', 'not evaluated') AND e.student_id = '$studentId'";
$coursesTakenResult = mysqli_query($connection, $coursesTakenQuery);
$coursesTaken = mysqli_fetch_all($coursesTakenResult, MYSQLI_ASSOC);
$evaluatedCoursesCount = 0;
$totalCoursesTaken = count($coursesTaken);
foreach ($coursesTaken as $course) {
if ($course['evaluated']) {
$evaluatedCoursesCount++;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Dashboard</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- <style>
.card,
.card-chart,
.card-table {
border-radius: 10px;
}
.card-chart {
background: rgb(240, 240, 240);
}
.chart {
background: rgb(230, 230, 230);
border-radius: 5px;
}
.card-table {
background: rgb(240, 240, 240);
}
tr:nth-child(even) {
background-color: rgb(250, 250, 250);
}
</style> -->
</head>
<body>
<div class="container">
<h1 class="mt-5">Welcome, <?php echo $studentName; ?></h1>
<p>Student ID: <?php echo $studentId; ?></p>
<p>Semester: <?php echo "Semester: {$semester}" ?></p>
<h2 class="mt-3">Courses Evaluated</h2>
<ul>
<?php foreach ($coursesTaken as $course): ?>
<?php if ($course['evaluated']): ?>
<li><?php echo $course['course_name']; ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<h2 class="mt-3">Courses Taken</h2>
<?php echo "Courses evaluated: {$evaluatedCoursesCount} / {$totalCoursesTaken}"; ?>
<table class="table table-striped">
<thead>
<tr>
<th>Course id</th>
<th>Course name</th>
<th>Faculty Name</th>
<th>Evaluation</th>
</tr>
</thead>
<tbody>
<?php foreach ($coursesTaken as $course): ?>
<tr>
<td><?php echo $course['course_id']; ?></td>
<td><?php echo $course['course_name']; ?></td>
<td><?php echo $course['faculty_name']; ?></td>
<td>
<?php if ($course['evaluated']): ?>
<button class="btn btn-secondary" disabled>Evaluated</button>
<?php else: ?>
<a href="student/student_evaluation.php?faculty_id=<?php echo $course['faculty_id']; ?>&course_name=<?php echo $course['course_name']; ?>&course_id=<?php echo $course['course_id']; ?>" class="btn btn-primary">Evaluate</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<a href="login.php" class="btn btn-danger">Logout</a>
<button onclick="goBack()" class="btn btn-secondary mb-3">Go Back</button>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
<script>
function goBack() {
window.history.back();
}
</script>
</body>
</html>