-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit-course-review.php
133 lines (118 loc) · 5.34 KB
/
edit-course-review.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
<html>
<head>
<?php
/**
* edit-course-review.php
* Form to edit a course review already in the database.
* This form can only be accessed from a user's profile page.
*/
include_once('db_connect.php');
include_once('links.html');
$user_id = $_POST['userID'];
$course_id = $_POST['courseID'];
$course_name = $_POST['courseName'];
$prof_id = $_POST['profID'];
$prof_name = $_POST['profName'];
$dept_id = $_POST['deptID'];
$query = "SELECT department.name AS department, college.id AS collegeID, college.name AS college FROM department JOIN college ON department.college_id=college.id WHERE department.id=?;";
$dept = $db->prepare($query);
$dept->execute(array($dept_id));
$dept = $dept->fetch();
$review = $_POST['review'];
$tips = $_POST['tips'];
$textbook = "";
if ($_POST['bookRequired'] == 'Yes') {
$textbook = "checked";
}
$usefulness = $_POST['usefulness'];
$easiness = $_POST['easiness'];
$overall = $_POST['overall'];
?>
<link rel="stylesheet" href="css/star-rating.css">
<script src="js/star-rating.js"></script>
<script>
function reset_star() {
$('#star1').rating('reset');
$('#star2').rating('reset');
$('#textbook').bootstrapToggle('off');
}
</script>
<link rel="stylesheet" href="css/bootstrap-toggle.css">
<script src="js/bootstrap-toggle.js"></script>
<title>
<?php
printf("Update review for %s course of %s Department, %s ", $course_name, $dept['department'], $dept['college']);
?>
</title>
<body style="background: url('img/pattern.png');">
<div class="container">
<?php
printf("<h3 style='text-align: center'>Update review for<br> <p><a href='course.php?id=$course_id'>$course_name</a></p>".
"<p><a href='department.php?id=$dept_id'>%s</a>, <a href='college.php?id=%d'>%s</a></p></h3>",$dept['department'], $dept['collegeID'], $dept['college']);
?>
</div>
<div class="jumbotron">
<form class="form-horizontal" role="form" method="POST" action="edit-course-review-auth.php">
<input type="hidden" name="courseID" value=<?php echo $course_id; ?>>
<input type="hidden" name="profID" value=<?php echo $prof_id; ?>>
<input type="hidden" name="deptID" value=<?php echo $dept_id; ?>>
<div class="form-group">
<label class="control-label col-sm-2">Professor:</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="professor" value='<?php echo $prof_name;?>' disabled>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Easiness:</label>
<div class="col-sm-4">
<input type="number" id='star1' name="easiness" class="rating" min=0 max=5 step=0.5 data-size="sm" data-rtl="false" value='<?php echo $easiness;?>' required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Textbook required:</label>
<div class="col-sm-4">
<input type="checkbox" id='textbook' data-toggle="toggle" data-on="Yes" data-off="No"
name="textbook_required" <?php echo $textbook;?> formnovalidate>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Course Review:</label>
<div class="col-sm-4">
<textarea class="form-control" name="course_review" rows="5" placeholder="Course Review"
required><?php echo $review;?></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Usefulness (Optional):</label>
<div class="col-sm-4">
<textarea class="form-control" name="helpfulness"
placeholder="How helpful was the course? (Eg: Was the course helpful towards your major? Did you learn new skills?)"
rows="2" required><?php echo $usefulness;?></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Tips (Optional):</label>
<div class="col-sm-4">
<textarea class="form-control" name="tips"
placeholder="Any tips for students taking or planning to take this course?"
rows="2" required><?php echo $tips;?></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Overall Rating:</label>
<div class="col-sm-4">
<input type="number" id='star2' name="overall_rating" class="rating" min=0 max=5 step=0.5 data-size="sm"
data-rtl="false" value='<?php echo $overall;?>' required>
</div>
</div>
<div class="form-group">
<div class="col-sm-4" align="right">
<input class="btn btn-success" type="submit" value="Submit">
<input class="btn btn-default" type="reset" onclick="reset_star()" value="Reset">
</div>
</div>
</form>
</div>
</body>
</head>
</html>