/** * 阅读填空 * * @return void */ public function blank($parent_id = 0) { // 读取题干信息 $parent_id = intval($parent_id); $this->examine_permission($parent_id); $parent_id && ($parent = QuestionModel::get_question($parent_id)); if (empty($parent) or !$parent['is_parent']) { message('阅读填空题不存在!'); return; } //判断该试题已经被考试过 或 正在被考 $parent['be_tested'] = QuestionModel::question_has_test_action($parent_id); $grades = C('grades'); $qtypes = C('qtype'); $subjects = CpUserModel::get_allowed_subjects(); $subject_types = C('subject_type'); $group_type = GroupTypeModel::get_group_type_list(0, $parent['subject_id'], false, true); // 类型、学科属性(文理科)、难易度 $class_list = ClassModel::get_class_list(); $show_subject_type = $parent['subject_id'] <= 3 && $parent['end_grade'] >= 11; $class_names = array(); $query = $this->db->get_where('relate_class', array('ques_id' => $parent_id)); foreach ($query->result_array() as $arr) { $subject_type = $show_subject_type ? ' , ' . $subject_types[$arr['subject_type']] : ''; $class_names[$arr['grade_id']][] = isset($class_list[$arr['class_id']]['class_name']) ? $class_list[$arr['class_id']]['class_name'] . '[难易度:' . $arr['difficulty'] . $subject_type . ']' : ''; } $parent['class_names'] = $class_names; $parent['start_grade'] = isset($grades[$parent['start_grade']]) ? $grades[$parent['start_grade']] : ''; $parent['end_grade'] = isset($grades[$parent['end_grade']]) ? $grades[$parent['end_grade']] : ''; $parent['subject_name'] = isset($subjects[$parent['subject_id']]) ? $subjects[$parent['subject_id']] : ''; $parent['addtime'] = date('Y-m-d H:i', $parent['addtime']); $parent['title'] = str_replace("\n", '<br/>', $parent['title']); //$parent['title'] = str_replace(" ", ' ', $parent['title']); /** ---------------- 真题 ----------------- */ if ($parent['is_original'] == 2) { $relateds = $this->db->query("select ques_id from {pre}question where related={$parent_id}")->result_array(); if (count($relateds) > 0) { $parent['relateds'] = $relateds; } } elseif ($parent['related']) { $related = $parent['related']; $relateds = $this->db->query("select ques_id from {pre}question where related={$related}")->result_array(); if (count($relateds) > 0) { $parent['relateds'] = $relateds; } } $cpusers = CpUserModel::get_cpuser_list(); // 读取子题信息 $query = $this->db->select()->get_where('question', array('parent_id' => $parent_id, 'is_delete' => 0)); $list = $query->result_array(); foreach ($list as &$row) { $row['cpuser'] = isset($cpusers[$row['admin_id']]['realname']) ? $cpusers[$row['admin_id']]['realname'] : ''; $row['addtime'] = date('Y-m-d H:i:s', $row['addtime']); $query = $this->db->get_where('option', array('ques_id' => $row['ques_id'])); $row['options'] = $query->result_array(); // 知识点 $query = $this->db->select('k.knowledge_name, rk.knowledge_id, rk.know_process')->from('relate_knowledge rk')->join('knowledge k', 'rk.knowledge_id=k.id', 'left')->where_in('rk.ques_id', $row['ques_id'])->get(); $knowledge_arr = array(); foreach ($query->result_array() as $arr) { $knowledge_arr[] = $arr['knowledge_name'] . '(认知过程:' . C('know_process/' . $arr['know_process']) . ')'; } $row['knowledge_name'] = count($knowledge_arr) ? implode(',', $knowledge_arr) : '<font style="font-size:15px;color:red;">该子题还未添加知识点</font>'; } // 读取子题信息(已删除) $query = $this->db->select()->get_where('question', array('parent_id' => $parent_id, 'is_delete' => 1)); $list2 = $query->result_array(); foreach ($list2 as &$row) { $row['cpuser'] = isset($cpusers[$row['admin_id']]['realname']) ? $cpusers[$row['admin_id']]['realname'] : ''; $row['addtime'] = date('Y-m-d H:i:s', $row['addtime']); } $data['qtypes'] = $qtypes; $data['grades'] = $grades; $data['q_tags'] = C('q_tags/8'); $data['parent'] = $parent; $data['list'] = $list; $data['list2'] = $list2; $data['group_type'] = $group_type; $data['priv_manage'] = true; $data['priv_delete'] = true; // 模版 $this->load->view('question_external/blank', $data); }
public function group_type_init() { $group_type_ids = trim($this->input->post('group_type_ids')); $subject_id = intval($this->input->post('subject_id')); if ($subject_id && $group_type_ids) { $group_type_ids = explode(',', $group_type_ids); // 使用Yaf样式GroupTypeModel代替 $list = GroupTypeModel::get_group_type_list(0, $subject_id); foreach ($list as $key => $val) { if (empty($group_type_ids)) { unset($list[$key]); continue; } $new_children = array(); $children = GroupTypeModel::get_group_type_list($val['id'], $subject_id); foreach ($group_type_ids as $k => $v) { if (isset($children[$v])) { $new_children[] = $children[$v]; unset($group_type_ids[$k]); } } if ($new_children) { $list[$key]['children'] = $new_children; } else { unset($list[$key]); } } } else { $list = array(); } echo json_encode(array_values($list)); }
private function _delete($id) { $id = intval($id); $item = GroupTypeModel::get_group_type($id); if (empty($item)) { // 知识点不存在 return -1; } $query = $this->db->select('count(*) num')->get_where('group_type', array('pid' => $id)); $row = $query->row_array(); if ($row['num']) { //该信息提取方式还存在下级分类; return -2; } $query = $this->db->select('count(*) num')->get_where('relate_group_type', array('group_type_id' => $id, 'is_child' => 0)); $row = $query->row_array(); if ($row['num']) { //该信息提取方式还存在关联试题; return -3; } if (!QuestionModel::check_subject_power($item['subject_id'], 'w', false)) { //没有权限 return -4; } try { $this->db->delete('group_type', array('id' => $id)); admin_log('delete', 'group_type', $id); } catch (Exception $e) { return FALSE; } return TRUE; }
/** * 试卷试题列表未加入期次 * * @param int $paper_id 试卷id * @param int $qtype 题型 * @param int $method_tactic_id 方法策略 * @param int $kid 知识点 * @return void */ public function index3($paper_id = 0) { if (!$this->check_power('exam_list,exam_manage,paper_diy')) { return; } $paper_id = intval($paper_id); $paper = ExamPaperModel::get_paper($paper_id); if (!empty($paper['question_sort'])) { $paper = ExamPaperModel::detail_sg($paper_id, 1, 1); } $paper['ques_ids'] = json_decode($paper['question_sort'], true); $ques_ids_str = implode(',', $paper['ques_ids']); if (empty($paper)) { message('试卷不存在'); return; } /* * 考试期次 */ $exam = ExamModel::get_exam($paper['exam_id'], 'exam_pid,grade_id,class_id'); $search = $where = $param = array(); if (!empty($paper['question_sort'])) { $where[] = "1=1"; } $qtypes = C('qtype'); $qtype = $this->input->get('qtype'); if (strlen($qtype)) { $qtype = abs(intval($qtype)); $where['qtype'] = "q.type={$qtype}"; $param[] = "qtype={$qtype}"; } $search['qtype'] =& $qtype; /** is_original */ $is_original = $this->input->get('is_original'); if (in_array($is_original, array(1, 2))) { $where['is_original'] = "q.is_original={$is_original}"; $param[] = "is_original={$is_original}"; } $search['is_original'] =& $is_original; //方法逻辑 $method_tactic_id = intval($this->input->get('method_tactic_id')); if ($method_tactic_id) { $where['method_tactic_id'] = "q.ques_id IN (SELECT\n DISTINCT rmt.ques_id FROM {pre}relate_method_tactic rmt\n WHERE rmt.ques_id in({$ques_ids_str})\n AND rmt.method_tactic_id={$method_tactic_id})"; $param[] = "method_tactic_id={$method_tactic_id}"; } $search['method_tactic_id'] =& $method_tactic_id; //知识点 if ($kid = intval($this->input->get('kid'))) { $pkid = KnowledgeModel::get_knowledge($kid, 'pid'); if ($pkid !== false) { if ($pkid == 0) { // 一级知识点 $k_children = KnowledgeModel::get_knowledge_list(0, $kid, 0); $where['knowledge'] = "q.ques_id IN (\n SELECT DISTINCT rk.ques_id FROM {pre}relate_knowledge rk\n WHERE rk.ques_id in({$ques_ids_str}) AND rk.knowledge_id\n IN (" . my_implode(array_keys($k_children)) . ") AND rk.is_child=0)"; } else { // 二级知识点 if (!empty($paper['question_sort'])) { $where['knowledge'] = "q.ques_id IN (SELECT DISTINCT rk.ques_id FROM {pre}relate_knowledge\n rk WHERE rk.ques_id in({$ques_ids_str}) AND rk.knowledge_id={$kid} AND rk.is_child=0)"; } } $param[] = "kid={$kid}"; } } $search['kid'] =& $kid; /* 信息提取方式 */ if ($gid = intval($this->input->get('group_type_id'))) { $pgid = GroupTypeModel::get_group_type($gid, 'pid'); if ($pgid !== false) { if ($pgid == 0) { $g_children = GroupTypeModel::get_group_type_list($gid, 0); if (!empty($paper['question_sort'])) { $where['group_type'] = "q.ques_id IN ( SELECT DISTINCT\n rk.ques_id FROM {pre}relate_group_type rk WHERE\n rk.ques_id in({$ques_ids_str}) AND rk.group_type_id\n IN (" . my_implode(array_keys($g_children)) . ") AND rk.is_child=0)"; } } else { if (!empty($paper['question_sort'])) { $where['group_type'] = "q.ques_id IN (\n SELECT DISTINCT rk.ques_id FROM {pre}relate_group_type rk\n WHERE rk.ques_id in({$ques_ids_str})\n AND rk.group_type_id={$gid} AND rk.is_child=0)"; } } $param[] = "group_type_id={$gid}"; } } $search['group_type_id'] =& $gid; if (!empty($paper['question_sort'])) { $total = count($paper['question_sort']); } $size = 150; $page = isset($_GET['page']) && intval($_GET['page']) > 1 ? intval($_GET['page']) : 1; $offset = ($page - 1) * $size; $list = array(); if ($total) { $sql = "SELECT q.ques_id,q.title,q.type,q.group_id,q.addtime,\n (SELECT AVG(rc.difficulty) FROM {pre}relate_class rc where rc.ques_id=q.ques_id) AS difficulty\n FROM {pre}question q WHERE q.ques_id in({$ques_ids_str})\n AND " . implode(' AND ', $where) . " LIMIT {$offset},{$size}"; $res = $this->db->query($sql); foreach ($res->result_array() as $row) { $row['qtype'] = isset($qtypes[$row['type']]) ? $qtypes[$row['type']] : ''; $row['addtime'] = date('Y-m-d H:i', $row['addtime']); $row['has_edit_power'] = QuestionModel::check_question_power($row['ques_id'], 'w', false); $row['difficulty'] = round($row['difficulty'], 2); $list[] = $row; } } // 分页 $purl = site_url('admin/exam_question/index3/' . $paper_id . '/') . ($param ? '?' . implode('&', $param) : ''); $data['pagination'] = multipage($total, $size, $page, $purl); // 按题型分组统计数量 $qtype_nums = array(0, 0, 0, 0); foreach (explode(',', $paper['qtype_ques_num']) as $k => $v) { $qtype_nums[$k] = $v; } //判断该试题已经被考试过 或 正在被考 $paper['be_tested'] = false; if (!ExamModel::is_mini_test($exam['exam_pid'])) { $paper['be_tested'] = QuestionModel::paper_has_test_action($paper_id); } $data['search'] = $search; $data['qtypes'] = $qtypes; $data['paper'] = $paper; $data['list'] = $list; $data['qtype_nums'] = $qtype_nums; $data['priv_manage'] = $this->check_power('exam_manage', FALSE); /* 是否有权限查看试卷列表 */ $is_exam_paper_list = $this->check_power('exam_list', false); $data['is_exam_paper_list'] = $is_exam_paper_list; // 模版 $this->load->view('exam_question/index3', $data); }
public function edit($id = 0) { if (!$this->check_power('comparison_manage')) { return; } $id = intval($id); //$sql = "select * from rd_comparison_info where cmp_info_id=3"; //$res = mysql_query($sql, $this->db->conn_id); //pr(mysql_fetch_array($res)); $id && ($info_detail = ComparisonInfoModel::get_comparison_info_by_id($id)); if (empty($info_detail)) { message('信息不存在'); } $info_detail['cmp_extraction_ratio'] = json_decode($info_detail['cmp_extraction_ratio'], true); $type_detail = ComparisonTypeModel::get_comparison_type_by_id($info_detail['cmp_type_id']); //$this->load->library('Fn'); $db = Fn::db(); $res = $db->fetchCol('SELECT DISTINCT subject_id FROM rd_subject_category_subject'); $type_detail['subject_ids'] = $res; //$result = $this->db->query('SELECT group_concat(DISTINCT subject_id) as subject_ids FROM {pre}subject_category_subject')->row_array(); //$type_detail['subject_ids'] = explode(',', $result['subject_ids']); if (empty($type_detail)) { message('分类信息不存在'); } else { $type_detail['class_name'] = ClassModel::get_question_class_by_id($type_detail['class_id'], 'class_name'); $type_detail['grade_name'] = C('grades/' . $type_detail['grade_id']); $type_detail['subject_name'] = C('subject/' . $type_detail['subject_id']); } $items = ComparisonInfoModel::get_comparison_items($id, TRUE); $items2 = ComparisonInfoModel::get_comparison_items2($id, TRUE); //外部知识点与对比信息关系 $external_items = ComparisonInfoModel::get_comparison_items_external($id, TRUE); // 一级知识点 $knowledge_list = KnowledgeModel::get_knowledge_list($type_detail['subject_id'], 0, false); ksort($knowledge_list); //信息提取方式 $group_type_list = array(); if ($type_detail['subject_id'] == 3) { $group_type_list = GroupTypeModel::get_group_type_list(0, $type_detail['subject_id'], false); ksort($group_type_list); } //对比项《难易度》 $item_difficulties = ComparisonInfoModel::get_comparison_items_difficutly($id, TRUE); //对比项《外部题型 难易度》 $item_external_difficulties = ComparisonInfoModel::get_comparison_items_external_difficutly($id, TRUE); //方法策略 $method_tactic_list = SubjectCategoryModel::get_method_tactic_by_subject_id($type_detail['subject_id']); ksort($method_tactic_list); //对比项《方法策略》 $item_method_tactics = ComparisonInfoModel::get_comparison_items_method_tactic($id, TRUE); //对比项《外部方法策略》 $external_method_tactics = ComparisonInfoModel::get_comparison_items_external_method_tactic($id, TRUE); $data['act'] = 'edit'; $data['type_detail'] =& $type_detail; $data['info_detail'] =& $info_detail; $data['items'] =& $items; $data['items2'] =& $items2; $data['external_items'] =& $external_items; $data['knowledge_list'] =& $knowledge_list; $data['group_type_list'] =& $group_type_list; $data['item_difficulties'] =& $item_difficulties; $data['item_external_difficulties'] =& $item_external_difficulties; $data['method_tactic_list'] =& $method_tactic_list; $data['item_method_tactics'] =& $item_method_tactics; $data['external_method_tactics'] =& $external_method_tactics; $data['q_types'] = C('q_type'); //试题题型 $data['difficulty_types'] = array('2' => '高', '1' => '中', '0' => '低'); //试题题型 // 模版 $this->load->view('comparison_info/edit', $data); }