-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontest.php
More file actions
executable file
·97 lines (81 loc) · 3.13 KB
/
contest.php
File metadata and controls
executable file
·97 lines (81 loc) · 3.13 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
94
95
96
97
<?php include 'lib.php';
$mysqli = connect2mysql();
$contest_id = $_GET["id"];
$res = $mysqli->query("select result from contests where contest_id = ".$contest_id.";");
if(!$res || $res->num_rows <= 0){
not_found();
}
$res->data_seek(0);
$contest_result = $res->fetch_assoc();
// TODO: contest result table should be established once the
// contest is added. contest result is not a view, which the user is unique
// with highest rank;
assert(defined("CONTEST_RESULT_TABLE_PREFIX"));
$contest_result = CONTEST_RESULT_TABLE_PREFIX.$contest_result["result"];
htmlHeader("Contests");
htmlBanner();
?>
<!-- We are in the body tag of this html file now! -->
<div class="wrap">
<?php htmlSidebar(); ?>
<div class="content">
<div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#specification" aria-controls="specification" role="tab" data-toggle="tab">Specification</a></li>
<li role="presentation"><a href="#results" aria-controls="results" role="tab" data-toggle="tab">Results</a></li>
<li role="presentation"><a href="#submit" aria-controls="submit" role="tab" data-toggle="tab">Submit</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="specification">
<?php
$res = $mysqli->query("select title, abstract, description from contests where contest_id = ".$contest_id);
$row = $res->fetch_assoc();
printf("<div class='panel-body contest-specification'>
<h2> %s </h2> <br />
<p>%s</p>
<br />
<p>%s</p>
</div>
", $row["title"], $row["abstract"], $row["description"]);
?>
<br /><br /></div>
<div role="tabpanel" class="tab-pane" id="results">
<div class="panel-body">
<table class="table table-hover">
<tr>
<th>User</th>
<th>Score</th>
<th>Last Submission</th>
</tr>
<?php
$res = $mysqli->query("select user_id, rank, date from ".$contest_result." ;");
for($row_no = 0; $row_no < $res->num_rows; $row_no++){
$res->data_seek($row_no);
$row = $res->fetch_assoc();
if($row_no % 2 == 0){
$color = "active";
} else {
$color = "info";
}
$nickname = $mysqli->query("select nickname from users where user_id = ".$row["user_id"]." ;");
$nickname = $nickname->fetch_assoc()["nickname"];
printf("<tr class='%s'>
<td>%s </td>
<td>%s </td>
<td>%s </td>
</tr>", $color, $nickname, $row["rank"], $row["date"]);
}
$mysqli->close();
?>
</table>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="submit">...</div>
</div>
</div>
<div class="clearFloat"></div>
</div>
</div>
<?php htmlFooter(); ?>