Example #1
0
 public function submitAllPaper()
 {
     $eid = I('get.eid', 0, 'intval');
     if (empty($eid)) {
         $this->alertError('Invaild Exam');
         return;
     }
     $sortanum = I('get.sortanum', 0, 'intval');
     $sortdnum = I('get.sortdnum', 0, 'intval');
     if (!$this->isOwner4ExamByExamId($eid)) {
         $this->echoError('You have no privilege to do it!');
     }
     $allTakeIn = PrivilegeBaseModel::instance()->getTakeInExamUsersByExamId($eid);
     $allHaveScore = M('ex_student')->distinct('user_id')->field('user_id,score')->where('exam_id=%d', $eid)->select();
     $haveScoreUserIds = array();
     $userIds2Submit = array();
     $negScoreUserId = array();
     foreach ($allHaveScore as $uid) {
         if ($uid['score'] >= 0) {
             $haveScoreUserIds[] = strtolower($uid['user_id']);
         } else {
             $negScoreUserId[strtolower($uid['user_id'])] = 1;
         }
     }
     foreach ($allTakeIn as $userId) {
         $_userId = strtolower($userId['user_id']);
         if (!in_array($_userId, $haveScoreUserIds)) {
             $userIds2Submit[] = $_userId;
         }
     }
     if (!empty($userIds2Submit)) {
         $userIds2Submit = array_unique($userIds2Submit);
         $field = array('start_time', 'end_time');
         $prirow = ExamBaseModel::instance()->getExamInfoById($eid, $field);
         $start_timeC = strftime("%Y-%m-%d %X", strtotime($prirow['start_time']));
         $end_timeC = strftime("%Y-%m-%d %X", strtotime($prirow['end_time']));
         foreach ($userIds2Submit as $_uid) {
             $mark = isset($negScoreUserId[$_uid]) ? 1 : 0;
             $this->rejudgepaper($_uid, $eid, $start_timeC, $end_timeC, $mark);
             usleep(10000);
         }
     }
     $this->redirect("Exam/userscore", array('eid' => $eid, 'sortdnum' => $sortdnum, 'sortanum' => $sortanum));
 }
Example #2
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();
         }
     }
 }
Example #3
0
 /**
  * 判断用户是否在权限列表
  * @param  string $userId 用户ID
  * @param  number $eid 比赛编号
  * @return number        是否存在
  */
 private function getPrivilege($userId, $eid)
 {
     $res = PrivilegeBaseModel::instance()->getPrivilegeByUserIdAndExamId($userId, $eid);
     return !empty($res);
 }
 protected function start2Exam()
 {
     $data = array('extrainfo' => $this->leftTime + 1);
     PrivilegeBaseModel::instance()->updatePrivilegeByUserIdAndExamId($this->userInfo['user_id'], $this->examId, $data);
 }