/** * @return Model_Problem */ public function real_problem() { if (!$this->detail) { $this->detail = Model_Problem::find_by_id($this->problem_id); } return $this->detail; }
public function action_rejudge() { if ($this->request->is_post()) { $type = $this->get_post('type'); $id = intval($this->get_post('typeid')); if ($type == 'PROBLEM') { $problem = Model_Problem::find_by_id($id); if ($problem) { $problem->rejudge(); $this->flash_info(__('common.rejudge_:problem', array(':problem' => $problem->problem_id))); } } else { if ($type == 'SOLUTION') { $solution = Model_Solution::find_by_id($id); if ($solution) { $solution->rejudge(); $this->flash_info(__('common.rejudge_:runid', array(':runid' => $solution->solution_id))); } } } } $this->redirect('/admin/'); }
public function action_deldata() { $problem = Model_Problem::find_by_id($this->request->param('id')); $filename = $this->request->param('filename'); $ext = $this->request->param('ext'); if ($problem) { $data_path = $problem->data_dir(); $path = $data_path . '/' . $filename . '.' . $ext; if (file_exists($path) and is_file($path)) { unlink($path); } } return $this->redirect($this->request->referrer()); }
public function action_summary() { // init $problem_id = $this->request->param('id'); $problem = Model_Problem::find_by_id($problem_id); $page = $this->get_query('page', 1); $per_page = OJ::per_page; $current_user = $this->get_current_user(); if (!$problem or !$problem->can_user_access($current_user)) { throw new Exception_Page(__('common.problem_not_found')); } $this->template_data['problem_id'] = $problem_id; $this->template_data['start_rank'] = $per_page * ($page - 1); $this->template_data['summary'] = $problem->summary(); $this->template_data['total'] = ceil($this->template_data['summary']['submit_user'] / $per_page); $this->template_data['solutions'] = $problem->best_solution($page - 1, $per_page); $this->template_data['title'] = __('problem.summary.summary_of_:id', array(':id' => $problem_id)); }