Esempio n. 1
0
 public function submitPaper()
 {
     $allscore = ExamService::instance()->getBaseScoreByExamId($this->examId);
     $jright = AnswerModel::instance()->saveProblemAnswer($this->userInfo['user_id'], $this->examId, JudgeBaseModel::JUDGE_PROBLEM_TYPE, false);
     $inarr['judgesum'] = $jright * $allscore['judgescore'];
     StudentService::instance()->submitExamPaper($this->userInfo['user_id'], $this->examId, $inarr);
     $this->checkActionAfterSubmit();
     redirect(U('Home/Question/navigation', array('eid' => $this->examId)));
 }
Esempio n. 2
0
 public function submitPaper()
 {
     $start_timeC = strftime("%Y-%m-%d %X", strtotime($this->examBase['start_time']));
     $end_timeC = strftime("%Y-%m-%d %X", strtotime($this->examBase['end_time']));
     $allscore = ExamService::instance()->getBaseScoreByExamId($this->examId);
     $inarr['choosesum'] = $this->chooseSumScore == -1 ? 0 : $this->chooseSumScore;
     $inarr['judgesum'] = $this->judgeSumScore == -1 ? 0 : $this->judgeSumScore;
     $inarr['fillsum'] = $this->fillSumScore == -1 ? 0 : $this->fillSumScore;
     $pright = AnswerModel::instance()->getRightProgramCount($this->userInfo['user_id'], $this->examId, $start_timeC, $end_timeC);
     $inarr['programsum'] = round($pright * $allscore['programscore']);
     $inarr['score'] = $inarr['choosesum'] + $inarr['judgesum'] + $inarr['fillsum'] + $inarr['programsum'];
     StudentService::instance()->submitExamPaper($this->userInfo['user_id'], $this->examId, $inarr);
     redirect(U('Home/Index/score'));
 }
Esempio n. 3
0
 public function index()
 {
     $this->start2Exam();
     $allBaseScore = ExamService::instance()->getBaseScoreByExamId($this->examId);
     $fillarr = ExamService::instance()->getUserAnswer($this->examId, $this->userInfo['user_id'], FillBaseModel::FILL_PROBLEM_TYPE);
     $fillans = ProblemService::instance()->getProblemsAndAnswer4Exam($this->examId, FillBaseModel::FILL_PROBLEM_TYPE);
     $fillsx = ExamadminModel::instance()->getProblemSequence($this->examId, FillBaseModel::FILL_PROBLEM_TYPE, $this->randnum);
     $this->zadd('allscore', $allBaseScore);
     $this->zadd('fillarr', $fillarr);
     $this->zadd('fillsx', $fillsx);
     $this->zadd('fillans', $fillans);
     $this->zadd('questionName', FillBaseModel::FILL_PROBLEM_NAME);
     $this->zadd('problemType', FillBaseModel::FILL_PROBLEM_TYPE);
     $this->auto_display('Exam:fill', 'exlayout');
 }
Esempio n. 4
0
 public function doRejudgeJudgeByExamIdAndUserId($eid, $userId, $judgeScore)
 {
     $judgeSum = 0;
     $judgearr = ExamService::instance()->getUserAnswer($eid, $userId, JudgeBaseModel::JUDGE_PROBLEM_TYPE);
     $query = "SELECT `judge_id`,`answer` FROM `ex_judge` WHERE `judge_id` IN\n\t\t(SELECT `question_id` FROM `exp_question` WHERE `exam_id`='{$eid}' AND `type`='2')";
     $row = M()->query($query);
     if ($row) {
         foreach ($row as $key => $value) {
             if (isset($judgearr[$value['judge_id']])) {
                 $myanswer = $judgearr[$value['judge_id']];
                 if ($myanswer == $value['answer']) {
                     $judgeSum += $judgeScore;
                 }
             }
         }
     }
     return $judgeSum;
 }
Esempio n. 5
0
 public function doRejudgeChooseByExamIdAndUserId($eid, $userId, $chooseScore)
 {
     $chooseSum = 0;
     $choosearr = ExamService::instance()->getUserAnswer($eid, $userId, ChooseBaseModel::CHOOSE_PROBLEM_TYPE);
     $query = "SELECT `choose_id`,`answer` FROM `ex_choose` WHERE `choose_id` IN\n\t\t(SELECT `question_id` FROM `exp_question` WHERE `exam_id`='{$eid}' AND `type`='1')";
     $row = M()->query($query);
     if ($row) {
         foreach ($row as $key => $value) {
             if (isset($choosearr[$value['choose_id']])) {
                 $myanswer = $choosearr[$value['choose_id']];
                 if ($myanswer == $value['answer']) {
                     $chooseSum += $chooseScore;
                 }
             }
         }
     }
     return $chooseSum;
     //choose over
 }
