-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrecord_ajax.php
More file actions
93 lines (89 loc) · 3.08 KB
/
record_ajax.php
File metadata and controls
93 lines (89 loc) · 3.08 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
<?php
session_start() ;
$db_host = 'localhost' ;
$db_database = 'pd course' ;
$db_username = 'root' ;
$connection = mysql_connect($db_host, $db_username, 'pdogsserver');
if (!$connection)
die ("connection failed".mysql_error()) ;
mysql_query("SET NAMES 'utf8'");
$selection = mysql_select_db($db_database) ;
if (!$selection)
die ("selection failed".mysql_error()) ;
if (!isset($_SESSION['account'])){
header ("Location:index.php") ;
} else {
?>
<div class="hero-unit upload_section">
<table class="table table-hover">
<thead>
<tr>
<th>Problem</th>
<th>Status</th>
<th>Run time</th>
<th>Submission date</th>
<th>Score</th>
</tr>
</thead>
<tbody>
<?php
$query_pd = "SELECT p_id, status, exec_time, time, score FROM pd_score NATURAL JOIN student
WHERE account = '".mysql_real_escape_string($_SESSION['account'])."' ORDER BY time DESC LIMIT 0, 15";
$pd = mysql_query($query_pd);
$query_lab = "SELECT lab_id, status, exec_time, time, score FROM lab_score NATURAL JOIN student
WHERE account = '".mysql_real_escape_string($_SESSION['account'])."' ORDER BY time DESC LIMIT 0, 15";
$lab = mysql_query($query_lab);
$count = 0;
$fetch_pd = mysql_fetch_row($pd);
$fetch_lab = mysql_fetch_row($lab);
while ( $count < 15 ){
if ($fetch_pd[3] > $fetch_lab[3]){
if ($fetch_pd[1] == 'Accepted'){
?><tr class="accept"><?php
} else if ($fetch_pd[1] == 'Compilation error' or $fetch_pd[1] == 'Runtime error'){
?><tr class="error"><?php
} else if ($fetch_pd[1] == 'Time limit exceed'){
?><tr class="time_exceed"><?php
} else if ($fetch_pd[1] == 'Wrong answer'){
?><tr class="wrong_answer"><?php
} else if ($fetch_pd[1] == 'System upload error'){
?><tr class="upload_error"><?php
} ?>
<td><?php echo $fetch_pd[0];?></td>
<td><?php echo $fetch_pd[1];?></td>
<td><?php echo $fetch_pd[2].'s';?></td>
<td><?php echo $fetch_pd[3];?></td>
<td><?php echo $fetch_pd[4];?></td>
</tr> <?php
$fetch_pd = mysql_fetch_row($pd);
} else {
if ($fetch_lab[1] == 'Accepted'){
?><tr class="accept"><?php
} else if ($fetch_lab[1] == 'Compilation error' or $fetch_lab[1] == 'Runtime error'){
?><tr class="error"><?php
} else if ($fetch_lab[1] == 'Time limit exceed'){
?><tr class="time_exceed"><?php
} else if ($fetch_lab[1] == 'Wrong answer'){
?><tr class="wrong_answer"><?php
} else if ($fetch_lab[1] == 'System upload error'){
?><tr class="upload_error"><?php
} ?>
<td><?php echo $fetch_lab[0];?></td>
<td><?php echo $fetch_lab[1];?></td>
<td><?php echo $fetch_lab[2].'s';?></td>
<td><?php echo $fetch_lab[3];?></td>
<td><?php echo $fetch_lab[4];?></td>
</tr> <?php
$fetch_lab = mysql_fetch_row($lab);
}
$count++;
if ($fetch_pd == null and $fetch_lab == null)
break;
}
?>
</tbody>
</table>
</div>
<?php
}
?>