示例#1
0
文件: Index.php 项目: krisrita/udo
 /**
  * 第二期首页
  */
 public function indexAction()
 {
     $cityId = (int) $this->get("city_id", 0);
     $datacourseModel = new DatasourceModel();
     $city = $datacourseModel->getCity($cityId);
     $schoolModel = new SchoolModel();
     $list = $schoolModel->getSchoolList($cityId, $this->uid);
     $this->assign("school_list", $list);
     $this->assign("city", $city);
 }
示例#2
0
文件: Paper.php 项目: krisrita/udo
 /**
  * 试卷列表
  */
 function listAction()
 {
     $pagesize = 15;
     $courseId = (int) $this->get('course_id', 0);
     $paperId = (int) $this->get('paper_id', 0);
     $type = (int) $this->get('type', 0);
     $courseModel = new CourseModel();
     $course = $courseModel->getCourse($courseId);
     if (!$course) {
         $this->redirect("/error/?errno=" . Common_Error::ERROR_COURSE_NOT_EXISTS);
     }
     $schoolModel = new SchoolModel();
     $school = $schoolModel->getSchool($course['school_id']);
     if (!$school) {
         $this->redirect("/error/?errno=" . Common_Error::ERROR_SCHOOL_NOT_EXISTS);
     }
     $paperModel = new PaperModel();
     //$list = $paperModel -> getList($courseId, $paperId, $type, $pagesize);
     $list = $paperModel->getAll($courseId);
     if (!$list) {
         $this->redirect("/error/?errno=" . Common_Error::ERROR_COURSE_NOT_EXISTS);
     }
     $courseModel = new CourseModel();
     $practiseList = $courseModel->getCoursePractiseList($courseId);
     $uSecList = $courseModel->getUserCourseSection($this->uid, $courseId);
     $uSectionIds = $uSecList ? array_keys($uSecList) : array();
     foreach ($list as $k => $section) {
         $list[$k] = array('id' => $section['id'], "name" => $section['name']);
         $list[$k]['last'] = isset($uSectionIds[0]) && $section['id'] == $uSectionIds[0] ? 1 : 0;
         $list[$k]['practise_video_list'] = isset($practiseList[$section['id']]) ? $practiseList[$section['id']] : array();
         if (empty($list[$k]['practise_video_list'])) {
             $list[$k]['practise_video_list_for_android'] = array();
             continue;
         }
         foreach ($list[$k]['practise_video_list'] as $seq => $videoId) {
             $list[$k]['practise_video_list_for_android'][] = array("practise_seq" => $seq, "practise_video_id" => $videoId);
         }
     }
     if ($this->isMobile) {
         $this->displayJson(Common_Error::ERROR_SUCCESS, $list);
     }
     $course['practise_num'] = $courseModel->getCoursePractiseNum($courseId);
     $course['user_practise_num'] = $courseModel->getUserCoursePractiseNum($this->uid, $courseId);
     $course['duration_minute'] = round($paperModel->getPaperDuration($courseId) / 60, 0);
     $course['user_spend_minute'] = round($paperModel->getUserPaperDuration($this->uid, $courseId) / 60, 0);
     $course['teachers'] = $courseModel->getCourseTeachers($courseId);
     $this->assign("school", $school);
     $this->assign("course", $course);
     $this->assign('paper_list', $list);
 }
示例#3
0
文件: Course.php 项目: krisrita/udo
 function listAction()
 {
     $pagesize = 15;
     $courseId = (int) $this->get('course_id', 0);
     $type = (int) $this->get('type', 0);
     $page = (int) $this->get('page', 1);
     $schoolId = (int) $this->get('school_id', 0);
     if ($schoolId < 1) {
         $this->redirect("/error/?errno=" . Common_Error::ERROR_PARAM);
     }
     //查询学校
     $schoolModel = new SchoolModel();
     $school = $schoolModel->getSchool($schoolId);
     if (empty($school)) {
         $this->redirect("/error/?errno=" . Common_Error::ERROR_SCHOOL_NOT_EXISTS);
     }
     $courseModel = new CourseModel();
     if ($this->isMobile) {
         $list = $courseModel->getCourseListById($schoolId, $courseId, $type, $pagesize, $this->uid);
     } else {
         $data = $courseModel->getList($schoolId, $page, $pagesize, $this->uid);
         $list = $data['list'];
     }
     if ($this->uid && $list) {
         $courseIds = array();
         foreach ($list as $course) {
             $courseIds[] = $course['id'];
         }
         $lastLearn = $courseModel->getUserCourseLastSection($this->uid, $courseIds);
         foreach ($list as &$course) {
             $course['last_section_id'] = (int) @$lastLearn[$course['id']]['last_section_id'];
             $course['last_section_name'] = (string) @$lastLearn[$course['id']]['last_section_name'];
             $course['last_section_seq'] = (int) @$lastLearn[$course['id']]['last_section_seq'];
             $course['last_chapter_id'] = (int) @$lastLearn[$course['id']]['last_chapter_id'];
             $course['last_chapter_name'] = (string) @$lastLearn[$course['id']]['last_chapter_name'];
             $course['last_chapter_seq'] = (int) @$lastLearn[$course['id']]['last_chapter_seq'];
         }
         unset($course);
     }
     if ($this->isMobile) {
         $this->displayJson(Common_Error::ERROR_SUCCESS, $list);
     }
     $this->assign('school', $school['name']);
     $this->assign('course_list', $list);
     $this->assign('course_count', $data['count']);
     $this->assign('page_count', ceil($data['count'] / $pagesize));
 }
示例#4
0
 /**
  * 学校信息
  * @method GET_infoAction
  * @param  integer          $id [description]
  * @author NewFuture
  */
 public function GET_infoAction($id = 0)
 {
     if ($school = SchoolModel::find($id)) {
         $school['number'] = Config::get('regex.number.' . strtolower($school['abbr']));
         $this->response(1, $school);
     } else {
         $this->response(0, $id);
     }
 }
示例#5
0
 public function school_list()
 {
     $where = array();
     if ($area_id = intval($this->input->get('area_id'))) {
         $where['area_id'] = $area_id;
     }
     if ($city_id = intval($this->input->get('city_id'))) {
         $where['city_id'] = $city_id;
     }
     if ($school_property = intval($this->input->get('school_property'))) {
         $where['school_property'] = $school_property;
     }
     if ($keyword = trim($this->input->get('keyword'))) {
         $where['keyword'] = $keyword;
     }
     if ($grade_id = intval($this->input->get('grade_id'))) {
         $grade_period = get_grade_period($grade_id);
         if ($grade_period) {
             $where['grade_period'] = $grade_period;
         }
     }
     $schools = SchoolModel::search_school($where);
     echo json_encode($schools);
 }
