/** * 课程学习人数++ */ function incrCourseViewNum() { $controllers = array("Section" => array("info" => 1, "answer" => 1)); if (isset($controllers[$this->controllerName][$this->actionName])) { //课程学习人数 $courseModel = new CourseModel(); $courseModel->incrViewNum($this->course['id']); } }
function CreateCourse($year, $semester, $department, $courseName, $professor, $minrating, $maxrating) { $courseModel = new CourseModel(); $courseArray = $courseModel->getCourse($year, $semester, $department, $courseName, $professor, $minrating, $maxrating); $result = "<table class = 'courseTable table'><tr>\r\n <th width = '75px' >Year: </th>\r\n <th>Semester: </th>\r\n <th>Department: </th>\r\n <th>Course Name: </th>\r\n <th>Professor: </th>\r\n <th>Rating: </th>\r\n </tr>"; foreach ($courseArray as $key => $course) { $result = $result . "\r\n \r\n <tr>\r\n <td>{$course->year}</td>\r\n <td>{$course->semester}</td>\r\n <td>{$course->department}</td>\r\n <td>{$course->courseName}</td>\r\n <td>{$course->professor}</td>\r\n <td>{$course->rating}</td>\r\n </tr>\r\n\t\t\t\t\t\t<tr><td></td>\r\n\t\t\t\t\t\t\t<th>Summary: </th>\r\n <td colspan='3'>{$course->summary}</td>\r\n\t\t\t\t\t\t</tr>"; } $result .= "</table>"; return $result; }
function playAction() { //视频观看次数++ $videoId = (int) $this->get("video_id", 0); $videoModel = new VideoModel(); $videoModel->incrViewNum($videoId); $videoModel->insert($this->uid, $videoId); //用户人数 $section = $videoModel->getVideoBelongSection($videoId); if ($section) { $courseModel = new CourseModel(); $courseModel->incrViewNum($section['course_id']); } $this->displayJson(Common_Error::ERROR_SUCCESS); }
public function User() { $course_id = $_GET['id']; $username = Cookie::get('username'); $usertype = Cookie::get('usertype'); $userid = Cookie::get('userid'); $course = new CourseModel(); $courselist = $course->where("course_id='{$course_id}'")->find(); $homework = new HomeworkModel(); $homeworklist = $homework->where("course_id='{$course_id}'")->select(); $this->assign('username', $username); $this->assign('usertype', $usertype); $this->assign('userid', $userid); $this->assign('course', $courselist); $this->assign('homeworklist', $homeworklist); $this->display(); }
public function add() { $course = new CourseModel(); $course_id = $_POST['course_id']; $message = D('message'); if ($course->where("course_id='{$course_id}'")->find()) { $message->create(); $result = $message->add(); if ($result) { $this->assign("jumpUrl", "__APP__/Teacher/courseindex/id/{$course_id}"); $this->success("add success!"); } else { $this->assign("jumpUrl", "__APP__/Message/index"); $this->error("failed"); } } }
public function User() { $course_id = $_GET['id']; $course = new CourseModel(); $zhang = new ZhangModel(); $zhanglist = $zhang->where("course_id='{$course_id}'")->select(); $result = $course->where("course_id='{$course_id}'")->find(); $username = Cookie::get('username'); $userid = Cookie::get('userid'); $usertype = Cookie::get('usertype'); $this->assign('course', $result); $this->assign('zhanglist', $zhanglist); $this->assign('username', $username); $this->assign('userid', $userid); $this->assign('usertype', $usertype); $this->display(); }
/** * 发表评论 * curl -d "course_id=1&comment_id=1&video_id=0&content=helloaaaaaaaaaa" http://182.92.110.119/comment/publish */ function publishAction() { $courseId = (int) $this->post("course_id", 0); $commentId = (int) $this->post("comment_id", 0); $videoId = (int) $this->post("video_id", 0); $content = $this->post("content", ""); $time = time(); $comment = array("uid" => $this->uid, "comment_id" => $commentId, "course_id" => $courseId, "video_id" => $videoId, "content" => $content, "create_time" => $time); $commentModel = new CommentModel(); $id = $commentModel->insertComment($comment); if ($id) { $userModel = new UserModel(); $videoModel = new VideoModel(); $courseModel = new CourseModel(); $author = $userModel->getUser($comment['uid']); $comment['create_time_fmt'] = Common_Time::flow($comment['create_time']); $comment['author_uid'] = $author['stuff_id']; $comment['author_name'] = $author['stuff_name']; $comment['author_avator'] = $author['avator']; if ($comment['comment_id']) { $parentComment = $commentModel->getComment($comment['comment_id']); $beReplyAuthor = $userModel->getUser($parentComment['uid']); $parentComment['author_uid'] = $beReplyAuthor['stuff_id']; $parentComment['author_name'] = $beReplyAuthor['stuff_name']; $parentComment['author_avator'] = $beReplyAuthor['avator']; $parentComment['create_time_fmt'] = Common_Time::flow($parentComment['create_time']); $comment['parent_comment'] = $parentComment; } if ($comment['video_id']) { $section = $videoModel->getVideoBelongSection($comment['video_id']); if (!$section) { $practiseModel = new PractiseModel(); $practise = $practiseModel->getVideoBelongPractise($comment['video_id'], $courseId); $comment['practise_seq'] = $practise['seq']; $section = $courseModel->getSection($practise['section_id']); } $chapter = $courseModel->getSection($section["parent_id"]); $comment["chapter_id"] = $chapter["id"]; $comment["chapter_name"] = $chapter["name"]; $comment["chapter_seq"] = $chapter["seq"]; $comment["section_id"] = $section["id"]; $comment["section_name"] = $section["name"]; $comment["section_seq"] = $section["seq"]; $userVideo = $videoModel->getUserVideoVote($comment['uid'], $comment['video_id']); $comment["video_like"] = isset($userVideo['like_type']) ? $userVideo['like_type'] : 0; } $this->displayJson(Common_Error::ERROR_SUCCESS, array($comment)); } $this->displayJson(Common_Error::ERROR_MYSQL_EXECUTE); }
public function index() { $course_id = $_GET['id']; $course = new CourseModel(); $zhang = new ZhangModel(); $vedio = new VedioModel(); $zhanglist = $zhang->where("course_id ='{$course_id}'")->select(); $result = $course->where("course_id='{$course_id}'")->find(); $username = Cookie::get('username'); $userid = Cookie::get('userid'); $usertype = Cookie::get('usertype'); $this->assign('course', $result); $this->assign('zhanglist', $zhanglist); $this->assign('username', $username); $this->assign('userid', $userid); $this->assign('usertype', $usertype); if ($usertype === 'Teacher') { $urlturn = 'teacherindex'; } else { $urlturn = 'studentindex'; } $this->assign('urlturn', $urlturn); $this->display(); }
/** * 试卷列表 */ 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); }
/** * 用户对视频的评价(顶,踩) */ public function like($uid, $videoId, $like = 1, $courseId = 0) { $flag = false; $courseModel = new CourseModel(); $tbl = new DB_Haodu_UserVideo(); $record = $tbl->scalar("*", "where uid={$uid} and video_id={$videoId}"); //只一次 if ($record) { return true; } $time = time(); $data = array("uid" => $uid, "video_id" => $videoId, "like_type" => $like, "create_time" => $time); $flag = $tbl->insert($data); if ($flag) { if ($like == 1) { $this->incrLikeNum($videoId, array('like_num' => 1)); $courseModel->incrLikeNum($courseId, array('like_num' => 1)); } else { $this->incrDislikeNum($videoId, array('dislike_num' => 1)); $courseModel->incrDislikeNum($courseId, array('dislike_num' => 1)); } } }
/** * Handle store course command. * * @param $courseInfo * @return int course id */ public function storeCourse($courseInfo) { $courseModel = new CourseModel(); return json_encode($courseModel->storeCourse($courseInfo['name'])); }
public function courseindex() { $course_id = $_GET['id']; $course = new CourseModel(); $message = new MessageModel(); $usertype = Cookie::get('usertype'); $username = Cookie::get('username'); $userid = Cookie::get('userid'); $courselist = $course->where("course_id='{$course_id}'")->find(); $messagelist = $message->where("course_id='{$course_id}'")->select(); $this->assign('course', $courselist); $this->assign('messagelist', $messagelist); $this->assign('usertype', $usertype); $this->assign('username', $username); $this->assign('userid', $userid); $this->display(); }
public function studentresult() { $zhang_id = $_GET['id']; $username = Cookie::get('username'); $userid = Cookie::get('userid'); $usertype = Cookie::get('usertype'); $test = new TestModel(); $testlist = $test->where("zhang_id='{$zhang_id}'")->select(); $student_test = new Student_testModel(); $student_testlist = $student_test->where("user_id='{$userid}'")->find(); $zhang = new ZhangModel(); $zhanglist = $zhang->where("zhang_id='{$zhang_id}'")->find(); $course_id = $zhanglist['course_id']; $course = new CourseModel(); $courselist = $course->where("course_id='{$course_id}'")->find(); $this->assign('username', $username); $this->assign('userid', $userid); $this->assign('usertype', $usertype); $this->assign('zhang', $zhanglist); $this->assign('student_test', $student_testlist); $this->assign('testlist', $testlist); $this->assign('course', $courselist); $this->display(); }
/** * 完善课程推送数据 * @param array $data */ private function perfect_data(&$data) { if (!$data) { return $data; } $cors_ids = array(); $cc_ids = array(); foreach ($data['courses'] as $item) { if ($item['cors_cmid'] == 1) { $cors_ids[] = $item['cors_id']; $cc_ids[] = $item['cc_id']; } } $cors_ids = array_unique($cors_ids); //获取一对一课程授课范围(年纪、学科) if ($cors_ids) { $data['course_range'] = CoursePushModel::courseRange($cors_ids); } //获取一对一课程授课老师 if ($cc_ids) { $data['course_teacher'] = CoursePushModel::courseTeacher($cc_ids); } //获取授课模式 $data['cors_stunumtype'] = CourseModel::courseStuNumTypePairs(); }
/** * @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); }
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(); }
/** * 导入课程记录(从excel文件中), * 注意: 目前$cors_id参数未启用 * * @param int $cors_id = NULL 默认将课程全导入到该课程ID下 */ public function import_cors_excel($cors_id = NULL) { if ($_GET['dl'] == '1') { Func::dumpFile('application/vnd.ms-excel', 'file/import_course_template.xls', '培训课程导入模板.xls'); exit; } $data = array(); while (isset($_FILES['file'])) { $param = $_POST; $err_map = array(UPLOAD_ERR_OK => '没有错误发生,文件上传成功', UPLOAD_ERR_INI_SIZE => '上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值', UPLOAD_ERR_FORM_SIZE => '上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值', UPLOAD_ERR_PARTIAL => '文件只有部分被上传', UPLOAD_ERR_NO_FILE => '没有文件被上传', UPLOAD_ERR_NO_TMP_DIR => '找不到临时文件夹', UPLOAD_ERR_CANT_WRITE => '文件写入失败'); if ($_FILES['file']['error'] !== 0) { $data['error'] = $err_map[$_FILES['file']['error']]; break; } if (strpos($_FILES['file']['type'], 'excel') === false) { $mime = mime_content_type($_FILES['file']['tmp_name']); if (!in_array($mime, array('application/vnd.ms-excel', 'application/vnd.ms-office', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'))) { $data['error'] = "您上传的不是Excel文件({$mime})"; break; } } // 开始处理excel $excel = PHPExcel_IOFactory::load($_FILES['file']['tmp_name']); $sheet = $excel->getSheet(0); $row_num = $sheet->getHighestRow(); $col_num = $sheet->getHighestColumn(); $title = array('课程名称', '来源机构', '授课模式', '年级', '学科', '类型', '授课教师', '教师来源', '课程时间', '课程周期', '上课校区', '上课省份', '上课城市', '上课区县', '上课地址', '收费', '上课课时', '联系人', '联系电话', '课程简介', '网址'); $col_num = base_convert($col_num, 36, 10); if ($col_num < count($title)) { $data['error'] = 'Excel列数验证未通过'; break; } $col_num = count($title); $col_char = array(); for ($j = 0; $j < $col_num; $j++) { $col_char[$j] = strtoupper(base_convert(10 + $j, 10, 36)); if ($title[$j] !== trim($sheet->getCell($col_char[$j] . '1')->getValue())) { $data['error'] = $col_char[$j] . '列标题不符'; break; } } if (isset($data['error'])) { break; } $rows = array(); for ($i = 2; $i <= $row_num; $i++) { $rows[$i - 2] = array(); for ($j = 0; $j < $col_num; $j++) { $rows[$i - 2][$j] = trim($sheet->getCell($col_char[$j] . $i)->getValue()); } if ($rows[$i - 2][0] == '') { unset($rows[$i - 2]); break; } } unset($sheet); unset($excel); if (empty($rows)) { $data['error'] = 'Excel文件工作表中没有任何要导入的记录'; break; } $cm_map = array_flip(array_map("trim", CourseModel::courseModePairs())); $grade_map = array_flip(C('grades')); $subject_map = array_flip(C('subject')); $ctf_map = array_flip(array_map("trim", CourseModel::courseTeachfromPairs())); $sql = <<<EOT SELECT class_id, class_name FROM rd_question_class EOT; $class_map = Fn::db()->fetchPairs($sql); if (!is_array($class_map)) { $class_map = array(); } else { $class_map = array_flip(array_map("trim", $class_map)); } $sql = <<<EOT SELECT * FROM rd_region WHERE region_id > 1 ORDER BY region_type EOT; $region_list = Fn::db()->fetchAll($sql); // 以region_id为键以行记录为值,同时加个children,以保存直接子项 $region_map = array(); // 以名字加'_'连接起来为键,以region_id为值 $regionname_map = array(); foreach ($region_list as $v) { $region_map[$v['region_id']] = $v; $region_map[$v['region_id']]['children'] = array(); if ($v['region_type'] == 1) { $regionname_map[trim($v['region_name'])] = $v['region_id']; } else { if ($v['region_type'] == 2) { $region_map[$v['parent_id']]['children'][] = $v['region_id']; $regionname_map[trim($region_map[$v['parent_id']]['region_name']) . '_' . trim($v['region_name'])] = $v['region_id']; } else { if ($v['region_type'] == 3) { $region_map[$v['parent_id']]['children'][] = $v['region_id']; $regionname_map[trim($region_map[$region_map[$v['parent_id']]['parent_id']]['region_name']) . '_' . trim($region_map[$v['parent_id']]['region_name']) . '_' . trim($v['region_name'])] = $v['region_id']; } } } } unset($region_list); $row_num = count($rows); $cors_arr = array(); //cors_arr[cors_name] => cors_list[i] $cc_arr = array(); //cc_arr[ti_name][tc_name] => cc_list[i] $cors_list = array(); $cc_list = array(); foreach ($rows as $k => $row) { // 课程名称 if ($row[0] == '') { $data['error'] == $col_char[0] . ($k + 2) . ' - "课程名称"不可为空'; break; } if (mb_strlen($row[0], 'UTF-8') > 100) { $data['error'] = $col_char[0] . ($k + 2) . ' - "课程名称"内容太长了,不可超过100个字符'; break; } // 来源机构 if ($row[1] == '') { $data['error'] = $col_char[1] . ($k + 2) . ' - "来源机构"不可为空'; break; } if (mb_strlen($row[1], 'UTF-8') > 60) { $data['error'] = $col_char[1] . ($k + 2) . ' - "来源机构"内容太长了,不可超过60个字符'; break; } // 授课模式 if ($row[2] == '') { $data['error'] = $col_char[2] . ($k + 2) . ' - "授课模式"不能为空'; break; } if (!isset($cm_map[$row[2]])) { $data['error'] = $col_char[2] . ($k + 2) . ' - "授课模式"不正确'; break; } $row['cors_cmid'] = $cm_map[$row[2]]; //////////// // 年级3 学科4 类型5 授课教师6 教师来源7 课程时间8 // 课程周期9 上课校区10 ////////////////// // 年级 if ($row[3] == '') { $data['error'] = $col_char[3] . ($k + 2) . ' - "年级"不能为空'; break; } $row['cors_gradeid'] = array(); $arr = explode(',', $row[3]); foreach ($arr as $v) { $v = trim($v); if (isset($grade_map[$v])) { $row['cors_gradeid'][] = $grade_map[$v]; } } if (count($arr) != count($row['cors_gradeid'])) { $data['error'] = $col_char[3] . ($k + 2) . ' - "年级"里有不正确的选项'; break; } if (empty($row['cors_gradeid'])) { $data['error'] = $col_char[3] . ($k + 2) . ' - "年级"不能为空'; break; } $row['cors_gradeid'] = array_unique($row['cors_gradeid']); if ($row['cors_cmid'] != 1 && count($row['cors_gradeid']) > 1) { $data['error'] = $col_char[3] . ($k + 2) . ' - 一对一课程"年级"只能有一个'; break; } // 学科 if ($row[4] == '') { $data['error'] = $col_char[4] . ($k + 2) . ' - "学科"不能为空'; break; } $row['cors_subjectid'] = array(); $arr = explode(',', $row[4]); foreach ($arr as $v) { $v = trim($v); if (isset($subject_map[$v])) { $row['cors_subjectid'][] = $subject_map[$v]; } } if (count($arr) != count($row['cors_subjectid'])) { $data['error'] = $col_char[4] . ($k + 2) . ' - "学科"里有不正确的选项空'; break; } if (empty($row['cors_subjectid'])) { $data['error'] = $col_char[4] . ($k + 2) . ' - "学科"不能为空'; break; } $row['cors_subjectid'] = array_unique($row['cors_subjectid']); if ($row['cors_cmid'] != 1 && count($row['cors_subjectid']) > 1) { $data['error'] = $col_char[3] . ($k + 2) . ' - 一对一课程"学科"只能有一个'; break; } // 类型 if ($row[5] == '') { if ($param['cors_classid_required']) { $data['error'] = $col_char[5] . ($k + 2) . ' - "类型"不能为空'; break; } $row['cors_classid'] = array(); } else { $row['cors_classid'] = array(); $arr = explode(',', $row[5]); foreach ($arr as $v) { $v = trim($v); if (isset($class_map[$v])) { $row['cors_classid'][] = $class_map[$v]; } } if (count($arr) != count($row['cors_classid'])) { $data['error'] = $col_char[5] . ($k + 2) . ' - "类型"里有不正确的选项空'; break; } if (empty($row['cors_classid'])) { if ($param['cors_classid_required']) { $data['error'] = $col_char[5] . ($k + 2) . ' - "类型"不能为空'; break; } } $row['cors_classid'] = array_unique($row['cors_classid']); } // TODO 需要验证 $row['cc_teachers'] = $row[6]; // 教师来源 if ($row[7] == '') { $data['error'] = $col_char[7] . ($k + 2) . ' - "教师来源"不能为空'; break; } if (!isset($ctf_map[$row[7]])) { $data['error'] = $col_char[7] . ($k + 2) . ' - "教师来源"不正确'; break; } $row['cc_ctfid'] = $ctf_map[$row[7]]; // 课程时间 if ($row[8] == '') { if ($param['cc_classtime_required']) { $data['error'] = $col_char[8] . ($k + 2) . ' - "课程时间"不能为空'; break; } } if (mb_strlen($row[8], 'UTF-8') > 255) { $data['error'] = $col_char[8] . ($k + 2) . ' - "课程时间"内容太长了,不可超过255个字符'; break; } // 课程周期 if ($row[9] == '') { // 任意时间开课 $row['cc_startanytime'] = 1; $row['cc_begindate'] = NULL; $row['cc_enddate'] = NULL; } else { $row['cc_startanytime'] = 0; if (strlen($row[9]) < 21) { $data['error'] = $col_char[9] . ($k + 2) . ' - "课程周期"格式不正确,应为"2015-02-04x2015-08-01",其中x可为一个或多个字符串'; break; } $d1 = substr($row[9], 0, 10); $d2 = substr($row[9], -10, 10); if (!Validate::isDate($d1) || !Validate::isDate($d2)) { $data['error'] = $col_char[9] . ($k + 2) . ' - "课程周期"格式不正确,应为"2015-02-04x2015-08-01",其中x可为一个或多个字符串'; break; } if ($d1 > $d2) { $data['error'] = $col_char[9] . ($k + 2) . ' - "课程周期"开始日期不能大于结束日期'; break; } $row['cc_begindate'] = $d1; $row['cc_enddate'] = $d2; } // 上课校区 if ($row['cors_cmid'] == 1) { // 一对一 // 上课校区 if ($row[10] == '') { $row['tc_name'] = NULL; } else { if (mb_strlen($row[10], 'UTF-8') > 60) { $data['error'] = $col_char[10] . ($k + 2) . ' - "上课校区"太长了'; break; } $row['tc_name'] = $row[10]; } } else { // 上课校区 if ($row[10] == '') { $data['error'] = $col_char[10] . ($k + 2) . ' - "上课校区"不可为空'; break; } if (mb_strlen($row[10], 'UTF-8') > 60) { $data['error'] = $col_char[10] . ($k + 2) . ' - "上课校区"太长了'; break; } $row['tc_name'] = $row[10]; } // 上课省份 if ($row[11] == '') { if ($param['cc_provid_required']) { $data['error'] = $col_char[11] . ($k + 2) . ' - "上课省份"不可为空'; break; } else { $row['cc_provid'] = 0; } } else { if (!isset($regionname_map[$row[11]])) { $data['error'] = $col_char[11] . ($k + 2) . ' - "上课省份"不存在'; break; } $row['cc_provid'] = $regionname_map[$row[11]]; } $row['cc_cityid'] = 0; $row['cc_areaid'] = 0; if (!empty($region_map[$regionname_map[$row[11]]]['children'])) { // 验证市 if ($row[12] == '') { if ($param['cc_cityid_required']) { $data['error'] = $col_char[12] . ($k + 2) . ' - "上课城市"不可为空'; break; } else { $row['cc_cityid'] = 0; } } else { if (!isset($regionname_map[$row[11] . '_' . $row[12]])) { $data['error'] = $col_char[12] . ($k + 2) . ' - "上课城市"不存在'; break; } $row['cc_cityid'] = $regionname_map[$row[11] . '_' . $row[12]]; } // 验证区县 if ($row[13] == '') { if ($param['cc_areaid_required']) { $data['error'] = $col_char[13] . ($k + 2) . ' - "上课区县"不可为空'; break; } else { $row['cc_areaid'] = 0; } } else { if (!isset($regionname_map[$row[11] . '_' . $row[12] . '_' . $row[13]])) { $data['error'] = $col_char[13] . ($k + 2) . ' - "上课区县"不存在'; break; } $row['cc_areaid'] = $regionname_map[$row[11] . '_' . $row[12] . '_' . $row[13]]; } } // 上课地址 if ($row[14] == '') { if ($param['cc_addr_required']) { $data['error'] = $col_char[14] . ($k + 2) . ' - "上课地址"不可为空'; break; } } if (mb_strlen($row[14], 'UTF-8') > 255) { $data['error'] = $col_char[14] . ($k + 2) . ' - "上课地址"内容太长了'; break; } // 收费 if ($row[15] == '') { if ($param['cc_price_required']) { $data['error'] = $col_char[15] . ($k + 2) . ' - "收费"不能为空'; break; } else { $row[15] = '0.00'; } } if (!is_numeric($row[15]) || $row[15] < 0) { $data['error'] = $col_char[15] . ($k + 2) . ' - "收费"必须为非负数'; break; } $row[15] = bcadd($row[15], '0.00', 2); // 上课课时 if ($row[16] == '') { if ($param['cc_hours_required']) { $data['error'] = $col_char[16] . ($k + 2) . ' - "上课课时"不能为空'; break; } else { $row[16] = '0'; } } if (!Validate::isInt($row[16]) || $row[16] < 0) { $data['error'] = $col_char[16] . ($k + 2) . ' - "上课课时"必须为非负整数'; break; } // 联系人 if ($row[17] == '') { if ($param['cc_ctcperson_required']) { $data['error'] = $col_char[17] . ($k + 2) . ' - "联系人"不可为空'; break; } } if (mb_strlen($row[17], 'UTF-8') > 60) { $data['error'] = $col_char[17] . ($k + 2) . ' - "联系人"太长了'; break; } // 联系电话 if ($row['18'] == '') { if ($param['cc_ctcphone_required']) { $data['error'] = $col_char[18] . ($k + 2) . ' - "联系电话"不能为空'; break; } } if (mb_strlen($row[18], 'UTF-8') > 120) { $data['error'] = $col_char[18] . ($k + 2) . ' - "联系电话"太长了'; break; } // 课程简介 if ($row[19] == '') { if ($param['cors_memo_required']) { $data['error'] = $col_char[19] . ($k + 2) . ' - "课程简介"不能为空'; break; } } if (mb_strlen($row[19], 'UTF-8') > 65535) { $data['error'] = $col_char[19] . ($k + 2) . ' - "课程简介"太长了'; break; } // 网址 if ($row[20] == '') { if ($param['cors_url_required']) { $data['error'] = $col_char[20] . ($k + 2) . ' - "网址"不能为空'; break; } } if (mb_strlen($row[20], 'UTF-8') > 512) { $data['error'] = $col_char[20] . ($k + 2) . ' - "网址"内容太长了'; break; } $key = <<<EOT {$row[0]}/{$row[1]}/{$row[2]}/{$row[3]}/{$row[4]} EOT; if (!isset($cors_arr[$key])) { $cors_arr[$key] = count($cors_list); $cors_list[] = array('key' => $key, 'index' => $k + 2, 'cors_id' => 0, 'cors_name' => $row[0], 'ti_name' => $row[1], 'cors_cmid' => $row['cors_cmid'], 'cors_gradeid' => $row['cors_gradeid'], 'cors_subjectid' => $row['cors_subjectid'], 'cors_classid' => $row['cors_classid'], 'cors_memo' => $row[19], 'cors_url' => $row[20]); } if (!isset($cc_arr[$key])) { $cc_arr[$key] = array(); } $cc_arr[$key][] = count($cc_list); $cc_list[] = array('key' => $key, 'index' => $k + 2, 'tc_name' => $row['tc_name'], 'cc_teachers' => $row['cc_teachers'], 'cc_ctfid' => $row['cc_ctfid'], 'cc_classtime' => $row[8], 'cc_startanytime' => $row['cc_startanytime'], 'cc_begindate' => $row['cc_begindate'], 'cc_enddate' => $row['cc_enddate'], 'cc_provid' => $row['cc_provid'], 'cc_cityid' => $row['cc_cityid'], 'cc_areaid' => $row['cc_areaid'], 'cc_price' => $row[15], 'cc_hours' => $row[16], 'cc_addr' => $row[14], 'cc_ctcperson' => $row[17], 'cc_ctcphone' => $row[18]); } if (isset($data['error'])) { break; } unset($region_map); unset($regionname_map); unset($cm_map); unset($grade_map); unset($subject_map); unset($ctf_map); unset($class_map); unset($rows); // 这里开始导入 $db = Fn::db(); // 所属机构 $sql1 = <<<EOT SELECT ti_id FROM t_training_institution WHERE ti_name = ? EOT; $sql2 = <<<EOT SELECT tc_tiid, tc_id, tc_name FROM t_training_campus WHERE tc_tiid IN EOT; $sql3 = <<<EOT UPDATE t_training_institution SET ti_campusnum = ti_campusnum + 1 WHERE ti_id = EOT; $sql4 = <<<EOT SELECT ct_id FROM t_cteacher WHERE ct_name = ? AND ct_contact IS NULL EOT; $ti_id_arr = array(); foreach ($cors_list as $k => $row) { $ti_id = $db->fetchOne($sql1, array($row['ti_name'])); if ($ti_id) { $ti_id_arr[] = $ti_id; $cors_list[$k]['cors_tiid'] = $ti_id; } else { $data['error'] = $col_char[1] . $row['index'] . ' - "来源机构"不存在'; break; } } if (isset($data['error'])) { break; } $ti_id_arr = array_unique($ti_id_arr); $tclist = $db->fetchAll($sql2 . '(' . implode(',', $ti_id_arr) . ')'); $ti_tc_map = array(); foreach ($tclist as $v) { if (!isset($ti_tc_map[$v['tc_tiid']])) { $ti_tc_map[$v['tc_tiid']] = array(); } $ti_tc_map[$v['tc_tiid']][trim($v['tc_name'])] = $v['tc_id']; } unset($tclist); foreach ($cc_list as $k => $row) { $ti_id = $cors_list[$cors_arr[$row['key']]]['cors_tiid']; $cc_list[$k]['ti_id'] = $ti_id; if (is_null($row['tc_name'])) { $cc_list[$k]['cc_tcid'] = NULL; } else { if (isset($ti_tc_map[$ti_id])) { if (isset($ti_tc_map[$ti_id][$row['tc_name']])) { $cc_list[$k]['cc_tcid'] = $ti_tc_map[$ti_id][$row['tc_name']]; } else { // 不存在 if ($param['non_exist_tcname_action'] == '0') { $data['error'] = $col_char[10] . $row['index'] . ' - "上课校区"不存在'; break; } $cc_list[$k]['cc_tcid'] = 0; } } else { // 不存在 if ($param['non_exist_tcname_action'] == '0') { $data['error'] = $col_char[10] . $row['index'] . ' - "上课校区"不存在'; break; } $cc_list[$k]['cc_tcid'] = 0; } } } if (isset($data['error'])) { break; } /* 不需要验证一对一课程是否只能有一个校区了 foreach ($cors_arr as $key => $index) { if ($cors_list[$index]['cors_cmid'] == 1) { if (count($cc_arr[$key]) > 1) { $data['error'] = $col_char[10] . $cc_list[$cc_arr[$key][1]]['index'] . ' - 该行为一对一课程,只能有一条课程校区'; break; } } } if (isset($data['error'])) { break; } */ try { $time = time(); $adduid = Fn::sess()->userdata('admin_id'); if (!$db->beginTransaction()) { throw new Exception('开始导入事务处理失败'); } $cors_insert = 0; $tc_insert = 0; $cc_insert = 0; $ct_insert = 0; // 导入课程 foreach ($cors_list as $k => $row) { // insert $row2 = array(); $row2['cors_cmid'] = $row['cors_cmid']; $row2['cors_name'] = $row['cors_name']; $row2['cors_flag'] = $time; $row2['cors_tiid'] = $row['cors_tiid']; if ($row['cors_cmid'] == 1) { $row2['cors_stunumtype'] = 1; } else { $row2['cors_stunumtype'] = 2; } $row2['cors_url'] = $row['cors_url']; $row2['cors_memo'] = $row['cors_memo']; $row2['cors_addtime'] = date('Y-m-d H:i:s', $time); $row2['cors_adduid'] = $adduid; $row2['cors_lastmodify'] = date('Y-m-d H:i:s', $time); $db->insert('t_course', $row2); $cors_list[$k]['cors_id'] = $cors_id = $db->lastInsertId('t_course', 'cors_id'); if (empty($row['cors_gradeid'])) { $db->insert('t_course_gradeid', array('cg_corsid' => $cors_id, 'cg_gradeid' => 0)); } else { foreach ($row['cors_gradeid'] as $v) { $db->insert('t_course_gradeid', array('cg_corsid' => $cors_id, 'cg_gradeid' => $v)); } } if (empty($row['cors_subjectid'])) { $db->insert('t_course_subjectid', array('cs_corsid' => $cors_id, 'cs_subjectid' => 0)); } else { foreach ($row['cors_subjectid'] as $v) { $db->insert('t_course_subjectid', array('cs_corsid' => $cors_id, 'cs_subjectid' => $v)); } } if (!empty($row['cors_classid'])) { foreach ($row['cors_classid'] as $v) { $db->insert('t_course_classid', array('cci_corsid' => $cors_id, 'cci_classid' => $v)); } } if ($row['cors_cmid'] != 1) { $db->insert('t_course_knowledge', array('ck_corsid' => $cors_id, 'ck_kid' => 0, 'ck_knprocid' => 0)); } $cors_insert++; } // 导入校区 foreach ($cc_list as $k => $row) { $key = $row['key']; $row['cc_corsid'] = $cors_id = $cors_list[$cors_arr[$key]]['cors_id']; $ti_id = $row['ti_id']; if (is_null($row['cc_tcid'])) { // 不要加 } else { if ($row['cc_tcid'] == 0) { if (isset($ti_tc_map[$ti_id][$row['tc_name']])) { $row['cc_tcid'] = $ti_tc_map[$ti_id][$row['tc_name']]; } } if ($row['cc_tcid'] == 0) { // 自动增加 $row2 = array(); $row2['tc_name'] = $row['tc_name']; $row2['tc_tiid'] = $ti_id; $row2['tc_provid'] = $row['cc_provid']; $row2['tc_cityid'] = $row['cc_cityid']; $row2['tc_areaid'] = $row['cc_areaid']; $row2['tc_flag'] = $time; $row2['tc_ctcaddr'] = $row['cc_addr']; $row2['tc_ctcperson'] = $row['cc_ctcperson']; $row2['tc_ctcphone'] = $row['cc_ctcphone']; $row2['tc_environ'] = 3; $row2['tc_addtime'] = date('Y-m-d H:i:s', $time); $row2['tc_adduid'] = $adduid; $db->insert('t_training_campus', $row2); $ti_tc_map[$ti_id][$row['tc_name']] = $row['cc_tcid'] = $db->lastInsertId('t_training_campus', 'tc_id'); $tc_insert++; $db->exec($sql3 . $ti_id); } } $cc_teachers = $row['cc_teachers']; unset($row['cc_teachers']); unset($row['key']); unset($row['index']); unset($row['tc_name']); unset($row['ti_id']); $db->insert('t_course_campus', $row); $cc_id = $db->lastInsertId('t_course_campus', 'cc_id'); $cc_insert++; if ($cc_teachers == '') { continue; } $cc_teachers_arr = explode(',', $cc_teachers); $cc_teachers_arr = array_unique($cc_teachers_arr); foreach ($cc_teachers_arr as $ctname) { if ($ctname == '') { continue; } $ct_id = $db->fetchOne($sql4, array($ctname)); if (!$ct_id) { $db->insert('t_cteacher', array('ct_name' => $ctname, 'ct_flag' => $time)); $ct_id = $db->lastInsertId('t_cteacher', 'ct_id'); $ct_insert++; $row3 = $cors_list[$cors_arr[$key]]; if (empty($row3['cors_gradeid'])) { $db->insert('t_cteacher_gradeid', array('ctg_ctid' => $ct_id, 'ctg_gradeid' => 0)); } else { foreach ($row3['cors_gradeid'] as $v) { $db->insert('t_cteacher_gradeid', array('ctg_ctid' => $ct_id, 'ctg_gradeid' => $v)); } } if (empty($row3['cors_subjectid'])) { $db->insert('t_cteacher_subjectid', array('cts_ctid' => $ct_id, 'cts_subjectid' => 0)); } else { foreach ($row3['cors_subjectid'] as $v) { $db->insert('t_cteacher_subjectid', array('cts_ctid' => $ct_id, 'cts_subjectid' => $v)); } } } $db->insert('t_course_campus_teacher', array('cct_ccid' => $cc_id, 'cct_ctid' => $ct_id)); } } if ($db->commit()) { $data['success'] = <<<EOT 导入Excel文件({$_FILES['file']['name']})成功,共插入{$cors_insert}条课程记录, 插入{$tc_insert}条机构校区记录, 插入{$cc_insert}条课程校区记录, 插入{$ct_insert}条教师记录 EOT; admin_log('add', 'course', $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('cors_classid_required' => 1, 'cc_classtime_required' => 1, 'cc_provid_required' => 1, 'cc_cityid_required' => 2, 'cc_areaid_required' => 3, 'cc_addr_required' => 1, 'cc_price_required' => 1, 'cc_hours_required' => 1, 'cc_ctcperson_required' => 1, 'cc_ctcphone_required' => 1, 'cors_memo_required' => 1, 'cors_url_required' => 1, 'non_exist_tcname_action' => 0); } $data['param'] = $param; $this->load->view('course/import_cors_excel', $data); }
public function deletecourse() { $course = new CourseModel(); $id = $_GET['id']; if ($course->where("course_id='{$id}'")->delete()) { $this->assign("jumpUrl", "__APP__/Manager/index"); $this->success("delete course success"); } else { $this->assign("jumpUrl", "__APP__/Manager/index"); $this->error("delete course failed!"); } }
/** * 课程介绍(app内嵌) */ function profileAction() { $profile = array(); $courseId = $this->get('course_id', 0); $courseModel = new CourseModel(); $course = $courseModel->getCourse($courseId); if ($course) { $profile['id'] = $course['id']; $profile['name'] = $course['name']; $profile['info'] = $course['info']; $profile['teachers'] = $courseModel->getCourseTeachers($courseId); } if ($this->ajax || $this->platform == 'ios') { $this->displayJson(Common_Error::ERROR_SUCCESS, $profile); } $this->assign("profile", $profile); }
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); }