Exemple #1
0
 public function group($group_id = 0)
 {
     if (!$this->check_power('question_manage')) {
         return;
     }
     $group_id = intval($group_id);
     if ($group_id) {
         $query = $this->db->get_where('relate_group', array('group_id' => $group_id));
         $group = $query->row_array();
     }
     if (empty($group)) {
         $site_url = site_url('/admin/question/index');
         header("location: {$site_url}");
         // message('关联分组不存在。','/admin/question/index');
         return;
     }
     $cpusers = CpUserModel::get_cpuser_list();
     // 加载分类数据
     $class_list = ClassModel::get_class_list();
     $subjects = CpUserModel::get_allowed_subjects();
     $grades = C('grades');
     $qtypes = C('qtype');
     $periods = C('grade_period');
     $langs = C('interview_lang');
     $types = C('interview_type');
     $list_ques = $list_interview = array();
     $query = $this->db->get_where('question', array('group_id' => $group_id, 'parent_id' => 0, 'is_delete' => 0));
     foreach ($query->result_array() as $row) {
         $row_cids = explode(',', trim($row['class_id'], ','));
         $row_cname = array();
         foreach ($row_cids as $cid) {
             $row_cname[] = isset($class_list[$cid]['class_name']) ? $class_list[$cid]['class_name'] : '';
         }
         $row['class_name'] = implode(',', $row_cname);
         $row['start_grade'] = isset($grades[$row['start_grade']]) ? $grades[$row['start_grade']] : '';
         $row['qtype'] = isset($qtypes[$row['type']]) ? $qtypes[$row['type']] : '';
         $row['end_grade'] = isset($grades[$row['end_grade']]) ? $grades[$row['end_grade']] : '';
         $row['subject_name'] = isset($subjects[$row['subject_id']]) ? $subjects[$row['subject_id']] : '';
         $row['addtime'] = date('Y-m-d H:i', $row['addtime']);
         $row['cpuser'] = isset($cpusers[$row['admin_id']]['realname']) ? $cpusers[$row['admin_id']]['realname'] : '';
         $row['has_edit_power'] = QuestionModel::check_question_power($row['ques_id'], 'w', false);
         //判断该试题已经被考试过 或 正在被考
         $row['be_tested'] = QuestionModel::question_has_test_action($row['ques_id']);
         $list_ques[] = $row;
     }
     $query2 = $this->db->get_where('interview_question', array('group_id' => $group_id, 'is_delete' => 0));
     foreach ($query2->result_array() as $row) {
         // 类型
         $row_cids = explode(',', trim($row['class_id'], ','));
         $row_cname = array();
         foreach ($row_cids as $cid) {
             $row_cname[] = isset($class_list[$cid]['class_name']) ? $class_list[$cid]['class_name'] : '';
         }
         // 年段
         $row_pids = explode(',', trim($row['grade_period'], ','));
         $row_pname = array();
         foreach ($row_pids as $pid) {
             $row_pname[] = isset($periods[$pid]) ? $periods[$pid] : '';
         }
         $row['class_name'] = implode(',', $row_cname);
         $row['period_name'] = implode(',', $row_pname);
         $row['language'] = isset($langs[$row['lang']]) ? $langs[$row['lang']] : '';
         $row['type_name'] = isset($types[$row['interview_type']]['type_name']) ? $types[$row['interview_type']]['type_name'] : '';
         $row['addtime'] = date('Y-m-d H:i', $row['addtime']);
         $row['cpuser'] = isset($cpusers[$row['admin_id']]['realname']) ? $cpusers[$row['admin_id']]['realname'] : '';
         $list_interview[] = $row;
     }
     $priv = array('delete_question' => $this->check_power('question_delete', FALSE), 'delete_interview_question' => $this->check_power('invterview_question_delete', FALSE));
     $data['group_id'] = $group_id;
     $data['list_ques'] = $list_ques;
     $data['list_interview'] = $list_interview;
     $data['priv'] = $priv;
     $data['has_edit_power'] = QuestionModel::check_question_power($group['group_name'], 'w', false);
     $data['has_interview_question_manage'] = $this->check_power('interview_question_manage', false);
     // 模版
     $this->load->view('relate_group/group', $data);
 }
 public function batch_unshenhe()
 {
     $ids = $this->input->post('ids');
     if (empty($ids) or !is_array($ids)) {
         message('请选择要取消审核的题目!');
         return;
     }
     $success = $fail = 0;
     foreach ($ids as $id) {
         $this->examine_permission($id);
         $be_tested = QuestionModel::question_has_test_action($id);
         $question = QuestionModel::get_question($id);
         if ($be_tested || !$this->has_question_check($question) || $question['is_original'] != 1 || $question['check'] != 1) {
             $fail++;
             continue;
         }
         $sql = "update {pre}question set `check`=0 where ques_id='{$id}'";
         $return = $this->db->query($sql);
         if ($return === true) {
             $liyo = 'unexamine';
             admin_log($liyo, 'question', $id);
             $success++;
         } else {
             $fail++;
         }
     }
     $back_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'admin/question_external/index';
     message('批量操作完成,成功取消审核:' . $success . ' 个,失败:' . $fail . ' 个。', $back_url);
 }
Exemple #3
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;
     }
 }