public function ACT_edit() { $prob_id = (int) $this->path_option->getPathSection(2); if ($prob_id != 0) { $rs = MDL_Problem_Show::getProblem($prob_id); $rs['action'] = 'edit'; } else { $rs = array('prob_id' => MDL_Problem_Edit::getNextProblemID(), 'prob_title' => '', 'prob_name' => '', 'prob_content' => '', 'display' => 0); $rs['action'] = 'add'; } $this->view->problem = $rs; $this->view->display('problem_edit.php'); }
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; }