send quiz results to server - help please!

Hello
Complete beginner - trying to send quiz results to server using php script below from ispring solutions/quizresults from Github. (without success).
I’ve uploaded all the files/directories to my server into a directory called QuizResults. Could someone please tell me which bits of the index.php script (below) I need to modify?
Any help gratefully received.
Thanks very much
Nyree

[php]<?php
header(‘Access-Control-Allow-Origin: *’);
if ($_SERVER[‘REQUEST_METHOD’] != ‘POST’)
{
echo “POST request expected”;
return;
}
error_reporting(E_ALL && E_WARNING && E_NOTICE);
ini_set(‘display_errors’, 0);
ini_set(‘log_errors’, 1);
require_once ‘includes/common.inc.php’;
$requestParameters = RequestParametersParser::getRequestParameters($_POST, !empty($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : null);
log($requestParameters);
try
{
$quizResults = new QuizResults();
$quizResults->InitFromRequest($requestParameters);
$generator = QuizReportFactory::CreateGenerator($quizResults, $requestParameters);
$report = $generator->createReport();
$dateTime = date(‘Y-m-d_H-i-s’);
$resultFilename = dirname(FILE) . "/result/quiz_result
{$dateTime}.txt";
@file_put_contents($resultFilename, $report);
echo “OK”;
}
catch (Exception $e)
{
error_log($e);
echo "Error: " . $e->getMessage();
}
function log($requestParameters)
{
$logFilename = dirname(FILE) . ‘/log/quiz_results.log’;
$event = array(‘ts’ => date(‘Y-m-d H:i:s’), ‘request_parameters’ => $requestParameters, 'ts
’ => time());
$logMessage = json_encode($event);
$logMessage .= ‘,’ . PHP_EOL;
@file_put_contents($logFilename, $logMessage, FILE_APPEND);
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service