示例#6
0
    /**
     * 导入教师记录(从excel文件中),
     */
    public function importteacher($sch_id = 0)
    {
        if ($_GET['dl'] == '1') {
            Func::dumpFile('application/vnd.ms-excel', 'file/import_school_teacher_template.xlsx', '教师导入模板.xlsx');
            exit;
        }
        if (!$sch_id || !SchoolModel::schoolInfo($sch_id)) {
            message('学校不存在,无法导入教师!');
        }
        $data = array();
        $data['sch_id'] = $sch_id;
        while (isset($_FILES['file'])) {
            $param = $_POST;
            $title = array('姓名', '年级', '学科', '简介');
            $col_char = array();
            $rows = Excel::readSimpleUploadFile($_FILES['file'], $title, $col_char);
            if (!is_array($rows)) {
                $data['error'] = $rows;
                break;
            }
            $grade_map = array_flip(C('grades'));
            $subject_map = array_flip(C('subject'));
            $ct_list = array();
            foreach ($rows as $k => $row) {
                //////////////////////////////
                //   姓名0 年级1 学科2  简介3
                //////////////////////////////
                // 姓名
                if ($row[0] == '') {
                    $data['error'] == $col_char[0] . ($k + 2) . ' - "姓名"不可为空';
                    break;
                }
                if (mb_strlen($row[0], 'UTF-8') > 30) {
                    $data['error'] = $col_char[0] . ($k + 2) . ' - "姓名"内容太长了,不可超过30个字符';
                    break;
                }
                // 年级
                if ($row[1] == '') {
                    $data['error'] = $col_char[1] . ($k + 2) . ' - "年级"不能为空';
                    break;
                }
                $row[1] = str_replace(array(',', ' ', ' ', '、', "\r\n", "\r", "\n"), ',', $row[1]);
                $row['ctg_gradeid'] = array();
                $arr = explode(',', $row[1]);
                foreach ($arr as $v) {
                    $v = trim($v);
                    if ($v == '') {
                        continue;
                    }
                    if (isset($grade_map[$v])) {
                        $row['ctg_gradeid'][] = $grade_map[$v];
                    } else {
                        $data['error'] = $col_char[1] . ($k + 2) . ' - "年级"里有不正确的选项';
                        break;
                    }
                }
                if (isset($data['error'])) {
                    break;
                }
                if (empty($row['ctg_gradeid'])) {
                    $data['error'] = $col_char[1] . ($k + 2) . ' - "年级"不能为空';
                    break;
                }
                $row['ctg_gradeid'] = array_unique($row['ctg_gradeid']);
                // 学科
                if ($row[2] == '') {
                    $data['error'] = $col_char[2] . ($k + 2) . ' - "学科"不能为空';
                    break;
                }
                $row[2] = str_replace(array(',', ' ', ' ', '、', "\r\n", "\r", "\n"), ',', $row[2]);
                $row['cts_subjectid'] = array();
                $arr = explode(',', $row[2]);
                foreach ($arr as $v) {
                    $v = trim($v);
                    if ($v == '') {
                        continue;
                    }
                    if (isset($subject_map[$v])) {
                        $row['cts_subjectid'][] = $subject_map[$v];
                    } else {
                        $data['error'] = $col_char[2] . ($k + 2) . ' - "学科"里有不正确的选项空';
                        break;
                    }
                }
                if (isset($data['error'])) {
                    break;
                }
                if (empty($row['cts_subjectid'])) {
                    $data['error'] = $col_char[2] . ($k + 2) . ' - "学科"不能为空';
                    break;
                }
                $row['cts_subjectid'] = array_unique($row['cts_subjectid']);
                // 简介
                if ($row[3] == '') {
                    $row[3] = NULL;
                }
                $ct_list[] = array('index' => $k + 2, 'ct_name' => $row[0], 'ct_memo' => $row[3], 'ctg_gradeid' => $row['ctg_gradeid'], 'cts_subjectid' => $row['cts_subjectid']);
            }
            if (isset($data['error'])) {
                break;
            }
            unset($grade_map);
            unset($subject_map);
            unset($rows);
            // 这里开始导入
            $db = Fn::db();
            try {
                $time = time();
                $adduid = Fn::sess()->userdata('admin_id');
                if (!$db->beginTransaction()) {
                    throw new Exception('开始导入事务处理失败');
                }
                $ct_insert = 0;
                // 导入教师
                foreach ($ct_list as $k => $row) {
                    // insert
                    $db->insert('t_cteacher', array('ct_name' => $row['ct_name'], 'ct_memo' => $row['ct_memo'], 'ct_flag' => $param['ct_flag']));
                    $ct_id = $db->lastInsertId('t_cteacher', 'ct_id');
                    $bind = array('scht_schid' => $sch_id, 'scht_ctid' => $ct_id);
                    $db->insert('t_cteacher_school', $bind);
                    foreach ($row['ctg_gradeid'] as $v) {
                        $db->insert('t_cteacher_gradeid', array('ctg_ctid' => $ct_id, 'ctg_gradeid' => $v));
                    }
                    foreach ($row['cts_subjectid'] as $v) {
                        $db->insert('t_cteacher_subjectid', array('cts_ctid' => $ct_id, 'cts_subjectid' => $v));
                    }
                    $ct_insert++;
                }
                if ($db->commit()) {
                    $data['success'] = <<<EOT
导入Excel文件({$_FILES['file']['name']})成功,共插入{$ct_insert}条教师记录
EOT;
                    admin_log('add', 'cteacher', $data['success']);
                } else {
                    $err = $db->errorInfo()[2];
                    $db->rollBack();
                    throw new Exception($err);
                }
            } catch (Exception $e) {
                $data['error'] = $e->getMessage();
            }
            break;
        }
        if (!isset($_FILES['file'])) {
            $param = array('ct_flag' => time());
        }
        $data['param'] = $param;
        $this->load->view('school/importteacher', $data);
    }
