private function _check_question(&$question, &$extends, $need_know_process = true, $need_knowledge = true) { // 试题信息验证 $message = array(); /** 试题类型数组最大键名 */ $max = max(array_keys(C('q_type'))); if (!isset($question['type']) || $question['type'] === '' || $question['type'] > $max) { $message[] = '请选择题型'; } $question['end_grade'] = $question['end_grade'] > 12 ? 12 : $question['end_grade']; if (empty($question['subject_id'])) { $message[] = '请选择学科'; } if ($question['subject_id'] == 11 && !$question['subject_id_str']) { $message[] = '请选择综合的学科'; } if (empty($question['start_grade']) or empty($question['end_grade'])) { $message[] = '请选择年级区间'; } elseif ($question['start_grade'] > $question['end_grade']) { $message[] = '开始年级不能比结束年级高'; } if (empty($extends['class_ids']) || !is_array($extends['class_ids'])) { $message[] = '请选择试题类型'; } else { $class_ids =& $extends['class_ids']; $subject_types =& $extends['subject_types']; $difficulty =& $extends['difficulty']; $relate_class = array(); $question_class = array(); for ($i = $question['start_grade']; $i <= $question['end_grade']; $i++) { if (empty($class_ids[$i]) or !is_array($class_ids[$i])) { if ($i == $question['start_grade'] || $i == $question['end_grade']) { $message[] = '请选择首尾年级相应的试题类型'; break; } else { continue; } } foreach ($class_ids[$i] as $cid) { $cid = intval($cid); $question_class[$cid] = $cid; //文理科属性只有 高二~高三 的语、数、外有,即grade_id >= 11 and subject_id > 3 if ($i >= 11) { if ($question['subject_id'] > 3) { $subject_type = '-1'; } else { $subject_type = isset($subject_types[$i][$cid]) ? $subject_types[$i][$cid] : '0'; } } else { $subject_type = '-1'; } $cid_diff = isset($difficulty[$i][$cid]) ? floatval($difficulty[$i][$cid]) : 0; if ($cid_diff < 1 or $cid_diff > 100) { $message[] = '请填写选中类型对应的难易度'; break 2; } $relate = array('grade_id' => $i, 'class_id' => $cid, 'subject_type' => $subject_type, 'difficulty' => $cid_diff, 'copy_difficulty' => $cid_diff); $relate_class[] = $relate; } } sort($question_class, SORT_NUMERIC); $question['class_id'] = ',' . implode(',', $question_class) . ','; $extends['relate_class'] = $relate_class; unset($extends['class_ids'], $extends['subject_types'], $extends['difficulty']); } //后续将技能移除,目前先不作限制 /* if (empty($extends['skill_ids']) || ! is_array($extends['skill_ids'])) { $message[] = '请选择技能'; }*/ if (!empty($extends['skill_ids']) && is_array($extends['skill_ids']) && count($extends['skill_ids'])) { $extends['skill_ids'] = my_intval($extends['skill_ids']); sort($extends['skill_ids'], SORT_NUMERIC); $question['skill'] = ',' . implode(',', $extends['skill_ids']) . ','; } else { $extends['skill_ids'] = array(); $question['skill'] = ''; } //方法策略, 选填项 if (!empty($extends['method_tactic_ids']) && is_array($extends['method_tactic_ids']) && count($extends['method_tactic_ids'])) { $extends['method_tactic_ids'] = my_intval($extends['method_tactic_ids']); sort($extends['method_tactic_ids'], SORT_NUMERIC); $question['method_tactic'] = ',' . implode(',', $extends['method_tactic_ids']) . ','; } else { $extends['method_tactic_ids'] = array(); $question['method_tactic'] = ''; } if ($need_knowledge) { if (empty($extends['knowledge_ids']) || !is_array($extends['knowledge_ids'])) { $message[] = '请选择知识点'; } else { //检查认知过程 if ($need_know_process) { foreach ($extends['knowledge_ids'] as $knowledge_id) { if (!isset($extends['know_process'][$knowledge_id]) || !intval($extends['know_process'][$knowledge_id])) { $message[] = '已勾选的知识点必须选择 认知过程'; break; } } } $extends['knowledge_ids'] = my_intval($extends['knowledge_ids']); sort($extends['knowledge_ids'], SORT_NUMERIC); $question['knowledge'] = ',' . implode(',', $extends['knowledge_ids']) . ','; } } else { if (is_array($extends['knowledge_ids']) && count($extends['knowledge_ids'])) { $extends['knowledge_ids'] = my_intval($extends['knowledge_ids']); sort($extends['knowledge_ids'], SORT_NUMERIC); $question['knowledge'] = ',' . implode(',', $extends['knowledge_ids']) . ','; } else { $extends['knowledge_ids'] = array(); $question['knowledge'] = ''; } } if (in_array($question['type'], array(5, 6))) { if (!empty($question['tags'])) { $q_tags = C('q_tags/' . $question['type']); if (!in_array($question['tags'], array_keys($q_tags))) { $message[] = '标签不存在'; } } else { $message[] = '请选择标签'; } } //翻译题 翻译类型 if ($question['type'] == 7) { $translation = $this->input->post('translation'); if (empty($translation)) { $message[] = '请选择翻译类型'; } else { $question['translation'] = intval($translation); } } if (isset($extends['group_type_ids']) && empty($extends['group_type_ids'])) { $message[] = '请选择信息提取方式'; } else { if (!empty($extends['group_type_ids'])) { $extends['group_type_ids'] = my_intval($extends['group_type_ids']); sort($extends['group_type_ids'], SORT_NUMERIC); $question['group_type'] = ',' . implode(',', $extends['group_type_ids']) . ','; } } if (isset($question['score_factor']) && ($question['score_factor'] < 1 or $question['score_factor'] > 10)) { $message[] = '请正确填写分值系数(1-10)'; } if (strlen($question['title']) == 0) { $message[] = '请填写试题内容'; } else { if (isset($question['options'])) { if (strlen($question['options']) == 0) { if ($question['type'] == 5) { $message[] = '请填写试题选项'; } elseif ($question['type'] == 6) { $message[] = '请填写试题选词'; } } else { $question['title'] .= " <br/> " . $question['options']; } unset($question['options']); } } if ($question['type'] == 3) { $answer = trim($this->input->post('input_answer')); if (strlen($answer) == 0) { $message[] = '请填写填空题答案'; } else { $new_lines = array(); $lines = explode("\n", $answer); foreach ($lines as $line) { $line = trim($line); if (strlen($line) > 0) { $new_lines[] = $line; } } $question['answer'] = implode("\n", $new_lines); } } return $message; }
/** * 添加 考场 监考人员 */ public function insert() { if (!$this->check_power('exam_manage')) { return; } $place_id = (int) $this->input->post('place_id'); if ($place_id) { $query = $this->db->select('p.*')->from('exam_place p')->join('exam e', 'p.exam_pid=e.exam_id')->join('school sch', 'p.school_id=sch.school_id')->where(array('p.place_id' => $place_id))->get(); $place = $query->row_array(); } if (empty($place)) { message('考场信息不存在', 'admin/exam/index'); return; } $ids = $this->input->post('id'); if (empty($ids) or !is_array($ids)) { message('请至少选择一项'); return; } //控制考场只能在未开始考试操作 $no_start = ExamPlaceModel::place_is_no_start($place_id); if (!$no_start) { message('该考场正在考试或已结束,无法做此操作'); } $ids = my_intval($ids); $inserts = array(); //获取未被分配考场的监考人员 /* * 同一个监考人员不能同时出现在 相同时段的考场中 */ $place['start_time'] = $place['start_time'] + 1; $place['end_time'] = $place['end_time'] - 1; $sql = "SELECT i.invigilator_id FROM {pre}invigilator i \n WHERE i.invigilator_flag=1 AND i.invigilator_id IN(" . my_implode($ids) . ")\n AND NOT EXISTS(SELECT ps.invigilator_id FROM {pre}exam_place_invigilator ps,{pre}exam_place p WHERE ps.place_id=p.place_id AND ps.invigilator_id=i.invigilator_id and ((p.start_time >= {$place['start_time']} and p.start_time <= {$place['end_time']}) OR (p.end_time >= {$place['start_time']} and p.end_time <= {$place['end_time']}) OR (p.start_time <= {$place['start_time']} and p.end_time >= {$place['end_time']})))"; //已经分配有考场的监考人员列表 $failed_ids = array(); $success_ids = array(); $result = $this->db->query($sql)->result_array(); foreach ($result as $row) { $inserts[] = array('place_id' => $place_id, 'invigilator_id' => $row['invigilator_id']); $success_ids[] = $row['invigilator_id']; } $failed_ids = array_diff($ids, $success_ids); $res = 0; if ($inserts) { // 关闭错误信息,防止 unique index 冲突出错 $this->db->db_debug = false; $this->db->insert_batch('exam_place_invigilator', $inserts); $res = $this->db->affected_rows(); } $back_url = 'admin/place_invigilator/index/' . $place_id; if ($res < 1) { message('监考人员添加失败', $back_url); } else { $failed_i_names = array(); foreach ($failed_ids as $id) { $i_name = ExamInvigilatorModel::get_invigilator_by_id($id, 'name'); if ($i_name) { $failed_i_names[] = $i_name; } } $msg = array('监考人员添加成功'); if (count($failed_i_names)) { $msg[] = '<hr/>以下监考人员已经分配了考场:<br/>' . implode('<br/>', $failed_i_names); } message(implode('', $msg), $back_url); } }
public function knowledge_select() { $subject_id = $this->input->post('subject_id'); if (Validate::isInt($subject_id)) { $relate_subject_id = SubjectModel::get_subject($subject_id, 'relate_subject_id'); if ($relate_subject_id) { $subject_id .= ",{$relate_subject_id}"; } } $knowledge_ids = ',' . trim($this->input->post('knowledge_ids')) . ','; $is_question_mode = intval($this->input->post('is_question_mode')); $list = array(); $list = KnowledgeModel::get_knowledge_list($subject_id, 0, 1); foreach ($list as $key => $val) { //pr($val,1); $children = KnowledgeModel::get_knowledge_list($val['subject_id'], $val['id'], 1); if ($children) { usort($children, 'cmp_knowledge'); $list[$key]['children'] = $children; } else { unset($list[$key]); } } //根据知识点ID获取对应的认知过程 $know_processes = array(); if ($is_question_mode) { $know_process_ids = trim($this->input->post('know_process')); $data['know_process'] = C('know_process'); $data['know_process_ids'] = my_intval((array) json_decode($know_process_ids)); } usort($list, 'cmp_knowledge'); $data['is_know_process'] = !in_array($subject_id, array(13, 14, 15, 16)); $data['list'] = $list; $data['knowledge_ids'] = $knowledge_ids; if ($is_question_mode && !in_array($subject_id, array(13, 14, 15, 16))) { $this->load->view('question/knowledge_select_with_know_process', $data); } else { $this->load->view('question/knowledge_select', $data); } }
/** * @description 更新学校保存数据库 * @author * @final * @param int $school_id 学校id * @param int $province 学校所在省 * @param int $city 学校所在市 * @param int $area 学校所在区县 * @param int $school_name 学校名称 * @param int $grade_period 学校类型 * @param int $status 学校状态 */ public function update() { if (!$this->check_power('school_manage')) { return; } $school_id = intval($_POST['school_id']); $data['province'] = intval($_POST['province']); $data['city'] = intval($_POST['city']); $data['area'] = intval($_POST['area']); $data['grade_period'] = $this->input->post('grade_period'); $data['school_name'] = trim($this->input->post('school_name')); $data['school_property'] = intval($this->input->post('school_property')) ? 1 : 0; $data['status'] = intval($this->input->post('status')) ? 1 : 0; foreach ($data as $k => $v) { if ($k != 'status' && $k != 'school_property' && empty($v)) { message('请填写完整学校信息!'); return; } } $data['grade_period'] = implode(',', my_intval($data['grade_period'])); $this->db->update('school', $data, array('school_id' => $school_id)); admin_log('edit', 'school', $school_id); message('学校修改成功.'); }
echo EOL . '</pre>'; if (isset($_SESSION['mpp']['hihand_cards'])) { echo $_SESSION['mpp']['hihand_cards']; } echo "Hi-est Hand: " . $_SESSION['mpp']['hihand'] . " (in " . $_SESSION['mpp']['num_hands'] . ")<br/>\n"; $utcEnd = microtime(TRUE); echo "Parsetime: " . number_format($utcEnd - $utcStart, 4, '.', ',') . " seconds"; // die; /* } */ $num = "37.124334d"; echo "<hr/>\n"; echo $num . "<br/>\n"; echo floor($num) . '.' . intval(substr($num, 2)) . "<br/>\n"; echo my_intval($num); function my_intval($num) { return floor($num) . '.' . intval(substr($num, strlen(floor($num)) + 1)); } function Go_Random($max) { global $used_randoms; $id = rand(1, $max); if (isset($used_randoms) && is_array($used_randoms) && in_array($id, $used_randoms)) { Go_Random($max); } else { $used_randoms[] = $id; } return $id; }
/** * 试题列表 * * @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); }
/** * 添加、修改组题规则[入库操作] * * @param int $id 规则id * @param string $rule_name 规则名称 * @param int $subject_id 学科 * @param int $class_id 类型 * @param int $grade_id 年级 * @param int $subject_type 学科类型:0文理,1文科,2理科 * @param int $difficulty 平均难易度 * @param int $ques_num 题型试题数:题组、单选、不定项、填空。以逗号分隔 * @param int $knowledge_id 范围知识点 * @param int $parent_knowledge 重点知识--父级知识点id * @param int $rule_knowledge 重点知识--二级知识点id * @param int $know_process 认知过程 * @param int $knowledge_qnum 重点知识试题数 * @return void */ public function update() { $act = $this->input->post('act') == 'add' ? 'add' : 'edit'; if ($act == 'add') { $this->session->set_userdata(array('exam_rule_update_add' => $this->input->post())); } if ($act == 'edit') { if ($id = intval($this->input->post('id'))) { $query = $this->db->get_where('exam_rule', array('rule_id' => $id)); $old = $query->row_array(); } if (empty($old)) { message('规则不存在'); return; } } /* * 题目基本信息 */ $rule['rule_name'] = trim($this->input->post('rule_name')); $rule['subject_id'] = intval($this->input->post('subject_id')); $rule['class_id'] = intval($this->input->post('class_id')); $rule['test_way'] = intval($this->input->post('test_way')); $rule['grade_id'] = intval($this->input->post('grade_id')); $subject_type = $this->input->post('subject_type'); $rule['subject_type'] = $subject_type === false ? '-1' : intval($subject_type); $rule['difficulty'] = intval($this->input->post('difficulty')); $rule['is_original'] = implode(',', array_filter(array_values($this->input->post('is_original')))); $ques_num = $this->input->post('ques_num'); //题目数量组合 $knowledge_id_arr = $this->input->post('knowledge_id'); //知识点范围 $parent_knowledge = $this->input->post('parent_knowledge'); //一级知识点 $rule_knowledge = $this->input->post('rule_knowledge'); //二级知识点 $know_process = $this->input->post('know_process'); //认知过程 $knowledge_qnum = $this->input->post('knowledge_qnum'); //重点知识点数量 //修改之前先判断各题型重点知识点题目数量和各题型总题目数量之间的大小 $sum1 = 0; $sum2 = 0; $sum3 = 0; $sum4 = 0; $sum5 = 0; $sum6 = 0; $sum7 = 0; $sum8 = 0; $sum9 = 0; $sum10 = 0; foreach ($knowledge_qnum as $k => $v) { foreach ($v as $k2 => $v2) { if ($k2 <= 2) { $sum0 += $v2; } elseif ($k2 <= 5) { $sum1 += $v2; } elseif ($k2 <= 8) { $sum2 += $v2; } elseif ($k2 <= 11) { $sum3 += $v2; } elseif ($k2 <= 14) { $sum4 += $v2; } elseif ($k2 <= 17) { $sum5 += $v2; } elseif ($k2 <= 20) { $sum6 += $v2; } elseif ($k2 <= 23) { $sum7 += $v2; } elseif ($k2 <= 26) { $sum8 += $v2; } elseif ($k2 <= 29) { $sum9 += $v2; } } } $qtype = C('qtype'); foreach ($ques_num as $k => $v) { if ($k == 0) { if ($v < $sum0) { message($qtype[$k] . '的总题目数量不能小于' . $qtype[$k] . '重点知识点题目数量', 'admin/exam_rule/index'); } } if ($k == 1) { if ($v < $sum1) { message($qtype[$k] . '的总题目数量不能小于' . $qtype[$k] . '重点知识点题目数量', 'admin/exam_rule/index'); } } if ($k == 2) { if ($v < $sum2) { message($qtype[$k] . '的总题目数量不能小于' . $qtype[$k] . '重点知识点题目数量', 'admin/exam_rule/index'); } } if ($k == 3) { if ($v < $sum3) { message($qtype[$k] . '的总题目数量不能小于' . $qtype[$k] . '重点知识点题目数量', 'admin/exam_rule/index'); } } if ($k == 4) { if ($v < $sum4) { message($qtype[$k] . '的总题目数量不能小于' . $qtype[$k] . '重点知识点题目数量', 'admin/exam_rule/index'); } } if ($k == 5) { if ($v < $sum5) { message($qtype[$k] . '的总题目数量不能小于' . $qtype[$k] . '重点知识点题目数量', 'admin/exam_rule/index'); } } if ($k == 6) { if ($v < $sum6) { message($qtype[$k] . '的总题目数量不能小于' . $qtype[$k] . '重点知识点题目数量', 'admin/exam_rule/index'); } } if ($k == 7) { if ($v < $sum7) { message($qtype[$k] . '的总题目数量不能小于' . $qtype[$k] . '重点知识点题目数量', 'admin/exam_rule/index'); } } if ($k == 8) { if ($v < $sum8) { message($qtype[$k] . '的总题目数量不能小于' . $qtype[$k] . '重点知识点题目数量', 'admin/exam_rule/index'); } } if ($k == 9) { if ($v < $sum9) { message($qtype[$k] . '的总题目数量不能小于' . $qtype[$k] . '重点知识点题目数量', 'admin/exam_rule/index'); } } } if ($rule['subject_id'] == 3) { //完形填空限制 $ques_children_num_4 = (int) $this->input->post('ques_children_num_4'); //难易度 $difficulty_limit = $this->input->post('difficulty_limit'); $difficulty_limit && ($difficulty_limit = array_values($difficulty_limit)); //单词数限制 $word_limit_num_min = $this->input->post('word_limit_num_min'); $word_limit_num_min && ($word_limit_num_min = array_values($word_limit_num_min)); $word_limit_num_max = $this->input->post('word_limit_num_max'); $word_limit_num_max && ($word_limit_num_max = array_values($word_limit_num_max)); //子题数 $children_limit_num = $this->input->post('children_limit_num'); $children_limit_num && ($children_limit_num = array_values($children_limit_num)); //所需子题数 $ques_limit_num = $this->input->post('ques_limit_num'); $ques_limit_num && ($ques_limit_num = array_values($ques_limit_num)); //匹配题和选词填空标签 $ques_tags = $this->input->post('ques_tags'); // 翻译题数量限制 $translation_c_e = (int) $this->input->post('translation_c_e'); $translation_e_c = (int) $this->input->post('translation_e_c'); } /* * 试题信息验证 */ $message = array(); if (empty($rule['rule_name'])) { $message[] = '请填写规则名称'; } if (empty($rule['subject_id'])) { $message[] = '请选择学科'; } if (empty($rule['grade_id'])) { $message[] = '请选择年级'; } if (empty($rule['class_id'])) { $message[] = '请选择类型'; } if (empty($rule['test_way'])) { $message[] = '请选择考试方式'; } if (empty($rule['difficulty'])) { $message[] = '请填写平均难易度'; } if ($rule['subject_id'] > 3 || $rule['grade_id'] < 11 || !in_array($rule['class_id'], array(2, 3))) { $rule['subject_type'] = '-1'; } else { if ($rule['subject_type'] == '-1') { $rule['subject_type'] = 0; } } if (empty($ques_num) or !is_array($ques_num)) { $message[] = '请填写试题数量'; } else { $ques_num = my_intval($ques_num); $question_num = 0; foreach ($ques_num as $type => $q_num) { if ($q_num == 0 && isset($ques_tags[$type])) { unset($ques_tags[$type]); } if ($rule['subject_id'] != 3 && $type > 3) { $q_num = 0; $ques_num[$type] = 0; } $question_num += $q_num; } if ($question_num == 0) { $message[] = '请填写试题数量'; } $rule['ques_num'] = implode(',', $ques_num); } if (empty($knowledge_id_arr) or !is_array($knowledge_id_arr)) { $message[] = '请选择知识点范围'; } else { $knowledge_id_arr = my_intval($knowledge_id_arr); sort($knowledge_id_arr); $rule['knowledge_ids'] = implode(',', $knowledge_id_arr); } if (!is_array($rule_knowledge) or !is_array($knowledge_qnum)) { $knowledge_qnum = $knowledge_qnum = array(); } else { /* * 去掉array第一条,第一条为用于js的规则demo */ array_shift($rule_knowledge); array_shift($knowledge_qnum); array_shift($parent_knowledge); array_shift($know_process); } if ($message) { message(implode('<br/>', $message), $this->input->post('act') == 'add' ? '/admin/exam_rule/add' : '', null, 10); return; } /* * 重点知识点 */ $tmp_know_process = array(); $knowledge_rules = array(); foreach ($rule_knowledge as $k => $v) { $v = intval($v); /* * 判断重点知识点是否在所选知识点范围内 */ if ($v) { if (!in_array($v, $knowledge_id_arr)) { continue; } } else { $v = intval($parent_knowledge[$k]); } /* * 试题数、认知过程数据处理判断 */ if (empty($v) or !isset($knowledge_qnum[$k]) or !is_array($knowledge_qnum[$k]) or !isset($know_process[$k]) or !intval($know_process[$k]) or isset($tmp_know_process[$v]) && in_array(my_intval($knowledge_qnum[$k]), $tmp_know_process[$v])) { continue; } $tmp_know_process[$v][] = intval($know_process[$k]); $knowledge_qnum[$k] = my_intval($knowledge_qnum[$k]); if (array_sum($knowledge_qnum[$k]) == 0) { continue; } $item = array('knowledge_id' => $v, 'know_process' => intval($know_process[$k]), 'setting' => implode(',', $knowledge_qnum[$k])); $knowledge_rules[$v . '_' . $item['know_process']] = $item; } try { if ($act == 'edit') { /* * 修改之前的知识点处理,之前有的知识点直接覆盖;没有的需要新增;之前有的现在没有的需要删除。 */ $old_sub_rules = array(); $query = $this->db->select('id,knowledge_id,know_process')->get_where('exam_rule_knowledge', array('rule_id' => $id)); foreach ($query->result_array() as $arr) { $old_sub_rules[$arr['knowledge_id'] . '_' . $arr['know_process']] = $arr['id']; } $this->db->trans_start(); $this->db->update('exam_rule', $rule, array('rule_id' => $id)); /* * 修改之前存在的知识点 */ foreach ($knowledge_rules as $k => &$val) { $val['rule_id'] = $id; if (isset($old_sub_rules[$k])) { $this->db->update('exam_rule_knowledge', $val, array('id' => $old_sub_rules[$k])); unset($old_sub_rules[$k]); unset($knowledge_rules[$k]); } } /* * 新增之前没有的知识点 */ if ($knowledge_rules) { $this->db->insert_batch('exam_rule_knowledge', $knowledge_rules); } /* * 直接删除之前有现在没有的知识点 */ if ($old_sub_rules) { $this->db->where_in('id', $old_sub_rules)->delete('exam_rule_knowledge'); } /* * 英语题组和完形填空限制 */ $this->db->delete('exam_rule_qtype_limit', 'exam_rule_id = ' . $id); if ($rule['subject_id'] == 3) { //完形填空 if ($ques_children_num_4 > 0) { $insert_data = array('exam_rule_id' => $id, 'subject_id' => $rule['subject_id'], 'qtype' => 4, 'children_num' => $ques_children_num_4, 'word_num_min' => 0, 'word_num_max' => 0, 'ques_num' => 0, 'difficulty_level' => 0, 'tags' => 0, 'translation_c_e' => 0, 'translation_e_c' => 0); $this->db->insert('exam_rule_qtype_limit', $insert_data); } // 翻译题 if ($translation_c_e > 0 || $translation_e_c > 0) { $insert_data = array('exam_rule_id' => $id, 'subject_id' => $rule['subject_id'], 'qtype' => 7, 'children_num' => 0, 'word_num_min' => 0, 'word_num_max' => 0, 'ques_num' => 0, 'difficulty_level' => 0, 'tags' => 0, 'translation_c_e' => $translation_c_e, 'translation_e_c' => $translation_e_c); $this->db->insert('exam_rule_qtype_limit', $insert_data); } //题组 $insert_data = array(); if ($ques_limit_num) { foreach ($ques_limit_num as $key => $num) { if ($num < 1) { continue; } $item = array('exam_rule_id' => $id, 'subject_id' => $rule['subject_id'], 'qtype' => 0, 'children_num' => (int) $children_limit_num[$key], 'word_num_min' => (int) $word_limit_num_min[$key], 'word_num_max' => (int) $word_limit_num_max[$key], 'ques_num' => $num, 'difficulty_level' => (int) $difficulty_limit[$key], 'tags' => 0, 'translation_c_e' => 0, 'translation_e_c' => 0); if (!in_array($item, $insert_data)) { $insert_data[] = $item; } else { foreach ($insert_data as &$val) { if ($val == $item) { $val['ques_num'] += 1; } } } } $insert_data && $this->db->insert_batch('exam_rule_qtype_limit', $insert_data); } //匹配题和选词填空题 if ($ques_tags) { foreach ($ques_tags as $key => $tags) { $insert_data = array('exam_rule_id' => $id, 'subject_id' => $rule['subject_id'], 'qtype' => $key, 'children_num' => 0, 'word_num_min' => 0, 'word_num_max' => 0, 'ques_num' => 0, 'difficulty_level' => 0, 'tags' => $tags, 'translation_c_e' => 0, 'translation_e_c' => 0); $this->db->insert('exam_rule_qtype_limit', $insert_data); } } } $this->db->trans_complete(); admin_log('edit', 'exam_rule', $id); message('组题规则编辑成功', 'admin/exam_rule/index'); } else { $rule['addtime'] = time(); $this->db->trans_start(); $res = $this->db->insert('exam_rule', $rule); if (empty($res)) { throw new Exception('规则添加失败'); } $id = $this->db->insert_id(); foreach ($knowledge_rules as $k => &$val) { $val['rule_id'] = $id; } if ($knowledge_rules) { $this->db->insert_batch('exam_rule_knowledge', $knowledge_rules); } /* * 英语题组和完形填空限制 */ if ($rule['subject_id'] == 3) { //完形填空 if ($ques_children_num_4 > 0) { $insert_data = array('exam_rule_id' => $id, 'subject_id' => $rule['subject_id'], 'qtype' => 4, 'children_num' => $ques_children_num_4, 'word_num_min' => 0, 'word_num_max' => 0, 'ques_num' => 0, 'difficulty_level' => 0, 'tags' => 0, 'translation_c_e' => 0, 'translation_e_c' => 0); $this->db->insert('exam_rule_qtype_limit', $insert_data); } // 翻译题 if ($translation_c_e > 0 || $translation_e_c > 0) { $insert_data = array('exam_rule_id' => $id, 'subject_id' => $rule['subject_id'], 'qtype' => 7, 'children_num' => 0, 'word_num_min' => 0, 'word_num_max' => 0, 'ques_num' => 0, 'difficulty_level' => 0, 'tags' => 0, 'translation_c_e' => $translation_c_e, 'translation_e_c' => $translation_e_c); $this->db->insert('exam_rule_qtype_limit', $insert_data); } //题组 $insert_data = array(); if ($ques_limit_num) { foreach ($ques_limit_num as $key => $num) { if ($num < 1) { continue; } $item = array('exam_rule_id' => $id, 'subject_id' => $rule['subject_id'], 'qtype' => 0, 'children_num' => (int) $children_limit_num[$key], 'word_num_min' => (int) $word_limit_num_min[$key], 'word_num_max' => (int) $word_limit_num_max[$key], 'ques_num' => $num, 'difficulty_level' => (int) $difficulty_limit[$key], 'tags' => 0, 'translation_c_e' => 0, 'translation_e_c' => 0); if (!in_array($item, $insert_data)) { $insert_data[] = $item; } else { foreach ($insert_data as &$val) { if ($val == $item) { $val['ques_num'] += 1; } } } } } $insert_data && $this->db->insert_batch('exam_rule_qtype_limit', $insert_data); } //匹配题和选词填空题 if ($ques_tags) { foreach ($ques_tags as $key => $tags) { $insert_data = array('exam_rule_id' => $id, 'subject_id' => $rule['subject_id'], 'qtype' => $key, 'children_num' => 0, 'word_num_min' => 0, 'word_num_max' => 0, 'ques_num' => 0, 'difficulty_level' => 0, 'tags' => $tags, 'translation_c_e' => 0, 'translation_e_c' => 0); $this->db->insert('exam_rule_qtype_limit', $insert_data); } } } $this->db->trans_complete(); admin_log('add', 'exam_rule', $id); $this->session->unset_userdata(array('exam_rule_update_add' => '')); message('组题规则添加成功', 'admin/exam_rule/index'); } catch (Exception $e) { message($e->getMessage()); } }
public function do_batch($act = '') { if (!$this->check_power('comparison_manage')) { return; } $act = trim($act); $ids = $this->input->post('ids'); $res = FALSE; if ($ids && is_array($ids)) { $ids = my_intval($ids); switch ($act) { case 'on': case 'restore': $res = ComparisonTypeModel::update($ids, array('cmp_type_flag' => 1)); break; case 'off': $res = ComparisonTypeModel::update($ids, array('cmp_type_flag' => 0)); break; case 'delete': $res = ComparisonTypeModel::update($ids, array('cmp_type_flag' => -1)); break; case 'remove': $res = ComparisonTypeModel::delete($ids); admin_log('remove', 'comparison_type', implode(',', $ids)); break; default: break; } if ($res) { message('批量操作成功!', 'admin/comparison_type/index'); } else { message('分类操作失败!', 'admin/comparison_type/index'); } } else { message('请选择要删除的分类'); } }
public function update() { if (!$this->check_power('interview_rule_manage')) { return; } $act = trim($this->input->post('act')); if ($act == 'edit') { if ($id = intval($this->input->post('id'))) { $query = $this->db->get_where('interview_rule', array('rule_id' => $id)); $old = $query->row_array(); } if (empty($old)) { message('规则不存在'); return; } if ($old['status']) { message('改规则已生成题目,不能修改。'); return; } } // 题目基本信息 $row['class_id'] = intval($this->input->post('class_id')); $row['grade_period'] = intval($this->input->post('period')); $row['type_id'] = intval($this->input->post('interview_type')); $row['lang'] = intval($this->input->post('lang')); $row['ques_num'] = intval($this->input->post('ques_num')); $row['rule_name'] = trim($this->input->post('rule_name')); if ($row['lang'] == 2) { $row['type_id'] = $row['extend_type'] = 0; } else { $extend_type = $this->input->post('extend_type'); if ($extend_type && is_array($extend_type)) { $extend_type = sort(my_intval($extend_type)); $row['extend_type'] = implode(',', $extend_type); } else { $row['extend_type'] = $row['type_id']; } } //pr($row,1); // 试题信息验证 $message = array(); if (empty($row['rule_name'])) { $message[] = '请填写规则名称'; } if (empty($row['grade_period'])) { $message[] = '请选择年段'; } if (empty($row['class_id'])) { $message[] = '请选择类型'; } if (empty($row['lang'])) { $message[] = '请选择语言'; } if ($row['lang'] == 1 && empty($row['type_id'])) { $message[] = '请选择考点'; } if (empty($row['ques_num'])) { $message[] = '请填写试题数量'; } if ($message) { message(implode('<br>', $message), null, 10); return; } if ($act == 'edit') { $this->db->update('interview_rule', $row, array('rule_id' => $id)); admin_log('edit', 'interview_rule', $id); } else { $row['addtime'] = time(); $this->db->insert('interview_rule', $row); admin_log('add', 'interview_rule', $this->db->insert_id()); } message('面试题组题规则编辑成功', 'admin/interview_rule/index'); }
private function _check_question(&$question, &$extends, $need_know_process = true, $need_knowledge = true) { // 试题信息验证 $message = array(); /** 试题类型数组最大键名 */ $max = max(array_keys(C('q_type'))); if (!isset($question['type']) || $question['type'] === '' || $question['type'] > $max) { $message[] = '请选择题型'; } if (!isset($question['test_way']) || !in_array($question['test_way'], array(1, 2, 3))) { $message[] = '请选择考试方式'; } $question['end_grade'] = $question['end_grade'] > 12 ? 12 : $question['end_grade']; if (empty($question['subject_id'])) { $message[] = '请选择学科'; } if ($question['subject_id'] == 11 && !$question['subject_id_str']) { $message[] = '请选择综合的学科'; } if (empty($question['start_grade']) or empty($question['end_grade'])) { $message[] = '请选择年级区间'; } elseif ($question['start_grade'] > $question['end_grade']) { $message[] = '开始年级不能比结束年级高'; } if (empty($extends['class_ids']) || !is_array($extends['class_ids'])) { $message[] = '请选择试题类型'; } else { $class_ids =& $extends['class_ids']; $subject_types =& $extends['subject_types']; $difficulty =& $extends['difficulty']; $relate_class = array(); $question_class = array(); for ($i = $question['start_grade']; $i <= $question['end_grade']; $i++) { if (empty($class_ids[$i]) or !is_array($class_ids[$i])) { if ($i == $question['start_grade'] || $i == $question['end_grade']) { $message[] = '请选择首尾年级相应的试题类型'; break; } else { continue; } } foreach ($class_ids[$i] as $cid) { $cid = intval($cid); $question_class[$cid] = $cid; //文理科属性只有 高二~高三 的语、数、外有,即grade_id >= 11 and subject_id > 3 if ($i >= 11) { if ($question['subject_id'] > 3) { $subject_type = '-1'; } else { $subject_type = isset($subject_types[$i][$cid]) ? $subject_types[$i][$cid] : '0'; } } else { $subject_type = '-1'; } $cid_diff = isset($difficulty[$i][$cid]) ? floatval($difficulty[$i][$cid]) : 0; if ($cid_diff < 1 or $cid_diff > 100) { $message[] = '请填写选中类型对应的难易度'; break 2; } $relate = array('grade_id' => $i, 'class_id' => $cid, 'subject_type' => $subject_type, 'difficulty' => $cid_diff, 'copy_difficulty' => $cid_diff); $relate_class[] = $relate; } } sort($question_class, SORT_NUMERIC); $question['class_id'] = ',' . implode(',', $question_class) . ','; $extends['relate_class'] = $relate_class; unset($extends['class_ids'], $extends['subject_types'], $extends['difficulty']); } //后续将技能移除,目前先不作限制 /* if (empty($extends['skill_ids']) || ! is_array($extends['skill_ids'])) { $message[] = '请选择技能'; }*/ if (!empty($extends['skill_ids']) && is_array($extends['skill_ids']) && count($extends['skill_ids'])) { $extends['skill_ids'] = my_intval($extends['skill_ids']); sort($extends['skill_ids'], SORT_NUMERIC); $question['skill'] = ',' . implode(',', $extends['skill_ids']) . ','; } else { $extends['skill_ids'] = array(); $question['skill'] = ''; } //方法策略, 选填项 if (!empty($extends['method_tactic_ids']) && is_array($extends['method_tactic_ids']) && count($extends['method_tactic_ids'])) { $extends['method_tactic_ids'] = my_intval($extends['method_tactic_ids']); sort($extends['method_tactic_ids'], SORT_NUMERIC); $question['method_tactic'] = ',' . implode(',', $extends['method_tactic_ids']) . ','; } else { $extends['method_tactic_ids'] = array(); $question['method_tactic'] = ''; } if ($need_knowledge) { if (empty($extends['knowledge_ids']) || !is_array($extends['knowledge_ids'])) { $message[] = '请选择知识点'; } else { //检查认知过程 if ($need_know_process) { foreach ($extends['knowledge_ids'] as $knowledge_id) { if (!isset($extends['know_process'][$knowledge_id]) || !intval($extends['know_process'][$knowledge_id])) { $message[] = '已勾选的知识点必须选择 认知过程'; break; } } } $extends['knowledge_ids'] = my_intval($extends['knowledge_ids']); sort($extends['knowledge_ids'], SORT_NUMERIC); $question['knowledge'] = ',' . implode(',', $extends['knowledge_ids']) . ','; } } else { if (is_array($extends['knowledge_ids']) && count($extends['knowledge_ids'])) { $extends['knowledge_ids'] = my_intval($extends['knowledge_ids']); sort($extends['knowledge_ids'], SORT_NUMERIC); $question['knowledge'] = ',' . implode(',', $extends['knowledge_ids']) . ','; } else { $extends['knowledge_ids'] = array(); $question['knowledge'] = ''; } } if (in_array($question['type'], array(5, 6))) { if (!empty($question['tags'])) { $q_tags = C('q_tags/' . $question['type']); if (!in_array($question['tags'], array_keys($q_tags))) { $message[] = '标签不存在'; } } else { $message[] = '请选择标签'; } } //翻译题 翻译类型 if ($question['type'] == 7) { $translation = $this->input->post('translation'); if (empty($translation)) { $message[] = '请选择翻译类型'; } else { $question['translation'] = intval($translation); } } if (isset($extends['group_type_ids']) && empty($extends['group_type_ids'])) { $message[] = '请选择信息提取方式'; } else { if (!empty($extends['group_type_ids'])) { $extends['group_type_ids'] = my_intval($extends['group_type_ids']); sort($extends['group_type_ids'], SORT_NUMERIC); $question['group_type'] = ',' . implode(',', $extends['group_type_ids']) . ','; } } if (isset($question['score_factor']) && ($question['score_factor'] < 1 or $question['score_factor'] > 10)) { $message[] = '请正确填写分值系数(1-10)'; } if (strlen($question['title']) == 0) { $message[] = '请填写试题内容'; } else { preg_match_all('/<video.*?>.*?<\\/video>/', $question['title'], $matchs); if (isset($matchs[0]) && $matchs[0]) { if (in_array($question['test_way'], array(2, 3))) { $message[] = '试题包含视频文件,不适用于纸质考试'; } if (count($matchs[0]) > 1) { $message[] = '题目视频数量不能多于一个'; } else { preg_match('/class=".*?"/', $matchs[0][0], $match); if ($match) { $question['title'] = str_replace('autoplay="autoplay"', '', $question['title']); $question['title'] = str_replace($match[0], $match[0] . ' autoplay="autoplay"', $question['title']); } } } preg_match_all('/<img.*?>/', $question['title'], $matchs2); $t_title = str_replace(array(" ", " "), array("", ""), strip_tags($question['title'])); if (empty($matchs[0]) && empty($matchs2[0]) && !$t_title) { $message[] = '请填写试题内容'; } if (isset($question['options'])) { if (strlen($question['options']) == 0) { if ($question['type'] == 5) { $message[] = '请填写试题选项'; } elseif ($question['type'] == 6) { $message[] = '请填写试题选词'; } } else { if (in_array($question['type'], array(5, 6))) { $question['title'] .= " <br/> " . $question['options']; } } unset($question['options']); } } // 试题图片 if ($_FILES['picture']['name']) { if ($this->upload->do_upload('picture')) { $question['picture'] = $this->upload->data('file_relative_path'); } else { $message[] = $this->upload->display_errors(); } } if ($question['type'] == 3) { if ($question['test_way'] == 2) { $answer = trim($this->input->post('input_answer_ue')); } else { $answer = trim($this->input->post('input_answer')); } if (strlen($answer) == 0) { $message[] = '请填写填空题答案'; } else { $new_lines = array(); $lines = explode("\n", $answer); foreach ($lines as $line) { $line = trim($line); if (strlen($line) > 0) { $new_lines[] = $line; } } $question['answer'] = implode("\n", $new_lines); } } if (in_array($question['type'], array(10)) && !$question['is_parent']) { $answer = trim($this->input->post('input_reference_answer')); preg_match_all('/<img.*?>/', $answer, $matchs); $answer2 = str_replace(array(" ", " "), array("", ""), strip_tags($answer)); if (strlen($answer) == 0 || empty($matchs[0]) && !$answer2) { $qtype_name = C('q_type/' . $question['type']); $message[] = "请填写{$qtype_name}答案"; } else { $question['reference_answer'] = $answer; } } //作文添加范文 if (in_array($question['type'], array(11))) { $question['reference_answer'] = trim($this->input->post('input_reference_answer')); } return $message; }
/** * 试卷加入试题 * * @param int $paper_id 试卷id * @param int $ques_ids 试题id * @return void */ public function insert() { if (!$this->check_power('exam_manage')) { return; } $paper_id = intval($this->input->post('paper_id')); $ques_ids = trim($this->input->post('ques_ids')); if (empty($ques_ids)) { message('请选择要添加的试题'); return; } $paper = ExamPaperModel::detail($paper_id); if (empty($paper)) { message('试卷不存在'); return; } $exam = ExamModel::get_exam($paper['exam_id'], 'exam_pid,subject_id,grade_id,class_id'); if (empty($exam)) { message('考试不存在'); return; } //判断该试卷已经被考试过 或 正在被考 $is_mini_test = ExamModel::is_mini_test($exam['exam_pid']); if (!$is_mini_test) { $be_tested = QuestionModel::paper_has_test_action($paper_id); if ($be_tested) { message('该试卷已经被考生考过 或者 正在被考, 无法修改'); } } $ques_ids = my_intval(explode(',', $ques_ids)); $this->check_total_score($paper_id, $ques_ids); $sql = "SELECT q.ques_id,q.group_id FROM {pre}question q,{pre}relate_class rc\n WHERE q.ques_id=rc.ques_id AND q.subject_id={$exam['subject_id']} AND rc.grade_id={$exam['grade_id']}\n AND rc.class_id={$exam['class_id']} AND q.ques_id IN (" . my_implode($ques_ids) . ")"; $query = $this->db->query($sql); $inserts = array(); $fail = $success = 0; $msg = array(); foreach ($query->result_array() as $row) { if (in_array($row['ques_id'], $paper['ques_ids']) or $row['group_id'] && in_array($row['group_id'], $paper['group_ids'])) { $fail++; $msg[] = '该试卷同一试题已存在或者同一分组中的试题已存在!'; continue; } $success++; $item = array('paper_id' => $paper['paper_id'], 'exam_id' => $paper['exam_id'], 'ques_id' => $row['ques_id']); $inserts[] = $item; $paper['ques_ids'][] = $row['ques_id']; if ($row['group_id']) { $paper['group_ids'][] = $row['group_id']; } } if ($inserts) { $this->db->insert_batch('exam_question', $inserts); ExamPaperModel::renew($paper_id); if ($is_mini_test) { SummaryModel::summary_paper($exam['exam_pid'], 0, $paper_id, true); } } $msg = '成功' . $success . '个,失败' . $fail . '个失败原因:<br>' . implode('<br>', $msg); message('试卷试题添加成功' . $msg, 'admin/exam_question/index/' . $paper_id); }
/** * @description 添加期次科目试卷 * @author * @final * @param int $exam_id 考试期次id * @param array $ids 试卷id */ public function insert() { if (!$this->check_power('exam_manage')) { return; } $exam_id = (int) $this->input->post('exam_id'); $exam_id && ($exam = ExamModel::get_exam($exam_id, 'exam_id,exam_pid,grade_id,class_id')); if (empty($exam)) { message('考试期次科目不存在', 'admin/exam/index'); return; } $ids = $this->input->post('ids'); if (empty($ids) or !is_array($ids)) { message('请至少选择一项'); return; } //检查该学科考试状态 $has_tested = ExamPlaceSubjectModel::exam_subject_has_test_action($exam_id); if ($has_tested) { message('该期次科目已经被考生考过 或者 正在被考中,因此无法操作'); } $ids = my_intval($ids); /* ------------------------------- */ /* 补全外部新试卷信息 */ foreach ($ids as $paper_id) { /* 查询试卷信息 */ $paper = PaperModel::get_paper_by_id($paper_id, 'paper_id,admin_id,question_sort'); /* 判定是否为外部试卷 */ if ($paper['admin_id'] > 0) { $questions = json_decode($paper['question_sort'], true); $qtype_ques_num = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $question_difficulty = array(); $this->db->trans_start(); $sql = "DELETE FROM rd_exam_question WHERE paper_id={$paper_id} \n AND exam_id={$exam_id}"; Fn::db()->query($sql); if (count($questions) > 0) { foreach ($questions as $ques_id) { /* 补全exam_question信息 */ $data = array(); $data['paper_id'] = $paper_id; $data['exam_id'] = $exam_id; $data['ques_id'] = $ques_id; $this->db->insert('exam_question', $data); $sql = "select q.ques_id,q.type,rc.difficulty from\n {pre}question q left join {pre}relate_class rc on q.ques_id=rc.ques_id\n where q.ques_id={$ques_id} and rc.grade_id={$exam['grade_id']} and rc.class_id={$exam['class_id']}"; $question = $this->db->query($sql)->row_array(); if (empty($question)) { $this->db->trans_rollback(); message('当前试卷中存在不属于当前考试期次年级的试题!请检查试题!'); exit; } /* 各个类型试题数量 */ $qtype_ques_num[$question['type']]++; /* 试题难易度 */ $question_difficulty[] = $question['difficulty']; } } /* 补全exam_pager信息 */ $data = array(); $data['exam_id'] = $exam_id; $data['qtype_ques_num'] = implode(',', $qtype_ques_num); $data['difficulty'] = array_sum($question_difficulty) / count($question_difficulty); PaperModel::update_paper($paper_id, $data); $this->db->trans_complete(); } } /* -------------------------------------- */ $inserts = array(); $sql = "SELECT p.paper_id,e.subject_id FROM {pre}exam_paper p,{pre}exam e\n WHERE p.exam_id=e.exam_id AND p.paper_id IN (" . my_implode($ids) . ")\n AND p.is_delete=0 AND p.exam_id={$exam_id}"; $query = $this->db->query($sql); foreach ($query->result_array() as $row) { $inserts[] = array('exam_pid' => $exam['exam_pid'], 'exam_id' => $exam['exam_id'], 'paper_id' => $row['paper_id'], 'subject_id' => $row['subject_id']); } $res = 0; if ($inserts) { // 关闭错误信息,防止 unique index 冲突出错 $this->db->db_debug = false; $this->db->insert_batch('exam_subject_paper', $inserts); $res = $this->db->affected_rows(); } $back_url = 'admin/subject_paper/add/' . $exam_id; if ($res < 1) { message('试卷添加失败', $back_url); } else { message('试卷添加成功', $back_url); } }
public function do_batch($act = '') { if (!$this->check_power('comparison_manage')) { return; } $act = trim($act); $type_id = (int) $this->input->post('type_id'); $ids = $this->input->post('ids'); $res = FALSE; if ($ids && is_array($ids)) { $ids = my_intval($ids); switch ($act) { case 'delete': case 'remove': $res = ComparisonInfoModel::delete($ids); admin_log('delete', 'comparison_info', implode(',', $ids)); break; default: break; } if ($res) { message('批量操作成功!', 'admin/comparison_info/index/' . $type_id); } else { message('批量操作失败!', 'admin/comparison_info/index/' . $type_id); } } else { message('请选择要删除的信息'); } }
public function insert() { if (!$this->check_power('exam_manage')) { return; } $place_id = (int) $this->input->post('place_id'); if ($place_id) { $query = $this->db->select('p.*,e.exam_name,e.exam_id,e.exam_pid,e.grade_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(array('p.place_id' => $place_id))->get(); $place = $query->row_array(); } if (empty($place)) { message('考场信息不存在', 'admin/exam/index'); return; } $ids = $this->input->post('ids'); if (empty($ids) or !is_array($ids)) { message('请至少选择一项'); return; } // 控制考场只能在未开始考试操作 $no_start = ExamPlaceModel::place_is_no_start($place_id); if (!$no_start) { message('该考场正在考试或已结束,无法做此操作'); } $ids = my_intval($ids); $school_id = (int) $this->input->post('school_id'); $inserts = array(); // 该考场所考到的学科 $subject_ids = array(); $query = $this->db->select('subject_id')->from('exam_place_subject')->where(array('place_id' => $place['place_id']))->get(); $subjects = $query->row_array(); $subject_ids = array(); foreach ($subjects as $subject) { $subject_ids[] = $subject['subject_id']; } $subject_ids = count($subject_ids) ? implode(',', $subject_ids) : '""'; $place['start_time'] = $place['start_time'] + 1; $place['end_time'] = $place['end_time'] - 1; $not_exists_sql = "SELECT uid FROM {pre}exam_place_student ps,{pre}exam_place p WHERE ps.place_id=p.place_id AND p.place_index={$place['place_index']} AND ps.uid=u.uid AND (((p.start_time >= {$place['start_time']} and p.start_time <= {$place['end_time']}) OR (p.end_time >= {$place['start_time']} and p.end_time <= {$place['end_time']}) OR (p.start_time <= {$place['start_time']} and p.end_time >= {$place['end_time']})) OR p.place_id IN(select distinct(place_id) from {pre}exam_place_subject eps where eps.subject_id in({$subject_ids}) and eps.exam_pid={$place['exam_id']}))"; $sql = "SELECT u.uid FROM {pre}student u\n WHERE u.school_id={$school_id} AND u.grade_id={$place['grade_id']} AND u.is_delete=0 AND u.uid IN(" . my_implode($ids) . ")\n AND NOT EXISTS({$not_exists_sql})"; $query = $this->db->query($sql); foreach ($query->result_array() as $row) { $inserts[] = array('place_id' => $place_id, 'uid' => $row['uid']); } // 添加学生时分配试卷 $this->load->model('cron/cron_place_student_paper_model', 'cron_place_student_paper_model'); $uids = array(); foreach ($inserts as $key => $val) { $uids[] = $val['uid']; $place_id = $val['place_id']; } $insert_data = array('place_id' => $place_id, 'uid_data' => json_encode($uids)); $this->cron_place_student_paper_model->insert($insert_data); // end $res = 0; if ($inserts) { // 关闭错误信息,防止 unique index 冲突出错 $this->db->db_debug = false; $this->db->insert_batch('exam_place_student', $inserts); $res = $this->db->affected_rows(); } $back_url = 'admin/place_student/add/manual/' . $place_id; if ($res < 1) { message('考生添加失败', $back_url); } else { message('考生添加成功', $back_url); } }
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); }
public function pwish_save() { //是否点击上一步触发 $go_prev = intval($this->input->get_post('go_prev')); $uid = $this->_uinfo['uid']; $parent_wish_arr = $this->input->post('parent_wish', TRUE); if (empty($parent_wish_arr)) { redirect('student/profile/pwish'); } if (!isset($parent_wish_arr['family_bg']) or !is_array($parent_wish_arr['family_bg'])) { $parent_wish_arr['family_bg'] = array(); } if (!isset($parent_wish_arr['upmethod'])) { $parent_wish_arr['upmethod'] = '其他'; } if (!isset($parent_wish_arr['upmethod_other'])) { $parent_wish_arr['upmethod_other'] = ''; } if (!isset($parent_wish_arr['other_bg']) or !in_array(99, $parent_wish_arr['family_bg'])) { $parent_wish_arr['other_bg'] = ''; } if (empty($parent_wish_arr['family_bg']) or empty($parent_wish_arr['upmethod']) or empty($parent_wish_arr['wish']) or in_array(99, $parent_wish_arr['family_bg']) && empty($parent_wish_arr['other_bg']) or $parent_wish_arr['upmethod'] == '其他' && empty($parent_wish_arr['upmethod_other'])) { if (!$go_prev) { message('请完整填写家长意愿'); } } else { $parent_wish = array('family_bg' => implode(',', my_intval($parent_wish_arr['family_bg'])), 'other_bg' => html_escape(trim($parent_wish_arr['other_bg'])), 'wish' => isset($parent_wish_arr['wish']) ? html_escape($parent_wish_arr['wish']) : '', 'upmethod' => html_escape($parent_wish_arr['upmethod'] == '其他' ? $parent_wish_arr['upmethod_other'] : $parent_wish_arr['upmethod'])); } $parent_wish['family_bg_qt'] = serialize($parent_wish_arr['family_bg_qt']); if ($uid) { $parent_wish['uid'] = $uid; $this->db->replace('student_parent_wish', $parent_wish); } else { $this->session->set_userdata('parent_wish', $parent_wish); } if ($go_prev) { redirect('student/profile/wish'); } if ($uid or $this->session->userdata('complete')) { message('家长意愿修改成功', 'student/profile/preview', 'success'); } else { redirect('student/profile/preview'); } }