示例#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']);
    }
}
//подключить шаблон центральный шаблон админки
示例#2
0
<?php

require_once "../classes/TestsDB2.php";
$testsDB = new TestsDB();
$tasksQuantity = $_REQUEST['tasksQuantity'];
$fileNamePattern = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['dir'] . 'test-data/' . $_REQUEST['testTypeDir'] . '/' . $_REQUEST['fileName'];
$fileNamedata = ['dir' => $_REQUEST['dir'], 'testTypeDir' => $_REQUEST['testTypeDir'], 'fileName' => $_REQUEST['fileName']];
$data = $testsDB->getRandomTasks($tasksQuantity, $fileNamedata);
file_put_contents('./test.json', json_encode($data));
echo json_encode($data);
示例#3
0
        //    file_put_contents('./test.json', 'else if ' . $file);
    } else {
        //    $file = /*'../../math_test/tests/' .*/ $file . '.json';
        $file = json_decode($_REQUEST['model'], true);
        $file = $file['file'];
        //    file_put_contents('./test.json', 'else ' /*. $_REQUEST*/);
    }
}
//file_put_contents('./test.json', $file);
//$file = '../../math_test/test-data/math1.json';
//file_put_contents('./test.json', $file);
$shortFile = '../../math_test/test-data/math1-short.json';
if (!file_exists($file)) {
    exit("file doesn't exists");
}
$testsDB = new TestsDB();
$testsDB::$file = $file;
$testsDB::$shortFile = $shortFile;
$uri = $_SERVER['REQUEST_URI'];
switch ($method) {
    case 'GET':
        $data = $testsDB->getTestsData();
        //        $data = json_encode($data);
        //        file_put_contents('./test.json', $data);
        echo $data;
        break;
    case 'POST':
        if (isset($model['answers']) || isset($model['task_content'])) {
            $testsDB->setTask($model);
            $testsDB->resetOrderValues();
            //            $testsDB->createShortVersion();
示例#4
0
<?php

require_once "classes/TestsDB2.php";
$testsDB = new TestsDB();
//$testsDB::$file = 'test-data/ege/math1.json';
$testData = $testsDB->getTestsData();
$testData = json_decode($testData, true);
$testData['tasks'] = array_values($testData['tasks']);
//set view_number & max_points
foreach ($testData['tasks'] as $key => $task) {
    $testData['tasks'][$key]['view_number'] = $key + 1;
    $taskPoints = 0;
    foreach ($task['answer_points'] as $answerPoints) {
        $taskPoints += $answerPoints;
    }
    $testData['tasks'][$key]['max_points'] = $taskPoints;
}
//подключить шаблон сайдбара
require_once 'views/testSidebar.php';
示例#5
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;
?>
);