示例#7
0
    /**
     * @description 预览学生信息
     * @author
     * @final
     * @param int $uid 学生id
     */
    public function preview($uid = 0)
    {
        if (!$this->check_power('student_list,student_manage')) {
            return;
        }
        $uid = intval($uid);
        /*
         * 基本信息
         */
        $uid && ($student = StudentModel::get_student($uid));
        if (!$student) {
            message('学生信息不存在。');
            return;
        }
        $db = Fn::db();
        $sbinfo = $db->fetchRow("SELECT * FROM t_student_base WHERE sb_uid = {$uid}");
        if (is_array($sbinfo)) {
            $student = array_merge($student, $sbinfo);
        }
        $sql = <<<EOT
SELECT sbs_stunumtype FROM t_student_base_stunumtype WHERE sbs_uid = {$uid}
EOT;
        $student['sbs_stunumtype'] = $db->fetchCol($sql);
        $sql = <<<EOT
SELECT sbclassid_classid FROM t_student_base_classid WHERE sbclassid_uid = {$uid}
EOT;
        $student['sbclassid_classid'] = $db->fetchCol($sql);
        $sql = <<<EOT
SELECT a.*, 
b.ti_id, b.ti_name, b.ti_typeid, b.ti_flag, b.ti_provid, b.ti_cityid, b.ti_areaid,  
c.cors_id, c.cors_cmid, c.cors_name, c.cors_flag, c.cors_tiid, c.cors_stunumtype
FROM t_student_base_course a
LEFT JOIN v_training_institution b ON a.sbc_tiid = b.ti_id
LEFT JOIN v_course c ON a.sbc_corsid = c.cors_id
WHERE a.sbc_uid = {$uid} AND a.sbc_idx = 0
EOT;
        $sbcinfo = $db->fetchRow($sql);
        if (is_array($sbcinfo)) {
            $student = array_merge($student, $sbcinfo);
            $student['no_tiid'] = 0;
        } else {
            $student['no_tiid'] = 1;
        }
        /*
         * 成绩排名
         */
        $sql = <<<EOT
SELECT * FROM rd_student_ranking WHERE uid = ? ORDER BY grade_id ASC
EOT;
        $score_ranks = $db->fetchAll($sql, $uid);
        /*
         * 竞赛成绩
         */
        $sql = <<<EOT
SELECT * FROM rd_student_awards WHERE uid = ?
EOT;
        $rows = $db->fetchAll($sql, $uid);
        $awards_list = array();
        foreach ($rows as $row) {
            $awards_list[$row['typeid']][] = $row;
        }
        /*
         * 社会实践
         */
        $sql = <<<EOT
SELECT * FROM rd_student_practice WHERE uid = ?
EOT;
        $practice = $db->fetchRow($sql, $uid);
        /*
         * 学生意愿
         */
        $sql = <<<EOT
SELECT * FROM rd_student_wish WHERE uid = ?
EOT;
        $student_wish = $db->fetchRow($sql, $uid);
        /*
         * 家长意愿
         */
        $sql = <<<EOT
SELECT * FROM rd_student_parent_wish WHERE uid = ?
EOT;
        $parent_wish = $db->fetchRow($sql, $uid);
        // 学考选考
        $sql = <<<EOT
SELECT * FROM rd_xuekao_xuankao WHERE uid = ?
EOT;
        $xuekao_xuankao = $db->fetchRow($sql, $uid);
        /*
         * 处理完善学生信息
         */
        $grades = C('grades');
        $student['birthday'] = date('Y-m-d', $student['birthday']);
        $row1 = SchoolModel::schoolInfo($student['school_id'], 'school_name');
        $student['school_name'] = $row1['school_name'];
        $student['grade_name'] = $grades[$student['grade_id']];
        $specs = array('0' => '哲学', '1' => '经济学', '2' => '法学', '3' => '教育学', '4' => '文学', '5' => '历史学', '6' => '理学', '7' => '工学', '8' => '农学', '9' => '医学', '10' => '军事学', '11' => '管理学', '12' => '艺术类', '13' => '不清楚');
        $school_id_arr = array();
        $swv = Fn::db()->fetchOne("SELECT volunteer FROM rd_student_wish WHERE uid = {$uid}");
        $school_id_arr = json_decode($swv);
        if ($swv) {
            foreach ($school_id_arr as $k => $v) {
                $school_id[$k] = $v;
                if ($v != 0) {
                    $volunteer[$k] = Fn::db()->fetchOne("SELECT school_name FROM rd_school WHERE school_id = {$v}");
                }
            }
        }
        $data['volunteer'] = $volunteer;
        $data['subjects'] = C('subject');
        $data['specs'] = $specs;
        $data['uid'] = $uid;
        $data['grades'] = $grades;
        $data['student'] = $student;
        $data['score_ranks'] = $score_ranks;
        $data['awards_list'] = $awards_list;
        $data['practice'] = $practice;
        $data['student_wish'] = $student_wish;
        $data['parent_wish'] = $parent_wish;
        $data['xuekao_xuankao'] = $xuekao_xuankao;
        $data['subject_list'] = C('subject');
        $data['awards_levels'] = C('awards_level');
        $data['stunumtype_list'] = CourseModel::courseStuNumTypeList();
        $data['class_list'] = ClassModel::get_class_list($student['grade_id']);
        // 模版
        $this->load->view('student/preview', $data);
    }
 /**
  * 学生成绩列表
  *
  * @param  int  $exam_id
  * @return  void
  */
 public function index($exam_pid = 0)
 {
     if (!$this->check_power('exam_list,exam_manage')) {
         return;
     }
     $page = intval($this->input->get('page'));
     $per_page = intval($this->input->get('per_page'));
     $exam_pid = intval($this->input->get('exam_pid'));
     $flag = $this->input->get('flag');
     $place_id = intval($this->input->get('place_id'));
     $school_id = intval($this->input->get('school_id'));
     $ticket = trim($this->input->get('ticket'));
     $score_start = trim($this->input->get('score_start'));
     $score_end = trim($this->input->get('score_end'));
     $subject_id = intval($this->input->get('subject_id'));
     $keyword = trim($this->input->get('keyword'));
     //var_dump($place_id);die;
     // 查询条件
     $query = array();
     $param = array();
     $search = array('exam_pid' => '', 'place_id' => '', 'flag' => '-2', 'keyword' => '', 'subject_id' => '', 'school_id' => '', 'school_name' => '', 'ticket' => '', 'score_start' => '', 'score_end' => '');
     $flags = array('-1' => '结果作废', '0' => '未生成分数(考试中)', '1' => '已交卷(未统计结果)', '2' => '已生成分数');
     //考试期次
     $exam_pid = !$exam_pid ? 0 : $exam_pid;
     if ($exam_pid) {
         $query['exam_pid'] = $exam_pid;
         $param[] = "exam_pid={$exam_pid}";
         $search['exam_pid'] = $exam_pid;
     }
     //状态
     if ($flag === false) {
     } else {
         if ($flag > -2) {
             $query['etp_flag'] = $flag;
             $param[] = "flag={$flag}";
             $search['flag'] = $flag;
         }
     }
     /*
     if (isset($query['etp_flag']) && $query['etp_flag'] == '2') {
     	$query['etp_flag'] = array('2', '-1');
     }
     */
     //考场
     if ($place_id) {
         $query['place_id'] = $place_id;
         $param[] = "place_id={$place_id}";
         $search['place_id'] = $place_id;
     }
     //学科
     if ($subject_id) {
         $query['subject_id'] = $subject_id;
         $param[] = "subject_id={$subject_id}";
         $search['subject_id'] = $subject_id;
     }
     //学科
     if ($keyword) {
         $escape_keyword = $this->db->escape_like_str($keyword);
         $where = "fullname LIKE '%" . $escape_keyword . "%'";
         $sql = "SELECT group_concat(uid) as uid FROM v_rd_student s WHERE {$where} ";
         $res = $this->db->query($sql)->row_array();
         $uids = explode(',', $res['uid']);
         $query['uid'] = $uids;
         $search['keyword'] = $keyword;
         $param[] = "keyword=" . urlencode($search['keyword']);
     }
     //得分查询
     if ($score_start != '') {
         $query['test_score']['>='] = $score_start;
         $param[] = "score_start={$score_start}";
         $search['score_start'] = $score_start;
     }
     if ($score_end != '') {
         $query['test_score']['<='] = $score_end;
         $param[] = "score_end={$score_end}";
         $search['score_end'] = $score_end;
     }
     //获取该学校下所有的学生
     if ($school_id) {
         $param[] = "school_id={$school_id}";
         $search['school_id'] = $school_id;
         $row = SchoolModel::schoolInfo($school_id, 'school_name');
         if ($row) {
             $school_name = trim($row['school_name']);
         } else {
             $school_name = '';
         }
         if (!count($school_name)) {
             $query = null;
             $search['school_name'] = $school_id;
         } else {
             $students = StudentModel::get_student_list(array('school_id' => $school_id), false, false, null, 'uid');
             if (count($students)) {
                 $uids = array();
                 foreach ($students as $student) {
                     $uids[] = $student['uid'];
                 }
                 $query['uid'] = $uids;
             } else {
                 $query = null;
             }
             $search['school_name'] = $school_name;
         }
     }
     //准考证号
     if ($ticket) {
         if (stripos($ticket, '@') === false) {
             $uid = StudentModel::get_student_by_exam_ticket($ticket, 'uid');
         } else {
             $uid = StudentModel::get_student_by_email($ticket, 'uid');
         }
         if (count($uid)) {
             $query['uid'] = $uid;
         } else {
             $query = null;
         }
         $param[] = "ticket={$ticket}";
         $search['ticket'] = $ticket;
     }
     $select_what = '*';
     $page = $page <= 0 ? 1 : $page;
     $per_page = $per_page <= 0 ? 10 : $per_page;
     $list = array();
     if (!is_null($query)) {
         $list = ExamTestPaperModel::get_test_paper_list($query, $page, $per_page, 'subject_id ASC,etp_id ASC', $select_what);
     }
     //获取学生信息
     $grades = C('grades');
     $subjects = C('subject');
     $data['subjects'] = $subjects;
     $tmp_list = array();
     foreach ($list as $k => $item) {
         $student = StudentModel::get_student($item['uid'], 'first_name, last_name, school_id, exam_ticket, grade_id');
         if (!count($student)) {
             $tmp_list[$k] = array_merge($item, array('truename' => '--', 'school_name' => '--', 'grade_name' => '--', 'subject_name' => '--'));
             continue;
         }
         $student['truename'] = $student['last_name'] . $student['first_name'];
         //获取学生学校信息
         $row = SchoolModel::schoolInfo($student['school_id'], 'school_name');
         if ($row) {
             $school_name = trim($row['school_name']);
         } else {
             $school_name = '';
         }
         $student['school_name'] = count($school_name) ? $school_name : '--';
         //获取该学生所在的年级
         $student['grade_name'] = isset($grades[$student['grade_id']]) ? $grades[$student['grade_id']] : '--';
         //获取科目
         $subject_name = SubjectModel::get_subject($item['subject_id'], 'subject_name');
         $student['subject_name'] = count($subject_name) ? $subject_name : '--';
         //获取考试试卷信息
         $paper_name = ExamPaperModel::get_paper($item['paper_id'], 'paper_name');
         $item['paper_name'] = count($paper_name) ? $paper_name : '--';
         //获取作废记录
         $etp_invalid_record = ExamTestPaperModel::get_etp_invalid_record($item['etp_id']);
         if (!$etp_invalid_record) {
             $item['invalid_record'] = false;
             $item['invalid_record_note'] = '';
         } else {
             $item['invalid_record'] = true;
             $item['invalid_record_note'] = $etp_invalid_record['note'];
         }
         $tmp_list[$k] = array_merge($item, $student);
     }
     $data['list'] =& $tmp_list;
     $data['search'] =& $search;
     $data['flags'] =& $flags;
     // 分页
     $purl = site_url('admin/exam_student_result/index/') . (count($param) ? '?' . implode('&', $param) : '');
     $total = ExamTestPaperModel::count_list($query);
     $data['pagination'] = multipage($total, $per_page, $page, $purl);
     $data['priv_manage'] = $this->check_power('exam_manage', FALSE);
     $this->load->view('exam_student_result/index', $data);
 }
