#!/usr/bin/php
<?php 
include '../phplib/config.php';
include '../phplib/api.php';
echo "Testing otulea::glue_session" . PHP_EOL;
$ot = new otulea(config::DIR_DATA);
$ot->set_user("SD5AM");
$tests = $ot->get_tests();
//otulea::print_testarray($tests);
// TEST 1
echo "Test 1: length of session is 2: ";
$timestamp = "2014_10_7_13_56_23";
otulea::glue_session($tests, $timestamp);
$cond1 = !strlen($tests[$timestamp]->get_prev());
$cond2 = !array_key_exists("2014_9_5_10_55_25", $tests);
$cond3 = is_null($tests["2014_10_7_11_47_5"]->get_key_prev());
if ($cond1 && $cond2 && $cond3) {
    echo "OK";
} else {
    echo "Failed";
}
echo PHP_EOL;
//otulea::print_testarray($tests);
echo "Test 2: length of session is 3: ";
$timestamp = "2014_10_7_11_57_1";
otulea::glue_session($tests, $timestamp);
$cond1 = !strlen($tests[$timestamp]->get_prev());
$cond2 = !array_key_exists("2014_10_7_11_53_58", $tests);
$cond3 = !array_key_exists("2014_10_7_11_47_5", $tests);
$cond4 = strcmp($tests[$timestamp]->get_key_next(), "2014_10_7_13_56_23");
$cond5 = strcmp($tests["2014_10_7_13_56_23"]->get_key_prev(), $timestamp);
#!/usr/bin/php
<?php 
include '../phplib/api.php';
$ot = new otulea("../data");
if ($argc < 2) {
    die("usage: ./getLatestMarks.php [userid] [testid]" . PHP_EOL);
}
$ot->set_user($argv[1]);
$timestamp = $argc < 3 ? "" : $argv[2];
$tests = $ot->get_tests($timestamp);
otulea::glue_session($tests, $timestamp);
$test = reset($tests);
$marks = $ot->get_marks($test);
otulea::print_markarray($marks);
Exemple #3
0
$testid = $_POST['testid'];
$save = $_POST['save'];
include '../phplib/api/main.php';
include '../phplib/api/eval.php';
include '../phplib/config/eval.php';
header('Content-type: application/xml');
if (is_null($user)) {
    api::response(400, "user id not specified");
    die;
}
if (is_null($type)) {
    api::response(400, "report type not specified");
    die;
}
$ot = new otulea(DIR_DATA);
$ot->set_user($user);
if (!$ot->is_valid_user()) {
    api::response(404, "requested user doesn't exist");
    die;
}
$type_match = array_search($type, array('1' => 'student', '2' => 'teacher'));
switch ($type_match) {
    case 1:
        $type_is_student = true;
        break;
    case 2:
        $type_is_student = false;
        break;
    default:
        api::response(400, "invalid report type");
        die;