public function update_correct()
 {
     $act = $this->input->post('act');
     $act = $act == 'add' ? $act : 'edit';
     if ($act == 'edit') {
         $ques_id = $this->input->post('ques_id');
         $this->examine_permission($ques_id);
         $ques_id && ($old_question = QuestionModel::get_question($ques_id));
         if (empty($old_question)) {
             message('改错题不存在');
             return;
         }
         $be_tested = QuestionModel::question_has_test_action($ques_id);
         if ($be_tested) {
             message('该试题已经被考生考过 或者 正在被考, 无法操作');
         }
     }
     // 题目基本信息
     $class_ids = $this->input->post('class_id');
     $skill_ids = $this->input->post('skill_id');
     $knowledge_ids = $this->input->post('knowledge_id');
     $difficulty = $this->input->post('difficulty');
     $subject_types = $this->input->post('subject_type');
     $question['type'] = 13;
     $question['test_way'] = array_sum($this->input->post('test_way'));
     $question['subject_id'] = intval($this->input->post('subject_id'));
     $question['start_grade'] = intval($this->input->post('start_grade'));
     $question['end_grade'] = intval($this->input->post('end_grade'));
     $question['title'] = trim($this->input->post('title'));
     $question['is_original'] = intval($this->input->post('is_original'));
     $question['exam_year'] = intval($this->input->post('exam_year'));
     $question['remark'] = trim($this->input->post('remark'));
     $question['related'] = intval($this->input->post('related'));
     $question['simulation'] = trim($this->input->post('simulation'));
     if ($question['subject_id'] == 11) {
         $question['subject_id_str'] = ',' . implode(',', $this->input->post('subject_str')) . ',';
     } else {
         $question['subject_id_str'] = ',' . $question['subject_id'] . ',';
     }
     $extends = array('difficulty' => &$difficulty, 'class_ids' => &$class_ids, 'skill_ids' => &$skill_ids, 'knowledge_ids' => &$knowledge_ids, 'subject_types' => &$subject_types, 'score_factor' => '');
     $message = $this->_check_question($question, $extends, false, false);
     if ($act == 'add') {
         $extends['group_id'] = intval($this->input->post('relate_group'));
         $extends['relate_ques_id'] = intval($this->input->post('relate_ques_id'));
         $ques_result = QuestionModel::add_group($question, $extends);
     } else {
         $question['ques_id'] = $ques_id;
         $ques_result = QuestionModel::update_group($question, $extends);
     }
     $url = site_url('/admin/question_external/edit_correct/' . $ques_result['ques_id']);
     if ($message) {
         message(implode('<br/>', $message), $url, null, 10);
         return;
     }
     if ($ques_result['success'] == TRUE) {
         message('试题编辑成功。', 'admin/question_external/correct/' . $ques_result['ques_id']);
         return;
     } else {
         message($ques_result['msg']);
         return;
     }
 }
Exemple #2
0
 public function update_combination()
 {
     if (!$this->check_power('question_manage')) {
         return;
     }
     $act = $this->input->post('act');
     $act = $act == 'add' ? $act : 'edit';
     if ($act == 'edit') {
         $ques_id = $this->input->post('ques_id');
         if (!QuestionModel::check_question_power($ques_id, 'w')) {
             return;
         }
         $ques_id && ($old_question = QuestionModel::get_question($ques_id));
         if (empty($old_question)) {
             message('题组不存在');
             return;
         }
         $be_tested = QuestionModel::question_has_test_action($ques_id);
         if ($be_tested) {
             message('该试题已经被考生考过 或者 正在被考, 无法操作');
         }
     }
     // 题目基本信息
     $class_ids = $this->input->post('class_id');
     $skill_ids = $this->input->post('skill_id');
     $knowledge_ids = $this->input->post('knowledge_id');
     $difficulty = $this->input->post('difficulty');
     $subject_types = $this->input->post('subject_type');
     $question['type'] = 15;
     $question['test_way'] = array_sum($this->input->post('test_way'));
     $question['subject_id'] = intval($this->input->post('subject_id'));
     $question['start_grade'] = intval($this->input->post('start_grade'));
     $question['end_grade'] = intval($this->input->post('end_grade'));
     $question['title'] = trim($this->input->post('title'));
     $question['is_original'] = intval($this->input->post('is_original'));
     $question['exam_year'] = intval($this->input->post('exam_year'));
     $question['remark'] = trim($this->input->post('remark'));
     $question['related'] = intval($this->input->post('related'));
     $question['simulation'] = trim($this->input->post('simulation'));
     $file_save_path = $this->input->post('file_save_path');
     if ($question['subject_id'] == 11) {
         $question['subject_id_str'] = ',' . implode(',', $this->input->post('subject_str')) . ',';
     } else {
         $question['subject_id_str'] = ',' . $question['subject_id'] . ',';
     }
     $extends = array('difficulty' => &$difficulty, 'class_ids' => &$class_ids, 'skill_ids' => &$skill_ids, 'knowledge_ids' => &$knowledge_ids, 'subject_types' => &$subject_types);
     $message = $this->_check_question($question, $extends, false, false);
     if ($message) {
         // 删除已上传试题图片
         if (!empty($question['picture'])) {
             @unlink(_UPLOAD_ROOT_PATH_ . $question['picture']);
         }
         message(implode('<br/>', $message), null, null, 10);
         return;
     }
     if ($act == 'add') {
         $extends['group_id'] = intval($this->input->post('relate_group'));
         $extends['relate_ques_id'] = intval($this->input->post('relate_ques_id'));
         $ques_result = QuestionModel::add_group($question, $extends);
     } else {
         $question['ques_id'] = $ques_id;
         $ques_result = QuestionModel::update_group($question, $extends);
     }
     //清理试题文件
     $ques_id = $ques_result['ques_id'];
     $this->clear_question_file($ques_id, $file_save_path);
     if ($ques_result['success'] == TRUE) {
         message('试题题编辑成功。', 'admin/question/combination/' . $ques_result['ques_id']);
         return;
     } else {
         message($ques_result['msg']);
         return;
     }
 }