Пример #1
0
 public function index()
 {
     if (isObsoleteIE()) {
         $this->error("浏览器不兼容,请选用Chrome,FireFox,Safari或IE9。<br>若您已使用IE9,请关闭兼容模式。");
     } else {
         redirect(__APP__ . '/Exam/manage');
     }
 }
Пример #2
0
 public function attend()
 {
     if (isObsoleteIE()) {
         $this->error("浏览器不兼容,请选用Chrome,FireFox,Safari或IE9。<br>若您已使用IE9,请关闭兼容模式。");
     }
     if (!isset($_GET['token'])) {
         $this->error();
     }
     // $this->clearSession();
     $token = $_GET['token'];
     $examId = $this->parseExamId($token);
     $Exam = M('Exam');
     if ($currExam = $Exam->where("exam_id = {$examId}")->field('paper_id, open_datetime, close_datetime, link')->find()) {
         $paperId = $currExam['paper_id'];
         //比对数据库中的token与链接中的token
         if ($currExam['link'] != $token) {
             $this->error();
         }
         //验证考试是否开放
         $today = date("Y-m-d H:i:s");
         $openDateTime = $currExam['open_datetime'];
         if ($today < $openDateTime) {
             $this->error("考试还未开放,请于'" . $openDateTime . "'后登录");
         } else {
             if ($today > $currExam['close_datetime']) {
                 $this->error('考试已关闭');
             }
         }
         //显示考卷的卷头信息
         $ExamPaper = M('ExamPaper');
         if ($paper = $ExamPaper->where("paper_id = {$paperId}")->field('paper_id, paper_name, total_score, total_mins, paper_desc')->find()) {
             //存储考卷问题到Session中
             $Model = M();
             if ($questions = $Model->query("select\n\t\t\t\t\t\t\t\t\t\t\t\t\tpq.question_id,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpq.question_seq,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpq.question_score,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcase when qh.question_type in ('radio', 'checkbox') then 0 else null end as examinee_score\n\t\t\t\t\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\t\t\t\t\tpaper_question pq\n\t\t\t\t\t\t\t\t\t\t\t\t\tjoin\n\t\t\t\t\t\t\t\t\t\t\t\t\tquestion_head qh\n\t\t\t\t\t\t\t\t\t\t\t\t\ton\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpq.question_id = qh.question_id\n\t\t\t\t\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t\t\t\t\tpq.paper_id = {$paperId}\n\t\t\t\t\t\t\t\t\t\t\t\torder by\n\t\t\t\t\t\t\t\t\t\t\t\t\tpq.question_seq")) {
                 // $PaperQuestion = M('PaperQuestion');
                 // if ($questions = $PaperQuestion
                 // ->where("paper_id = $paperId")
                 // ->field('question_id, question_seq, question_score')
                 // ->order('question_seq')
                 // ->select()) {
                 $_SESSION['questions'] = $questions;
                 $_SESSION['total_mins'] = $paper['total_mins'];
                 $totalCount = count($questions);
                 $_SESSION['totalCount'] = $totalCount;
                 $this->assign('totalCount', $totalCount);
                 $this->assign('paper', $paper);
                 $this->assign('examId', $examId);
                 $this->display();
             } else {
                 $this->error();
             }
         } else {
             $this->error();
         }
     } else {
         $this->error();
     }
 }