Ejemplo n.º 1
0
 public function batch_relate()
 {
     if (!$this->check_power('interview_question_manage')) {
         return;
     }
     $back_url = empty($_SERVER['HTTP_REFERER']) ? 'admin/interview_question/index' : $_SERVER['HTTP_REFERER'];
     $ids = $this->input->post('ids');
     if (empty($ids) or !is_array($ids)) {
         message('请选择要关联的项目!');
         return;
     }
     // 检查被关联试题
     $relate_ques_id = intval($this->input->post('relate_ques_id'));
     $relate_ques_id && ($relate_ques = QuestionModel::get_question($relate_ques_id));
     if (empty($relate_ques)) {
         message('被关联试题不存在。');
         return;
     }
     // 如果被关联试题无分组,则:创建分组,并把该试题加入关联
     $group_id = $relate_ques['group_id'];
     if (empty($group_id)) {
         $this->db->insert('relate_group', array('group_name' => $relate_ques_id));
         $group_id = $this->db->insert_id();
         $this->db->update('question', array('group_id' => $group_id), array('ques_id' => $relate_ques_id));
     }
     $success = $fail = 0;
     foreach ($ids as $id) {
         $num = $this->_relate($id, $group_id);
         if ($num > 0) {
             $success += $num;
         } else {
             $fail++;
         }
     }
     message('批量操作完成,成功关联:' . $success . ' 个,失败:' . $fail . ' 个。', $back_url);
 }
Ejemplo n.º 2
0
 public function validate_related()
 {
     $related = $this->input->post('related');
     $question = QuestionModel::get_question($related);
     $result = $question && $question['is_original'] == '2' ? 'true' : 'false';
     die($result);
 }
Ejemplo n.º 3
0
 /**
  * 学生答题详情
  *
  * @author TCG
  * @param int $uid 用户ID
  * @param int $etp_id 考场-试卷-学生关联表
  * @return void
  */
 public function detail($uid = 0, $etp_id = 0)
 {
     $sql = "select subject_id,exam_id from {pre}exam_test_paper where etp_id='{$uid}' ";
     $res = $this->db->query($sql)->row_array();
     $subject_id = $res['subject_id'];
     $exam_id = $res['exam_id'];
     $exam = $this->db->select('exam_id, subject_id, grade_id, class_id, total_score, qtype_score')->get_where('exam', array('exam_id' => $exam_id), 1)->row_array();
     $sql = "SELECT  q.type,etr.ques_id,etr.answer,etr.ques_subindex,etr.full_score,etr.test_score,etr.sub_ques_id \n                from {pre}exam_test_result etr\n                LEFT JOIN {pre}relate_class rc ON rc.ques_id=etr.ques_id AND rc.grade_id='{$exam['grade_id']}' AND rc.class_id='{$exam['class_id']}'\n                LEFT JOIn {pre}question q ON etr.ques_id = q.ques_id \n                where etp_id = ? and uid = ? order by rc.difficulty DESC,etr.ques_id ASC, q.sort ASC, etr.sub_ques_id";
     $query = $this->db->query($sql, array($uid, $etp_id));
     $sql = "SELECT paper_id FROM {pre}exam_test_paper WHERE etp_id='{$uid}' ";
     $res = $this->db->query($sql)->row_array();
     $paper_id = $res['paper_id'];
     $paper = PaperModel::get_paper_by_id($paper_id);
     $questions_arr = json_decode($paper['question_sort'], true);
     $questions_score = json_decode($paper['question_score'], true);
     if ($query->num_rows() > 0) {
         $sort = array();
         /* 重新排序 */
         if (is_array($questions_arr)) {
             foreach ($questions_arr as $v) {
                 foreach ($query->result_array() as $value) {
                     if ($v == $value['ques_id']) {
                         $sort[] = $value;
                     }
                 }
             }
         } else {
             $sort = $query->result_array();
         }
         $result = array();
         $result1 = array();
         foreach ($sort as $key => $row) {
             if ($row['sub_ques_id'] > 0) {
                 $result[$row['ques_id']][$row['sub_ques_id']]['answer'] = $row['answer'];
                 $result[$row['ques_id']][$row['sub_ques_id']]['full_score'] = $row['full_score'];
                 $result[$row['ques_id']][$row['sub_ques_id']]['test_score'] = $row['test_score'];
             } else {
                 $result[$row['ques_id']]['answer'] = $row['answer'];
                 $result[$row['ques_id']]['full_score'] = $row['full_score'];
                 $result[$row['ques_id']]['test_score'] = $row['test_score'];
             }
         }
         // 试题类型
         foreach ($result as $ques_id => $value) {
             $question['type'] = QuestionModel::get_question($ques_id, 'type');
             $result[$ques_id]['type'] = $question['type'];
             if (in_array($question['type'], array(1, 2, 3, 7, 9, 11, 10, 14))) {
                 if (in_array($question['type'], array(1, 2, 7, 14))) {
                     $answer = explode(',', $value['answer']);
                     $tmp_answer = array();
                     foreach ($answer as $k => $v) {
                         if (!$v) {
                             continue;
                         }
                         $option = QuestionModel::get_option($v);
                         if ($option) {
                             $tmp_answer[$k] = '<span>' . $option['option_name'] . '</span>';
                             if ($option['picture']) {
                                 $tmp_answer[$k] .= '<br/><img src="' . __IMG_ROOT_URL__ . $option['picture'] . '" />';
                             }
                         }
                     }
                     $result[$ques_id]['answer'] = $tmp_answer;
                 } else {
                     if (in_array($question['type'], array(3, 9))) {
                         $result[$ques_id]['answer'] = explode("\n", $value['answer']);
                     }
                 }
             } else {
                 foreach ($value as $sub_ques_id => $item) {
                     $sub_question['type'] = QuestionModel::get_question($sub_ques_id, 'type');
                     if (in_array($sub_question['type'], array(1, 2))) {
                         $answer = explode(',', $item['answer']);
                         $tmp_answer = array();
                         foreach ($answer as $k => $v) {
                             if (!$v) {
                                 continue;
                             }
                             $option = QuestionModel::get_option($v);
                             if ($option) {
                                 $tmp_answer[$k] = '<span>' . $option['option_name'] . '</span>';
                                 if ($option['picture']) {
                                     $tmp_answer[$k] .= '<br/><img src="' . __IMG_ROOT_URL__ . $option['picture'] . '" />';
                                 }
                             }
                         }
                         $result[$ques_id][$sub_ques_id]['answer'] = $tmp_answer;
                     } else {
                         if ($sub_question['type'] == 3) {
                             $result[$ques_id][$sub_ques_id]['answer'] = explode("\n", $item['answer']);
                         }
                     }
                 }
             }
             $groups[$question['type']]['list'][$ques_id] = $result[$ques_id];
         }
         $data['result'] = $groups;
     } else {
         die('暂无考生考试信息!');
     }
     $data['group_index'] = array('一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二', '十三', '十四');
     $this->load->view('exam_student_result/detail', $data);
 }
