Ejemplo n.º 1
0
 /**
  * @return Model_Problem
  */
 public function real_problem()
 {
     if (!$this->detail) {
         $this->detail = Model_Problem::find_by_id($this->problem_id);
     }
     return $this->detail;
 }
Ejemplo n.º 2
0
 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/');
 }
Ejemplo n.º 3
0
 public function action_list()
 {
     $page = $this->request->param('id', 1);
     $filter = array();
     $orderby = array(Model_Problem::$primary_key => Model_Base::ORDER_ASC);
     $problem_list = Model_Problem::find($filter, $page, OJ::per_page, $orderby);
     $this->template_data['pages'] = ceil(intval(Model_Problem::count($filter)) / OJ::per_page);
     $this->template_data['problem_list'] = $problem_list;
     $this->template_data['title'] = __('admin.problem.list.problem_list');
 }
Ejemplo n.º 4
0
 /**
  * @param Model_User $user
  * @param Model_Problem $problem
  * @param int $language
  * @param string $source_code
  *
  * @return Model_Solution
  */
 public static function create($user, $problem, $language, $source_code)
 {
     $solution = new Model_Solution();
     $solution->user_id = $user->user_id;
     $solution->problem_id = $problem->problem_id;
     $solution->language = $language;
     $solution->ip = Request::$client_ip;
     $solution->set_source_code($source_code);
     $problem->have_new_solution();
     $user->take_new_submit();
     return $solution;
 }
Ejemplo n.º 5
0
 public function action_search()
 {
     // init
     $text = $this->get_query('text');
     $area = $this->get_query('area');
     if ($text === NULL) {
         // TODO: add better handler
         $this->action_list();
     }
     // TODO: validation
     $list = Model_Problem::search($text, $area);
     $this->template_data['area'] = $area;
     $this->template_data['search_text'] = $text;
     $this->template_data['problemlist'] = $list;
     $this->template_data['title'] = __(':text_search_result', array(':text' => $text));
 }
Ejemplo n.º 6
0
 /**
  * problem list for volume
  *
  * @param int $volume page for volume
  *
  * @return Model_Problem[]
  */
 public static function problems_for_volume($volume)
 {
     $orderby = array(Model_Problem::$primary_key => Model_Base::ORDER_ASC);
     $filter = self::default_filter();
     return Model_Problem::find($filter, $volume, OJ::per_page, $orderby);
 }