public function index($mode = '') { // 加载分类数据 $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"; // 过滤题组子题目,在题组页面管理 $mode = $mode == 'trash' ? 'trash' : ''; if ($mode == 'trash') { $where[] = "q.is_delete = 1"; } else { $where[] = "q.is_delete <> 1"; } /* 用户信息 */ $admin_info = $this->session->all_userdata(); if (empty($admin_info['admin_id'])) { message('获取管理员数据失败,请从新登陆后重试!'); } else { $where[] = "q.admin_id={$admin_info['admin_id']}"; $param[] = "admin_id={$admin_info['admin_id']}"; $search['admin_id'] = $admin_info['admin_id']; } // 操作时间 $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']; } } $where[] = "q.ques_id IN (SELECT DISTINCT ques_id FROM rd_relate_class) "; 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 '; //echo $where; // 统计数量 $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']); $row['has_edit_power'] = true; /* * 检查是否有关联信息 * 非题组:关联技能 * 题组:题干关联技能、知识点,子题必须要全部添加知识点 */ $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; //获取回收站信息 if ($mode == 'trash') { $recycle = RecycleModel::get_recycle_list(array('type' => RECYCLE_QUESTION, 'obj_id' => $row['ques_id']), null, null, 'ctime asc'); $row['recycle'] = $recycle; } else { $row['recycle'] = array(); } $list[] = $row; } } $data['list'] =& $list; // 分页 $purl = site_url('admin/question_external/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'] = true; $data['priv_trash'] = true; $data['priv_manage'] = true; $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'); $data['is_english_admin'] = true; // 模版 $this->load->view('question_external/index', $data); }
function recycle_log_1($type, $obj_id, $reason) { $CI =& get_instance(); //$CI->load->model('admin/recycle_model'); // $reason = trim($CI->input->get_post('reason')); RecycleModel::add($type, $obj_id, $reason); }
public function account($mode = '') { if (!$this->check_power('student_list,student_manage')) { return; } // 查询条件 $where = array(); $param = array(); $search = array(); $query = array(); $data = array(); $mode = $mode == 'trash' ? 'trash' : ''; if ($mode == 'trash') { if (!$this->check_power('student_list, student_trash')) { return; } $query['is_delete'] = 1; } else { if (!$this->check_power('student_list, student_manage')) { return; } $query['is_delete'] = 0; } $grades = C('grades'); if ($search['province'] = intval($this->input->get('province'))) { $param[] = "province={$search['province']}"; $query['province'] = intval($search['province']); } if ($search['city'] = intval($this->input->get('city'))) { $param[] = "city={$search['city']}"; $query['city'] = intval($search['city']); } if ($search['area'] = intval($this->input->get('area'))) { $param[] = "area={$search['area']}"; $query['area'] = intval($search['area']); } if ($search['school_id'] = intval($this->input->get('school_id'))) { $param[] = "school_id={$search['school_id']}"; $query['school_id'] = intval($search['school_id']); } if ($search['grade_id'] = intval($this->input->get('grade_id'))) { $param[] = "grade_id={$search['grade_id']}"; $query['grade_id'] = intval($search['grade_id']); } $search['from'] = intval($this->input->get('from')); if ($search['from'] > 0) { $param[] = "from={$search['from']}"; $query['source_from'] = intval($search['from']); } if ($search['keyword'] = trim($this->input->get('keyword'))) { $escape_keyword = $this->db->escape_like_str($search['keyword']); $param[] = "keyword=" . urlencode($search['keyword']); $query['keyword'] = "CONCAT(s.last_name,s.first_name,s.idcard) LIKE '%" . $escape_keyword . "%'"; } if ($search['exam_ticket'] = trim($this->input->get('exam_ticket'))) { $param[] = "exam_ticket={$search['exam_ticket']}"; $query['exam_ticket'] = $search['exam_ticket']; } if ($search['email'] = trim($this->input->get('email'))) { $param[] = "email={$search['email']}"; $query['email'] = $search['email']; } if ($search['mobile'] = trim($this->input->get('mobile'))) { $param[] = "mobile={$search['mobile']}"; $query['mobile'] = $search['mobile']; } if ($uid = intval($this->input->get('uid'))) { $search['uid'] = $uid; $param = array("uid={$uid}"); $query = array(); $query['uid'] = $search['uid']; } $res = CommonModel::get_list($query, 'rd_student', 'count(*) AS count'); /* * 统计所有学生数量 */ $total = $res[0]['count']; /* *分页读取数据列表,并处理相关数据 */ $size = 15; $page = isset($_GET['page']) && intval($_GET['page']) > 1 ? intval($_GET['page']) : 1; $offset = ($page - 1) * $size; $list = array(); if ($total) { $res = CommonModel::get_list($query, 'v_student', '*', $page, $size); foreach ($res as $row) { $row['grade'] = isset($grades[$row['grade_id']]) ? $grades[$row['grade_id']] : '未选择'; $row['addtime'] = date('Y-m-d H:i', $row['addtime']); //获取回收站信息 if ($mode == 'trash') { $recycle = RecycleModel::get_recycle_list(array('type' => RECYCLE_STUDENT, 'obj_id' => $row['uid']), null, null, 'ctime asc'); $row['recycle'] = $recycle; } else { $row['recycle'] = array(); } $list[] = $row; } } $data['list'] = $list; // 分页 $purl = site_url('admin/student/account/') . ($param ? '?' . implode('&', $param) : ''); $data['pagination'] = multipage($total, $size, $page, $purl); // 使用Yaf样式RegionModel代替 $data['province_list'] = RegionModel::get_regions(1); $data['city_list'] = RegionModel::get_regions($search['province'], FALSE, 2); $data['area_list'] = RegionModel::get_regions($search['city'], FALSE, 3); $data['grades'] = $grades; $data['from'] = C('student_source'); $data['search'] = $search; $data['schools'] = array(); $data['mode'] = $mode; $data['priv_delete'] = $this->check_power('student_trash', FALSE); $data['priv_manage'] = $this->check_power('student_manage', FALSE); // 模版 $this->load->view('student/account', $data); }
/** * 监考人员 列表 * * @return void */ public function index() { if (!$this->check_power('exam_list,exam_manage')) { return; } // 查询条件 $query = array(); $param = array(); $search = array(); $place_id = $this->input->get_post('place_id'); if ($place_id) { $db_query = $this->db->select('p.place_id,p.place_name,p.address,e.exam_id,e.exam_name,sch.school_id,sch.school_name')->from('exam_place p')->join('exam e', 'p.exam_pid=e.exam_id')->join('school sch', 'p.school_id=sch.school_id')->where('p.place_id', $place_id)->get(); $place = $db_query->row_array(); } if (empty($place)) { message('考场信息不存在'); } //控制考场只能在未开始考试操作 $no_start = ExamPlaceModel::place_is_no_start($place_id); if (!$no_start) { message('该考场正在考试或已结束,无法做此操作'); } $data['place'] = $place; $search['place_id'] = $place_id; $param[] = "place_id={$place_id}"; $page = (int) $this->input->get_post('page'); $page = $page ? $page : 1; $per_page = (int) $this->input->get_post('per_page'); $per_page = $per_page ? $per_page : 10; $order_bys = array('email' => 'invigilator_email', 'name' => 'invigilator_name', 'memo' => 'invigilator_memo', 'time' => 'invigilator_addtime'); $order = $this->input->get_post('order'); !$order && ($order = 'time'); $search['order'] = $order; $param[] = "order={$order}"; $order_type = $this->input->get_post('order_type'); !$order_type && ($order_type = 'desc'); $search['order_type'] = $order_type; $param[] = "order_type={$order_type}"; $order_by = $order_bys[$order] . ' ' . $order_type; $selectWhat = '*'; //拼接查询条件 $query_email = $this->input->get_post('email'); if ($query_email) { $query['invigilator_email'] = trim($query_email); $search['email'] = $query_email; $param[] = "email={$query_email}"; } $query_name = $this->input->get_post('name'); if ($query_name) { $query['invigilator_name'] = trim($query_name); $search['name'] = $query_name; $param[] = "name={$query_name}"; } $query_flag = $this->input->get_post('flag'); if ($query_flag) { $query['invigilator_flag'] = is_string($query_flag) ? (int) $query_flag : $query_flag; $search['flag'] = $query_flag; $param[] = "flag={$query_flag}"; } $query_is_trash = (int) $this->input->get_post('trash'); if ($query_is_trash) { $query['invigilator_flag'] = '-1'; $search['trash'] = $query_is_trash; $param[] = "trash={$query_is_trash}"; } else { $query['invigilator_flag'] = array('0', '1'); } $query_begin_time = $this->input->get_post('begin_time'); if ($query_begin_time) { $query['invigilator_addtime'] = array('>=' => strtotime($query_begin_time)); $search['begin_time'] = $query_begin_time; $param[] = "begin_time={$query_begin_time}"; } $query_end_time = $this->input->get_post('end_time'); if ($query_end_time) { if (!isset($query['invigilator_addtime'])) { $query['invigilator_addtime'] = array(); } $query['invigilator_addtime']['<='] = strtotime($query_end_time); $search['end_time'] = $query_end_time; $param[] = "end_time={$query_end_time}"; } //查看已分配 $has_assigned = intval($this->input->get_post('has_assigned')); if (!$query_is_trash) { if ($has_assigned) { $search['has_assigned'] = $has_assigned; $param[] = "has_assigned={$has_assigned}"; $result = ExamInvigilatorModel::get_invigilator_list($query, $page, $per_page, $order_by, $selectWhat, $place_id); } else { $result = ExamInvigilatorModel::get_invigilator_list($query, $page, $per_page, $order_by, $selectWhat, $place_id, true); } } else { $result = ExamInvigilatorModel::get_invigilator_list($query, $page, $per_page, $order_by, $selectWhat); } $tmp_result = array(); if (count($result)) { foreach ($result as $v) { if ($query_is_trash) { $recycle = RecycleModel::get_recycle_list(array('type' => RECYCLE_EXAM_INVIGILATOR, 'obj_id' => $v['invigilator_id']), null, null, 'ctime asc'); $v['recycle'] = $recycle; } else { $v['recycle'] = array(); } $tmp_result[] = $v; } } // 分页 $purl = site_url('admin/exam_invigilator/index/') . (count($param) ? '?' . implode('&', $param) : ''); if ($has_assigned) { $total = ExamInvigilatorModel::count_invigilator_lists($query, $place_id); } else { $total = ExamInvigilatorModel::count_invigilator_lists($query, $place_id, true); } $data['pagination'] = multipage($total, $per_page, $page, $purl); $data['search'] =& $search; $data['list'] =& $tmp_result; //排序地址 unset($param['order=']); unset($param['order_type=']); $order_url = site_url('admin/exam_invigilator/index/') . (count($param) ? '?' . implode('&', $param) : ''); $data['order_url'] = $order_url; $data['priv_manage'] = $this->check_power('exam_manage', FALSE); // 模版 $this->load->view('exam_invigilator/index', $data); }