示例#9
0
 public function add($method = 'manual', $place_id = 0, $page_size = '')
 {
     if (!$this->check_power('exam_manage')) {
         return;
     }
     $param = array();
     $place_id = intval($place_id);
     if ($place_id) {
         $query = $this->db->select('p.*,e.exam_id,e.exam_name,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();
     }
     if (empty($place)) {
         message('考场信息不存在', 'admin/exam/index');
         return;
     }
     $subjects = ExamPlaceModel::get_exam_place_subject($place_id);
     if (empty($subjects)) {
         message('考场学科信息不存在', 'admin/exam/index');
         return FALSE;
     }
     foreach ($subjects as $row) {
         $query = $this->db->select('paper_id,exam_pid')->where(array('exam_id' => $row['exam_id']))->order_by('rand()')->get(self::$_table_exam_subject_paper, 1);
         $arr = $query->row_array();
         if (!isset($arr['paper_id'])) {
             message('考场学科试卷信息不存在', 'admin/exam/index');
             return FALSE;
         }
     }
     // 控制考场只能在未开始考试操作
     $no_start = ExamPlaceModel::place_is_no_start($place_id);
     if (!$no_start) {
         message('该考场正在考试或已结束,无法做此操作');
     }
     // 是否为本考场所在的学校的考生
     $school_id = $place['school_id'];
     if ($school_id) {
         $query_school_id = intval($this->input->post('school_id'));
         if ($query_school_id) {
             $school_id = $query_school_id;
         }
         $param[] = "school_id=" . $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;
     // 不存在这些状态:已参加正在进行、已参加还未开始、已参加相同学科
     $not_exists_sql = "SELECT uid FROM {pre}exam_place_student ps,{pre}exam_place p WHERE ps.place_id=p.place_id AND p.place_index={$place['place_index']} AND ps.uid=u.uid 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 {pre}exam_place_subject eps where eps.subject_id in({$subject_ids}) and eps.exam_pid={$place['exam_id']}) )";
     $tmp_sql = '';
     $data['student_name'] = $this->input->post('student_name');
     if ($data['student_name']) {
         $student_name = "'" . implode("','", array_unique(array_filter(explode("\n", $data['student_name'])))) . "'";
         $tmp_sql = " AND u.uid IN (SELECT uid FROM v_rd_student WHERE fullname IN ({$student_name}))";
     }
     // 统计还未安排考场的学生数量(以学校作为一个考点单位)
     $sql = "SELECT COUNT(*) nums FROM {pre}student u\n                WHERE u.school_id={$school_id} AND u.grade_id={$place['grade_id']} AND u.is_delete=0\n                AND NOT EXISTS({$not_exists_sql}) {$tmp_sql}";
     $row = $this->db->query($sql)->row_array();
     $total = $row['nums'];
     if ($total == 0) {
         // message('所有学生都已经分配考场', 'admin/place_student/index/'.$place_id);
         // return;
     }
     $data['page_size'] = $page_size;
     if ($method == 'auto') {
         // 自动模式添加
         $tpl = 'place_student/add_auto';
     } else {
         // 手工模式添加
         $tpl = 'place_student/add_manual';
         $size = $page_size ? $page_size : 15;
         $page = isset($_GET['page']) && intval($_GET['page']) > 1 ? intval($_GET['page']) : 1;
         $offset = ($page - 1) * $size;
         $list = array();
         // 获取所有学校里未被分配过考场的学生
         $sql = "SELECT u.uid,u.first_name,u.last_name,u.email,u.exam_ticket,u.sex,sch.school_name\n                    FROM {pre}student u,{pre}school sch\n                    WHERE u.school_id=sch.school_id " . ($school_id ? "AND u.school_id={$school_id}" : '') . " AND u.grade_id={$place['grade_id']} AND u.is_delete=0\n                    AND NOT EXISTS({$not_exists_sql}) {$tmp_sql} LIMIT {$offset},{$size}";
         $query = $this->db->query($sql);
         foreach ($query->result_array() as $row) {
             $list[] = $row;
         }
         // 分页
         $purl = site_url('admin/place_student/add/manual/' . $place_id . '/' . $size . ($param ? '?' . implode('&', $param) : ''));
         $data['pagination'] = multipage($total, $size, $page, $purl);
         $data['list'] =& $list;
     }
     $school = SchoolModel::schoolInfo($school_id);
     $data['total'] = $total;
     $data['place'] =& $place;
     $data['school'] =& $school;
     // 模版
     $this->load->view($tpl, $data);
 }
示例#10
0
 public function teaList()
 {
     import("@.ORG.Page");
     //导入分页类
     $stu = new StuModel();
     $count = $stu->count();
     $p = new Page($count, 15);
     $stu_res = $stu->relation('School')->limit($p->firstRow . ',' . $p->listRows)->order('stu_id desc')->findAll();
     $p->setConfig('header', '篇记录');
     $p->setConfig('prev', "上一页");
     $p->setConfig('next', '下一页');
     $p->setConfig('first', '<<');
     $p->setConfig('last', '>>');
     $page = $p->show();
     $school = new SchoolModel();
     $school_res = $school->findAll();
     $xueji_res = getXueji();
     $city_res = getCity();
     $this->assign('xueji_res', $xueji_res);
     $this->assign('city_res', $city_res);
     $this->assign('school_res', $school_res);
     $this->assign('stu_res', $stu_res);
     $this->assign("page", $page);
     $this->display();
 }
示例#11
0
 /**
  * [_getList description]
  * @method _getList
  * @return [type]   [description]
  * @access private
  * @author NewFuture
  */
 private static function _getList()
 {
     if (!($list = Cache::get('v_school_list'))) {
         $schools = SchoolModel::where('id', '>', 0)->select('id,abbr');
         foreach ($schools as $school) {
             $list[$school['id']] = strtolower($school['abbr']);
         }
         Cache::set('v_school_list', $list, 864000);
     }
     return $list;
 }
示例#12
0
文件: Share.php 项目: krisrita/udo
 function holiday1Action()
 {
     $schoolModel = new SchoolModel();
     $count = $schoolModel->bannerData(2780, 0);
     //print_r($count);
     $bCount = $count['boughtCount'];
     $cCount = $this->get('cCount');
     $this->assign('bCount', $bCount);
     $this->assign('cCount', $cCount);
 }
示例#13
0
文件: Account.php 项目: krisrita/udo
 function getOrderAction()
 {
     $userId = (int) $this->get('userId', 0);
     $mobile = $this->get('mobile', "");
     $status = (int) $this->get('status', -1);
     $payType = (int) $this->get('payType', 0);
     $previousId = (int) $this->get('previousId', 0);
     $pageSize = (int) $this->get('pageSize', 20);
     $date = $this->get('date', "");
     $page = (int) $this->get('page', 1);
     $startTime = 0;
     $endTime = 0;
     if ($date) {
         $startTime = strtotime(substr($date, 0, 10));
         $endTime = strtotime(substr($date, 13, 10));
     }
     /*        print_r($date);
             print_r(substr($date,0,10)." - ".substr($date,13,10));
             print_r($startTime." - ".$endTime);*/
     $accountModel = new AccountModel();
     $order = $accountModel->getOrder($userId, $mobile, $startTime, $endTime, $status, $payType, $previousId, $page, $pageSize);
     $orderList = $order['orderList'];
     $userModel = new UserModel();
     $schoolModel = new SchoolModel();
     $tradeModel = new TradeModel();
     //对orderList进行处理
     foreach ($orderList as $k => $value) {
         $orderList[$k]['mobile'] = $userModel->getUserName($value['userId'])['mobile'];
         switch ($value['payType']) {
             case Common_Config::UDO_PAYTYPE_COIN:
                 $orderList[$k]['payType'] = "U币购买";
                 break;
             case Common_Config::UDO_PAYTYPE_CREDIT:
                 $orderList[$k]['payType'] = "学分购买";
                 break;
             case Common_Config::UDO_PAYTYPE_RECHARGE:
                 $orderList[$k]['payType'] = "U币充值";
                 break;
         }
         switch ($value['status']) {
             case Common_Config::ORDER_SUCCESS:
                 $orderList[$k]['status'] = "支付成功";
                 break;
             case Common_Config::ORDER_NOT_PAY:
                 $orderList[$k]['status'] = "尚未支付";
                 break;
             case Common_Config::ORDER_FAIL:
                 $orderList[$k]['status'] = "订单支付失败";
                 break;
             case Common_Config::ORDER_CLOSED:
                 $orderList[$k]['status'] = "订单关闭";
                 break;
         }
         $orderList[$k]['createTime'] = date('Y-m-d H:i:s', $value['createTime']);
         //为order中的每一项赋予序号,便于在模板中的foreach给class赋值
         $orderList[$k]['no'] = $k;
         //处理resource
         //resource取出来是序列化的字符串,首先先反序列化
         if ($value['resource']) {
             $courseCount = 0;
             //$value['resource'] = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $value['resource']);
             //print_r($value['resource']);
             $orderList[$k]['resource'] = json_decode($value['resource'], true);
             $schoolInfo = [];
             //print_r($orderList[$k]['resource']);
             foreach ($orderList[$k]['resource'] as $v => $val) {
                 if ($val['resourceId'] == 1) {
                     continue;
                 }
                 $orderList[$k]['resource'][$v]['resourceName'] = $schoolModel->getSingleCourse($val['resourceId'])['name'];
                 $courseCount++;
                 if (!$schoolInfo) {
                     $schoolInfo = $schoolModel->getSchoolByCourse($val['resourceId']);
                 }
             }
             $orderList[$k]['courseCount'] = $courseCount;
             $orderList[$k]['schoolName'] = $schoolInfo['customer_name'];
             $orderList[$k]['schoolTitle'] = $schoolInfo['customer_title'];
         }
     }
     /*
      * 计算总页数,确定页码显示.页码显示需要的参数:
      */
     $pageNumber = ceil($order['orderCount'] / $pageSize);
     //如果总页数比10小或当前页比6小,那么分页变量是1到分页总数
     if ($pageNumber <= 10) {
         $pagination = range(1, $pageNumber);
     } elseif ($page <= 6 && $pageNumber > 10) {
         $pagination = range(1, 10);
     } else {
         $pagination = range($page - 5, $page + 4);
     }
     /*
      * 初始化筛选参数
      */
     $initFilter = array("date" => $date, "status" => $status, "payType" => $payType, "mobile" => $mobile, "userId" => $userId, "page" => $page, "pageNumber" => $pageNumber, "orderCount" => $order['orderCount']);
     $this->assign('orderList', $orderList);
     $this->assign('status', $tradeModel->getOrderStatus());
     $this->assign('payType', $tradeModel->getOrderPaytype());
     $this->assign('init', $initFilter);
     $this->assign('pagination', $pagination);
 }
示例#14
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');
     }
 }
 public function addcourse()
 {
     $username = Cookie::get('username');
     $usertype = Cookie::get('usertype');
     $userid = Cookie::get('userid');
     $school = new SchoolModel();
     $teacher = new TeacherModel();
     $schoollist = $school->select();
     $teacherlist = $teacher->select();
     $this->assign('schoollist', $schoollist);
     $this->assign('teacherlist', $teacherlist);
     $this->assign('username', $username);
     $this->assign('usertype', $usertype);
     $this->assign('userid', $userid);
     $this->display();
 }
