-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProfessorViewsGradedExam.php
48 lines (39 loc) · 1.6 KB
/
ProfessorViewsGradedExam.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
<?php
$hostname = 'sql.njit.edu';
$username = 'am2272';
$password = 'zy0sqcm7'; //NJIT given password
$database = 'am2272';
$examnum = (int)trim($_POST['examnum']);
//$examnum = 5;
$conn = mysqli_connect($hostname, $username, $password, $database);
if(!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM ExamLookup2 WHERE ExamNumber = $examnum";
$result = $conn->query($sql);
$counter = 1;
$div = "<h1 id='examnumber'>Exam $examnum</h1><br><br>";
while ($row = mysqli_fetch_assoc($result)) {
$cntstr = (string)$counter;
//$cntstr = "1";
$points = (string)$row["Points"];
//$points = "0";
$strdes = (string)$row["Description"];
$strans = (string)$row["Answer"];
$strgra = (string)$row["Grade"];
$strcom = (string)$row["Comments"];
//$strdes = "hello";
$div = $div . "<h3>Question $cntstr, $points Points</h3><h4>$strdes</h4>";
$div = $div . "<h5>Student answer: </h5>";
$div = $div . "<p><pre>$strans</pre></p>";
$div = $div . "<h3>Auto-Grade: $strgra/$points</h3>";//<h5>Final Grade:</h5><input type=\"text\" name=\"changegrade$cntstr\"><br><br>";
//$div = $div . "<h5>Comments: <pre>$strcom</pre></h5><br><h5>Add to comments: </h5><br><input type=\"text\" name=\"professorcomment$cntstr\"><br><br>";
$div = $div . "<h5>Comments: </h5><pre>$strcom</pre><br><h5>Add to comments: </h5><br><textarea rows=\"5\" cols=\"60\" wrap=\"soft\" id=\"professorcomment$cntstr\"></textarea><br><br>";
$counter += 1;
}
$arr = array("results" => $div);
//echo $div;
echo json_encode($arr);
//echo "reached the end";
?>