-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchartFile.php
218 lines (200 loc) · 6.94 KB
/
chartFile.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
/* Database connection settings */
$host = 'localhost';
$user = 'utente';
$pass = 'pass123';
$db = 'dbmysql';
$mysqli = new mysqli($host, $user, $pass, $db) or die($mysqli->error);
session_start();
$result1 = '';
if (!empty($_POST['db'])) {
$db = $_POST['db'];
if ($db == 'Image') {
$query1 = "SELECT DISTINCT IMAGE_FILE FROM `immquality`";
$result1 = mysqli_query($mysqli, $query1);
$_SESSION['db'] = 'Image';
} else
if ($db == 'Video') {
$query2 = "SELECT DISTINCT VIDEO_FILE FROM `vidquality`";
$result1 = mysqli_query($mysqli, $query2);
$_SESSION['db'] = 'Video';
}
}
$data1 = '';
$data2 = '';
if (!empty($_POST['file'])) {
if ($_SESSION['db'] == 'Image') {
$file = $_POST['file'];
$sql = "SELECT QUALITY, WORKER_ID FROM `immquality` WHERE IMAGE_FILE= '$file'";
$result = mysqli_query($mysqli, $sql);
while ($row = mysqli_fetch_array($result)) {
$data1 = $data1 . '"' . $row['QUALITY'] . '",';
$data2 = $data2 . '"' . $row['WORKER_ID'] . '",';
}
$data1 = trim($data1, ",");
$data2 = trim($data2, ",");
} else if ($_SESSION['db'] == 'Video') {
$file = $_POST['file'];
$sql = "SELECT QUALITY, WORKER_ID FROM `vidquality` WHERE VIDEO_FILE= '$file'";
$result = mysqli_query($mysqli, $sql);
while ($row = mysqli_fetch_array($result)) {
$data1 = $data1 . '"' . $row['QUALITY'] . '",';
$data2 = $data2 . '"' . $row['WORKER_ID'] . '",';
}
$data1 = trim($data1, ",");
$data2 = trim($data2, ",");
}
} else {
$data1 = 0;
$data2 = 0;
$file = '';
}
?>
<!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>EVALUATION HISTORY OF SINGLE FILE</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>
<form method="post">
<div class="container">
<select class="custom-select" name="file" id="select_file" onclick="selected()">
<option selected value="">Choose File...</option>
<?php while ($row = mysqli_fetch_array($result1)):; ?>
<option value="<?php echo $row[0] ?>"><?php echo $row[0] ?></option>
<?php endwhile; ?>
</select>
</div>
<div class="container">
<button type="submit" class="btn btn-secondary" disabled id="button">GET</button>
</div>
<script>
function selected() {
document.getElementById("button").disabled = false;
}
</script>
</form>
<div class="container">
<canvas id="chart"
style="width: 70%; height: 35vh; background: #222; border: 1px solid #555652; margin-top: 10px;"></canvas>
<script>
var ctx = document.getElementById("chart").getContext('2d');
var sum = 0;
var data1 = [<?php echo $data1; ?>];
for (var i = 0; i < data1.length; i++) {
sum += parseInt(data1[i], 10);
}
var singleavg = Math.round(sum / data1.length);
var avg = [];
for (var j = 0; j < data1.length; j++) {
avg.push(singleavg);
}
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: [<?php echo $data2?>],
datasets:
[{
label: 'Quality',
data: data1,
backgroundColor: 'transparent',
borderColor: 'rgb(255,34,0)',
borderWidth: 3
},
{
label: 'Average',
data: avg,
backgroundColor: 'transparent',
borderColor: 'rgb(10,0,255)',
borderWidth: 1,
}
]
},
options: {
scales: {scales: {yAxes: [{beginAtZero: false}], xAxes: [{autoskip: true, maxTicketsLimit: 20}]}},
tooltips: {mode: 'index'},
legend: {display: true, position: 'top', labels: {fontColor: 'rgb(255,255,255)', fontSize: 16}},
title: {
display: true,
position: 'bottom',
text: '<?php echo $file;?>' + ' History',
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="age.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="chartWorker.php" class="next round">›</a>
</div>
</div>
</body>
</html>