public function judge() { $tmp = JudgeBaseModel::instance()->getById($this->id, array('creator', 'isprivate')); if (!$this->isProblemCanDelete($tmp['isprivate'], $tmp['creator'])) { $this->echoError('You have no privilege!'); } else { JudgeBaseModel::instance()->delById($this->id); $sql = "DELETE FROM `exp_question` WHERE `question_id`={$this->id} and `type`=2"; M()->execute($sql); $sql = "DELETE FROM `ex_stuanswer` WHERE `question_id`={$this->id} and `type`=2"; M()->execute($sql); QuestionPointBaseModel::instance()->delByQuestion($this->id, 2); $this->success("判断题删除成功", U("Teacher/Index/judge", array('page' => $this->page)), 2); } }
public function addJudgeInfo() { $reqResult = new Result(); $arr = JudgeConvert::convertJudgeFromPost(); $arr['creator'] = $_SESSION['user_id']; $arr['addtime'] = date('Y-m-d H:i:s'); $lastId = JudgeBaseModel::instance()->insertData($arr); if ($lastId) { $pointIds = I('post.point', array()); KeyPointService::instance()->saveExamPoint($pointIds, $lastId, JudgeBaseModel::JUDGE_PROBLEM_TYPE); $reqResult->setMessage("判断题添加成功!"); $reqResult->setData("judge"); } else { $reqResult->setStatus(false); $reqResult->setMessage("判断题添加失败!"); } return $reqResult; }
public function getProblemsAndAnswer4Exam($eid, $problemType) { switch ($problemType) { case ChooseBaseModel::CHOOSE_PROBLEM_TYPE: return ChooseBaseModel::instance()->getChooseProblems4Exam($eid); break; case JudgeBaseModel::JUDGE_PROBLEM_TYPE: return JudgeBaseModel::instance()->getJudgeProblems4Exam($eid); break; case FillBaseModel::FILL_PROBLEM_TYPE: return FillBaseModel::instance()->getFillProblems4Exam($eid); break; case self::PROGRAM_PROBLEM_TYPE: return $this->getProgramProblems4Exam($eid); break; case self::PROBLEMANS_TYPE_FILL: return FillBaseModel::instance()->getFillAnswerByFillId($eid); break; } }
public function judge() { if (IS_POST) { if (!check_post_key()) { $this->echoError('发生错误!'); } $reqResult = null; if (isset($_POST['judgeid'])) { $reqResult = JudgeService::instance()->updateJudgeInfo(); } else { if (isset($_POST['judge_des'])) { $reqResult = JudgeService::instance()->addJudgeInfo(); } } $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 = JudgeBaseModel::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!'); } $pnt = KeyPointService::instance()->getQuestionPoints($id, JudgeBaseModel::JUDGE_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'); $problemType = I('get.problem', 0, 'intval'); $key = set_post_key(); $this->zadd('page', $page); $this->zadd('problemType', $problemType); $this->zadd('mykey', $key); $this->auto_display(); } } }