forked from BE-PROJECTS2018/GroupNo45-Pantomath-bo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
interview.php
398 lines (337 loc) · 12.9 KB
/
interview.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<?php
include './serverScript/class/Database.php';
$db = new Database();
$db->connect();
$db->sql("SELECT count(*) as num FROM pb_candidate_list;");
$num_conducted = $db->getResult();
$db->sql("SELECT count(*) as num FROM pb_candidate_details;");
$num_total = $db->getResult();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="New Intelligent System">
<title>Pantomath'Bo</title>
<link rel="stylesheet" href="./css/mainstyle.css" >
<link rel="stylesheet" href="./css/fontawesome.css" >
<link rel="stylesheet" href="./css/bootstrap.min.css">
<!-- JS -->
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/bootstrap.min.js"></script>
<script type="text/javascript" src="./js/plot/d3.min.js"></script>
<script type="text/javascript" src="./js/plot/d3.layout.min.js"></script>
<script type="text/javascript" src="./js/plot/rickshaw.min.js"></script>
<script type="text/javascript" src="./js/plot/Rickshaw.Series.Sliding.js"></script>
<script type="text/javascript" src="./js/plot/d3.v2.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/build/grids-responsive-min.css">
<link rel="stylesheet" href="css/layouts/blog.css">
<style type="text/css">
form { margin-top: 15px; }
form > input { margin-right: 15px; }
#results { float:right; margin:20px; padding:20px; border:1px solid; background:#ccc; }
#myProgress {
width: 750px;
background-color: #ddd;
}
#analysis_results{
margin-bottom:0;
margin-top:20px;
text-align:center;
}
#myBar {
width: 10%;
height: 30px;
background-color: #4CAF50;
text-align: center;
line-height: 30px;
color: white;
}
.container {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
margin: 0 auto;
flex-wrap: wrap;
box-sizing: border-box;
}
.container-wrapper {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
max-width: 750px;
margin: 0 auto;
flex-wrap: wrap;
}
.card {
margin-top:10px;
margin-right:10px;
padding:5px;
border: 1px solid #ddd;
}
.rating_label{
background-color:#56776e;
color:white;
padding:5px;
}
hr{
margin:0;
height: 12px;
border: 0;
box-shadow: inset 0 12px 12px -12px rgba(0, 0, 0, 0.5);
}
</style>
</head>
<body onload="startTime()">
<div id="layout" class="pure-g">
<div class="sidebar pure-u-1 pure-u-md-1-4">
<div class="header">
<h1 class="brand-title">Pantomath 'Bo</h1>
<h2 class="brand-tagline">Discover Cross Model Behavior Analysis</h2>
<nav class="nav">
<ul class="nav-list">
<li class="nav-item">
<a class="pure-button" <?php echo "href=\"./start.php?id=" . $_GET["id"] . "\""?>>Interview Info</a>
</li>
<li class="nav-item">
<a class="pure-button" href="./list.php">List of Candidates</a>
</li>
<li class="nav-item">
<a class="pure-button" href="index.php">New Interview</a>
</li>
</ul>
</nav>
</div>
</div>
<div class="content pure-u-1 pure-u-md-3-4">
<div>
<!-- A wrapper for all the blog posts -->
<div class="posts">
<h1 class="content-subhead">Pinned Board</h1>
<!-- A single blog post -->
<section class="post">
<header class="post-header">
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML =
h + ":" + m + ":" + s;
var t = setTimeout(startTime, 500);
}
function checkTime(i) {
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
</script>
<h2 class="post-title">Time <div id="txt"></div></h2>
</header>
<div class="post-description">
<div class="list">
<ul class="quantity-list">
<li class="quantity-item">
Number of Cadidates:
<h2 class="quantity-item"><?php echo $num_total[0]["num"];?></h2>
</li>
<li class="quantity-item">
Number of interviews conducted:
<h2 class="quantity-item"><?php echo $num_conducted[0]["num"];?></h2>
</li>
</ul>
</div>
</div>
</section>
<section >
<div class="container">
<div class="container-wrapper">
<!-- candidate photo -->
<div id="results" class="card" >
<?php
$db->sql('SELECT photo FROM pb_candidate_details WHERE c_id=' . $_GET['id']);
$res = $db->getResult();
$html = '<h2>Candidate Profile:</h2>' .
'<img src="' . $res[0]["photo"] . '"/>';
echo $html;
?>
</div>
<!-- Interview Controls-->
<div class="card">
<button id="start" >start Interview</button>
<button id="stop">stop Interview</button>
<button id="fetch">Get Analysis</button>
<div id="log">Here your log comes</div>
</div>
</div>
</div>
<div class="container">
<div class="container-wrapper">
<div id="myProgress" class="card">
<div id="myBar">10%</div>
</div>
</div>
<div class="container-wrapper">
<div class="graphs">
<ul class="graph-list">
<li class="graph-number">
<div id="chart-smile">
<h2 style="text-align: center">Smile Score Variation</h2>
</div>
</li>
</ul>
</div>
</div>
</div>
</section>
<section class="ratings-container" id="final_Score">
</section>
</div>
</div>
</div>
</div>
<script>
var graph=null;
var stop=false;
var started=false;
var isLastModifiedSet = false;
var lastModified = 0;
// Generate a graph
$(document).ready(function(){
$(".graphs").hide();
$("#myProgress").hide();
$(".ratings-container").hide();
$("#start").click(function(){
if(!started){
started=true;
$("#myProgress").show();
progressBar();
$.get("./driver.php",{"id":1},function(data) {
console.log(data);
$("#log").append("<br><p>" + data + "</p>");
});
getBackgroundStatus();
}
else{
alert("Backend is starting soon...");
}
});
$("#stop").click(function(){
$.get("./driver.php",{"id":2},function(data) {
stop = true;
$("#log").append("<br><p>" + data + "</p>");
$(".graphs").hide();
$.get("./getFeatures.php",{"id":<?php echo $_GET["id"] ?>},function(data) {
$("#log").append("<br><p>" + data + "</p>");
var obj = data;
console.log(obj);
});
});
});
$("#fetch").click(function(){
$.get("./getFeatures.php",{"id":<?php echo $_GET["id"] ?>,"fetch":1},function(data) {
//$("#log").html("<br><p>" + data + "</p>");
var obj = data;
console.log(obj);
var content = "<h2 id=\"analysis_results\">Analysis Results</h2><br><hr/>" + data;
$(".ratings-container").html(content);
$(".ratings-container").show();
});
});
});
function initiate(){
console.log("setting up graph and flooding data");
graph_flood();
console.log("displaying graphs");
$(".graphs").show();
console.log("hiding rating container");
$(".ratings-container").hide();
console.log("creating new connection");
fetch_data();
}
function graph_flood(){
console.log("graph instance created");
graph = new Rickshaw.Graph( {
element: document.getElementById("chart-smile"),
width: 600,
height: 240,
renderer: 'line',
series: new Rickshaw.Series.Sliding([{ name: 'smile'}], undefined, {
maxDataPoints: 100,
})
});
console.log("graph:"+graph);
// Render the graph
console.log("rendering started");
graph.render();
console.log("Graph setup complete");
}
function progressBar() {
var elem = document.getElementById("myBar");
var width = 10;
var id = setInterval(frame, 700);
function frame() {
if (width >= 100) {
clearInterval(id);
} else {
width++;
elem.style.width = width + '%';
elem.innerHTML = width * 1 + '%';
}
}
}
function fetch_data() {
console.log("Data fetch started");
$.ajax({
type: "GET",
url: "./stream.php",
success: function(e) {
var obj = JSON.parse(e);
console.log(obj);
graph.series.addData(obj.series, obj.x);
graph.render();
}
});
console.log("added to graph");
if(stop != true)
{
setTimeout(fetch_data, 200);
}else{
console.log("User stopped");
}
}
function loadData(){
console.log("showing smile score");
$("#myProgress").hide();
initiate();
}
function getBackgroundStatus() {
$.ajax({
type: "GET",
url: "./backgroundStatus.php",
success: function(e) {
console.log(e);
if(lastModified < parseInt(e) && isLastModifiedSet){
console.log("data changed");
}else{
lastModified = parseInt(e);
isLastModifiedSet = true;
}
if(lastModified == parseInt(e)){
console.log("last modified is same");
setTimeout(getBackgroundStatus,500);
}else{
console.log("calling load data");
loadData();
}
}
});
}
</script>
</body>
</html>