static function student($testarray, $otulea, $threshold, $limits) { $meta = array(); foreach ($testarray as $test) { foreach ($otulea->get_marks($test) as $mark) { $marks[] = $mark; } $meta['timestamp'] = $test->get_timestamp(); $meta['subject'] = $test->get_subject(); $meta['level'] = $test->get_level(); break; } $passed = array(); $failed = array(); $scores = otulea::average_marks($marks); foreach ($scores as $k => $v) { if ($v >= $threshold) { $passed[] = $k; } else { $failed[] = $k; } } usort($passed, "otulea::cmp_alphaid"); $passed = array_slice($passed, 0, $limits[0]); usort($failed, "otulea::cmp_alphaid"); $failed = array_slice($failed, 0, $limits[1]); return array('meta' => $meta, 'eval' => array('A1' => $passed, 'A2' => $failed)); }
#!/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);
public function merge($test) { $this->prev = $test->prev; foreach ($this->items as $item => $values) { $this->items[$item] = otulea::merge_items($this->items[$item], $test->items[$item]); } }
#!/usr/bin/php <?php include '../phplib/api.php'; $ot = new otulea("../data"); foreach ($ot->ls_users() as $id) { echo $id . PHP_EOL; }
#!/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);
echo "Test 1: length(\$a) = length(\$b) but \$a <> \$b: "; if (otulea::cmp_alphaid("1.3.2.1", "1.4.1.2") == -1) { echo "OK"; } else { echo "Failed"; } echo PHP_EOL; // TEST 2 echo "Test 2: length(\$a) = length(\$b) and \$a == \$b: "; if (!otulea::cmp_alphaid("1.3.1.2", "1.3.1.2")) { echo "OK"; } else { echo "Failed"; } echo PHP_EOL; // TEST 3 echo "Test 3: length(\$a) <> length(\$b) and \$a <> \$b: "; if (otulea::cmp_alphaid("1.4.1.1.5", "1.4.2.2") == -1) { echo "OK"; } else { echo "Failed"; } echo PHP_EOL; // TEST 4 echo "Test 4: length(\$a) <> length(\$b) but \$a == \$b: "; if (otulea::cmp_alphaid("1.3.1.2.4", "1.3.1.2") == 1) { echo "OK"; } else { echo "Failed"; } echo PHP_EOL;
#!/usr/bin/php <?php include '../phplib/config.php'; include '../phplib/api.php'; echo "Testing otulea::merge_items" . PHP_EOL; $ot = new otulea(config::DIR_DATA); $ot->set_user("SD5AM"); $timestamp = "2014_10_7_13_56_23"; $tests = $ot->get_tests($timestamp); $test = $tests[$timestamp]; $test_prev = $tests[$test->get_prev()]; // TEST 1 echo "Test 1: 'data' is empty for both items: "; $item = "2.3.03_II"; $item1 = $test->get_items()[$item]; $item2 = $test_prev->get_items()[$item]; $merged = otulea::merge_items($item1, $item2); $cond1 = strcmp($merged['timestamp'], $timestamp) === 0; $cond2 = strlen($merged['data']) === 0; if ($cond1 && $cond2) { echo "OK"; } else { echo "Failed"; } echo PHP_EOL; // TEST 2 echo "Test 2: 'data' is empty only for the first item: "; $item = '2.3.01_I'; $item1 = $test->get_items()[$item]; $item2 = $test_prev->get_items()[$item]; $merged = otulea::merge_items($item1, $item2);
#!/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();
$type = $_POST['type']; $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");