-
Notifications
You must be signed in to change notification settings - Fork 1
/
topUser.php
156 lines (142 loc) · 4.82 KB
/
topUser.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
/* Database connection settings */
$host = 'localhost';
$user = 'utente';
$pass = 'pass123';
$db = 'dbmysql';
$mysqli = new mysqli($host, $user, $pass, $db) or die($mysqli->error);
$result1 = '';
$data1 = '';
$data2 = '';
$file = '';
if (!empty($_POST['db'])) {
$db = $_POST['db'];
if ($db == 'Image') {
$query1 = "SELECT WORKER_ID, COUNT(IMAGE_FILE) AS NUM FROM `immquality` GROUP BY WORKER_ID ORDER BY NUM DESC";
$result1 = mysqli_query($mysqli, $query1);
$file = 'Image';
} else
if ($db == 'Video') {
$query2 = "SELECT WORKER_ID, COUNT(VIDEO_FILE) AS NUM FROM `vidquality` GROUP BY WORKER_ID ORDER BY NUM DESC";
$result1 = mysqli_query($mysqli, $query2);
$file = 'Video';
}
while ($row = mysqli_fetch_array($result1)) {
$data1 = $data1 . '"' . $row['WORKER_ID'] . '",';
$data2 = $data2 . '"' . $row['NUM'] . '",';
}
}
?>
<!DOCTYPE html>
<html>
<link
rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
<title>Mechanical Turk HIT Results</title>
<style type="text/css">
body {
font-family: Arial;
margin: 10px 10px 10px 10px;
padding: 0;
color: white;
text-align: center;
background: #555652;
}
.container {
color: #E8E9EB;
background: #222;
border: #555652 1px solid;
padding: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>TOP WORKERS</h1>
</div>
<form method="post" id="form">
<div class="btn-group btn-group-toggle container" data-toggle="buttons">
<label class="btn btn-secondary">
<input type="radio" name="db" id="option1" autocomplete="off"
onclick="document.getElementById('form').submit();" value="Video"> Video
</label>
<label class="btn btn-secondary">
<input type="radio" name="db" id="option2" autocomplete="off"
onclick="document.getElementById('form').submit();" value="Image"> Image
</label>
</div>
</form>
<div class="container">
<canvas id="chart"
style="width: 95%; height: 63vh; background: #222; border: 1px solid #555652; margin-top: 10px;"></canvas>
<script>
var ctx = document.getElementById("chart").getContext('2d');
var data1 = [<?php echo $data1; ?>];
var data2 = [<?php echo $data2; ?>];
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: data1,
datasets:
[{
data: data2,
backgroundColor: 'rgb(10,0,255, 0.2)',
borderColor: 'rgb(10,0,255)',
borderWidth: 1,
}
]
},
options: {
scales: {scales: {yAxes: [{beginAtZero: false}], xAxes: [{autoskip: true, maxTicketsLimit: 20}]}},
tooltips: {mode: 'index'},
legend: {display: false},
title: {
display: true,
position: 'bottom',
text: '<?php echo $file;?>' + ' Top Workers',
fontColor: 'rgba(255,249,255,0.5)',
fontSize: 16,
}
}
});
</script>
<div class="container">
<style>
a {
text-decoration: none;
display: inline-block;
padding: 8px 16px;
}
a:hover {
background-color: white;
color: black;
}
.previous {
background-color: white;
color: black;
float: left;
}
.next {
background-color: white;
color: black;
float: right;
}
.round {
border-radius: 50%;
}
</style>
<a href="cake.php" class="previous round">‹</a>
<button style="font-size:16px" onclick="window.location.href='/Chart'" class="btn btn-secondary">Dashboard <i
class="fa fa-dashboard"></i>
</button>
<a href="scatter.php" class="next round">›</a>
</div>
</div>
</body>
</html>