-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcourseOptions.php
More file actions
95 lines (70 loc) · 3.49 KB
/
Copy pathcourseOptions.php
File metadata and controls
95 lines (70 loc) · 3.49 KB
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
<!-- Include Header -->
<?php include 'sources/php/head.php';?>
<body>
<!-- Designed by SHP Tech Ambassadors -->
<section id="hero">
<div class="container">
<div class="row col-xs-12">
<div class="page-header">
<h1>Course Options <small>SHP</small></h1>
</div>
</div>
</div>
</section><!-- /#hero -->
<section id="content">
<div class="container">
<div class="row col-xs-12">
<!-- Content -->
<?php
include 'sources/php/model.php';
$courseOptions = array();
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// die if connection fails
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// get a query of all the deparments
$departmentQuery = "SELECT department_name FROM department ORDER BY department_name";
$departmentResult = $conn->query($departmentQuery);
while($departmentRow = $departmentResult->fetch_assoc()) {
$departmentName = $departmentRow['department_name'];
$subDepartmentName = null;
$courseGiven = $_POST[str_replace(' ', '',$departmentName)];
$newCourseIndex = 0;
$oldCourseIndex = -1;
if($courseGiven != 'none') {
$currentCourseQuery = "SELECT course_name, sub_department, course_index, index_increase_upon_course_completion FROM course WHERE course_name='$courseGiven'";
$currentCourseresult = $conn->query($currentCourseQuery);
while($currentCourse = $currentCourseresult->fetch_assoc()) {
$subDepartmentName = $currentCourse['sub_department'];
$oldCourseIndex = $currentCourse['course_index'];
$newCourseIndex = $currentCourse['course_index'] + $currentCourse['index_increase_upon_course_completion'];
}
}
$avaliableCoursesQuery;
echo "<h3>$departmentName:</h3>";
if(is_null($subDepartmentName)) {
$avaliableCoursesQuery = "SELECT * FROM course WHERE department='$departmentName' AND (course_index=$newCourseIndex OR (alternate_course_index=$newCourseIndex AND course_index >= $oldCourseIndex) OR (alternate_course_index = -2 AND $newCourseIndex > course_index))";
} else {
$avaliableCoursesQuery = "SELECT * FROM course WHERE (department='$departmentName' AND (sub_department='$subDepartmentName' OR sub_department IS NULL)) AND (course_index=$newCourseIndex OR (alternate_course_index=$newCourseIndex AND course_index >= $oldCourseIndex) OR (alternate_course_index = -2 AND $newCourseIndex > course_index))";
// echo message about sub departments eliminating other introductory course options
echo "<p> Note: These suggestsions assume you wish to remain in the sub-department of <i>$subDepartmentName</i> in <i>$departmentName</i>. If you would like to switch sub-departments consult the <a href='https://shschools.myschoolapp.com/app/student#resourceboarddetail/9142'>official course handbook</a> for the upcoming school year. Keep in mind such a switch's affect on graduation requirements.<br><br></p>";
}
$avaliableCoursesResult = $conn->query($avaliableCoursesQuery);
while($course = $avaliableCoursesResult->fetch_assoc()) {
echo($course['course_name']."<br>");
}
echo("<br><br>");
}
?>
</div>
</div>
</section><!-- /#content -->
<!-- Javascript files -->
<!-- Javascript Libraries -->
<script src="sources/js/modernizr.custom.js"></script>
<!-- Javascript Custom -->
<script src="sources/js/the.js"></script>
</body>
</html>