-
Notifications
You must be signed in to change notification settings - Fork 1
/
student_session_page.php
210 lines (176 loc) · 6.22 KB
/
student_session_page.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
session_start();
include_once("pdo_mysql.php");
if(isset($_POST['submitBtn'])){
$_SESSION['classID'] = $_POST['sessionid'];
$classID = $_POST['sessionid'];
$_SESSION['userName'] = $_POST['studName'];
$userName = $_SESSION['userName'];
$_SESSION['userEmail'] = $_POST['studEmail'];
$userEmail = $_SESSION['userEmail'];
}
if(isset($_GET["w1"]) && isset($_GET["w2"])){
$deleteName = $_GET["w1"];
$deleteDescr = $_GET["w2"];
$host = 'dbserver.engr.scu.edu';
$username = 'pnguyen';
$password = '00000949559';
$database = 'sdb_pnguyen';
if(!$conn = pdo_connect("$host", $username, $password))
die('Error connecting to '.host.'. '.pdo_error());
if(!pdo_select_db($database, $conn))
die('Error selecting '.$database.'. '.pdo_error());
$deleteName = pdo_escape_string($deleteName);
$deleteDescr = pdo_escape_string($deleteDescr);
$newQuery = "UPDATE `enqueue` SET `isSolved` = '1', `TimeOut` = now() WHERE `reqDescrip` LIKE '%$deleteDescr%' AND `studentName` LIKE '%$deleteName%'";
if(strcmp($_SESSION['userName'], $deleteName) == 0){
if(pdo_query($newQuery)){
}
else{
echo'update not complete';
die(pdo_error());
}
}
}
?>
<html lang="en">
<head>
<style>
.alert{
display: none;
}
</style>
<title>Student Session Page</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
</head>
<body>
<div class="container" align = "center">
<h1>enQueue</h1>
<h4>Class Listing: <?php echo $_SESSION['classID']; ?> </h4>
<br><br>
<table id = "classTable" class = "pure-table pure-table-bordered">
<thead>
<tr>
<th> Select </th>
<th> Student Name </th>
<th> Request Description </th>
<th> Type </th>
<th> Time In </th>
</tr>
</thead>
<tbody>
<?php
if(isset($_POST['submitBtn'])){
$_SESSION['classID'] = $_POST['sessionid'];
$classID = $_POST['sessionid'];
$_SESSION['userName'] = $_POST['studName'];
$userName = $_SESSION['userName'];
$_SESSION['userEmail'] = $_POST['studEmail'];
$userEmail = $_SESSION['userEmail'];
}
$host = 'dbserver.engr.scu.edu';
$username = 'pnguyen';
$password = '00000949559';
$database = 'sdb_pnguyen';
if(!$conn = pdo_connect("$host", $username, $password))
die('Error connecting to '.host.'.'.pdo_error());
if(!pdo_select_db($database, $conn))
die('Error selecting '.$database.'. '.pdo_error());
$classID = $_SESSION['classID'];
$execItems = pdo_query("SELECT classID, studentName, reqDescrip, category, timeIn FROM `enqueue` WHERE classID = $classID and studentName != 'blank' and isSolved = 'FALSE' ORDER BY `order`");
while($row = pdo_fetch_array($execItems, MYSQL_ASSOC)){
echo "
<tr>
<td> <input type=\"checkbox\" name=\"chk\"/></td>
<td>".$row['studentName']."</td>
<td>".$row['reqDescrip']."</td>
<td>".$row['category']."</td>
<td>".$row['timeIn']."</td>
</tr>
";
}
?>
</tbody>
</table>
<p>*Students may only delete their own requests!</p>
<div class="container">
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal" style = "margin-right: 25px;">Add Request</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<form role="form" method ="post" id = "requestForm" action = "post_request.php">
<div class="form-group">
Category: <br>
<select id = "category" name = "category">
<option value = "Clarification"> Clarification </option>
<option value = "Conceptual"> Conceptual </option>
<option value = "Logical Error"> Logical Error </option>
<option value = "Compiling Error"> Compiling Error </option>
<option value = "Runtime Error"> Runtime Error </option>
<option value ="Demo"> Demo </option>
<option value = "Other"> Other </option>
</select>
</div>
<div class="dropdown">
Description: <br>
<textarea rows = "4" cols = "25" name = "description" id = "description"> </textarea><br>
<input type = "submit" name = "submitted" value = "Add Request"/>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<br> <br>
</div>
<input type="button" value = "Remove Request" onclick = "delRow()"/>
<form action = "http://students.engr.scu.edu/~pnguyen/enqueue_master/student_session_page.php"><input type= "submit" value="Refresh"></form>
</div>
<script>
function delRow(){
try{
var table = document.getElementById("classTable");
var rowCount = table.rows.length;
var checkList = window.document.getElementsByName('chk');
for(var j =0; j<checkList.length; j++){
if(checkList[j].checked == true){
var x = document.getElementById("classTable").rows[j+1].cells;
xVal1 = x[1].innerHTML;
xVal2 = x[2].innerHTML;
table.deleteRow(j+1);
rowCount--;
j--;
window.location.href = "student_session_page.php?w1=" + xVal1 + "&w2=" + xVal2;
}
}
}
catch(e){
alert(e);
}
}
function test(){
alert("test");
}
</script>
<center>
<a href="logout_student.php">Exit Session</a>
<br><br>
<p>We appreciate you guys using our enQueue prototype! Please take 2 minutes and click <a href ="http://goo.gl/forms/fX7shxhV3d">here</a> to fill out a very brief survey about your experience. Thank you!
</center>
</body>
</html>