<?php require_once '../sc_data_recording.php'; date_default_timezone_set('Europe/London'); // $sc_dr = new SC_Data_Recording('test_survey'); $survey_id = 'sc_test_survey'; $arr_response = array('q_one' => 'Tom', 'q_two' => 'likes', 'q_three' => array('chocolate', 'roast lamb', 'cheese', 'pork pies')); $db = array('host' => 'localhost', 'name' => 'sc_test', 'user' => 'root', 'pass' => ''); $local = TRUE; $created_time = strtotime('-10 minutes'); $device_id = 'SC Test Page'; $rid = SC_Data_Recording::to_database($survey_id, $arr_response, $db, $local, $created_time, $device_id); echo 'Response recorded: ' . $rid;
//Response has already been noted, so this must be a duplicate submission $duplicate_response = TRUE; break; } } //Store this urid $_SESSION['urids'][] = $response['h_unique_response_id']; } else { //Create urid library and store this urid for future testing $_SESSION['urids'] = array($response['h_unique_response_id']); } //Save the response if (!$duplicate_response) { //Complete response with system data $response['h_finish_time'] = isset($_SESSION['wrapper']['date']) ? $_SESSION['wrapper']['date'] : time(); $response['h_duration'] = isset($response['h_start_time']) && $response['h_start_time'] > 0 ? (string) ((int) $response['h_finish_time'] - (int) $response['h_start_time']) : ''; //Set database to local or remote if ($config['isOffline']) { $db = $dbs['local']; $local = TRUE; } else { $db = $dbs['remote']; $local = FALSE; } //Save the response to the database $response_id = SC_Data_Recording::to_database($sid, $response, $db, $local, $response['h_finish_time'], $did); } unset($_SESSION['wrapper']['date']); //Load thank you page header('Location:../?pagetype=thankyou'); exit;