Esempio n. 6
0
 public function exam()
 {
     if (IS_POST) {
         if (!check_post_key()) {
             $this->echoError('发生错误!');
         }
         if (!$this->isCreator()) {
             $this->echoError('You have no privilege!');
         }
         $reqResult = null;
         if (isset($_POST['examid'])) {
             $reqResult = ExamService::instance()->updateExamInfo();
         } else {
             if (isset($_POST['examname'])) {
                 $reqResult = ExamService::instance()->addExamInfo();
             }
         }
         $this->checkReqResult($reqResult);
     } else {
         if (IS_GET && I('get.eid') != '') {
             $examId = I('get.eid', 0, 'intval');
             $page = I('get.page', 1, 'intval');
             $key = set_post_key();
             $examInfo = ExamBaseModel::instance()->getExamInfoById($examId);
             if (empty($examInfo)) {
                 $this->echoError('No Such Exam!');
             }
             if (!$this->isOwner4ExamByUserId($examInfo['creator'])) {
                 $this->echoError('You have no privilege!');
             }
             $this->zadd('page', $page);
             $this->zadd('row', $examInfo);
             $this->zadd('mykey', $key);
             $this->auto_display();
         } else {
             $page = I('get.page', 1, 'intval');
             $key = set_post_key();
             $this->zadd('page', $page);
             $this->zadd('mykey', $key);
             $this->auto_display();
         }
     }
 }
Esempio n. 7
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);
     }
 }
Esempio n. 8
0
 public function doRejudgeFillByExamIdAndUserId($eid, $userId, $allscore)
 {
     $fillSum = 0;
     $fillarr = ExamService::instance()->getUserAnswer($eid, $userId, FillBaseModel::FILL_PROBLEM_TYPE);
     $query = "SELECT `fill_answer`.`fill_id`,`answer_id`,`answer`,`answernum`,`kind` FROM `fill_answer`,`ex_fill` WHERE\n\t\t`fill_answer`.`fill_id`=`ex_fill`.`fill_id` AND `fill_answer`.`fill_id` IN ( SELECT `question_id` FROM `exp_question` WHERE `exam_id`='{$eid}' AND `type`='3')";
     $row = M()->query($query);
     if ($row) {
         foreach ($row as $key => $value) {
             if (isset($fillarr[$value['fill_id']][$value['answer_id']]) && (!empty($fillarr[$value['fill_id']][$value['answer_id']]) || $fillarr[$value['fill_id']][$value['answer_id']] == "0")) {
                 $myanswer = trim($fillarr[$value['fill_id']][$value['answer_id']]);
                 $rightans = trim($value['answer']);
                 if ($myanswer == $rightans && strlen($myanswer) == strlen($rightans)) {
                     if ($value['kind'] == 1) {
                         $fillSum += $allscore['fillscore'];
                     } else {
                         if ($value['kind'] == 2) {
                             $fillSum = $fillSum + $allscore['prgans'] / $value['answernum'];
                         } else {
                             if ($value['kind'] == 3) {
                                 $fillSum = $fillSum + $allscore['prgfill'] / $value['answernum'];
                             }
                         }
                     }
                 }
             }
         }
     }
     //fillover
     return $fillSum;
 }
Esempio n. 9
0
 private function getEachProgramAvgScore($programIds, $personCnt, $sqladd)
 {
     $examId = $this->eid;
     $ans = array();
     foreach ($programIds as $_programId) {
         $programId = $_programId['question_id'];
         if ($personCnt == 0) {
             $ans[$programId] = 0;
             continue;
         }
         $allScore = ExamService::instance()->getBaseScoreByExamId($examId);
         $examBase = ExamBaseModel::instance()->getById($examId);
         $sTime = $examBase['start_time'];
         $eTime = $examBase['end_time'];
         $programScore = $allScore['programscore'];
         $sql = "select (sum(rate) * {$programScore} / {$personCnt}) as r from (" . "select user_id, if(max(pass_rate)=0.99, 1, max(pass_rate)) as rate from solution " . "where problem_id={$programId} and pass_rate > 0 and " . "in_date>='{$sTime}' and in_date<='{$eTime}' {$sqladd} group by user_id" . ") t";
         $res = M()->query($sql);
         if (empty($res)) {
             $ans[$programId] = 0;
         } else {
             $ans[$programId] = isset($res[0]['r']) ? $res[0]['r'] : 0;
         }
     }
     return $ans;
 }