/**
     * 
     * 通过 条件 获取监考人员帐号 记录列表
     * @param array $query
     * @param integer $page
     * @param integer $per_page
     * @param string $order_by
     * @param string $select_what
     * @param integer $place_id 当前考场
     * @param boolean $filter_assigned 是否过滤已分配的监考人员
     * 
     */
    public static function get_invigilator_list($query, $page = 1, $per_page = 20, $order_by = null, $select_what = '*', $place_id = 0, $filter_assigned = false)
    {
        try {
            $where = array();
            $bind = array();
            if (is_array($query) && count($query)) {
                foreach ($query as $key => $val) {
                    switch ($key) {
                        case 'invigilator_id':
                            if (is_array($val)) {
                                $tmpStr = array();
                                foreach ($val as $k => $v) {
                                    $tmpStr[] = '?';
                                    $bind[] = intval($v);
                                }
                                $tmpStr = implode(', ', $tmpStr);
                                $where[] = "i.invigilator_id IN ({$tmpStr})";
                            } else {
                                $where[] = 'i.invigilator_id = ?';
                                $bind[] = intval($val);
                            }
                            break;
                        case 'invigilator_email':
                            if (is_array($val)) {
                                foreach ($val as $k => $v) {
                                    $where[] = "i.invigilator_email {$k} ?";
                                    $bind[] = $v;
                                }
                            } else {
                                //$where[] = 'i.invigilator_email = ?';
                                //$bind[] = $val;
                                $where[] = 'invigilator_email like ?';
                                $bind[] = '%' . $val . '%';
                            }
                            break;
                        case 'invigilator_name':
                            if (is_array($val)) {
                                foreach ($val as $k => $v) {
                                    $where[] = "i.invigilator_name {$k} ?";
                                    $bind[] = $v;
                                }
                            } else {
                                // $where[] = 'i.invigilator_name = ?';
                                // $bind[] = $val;
                                $where[] = 'invigilator_name like ?';
                                $bind[] = '%' . $val . '%';
                            }
                            break;
                        case 'invigilator_flag':
                            if (is_array($val)) {
                                $tmpStr = array();
                                foreach ($val as $k => $v) {
                                    $tmpStr[] = '?';
                                    $bind[] = intval($v);
                                }
                                $tmpStr = implode(', ', $tmpStr);
                                $where[] = "i.invigilator_flag IN ({$tmpStr})";
                            } else {
                                $where[] = 'i.invigilator_flag = ?';
                                $bind[] = intval($val);
                            }
                            break;
                        case 'invigilator_addtime':
                            if (is_array($val)) {
                                foreach ($val as $k => $v) {
                                    $where[] = "i.invigilator_addtime {$k} ?";
                                    $bind[] = $v;
                                }
                            } else {
                                $where[] = 'i.invigilator_addtime = ?';
                                $bind[] = $val;
                            }
                            break;
                        case 'invigilator_updatetime':
                            if (is_array($val)) {
                                foreach ($val as $k => $v) {
                                    $where[] = "i.invigilator_updatetime {$k} ?";
                                    $bind[] = $v;
                                }
                            } else {
                                $where[] = 'i.invigilator_updatetime = ?';
                                $bind[] = $val;
                            }
                            break;
                        default:
                    }
                }
            }
            $where = count($where) ? " WHERE " . implode(' AND ', $where) : '';
            $order_by = !is_null($order_by) ? 'ORDER BY i.' . $order_by : '';
            $group_by = ' GROUP BY i.invigilator_id';
            $limit = '';
            $page = intval($page);
            if ($page > 0) {
                $per_page = intval($per_page);
                $start = ($page - 1) * $per_page;
                $limit = " LIMIT {$per_page} OFFSET {$start}";
            }
            //获取考场
            $place_id = intval($place_id);
            $table_name = 'rd_invigilator';
            if ($place_id > 0) {
                //$this->load->model('admin/exam_place_model');
                $place = ExamPlaceModel::get_place($place_id);
                $place['start_time'] = $place['start_time'] + 1;
                $place['end_time'] = $place['end_time'] - 1;
                $sub_sql = <<<EOT
SELECT DISTINCT(invigilator_id) 
FROM rd_exam_place_invigilator epi, rd_exam_place p 
WHERE (
(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']})
) 
AND p.place_id=epi.place_id
EOT;
                if ($filter_assigned) {
                    $sql = <<<EOT
SELECT {$select_what} FROM {$table_name} i 
{$where} AND invigilator_id NOT IN ({$sub_sql}) 
{$group_by} {$order_by} {$limit}
EOT;
                } else {
                    $sql = <<<EOT
SELECT {$select_what} FROM {$table_name} i, rd_exam_place_invigilator epi 
{$where} AND i.invigilator_id = epi.invigilator_id 
AND i.invigilator_id IN ({$sub_sql}) {$group_by} {$order_by} {$limit}
EOT;
                }
            } else {
                $sql = <<<EOT
SELECT {$select_what} FROM {$table_name} i 
{$where} {$group_by} {$order_by} {$limit}
EOT;
            }
            $data = Fn::db()->fetchAll($sql, $bind);
            return $data;
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }
 public function delete($id = 0)
 {
     if (!$this->check_power('exam_manage')) {
         return;
     }
     $id = intval($id);
     $place_id = (int) $this->input->post('place_id');
     if (!$id) {
         message('该条信息不存在');
         return;
     }
     $place = ExamPlaceModel::get_place($place_id);
     if (!count($place)) {
         message('考场信息不存在');
         return;
     }
     //控制考场只能在未开始考试操作
     //$no_start = ExamPlaceModel::place_is_no_start($place_id);
     //if (!$no_start) {
     //	message('该考场正在考试或已结束,无法做此操作');
     //}
     $back_url = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
     if (empty($back_url) && $place_id) {
         $back_url = 'admin/place_invigilator/index/' . $place_id;
     }
     $this->db->where('id', $id)->delete('exam_place_invigilator');
     message('删除成功', $back_url);
 }
Beispiel #3
0
 /**
  * 下载班级报告
  */
 public function down_class_report($rule_id = 0)
 {
     $rule_id = intval($rule_id);
     $rule_id && ($rule = EvaluateRuleModel::get_evaluate_rule($rule_id));
     if (empty($rule)) {
         message('不存在该评估规则');
     }
     $save_file = realpath(dirname(APPPATH)) . "/cache/down_class_report/" . $rule_id . '.zip';
     if (!file_exists($save_file)) {
         $place_id = $rule['place_id'];
         $schcls_ids = array();
         if ($place_id > 0) {
             $place = ExamPlaceModel::get_place($place_id);
             if ($place['place_schclsid']) {
                 $schcls_ids = array($place['place_schclsid']);
             }
         } else {
             $placelist = ExamPlaceModel::get_exam_place_list(array('exam_pid' => $rule['exam_pid']), 1, time());
             foreach ($placelist as $item) {
                 if ($item['place_schclsid']) {
                     $schcls_ids[] = $item['place_schclsid'];
                 }
             }
         }
         if (!$schcls_ids) {
             message('当前评估规则没有关联班级,无法下载班级报告!');
         }
         $cls_list = SchoolModel::schoolClassListInfo(implode(',', $schcls_ids));
         $dir_name = realpath(dirname(APPPATH)) . "/cache/down_class_report/" . $rule_id;
         if (!is_dir($dir_name)) {
             @mkdir($dir_name, 0777, true);
         }
         $pdf_dir = C('html2pdf_path') . '/zeming/report/';
         $pdf_ready = false;
         foreach ($schcls_ids as $cls_id) {
             $dir = $pdf_dir . "{$rule_id}/class_{$cls_id}";
             if (!is_dir($dir)) {
                 continue;
             }
             $pdf_ready = true;
             $cls_name = $cls_list[$cls_id]['schcls_name'];
             $f = @dir($dir);
             if ($f) {
                 while (false !== ($entry = $f->read())) {
                     if ($entry != '.' && $entry != '..') {
                         @copy($dir . '/' . $entry, $dir_name . '/' . $cls_name . '_' . $entry);
                     }
                 }
             }
         }
         if ($pdf_ready) {
             require_once APPPATH . 'libraries/Pclzip.php';
             $archive = new PclZip($save_file);
             //将文件进行压缩
             $archive->create($dir_name, PCLZIP_OPT_REMOVE_PATH, realpath(dirname(APPPATH)) . "/cache/down_class_report");
             $this->rm_dir($dir_name);
         } else {
             message('班级报告PDF文件还未生成,无法下载!');
         }
     }
     if (file_exists($save_file)) {
         $exam_name = ExamModel::get_exam($rule['exam_pid'], 'exam_name');
         $subject_name = '';
         if ($rule['subject_id'] > 0) {
             $subject_name = $this->_subject_name($rule['exam_pid'], $rule['subject_id']);
         }
         $filename = $exam_name . $subject_name . '班级报告';
         Func::dumpFile('application/zip', $save_file, $filename . '.zip');
     }
 }
Beispiel #4
0
 /**
  * 检查考场 配置信息
  *
  * @return  void
  */
 public function check_status($place_id = 0)
 {
     if (!$this->check_power('exam_manage')) {
         return;
     }
     $place_id = intval($place_id);
     $place_id && ($place = ExamPlaceModel::get_place($place_id));
     if (empty($place)) {
         message('考场不存在');
         return;
     }
     $message = array();
     /*
         	try {
         		$this->db->trans_start();
         		$sql = "DELETE FROM {pre}exam_subject_paper WHERE paper_id NOT IN(SELECT paper_id from {pre}exam_paper )";
         		$this->db->query($sql);
     
         		$this->db->trans_complete();
     
         	} catch(Exception $e) {
         		$this->db->trans_complete();
     
         	}
     */
     /*
      * todo:
      * 	检查是否已选择学科
      *  检查学科是否添加试卷
      *
      *  检查是否已添加考生
      *  检查是否已添加监考人员
      */
     //检查是否已选择学科
     $result = $this->db->query("select count(*) as count from {pre}exam_place_subject where place_id={$place_id} and exam_pid = {$place['exam_pid']}")->result_array();
     if (!$result[0]['count']) {
         $message[] = '未选择学科(<font color="red">请确认下该考场所在的考试期次下是否已添加 学科</font>)';
     } else {
         $result = $this->db->query("select count(*) as count from {pre}exam_place_subject where place_id={$place_id} and exam_pid = {$place['exam_pid']}")->result_array();
         $result2 = $this->db->query("select count(distinct(eps.exam_id)) as count from {pre}exam_place_subject eps, {pre}exam_subject_paper esp where eps.place_id={$place_id} and eps.exam_id=esp.exam_id and eps.exam_pid = {$place['exam_pid']}")->result_array();
         if ($result[0]['count'] > $result2[0]['count']) {
             $message[] = '有学科未选择试卷';
         }
         $result = $this->db->query("select count(*) as count,eps.subject_id,esp.paper_id from {pre}exam_place_subject eps, {pre}exam_subject_paper esp where eps.place_id={$place_id}\n\t    \t\tand eps.exam_pid = {$place['exam_pid']} and eps.exam_id=esp.exam_id and esp.paper_id not in(SELECT paper_id from {pre}exam_paper) group by esp.paper_id")->result_array();
         $subjects = C('subject');
         foreach ($result as $key => $val) {
             $message[] = '学科[' . $subjects[$val['subject_id']] . ']试卷ID【' . $val['paper_id'] . '】不存在';
         }
     }
     //检查是否已添加考生
     $result = $this->db->query("select count(*) as count from {pre}exam_place_student where place_id={$place_id}")->result_array();
     if (!$result[0]['count']) {
         $message[] = '未添加考生';
     }
     //检查是否已添加监考人员
     $result = $this->db->query("select count(*) as count from {pre}exam_place_invigilator where place_id={$place_id}")->result_array();
     if (!$result[0]['count']) {
         $message[] = '未添加监考人员';
     }
     if (count($message)) {
         message('<strong>检测到该考场有以下异常:<br/></strong>' . implode('<br/>', $message));
     }
     message('恭喜您,该考场配置信息均正常 :)');
 }
Beispiel #5
0
 /**
  * 编辑信息
  *
  * @param int $id
  * @return void
  */
 public function edit($id)
 {
     if (!$this->check_power('evaluate_rule_manage')) {
         return;
     }
     $data = array();
     $query = array('id' => $id);
     $detail = EvaluateRuleModel::get_evaluate_rule_list($query);
     if (!$id || !count($detail)) {
         message('不存在评估规则信息');
         return;
     }
     $detail = $detail[0];
     $detail['is_reportting'] = $this->rule_is_reportting($id);
     // 获取关联知识点
     $query = array('er_id' => $id);
     $knowledge_list = EvaluateRuleModel::get_evaluate_knowledge_list($query, null, null, null, null, true);
     // 按照 等级 归档
     $tmp_knowledge_list = array();
     foreach ($knowledge_list as $k => $v) {
         $subject_id = $k;
         foreach ($v as $i) {
             $knowledge_id = $i['knowledge_id'];
             $tmp_knowledge_list['s_' . $subject_id]['k_' . $knowledge_id]['l_' . $i['level']] = array('comment' => $i['comment'], 'suggest' => $i['suggest']);
         }
     }
     // 获取关联 方法策略
     $query = array('er_id' => $id);
     $method_tactic_list = EvaluateRuleModel::get_evaluate_method_tactic_list($query, null, null, null, null, true);
     $method_tactic_ids = array();
     foreach ($method_tactic_list as $val) {
         foreach ($val as $item) {
             $method_tactic_ids[] = $item['method_tactic_id'];
         }
     }
     $method_tactic_ids = array_filter($method_tactic_ids);
     $method_tactic_ids = array_unique($method_tactic_ids);
     $method_tactic_ids = count($method_tactic_ids) ? $method_tactic_ids : array(0);
     $method_tactic_ids = implode(',', $method_tactic_ids);
     $subject_category = $this->db->query("select sc.id as subject_category_id,mt.id as method_tactic_id, mt.name, scs.subject_id from {pre}method_tactic mt, {pre}subject_category_subject scs,{pre}subject_category sc where mt.subject_category_id=scs.subject_category_id and sc.id=scs.subject_category_id and mt.id in ({$method_tactic_ids})")->result_array();
     // 按照 等级 归档
     $tmp_method_tactic_list = array();
     foreach ($method_tactic_list as $k => $v) {
         $subject_id = $k;
         foreach ($v as $i) {
             $method_tactic_id = $i['method_tactic_id'];
             foreach ($subject_category as $item) {
                 if ($method_tactic_id == $item['method_tactic_id']) {
                     $tmp_method_tactic_list['sc_' . $item['subject_category_id']]['method_tactic_' . $method_tactic_id]['l_' . $i['level']] = array('comment' => $i['comment'], 'suggest' => $i['suggest']);
                     continue;
                 } else {
                     $tmp_method_tactic_list['s_' . $subject_id]['method_tactic_' . $method_tactic_id]['l_' . $i['level']] = array('comment' => $i['comment'], 'suggest' => $i['suggest']);
                 }
             }
         }
     }
     // 获取关联信息提取方式
     $query = array('er_id' => $id);
     $group_type_list = EvaluateRuleModel::get_evaluate_group_type_list($query, null, null, null, null, true);
     // 按照 等级 归档
     $tmp_group_type_list = array();
     foreach ($group_type_list as $k => $v) {
         $subject_id = $k;
         foreach ($v as $i) {
             $gr_id = $i['group_type_id'];
             $tmp_group_type_list['s_' . $subject_id]['gr_' . $gr_id]['l_' . $i['level']] = array('comment' => $i['comment'], 'suggest' => $i['suggest']);
         }
     }
     // 获取单人模式下被搜索考生
     $student = array();
     if ($detail['generate_mode'] == '1') {
         $student = StudentModel::get_student($detail['generate_uid']);
     }
     $detail['generate_u_keyword'] = count($student) ? $student['email'] : '';
     // 获取当前期次
     $exam = ExamModel::get_exam($detail['exam_pid'], 'exam_id, exam_name');
     $detail['exam_name'] = count($exam) ? $exam['exam_name'] : '该考试期次已经被删除';
     // 获取当前考场
     $place = ExamPlaceModel::get_place($detail['place_id'], 'place_id, place_name');
     $detail['place_name'] = is_array($place) && count($place) ? $place['place_name'] : ($detail['place_id'] == 0 ? '所有考场' : '该考场已经被删除');
     // 外部对比信息
     $comparison_info = unserialize($detail['comparison_info']);
     $comparison_info = is_array($comparison_info) ? $comparison_info : array();
     $detail['comparison_info'] = $comparison_info;
     $this->session->set_userdata(array('comparison_info' => $detail['comparison_info']));
     $data['detail'] =& $detail;
     $data['knowledge_list'] =& $tmp_knowledge_list;
     $data['method_tactic_list'] =& $tmp_method_tactic_list;
     $data['group_type_list'] =& $tmp_group_type_list;
     $data['comparison_types'] = $this->_get_comparison_info();
     $data['mode'] = 'edit';
     $data['comparison_levels'] = C('evaluate_comparison_level');
     $this->load->view('evaluate_rule/add', $data);
 }
Beispiel #6
0
 public function batch_delete()
 {
     if (!$this->check_power('exam_manage')) {
         return;
     }
     $ids = $this->input->post('ids');
     $place_id = (int) $this->input->post('place_id');
     if (empty($ids) or !is_array($ids)) {
         message('请至少选择一项');
         return;
     }
     $place = ExamPlaceModel::get_place($place_id);
     if (!count($place)) {
         message('考场信息不存在');
         return;
     }
     // 控制考场只能在未开始考试操作
     $no_start = ExamPlaceModel::place_is_no_start($place_id);
     if (!$no_start) {
         message('该考场正在考试或已结束,无法做此操作');
     }
     $back_url = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
     if (empty($back_url) && $place_id) {
         $back_url = 'admin/place_student/' . $place_id;
     }
     // 删除考试已分配的试卷
     $ids_array = array_filter(array_values($ids));
     $ids_string = implode(',', $ids_array);
     $sql = "select group_concat(uid) as uids from {pre}exam_place_student where id in({$ids_string})";
     $res = $this->db->query($sql)->row_array();
     $uids = $res['uids'];
     // 查询已分配的试卷编号组合
     $sql = "select  group_concat(etp_id) as etp_ids from {pre}exam_test_paper where uid in({$uids}) and place_id='{$place_id}' ";
     $res = $this->db->query($sql)->row_array();
     $etp_ids = $res['etp_ids'];
     if ($etp_ids) {
         // 删除试卷题目
         $sql = "delete from {pre}exam_test_paper_question where etp_id in({$etp_ids})";
         $this->db->query($sql);
         // 删除试卷答案
         $sql = "delete from {pre}exam_test_result where etp_id in({$etp_ids})";
         $this->db->query($sql);
     }
     // 删除试卷
     $sql = "delete from {pre}exam_test_paper where uid in({$uids}) and place_id={$place_id}";
     $this->db->query($sql);
     // end
     $this->db->where_in('id', $ids)->delete('exam_place_student');
     message('删除成功', $back_url);
 }