Targets are now read from CSV file on server #30
23
index.php
23
index.php
@ -30,6 +30,18 @@ $variables = array(
|
||||
'baseURL' => $settings->baseURL
|
||||
);
|
||||
|
||||
//Pull targets from CSV file
|
||||
if (($handle = fopen('targets.csv', 'r')) === false) {
|
||||
die('Error opening file');
|
||||
}
|
||||
$headers = fgetcsv($handle, 1024, ',');
|
||||
$targets = array();
|
||||
while ($row = fgetcsv($handle, 1024, ',')) {
|
||||
$targets[$row[0]] = array_combine($headers, $row);
|
||||
}
|
||||
fclose($handle);
|
||||
|
||||
|
||||
$template = false;
|
||||
$mode = !empty($_GET['mode']) ? $_GET['mode'] : 'start';
|
||||
$phase = !empty($_GET['phase']) && in_array($_GET['phase'], $settings->phases) ? $_GET['phase'] : false;
|
||||
@ -97,18 +109,17 @@ switch ($mode) {
|
||||
}
|
||||
|
||||
//Calculate the score. Compare results with targets in settings.json.
|
||||
if (($phasevalue['xcoordinate'] >= $settings->elementLocations->{$phasename }->topleft->x)
|
||||
&& ($phasevalue['xcoordinate'] < $settings->elementLocations->{$phasename}->bottomright->x)
|
||||
&& ($phasevalue['ycoordinate'] >= $settings->elementLocations->{$phasename}->topleft->y)
|
||||
&& ($phasevalue['ycoordinate'] < $settings->elementLocations->{$phasename}->bottomright->y)) {
|
||||
if (($phasevalue['xcoordinate'] >= $targets[$phasename][topleftx])
|
||||
&& ($phasevalue['xcoordinate'] < $targets[$phasename][bottomrightx])
|
||||
&& ($phasevalue['ycoordinate'] >= $targets[$phasename][toplefty])
|
||||
&& ($phasevalue['ycoordinate'] < $targets[$phasename][bottomrighty])) {
|
||||
//Put the correct score in the ready array
|
||||
array_push($ready, '1');
|
||||
}
|
||||
else {
|
||||
//Put the incorrect score in the ready array
|
||||
array_push($ready, '0');
|
||||
}
|
||||
|
||||
}
|
||||
//Building an INSERT query:
|
||||
//Include userid (once collection form is added into the start page)
|
||||
// DB fields are listed here:
|
||||
|
@ -12,37 +12,5 @@
|
||||
"renoted"
|
||||
],
|
||||
"baseURL": "/",
|
||||
"elementLocations": {
|
||||
"notable": {
|
||||
"topleft": {
|
||||
"x": 724,
|
||||
"y": 340
|
||||
},
|
||||
"bottomright": {
|
||||
"x": 884,
|
||||
"y": 456
|
||||
}
|
||||
},
|
||||
"unnoted": {
|
||||
"topleft": {
|
||||
"x": 48,
|
||||
"y": 180
|
||||
},
|
||||
"bottomright": {
|
||||
"x": 900,
|
||||
"y": 200
|
||||
}
|
||||
},
|
||||
"renoted": {
|
||||
"topleft": {
|
||||
"x": 48,
|
||||
"y": 180
|
||||
},
|
||||
"bottomright": {
|
||||
"x": 900,
|
||||
"y": 204
|
||||
}
|
||||
}
|
||||
},
|
||||
"debug": false
|
||||
}
|
||||
|
6
targets.csv
Normal file
6
targets.csv
Normal file
@ -0,0 +1,6 @@
|
||||
phase,topleftx,toplefty,bottomrightx,bottomrighty
|
||||
1,0,0,10,10
|
||||
2,0,0,20,20
|
||||
3,0,0,30,30
|
||||
4,0,0,40,40
|
||||
5,0,0,50,50
|
|
Reference in New Issue
Block a user