Exemplo n.º 1
0
 public function fill()
 {
     if (IS_POST) {
         if (!check_post_key()) {
             $this->error('发生错误!');
         }
         if (isset($_POST['fillid'])) {
             $flag = AdminfillModel::instance()->upd_question();
             $this->checkflag($flag, 2);
         } else {
             if (isset($_POST['fill_des'])) {
                 $flag = AdminfillModel::instance()->add_question();
                 $this->checkflag($flag, 2);
             }
         }
     } else {
         if (IS_GET && I('get.id') != '') {
             dbg('yyyyyy');
             $id = I('get.id', 0, 'intval');
             $page = I('get.page', 1, 'intval');
             $problemType = I('get.problem', 0, 'intval');
             $pnt = M('ex_point')->select();
             $key = set_post_key();
             $row = M('ex_fill')->field('fill_id,question,answernum,creator,point,easycount,kind,isprivate')->where('fill_id=%d', $id)->find();
             if ($row) {
                 if ($this->checkrow($row['isprivate'], $row['creator']) == -1) {
                     $this->error('You have no privilege!');
                 }
                 if ($row['answernum'] != 0) {
                     $ansrow = M('fill_answer')->field('answer_id,answer')->where('fill_id=%d', $id)->order('answer_id')->select();
                     $this->zadd('ansrow', $ansrow);
                 }
                 $this->zadd('page', $page);
                 $this->zadd('row', $row);
                 $this->zadd('mykey', $key);
                 $this->zadd('pnt', $pnt);
                 $this->zadd('problemType', $problemType);
                 $this->auto_display();
             } else {
                 $this->error('No Such Problem!');
             }
         } else {
             dbg('xxxxxx');
             $page = I('get.page', 1, 'intval');
             $pnt = M('ex_point')->select();
             $key = set_post_key();
             $problemType = I('get.problem', 0, 'intval');
             $this->zadd('page', $page);
             $this->zadd('mykey', $key);
             $this->zadd('pnt', $pnt);
             $this->zadd('problemType', $problemType);
             $this->auto_display();
         }
     }
 }
Exemplo n.º 2
0
 public function rejudge()
 {
     if (!checkAdmin(1)) {
         $this->error('Sorry,Only admin can do');
     } else {
         $key = set_post_key();
         $this->zadd('mykey', $key);
         $this->auto_display();
     }
 }
Exemplo n.º 3
0
 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');
     }
 }
Exemplo n.º 4
0
 public function addprogram()
 {
     if (IS_POST && I('post.eid')) {
         if (!check_post_key()) {
             $this->error('发生错误!');
         } else {
             if (!checkAdmin(2)) {
                 $this->error('You have no privilege of this exam');
             } else {
                 $eid = I('post.eid', 0, 'intval');
                 $flag = AdminproblemModel::instance()->addprogram($eid);
                 if ($flag === true) {
                     $this->success('程序题添加成功', U('Teacher/Problem/addprogram', array('eid' => $eid, 'type' => 4)), 2);
                 } else {
                     $this->error('Invaild Path');
                 }
             }
         }
     } else {
         $ansrow = M('exp_question')->field('question_id')->where('exam_id=%d and type=4', $this->eid)->order('question_id')->select();
         $answernumC = M('exp_question')->where('exam_id=%d and type=4', $this->eid)->count();
         $key = set_post_key();
         $this->zadd('mykey', $key);
         $this->zadd('answernumC', $answernumC);
         $this->zadd('ansrow', $ansrow);
         $this->auto_display('program');
     }
 }
Exemplo n.º 5
0
 public function fill()
 {
     if (IS_POST) {
         if (!check_post_key()) {
             $this->echoError('发生错误!');
         }
         $reqResult = null;
         if (isset($_POST['fillid'])) {
             $reqResult = FillService::instance()->updateFillInfo();
         } else {
             if (isset($_POST['fill_des'])) {
                 $reqResult = FillService::instance()->addFillInfo();
             }
         }
         $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 = FillBaseModel::instance()->getById($id);
             if (empty($row)) {
                 $this->echoError('No Such Problem!');
             }
             if ($this->checkProblemPrivate($row['isprivate'], $row['creator']) == -1) {
                 $this->echoError('You have no privilege!');
             }
             if ($row['answernum'] != 0) {
                 $ansrow = FillBaseModel::instance()->getFillAnswerByFillId($id);
                 $this->zadd('ansrow', $ansrow);
             }
             $pnt = KeyPointService::instance()->getQuestionPoints($id, FillBaseModel::FILL_PROBLEM_TYPE);
             $this->zadd('page', $page);
             $this->zadd('row', $row);
             $this->zadd('mykey', $key);
             $this->zadd('pnt', $pnt);
             $this->zadd('problemType', $problemType);
             $this->auto_display();
         } else {
             $page = I('get.page', 1, 'intval');
             $key = set_post_key();
             $problemType = I('get.problem', 0, 'intval');
             $this->zadd('page', $page);
             $this->zadd('mykey', $key);
             $this->zadd('problemType', $problemType);
             $this->auto_display();
         }
     }
 }