public static function submit($user_id, $prob_id, $lang, $source, $display) { //TODO verify problem allowence $problem = MDL_Problem_Show::getProblem($prob_id); if ($problem['verified'] != 1) { throw new MDL_Exception_Problem(MDL_Exception_Problem::UNVALIDATED_PROBLEM); } //check length $config = MDL_Config::getInstance(); $smaxlen = $config->getVar('judge_source_length_max'); if (strlen($source) > $smaxlen) { throw new MDL_Exception_Judge(MDL_Exception_Judge::INVALID_SOURCE_LENGTH); } //encode source $source = self::convertEncode($source); //create new record $record_id = MDL_Judge_Record::createRecord($user_id, $prob_id, $lang, $source, $display); return $record_id; }
public static function getTask() { //find records whose record_judger_id = 0 $db = BFL_Database::getInstance(); $stmt = $db->factory('select `record_id`,`record_prob_id` from ' . DB_TABLE_RECORD . ' where `record_judger_id` = 0 order by `record_id` asc'); $stmt->execute(); $task = $stmt->fetch(); if (!$task) { return array(); } $record_meta = new MDL_Record_Meta($task['record_id']); $task['language'] = $record_meta->getVar('lang'); $task['source'] = $record_meta->getVar('source'); $submit_time = $record_meta->getVar('submit_time'); $task['task_name'] = 'vkm_' . $task['record_id']; $prob_names = MDL_Problem_Show::getProblemName($task['record_prob_id']); $task['prob_name'] = $prob_names['prob_name']; unset($task['record_prob_id']); return $task; }
public function ACT_dodispatch() { if (isset($_POST['ajax'])) { $ajax = true; } //TODO: add non-ajax support if (!isset($_POST['prob_id']) || !isset($_POST['judger_id'])) { die('interface error'); } $prob_id = $_POST['prob_id']; $judger_id = $_POST['judger_id']; $prob_names = MDL_Problem_Show::getProblemName($prob_id); $data_config = MDL_Problem_Data::getDataConfig($prob_id, $prob_names['prob_name'], $prob_names['prob_title']); $verify_result = MDL_Problem_Dispatch::verify($data_config); if ($verify_result['overall'] != '') { die('problem not verified'); } $rs = MDL_Problem_Dispatch::transmitTestdata($judger_id, $data_config); if ($rs['version'] == $data_config['version'] && $rs['hash_code'] == $verify_result['hash_code']) { $result['overall'] = ""; if ($data_config['checker']['type'] == 'custom' && $data_config['checker']['custom']['language'] != '') { if (!isset($rs['checker_compile']) || $rs['checker_compile'] != 1) { $result['overall'] = "checker_compile"; } } } else { $result['overall'] = "verify"; } echo BFL_XML::Array2XML($result); }