-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·79 lines (65 loc) · 2.76 KB
/
index.php
File metadata and controls
executable file
·79 lines (65 loc) · 2.76 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
<?php
require_once('includes/bootstrap.php');
include('header.php');
if (isset($_GET['success']))
echo("<div class=\"alert alert-success\" style=\"margin-right:100px\">\nCongratulations! Your code has been submitted\n</div>");
?>
<div class="cards-container" style="margin-right:100px">
<div class="collapsible-header purple darken-4 z-depth-5 white-text"><b>AVAILABLE PROBLEMS<span style="position:relative; right:-280px;">Time-remaining :<span id="timer_text">2:00</span></span></b></div>
<br>
<!-- Start Listing All problems-->
<div ></div>
<?php
$query = "SELECT * FROM problems";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) == 0)
echo(" <div class=\"card-panel\">None</div>"); // no problems are there
else {
while ($row = mysqli_fetch_assoc($result)) {
// echo("<li><a href=\"submit.php?id=" . $row['id'] . "\">" . $row['title'] . $tag . "</a></li>\n");
$url = "submit.php?id=".$row['id'];
$text = strip_tags(shortenText($row['text']));
//Determine whether the problem has been solved or just attempted for this user
$sql = "SELECT statusCode FROM submissions WHERE (username='".$_SESSION['username'].
"' AND problem_id='".$row['id']."')";
$res = mysqli_query($con, $sql);
$status = "";
// decide the attempted or solve tag
if(mysqli_num_rows($res) !== 0) {
$res = mysqli_fetch_assoc($res);
if($res['statusCode'] == 1)
$status = " <span class=\"custom-label-status-attempted\">Attempted</span>";
else if($res['statusCode'] == 2)
$status = " <span class=\"custom-label-status-solved\">Solved</span>";
}
else
$status = "<span class=\"custom-label-status-nattempted\">Not Attempted</span>";
echo "
<div class=\"card indigo darken-1 z-depth-4 white-text\" style=\"box-shadow: grey 10px 9px 3px;margin-bottom:30px;\">
<div class=\"card-content\">
<a href=\"{$url}\" target='_blank'>
<span class='card-title white-text'>
{$row['title']}
</span>
</a>
<hr>
<p>{$text}</p>
</div>
<div class=\"card-action grey lighten-3\">
<a href=\"{$url}\" target='_blank' class='blue-text text-darken-4'>Click to solve this</a>
<a class=\"right\">{$status}</a>
</div>
</div>
";
}
}
?>
</ul>
</div>
<script type="text/javascript" src="js/timer.js">
</script>
<script type="text/javascript" >
timelimit(<?php echo getRemTimeForUser($con, $_SESSION['username']); ?>);
</script>
<<<<<<< HEAD
<?php include('footer.php'); ?>