示例#16
0
 /**
  * 编辑考场信息
  *
  * @return  void
  */
 public function edit($id = 0)
 {
     if (!$this->check_power('exam_manage')) {
         return;
     }
     $id = intval($id);
     $id && ($place = ExamPlaceModel::get_place($id));
     if (empty($place)) {
         message('考场不存在');
         return;
     }
     $parent = ExamModel::get_exam($place['exam_pid'], 'exam_id,exam_name,exam_pid,grade_id,creator_id,managers,exam_isfree');
     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);
     $place['start_time'] = date('Y-m-d H:i', $place['start_time']);
     $place['end_time'] = date('Y-m-d H:i', $place['end_time']);
     $place['exam_time_custom'] = json_decode($place['exam_time_custom'], true);
     $grade_period = get_grade_period($parent['grade_id']);
     $query = $this->db->select('s.school_id,s.school_name,count(u.uid) nums')->from('school s')->join('student u', 's.school_id=u.school_id')->like('s.grade_period', $grade_period)->where(array('u.is_delete' => 0))->group_by('s.school_id')->get();
     $schools = $query->result_array();
     if ($schools) {
         $school_ids = array();
         foreach ($schools as $item) {
             $school_ids[] = $item['school_id'];
         }
         $param['schcls_schid'] = implode(',', $school_ids);
         $data['class'] = SchoolModel::schoolClassList("*", $param, 1, time());
     }
     $data['act'] = 'edit';
     $data['place'] =& $place;
     $data['parent'] =& $parent;
     $data['schools'] =& $schools;
     // 模版
     $this->load->view('exam_place/edit', $data);
 }
