/** * 重新统计报告数据 * @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; }
/** * 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'); } }
/** * 生成某一期考试的考生成绩 * * @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 index($exam_pid = 0) { if (!$this->check_power('exam_list,exam_manage')) { return; } // 查询条件 $where = array(); $param = array(); $search = array(); $exam_pid = intval($exam_pid); if ($exam_pid) { $parent = ExamModel::get_exam($exam_pid, '*'); } if (empty($parent) or $parent['exam_pid'] > 0) { message('考试期次不存在', 'admin/exam/index'); return; } $managers = $parent['managers'] ? json_decode($parent['managers'], true) : array(); $this->check_exam_manager_power($parent['creator_id'], $managers); $where[] = "p.exam_pid={$exam_pid}"; if ($search['keyword'] = trim($this->input->get('keyword'))) { $escape_keyword = $this->db->escape_like_str($search['keyword']); $where[] = "p.place_name LIKE '%" . $escape_keyword . "%'"; $param[] = "keyword=" . urlencode($search['keyword']); } $where = $where ? ' WHERE ' . implode(' AND ', $where) : ''; // 统计数量 $sql = "SELECT COUNT(*) nums FROM {pre}exam_place p {$where}"; $res = $this->db->query($sql); $row = $res->row_array(); $total = $row['nums']; // 读取数据 $size = 15; $page = isset($_GET['page']) && intval($_GET['page']) > 1 ? intval($_GET['page']) : 1; $offset = ($page - 1) * $size; $list = array(); if ($total) { $sql = "SELECT p.*,s.school_name,COUNT(ps.uid) student_num, sc.schcls_name\n FROM {pre}exam_place p\n LEFT JOIN {pre}school s ON p.school_id=s.school_id\n LEFT JOIN {pre}exam_place_student ps ON p.place_id=ps.place_id\n LEFT JOIN t_school_class sc ON sc.schcls_id = p.place_schclsid\n {$where} GROUP BY p.place_id ORDER BY p.place_id ASC LIMIT {$offset},{$size}"; $res = $this->db->query($sql); foreach ($res->result_array() as $row) { $row['start_time'] = $row['start_time'] ? date('Y-m-d H:i', $row['start_time']) : ''; $row['end_time'] = $row['end_time'] ? date('Y-m-d H:i', $row['end_time']) : ''; //检查该考场是否有关联信息 $row['has_relate_info'] = ExamPlaceModel::has_place_relate_info($row['place_id']); $list[] = $row; } } // 分页 $purl = site_url('admin/exam_place/index/' . $exam_pid) . ($param ? '?' . implode('&', $param) : ''); $data['pagination'] = multipage($total, $size, $page, $purl); //外部考试 if ($parent['exam_ticket_maprule']) { $parent['max_end_time'] = ExamPlaceModel::get_exam_place($exam_pid, 'MAX(end_time) AS end_time'); } $data['search'] = $search; $data['parent'] = $parent; $data['list'] = $list; $data['priv_manage'] = $this->check_power('exam_manage', FALSE); $data['has_preview_manage'] = false; $data['is_super_user'] = $this->is_super_user(); if ($this->is_super_user() || $parent['creator_id'] == $this->session->userdata('admin_id')) { $data['has_preview_manage'] = true; } $this->demo_exams($data); // 模版 $this->load->view('exam_place/index', $data); }