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
|
'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;
|
$template = false;
|
||||||
$mode = !empty($_GET['mode']) ? $_GET['mode'] : 'start';
|
$mode = !empty($_GET['mode']) ? $_GET['mode'] : 'start';
|
||||||
$phase = !empty($_GET['phase']) && in_array($_GET['phase'], $settings->phases) ? $_GET['phase'] : false;
|
$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.
|
//Calculate the score. Compare results with targets in settings.json.
|
||||||
if (($phasevalue['xcoordinate'] >= $settings->elementLocations->{$phasename }->topleft->x)
|
if (($phasevalue['xcoordinate'] >= $targets[$phasename][topleftx])
|
||||||
&& ($phasevalue['xcoordinate'] < $settings->elementLocations->{$phasename}->bottomright->x)
|
&& ($phasevalue['xcoordinate'] < $targets[$phasename][bottomrightx])
|
||||||
&& ($phasevalue['ycoordinate'] >= $settings->elementLocations->{$phasename}->topleft->y)
|
&& ($phasevalue['ycoordinate'] >= $targets[$phasename][toplefty])
|
||||||
&& ($phasevalue['ycoordinate'] < $settings->elementLocations->{$phasename}->bottomright->y)) {
|
&& ($phasevalue['ycoordinate'] < $targets[$phasename][bottomrighty])) {
|
||||||
//Put the correct score in the ready array
|
//Put the correct score in the ready array
|
||||||
array_push($ready, '1');
|
array_push($ready, '1');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Put the incorrect score in the ready array
|
//Put the incorrect score in the ready array
|
||||||
array_push($ready, '0');
|
array_push($ready, '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Building an INSERT query:
|
//Building an INSERT query:
|
||||||
//Include userid (once collection form is added into the start page)
|
//Include userid (once collection form is added into the start page)
|
||||||
// DB fields are listed here:
|
// DB fields are listed here:
|
||||||
|
@ -12,37 +12,5 @@
|
|||||||
"renoted"
|
"renoted"
|
||||||
],
|
],
|
||||||
"baseURL": "/",
|
"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
|
"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