public function addFillInfo() { $reqResult = new Result(); $arr = FillConvert::convertFillFromPost(); $arr['addtime'] = date('Y-m-d H:i:s'); $arr['creator'] = $_SESSION['user_id']; $fillId = FillBaseModel::instance()->insertData($arr); if ($fillId) { for ($i = 1; $i <= $arr['answernum']; $i++) { $answer = test_input($_POST["answer{$i}"]); $arr2['fill_id'] = $fillId; $arr2['answer_id'] = $i; $arr2['answer'] = $answer; M('fill_answer')->add($arr2); } $pointIds = I('post.point', array()); KeyPointService::instance()->saveExamPoint($pointIds, $fillId, FillBaseModel::FILL_PROBLEM_TYPE); $reqResult->setMessage("填空题添加成功!"); $reqResult->setData("fill"); } else { $reqResult->setStatus(false); $reqResult->setMessage("填空题添加失败!"); } return $reqResult; }
public function addChooseInfo() { $reqResult = new Result(); $arr = ChooseConvert::convertChooseFromPost(); $arr['creator'] = $_SESSION['user_id']; $arr['addtime'] = date('Y-m-d H:i:s'); $lastId = ChooseBaseModel::instance()->insertData($arr); if ($lastId) { $pointIds = I('post.point', array()); KeyPointService::instance()->saveExamPoint($pointIds, $lastId, ChooseBaseModel::CHOOSE_PROBLEM_TYPE); $reqResult->setMessage("选择题添加成功!"); $reqResult->setData("choose"); } else { $reqResult->setStatus(false); $reqResult->setMessage("选择题添加失败!"); } return $reqResult; }
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(); } } }