示例#17
0
 /**
  * 验证准备注册
  * @method verify
  * @access public
  * @author NewFuture[newfuture@yunyin.org]
  * @return bool|null
  */
 public function verify($number, $password, $sch_id = null, $code = null)
 {
     $info = array('number' => $number, 'password' => $password, 'sch_id' => $sch_id);
     $code and $info['code'] = $code;
     //验证码
     /*黑名单*/
     $black = isset($this->reg_schools) ? $this->reg_schools : [];
     if (!($result = School::verify($info, $black))) {
         return false;
     } elseif ($result = array_filter($result)) {
         /*验证成功*/
         $reg = array('number' => $info['number'], 'password' => md5($info['password']), 'name' => current($result), 'sch_id' => key($result));
         $sid = Session::start();
         Session::set('reg', $reg);
         unset($reg['password']);
         $reg['school'] = SchoolModel::getName($reg['sch_id']);
         $this->response(2, ['sid' => $sid, 'user' => $reg, 'msg' => '验证成功', 'url' => '/user/']);
         return true;
     }
 }
 public function test()
 {
     $course = new CourseModel();
     $school = new SchoolModel();
     $courselist = $course->select();
     $schoollist = $school->select();
     $this->assign('schoollist', $schoollist);
     $this->assign('courselist', $courselist);
     $this->display();
 }
示例#19
0
文件: School.php 项目: krisrita/udo
 function searchSchoolAction()
 {
     $request = $this->getRequest();
     if ('POST' == $request->getMethod()) {
         $ssotoken = $this->post()->get("ssotoken");
         $keyword = $this->post()->get("keyword");
     } else {
         $ssotoken = $this->get("ssotoken");
         $keyword = $this->get("keyword");
     }
     if (!$ssotoken || !$keyword) {
         $this->displayJsonUdo(Common_Error::ERROR_PARAM);
     }
     //获取用户id
     $userModel = new UserModel();
     $uid = $userModel->getUserId($ssotoken);
     if (is_array($uid)) {
         $this->displayJsonUdo(Common_Error::INVALID_TOKEN, "", $uid['msg']);
     }
     $schoolModel = new SchoolModel();
     $result = $schoolModel->searchSchool($keyword, $ssotoken);
     if ($result == -1) {
         $this->displayJsonUdo(Common_Error::ERROR_NO_SEARCH_RESULT, "", "搜索结果为空");
     }
     $this->displayJsonUdo(Common_Error::ERROR_SUCCESS, $result);
 }
