public function edit($id = 0) { if (!$this->check_power('skill_manage')) { return; } $id = intval($id); $id && ($row = SkillModel::get_skill($id)); if (empty($row)) { message('技能不存在'); return; } if (!QuestionModel::check_subject_power($row['subject_id'], 'w')) { return; } $data['row'] = $row; $data['subjects'] = CpUserModel::get_allowed_subjects(); // 模版 $this->load->view('skill/edit', $data); }
public function index($type_id = 0) { if (!$this->check_power('comparison_list,comparison_manage')) { return; } if ($type_id = intval($type_id)) { $type_detail = ComparisonTypeModel::get_comparison_type_by_id($type_id); } if (empty($type_detail)) { message('对比信息分类不存在!', site_url('admin/comparison_type/index')); } $size = C('admin_page_size'); $page = isset($_GET['page']) && intval($_GET['page']) > 1 ? intval($_GET['page']) : 1; $order_by = 'cmp_info_year DESC'; $select_what = 'cmp_info_id,cmp_info_year,cmp_info_score,updatetime,addtime'; // 查询条件 $condition = $param = $search = array(); $condition['cmp_type_id'] = $type_id; // 获取数据 $total = ComparisonInfoModel::get_comparison_info_count($condition); $list = array(); if ($total) { $list = ComparisonInfoModel::get_comparison_info_list($condition, $page, $size, $order_by, $select_what); } $data['type_detail'] =& $type_detail; $data['list'] =& $list; $data['search'] =& $search; // 分页 $purl = site_url('admin/comparison_info/index/' . $type_id) . ($param ? '?' . implode('&', $param) : ''); $data['pagination'] = multipage($total, $size, $page, $purl); // 学科、类型 $data['subjects'] = CpUserModel::get_allowed_subjects(); $data['class_list'] = ClassModel::get_class_list(); $data['priv_manage'] = $this->check_power('comparison_manage', FALSE); // 模版 $this->load->view('comparison_info/index', $data); }
/** * 听力题-编辑 * * @return void */ public function edit_correct($id = 0) { $id = intval($id); $this->examine_permission($id); $id && ($question = QuestionModel::get_question($id)); if ($question['related'] == 0) { $question['related'] = ''; } if ($question['exam_year'] == 0) { $question['exam_year'] = ''; } if (empty($question)) { message('试题不存在'); return; } //判断该试题已经被考试过 或 正在被考 $be_tested = QuestionModel::question_has_test_action($id); if ($be_tested) { message('该试题已经被考生考过 或者 正在被考, 无法操作'); } // 试题类型 $relate_class = array(); $query = $this->db->get_where('relate_class', array('ques_id' => $id)); foreach ($query->result_array() as $row) { $relate_class[$row['grade_id']][$row['class_id']] = $row; } $data['relate_class'] = $relate_class; $data['act'] = 'edit'; $data['question'] = $question; $data['grades'] = C('grades'); $data['subjects'] = CpUserModel::get_allowed_subjects(); $data['all_subjects'] = C('subject'); $data['subject_types'] = C('subject_type'); $data['all_grade_class'] = ClassModel::all_grade_class(); // 模版 $this->load->view('question_external/edit_correct', $data); }
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); }
/** * 知识点同步 * @param int $pid = 0 父知识点ID * @param int $_GET['subject_id'] 学科ID * @param string $_GET['subject_name'] 学科名称 */ public function synclist() { header('Content-Type:text/javascript;charset=UTF-8'); $data = array(); while (true) { $subject_id = intval($this->input->get('subject_id')); $subject_name = trim($this->input->get('subject_name')); $subject_list = C('subject'); if (!$subject_id && $subject_name != '') { $subject_id = array_search($subject_name, $subject_list); } if (!isset($subject_list[$subject_id])) { $data['error'] = '错误的学科参数'; break; } $subject_name = $subject_list[$subject_id]; $subjects = CpUserModel::get_allowed_subjects(); if (!isset($subjects[$subject_id])) { $data['error'] = '您没有指定学科权限'; break; } $data['subject_id'] = $subject_id; $data['subject_name'] = $subject_name; $sql = <<<EOT SELECT id AS k_id, knowledge_name AS k_name, pid AS k_pid FROM rd_knowledge WHERE subject_id = {$subject_id} ORDER BY pid EOT; $data['ktree_list'] = Fn::db()->fetchAll($sql); break; } echo 'var zmte_ktree = '; echo json_encode($data); exit; }
/** * @description 修改组题规则 * * @param int $id 规则id * @return void */ public function edit($id = 0) { if ($id = intval($id)) { $query = $this->db->get_where('exam_rule', array('rule_id' => $id)); $rule = $query->row_array(); $rule['is_original'] = explode(',', $rule['is_original']); } if (empty($rule)) { message('规则不存在'); return; } $rule['ques_num'] = explode(',', $rule['ques_num']); /** 组题规则限制 */ $rule_limits = $this->db->get_where('exam_rule_qtype_limit', array('exam_rule_id' => $id))->result_array(); $rule_limit = array(); if ($rule_limits) { foreach ($rule_limits as $key => $item) { $rule_limit[$item['qtype']][] = $item; } } /* * 读取知识点名称,以及相应试题数量 */ $knowledge_list = array(); $knowledge_parents = array(); $knowledge_ids = explode(',', $rule['knowledge_ids']); foreach ($knowledge_ids as $kid) { $knowledge = KnowledgeModel::get_konwledge_ques_num($kid); $knowledge_list[$kid] = $knowledge; if ($knowledge['pid'] && !isset($knowledge_parents[$knowledge['pid']])) { $knowledge_parents[$knowledge['pid']] = KnowledgeModel::get_konwledge_ques_num($knowledge['pid']); } } if ($rule['subject_id'] == 11) { $sql = "SELECT distinct(subject_id) FROM {pre}knowledge WHERE id IN ({$rule['knowledge_ids']})"; foreach ($this->db->query($sql)->result_array() as $item) { $data['subject_ids'][] = $item['subject_id']; } } /* * 重点知识点 */ $sub_rules = array(); $query = $this->db->get_where('exam_rule_knowledge', array('rule_id' => $id)); foreach ($query->result_array() as $row) { $row['pid'] = isset($knowledge_list[$row['knowledge_id']]['pid']) ? $knowledge_list[$row['knowledge_id']]['pid'] : 0; $row['nums'] = explode(',', $row['setting']); $sub_rules[] = $row; } usort($knowledge_list, 'cmp_knowledge'); foreach ($knowledge_list as $val) { $knowledge_parents[$val['pid']]['next'][] = $val; } usort($knowledge_parents, 'cmp_knowledge'); unset($knowledge_list); // 加载分类数据 $class_list = ClassModel::get_class_list(); $grades = C('grades'); $subjects = CpUserModel::get_allowed_subjects(); $data['act'] = 'edit'; $data['rule'] = $rule; $data['rule_limit'] = $rule_limit; $data['sub_rules'] = $sub_rules; $data['subjects'] = CpUserModel::get_allowed_subjects(); $data['all_subjects'] = C('subject'); $data['grades'] = C('grades'); $data['subject_types'] = C('subject_type'); $data['class_list'] = $class_list; $data['knowledge_list'] = $knowledge_parents; $data['know_process'] = C('know_process'); $data['q_tags'] = C('q_tags'); // 模版 $this->load->view('exam_rule/edit', $data); }
/** * 试题列表 * * @return void */ public function index() { // 加载分类数据 $class_list = ClassModel::get_class_list(); //限制只能查看所属学科 $subjects = CpUserModel::get_allowed_subjects(); $grades = C('grades'); $qtypes = C('qtype'); $knowledge_list = KnowledgeModel::get_knowledge_list(); // 查询条件 $where = array(); $param = array(); $search = array(); $where[] = "q.parent_id=0"; // 过滤题组子题目,在题组页面管 $where[] = "q.is_delete <> 1"; /* 真题不需要审核 */ $where[] = "q.is_original <> 2"; // 录入人员 if ($search['admin_id'] = intval($this->input->get('admin_id'))) { $where[] = "q.admin_id={$search['admin_id']}"; $param[] = "admin_id={$search['admin_id']}"; } //限制只能查看自己创建的试题 if (!$this->is_super_user() && !CpUserModel::is_action_type_all('question', 'r') && !CpUserModel::is_action_type_subject('question', 'r') && CpUserModel::is_action_type_self('question', 'r')) { $c_uid = $this->session->userdata('admin_id'); $search['admin_id'] = $c_uid; $param[] = "admin_id={$c_uid}"; $where[] = "q.admin_id='{$c_uid}'"; } // 操作时间 $begin_time = $this->input->get('begin_time'); $end_time = $this->input->get('end_time'); if ($btime = (int) strtotime($begin_time)) { $search['begin_time'] = $begin_time; $where[] = "q.addtime >= {$btime}"; $param[] = "begin_time={$begin_time}"; } else { $search['begin_time'] = ''; } if ($etime = (int) strtotime($end_time)) { $etime += 86400; $search['end_time'] = $end_time; $where[] = "q.addtime < {$etime}"; $param[] = "end_time={$end_time}"; } else { $search['end_time'] = ''; } // 分组 if ($search['group_id'] = intval($this->input->get('group_id'))) { $where[] = "q.group_id={$search['group_id']}"; $param[] = "group_id={$search['group_id']}"; } // 题型 $search['type'] = $this->input->get('qtype'); if (strlen($search['type']) > 0) { $search['type'] = intval($search['type']); $where[] = "q.type={$search['type']}"; $param[] = "qtype={$search['type']}"; } // 考试方式 $search['test_way'] = $this->input->get('test_way'); if (strlen($search['test_way']) > 0) { $search['test_way'] = intval($search['test_way']); $where[] = "q.test_way IN ({$search['test_way']}, 3)"; $param[] = "test_way={$search['test_way']}"; } // 审核 $search['check'] = $this->input->get('check'); if (strlen($search['check']) > 0) { $search['check'] = intval($search['check']); $where[] = "q.check={$search['check']}"; $param[] = "check={$search['check']}"; } if ($search['subject_id'] = intval($this->input->get('subject_id'))) { $where[] = "q.subject_id={$search['subject_id']}"; $param[] = "subject_id={$search['subject_id']}"; $knowledge_parents = KnowledgeModel::get_knowledge_list($search['subject_id'], 0); } //信息提取方式 if ($search['group_type_id'] = intval($this->input->get('group_type_id'))) { $where[] = "q.group_type LIKE '%," . $search['group_type_id'] . ",%'"; $param[] = "group_type_id=" . $search['group_type_id']; } if ($search['group_type_pid'] = intval($this->input->get('group_type_pid'))) { $param[] = "group_type_pid=" . $search['group_type_pid']; if (isset($group_type_list[$search['group_type_pid']]['childlist']) && !$search['group_type_id']) { $group_type = $group_type_list[$search['group_type_pid']]['childlist']; $tmp_str = ''; foreach ($group_type as $item) { if ($tmp_str) { $tmp_str .= " OR q.group_type LIKE '%," . $item['id'] . ",%'"; } else { $tmp_str .= "q.group_type LIKE '%," . $item['id'] . ",%'"; } } $where[] = "(" . $tmp_str . ")"; } } // 题目类型 $search['is_original'] = $this->input->get('is_original'); $search['exam_year'] = $this->input->get('exam_year'); $search['remark'] = $this->input->get('remark'); if ($search['is_original'] > 0) { $search['is_original'] = intval($search['is_original']); $where[] = "q.is_original={$search['is_original']}"; $param[] = "is_original={$search['is_original']}"; //真题年份 if ($search['is_original'] == 2 && strlen($search['exam_year']) > 0) { $search['exam_year'] = intval($search['exam_year']); $where[] = "q.exam_year='{$search['exam_year']}'"; $param[] = "exam_year={$search['exam_year']}"; } // 真题备注关键词 if ($search['is_original'] == 2 && strlen($search['remark']) > 0) { $search['remark'] = $search['remark']; $where[] = "q.remark like '%" . $search['remark'] . "%'"; $param[] = "remark={$search['remark']}"; } } //标签 if ($search['tags'] = $this->input->get('tags')) { $tmp_item = explode('-', $search['tags']); if (strlen($search['type']) > 0) { $where[] = "q.tags = " . $tmp_item[1]; $param[] = "tags=" . $search['tags']; } else { $where[] = "q.type = " . $tmp_item[0] . " AND q.tags = " . $tmp_item[1]; $param[] = "tags=" . $search['tags']; } } //限制只能查看所属学科 if (!$this->is_super_user() && !$this->is_all_subject_user() && !CpUserModel::is_action_type_all('question', 'r') && CpUserModel::is_action_type_subject('question', 'r')) { $c_subject_id = rtrim($this->session->userdata('subject_id'), ','); if ($c_subject_id != '') { $c_subject_id = explode(',', $c_subject_id); $c_subject_id = array_values(array_filter($c_subject_id)); $c_subject_id = implode(',', $c_subject_id); $where[] = "q.subject_id in({$c_subject_id})"; } } //限制只能查看所属年级 if (!$this->is_super_user() && !$this->is_all_grade_user()) { $c_grade_id = rtrim($this->session->userdata('grade_id'), ','); if ($c_grade_id != '') { $c_grade_id = explode(',', $c_grade_id); $c_grade_id = array_values(array_filter($c_grade_id)); $c_grade_id = implode(',', $c_grade_id); $where_3 = " grade_id in({$c_grade_id})"; } else { $where_3 = '1=1'; } } else { $where_3 = '1=1'; } //限制只能查看所属类型 if (!$this->is_super_user() && !$this->is_all_q_type_user()) { $c_q_type_id = rtrim($this->session->userdata('q_type_id'), ','); if ($c_q_type_id != '') { $c_q_type_id = explode(',', $c_q_type_id); $c_q_type_id = array_values(array_filter($c_q_type_id)); $c_q_type_id = implode(',', $c_q_type_id); $where_4 = "class_id in ({$c_q_type_id})"; } else { $where_4 = '1=1'; } } else { $where_4 = '1=1'; } if ($where_3 != '1=1' || $where_4 != '1=1') { $where[] = "q.ques_id IN (SELECT DISTINCT ques_id FROM rd_relate_class WHERE {$where_3} AND {$where_4}) "; } if ($search['subject_id_str'] = $this->input->get('subject_str')) { $param[] = implode('&subject_str[]=', $search['subject_id_str']); $search['subject_id_str'] = implode(',', $search['subject_id_str']); $where[] = "q.subject_id_str = '," . $search['subject_id_str'] . ",'"; } //-----------------------------------------// // 年级区间、试题类型、难易度区间、文理科 //-----------------------------------------// $search['start_grade'] = intval($this->input->get('start_grade')); $search['end_grade'] = intval($this->input->get('end_grade')); $search['class_id'] = $this->input->get('class_id'); $search['start_difficulty'] = floatval($this->input->get('start_difficulty')); $search['end_difficulty'] = floatval($this->input->get('end_difficulty')); $search['subject_type'] = trim($this->input->get('subject_type')); if (is_array($search['class_id'])) { $search['class_id'] = my_intval($search['class_id']); } else { $search['class_id'] = array(); } if ($search['class_id'] or $search['start_difficulty'] or $search['end_difficulty'] or is_numeric($search['subject_type'])) { $class_where = array(); if ($search['end_grade']) { $class_where[] = "grade_id BETWEEN {$search['start_grade']} AND {$search['end_grade']}"; } elseif ($search['start_grade']) { $class_where[] = "grade_id >= {$search['start_grade']}"; } if ($search['class_id']) { if (count($search['class_id']) == 1) { $class_where[] = "class_id='" . $search['class_id'][0] . "'"; } else { $class_where[] = "class_id IN (" . my_implode($search['class_id']) . ")"; } } //文理科 if (is_numeric($search['subject_type'])) { $class_where[] = "subject_type='" . $search['subject_type'] . "'"; } if ($search['end_difficulty']) { $class_where[] = "difficulty BETWEEN {$search['start_difficulty']} AND {$search['end_difficulty']}"; } elseif ($search['start_difficulty']) { $class_where[] = "difficulty >= {$search['start_difficulty']}"; } if ($class_where) { $where[] = "q.ques_id IN (SELECT DISTINCT ques_id FROM {pre}relate_class WHERE " . implode(' AND ', $class_where) . ")"; } } elseif ($search['start_grade'] && $search['end_grade']) { if ($search['start_grade'] <= $search['end_grade']) { $where[] = "q.start_grade <= {$search['end_grade']} AND q.end_grade>= {$search['start_grade']}"; } } elseif ($search['start_grade']) { $where[] = "q.start_grade <= {$search['start_grade']} AND q.end_grade>= {$search['start_grade']}"; } elseif ($search['end_grade']) { $where[] = "q.start_grade <= {$search['end_grade']} AND q.end_grade>= {$search['end_grade']}"; } // url参数 if ($search['start_grade']) { $param[] = "start_grade=" . $search['start_grade']; } else { $search['start_grade'] = ''; } if ($search['end_grade']) { $param[] = "end_grade=" . $search['end_grade']; } else { $search['end_grade'] = ''; } if ($search['class_id']) { $param[] = "class_id[]=" . implode('&class_id[]=', $search['class_id']); } if (is_numeric($search['subject_type'])) { $param[] = "subject_type=" . $search['subject_type']; } if ($search['start_difficulty']) { $param[] = "start_difficulty=" . $search['start_difficulty']; } else { $search['start_difficulty'] = ''; } if ($search['end_difficulty']) { $param[] = "end_difficulty=" . $search['end_difficulty']; } else { $search['end_difficulty'] = ''; } // 试题技能 $search['skill_id'] = $this->input->get('skill_id'); if ($search['skill_id'] && is_array($search['skill_id'])) { foreach ($search['skill_id'] as $sid) { $sid = intval($sid); $where[] = "q.skill LIKE '%,{$sid},%'"; $param[] = "skill_id[]={$sid}"; } } else { $search['skill_id'] = array(); } // 试题方法策略 $method_tactic_ids = trim($this->input->get('method_tactic_ids')); $method_tactic_arr = my_intval(explode(',', $method_tactic_ids)); $search['method_tactic_ids'] = implode(',', $method_tactic_arr); if ($search['method_tactic_ids']) { $param[] = "method_tactic_ids=" . $search['method_tactic_ids']; $where[] = "exists(select ques_id from {pre}relate_method_tactic rmt WHERE q.ques_id=rmt.ques_id AND rmt.method_tactic_id IN ({$search['method_tactic_ids']}) and rmt.is_child=0)"; } // 试题知识点 $knowledge_ids = trim($this->input->get('knowledge_ids')); $knowledge_arr = my_intval(explode(',', $knowledge_ids)); $search['knowledge_ids'] = implode(',', $knowledge_arr); $know_processes = $this->input->get('know_process'); $search['know_process'] = my_intval($know_processes); if ($search['knowledge_ids']) { $param[] = "knowledge_ids=" . $search['knowledge_ids']; if ($search['know_process']) { $tmp_know_process = implode(',', $search['know_process']); $param[] = "know_process[]=" . implode('&know_process[]=', $search['know_process']); $where[] = "exists(select ques_id from {pre}relate_knowledge rk WHERE q.ques_id=rk.ques_id AND rk.knowledge_id IN ({$search['knowledge_ids']}) AND rk.know_process IN ({$tmp_know_process}) AND rk.is_child=0)"; } else { $where[] = "exists(select ques_id from {pre}relate_knowledge rk WHERE q.ques_id=rk.ques_id AND rk.knowledge_id IN ({$search['knowledge_ids']}) AND rk.is_child=0)"; } } else { if ($search['know_process']) { $tmp_know_process = implode(',', $search['know_process']); $param[] = "know_process[]=" . implode('&know_process[]=', $search['know_process']); $where[] = "exists(select ques_id from {pre}relate_knowledge rk WHERE q.ques_id=rk.ques_id AND rk.know_process IN ({$tmp_know_process}) AND rk.is_child=0)"; } } if ($search['keyword'] = trim($this->input->get('keyword'))) { $escape_keyword = $this->db->escape_like_str($search['keyword']); $where[] = "q.title LIKE '%" . $escape_keyword . "%'"; $param[] = "keyword=" . urlencode($search['keyword']); } if ($ques_id = intval($this->input->get('ques_id'))) { $search['ques_id'] = $ques_id; $where[] = "q.ques_id={$ques_id}"; $param[] = "ques_id={$ques_id}"; } $where = $where ? ' WHERE ' . implode(' AND ', $where) : ' 1 '; // 统计数量 $nums = QuestionModel::get_question_nums($where); $total = $nums['total']; // 读取数据 $size = 15; $page = isset($_GET['page']) && intval($_GET['page']) > 1 ? intval($_GET['page']) : 1; $offset = ($page - 1) * $size; $list = array(); if ($total) { $sql = "SELECT q.*,a.admin_user,a.realname FROM {pre}question q\n LEFT JOIN {pre}admin a ON a.admin_id=q.admin_id\n {$where} ORDER BY q.ques_id DESC LIMIT {$offset},{$size}"; $res = $this->db->query($sql); foreach ($res->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'] : ''; } if ($row['exam_year'] == 0) { $row['exam_year'] = ''; } if ($row['related'] == 0) { $row['related'] = ''; } $row['class_name'] = implode(',', $row_cname); $row['qtype'] = isset($qtypes[$row['type']]) ? $qtypes[$row['type']] : ''; $row['start_grade'] = isset($grades[$row['start_grade']]) ? $grades[$row['start_grade']] : ''; $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['be_tested'] = QuestionModel::question_has_test_action($row['ques_id']); //判断试题已经被考过 $row['be_tested_1'] = QuestionModel::question_has_be_tested($row['ques_id']); /* * 检查是否有关联信息 * 非题组:关联技能 * 题组:题干关联技能、知识点,子题必须要全部添加知识点 */ $no_relate_info = false; $q_type = $row['type']; if ($q_type > 0) { //非题组 $no_relate_info = $row['skill'] == ''; } else { //题组 //判断是否所有子题都已添加知识点 $tmp_ques_id = $row['ques_id']; $child_questions = $this->db->query("select count(*) as `count` from {pre}question where parent_id={$tmp_ques_id}")->row_array(); $count_child = $child_questions['count']; $child_count_result = $this->db->query("select count(*) as `count` from {pre}question where parent_id={$tmp_ques_id} and knowledge != ''")->row_array(); $tmp_count = $child_count_result['count']; if ($count_child == $tmp_count && $row['skill'] == '' && $row['knowledge'] == '') { $no_relate_info = true; } } $row['no_relate_info'] = $no_relate_info; $row['has_edit_power'] = QuestionModel::check_question_power($row['ques_id'], 'w', false); $row['recycle'] = array(); $list[] = $row; } } $data['list'] =& $list; // 分页 $purl = site_url('admin/question_audit/index/' . $mode) . ($param ? '?' . implode('&', $param) : ''); $data['pagination'] = multipage($total, $size, $page, $purl, '', $nums['relate_num']); if ($search['group_id'] && $list) { $row = array_pop($list); $data['relate_ques_id'] = $row['ques_id']; } $data['mode'] = $mode; $data['search'] = $search; $data['grades'] = $grades; $data['subjects'] = $subjects; $data['qtypes'] = $qtypes; $data['q_tags'] = C('q_tags'); $data['class_list'] = $class_list; $data['all_grade_class'] = ClassModel::all_grade_class(); $data['relate_class'] = array(); $data['knowledge_list'] = $knowledge_list; $data['priv_delete'] = $this->check_power('question_delete', FALSE); $data['priv_trash'] = $this->check_power('question_trash', FALSE); $data['priv_manage'] = $this->check_power('question_manage', FALSE); if (!$this->is_super_user() && !$this->is_all_subject_user() && CpUserModel::is_action_type_all('question', 'r')) { $query = $this->db->select('admin_id,admin_user,realname')->get_where('admin', array('is_delete' => 0)); } else { if (!$this->is_super_user() && !$this->is_all_subject_user() && CpUserModel::is_action_type_subject('question', 'r')) { $c_subject_id = $this->session->userdata('subject_id'); $c_subject_id = explode(',', $c_subject_id); $c_subject_id = array_values(array_filter($c_subject_id)); $where_11 = array(); foreach ($c_subject_id as $val) { $where_11[] = "find_in_set({$val},b.subject_id)"; } $where_12 = implode(' or ', $where_11); $sql = "SELECT admin_id,admin_user,realname FROM {pre}admin\n WHERE admin_id in(select admin_id from {pre}admin_role a,{pre}role b\n WHERE a.role_id=b.role_id and ({$where_12})) and is_delete=0 "; $query = $this->db->query($sql); /* $query = $this->db->select('admin_id,admin_user,realname')->where('subject_id', $c_subject_id)->get_where('admin', array('is_delete'=>0)); */ } else { if (!$this->is_super_user() && !$this->is_all_subject_user() && CpUserModel::is_action_type_self('question', 'r')) { $c_uid = $this->session->userdata('admin_id'); $query = $this->db->select('admin_id,admin_user,realname')->where('admin_id', $c_uid)->get_where('admin'); } else { $query = $this->db->select('admin_id,admin_user,realname')->get_where('admin', array('is_delete' => 0)); } } } $data['admin_list'] = $query->result_array(); //文理科 $data['subject_types'] = C('subject_type'); $data['all_subjects'] = C('subject'); //认知过程 $data['know_processes'] = C('know_process'); if ($this->is_super_user() || $this->is_all_subject_user() || $this->is_subject_user(3) || CpUserModel::is_action_type_all('question', 'w')) { $data['is_english_admin'] = true; } // 模版 $this->load->view('question_audit/index', $data); }
public function edit($id = 0) { if (!$this->check_power('comparison_manage')) { return; } $id = intval($id); $id && ($detail = ComparisonTypeModel::get_comparison_type_by_id($id)); if (empty($detail)) { message('分类不存在'); } $data['act'] = 'edit'; $data['detail'] =& $detail; // 学科、类型 $data['grades'] = C('grades'); $data['subjects'] = CpUserModel::get_allowed_subjects(); $data['class_list'] = ClassModel::get_class_list(); // 模版 $this->load->view('comparison_type/edit', $data); }
/** * 编辑信息提取方式 * @param int $id = 0 * @see update() */ public function edit($id = 0) { if (!$this->check_power('group_type_manage')) { return; } $id = intval($id); $id && ($row = GroupTypeModel::get_group_type($id)); if (empty($row)) { message('信息提取方式不存在'); return; } if ($row['pid']) { $parent = GroupTypeModel::get_group_type($row['pid']); $data['parent'] = $parent; } if (!QuestionModel::check_subject_power($row['subject_id'], 'w')) { return; } $data['row'] = $row; $data['subjects'] = CpUserModel::get_allowed_subjects(); // 模版 $this->load->view('group_type/edit', $data); }
/** * 编辑考试学科 * * @param int $id 考试学科id * @return void */ public function edit_subject($id = 0) { if (!$this->check_power('exam_manage')) { return; } $id = intval($id); $id && ($exam = ExamModel::get_exam($id)); if (empty($exam) or $exam['exam_pid'] == 0) { message('考试学科不存在', 'admin/exam/index'); return; } $parent = ExamModel::get_exam($exam['exam_pid'], 'exam_id,exam_name,exam_pid,grade_id,class_id,creator_id,managers'); if (empty($parent)) { message('考试期次不存在', 'admin/exam/index'); return; } $managers = $parent['managers'] ? json_decode($parent['managers'], true) : array(); $this->check_exam_manager_power($parent['creator_id'], $managers, $exam['creator_id']); $class_list = ClassModel::get_class_list(); $grades = C('grades'); $parent['grade_name'] = isset($grades[$parent['grade_id']]) ? $grades[$parent['grade_id']] : ''; $parent['class_name'] = isset($class_list[$parent['class_id']]['class_name']) ? $class_list[$parent['class_id']]['class_name'] : ''; $exam['qtype_score'] = explode(',', $exam['qtype_score']); for ($i = 0; $i < 9; $i++) { if (!isset($exam['qtype_score'][$i])) { $exam['qtype_score'][$i] = ''; } } $data['act'] = 'edit'; $data['exam'] = $exam; $data['parent'] = $parent; $data['subjects'] = CpUserModel::get_allowed_subjects(); $data['subject_types'] = C('subject_type'); $data['referer'] = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; $this->load->view('exam/edit_subject', $data); }
public function edit_combination($id = 0) { if (!$this->check_power('question_manage')) { return; } if (!QuestionModel::check_question_power($id, 'w')) { return; } $id = intval($id); $id && ($question = QuestionModel::get_question($id)); if ($question['related'] == 0) { $question['related'] = ''; } if ($question['exam_year'] == 0) { $question['exam_year'] = ''; } if (empty($question)) { message('组合题不存在'); return; } //判断该试题已经被考试过 或 正在被考 $be_tested = QuestionModel::question_has_test_action($id); if ($be_tested) { message('该试题已经被考生考过 或者 正在被考, 无法操作'); } // 不是组合题,做相应跳转 if ($question['type'] != 15 || $question['parent_id']) { redirect('admin/question/edit/' . $id); } // 试题类型 $relate_class = array(); $query = $this->db->get_where('relate_class', array('ques_id' => $id)); foreach ($query->result_array() as $row) { $relate_class[$row['grade_id']][$row['class_id']] = $row; } $data['relate_class'] = $relate_class; $data['paper_diy'] = $this->paper_diy; $data['act'] = 'edit'; $data['question'] = $question; $data['grades'] = CpUserModel::get_allowed_grades($q = 2); $data['subjects'] = CpUserModel::get_allowed_subjects(); $data['all_subjects'] = C('subject'); $data['subject_types'] = C('subject_type'); $data['all_grade_class'] = ClassModel::all_grade_class(); // 模版 $this->load->view('question/edit_group', $data); }
/** * @description 添加期次科目样卷 * @author * @final * @param int $exam_id 考试期次id * @param array $ids 试卷id */ public function add_demo($exam_id = 0) { if (!$this->check_power('exam_manage')) { return; } $exam_id = intval($exam_id); $exam_id && ($exam = ExamModel::get_exam($exam_id, 'exam_name,exam_id,exam_pid,subject_id')); if (empty($exam)) { message('考试期次科目不存在', 'admin/exam/index'); return; } //样卷,跳到样卷选择 if ($exam['exam_pid'] > 1) { redirect('admin/subject_paper/add/' . $exam_id); } //检查该学科考试状态 $has_tested = ExamPlaceSubjectModel::exam_subject_has_test_action($exam_id); if ($has_tested) { message('该期次科目已经被考生考过 或者 正在被考中,因此无法操作'); } $subject_id = $exam['subject_id']; $subjects = CpUserModel::get_allowed_subjects(); $exam['subject_name'] = $subjects[$subject_id]; $demo_subject_papers = C('demo_subject_paper', 'app/admin/exam/demo'); $paper_list = array(); $size = 30; $page = isset($_GET['page']) && intval($_GET['page']) > 1 ? intval($_GET['page']) : 1; $offset = ($page - 1) * $size; $total = 0; if (isset($demo_subject_papers[$subject_id]) && count($demo_subject_papers[$subject_id])) { $total = count($demo_subject_papers[$subject_id]); $sql = "SELECT * FROM {pre}exam_paper p WHERE p.exam_id={$exam_id} AND p.is_delete=0 AND p.paper_id in(" . implode(',', $demo_subject_papers[$subject_id]) . ") LIMIT {$offset},{$size}"; $query = $this->db->query($sql); foreach ($query->result_array() as $row) { $row['qtype_ques_num'] = explode(',', $row['qtype_ques_num']); $paper_list[] = $row; } } $data['exam'] =& $exam; $data['paper_list'] =& $paper_list; // 分页 $purl = site_url('admin/subject_paper/add_demo/' . $exam_id); $data['pagination'] = multipage($total, $size, $page, $purl); // 模版 $this->load->view('subject_paper/add', $data); }
public function index() { if (!$this->check_power('question_difficulty_list')) { return; } $page = intval($this->input->get('page')); $per_page = intval($this->input->get('per_page')); $id = intval($this->input->get('id')); $ques_id = intval($this->input->get('ques_id')); $grade_id = intval($this->input->get('grade_id')); $class_id = $this->input->get('class_id'); $subject_type = $this->input->get('subject_type'); $from_question_list = intval($this->input->get('from_question_list')); $difficulty_start = intval($this->input->get('difficulty_start')); $difficulty_end = intval($this->input->get('difficulty_end')); $copy_difficulty_start = intval($this->input->get('copy_difficulty_start')); $copy_difficulty_end = intval($this->input->get('copy_difficulty_end')); // 查询条件 $query = array(); $param = array(); $search = array('id' => '', 'ques_id' => '', 'grade_id' => '', 'subject_type' => '', 'class_id' => array(), 'difficulty_start' => '', 'difficulty_end' => '', 'copy_difficulty_start' => '', 'copy_difficulty_end' => ''); $grades = C('grades'); $subjects = CpUserModel::get_allowed_subjects(); $qtypes = C('qtype'); $subject_types = C('subject_type'); $class_list = ClassModel::get_class_list(); $data['grades'] = $grades; $data['subjects'] = $subjects; $data['qtypes'] = $qtypes; $data['subject_types'] = $subject_types; $data['class_list'] = $class_list; if ($id) { $query['id'] = $id; $param[] = "id={$id}"; $search['id'] = $id; } if ($ques_id) { $query['ques_id'] = $ques_id; $param[] = "ques_id={$ques_id}"; $search['ques_id'] = $ques_id; } if ($grade_id) { $query['grade_id'] = $grade_id; $param[] = "grade_id={$grade_id}"; $search['grade_id'] = $grade_id; } if (is_numeric($subject_type)) { $query['subject_type'] = $subject_type; $param[] = "subject_type={$subject_type}"; $search['subject_type'] = $subject_type; } if (is_array($class_id)) { $class_id = my_intval($class_id); if (count($class_id) == 1) { $query['class_id'] = $class_id[0]; } else { $query['class_id'] = $class_id; } $param[] = implode('&class_id[]=', $search['class_id']); $search['class_id'] = $class_id; } if ($difficulty_start) { $query['difficulty']['>='] = $difficulty_start; $param[] = "difficulty_start={$difficulty_start}"; $search['difficulty_start'] = $difficulty_start; } if ($difficulty_end) { $query['difficulty']['<='] = $difficulty_end; $param[] = "difficulty_end={$difficulty_end}"; $search['difficulty_end'] = $difficulty_end; } if ($copy_difficulty_start) { $query['copy_difficulty']['>='] = $copy_difficulty_start; $param[] = "copy_difficulty_start={$copy_difficulty_start}"; $search['copy_difficulty_start'] = $copy_difficulty_start; } if ($copy_difficulty_end) { $query['copy_difficulty']['<='] = $copy_difficulty_end; $param[] = "copy_difficulty_end={$copy_difficulty_end}"; $search['copy_difficulty_end'] = $copy_difficulty_end; } if ($from_question_list) { $param[] = "from_question_list={$from_question_list}"; $search['from_question_list'] = $from_question_list; } else { $search['from_question_list'] = '0'; } //限制只能查看所属学科 if (!$this->is_super_user() && !$this->is_all_subject_user() && !CpUserModel::is_action_type_all('question', 'r') && CpUserModel::is_action_type_subject('question', 'r')) { $c_subject_id = rtrim($this->session->userdata('subject_id'), ','); if ($c_subject_id != '') { $c_subject_id = explode(',', $c_subject_id); $c_subject_id = array_values(array_filter($c_subject_id)); $c_subject_id = implode(',', $c_subject_id); $where0 = " q.subject_id in({$c_subject_id})"; } else { $where0 = " 1=1"; } } else { $where0 = " 1=1"; } //限制只能查看所属年级 if (!$this->is_super_user() && !$this->is_all_grade_user()) { $c_grade_id = rtrim($this->session->userdata('grade_id'), ','); if ($c_grade_id != '') { $c_grade_id = explode(',', $c_grade_id); $c_grade_id = array_values(array_filter($c_grade_id)); $c_grade_id = implode(',', $c_grade_id); $where1 = " rc.grade_id in ({$c_grade_id})"; } else { $where1 = " 1=1"; } } else { $where1 = " 1=1"; } //限制只能查看所属类型 if (!$this->is_super_user() && !$this->is_all_q_type_user()) { $c_q_type_id = rtrim($this->session->userdata('q_type_id'), ','); if ($c_q_type_id != '') { $c_q_type_id = explode(',', $c_q_type_id); $c_q_type_id = array_values(array_filter($c_q_type_id)); $c_q_type_id = implode(',', $c_q_type_id); $where2 = " rc.class_id in ({$c_q_type_id})"; } else { $where2 = " 1=1"; } } else { $where2 = " 1=1"; } $where = $where0 . ' and (' . $where1 . ' and ' . $where2 . ')'; $select_what = 'rc.*'; $page = $page <= 0 ? 1 : $page; $per_page = $per_page <= 0 ? 10 : $per_page; $list = array(); if (!is_null($query)) { $list = RelateClassModel::get_relate_class_list($query, $page, $per_page, 'ques_id desc', $select_what, $group_by = null, $where); } //获取试题信息 $tmp_list = array(); foreach ($list as $k => $item) { $question = QuestionModel::get_question($item['ques_id'], 'title, subject_id, admin_id, addtime, type, is_parent'); if (!count($question)) { continue; } $admin = $this->db->query("SELECT a.realname FROM {pre}admin a where a.admin_id={$question['admin_id']}")->result_array(); $question['admin_name'] = count($admin) ? $admin[0]['realname'] : '--'; $question['subject_name'] = $subjects[$question['subject_id']]; $item['grade_name'] = $grades[$item['grade_id']]; $item['subject_type_name'] = $subject_types[$item['subject_type']]; $item['addtime'] = date('Y-m-d H:i:s', $question['addtime']); $question['type'] = $qtypes[$question['type']]; //获取试题类型 $item['class_name'] = isset($class_list[$item['class_id']]) ? $class_list[$item['class_id']]['class_name'] : '--'; //学科/试题相关权限 $has_question_power = QuestionModel::check_question_power($item['ques_id'], 'w', false); $has_subject_power = true; $item['has_edit_power'] = $has_question_power && $has_subject_power; $tmp_list[$k] = array_merge($item, $question); } $data['list'] =& $tmp_list; $data['search'] =& $search; $data['flags'] =& $flags; //难易度更新全新 $data['priv_manage'] = $this->check_power('update_system_difficulty', FALSE); $data['priv_question_manage'] = $this->check_power('question_manage', FALSE); // 分页 $purl = site_url('admin/relate_class/index/') . (count($param) ? '?' . implode('&', $param) : ''); $total = RelateClassModel::count_list($query, $where); $data['pagination'] = multipage($total, $per_page, $page, $purl); $this->load->view('relate_class/index', $data); }
/** * 试卷列表 * * @return void **/ public function index() { /* 搜索 */ $param = array(); $search = array(); /* 搜索条件 */ if (isset($_GET['begin_time']) && !empty($_GET['begin_time'])) { $param['addtime >='] = strtotime($_GET['begin_time'] . '00:00:59'); $search['begin_time'] = $_GET['begin_time']; } if (isset($_GET['end_time']) && !empty($_GET['end_time'])) { $param['addtime <='] = strtotime($_GET['end_time'] . '23:59:59'); $search['end_time'] = $_GET['end_time']; } if (isset($_GET['keyword']) && !empty($_GET['keyword'])) { $param['paper_name like'] = "%" . $_GET['keyword'] . "%"; $search['keyword'] = $_GET['keyword']; } /* 如果存在试卷ID 清除其他条件 */ if (isset($_GET['paper_id']) && !empty($_GET['paper_id'])) { $param = array(); $param['paper_id'] = intval($_GET['paper_id']); $search['paper_id'] = $_GET['paper_id']; } /* 如果存在试卷ID 清除其他条件 */ if (isset($_GET['subject_id']) && !empty($_GET['subject_id'])) { $param['subject_id'] = intval($_GET['subject_id']); $search['subject_id'] = $_GET['subject_id']; } /* 默认过滤条件 只能看到自己的试卷 */ if (!$this->session->userdata('is_super')) { $admin_info = $this->session->all_userdata(); if (empty($admin_info['admin_id'])) { message('获取管理员数据失败,请从新登陆后重试!'); } $param['admin_id'] = $admin_info['admin_id']; } else { $param['admin_id >'] = '0'; } /* 分页 */ $number = 15; $total = PaperModel::count_papers($param); $page = isset($_GET['page']) && intval($_GET['page']) > 1 ? intval($_GET['page']) : 1; $start = ($page - 1) * $number; $purl = site_url('admin/paper_diy/index') . ($param ? '?' . implode('&', $param) : ''); /* 试卷数据 */ $papers = PaperModel::get_papers('paper_id,exam_id,paper_name,addtime,admin_id,ques_num,exam_id,subject_id', $param, $start, $number); foreach ($papers as $key => $paper) { if ($exam_pid = ExamModel::get_exam($paper['exam_id'], 'exam_pid')) { $papers[$key]['is_mini_test'] = ExamModel::is_mini_test($exam_pid); } $papers[$key]['has_tested'] = $this->is_super_user() ? false : ExamPlaceSubjectModel::exam_subject_has_test_action($paper['exam_id']); if ($paper['admin_id'] > 0) { $sql = "select admin_id,admin_user,realname from {pre}admin where admin_id={$paper['admin_id']}"; $papers[$key]['admin_info'] = $this->db->query($sql)->row_array(); } else { $papers[$key]['admin_info']['realname'] = '系统'; } } $subject_type = CpUserModel::get_allowed_subjects(); $data = array(); $data['papers'] = $papers; $data['pagination'] = multipage($total, $number, $page, $purl); $data['search'] = $search; $data['subject_type'] = $subject_type; $this->load->view('paper_diy/list', $data); }