Ejemplo n.º 4
0
 /**
  * 批量取消审核
  *
  * @return void
  */
 public function batch_unshenhe()
 {
     $ids = $this->input->post('ids');
     if (empty($ids) or !is_array($ids)) {
         message('请选择要取消审核的题目!');
     }
     $success = $fail = 0;
     foreach ($ids as $id) {
         $be_tested = QuestionModel::question_has_test_action($id);
         $question = QuestionModel::get_question($id);
         if ($be_tested || !$this->has_question_check($question) || $question['is_original'] != 1 || $question['check'] != 1) {
             $fail++;
             continue;
         }
         $sql = "update {pre}question set `check`=0 where ques_id='{$id}'";
         $return = $this->db->query($sql);
         if ($return === true) {
             $liyo = 'unexamine';
             admin_log($liyo, 'question', $id);
             $success++;
         } else {
             $fail++;
         }
     }
     $back_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'admin/question_audit/index';
     message('批量操作完成,成功取消审核:' . $success . ' 个,失败:' . $fail . ' 个。', $back_url);
 }
Ejemplo n.º 5
0
 public function setexamrelatequestion($erq_examid, $erq_zmoss_examid)
 {
     $erq_examid = intval($erq_examid);
     $erq_zmoss_examid = intval($erq_zmoss_examid);
     $paper_id = intval(Fn::getParam('er_paperid'));
     $exam = ExamModel::get_exam($erq_examid);
     if (!$exam['exam_pid']) {
         message('请指定需要设置试题对应的考试学科!');
     }
     $examrelate = ZmossModel::examRelateInfo($erq_examid, $erq_zmoss_examid);
     if (!$examrelate) {
         message('此考试学科没有对应关系,无法设置试题关系!');
     }
     $zmossquestion = ZmossModel::examQuestionList($examrelate['er_zmoss_examid']);
     if (!$zmossquestion) {
         message('此考试学科对应阅卷系统的考试没有试题,无法设置试题关系!');
     }
     $paperlist = ExamPaperModel::examSubjectPaperList($erq_examid);
     if (!$paperlist) {
         message('此考试学科没有设置考试试卷,无法设置试题关系!');
     }
     if ($paper_id) {
         $paper = $paperlist[$paper_id];
     }
     if (!$paper) {
         $paper = current($paperlist);
     }
     /*
     $paperquestion = ExamPaperModel::examPaperQuestion(
         $paper['paper_id'], 'q.ques_id, q.parent_id, q.type, IFNULL(pq.type, q.type) AS p_type', 
         'AND q.is_parent = 0', 'ORDER BY p_type ASC, q.parent_id ASC, q.ques_id ASC');
     */
     $question = json_decode($paper['question_sort'], true);
     $paperquestion = array();
     foreach ($question as $k => $ques_id) {
         $info = QuestionModel::get_question($ques_id);
         $list = QuestionModel::get_children($ques_id);
         if ($list) {
             foreach ($list as $key => $val) {
                 $paperquestion[$val['ques_id']] = array('ques_id' => $val['ques_id'], 'type' => $info['type'], 'parent_id' => $ques_id);
             }
         } else {
             $paperquestion[$ques_id] = array('ques_id' => $ques_id, 'type' => $info['type']);
         }
     }
     $examrelatequestion = ZmossModel::examRelateQuestionInfo($erq_examid, $erq_zmoss_examid, $paper['paper_id']);
     $erq_relate_data = array();
     if ($examrelatequestion) {
         $erq_relate_data = json_decode($examrelatequestion['erq_relate_data'], true);
     }
     $data['examrelatequestion'] = $erq_relate_data;
     $data['examrelate'] = $examrelate;
     $data['paperquestion'] = $paperquestion;
     $data['zmossquestion'] = $zmossquestion;
     $data['qtype'] = C('qtype');
     $data['paperlist'] = $paperlist;
     $this->load->view('zmoss/setexamrelatequestion', $data);
 }