示例#20
0
 /**
  * @param   int     $rule_id
  * @param   int     $exam_id
  * @param   int     $stu_id
  * @return  mixed
  */
 public static function studentTranscriptInfo($rule_id, $exam_id, $stu_id)
 {
     $rule_id = intval($rule_id);
     $exam_id = intval($exam_id);
     $stu_id = intval($stu_id);
     if (!$rule_id || !$exam_id || !$stu_id) {
         return array();
     }
     //考试信息
     $exam = self::$_data['exam_info'][$exam_id];
     if (!$exam) {
         $exam = ExamModel::get_exam($exam_id);
         if (!$exam) {
             return array();
         }
         self::$_data['exam_info'][$exam_id] = $exam;
     }
     //学生信息
     $stu_info = StudentModel::get_student($stu_id, 'school_id,last_name,first_name,external_account,exam_ticket');
     if (!$stu_info) {
         return array();
     }
     $db = Fn::db();
     $data = array();
     $subject_id = $exam['subject_id'];
     $exam_pid = $exam['exam_pid'];
     $subject_name = C('subject/' . $subject_id);
     if (!isset(self::$_data['school_rank'][$exam_id][$stu_info['school_id']])) {
         $sql = "SELECT uid, rank\n                    FROM rd_summary_region_student_rank\n                    WHERE exam_id = {$exam_id} AND region_id = ?\n                    AND is_school = 1 AND is_class = 0\n                    ORDER BY rank ASC";
         $grade_rank = $db->fetchPairs($sql, array($stu_info['school_id']));
         self::$_data['school_rank'][$exam_id][$stu_info['school_id']] = $grade_rank;
     } else {
         $grade_rank = self::$_data['school_rank'][$exam_id][$stu_info['school_id']];
     }
     $sql = "SELECT a.etp_id, paper_id, test_score, ques_id FROM rd_exam_test_paper a\n                LEFT JOIN rd_exam_test_paper_question b ON a.etp_id = b.etp_id\n                WHERE uid = ? AND exam_id = ?";
     $bind = array($stu_id, $exam_id);
     $etp = $db->fetchRow($sql, $bind);
     if (!$etp) {
         return array();
     }
     $proportion = self::$_data['distribution_proportion'][$rule_id];
     if (!$proportion) {
         $proportion = json_decode(EvaluateRuleModel::get_evaluate_rule($rule_id, 'distribution_proportion'), true);
         if (!$proportion) {
             $proportion = array('高分段' => 27, '中分段' => 73, '低分段' => 100);
         }
         $proportion = array_values($proportion);
         self::$_data['distribution_proportion'][$rule_id] = $proportion;
     }
     $level_results = 'A';
     $prev_rank = 0;
     $stu_num = count($grade_rank);
     $stu_rank = $grade_rank[$stu_id];
     foreach ($proportion as $k => $rate) {
         $rank = $stu_num * $rate / 100;
         if ($prev_rank < $stu_rank && $stu_rank <= $rank) {
             break;
         }
         $level_results++;
         $prev_rank = $rank;
     }
     $sch_name = self::$_data['school_info'][$stu_info['school_id']];
     if (!$sch_name) {
         $school = SchoolModel::schoolInfo($stu_info['school_id'], 'school_name');
         $sch_name = $school['school_name'];
         self::$_data['school_info'][$stu_info['school_id']] = $sch_name;
     }
     //成绩信息
     $data['results'] = array('exam_name' => $exam['exam_name'], 'stu_fullname' => $stu_info['last_name'] . $stu_info['first_name'], 'stu_schname' => $sch_name, 'subject_name' => $subject_name, 'exam_ticket' => $stu_info['external_account'] ? $stu_info['external_account'] : $stu_info['exam_ticket'], 'test_score' => $etp['test_score'], 'level_results' => $level_results);
     //试题得分
     //计算学校总体试卷试题得分率
     $level_percent = self::$_data['school_question_level_percent'][$etp['paper_id']][$stu_info['school_id']];
     if (!$level_percent) {
         $sql = "SELECT ques_id, ROUND(test_score / total_score * 100) AS percent\n                    FROM rd_summary_region_question\n                    WHERE exam_id = {$exam_id} AND region_id = {$stu_info['school_id']}\n                    AND is_school = 1";
         $stmt = $db->query($sql);
         while ($item = $stmt->fetch(PDO_DB::FETCH_ASSOC)) {
             self::calLevelPercent($item['ques_id'], $item['percent'], $level_percent);
         }
         self::$_data['school_level_percent'][$etp['paper_id']][$stu_info['school_id']] = $level_percent;
     }
     //计算本次学生试题得分率
     $sql = "SELECT ques_id, ROUND(SUM(test_score) / SUM(full_score) * 100) AS percent\n                FROM rd_exam_test_result WHERE etp_id = ?\n                GROUP BY ques_id";
     $stu_percent = $db->fetchPairs($sql, array($etp['etp_id']));
     //计算学生考试试题得分率对应等级
     $ques_ids = explode(',', $etp['ques_id']);
     $data['question'] = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array());
     foreach ($ques_ids as $index => $ques_id) {
         $percent = $stu_percent[$ques_id] > 100 ? 100 : (int) $stu_percent[$ques_id];
         foreach ($level_percent[$ques_id] as $level => $v) {
             if ($v[0] <= $percent && $percent <= $v[1]) {
                 $data['question'][$level][] = $index + 1;
                 break;
             }
         }
     }
     ksort($data['question']);
     //知识点
     $level_percent = self::$_data['school_knowledge_level_percent'][$etp['paper_id']][$stu_info['school_id']];
     if (!$level_percent) {
         $sql = "SELECT knowledge_id, ROUND(test_score / total_score * 100) AS percent\n                    FROM rd_summary_region_knowledge\n                    WHERE exam_id = {$exam_id} AND region_id = {$stu_info['school_id']}\n                    AND is_school = 1 AND is_parent = 0";
         $stmt = $db->query($sql);
         while ($item = $stmt->fetch(PDO::FETCH_ASSOC)) {
             self::calLevelPercent($item['knowledge_id'], $item['percent'], $level_percent);
         }
         self::$_data['school_knowledge_level_percent'][$etp['paper_id']][$stu_info['school_id']] = $level_percent;
     }
     //计算本次学生知识点得分率
     $sql = "SELECT knowledge_id, knowledge_name, ROUND(test_score / total_score * 100) AS percent\n                FROM rd_summary_student_knowledge ssk\n                LEFT JOIN rd_knowledge k ON k.id = ssk.knowledge_id\n                WHERE paper_id = ? AND uid = ? AND is_parent = 0";
     $stu_percent = $db->fetchAssoc($sql, array($etp['paper_id'], $stu_id));
     $data['knowledge'] = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array());
     foreach ($level_percent as $knowledge_id => $levels) {
         $percent = $stu_percent[$knowledge_id]['percent'] > 100 ? 100 : (int) $stu_percent[$knowledge_id]['percent'];
         foreach ($levels as $level => $v) {
             if ($v[0] <= $percent && $percent <= $v[1]) {
                 $data['knowledge'][$level][] = $stu_percent[$knowledge_id]['knowledge_name'];
                 break;
             }
         }
     }
     ksort($data['knowledge']);
     //方法策略
     $sql = "SELECT DISTINCT(subject_id) FROM rd_subject_category_subject";
     $subject_ids = $db->fetchCol($sql);
     if (in_array($subject_id, $subject_ids)) {
         $level_percent = self::$_data['school_method_tactic_level_percent'][$etp['paper_id']][$stu_info['school_id']];
         if (!$level_percent) {
             $sql = "SELECT method_tactic_id, ROUND(test_score / total_score * 100) AS percent\n                        FROM rd_summary_region_method_tactic\n                        WHERE exam_id = {$exam_id} AND region_id = {$stu_info['school_id']}\n                        AND is_school = 1";
             $stmt = $db->query($sql);
             while ($item = $stmt->fetch(PDO::FETCH_ASSOC)) {
                 self::calLevelPercent($item['method_tactic_id'], $item['percent'], $level_percent);
             }
             self::$_data['school_method_tactic_level_percent'][$etp['paper_id']][$stu_info['school_id']] = $level_percent;
         }
         //计算本次学生方法策略得分率
         $sql = "SELECT method_tactic_id, name, ROUND(test_score / total_score * 100) AS percent\n                    FROM rd_summary_student_method_tactic ssmt\n                    LEFT JOIN rd_method_tactic mt ON mt.id = ssmt.method_tactic_id\n                    WHERE paper_id = ? AND uid = ?";
         $stu_percent = $db->fetchAssoc($sql, array($etp['paper_id'], $stu_id));
         $data['method_tactic'] = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array());
         foreach ($level_percent as $method_tactic_id => $levels) {
             $percent = $stu_percent[$method_tactic_id]['percent'] > 100 ? 100 : (int) $stu_percent[$method_tactic_id]['percent'];
             foreach ($levels as $level => $v) {
                 if ($v[0] <= $percent && $percent <= $v[1]) {
                     $data['method_tactic'][$level][] = $stu_percent[$method_tactic_id]['name'];
                     break;
                 }
             }
         }
         ksort($data['method_tactic']);
     } else {
         if ($subject_id == 3) {
             $level_percent = self::$_data['school_group_type_level_percent'][$etp['paper_id']][$stu_info['school_id']];
             if (!$level_percent) {
                 $sql = "SELECT group_type_id, ROUND(test_score / total_score * 100) AS percent\n                        FROM rd_summary_region_group_type\n                        WHERE exam_id = {$exam_id} AND region_id = {$stu_info['school_id']}\n                        AND is_school = 1 AND is_parent = 0";
                 $stmt = $db->query($sql);
                 while ($item = $stmt->fetch(PDO::FETCH_ASSOC)) {
                     self::calLevelPercent($item['group_type_id'], $item['percent'], $level_percent);
                 }
                 self::$_data['school_group_type_level_percent'][$etp['paper_id']][$stu_info['school_id']] = $level_percent;
             }
             //计算本次学生信息提取方式得分率
             $sql = "SELECT group_type_id, group_type_name, ROUND(test_score / total_score * 100) AS percent\n                    FROM rd_summary_student_group_type ssgt\n                    LEFT JOIN rd_group_type gt ON gt.id = ssgt.group_type_id\n                    WHERE paper_id = ? AND uid = ? AND is_parent = 0";
             $stu_percent = $db->fetchAssoc($sql, array($etp['paper_id'], $stu_id));
             $data['group_type'] = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array());
             foreach ($level_percent as $group_type_id => $levels) {
                 $percent = $stu_percent[$group_type_id]['percent'] > 100 ? 100 : (int) $stu_percent[$group_type_id]['percent'];
                 foreach ($levels as $level => $v) {
                     if ($v[0] <= $percent && $percent <= $v[1]) {
                         $data['group_type'][$level][] = $stu_percent[$group_type_id]['group_type_name'];
                         break;
                     }
                 }
             }
             ksort($data['group_type']);
         }
     }
     return $data;
 }
