Exemplo n.º 1
0
 public function dorejudge()
 {
     if (IS_POST && I('post.eid')) {
         if (!check_post_key() || !checkAdmin(1)) {
             $this->error('发生错误!');
         }
         $eid = intval($_POST['eid']);
         if (I('post.rjall')) {
             $prirow = M('exam')->field('start_time,end_time')->where('exam_id=%d', $eid)->find();
             $start_timeC = strftime("%Y-%m-%d %X", strtotime($prirow['start_time']));
             $end_timeC = strftime("%Y-%m-%d %X", strtotime($prirow['end_time']));
             $userlist = M('ex_student')->field('user_id')->where('exam_id=%d', $eid)->select();
             if ($userlist) {
                 foreach ($userlist as $value) {
                     $this->rejudgepaper($value['user_id'], $eid, $start_timeC, $end_timeC, 1);
                 }
                 unset($userlist);
             }
             $this->success('全部重判成功!', U('Teacher/Exam/userscore', array('eid' => $eid)), 2);
         } else {
             if (I('post.rjone')) {
                 $rjuserid = test_input($_POST['rjuserid']);
                 $flag = $this->dojudgeone($eid, $rjuserid);
                 if ($flag) {
                     $this->success('重判成功!', U('Teacher/Exam/userscore', array('eid' => $eid)), 2);
                 }
             } else {
                 $this->error('Invaild Path');
             }
         }
     } else {
         $this->error('Wrong Method');
     }
 }
Exemplo n.º 2
0
 public function adduser()
 {
     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 = D('Adminexam')->addexamuser($eid);
                 if ($flag === true) {
                     $this->success('考生添加成功', U('Teacher/Exam/userscore', array('eid' => $eid)), 2);
                 } else {
                     $this->error('Invaild Path');
                 }
             }
         }
     } else {
         if (!$this->isowner($this->eid)) {
             $this->error('You have no privilege of this exam');
         } else {
             $ulist = "";
             $row = M('ex_privilege')->field('user_id')->where("rightstr='e{$this->eid}'")->order('user_id')->select();
             if ($row) {
                 $cnt = 0;
                 foreach ($row as $key => $value) {
                     if ($cnt) {
                         $ulist .= "\n";
                     }
                     $ulist .= $value['user_id'];
                     $cnt++;
                 }
                 unset($row);
             }
             $key = set_post_key();
             $this->assign('mykey', $key);
             $this->assign('ulist', $ulist);
             $this->auto_display();
         }
     }
 }
Exemplo n.º 3
0
 public function adduser()
 {
     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 = ExamService::instance()->addUsers2Exam($eid);
                 if ($flag === true) {
                     $this->success('考生添加成功', U('Teacher/Exam/userscore', array('eid' => $eid)), 2);
                 } else {
                     $this->echoError('Invaild Path');
                 }
             }
         }
     } else {
         if (!$this->isOwner4ExamByExamId($this->eid)) {
             $this->echoError('You have no privilege of this exam');
         } else {
             $ulist = "";
             $row = PrivilegeBaseModel::instance()->getUsersByExamId($this->eid, array('user_id'));
             if ($row) {
                 $cnt = 0;
                 foreach ($row as $key => $value) {
                     if ($cnt) {
                         $ulist .= "\n";
                     }
                     $ulist .= $value['user_id'];
                     $cnt++;
                 }
                 unset($row);
             }
             $key = set_post_key();
             $this->zadd('mykey', $key);
             $this->zadd('ulist', $ulist);
             $this->auto_display();
         }
     }
 }
Exemplo n.º 4
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.º 5
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.º 6
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.º 7
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();
         }
     }
 }