-
Notifications
You must be signed in to change notification settings - Fork 0
/
teacher.php
152 lines (122 loc) · 3.95 KB
/
teacher.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
<?php
// start session
session_start();
require_once ("functions.php");
// Send a raw HTTP header with the media type
header("Content-Type: text/html;charset=utf-8");
$login = $_SESSION['login'];
$passw = $_SESSION['passw'];
// if user is not logged in redirect him to login page
if(empty($_SESSION['login']))
header('Location: index.php');
if( $_SESSION['Usertype'] == 'S' )
header('Location: student.php');
elseif ( $_SESSION['Usertype'] != 'T' )
{
session_destroy();
header('Location: index.php');
}
// Create connection
$conn = ConnectToServer();
// connect to database
mysqli_query($conn, "use vr2m");
if($_SERVER["REQUEST_METHOD"]=="POST")
{
if(isset($_POST['SignOut']))
{
session_destroy();
header('Location: index.php');
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<h1>Instructor page</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="submit" name="SignOut" value="Sign out" />
</form>
</br>
<?php
if($_SERVER["REQUEST_METHOD"]=="POST")
{
{
if(isset($_POST['CreateCourseWork']))
{
$sql = "call addCourseWork('".$_POST['cNum']."','".$_POST['cName']."','".$_POST['sNum']."','".$_POST['eDes']."','".$_POST['aDate']."','".$_POST['dDate']."','".$_POST['wtype']."')";
$result = mysqli_query($conn, $sql);
}
if(isset($_POST['EditCourseWork']))
{
$sql = "call editAssignDueDate('".$_POST['cName']."','".$_POST['c_crn']."','".$_POST['aDate']."','".$_POST['dDate']."')";
$result = mysqli_query($conn, $sql);
}
if(isset($_POST['DeleteCourseWork']))
{
$sql = "call deleteCourseWork('".$_POST['cName']."','".$_POST['crnNum']."')";
$result = mysqli_query($conn, $sql);
}
if(isset($_POST['ViewAllCourseWork']))
{
$sql = "call courseWorkOfInstructor('".$login."')";
$result = mysqli_query($conn, $sql);
echo "<table> <tr><th>Course</th><th>CRN</th> <th>Section</th> <th>Name</th> <th>Assign_date</th> <th>Due_date</th> <th>Description</th> </tr>";
echo "</td>";
if (mysqli_num_rows($result) > 0)
{
// output data of each row
while($row = mysqli_fetch_assoc($result))
echo "<tr><th>".$row["CourseNum"]."</th><th>".$row["eCRN"]."</th> <th>".$row["eSectionNum"]."</th> <th>".$row["Name"]."</th> <th>".$row["Assign_date"]."</th> <th>".$row["Due_date"]."</th> <th>". "<a href='".$row["eDescription"]."'>Description</a>" ."</th> </tr>";
}
echo "</table>";
}
}
}
?>
<br/>
<br/>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="submit" name="ViewAllCourseWork" value="View all coursework" />
</form>
<br/>
<br/>
<h3>Create Coursework</h3>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="cName"/> Coursework name <br/>
<input type="text" name="cNum" /> Course #<br/>
<input type="text" name="sNum" /> Section #<br/>
<input type="text" name="eDes" /> Description file<br/>
<input type="text" name="aDate"/> Available date<br/>
<input type="text" name="dDate"/> Due date<br/>
<input type="text" name="wtype"/> Work type<br/>
<input type="submit" name="CreateCourseWork" value="Enter" />
</form>
<br/>
<br/>
<h3>Edit Coursework</h3>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="cName"/>Coursework name <br/>
<input type="text" name="c_crn"/>CRN<br/>
<input type="text" name="aDate"/>Available date<br/>
<input type="text" name="dDate"/>Due date<br/>
<input type="submit" name="EditCourseWork" value="Enter" />
</form>
<br/>
<br/>
<h3>Delete Coursework</h3>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="cName"/>Coursework name<br/>
<input type="text" name="crnNum"/>CRN<br/>
<input type="submit" name="DeleteCourseWork" value="Enter" />
</form>
<br/>
<br/>
</body>
</html>