Ejemplo n.º 1
0
<?php

require_once "classes/TestsDB2.php";
$filename = $_REQUEST['file'];
//file_put_contents('./test2.json', $_REQUEST);
//получить данные теста
$testsDB = new TestsDB();
$testsDB::$file = '../math_test/tests/' . $filename;
$testData = $testsDB->getTestsData();
$testData = json_decode($testData, true);
$testData['tasks'] = array_values($testData['tasks']);
//helper: первая заглавная буква для utf-8 строки
function mb_ucfirst($text)
{
    return mb_strtoupper(mb_substr($text, 0, 1)) . mb_substr($text, 1);
}
//set view_number & max_points
foreach ($testData['tasks'] as $key => $task) {
    $testData['tasks'][$key]['view_number'] = $key + 1;
    $testData['tasks'][$key]['type'] = mb_ucfirst($task['type']);
    $taskPoints = 0;
    foreach ($task['answer_points'] as $answerPoints) {
        $taskPoints += $answerPoints;
    }
    $testData['tasks'][$key]['max_points'] = $taskPoints;
    //timer data timestamp to array
    if (isset($task['taskTimerData'])) {
        $testData['tasks'][$key]['taskTimerData'] = $testsDB->timestampToArray($task['taskTimerData']);
    }
}
//подключить шаблон центральный шаблон админки
Ejemplo n.º 2
0
<?php

require_once "classes/TestsDB2.php";
$testsDB = new TestsDB();
$filename = $_REQUEST['file'];
//file_put_contents('./test.json', $_REQUEST['file']);
$regexp = '#^(.*)/#U';
preg_match($regexp, $filename, $matches);
$testType = $matches[1];
//$testsDB::$file = '../math_test/tests/' . $filename;
$testsDB::$file = 'c://v6-vagrant/v6-env/repos/v6-apps/tests/frontend/tests/' . $filename;
//$testsDB::$file = '../../../../v6-vagrant/v6-env/repos/v6-apps/tests/frontend/tests/' . $filename;
$data = $testsDB->getTestsData();
//$commonDataPath = '../math_test/tests/' . $testType . '/test-data/common.json';
//$commonDataPath = '../math_test/tests/' . $filename;
$commonDataPath = 'c://v6-vagrant/v6-env/repos/v6-apps/tests/frontend/tests/' . $filename;
$testsDB::$file = $commonDataPath;
$commonData = $testsDB->getTestsData();
$commonData = json_encode($commonData);
//file_put_contents('./test3.json', $commonData);
?>

<script type="text/javascript">
    var phpTestData = <?php 
echo $data;
?>
;
    var commonData = JSON.parse(<?php 
echo $commonData;
?>
);