forked from ngsankha/codejudge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoreboard.php
100 lines (87 loc) · 2.65 KB
/
scoreboard.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
<?php
/*
* Codejudge
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
* Licensed under MIT License.
*
* Scoreboard page
*/
require_once('functions.php');
if(!loggedin())
header("Location: login.php");
else
include('header.php');
$link=connectdb();
?>
<li><a href="index.php">Problems</a></li>
<li><a href="submissions.php">Submissions</a></li>
<li class="active"><a href="#">Scoreboard</a></li>
<li><a href="account.php">Account</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
The current standings of all the participants, the number of problems they have attempted and solved.
<table class="table table-striped">
<thead><tr>
<th>Name</th>
<th>Points</th>
<th>Solved</th>
<th>Attempted</th>
</tr></thead>
<tbody><div id="live">
<?php
$_q = "SELECT users.sl,
users.username,
(SELECT COUNT(solve.status)
FROM solve
WHERE solve.username = users.username
AND solve.status=2 ) AS solved,
(SELECT COUNT(solve.status)
FROM solve
WHERE solve.username = users.username ) AS attempts,
(SELECT SUM(points)
FROM solve
WHERE status=2 AND username=users.username) AS points
FROM users
WHERE users.status=1 and users.username!='admin'
ORDER BY points DESC, attempts ASC
LIMIT 0, 35 ";
$_result = mysqli_query($link,$_q);
while($row = mysqli_fetch_array($_result,MYSQLI_BOTH)){
echo("<tr><td>".$row['username']."</td>");
// POINT BADGE
echo "<td><span class=\"badge badge-info\">[ $row[points] POINTS ]</span></td>";
// SOLVED BADGE
echo "<td><span class=\"badge badge-success\">".$row['solved']."</span></td>";
// ATTEMPTED BADGE
echo("<td><span class=\"badge badge-warning\">".$row['attempts']."</span></td>");
$class="<span class= 'badge badge-success' >";
echo "<td>.$class $total </span></td></tr>";
}
?>
</div>
</tbody>
</table>
</div> <!-- /container -->
<script>
window.setTimeout(function(){
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("live").innerHTML = this.responseText;
}
};
xhttp.open("GET", "live.php", true);
xhttp.send();
}
loadDoc
}, 8000);
</script>
<?php
include('footer.php');
?>