#!/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);
#!/usr/bin/php <?php include '../phplib/api.php'; $ot = new otulea("../data"); if ($argc < 3) { die("usage: ./lsTasks [id] [test]" . PHP_EOL); } $ot->set_user($argv[1]); $tests = $ot->get_tests($argv[2]); $tests[$argv[2]]->print_test();
#!/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);
$type_is_student = true; break; case 2: $type_is_student = false; break; default: api::response(400, "invalid report type"); die; } if (is_null($testid)) { $testid_filter = false; } else { $testid_filter = true; $testid_orig = $testid; } $tests = $ot->get_tests($testid); if (!$tests) { api::response(500, "testindex file doesn't exist"); die; } if ($testid_filter && strcmp($testid_orig, $testid)) { api::response(404, "requested test doesn't exist"); die; } do { $it = otulea::glue_session($tests, $testid); //echo $it . " " . $testid . PHP_EOL; if (!$it) { api::response(500, "test history not found"); die; }