public function index() { $this->start2Exam(); $allBaseScore = ExamService::instance()->getBaseScoreByExamId($this->examId); $judgearr = ExamService::instance()->getUserAnswer($this->examId, $this->userInfo['user_id'], JudgeBaseModel::JUDGE_PROBLEM_TYPE); $judgeans = ProblemService::instance()->getProblemsAndAnswer4Exam($this->examId, JudgeBaseModel::JUDGE_PROBLEM_TYPE); $judgesx = ExamadminModel::instance()->getProblemSequence($this->examId, JudgeBaseModel::JUDGE_PROBLEM_TYPE, $this->randnum); $this->zadd('allscore', $allBaseScore); $this->zadd('judgearr', $judgearr); $this->zadd('judgesx', $judgesx); $this->zadd('judgeans', $judgeans); $this->zadd('questionName', JudgeBaseModel::JUDGE_PROBLEM_NAME); $this->zadd('problemType', JudgeBaseModel::JUDGE_PROBLEM_TYPE); $this->auto_display('Exam:judge', 'exlayout'); }
public function index() { if (!$this->isOwner4ExamByExamId($this->eid)) { $this->echoError('You have no privilege of this exam~'); } $allscore = ExamService::instance()->getBaseScoreByExamId($this->eid); $chooseans = ProblemService::instance()->getProblemsAndAnswer4Exam($this->eid, ChooseBaseModel::CHOOSE_PROBLEM_TYPE); $judgeans = ProblemService::instance()->getProblemsAndAnswer4Exam($this->eid, JudgeBaseModel::JUDGE_PROBLEM_TYPE); $fillans = ProblemService::instance()->getProblemsAndAnswer4Exam($this->eid, FillBaseModel::FILL_PROBLEM_TYPE); $programans = ProblemService::instance()->getProblemsAndAnswer4Exam($this->eid, ProblemService::PROGRAM_PROBLEM_TYPE); $fillans2 = array(); if ($fillans) { foreach ($fillans as $key => $value) { $fillans2[$value['fill_id']] = ProblemService::instance()->getProblemsAndAnswer4Exam($value['fill_id'], ProblemService::PROBLEMANS_TYPE_FILL); } } $numofchoose = count($chooseans); $numofjudge = count($judgeans); $numoffill = 0; $numofprgans = 0; $numofprgfill = 0; $numofprogram = count($programans); $this->zadd('allscore', $allscore); $this->zadd('chooseans', $chooseans); $this->zadd('judgeans', $judgeans); $this->zadd('fillans', $fillans); $this->zadd('fillans2', $fillans2); $this->zadd('programans', $programans); $this->zadd('choosenum', $numofchoose); $this->zadd('judgenum', $numofjudge); $this->zadd('fillnum', $numoffill); $this->zadd('prgansnum', $numofprgans); $this->zadd('prgfillnum', $numofprgfill); $this->zadd('programnum', $numofprogram); $this->auto_display(); }
public function programSave() { $pid = I('post.pid', 0, 'intval'); $userId = $this->userInfo['user_id']; $start_timeC = strftime("%Y-%m-%d %X", strtotime($this->examBase['start_time'])); $end_timeC = strftime("%Y-%m-%d %X", strtotime($this->examBase['end_time'])); $where = array('problem_id' => $pid, 'user_id' => $userId, 'result' => 4, 'in_date' => array(array('gt', $start_timeC), array('lt', $end_timeC))); $row_cnt = M('solution')->field(array('result'))->where($where)->find(); if (!empty($row_cnt)) { Log::record("programSave method, trace 1, userId: {$userId} , problemId: {$pid}, programAnswer: " . json_encode($row_cnt)); $res = ProblemService::instance()->syncProgramAnswer($userId, $this->examId, $pid, 4, null); Log::record("programSave method, trace 2, userId: {$userId}, problemId: {$pid}, sync answer res: {$res}"); $this->echoError(4); } else { Log::record("programSave method, trace 1, userId: {$userId} , problemId: {$pid}, programAnswer: null"); $this->echoError(-1); } }
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); } }
public function addProgramProblem() { if (IS_POST && I('post.eid')) { if (!check_post_key()) { $this->echoError('发生错误!'); } else { if (!$this->isCreator()) { $this->echoError('You have no privilege of this exam'); } else { $eid = I('post.eid', 0, 'intval'); $flag = ProblemService::instance()->addProgram2Exam($eid); if ($flag === true) { $this->success('程序题添加成功', U('Teacher/Problem/addProgramProblem', array('eid' => $eid, 'type' => 4)), 2); } else { $this->echoError('Invaild Path'); } } } } else { $ansrow = QuestionBaseModel::instance()->getQuestionIds4ExamByType($this->eid, ProblemService::PROGRAM_PROBLEM_TYPE); $answernumC = count($ansrow); $key = set_post_key(); $widgets = array('mykey' => $key, 'ansrow' => $ansrow, 'answernumC' => $answernumC); $this->ZaddWidgets($widgets); $this->auto_display('program'); } }