-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
102 lines (91 loc) · 2.63 KB
/
admin.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
101
102
<?php require_once 'core/init.php'; ?>
<?php require_once 'core/template/header.inc.php'; ?>
<?php restrictedAdmin(); ?>
<?php
$sql = "SELECT * FROM responses";
$query = $db->prepare( $sql );
$query->execute();
$results = $query->fetchAll( PDO::FETCH_ASSOC );
?>
<header class="clear">
<p class="total">Total number of participants: <?php echo countParticipants($db) ?></p>
<a class="btn pull-right" href="flush.php">Logout</a>
</header>
<main class="clear">
<?php
if(isset($_GET['response'])){
$currentResponse = $_GET['response'];
?>
<a href="admin.php" class="home-link"><i class="fa fa-home"></i></a>
<div class="response-chart-container">
<input type="hidden" id="chart-data" value='<?php echo json_encode(getResponse($db, $currentResponse)) ?>'>
<div id="response-chart"></div>
</div>
<div class="response-navigation clear">
<?php
if($currentResponse >= 2){
?>
<a class="prev" href="admin.php?response=<?php echo $currentResponse - 1 ?>"><i class="fa fa-arrow-left"></i> Response <?php echo $currentResponse - 1 ?></a>
<?php
}
?>
<?php
if($currentResponse <= 25){
?>
<a class="next" href="admin.php?response=<?php echo $currentResponse + 1 ?>">Response <?php echo $currentResponse + 1 ?> <i class="fa fa-arrow-right"></i> </a>
<?php
}
?>
</div>
<?php
} else {
?>
<div class="table-container">
<table>
<thead>
<tr>
<th>Responses</th>
<th><i class="fa fa-arrow-down"></i></th>
<th>-</th>
<th><i class="fa fa-arrow-up"></i></th>
</tr>
</thead>
<tbody>
<?php
for( $i=1; $i<=26; $i++ ){
echo '<tr><td>';
echo '<a href="?response=' . $i . '">Response No. ' . $i;
echo '</td><td>';
echo getResponses($db, 'MIN', $i);
echo'</td><td>';
echo getResponses($db, 'AVG', $i);
echo '</td><td>';
echo getResponses($db, 'MAX', $i);
echo '</td></tr>';
}
?>
</tbody>
</table>
</div>
<div class="pie-container">
<div class="age">
<h4>Age Ranges of Participants</h4>
<input type="hidden" id="age-values" value='<?php echo getValues($db, "age") ?>'>
<div class="chart" data-type="age"></div>
</div>
<div class="sex">
<h4>Sexes of Participants</h4>
<input type="hidden" id="sex-values" value='<?php echo getValues($db, "sex") ?>'>
<div class="chart" data-type="sex"></div>
</div>
<div class="usage">
<h4>Usage by Participants</h4>
<input type="hidden" id="amount-values" value='<?php echo getValues($db, "amount") ?>'>
<div class="chart" data-type="amount"></div>
</div>
</div>
<?php } ?>
</main>
<footer>
</footer>
<?php require_once 'core/template/footer.inc.php'; ?>