Ejemplo n.º 6
0
    /**
     * 一键更新试题缓存
     *
     * @author TCG
     * @param int $exam_id 考试期次科目id
     * @return mixed 返回成功及失败提示
     */
    public function update_questions_cache($exam_id)
    {
        $exam_id = (int) $exam_id;
        $exam = Fn::db()->fetchRow("SELECT exam_id, exam_pid, subject_id, grade_id, class_id, total_score, qtype_score FROM rd_exam WHERE exam_id=?", $exam_id);
        if (empty($exam)) {
            return false;
        }
        $is_mini_test = ExamModel::is_mini_test($exam['exam_pid']);
        /** 载入缓存功能 */
        if ($is_mini_test) {
            $this->load->driver('cache');
            /** 缓存时间 单位second 默认缓存30天 */
            $cache_time = 24 * 3600 * 20;
        } else {
            $cache = Fn::factory('File');
        }
        /** 写入缓存 */
        $is_mini_test && $this->cache->file->save('get_paper_question_detail_p_exam_' . $exam_id, $exam, $cache_time);
        $sql = "SELECT paper_id FROM rd_exam_paper WHERE exam_id={$exam_id}";
        $rows = Fn::db()->fetchAll($sql);
        foreach ($rows as $row) {
            /** 写入缓存 */
            $is_mini_test && $this->cache->file->save('get_paper_question_detail_p_exam_id_' . $row['paper_id'], $exam_id, $cache_time);
            $question_sort = Fn::db()->fetchOne('SELECT question_sort FROM rd_exam_paper
                WHERE paper_id = ?', array($row[paper_id]));
            $question_sort = json_decode($question_sort, true);
            $sql = <<<EOT
    SELECT q.ques_id,q.type,q.title,q.score_factor,rc.difficulty
    FROM rd_exam_question eq
    LEFT JOIN rd_question q ON eq.ques_id=q.ques_id
    LEFT JOIN rd_relate_class rc ON rc.ques_id = q.ques_id AND rc.grade_id = ? AND rc.class_id = ?
    WHERE eq.paper_id = ? ORDER BY rc.difficulty DESC,q.ques_id ASC
EOT;
            if ($question_sort) {
                $res = Fn::db()->fetchAssoc($sql, array($exam['grade_id'], $exam['class_id'], $row['paper_id']));
                $sort = explode(',', $question_sort);
                $result = array();
                foreach ($question_sort as $ques_id) {
                    $result[] = $res[$ques_id];
                    unset($res[$ques_id]);
                }
            } else {
                $result = Fn::db()->fetchAll($sql, array($exam[grade_id], $exam[class_id], $row[paper_id]));
            }
            $key = 'get_paper_question_detail_p_' . $exam[grade_id] . '_' . $exam[class_id] . '_' . $row[paper_id];
            !$is_mini_test && $cache->save('/zmexam/' . $key, $result);
            /** 写入缓存 */
            $is_mini_test && $this->cache->file->save($key, $result, $cache_time);
        }
        //$domain=C('memcache_pre');
        /** 获取考试期次所有试题 */
        $sql = "SELECT ques_id FROM {pre}exam_question WHERE exam_id={$exam_id}";
        $query = $this->db->query($sql);
        $rows = $query->result_array();
        /** 生成缓存 (执行时间可能过长) */
        if (count($rows) > 0 && !empty($rows)) {
            $questions = array();
            /** 获取试题数据 */
            foreach ($rows as $key => $value) {
                $question = QuestionModel::get_question($value['ques_id'], 'ques_id, type, title, picture, parent_id,subject_id');
                if (!$question) {
                    continue;
                }
                /** 题组 */
                if (in_array($question['type'], array(0, 4, 5, 6, 8))) {
                    $pid = $question['ques_id'];
                    $sql = "SELECT ques_id,type,title,picture,parent_id,subject_id FROM {pre}question WHERE parent_id={$pid}";
                    $query = $this->db->query($sql);
                    $group_rows = $query->result_array();
                    /** 写入题组子题 */
                    $question['children'] = $group_rows;
                    /** 子题加入缓存列表 */
                    $questions = array_merge($questions, $group_rows);
                }
                $questions[] = $question;
            }
            foreach ($questions as $key => &$question) {
                /** 样式修正 */
                $question['title'] && $this->_format_question_content($question['ques_id'], $question['title'], in_array($question['type'], array(3, 9)));
                /** 获取试题选项数据(选择题) */
                if (in_array($question['type'], array(1, 2, 7, 14))) {
                    $question['options'] = QuestionModel::get_options($question['ques_id']);
                }
                /** 获取题组子题选项 */
                if (in_array($question['type'], array(0, 4, 5, 6, 8)) && !empty($question['children'])) {
                    foreach ($question['children'] as $k => &$v) {
                        $v['title'] && $this->_format_question_content($v['ques_id'], $v['title'], $v['type'] == 3);
                        $question['children'][$k]['options'] = QuestionModel::get_options($v['ques_id']);
                    }
                }
                !$is_mini_test && $cache->save('/zmexam/question_' . $question['ques_id'], $question);
                /** 写入缓存 */
                $is_mini_test && $this->cache->file->save($question['ques_id'], $question, $cache_time);
            }
            /** 成功提示页面 */
            message('生成成功.', 'admin/exam/index');
        } else {
            /** 失败提示页面 */
            message('生成失败!!!请尝试从新输入!', 'admin/exam/index');
        }
        /** $this->output->enable_profiler(TRUE); */
    }
Ejemplo n.º 7
0
 public function update_combination()
 {
     if (!$this->check_power('question_manage')) {
         return;
     }
     $act = $this->input->post('act');
     $act = $act == 'add' ? $act : 'edit';
     if ($act == 'edit') {
         $ques_id = $this->input->post('ques_id');
         if (!QuestionModel::check_question_power($ques_id, 'w')) {
             return;
         }
         $ques_id && ($old_question = QuestionModel::get_question($ques_id));
         if (empty($old_question)) {
             message('题组不存在');
             return;
         }
         $be_tested = QuestionModel::question_has_test_action($ques_id);
         if ($be_tested) {
             message('该试题已经被考生考过 或者 正在被考, 无法操作');
         }
     }
     // 题目基本信息
     $class_ids = $this->input->post('class_id');
     $skill_ids = $this->input->post('skill_id');
     $knowledge_ids = $this->input->post('knowledge_id');
     $difficulty = $this->input->post('difficulty');
     $subject_types = $this->input->post('subject_type');
     $question['type'] = 15;
     $question['test_way'] = array_sum($this->input->post('test_way'));
     $question['subject_id'] = intval($this->input->post('subject_id'));
     $question['start_grade'] = intval($this->input->post('start_grade'));
     $question['end_grade'] = intval($this->input->post('end_grade'));
     $question['title'] = trim($this->input->post('title'));
     $question['is_original'] = intval($this->input->post('is_original'));
     $question['exam_year'] = intval($this->input->post('exam_year'));
     $question['remark'] = trim($this->input->post('remark'));
     $question['related'] = intval($this->input->post('related'));
     $question['simulation'] = trim($this->input->post('simulation'));
     $file_save_path = $this->input->post('file_save_path');
     if ($question['subject_id'] == 11) {
         $question['subject_id_str'] = ',' . implode(',', $this->input->post('subject_str')) . ',';
     } else {
         $question['subject_id_str'] = ',' . $question['subject_id'] . ',';
     }
     $extends = array('difficulty' => &$difficulty, 'class_ids' => &$class_ids, 'skill_ids' => &$skill_ids, 'knowledge_ids' => &$knowledge_ids, 'subject_types' => &$subject_types);
     $message = $this->_check_question($question, $extends, false, false);
     if ($message) {
         // 删除已上传试题图片
         if (!empty($question['picture'])) {
             @unlink(_UPLOAD_ROOT_PATH_ . $question['picture']);
         }
         message(implode('<br/>', $message), null, null, 10);
         return;
     }
     if ($act == 'add') {
         $extends['group_id'] = intval($this->input->post('relate_group'));
         $extends['relate_ques_id'] = intval($this->input->post('relate_ques_id'));
         $ques_result = QuestionModel::add_group($question, $extends);
     } else {
         $question['ques_id'] = $ques_id;
         $ques_result = QuestionModel::update_group($question, $extends);
     }
     //清理试题文件
     $ques_id = $ques_result['ques_id'];
     $this->clear_question_file($ques_id, $file_save_path);
     if ($ques_result['success'] == TRUE) {
         message('试题题编辑成功。', 'admin/question/combination/' . $ques_result['ques_id']);
         return;
     } else {
         message($ques_result['msg']);
         return;
     }
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 /**
  * 试卷中试题管理
  *
  * @return void
  **/
 public function question_manage($paper_id)
 {
     /* 查询试卷信息 */
     $paper = PaperModel::get_paper_by_id($paper_id);
     $admin_info = $this->session->all_userdata();
     if (empty($paper)) {
         message('参数错误,请重试!');
     }
     if ($paper['admin_id'] != $admin_info['admin_id'] && !$admin_info['is_super']) {
         message('你没有该试卷的权限!');
     }
     /* 查询试题信息 调取试题相关信息 */
     $questions = array();
     $qtypes = C('qtype');
     $subjects = C('subject');
     $question_sort = json_decode($paper['question_sort'], true);
     $question_score = json_decode($paper['question_score'], true);
     if (!empty($question_sort)) {
         foreach ($question_sort as $key => &$value) {
             /*
             $sql = "SELECT count(*) as 'c' FROM rd_exam_question WHERE ques_id=?
                      AND paper_id=?";
             $res = Fn::db()->fetchOne($sql,array($value,$paper_id));
             if(!$res['c'])
             {
                 unset($value);
                 continue;
             }
             */
             $questions[$key] = QuestionModel::get_question($value);
             $questions[$key]['title'] = strip_tags($questions[$key]['title']);
             $questions[$key]['qtype'] = isset($qtypes[$questions[$key]['type']]) ? $qtypes[$questions[$key]['type']] : '';
             $questions[$key]['subject_name'] = isset($subjects[$questions[$key]['subject_id']]) ? $subjects[$questions[$key]['subject_id']] : '';
             $questions[$key]['addtime'] = date('Y-m-d H:i', $questions[$key]['addtime']);
             $questions[$key]['score'] = $question_score[$value];
             /* 获取试题添加者信息 */
             $admin_id = $questions[$key]['admin_id'];
             $sql = "select admin_id,admin_user,realname from {pre}admin where admin_id={$admin_id}";
             $questions[$key]['admin_info'] = $this->db->query($sql)->row_array();
         }
     } else {
         $questions = array();
     }
     $data = array();
     $data['paper_id'] = $paper_id;
     $data['paper'] = $paper;
     $data['questions'] = $questions;
     $data['has_tested'] = $this->is_super_user() ? false : ExamPlaceSubjectModel::exam_subject_has_test_action($paper['exam_id']);
     $this->load->view('paper_diy/question_manage', $data);
 }