Skip to content

Instantly share code, notes, and snippets.

@pavelk2
Created June 11, 2014 15:01
Show Gist options
  • Save pavelk2/d43608a802bb9ad0e9e9 to your computer and use it in GitHub Desktop.
Save pavelk2/d43608a802bb9ad0e9e9 to your computer and use it in GitHub Desktop.
<?php
header('Content-type: application/json');
error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once 'settings_crowdcafe_local.php';
require_once 'libs/firebase/firebaseLib.php';
function setFirebaseValue($path, $value) {
require_once 'settings_firebase.php';
$firebase = new Firebase($firebase_url, $firebase_secret);
return $firebase->push($path, $value);
}
$foo = file_get_contents("php://input");
$data = json_decode($foo, true);
$gold_string = $data['question']['gold_rectangle'];
foreach ($data['answer'] as $key=>$val){
$answer_string = $val;
}
//var_dump($gold_string);
//var_dump($answer_string);
$gold_positions = explode(";", $gold_string);
$answer_positions = explode(";", $answer_string);
//var_dump(abs(floatval($gold_positions[0])-floatval($answer_positions[0])));
if (
abs(floatval($gold_positions[0])-floatval($answer_positions[0])) < 0.05 and
abs(floatval($gold_positions[1])-floatval($answer_positions[1])) < 0.05 and
abs(floatval($gold_positions[2])-floatval($answer_positions[2])) < 0.05 and
abs(floatval($gold_positions[3])-floatval($answer_positions[3])) < 0.05
){
echo 1;
}
else{
echo -1;
}
$new_block = setFirebaseValue('answers',$data);
#echo json_decode($new_block)->name;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment