Пример #1
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);
    }
Пример #2
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);
    }
Пример #3
0
 /**
  * 学生成绩列表
  *
  * @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);
 }
Пример #4
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;
 }
Пример #5
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);
 }
Пример #6
0
    public function preview()
    {
        Fn::ajax_call($this, 'login', 'logout');
        if (!$this->_uinfo['uid']) {
            redirect('student/index/login');
        }
        $uid = $this->_uinfo['uid'];
        $data = array();
        $data['uinfo'] = $this->_uinfo;
        if ($uid) {
            // 基本信息
            $student = StudentModel::get_student($uid);
            // 学习概况
            $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;
            }
            // 成绩排名
            $this->db->order_by('grade_id ASC');
            $query = $this->db->get_where('student_ranking', array('uid' => $uid));
            $score_ranks = $query->result_array();
            $start_grade = $student['grade_id'] < 3 ? 1 : $student['grade_id'] - 2;
            $grades = array();
            for ($i = $student['grade_id']; $i >= $start_grade; $i--) {
                $grades[] = $i;
            }
            /******TODO    暂时去除掉 ****************************************
               foreach ($score_ranks as $v){
                   if ( ! in_array($v[grade_id], $grades))
                   {
                       message('请填写最近三年年级成绩排名', 'student/profile/awards');
                       //$message[] = '请填写最近三年年级成绩排名';
                       break;
                   }
               }
               /****************************************************************/
            // 竞赛成绩
            $query = $this->db->get_where('student_awards', array('uid' => $uid));
            $awards_list = array();
            foreach ($query->result_array() as $row) {
                $awards_list[$row['typeid']][] = $row;
            }
            // 社会实践
            $query = $this->db->get_where('student_practice', array('uid' => $uid));
            $practice = $query->row_array();
            // 学生意愿
            $query = $this->db->get_where('student_wish', array('uid' => $uid));
            $student_wish = $query->row_array();
            // 家长意愿
            $query = $this->db->get_where('student_parent_wish', array('uid' => $uid));
            $parent_wish = $query->row_array();
            // 学考选考
            $query = $this->db->get_where('xuekao_xuankao', array('uid' => $uid));
            $xuekao_xuankao = $query->row_array();
            $subject_first = unserialize($xuekao_xuankao[subject_first]);
            /***  TODO      暂时去除掉 **************************************
               if ( ($student['grade_id'] == 11||$student['grade_id'] == 12) && !$subject_first[subject_id]&&!$subject_first[fenshu]&&! $subject_first[shijian] )
               {
                   message('第一次参加的选考科目及成绩', 'student/profile/awards');
               }
               /**************************************************************/
        } else {
            if (!($student = $this->session->userdata('student'))) {
                message('请填写基本信息!', 'student/profile/basic');
            }
            if (!($sbinfo = $this->session->userdata('student_base'))) {
                message('请填写学习概况!', 'student/profile/base');
            }
            if (is_array($sbinfo)) {
                $student = array_merge($student, $sbinfo);
            }
            if (!isset($student['sbs_stunumtype']) || !is_array($student['sbs_stunumtype'])) {
                $student['sbs_stunumtype'] = array();
            }
            if (!isset($student['sbclassid_classid']) || !is_array($student['sbclassid_classid'])) {
                $student['sbclassid_classid'] = array();
            }
            $score_ranks = $this->session->userdata('score_ranks');
            $start_grade = $student['grade_id'] < 3 ? 1 : $student['grade_id'] - 2;
            $grades = array();
            for ($i = $student['grade_id']; $i >= $start_grade; $i--) {
                $grades[] = $i;
            }
            foreach ($score_ranks as $v) {
                if (!in_array($v[grade_id], $grades)) {
                    message('请填写最近三年年级成绩排名', 'student/profile/awards');
                    // $message[] = '请填写最近三年年级成绩排名';
                    break;
                }
            }
            $awards_list = $this->session->userdata('awards_list');
            $xuekao_xuankao = $this->session->userdata('xuekao_xuankao');
            $subject_first = unserialize($xuekao_xuankao[subject_first]);
            if ($student['grade_id'] > 1 && !$score_ranks) {
                message('请填写学习成绩', 'student/profile/awards');
            }
            if (($student['grade_id'] == 11 || $student['grade_id'] == 12) && !$subject_first[subject_id] && !$subject_first[fenshu] && !$subject_first[shijian]) {
                message('第一次参加的选考科目及成绩', 'student/profile/awards');
            }
            if (!($practice = $this->session->userdata('practice'))) {
                message('请填写社会实践情况!', 'student/profile/practice');
            }
            if (!($student_wish = $this->session->userdata('student_wish'))) {
                message('请填写学生意愿!', 'student/profile/wish');
            }
            if (!($parent_wish = $this->session->userdata('parent_wish'))) {
                message('请填写家长意愿!', 'student/profile/pwish');
            }
            $this->session->set_userdata('complete', 1);
        }
        $grades = C('grades');
        // 使用Yaf样式RegionModel代替
        //$this->load->model('admin/region_model');
        //$this->load->model('admin/school_model');
        $student['birthday'] = date('Y-m-d', $student['birthday']);
        //$student['region_text'] = $this->region_model->get_region_text(array($student['province'],$student['city'],$student['area']));
        $row1 = SchoolModel::schoolInfo($student['school_id'], 'school_name');
        $student['school_name'] = $row1['school_name'];
        $student['grade_name'] = isset($grades[$student['grade_id']]) ? $grades[$student['grade_id']] : '';
        $data['uid'] = $uid;
        $data['grades'] = $grades;
        $specs = array('0' => '哲学', '1' => '经济学', '2' => '法学', '3' => '教育学', '4' => '文学', '5' => '历史学', '6' => '理学', '7' => '工学', '8' => '农学', '9' => '医学', '10' => '军事学', '11' => '管理学', '12' => '艺术类', '13' => '不清楚');
        $data['subjects'] = C('subject');
        $data['specs'] = $specs;
        $data['xuekao_xuankao'] = $xuekao_xuankao;
        $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['ranks'] = array('1' => 'A', '2' => 'B', '3' => 'C', '4' => 'E');
        $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('profile/preview', $data);
    }