/** * 控制界面首页 */ public function index($exam_pid = 0) { Fn::ajax_call($this, 'regenerateExamRecord', 'regenerateExamResults', 'endPlaceExam', 'regenerateSummaryReportData', 'regenerateReport', 'removeCronTaskReport'); $exam_pid = intval($exam_pid); $param['exam_pid'] = 0; $param['exam_isfree'] = 0; $examlist = ExamModel::get_exam_list_all($param); $exam = array(); if ($exam_pid > 0) { $exam = ExamModel::get_exam($exam_pid); } if (!$exam) { $exam = current($examlist); } $db = Fn::db(); /////////////////////////考试记录是否生成///////////// $sql = "SELECT uid_data FROM rd_cron_task_place_student_paper ctps\n LEFT JOIN rd_exam_place ep ON ep.place_id = ctps.place_id\n WHERE ep.exam_pid ={$exam['exam_id']} AND ctps.status=2"; $uid_arr = $db->fetchCol($sql); $paper_count = 0; foreach ($uid_arr as $item) { $paper_count += count(json_decode($item)); } $sql = "SELECT COUNT(*) FROM rd_exam_place_student eps\n LEFT JOIN rd_exam_place ep ON ep.place_id = eps.place_id\n WHERE ep.exam_pid = {$exam['exam_id']}"; $student_count = $db->fetchOne($sql); if ($paper_count == $student_count) { $data['paper_status'] = true; //考试记录是否完全生成 } else { $data['paper_status'] = false; } ///////////////////////////////////////// $sql = "SELECT status FROM rd_cron_task_exam_result \n WHERE exam_pid = {$exam['exam_id']}"; $data['cter_status'] = $db->fetchOne($sql); ////////////////////////////////////////// $sql = "SELECT DISTINCT(status) FROM rd_cron_task_report ctr \n LEFT JOIN rd_evaluate_rule er ON er.id = ctr.rule_id \n WHERE exam_pid = {$exam['exam_id']}"; $data['ctr_status'] = $db->fetchCol($sql); //////////////////////////////////////// $data['exam'] = $exam; $data['demo_exam'] = $this->demo_exam_list(); $data['examlist'] = $examlist; $data['place'] = ExamPlaceModel::get_exam_place($exam_pid, 'MAX(end_time) as end_time'); $data['crontaskexamresult'] = ReportCommandModel::cronTaskExamResultInfo($exam['exam_id']); $data['evaluerulelist'] = ReportCommandModel::cronTaskReportLists($exam['exam_id']); $this->load->view('report_command/index', $data); }
public function setexamrelate($er_exampid = 0) { $er_exampid = intval($er_exampid); if ($er_exampid > 0) { $exam = ExamModel::get_exam($er_exampid); if ($exam['exam_ticket_maprule'] < 1) { message('该考试不是外部纸质考试,无法对应考试关系!'); } if ($exam['exam_pid'] > 0) { redirect('/admin/zmoss/setexamrelate/' . $exam['exam_pid']); exit; } $data['exam'] = $exam; $data['examrelate'] = ZmossModel::examRelateInfo($er_exampid); $data['examrelatelist'] = ZmossModel::examRelateZmossExamList($er_exampid); $examlist2 = ExamModel::get_exam_list(array('exam_pid' => $er_exampid), null, null, 'subject_id ASC'); } else { $cond_param = array('er_exampid' => 0); $list = ZmossModel::examRelatelist($cond_param, 1, time()); $examplist = array_keys($list); $examlist = ExamModel::get_exam_list_all(array('exam_pid' => 0, 'exam_ticket_maprule >' => '0')); $examlist2 = array(); if ($examlist) { $exam_pid = array(); foreach ($examlist as $k => $item) { if (in_array($item['exam_id'], $examplist)) { unset($examlist[$k]); continue; } $exam_pid[] = $item['exam_id']; } $list = ExamModel::get_exam_list(array('exam_pid' => $exam_pid), null, null, 'subject_id ASC'); foreach ($list as $item) { $examlist2[$item['exam_pid']][] = $item; } unset($list); } } $where = "exam_pid = 0"; $er_zmoss_examid = ZmossModel::examRelateZmossExamList(); if ($er_exampid > 0) { unset($er_zmoss_examid[$er_exampid]); } if ($er_zmoss_examid) { $where .= " AND exam_id NOT IN (" . implode(',', $er_zmoss_examid) . ")"; } $zmossexamlist = ZmossModel::examlist("*", $where); $zmossexamlist2 = array(); if ($zmossexamlist) { $list = ZmossModel::examlist("*", array('exam_pid' => implode(',', array_keys($zmossexamlist)))); foreach ($list as $item) { $zmossexamlist2[$item['exam_pid']][] = $item; } unset($list); } $data['examlist'] = $examlist; $data['examlist2'] = $examlist2; $data['zmossexamlist'] = $zmossexamlist; $data['zmossexamlist2'] = $zmossexamlist2; $data['subject'] = C('subject'); // 模版 $this->load->view('zmoss/setexamrelate', $data); }
/** * 考试期次列表 * * @return void */ public function exam_place_list() { $data = array(); $data['list'] = ExamModel::get_exam_list_all(array('exam_pid' => '0', 'status' => '1'), 'exam_id,exam_name'); /* 查询已经有评分标准的考试期次 */ foreach ($data['list'] as $key => $value) { $flag = EvaluationStandardExamModel::get_standard_by_exam($value['exam_id']); if ($flag) { $data['list'][$key]['flag'] = true; } else { $data['list'][$key]['flag'] = false; } } $this->load->view('interview/exam_place_list', $data); }
/** * 导入处理 * * @return mixed void */ public function save() { ini_set("display_errors", "On"); error_reporting(-1); $post = $this->input->post(); /** 上传文件 */ $config['upload_path'] = '../../cache/excel/'; $config['allowed_types'] = '*'; $config['max_size'] = 1024 * 10; #单位kb $config['overwrite'] = false; $this->load->library('upload', $config); if (!$this->upload->do_upload('file')) { $data = array(); $data['exam_id'] = $post['exam_id']; $data['error'] = $this->upload->display_errors(); $data['exams'] = ExamModel::get_exam_list_all(array('exam_pid' => '0', 'status' => '1'), 'exam_id,exam_name'); $this->load->view('interview/interview_import', $data); } else { /** 实时输出导入结果 */ ob_end_flush(); set_time_limit(0); $start_time = microtime(true); $upload_data = $this->upload->data(); /** 读取excel */ $this->load->library('PHPExcel'); $this->load->library('PHPExcel/IOFactory'); $inputFileType = IOFactory::identify($upload_data['file_relative_path']); $objReader = IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($upload_data['file_relative_path']); $data = $objPHPExcel->getSheet(0)->toArray(); $end_time = microtime(true); $execute_time = $end_time - $start_time; if (!empty($data)) { echo '文件载入成功!执行时间:' . sprintf('%.4f', $execute_time) . 's' . '<hr/>'; flush(); } /** 评分标准信息 */ $start_time = microtime(true); $relation = EvaluationStandardExamModel::get_standard_by_exam($post['exam_id']); $standard = EvaluationStandardModel::get_one($relation['standard_id']); $option_count = count(explode(',', $standard['options'])); $end_time = microtime(true); $execute_time = $end_time - $start_time; if ($standard && !empty($standard) && $option_count >= 1) { echo '获取考试期次对应评分标准信息成功!执行时间:' . sprintf('%.4f', $execute_time) . 's' . '<hr/>'; flush(); } else { echo '获取考试期次对应评分标准信息失败!请检查本期次对应评分标准及评分项!'; flush(); exit; } if ($standard['status'] != 1) { echo '当前评分标准已禁用!停止导入!<hr/>'; flush(); exit; } /** 导入结果 */ $start_time = microtime(true); foreach ($data as $key => $value) { if ($key < 1) { continue; } $student_ticket = trim($value[0]); $sql = "select * from {pre}exam_student_list where student_ticket={$student_ticket}"; $ruidabei_student = $this->db->query($sql)->row_array(); if (!$ruidabei_student['uid'] > 0) { echo "未查询到当前用户数据,在第" . ($key + 1) . "行。姓名:" . $value['1'] . "<br/>"; continue; } if (!$ruidabei_student) { echo "未查询到当前用户数据,在第" . ($key + 1) . "行。姓名:" . $value['1'] . "<br/>"; continue; } if ($ruidabei_student['student_name'] != $value[1]) { echo "当前用户睿达杯准考证号与姓名不符,在第" . ($key + 1) . "行。姓名:" . $value[1] . "<br/>"; continue; } $option_index = 1; /* 获取学科信息 */ $subject_name = "%" . $value[2] . "%"; $subject_id = $this->db->select('subject_id')->get_where('subject', array('subject_name like' => $subject_name))->row_array(); foreach ($value as $k => $v) { if ($k < 3 || $k >= 3 + $option_count) { continue; } /** 判断数据是否已存在数据库中 */ $param = array(); $param['exam_id'] = $post['exam_id']; $param['student_id'] = $ruidabei_student['uid']; $param['subject_id'] = $subject_id['subject_id']; $param['option_index'] = $option_index; $row = array(); $row['exam_id'] = $post['exam_id']; $row['student_id'] = $ruidabei_student['uid']; $row['subject_id'] = $subject_id['subject_id']; $row['option_index'] = $option_index; $row['scroe'] = $v ? $v : 0; $row['create_time'] = time(); $option_index++; $result = InterviewResultModel::get_one($param); if ($result && !empty($result)) { echo '<p style="color:red;">警告!本条数据已存在!将覆盖原有数据!在第' . ($key + 1) . '行:' . $param['student_id'] . '</p><br/>'; $result = InterviewResultModel::update(array('id' => $result['id']), $row); } else { $result = InterviewResultModel::add($row); } if ($result) { echo '<p style="color:green;">第' . ($key + 1) . '行' . '第' . ($k - 2) . '条导入成功!</p><br/>'; flush(); } else { echo '<p style="color:red;">错误!第' . ($key + 1) . '行' . '第' . ($k - 2) . '条导入失败!</p><br/>'; flush(); } } } $end_time = microtime(true); $execute_time = $end_time - $start_time; echo '导入成功!用时:' . $execute_time . 's'; } }
/** * 导入处理 * * @return mixed void */ public function save() { $post = $this->input->post(); /** 上传文件 */ $config['upload_path'] = '../../cache/excel/'; $config['allowed_types'] = '*'; $config['max_size'] = 1024 * 10; #单位kb $config['overwrite'] = false; $this->load->library('upload', $config); if (!$this->upload->do_upload('file')) { $data = array(); $data['exam_id'] = $post['exam_id']; $data['error'] = $this->upload->display_errors(); $data['exams'] = ExamModel::get_exam_list_all(array('exam_pid' => '0', 'status' => '1'), 'exam_id,exam_name'); $this->load->view('ruidabei/import', $data); } else { /** 实时输出导入结果 */ ob_end_flush(); set_time_limit(0); $start_time = microtime(true); $upload_data = $this->upload->data(); /** 读取excel */ $this->load->library('PHPExcel'); $this->load->library('PHPExcel/IOFactory'); $inputFileType = IOFactory::identify($upload_data['file_relative_path']); $objReader = IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($upload_data['file_relative_path']); $data = $objPHPExcel->getSheet(0)->toArray(); $end_time = microtime(true); $execute_time = $end_time - $start_time; if (!empty($data)) { echo '文件载入成功!执行时间:' . sprintf('%.4f', $execute_time) . 's' . '<hr/>'; flush(); } /** 导入结果 */ $start_time = microtime(true); foreach ($data as $key => $value) { if ($key < 1) { continue; } $student_ticket = $value[0]; $sql = "select * from {pre}exam_student_list where student_ticket={$student_ticket}"; $ruidabei_student = $this->db->query($sql)->row_array(); if (!$ruidabei_student) { echo "未查询到当前用户数据,在第" . ($key + 1) . "行:" . $value[1]; continue; } if ($ruidabei_student['student_name'] != $value[1]) { echo "当前用户睿达杯准考证号与姓名不符,在第" . ($key + 1) . "行" . $value[1]; continue; } /** 判断数据是否已存在数据库中 */ $param = array(); $param['exam_id'] = $post['exam_id']; $param['student_id'] = $ruidabei_student['uid']; $param['school_name'] = $value[2]; $param['grade'] = $value[7]; $param['subject'] = $value[6]; $row = array(); $row['exam_id'] = $post['exam_id']; $row['student_id'] = $ruidabei_student['uid']; $row['student_name'] = $value[1]; $row['school_name'] = $value[2]; $row['awards'] = $value[3]; $row['score'] = $value[4]; $row['ranks'] = $value[5]; $row['subject'] = $value[6]; $row['grade'] = $value[7]; $row['create_time'] = time(); $query_result = RuidabeiResultModel::get_one($param); if ($query_result) { echo '<p style="color:red;">警告!本条数据已存在!将覆盖原有数据!在第' . ($key + 1) . '行' . '</p><br/>'; $result = RuidabeiResultModel::update(array('id' => $query_result['id']), $row); } else { $result = RuidabeiResultModel::add($row); } if ($result) { echo '<p style="color:green;">第' . ($key + 1) . '行导入成功!</p><br/>'; flush(); } else { echo '<p style="color:red;">错误!第' . ($key + 1) . '行导入失败!</p><br/>'; flush(); } } $end_time = microtime(true); $execute_time = $end_time - $start_time; echo '导入成功!用时:' . $execute_time . 's'; } }
/** * 当前用户可以参与的考试期次 */ private function u_exam_list() { $exam_list = ExamModel::get_exam_list_all(array('exam_pid > ' => 0), 'exam_id, exam_name, subject_id, managers, creator_id'); $data = array(); $admin_id = $this->session->userdata('admin_id'); $is_super = self::is_super_user(); foreach ($exam_list as $item) { $managers = $item['managers']; $creator_id = $item['creator_id']; unset($item['managers']); unset($item['creator_id']); if ($is_super || $creator_id == $admin_id || $managers && in_array($admin_id, json_decode($managers, true))) { $data[] = $item; } } return $exam_list; }