Beispiel #1
0
 /**
  * 根据考试期次获取考场信息
  *
  * @param number $exam_pid
  * @return void
  */
 public function ajax_get_exam_place($exam_pid = 0, $place_id = 0)
 {
     $exam_pid = intval($exam_pid);
     if (!$exam_pid) {
         die;
     }
     $query = array('exam_pid' => $exam_pid);
     $select_what = 'place_id, place_name, start_time, end_time';
     $order_by = 'end_time asc';
     $places = ExamPlaceModel::get_exam_place_list($query, false, false, $order_by, $select_what);
     $now = time();
     $output = array();
     $output[] = '<option value="0">--请选择考试场次--</option>';
     foreach ($places as $place) {
         $place_name = $place['place_name'];
         $t_place_id = $place['place_id'];
         $start_time = $place['start_time'];
         $end_time = $place['end_time'];
         $status = '';
         if ($now < $start_time) {
             $status = '(未开始)';
         } elseif ($now >= $start_time && $now < $end_time) {
             $status = '(进行中)';
         } elseif ($now >= $end_time) {
             $status = '(已结束)';
         }
         $output[] = "<option value='{$t_place_id}'" . ($place_id == $t_place_id ? 'selected="selected"' : '') . ">{$place_name}{$status}</option>";
     }
     echo implode('', $output);
     die;
 }
Beispiel #2
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 #3
0
 /**
  * 设置MINI测配置
  */
 public function save_config()
 {
     $dec_id = intval($this->input->post('dec_id'));
     $dec_name = trim($this->input->post('dec_name'));
     $grade_id = intval($this->input->post('grade_id'));
     $exam_pid = intval($this->input->post('exam_pid'));
     if (empty($dec_name)) {
         message('名称不能为空');
     }
     if ($grade_id < 1 || $grade_id > 12) {
         message('年级不合法');
     }
     if ($exam_pid < 1) {
         message('考试期次不存在');
     }
     $config = DemoConfigModel::get_demo_config($dec_id);
     if ($config && $config['dec_grade_id'] == $grade_id && $config['dec_exam_pid'] == $exam_pid) {
     } else {
         if ($config && $config['dec_grade_id'] == $grade_id && $config['dec_exam_pid'] != $exam_pid) {
             $param = array('exam_pid' => $exam_pid);
             if (DemoConfigModel::check_config_exist($param)) {
                 message('考试期次已经在配置中设置过了');
             }
         } else {
             if ($config && $config['dec_grade_id'] != $grade_id && $config['dec_exam_pid'] == $exam_pid) {
                 $param = array('grade_id' => $grade_id);
                 if (DemoConfigModel::check_config_exist($param)) {
                     message('年级已经在配置中设置过了');
                 }
             } else {
                 $param = array('grade_id' => $grade_id, 'exam_pid' => $exam_pid);
                 if (DemoConfigModel::check_config_exist($param)) {
                     message('年级或考试期次已经在配置中设置过了');
                 }
             }
         }
     }
     $exam = ExamModel::get_exam($exam_pid);
     if (empty($exam)) {
         message('考试期次不存在');
     }
     if ($exam['grade_id'] != $grade_id) {
         message('考试期次与所选的年级不匹配');
     }
     $exam_subject = DemoConfigModel::get_parent_exam($exam_pid);
     if (empty($exam_subject)) {
         message('该考试期次未设置考试学科');
     }
     $subject = C('subject');
     $subject_name = array();
     foreach ($exam_subject as $item) {
         $exam_paper = $this->db->get_where("exam_subject_paper", array('exam_id' => $item['exam_id']))->row_array();
         if (empty($exam_paper)) {
             $subject_name[] = $subject[$item['subject_id']];
         }
     }
     if ($subject_name) {
         message("该考试期次中【" . implode("、", $subject_name) . "】学科未分配试卷");
     }
     $place = ExamPlaceModel::get_exam_place_list(array('exam_pid' => $exam_pid));
     if (empty($place)) {
         message('该考试期次未设置考场');
     }
     /*
     $this->load->model('admin/exam_place_subject_model');
     $place_subject = $this->exam_place_subject_model->get_exam_place_subject_list(array('place_id'=>$place[0]['place_id']));
     if (empty($place_subject))
     {
         message('该考试期次考场未添加考试学科');
     }
     */
     $data = array('dec_name' => $dec_name, 'dec_grade_id' => $grade_id, 'dec_exam_pid' => $exam_pid, 'place_id' => $place[0]['place_id']);
     if ($dec_id > 0) {
         $res = DemoConfigModel::update($data, $dec_id);
         admin_log('edit', 'demo_exam_config', $dec_id);
     } else {
         $res = DemoConfigModel::add($data);
         admin_log('add', 'demo_exam_config', $this->db->insert_id());
     }
     if ($res) {
         $this->load->model('cron/summary_paper_model');
         $this->summary_paper_model->do_all($exam_pid);
     }
     DemoConfigModel::update_cache();
     $back_url = "/admin/demo_config/index";
     message('MINI测' . ($dec_id ? '修改' : '添加') . ($res ? '成功' : '失败'), $back_url);
 }