Esempio n. 1
0
 public function choose()
 {
     if (IS_POST) {
         if (!check_post_key()) {
             $this->echoError('发生错误!');
         }
         $reqResult = null;
         if (isset($_POST['chooseid'])) {
             $reqResult = ChooseService::instance()->updateChooseInfo();
         } else {
             if (isset($_POST['choose_des'])) {
                 $reqResult = ChooseService::instance()->addChooseInfo();
             }
         }
         $this->checkReqResult($reqResult);
     } else {
         if (IS_GET && I('get.id') != '') {
             $id = I('get.id', 0, 'intval');
             $page = I('get.page', 1, 'intval');
             $problemType = I('get.problem', 0, 'intval');
             $key = set_post_key();
             $row = ChooseBaseModel::instance()->getById($id);
             if (empty($row)) {
                 $this->error('No Such Problem!');
             }
             if ($this->checkProblemPrivate($row['isprivate'], $row['creator']) == -1) {
                 $this->echoError('You have no privilege!');
             }
             $pnt = KeyPointService::instance()->getQuestionPoints($id, ChooseBaseModel::CHOOSE_PROBLEM_TYPE);
             $this->zadd('page', $page);
             $this->zadd('row', $row);
             $this->zadd('mykey', $key);
             $this->zadd('problemType', $problemType);
             $this->zadd('pnt', $pnt);
             $this->auto_display();
         } else {
             $page = I('get.page', 1, 'intval');
             $problemType = I('get.problem', 0, 'intval');
             $key = set_post_key();
             $this->zadd('page', $page);
             $this->zadd('mykey', $key);
             $this->zadd('problemType', $problemType);
             $this->auto_display();
         }
     }
 }
Esempio n. 2
0
 private function rejudgepaper($userId, $eid, $start_timeC, $end_timeC, $mark)
 {
     $allscore = ExamService::instance()->getBaseScoreByExamId($eid);
     $choosesum = ChooseService::instance()->doRejudgeChooseByExamIdAndUserId($eid, $userId, $allscore['choosescore']);
     $judgesum = JudgeService::instance()->doRejudgeJudgeByExamIdAndUserId($eid, $userId, $allscore['judgescore']);
     $fillsum = FillService::instance()->doRejudgeFillByExamIdAndUserId($eid, $userId, $allscore);
     $programsum = ProblemService::instance()->doRejudgeProgramByExamIdAndUserId($eid, $userId, $allscore['programscore'], $start_timeC, $end_timeC);
     $sum = $choosesum + $judgesum + $fillsum + $programsum;
     if ($mark == 0) {
         // if the student has not submitted the paper
         $sql = "INSERT INTO `ex_student` VALUES('" . $userId . "','{$eid}','{$sum}','{$choosesum}','{$judgesum}','{$fillsum}','{$programsum}')";
         M()->execute($sql);
     } else {
         $sql = "UPDATE `ex_student` SET `score`='{$sum}',`choosesum`='{$choosesum}',`judgesum`='{$judgesum}',`fillsum`='{$fillsum}',`programsum`='{$programsum}'\n\t\t\tWHERE `user_id`='" . $userId . "' AND `exam_id`='{$eid}'";
         M()->execute($sql);
     }
 }