示例#21
0
文件: Trade.php 项目: krisrita/udo
 function getSchoolPrice($priceType = 0, $isPriced = 2, $isPublic = 2, $keyword = "", $schoolId = 0)
 {
     $tblEntrance = new DB_Sso_Entrance();
     $tblSchoolPrice = new DB_Udo_SchoolPrice();
     $schoolModel = new SchoolModel();
     //构造筛选条件
     $where = "where open_status = 1";
     if ($keyword) {
         $where .= " and (customer_name like '%{$keyword}%' or customer_title like '%{$keyword}%')";
     }
     if ($schoolId) {
         $where .= " and id ={$schoolId}";
     }
     if ($isPublic != 2) {
         $where .= " and is_public = {$isPublic}";
     }
     //默认按照频道发布的先后顺序排
     $entrance = $tblEntrance->fetchAll("id,customer_name,customer_title,is_public,created_on", $where, "order by created_on desc");
     $resultArr = [];
     foreach ($entrance as $k => $val) {
         $price = $tblSchoolPrice->scalar("resourceId,priceType,price", "where resourceId = {$val['id']}");
         if (!$price) {
             $val['priceType'] = 0;
             $val['price'] = 0;
         } else {
             $val['price'] = $price['price'];
             $val['priceType'] = $price['priceType'];
         }
         //根据定价类型和是否定价的条件筛选掉不符合的项目
         if ($priceType) {
             if ($val['priceType'] != $priceType) {
                 continue;
             }
         }
         if ($isPriced == 1) {
             if (!$price) {
                 continue;
             }
         }
         if ($isPriced == 0) {
             if ($price) {
                 continue;
             }
         }
         //通过筛选的频道获取消费者人次和课程数量
         $val['cusNumber'] = $this->getCustomerNumber($val['id']);
         $val['courseNumber'] = $schoolModel->getCourseNumber($val['id']);
         //跟据数字类型的priceType给类型命名
         $val['type'] = $this->getPriceTypeName($price['priceType']);
         $val['public'] = $val['is_public'] ? "公开" : "私有";
         array_push($resultArr, $val);
     }
     return $resultArr;
 }
示例#22
0
 /**
  * 生成省市区+学校联动的源数据为JS文件.
  */
 public function generate_schools()
 {
     //TODO
     $school_info = $region_info = $school_names = $region_names = $region_parents = $region_depths = $region_schools = $grade_schools = array();
     $school_info = SchoolModel::get_v_schools();
     foreach ($school_info as $k => $v) {
         $school_names[$v['school_id']] = $v['school_name'];
         //1. 学校id=>名称关系
         $region_schools[$v['school_id']] = $v['area'];
         //2. 学校与所属区县的关系
         $grade_schools[2][] = $v['school_id'];
         //3. 年级段(小初高1,32,)与学校的关系
         $grade_schools[3][] = $v['school_id'];
         //年级段(小初高1,2,3)与学校的关系
     }
     $region_info = RegionModel::get_all_region();
     foreach ($region_info as $k2 => $v2) {
         $region_names[$v2['region_id']] = $v2['region_name'];
         //4. 地域id=>名称关系
         $region_parents[$v2['region_id']] = $v2['parent_id'];
         //5. 地域每级的关系
     }
     //6. 地域深度
     $region_array1 = $region_array2 = $region_array3 = $region_depths = array();
     $region_array1 = RegionModel::get_regions_by_depth(1);
     //省
     $region_array2 = RegionModel::get_regions_by_depth(2);
     //市
     $region_array3 = RegionModel::get_regions_by_depth(3);
     //区、县
     foreach ($region_array1 as $v3) {
         $region_depths[1][] = $v3['region_id'];
     }
     foreach ($region_array2 as $v4) {
         $region_depths[2][] = $v4['region_id'];
     }
     foreach ($region_array3 as $v5) {
         $region_depths[3][] = $v5['region_id'];
     }
     $str_1 = "var school_names = " . "'" . json_encode($school_names) . "';\n";
     $str_2 = "var region_schools = " . "'" . json_encode($region_schools) . "';\n";
     $str_3 = "var grade_schools = " . "'" . json_encode($grade_schools) . "';\n";
     $str_4 = "var region_names = " . "'" . json_encode($region_names) . "';\n";
     $str_5 = "var region_parents = " . "'" . json_encode($region_parents) . "';\n";
     $str_6 = "var region_depths = " . "'" . json_encode($region_depths) . "';\n";
     file_put_contents(FCPATH . 'js/schools_data.js', $str_1 . $str_2 . $str_3 . $str_4 . $str_5 . $str_6);
 }