/** * 考场添加学科 * * @param int $exam_id 考试期次ID * @param int $place_id 考场ID * @return void */ public function index($exam_id = 0, $place_id = 0) { if (!$this->check_power('exam_list,exam_manage')) { return; } if (empty($exam_id) || empty($place_id)) { message('参数错误!'); } $query = "select * from {pre}exam_place where place_id={$place_id}"; $place = $this->db->query($query)->row_array(); if (!$place) { message('未查询到考场信息!'); } $query = "select * from {pre}exam where exam_id={$exam_id}"; $exam = $this->db->query($query)->row_array(); if (!$exam) { message('未查询到考场信息!'); } //获取考试期次下的学科 $exams = $this->db->query("select exam_id,subject_id from {pre}exam where rd_exam.exam_pid={$exam_id}")->result_array(); if (empty($exams)) { message('该考试期次不存在学科!'); } //控制考场只能在未开始考试操作 $no_start = ExamPlaceModel::place_is_no_start($place_id); $place['no_start'] = $no_start; $query = array('exam_pid' => $exam_id, 'place_id' => $place_id); $result = ExamPlaceSubjectModel::get_exam_place_subject_list($query); $old_subjects = array(); foreach ($result as $key => $value) { $old_subjects[$value['subject_id']] = $value; } $data = array(); $data['exam'] = $exam; $data['place'] = $place; //$data['allow_subject'] = CpUserModel::get_allowed_subjects(); $data['subjects'] = $exams; $data['subjects_name'] = C('subject'); $data['old_subjects'] = $old_subjects; $data['priv_manage'] = $this->check_power('exam_manage', FALSE); // 模版 $this->load->view('place_subject/index', $data); }
/** * * 通过 条件 获取监考人员帐号 记录列表 * @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); }
/** * 下载班级报告 */ 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'); } }
/** * 重新统计报告数据 * @param int $exam_pid * @return AjaxResponse */ public function regenerateSummaryReportDataFunc($exam_pid) { $resp = new AjaxResponse(); $place_time = ExamPlaceModel::get_exam_place($exam_pid, 'MAX(end_time) as end_time'); if ($place_time['end_time'] > time()) { $resp->alert('考试还未结束,无法重新统计报告数据。'); return $resp; } try { if (ReportCommandModel::updateCronTaskExamResultStatus($exam_pid)) { $resp->alert('重新统计报告数据已加入计划任务中,请耐心等待或执行相关php命令。'); $resp->refresh(); } else { $resp->alert('操作失败,请重试。'); } } catch (Exception $e) { $resp->alert($e->getMessage()); } return $resp; }
/** * 设定学生考卷(每科考试随机选一份试卷) * * @param int 考试场次id(place_id) * @param int 学生id * @return array */ public static function set_student_test_paper($place_id, $uid, $is_trans = true) { $subjects = ExamPlaceModel::get_exam_place_subject($place_id); if (empty($subjects)) { return FALSE; } $test_papers = array(); $no_paper_subjects = false; foreach ($subjects as $row) { $sql = <<<EOT SELECT paper_id, exam_pid FROM rd_exam_subject_paper WHERE exam_id = ? ORDER BY RAND() LIMIT 1 EOT; $arr = Fn::db()->fetchRow($sql, $row['exam_id']); if (!isset($arr['paper_id'])) { $no_paper_subjects = true; break; } $exam = ExamModel::get_exam_by_id($row['exam_id'], 'total_score, class_id, grade_id'); $total_score = $exam['total_score']; $class_id = $exam['class_id']; $grade_id = $exam['grade_id']; $test_papers[] = array('exam_pid' => $row['exam_pid'], 'exam_id' => $row['exam_id'], 'uid' => $uid, 'paper_id' => $arr['paper_id'], 'place_id' => $place_id, 'subject_id' => $row['subject_id'], 'full_score' => $total_score, 'test_score' => '0.00', 'etp_flag' => 0, 'ctime' => time()); } if ($no_paper_subjects) { return false; } $db = Fn::db(); if ($is_trans) { $db->beginTransaction(); } // save $insert_ids = array(); foreach ($test_papers as $val) { $sql = "SELECT etp_id FROM rd_exam_test_paper\n WHERE exam_pid = {$val['exam_pid']} AND exam_id = {$val['exam_id']}\n AND uid = {$val['uid']} AND paper_id = {$val['paper_id']}\n AND place_id = {$val['place_id']} AND subject_id = {$val['subject_id']} "; $res1 = $db->fetchRow($sql); if (isset($res1['etp_id']) && $res1['etp_id'] > 0) { $res = $db->update('rd_exam_test_paper', $val, 'etp_id = ' . $res1['etp_id']); $etp_id = $res1['etp_id']; } else { $res = $db->insert('rd_exam_test_paper', $val); //添加试卷试题 $etp_id = $db->lastInsertId('rd_exam_test_paper', 'etp_id'); } if ($etp_id) { $etp_id_where = "etp_id = {$etp_id}"; $db->delete('rd_exam_test_paper_question', $etp_id_where); $sql = "SELECT q.ques_id,q.type\n FROM rd_exam_question eq\n LEFT JOIN rd_question q ON eq.ques_id=q.ques_id\n LEFT JOIN rd_relate_class rc ON rc.ques_id=q.ques_id AND rc.grade_id={$grade_id}\n AND rc.class_id={$class_id} WHERE eq.paper_id={$val['paper_id']}\n ORDER BY rc.difficulty DESC,q.ques_id ASC"; $result = $db->fetchAll($sql); if ($val['subject_id'] == 3) { $types = array('12', '1', '0', '5', '4', '8', '3', '15', '11', '7', '6', '2', '9', '10', '13', '14'); } else { $types = array('1', '2', '3', '0', '10', '14', '15', '11'); } $paper_array = array(); foreach ($types as $type) { foreach ($result as $key => $row) { if ($row['type'] != $type) { continue; } $paper_array[] = $row['ques_id']; unset($result[$key]); } } $ques_ids = implode(',', $paper_array); $res = $db->insert('rd_exam_test_paper_question', array('etp_id' => $etp_id, 'ques_id' => $ques_ids)); } if (!$res) { break; } } if ($is_trans && $res) { $res = $db->commit(); if (!$res) { $db->rollBack(); } } else { if ($is_trans && !$res) { $db->rollBack(); return false; } } return $res; }
/** * 生成某一期考试的考生成绩 * * @param int $exam_pid * @return void */ public function generate($exam_pid = 0) { if (!$this->check_power('exam_manage')) { return; } $exam_pid = intval($exam_pid); if (!$exam_pid) { message('不存在该考试期次.'); } $exam = ExamModel::get_exam($exam_pid, 'exam_id, status'); if (!count($exam)) { message('不存在该考试期次.'); } if (!$exam['status']) { message('该考试期次未被启用,无法生成考试成绩.'); } //获取当前考试期次下考场信息 $place_time = ExamPlaceModel::get_exam_place($exam_pid, 'MAX(end_time) as end_time'); /* $place_id=array(); foreach ($place_time as $val) { $place_id[] = $val['place_id']; } //查询日志信息是否存在已生成的考场信息 $success=0; $fail=0; foreach ($place_id as &$v) { $log_info = "生成考生成绩(".$v.")"; $row = $this->admin_log_model->get_admin_log($log_info); if($row['id']>0) { $fail++; unset($v); } else $success++; } */ //end if ($place_time['end_time'] > time()) { message('目前没有成绩可以生成.'); } //end //如果日志信息不存在考场信息,且该考场未生成考试成绩 $this->load->model('cron/cron_exam_result_model', 'cer_model'); $result = $this->cer_model->insert(array('exam_pid' => $exam_pid)); if ($result) { message("生成考生成绩操作已加入定时任务中,请耐心等候..."); } else { message("生成考生成绩操作加入定时任务失败,请重新执行..."); } exit; // /*if ($success>0&&count($place_id)>0) // {*/ // try { // require_once (APPPATH.'cron/exam.php'); // $exam_cron = new Exam(); // try { // /* // //开启事务 // $this->db->trans_start(); // $exam_cron->fill_unanswer_questions($exam_pid);//先补齐考生未做的题目 // $exam_cron->cal_test_result_score($exam_pid);//计算考生试题分数 // $exam_cron->cal_test_paper_score($exam_pid);//计算考生试卷分数 // //提交事务 // $this->db->trans_complete(); // */ // $exam_cron->cal_test_score($exam_pid); // } catch(Exception $e) { // //$this->db->trans_complete(); // throw new Exception('更新 考生试卷 得分失败,更新字段:' . $t_test_paper . '->test_score, Error:' . $e->getMessage()); // } // /* // foreach ($place_id as $v) // { // admin_log('generate', 'exam_student_result', $v); // } // */ // message("考生成绩生成成功."); // //message("考生成绩生成,成功(".$success.")个,失败(".$fail.")个"); // } catch(Exception $e) { // message('考生成绩生成失败,请重试.'); // } /*}*/ //不存在考场信息 /* else message('目前没有成绩可以生成.'); */ }
/** * 检查考场 配置信息 * * @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('恭喜您,该考场配置信息均正常 :)'); }
/** * ription 编辑产品信息保存数据库 * * @param $act 编辑类型[新增/更新] * @param string $p_name * 产品名称 * @param int $admin_id * 管理员id * @param int $pc_id * 产品分类id * @param int $exam_id * 期次id * @param int $p_status * 产品状态 * @param int $p_money * 产品定价 * @param int $p_money_pushcourse * @param array $p_managers * 产品管理员 * @param string $p_notice * 产品备注 */ public function update() { $act = $this->input->post('act') == 'add' ? 'add' : 'edit'; $product = array(); if ($act == 'add') { if (!$this->check_power_new('production_add')) { return; } $product['p_c_time'] = time(); $product['p_admin'] = intval($this->session->userdata('admin_id')); $product['p_managers'] = intval($this->session->userdata('admin_id')); } else { if (!$this->check_power_new('production_edit')) { return; } $p_id = intval($this->input->post('p_id')); $old_product = CommonModel::get_product_list($p_id); if (empty($old_product)) { message('产品信息不存在!'); return; } /* $admin = $this->session->userdata('admin_id'); $managers = explode(',',$old_product['p_managers']); if (!in_array($admin, $managers)&&!$this->is_super_user()) { message('没有管理权限'); return; } */ $product['p_id'] = trim($this->input->post('p_id')); /* if(is_array($this->input->post('p_managers'))) { $product['p_managers'] = implode(',', $this->input->post('p_managers')); } else { $product['p_managers'] = $old_product[p_admin]; } */ } $product['p_name'] = trim($this->input->post('p_name')); $product['pc_id'] = intval($this->input->post('pc_id')); $product['exam_pid'] = intval($this->input->post('exam_id')); $ip = ExamPlaceModel::get_exam_place($product['exam_pid'], 'ip'); if ($ip) { message('所选考试期次有IP限制,不可选为产品'); return; } $product['p_status'] = intval($this->input->post('p_status')); $product['p_price'] = intval($this->input->post('p_money')); $product['p_price_pushcourse'] = intval($this->input->post('p_money_pushcourse')); $p_prefixinfo = $this->input->post('p_prefixinfo'); if (!is_array($p_prefixinfo)) { $p_prefixinfo = array(); } $product['p_prefixinfo'] = implode(',', $p_prefixinfo); if (!Validate::isInt($product['p_price_pushcourse']) || $product['p_price_pushcourse'] < 0) { message('不推送课程价时价格不正确,必须为非负整数'); return; } if (!Validate::isInt($product['p_price']) || $product['p_price'] < 0) { message('不推送课程价时价格不正确,必须为非负整数'); return; } $product['p_notice'] = trim($this->input->post('p_notice')); $where = "p_id={$p_id}"; /* * 补充学生的所在区域 根据学生所选的学校更新学生所在地区 */ $this->db->trans_start(); if ($act == 'add') { $result = Fn::db()->insert('rd_product', $product); } else { $result = Fn::db()->update('rd_product', $product, $where); } $this->db->trans_complete(); if ($result >= 0) { if ($act == 'add') { $msg = '产品信息添加成功'; admin_log('add', 'product', $result['p_id']); } else { $msg = '产品信息修改成功'; admin_log('edit', 'product', $p_id); } message($msg, 'admin/production/index', 'success'); } else { if ($act == 'add') { $msg = '产品信息添加失败'; admin_log('add', 'product', $result['p_id']); } else { $msg = '产品信息修改失败'; admin_log('edit', 'product', $p_id); } message($msg, 'admin/production/index', 'fail'); } }
/** * 监考人员 列表 * * @return void */ public function index() { if (!$this->check_power('exam_list,exam_manage')) { return; } // 查询条件 $query = array(); $param = array(); $search = array(); $place_id = $this->input->get_post('place_id'); if ($place_id) { $db_query = $this->db->select('p.place_id,p.place_name,p.address,e.exam_id,e.exam_name,sch.school_id,sch.school_name')->from('exam_place p')->join('exam e', 'p.exam_pid=e.exam_id')->join('school sch', 'p.school_id=sch.school_id')->where('p.place_id', $place_id)->get(); $place = $db_query->row_array(); } if (empty($place)) { message('考场信息不存在'); } //控制考场只能在未开始考试操作 $no_start = ExamPlaceModel::place_is_no_start($place_id); if (!$no_start) { message('该考场正在考试或已结束,无法做此操作'); } $data['place'] = $place; $search['place_id'] = $place_id; $param[] = "place_id={$place_id}"; $page = (int) $this->input->get_post('page'); $page = $page ? $page : 1; $per_page = (int) $this->input->get_post('per_page'); $per_page = $per_page ? $per_page : 10; $order_bys = array('email' => 'invigilator_email', 'name' => 'invigilator_name', 'memo' => 'invigilator_memo', 'time' => 'invigilator_addtime'); $order = $this->input->get_post('order'); !$order && ($order = 'time'); $search['order'] = $order; $param[] = "order={$order}"; $order_type = $this->input->get_post('order_type'); !$order_type && ($order_type = 'desc'); $search['order_type'] = $order_type; $param[] = "order_type={$order_type}"; $order_by = $order_bys[$order] . ' ' . $order_type; $selectWhat = '*'; //拼接查询条件 $query_email = $this->input->get_post('email'); if ($query_email) { $query['invigilator_email'] = trim($query_email); $search['email'] = $query_email; $param[] = "email={$query_email}"; } $query_name = $this->input->get_post('name'); if ($query_name) { $query['invigilator_name'] = trim($query_name); $search['name'] = $query_name; $param[] = "name={$query_name}"; } $query_flag = $this->input->get_post('flag'); if ($query_flag) { $query['invigilator_flag'] = is_string($query_flag) ? (int) $query_flag : $query_flag; $search['flag'] = $query_flag; $param[] = "flag={$query_flag}"; } $query_is_trash = (int) $this->input->get_post('trash'); if ($query_is_trash) { $query['invigilator_flag'] = '-1'; $search['trash'] = $query_is_trash; $param[] = "trash={$query_is_trash}"; } else { $query['invigilator_flag'] = array('0', '1'); } $query_begin_time = $this->input->get_post('begin_time'); if ($query_begin_time) { $query['invigilator_addtime'] = array('>=' => strtotime($query_begin_time)); $search['begin_time'] = $query_begin_time; $param[] = "begin_time={$query_begin_time}"; } $query_end_time = $this->input->get_post('end_time'); if ($query_end_time) { if (!isset($query['invigilator_addtime'])) { $query['invigilator_addtime'] = array(); } $query['invigilator_addtime']['<='] = strtotime($query_end_time); $search['end_time'] = $query_end_time; $param[] = "end_time={$query_end_time}"; } //查看已分配 $has_assigned = intval($this->input->get_post('has_assigned')); if (!$query_is_trash) { if ($has_assigned) { $search['has_assigned'] = $has_assigned; $param[] = "has_assigned={$has_assigned}"; $result = ExamInvigilatorModel::get_invigilator_list($query, $page, $per_page, $order_by, $selectWhat, $place_id); } else { $result = ExamInvigilatorModel::get_invigilator_list($query, $page, $per_page, $order_by, $selectWhat, $place_id, true); } } else { $result = ExamInvigilatorModel::get_invigilator_list($query, $page, $per_page, $order_by, $selectWhat); } $tmp_result = array(); if (count($result)) { foreach ($result as $v) { if ($query_is_trash) { $recycle = RecycleModel::get_recycle_list(array('type' => RECYCLE_EXAM_INVIGILATOR, 'obj_id' => $v['invigilator_id']), null, null, 'ctime asc'); $v['recycle'] = $recycle; } else { $v['recycle'] = array(); } $tmp_result[] = $v; } } // 分页 $purl = site_url('admin/exam_invigilator/index/') . (count($param) ? '?' . implode('&', $param) : ''); if ($has_assigned) { $total = ExamInvigilatorModel::count_invigilator_lists($query, $place_id); } else { $total = ExamInvigilatorModel::count_invigilator_lists($query, $place_id, true); } $data['pagination'] = multipage($total, $per_page, $page, $purl); $data['search'] =& $search; $data['list'] =& $tmp_result; //排序地址 unset($param['order=']); unset($param['order_type=']); $order_url = site_url('admin/exam_invigilator/index/') . (count($param) ? '?' . implode('&', $param) : ''); $data['order_url'] = $order_url; $data['priv_manage'] = $this->check_power('exam_manage', FALSE); // 模版 $this->load->view('exam_invigilator/index', $data); }
/** * 编辑信息 * * @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); }
public function out_student_save() { $exam_ticket = trim($this->input->post('account')); $password = $this->input->post('password'); $place_id = intval($this->input->post('place_id')); $exam_id = intval($this->input->post('exam_id')); $txt_student_tichu = intval($this->input->post('txt_student_tichu')); if (!strlen($password)) { output_json(CODE_ERROR, '理由不能为空.'); } if (!strlen($txt_student_tichu)) { output_json(CODE_ERROR, '状态不能为空.'); } // 检查帐号密码是否正确 $this->load->model(APPPATH . 'models/exam/student_model'); $student = $this->student_model->is_valid_student($exam_ticket); if (!$student) { output_json(CODE_ERROR, '该考生不存在.'); } $user_id = $student['uid']; // 重置考生密码 try { if ($txt_student_tichu == '1') { $action = 'out_student'; } else { $action = 'in_student'; } if ($action && ($log_type = Log_type_desc::get_log_alia($action))) { $log_content = $password; exam_log_1($log_type, $log_content, $user_id, $place_id, $exam_id); } $session_data = array('exam_ticket_out' => $exam_ticket, 'password_out' => $password, 'txt_student_tichu' => $txt_student_tichu); $this->session->set_userdata($session_data); ExamPlaceModel::out_exam_place_student($place_id, $user_id, $password, $txt_student_tichu); if ($txt_student_tichu == 1) { output_json(CODE_SUCCESS, '<p></p><p>踢出成功, 该考生考试信息为:</p><p><strong>准考证号:</strong>' . $exam_ticket . ' </p>'); } else { output_json(CODE_SUCCESS, '<p></p><p>恢复成功, 该考生考试信息为:</p><p><strong>准考证号:</strong>' . $exam_ticket . ' </p>'); } } catch (Exception $e) { output_json(CODE_ERROR, '<p></p><p>踢出失败,请重试(如多次出现类似情况,请联系系统管理员)</p>'); } }
/** * 设置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); }
/** * 测试报名 * @param int $exam 期次id * @param int $place 场次id, 多个ID用英文逗号分隔开 * @param int $p_id 产品id * @return json 成功/失败 */ public function place_in() { $exam = intval($this->input->post('exam')); $place = $this->input->post('place'); $uid = $this->session->userdata('uid'); $p_id = intval($this->input->post('p_id')); $force = intval($this->input->post('force')); $b_pushcourse = intval($this->input->post('b_pushcourse')); if (!Validate::isJoinedIntStr($place)) { output_json(CODE_ERROR, '报名失败,考场不正确'); } // 检查是否存在该学生 $account = StudentModel::get_student($uid, 'account,account_status'); if (!count($account['account'])) { output_json(CODE_ERROR, '报名失败,不存在该学生.'); } else { if ($account['account_status']) { output_json(CODE_ERROR, '报名失败,学生帐号已被冻结'); } } if (CommonModel::get_product_trans($p_id, $uid, $place, $exam)) { output_json(CODE_ERROR, '报名失败,已报名该产品'); } $res = CommonModel::get_product_list($p_id); if (!$res) { output_json(CODE_ERROR, '报名失败,产品不存在'); } else { $price = $b_pushcourse ? $res['p_price_pushcourse'] : $res['p_price']; $pc_id = $res['pc_id']; } $account = $account['account']; $account1 = $account - $price; if ($account1 < 0) { output_json(CODE_ERROR, '帐号余额不足'); } $inserts = array(); $error = array(); $code = CODE_ERROR; $place_id_arr = array_unique(explode(',', $place)); $place_id_arr2 = array(); foreach ($place_id_arr as $place_id) { if ($place_id) { $query = $this->db->select('p.*,e.exam_name,e.exam_id,e.exam_pid,e.grade_id')->from('exam_place p')->join('exam e', 'p.exam_pid=e.exam_id')->where(array('p.place_id' => $place_id))->get(); $place = $query->row_array(); } else { continue; } if (empty($place)) { $error[] = "考场[{$place_id}]信息不存在"; //output_json(CODE_ERROR, '考场信息不存在'); continue; } $ids = $uid; // 控制考场只能在未开始考试操作 $no_start = ExamPlaceModel::place_is_no_start($place_id); if (!$no_start) { $error[] = "考场[{$place_id}]正确考试或已结束,无法报名"; continue; //output_json(CODE_ERROR, '该考场正在考试或已结束,无法做此操作'); } // $ids = my_intval($ids); // $school_id = (int)$this -> input ->post('school_id'); // 该考场所考到的学科 $subject_ids = array(); $query = $this->db->select('subject_id')->from('exam_place_subject')->where(array('place_id' => $place['place_id']))->get(); $subjects = $query->result_array(); $subject_ids = array(); foreach ($subjects as $subject) { $subject_ids[] = $subject['subject_id']; } $subject_ids = count($subject_ids) ? implode(',', $subject_ids) : '""'; $place['start_time'] = $place['start_time'] + 1; $place['end_time'] = $place['end_time'] - 1; if ($force == 0) { $sql = "SELECT count(u.uid) FROM rd_student u\n WHERE u.grade_id={$place['grade_id']} AND u.is_delete=0 AND u.uid ={$ids}"; $query = Fn::db()->fetchOne($sql); if ($query == 0) { $error[] = "考场[{$place_id}]您的年级不符合要求"; $code = -2; continue; //output_json('-2', '你的年级不符合要求'); } } $not_exists_sql = <<<EOT SELECT uid FROM rd_exam_place_student ps, rd_exam_place p, rd_exam e WHERE e.exam_isfree = 0 AND ps.place_id = p.place_id AND p.place_index = {$place['place_index']} AND ps.uid = u.uid AND p.exam_pid = e.exam_id AND ( ( (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']} ) ) OR p.place_id IN ( SELECT DISTINCT(place_id) FROM rd_exam_place_subject eps WHERE eps.subject_id IN ({$subject_ids}) AND eps.exam_pid = {$place['exam_id']} ) ) EOT; $sql = <<<EOT SELECT u.uid FROM rd_student u WHERE u.is_delete = 0 AND u.uid = {$ids} AND NOT EXISTS({$not_exists_sql}) EOT; $tmp_inserts = array(); $query = $this->db->query($sql); foreach ($query->result_array() as $row) { $vrow = array('place_id' => $place_id, 'uid' => $row['uid']); $tmp_inserts[] = $vrow; $inserts[] = $vrow; } if (empty($tmp_inserts)) { $error[] = "考场[{$place_id}]时间段内您已经参加了相同时间段其它考试"; continue; //output_json(CODE_ERROR, '你已经参加相同时间段其他考试'); } $place_id_arr2[] = $place_id; } if (!empty($error) || empty($inserts)) { output_json($code, "报名失败\n" . implode("\n", $error)); } $vc = C('virtual_currency'); $pt_log = $account . $vc['name'] . '--' . $account1 . $vc['name']; $txt_account = -$price; $db = Fn::db(); $flag = false; if ($db->beginTransaction()) { foreach ($inserts as $val) { $db->replace('rd_exam_place_student', $val); } $param = array('tr_uid' => $uid, 'tr_type' => 3, 'tr_pid' => $p_id, 'tr_flag' => 1, 'tr_money' => $account1, 'tr_trade_amount' => $txt_account, 'tr_comment' => $pt_log); $number = TransactionRecordModel::addTransactionRecord($param); if ($b_pushcourse) { $now = date('Y-m-d H:i:s'); foreach ($place_id_arr2 as $place_id) { $db->insert('t_course_push', array('cp_stuuid' => $uid, 'cp_exampid' => $exam, 'cp_examplaceid' => $place_id, 'cp_addtime' => $now)); } } $sql = <<<EOT UPDATE rd_student SET account = account - {$price} WHERE uid = {$uid} EOT; $db->exec($sql); $flag = $db->commit(); if (!$flag) { $db->rollBack(); $error[] = "考场[{$place_id}]报名失败"; } } if (!$flag) { output_json(CODE_ERROR, "报名失败\n" . implode("\n", $error)); } else { output_json(CODE_SUCCESS, '报名成功.'); } }