public function SAC_otherAction() { $identifier = $this->path_option->getPathSection(1); if (is_numeric($identifier)) { $prob_id = $identifier; try { $problem = new MDL_Problem($prob_id); $prob_name = $problem->getName(); } catch (MDL_Exception_Problem $e) { if ($e->testTopDesc(MDL_Exception_Problem::INVALID_PROB_ID)) { /* $identifier作爲prob_id未找到對應記錄,作爲prob_name再次査找 */ $prob_name = $identifier; } else { throw $e; } } if ($prob_name != $prob_id) { /* 重定向到$prob_name路徑頁,如果$prob_name和$prob_id不同 */ $this->locator->redirect('problem', array(), '/' . $prob_name); } } $prob_name = $identifier; /* $identifier作爲prob_name査找 */ $problem = new MDL_Problem(array('name' => $prob_name), MDL_Problem::GET_ALL); if (!$problem->getProblemMeta()->display || !$problem->getProblemMeta()->verified) { $this->deny(); } $this->view->problem = $problem; $this->view->submit_url = $this->locator->getURL('judge/submit'); $this->view->display('problem/single.php'); }
/** * * @param MDL_Problem $problem * @return MDL_Record */ public function getLastRecordWithProblem($problem) { $prob_id = $problem->getID(); if (!isset($this->last_record[$prob_id])) { $records = $this->getRecordsWithProblem($problem); if (count($records) > 0) { $record = $records[count($records) - 1]; } else { $record = NULL; } $this->last_record[$prob_id] = $record; } return $this->last_record[$prob_id]; }
public function ACT_submit() { if (!$this->acl->check('general')) { $this->deny(); } if ($this->config->getVar('judge_allowed') != 1) { $this->deny(); } $user_id = $this->acl->getUser()->getID(); $prob_id = $_POST['prob_id']; $lang = $_POST['lang']; $source = file_get_contents($_FILES['source']['tmp_name']); $problem = new MDL_Problem($prob_id); if (!$problem->getProblemMeta()->display || !$problem->getProblemMeta()->verified) { $this->deny(); } $default_display = MDL_Config::getInstance()->getVar('record_display_default'); $display = new MDL_Record_Display($default_display); $record_id = MDL_Judge_Single::submit($user_id, $prob_id, $lang, $source, $display); MDL_Judger_Process::processTaskQueue(); $this->locator->redirect('record_detail', array(), '/' . $record_id); }