ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 同步课程 # ![](./img/2019-01-22_135423.png) ## 用户同步课程教材列表 http://t.wmxuetang.com/index.php?r=teachCourse/default/bookshelf ### 表 wkwke.tbTeachCourse 同步课程教材列表 ``` CREATE TABLE `tbTeachCourse` ( `id` int(11) NOT NULL AUTO_INCREMENT, `fdUserID` int(11) NOT NULL COMMENT '用户ID', `fdTagID` int(11) NOT NULL COMMENT '教材ID', `fdSubjectID` int(11) NOT NULL COMMENT '科目ID', `fdSchoolTypeID` int(11) NOT NULL COMMENT '学段ID', `fdStatus` tinyint(4) DEFAULT NULL, `fdExpire` datetime DEFAULT NULL COMMENT '过期时间', `fdCreate` datetime NOT NULL, PRIMARY KEY (`id`), KEY `fdUserID` (`fdUserID`,`fdTagID`,`fdSubjectID`) ) ENGINE=MyISAM AUTO_INCREMENT=3869 DEFAULT CHARSET=utf8 COMMENT='同步课程'; ``` ### 表 wkwke.tbTeachCourseSche 章节、知识点进度表 ``` CREATE TABLE `tbTeachCourseSche` ( `id` int(11) NOT NULL AUTO_INCREMENT, `fdTeachCourseID` int(11) NOT NULL COMMENT '课程ID', `fdTagID` int(11) DEFAULT '0' COMMENT '教材章节ID', `fdPointID` int(11) DEFAULT '0' COMMENT '知识点ID', `fdStarNum` int(11) DEFAULT '0' COMMENT '获得星星数', `fdCoinNum` int(11) DEFAULT '0' COMMENT '获得学币数', `fdCurrent` int(11) DEFAULT '0' COMMENT '最后更新时间戳', `fdType` tinyint(4) DEFAULT '0' COMMENT '类型 1:教材章节 2:知识点 3:单元测试', `fdParentID` int(11) DEFAULT '0', `fdFinish` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0未完成,1已完成', PRIMARY KEY (`id`), KEY `fdTeachCourseID` (`fdTeachCourseID`,`fdTagID`) ) ENGINE=MyISAM AUTO_INCREMENT=18754 DEFAULT CHARSET=utf8 COMMENT='同步课程学习进度'; ``` ### 表 wkwke.tbTeachCourseRecord 同步课程学习记录 ``` CREATE TABLE `tbTeachCourseRecord` ( `id` int(11) NOT NULL AUTO_INCREMENT, `fdTeachCourseID` int(11) NOT NULL COMMENT '课程ID', `fdTagID` int(11) NOT NULL DEFAULT '0' COMMENT '章节ID', `fdPointID` int(11) NOT NULL DEFAULT '0' COMMENT '知识点ID', `fdAeid` int(11) DEFAULT '0' COMMENT '答卷ID', `fdScore` float NOT NULL DEFAULT '0' COMMENT '试卷得分', `fdScoreRate` float NOT NULL DEFAULT '0', `fdUsed` int(11) NOT NULL DEFAULT '0', `fdDifficulty` tinyint(4) DEFAULT '0' COMMENT '答题难度', `fdStatus` tinyint(4) DEFAULT '0' COMMENT '是否交卷', `fdPass` tinyint(4) DEFAULT '0' COMMENT '是否通关', `fdType` tinyint(4) DEFAULT '0' COMMENT '答题类型 2:知识点 3:单元测', `fdTeachCourseScheID` int(11) NOT NULL COMMENT '学习进度ID', PRIMARY KEY (`id`), KEY `fdTeachCourseID` (`fdTeachCourseID`,`fdTagID`,`fdPointID`) ) ENGINE=MyISAM AUTO_INCREMENT=63615 DEFAULT CHARSET=utf8 COMMENT='同步课程学习记录'; ``` ## 获取教材列表 http://t.wmxuetang.com/index.php?r=teachCourse/default/getTeachCourse ![](./img/2019-01-22_154013.png) ### code ``` /** * 获取同步课程 * @author: pengjch 18-7-9 下午2:26 */ public function actionGetTeachCourse(){ $args['userID'] = Yii::app()->user->id; $args['status'] = WK::CNT_ENABLE; $args['order'] = 't.id ASC'; $args['with'] = array('tag','tag.version'); $teachCourses = TeachCourseService::factory()->getTeachCourses($args); $datas = TeachCourseService::factory()->countUserStarAndCoin(Yii::app()->user->id); $datas['list'] = array(); if($teachCourses){ foreach ($teachCourses as $teachCourse){ $cover = RelevanceService::factory()->getTextbookCover($teachCourse->fdTagID); $versionObject = wkeVersion::model()->findByPk($teachCourse->tag->version->fdValue); $item = array(); $item['id'] = $teachCourse->id; $item['version'] = $versionObject->fdName; $item['subjectID'] = (int)$teachCourse->fdSubjectID; $item['subjectName'] = Yii::app()->params['SUBJECT_ARR'][$teachCourse->fdSubjectID]; $item['textBookID'] = (int)$teachCourse->fdTagID; $item['textBookName'] = $teachCourse->tag->fdName; $item['expire'] = strtotime($teachCourse->fdExpire)*1000; $item['expireStatus'] = $teachCourse->fdExpire ? (time() > strtotime($teachCourse->fdExpire) ? 1 : 0) : 2; //0未到期 1已到期 2未购买 $item['cover'] = $cover; $datas['list'][] = $item; } } ResponseUtils::json(array('data'=>$datas),0,"success"); } ``` *****