# 同步课程统计功能 #
## 1. 学习统计:获取学生的同步课程 ##
http://t.wmxuetang.com/index.php?r=croom/manage/getTeachCourse&userID=474598
返回格式JSON:
```
{
"data": [
{
"id": "20",
"version": "人教版",
"subjectID": 2,
"subjectName": "数学",
"textBookID": 42038,
"textBookName": "八年级上册",
"expire": 1556586494000,
"expireStatus": 0,
"cover": "http://file.cnweike.cn/content/tmp/0/0/226/57954/53518.jpg"
},
{
"id": "21",
"version": "人教版",
"subjectID": 2,
"subjectName": "数学",
"textBookID": 53743,
"textBookName": "八年级下册",
"expire": 1536225016000,
"expireStatus": 1,
"cover": "http://file.cnweike.cn/content/tmp/0/0/1/260/83582.jpg"
},
{
"id": "412",
"version": "人教版",
"subjectID": 2,
"subjectName": "数学",
"textBookID": 54534,
"textBookName": "九年级上册",
"expire": 1537862783000,
"expireStatus": 1,
"cover": "http://file.cnweike.cn/content/tmp/0/0/1/260/83583.jpg"
},
{
"id": "943",
"version": "新课标人教A版",
"subjectID": 2,
"subjectName": "数学",
"textBookID": 4839,
"textBookName": "必修三",
"expire": 0,
"expireStatus": 2,
"cover": "http://file.cnweike.cn/content/tmp/0/0/226/57877/53441.jpg"
},
{
"id": "3633",
"version": "新课标人教A版",
"subjectID": 2,
"subjectName": "数学",
"textBookID": 4677,
"textBookName": "必修一",
"expire": 0,
"expireStatus": 2,
"cover": "http://file.cnweike.cn/content/tmp/0/0/226/57875/53439.jpg"
}
],
"status": 0,
"msg": "success",
"ssk": null
}
```
*D:\wamp\www\xue.test\xuetang\protected\modules\croom\controllers\ManageController.php*
```
/**
* 学习统计:获取学生的同步课程
* @example http://t.wmxuetang.com/index.php?r=croom/manage/getTeachCourse&userID=474598
* @url croom/manage/getTeachCourse
* @param
* userID
*/
public function actionGetTeachCourse(){
$args['userID'] = RequestUtils::getNormalRequest('userID');;
$args['status'] = WK::CNT_ENABLE;
$args['order'] = 't.id ASC';
$args['with'] = array('tag','tag.version');
$teachCourses = TeachCourseService::factory()->getTeachCourses($args);
$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;
$list[] = $item;
}
}
ResponseUtils::json(array('data'=>$list),0,"success");
}
```
## 2. 同步课程练习数据统计
```
/**
* 学习统计:同步课程练习数据统计
* @author wangbo 2019-1-23
* @url croom/manage/myTeachCourseRecordStatistics
* @example http://t.wmxuetang.com/index.php?r=croom/manage/myTeachCourseRecordStatistics&userID=474598&textBookID=42038&begin=1547596800000
* @param
* userID
* textBookID
* begin
* end
*/
public function actionMyTeachCourseRecordStatistics()
{
$userID = RequestUtils::getNormalRequest('userID', 0);
$textbookID = RequestUtils::getNormalRequest('textBookID', 0);
$end = RequestUtils::getNormalRequest('end', (time() + 3600 * 24) * 1000);
$begin = RequestUtils::getNormalRequest('begin', (time() - 3600 * 24 * 30) * 1000); //默认是30天
// todo:校验数据
if (!$textbookID) {
ResponseUtils::json(null, 1, '缺少必填参数textBookID');
}
$data = TeachCourseService::factory()->getTeachCourseByUserID($textbookID, $userID, $begin, $end);
if ($data) {
ResponseUtils::json(['data' => array_values($data)]);
}
ResponseUtils::json(['data' => []]);
}
```
*D:\wamp\www\xue.test\xuetang\protected\service\TeachCourseService.php*
```
/**
* 同步课程,学生学习统计查询
* @param $textbookID
* @param int $userID
* @return array
* @author wangbo 2019-1-23
*/
public function getTeachCourseByUserID($textbookID, $userID, $begin, $end)
{
if(!$textbookID)
return array();
$knowLedges = $this->getBookTree($textbookID);
$teachCourse = TeachCourse::model()->findByAttributes(['fdUserID' => $userID, 'fdTagID' => $textbookID]);
if (!$teachCourse) {
return array();
}
$teachCourseID = $teachCourse->id;
// 获取章、节、知识点目录结构
$courseChapter = array();
if($knowLedges){
foreach ($knowLedges as $knowledge){
//章
$knowFirst['id'] = $knowledge['id'];
$knowFirst['name'] = $knowledge['name'];
$knowFirst['level'] = $knowledge['level'];
$book = Tag::model()->findByPk($knowledge['id']);
$tags = CategoryService::factory()->getChildren('Tag', $knowledge['id'], null, $book->fdLeft, $book->fdRight, true, 0);
$temp = array();
foreach ($tags as $tag) {
//节
$child = array();
$child['id'] = $tag->id;
$child['name'] = $tag->fdName;
$child['level'] = $tag->fdLevel;
if ($knowledge['id'] == $tag->fdParentID) {
$temp[$tag->id] = $child;
} else {
$temp[$tag->fdParentID] ? $temp[$tag->fdParentID]['childNode'][$tag->id] = $child : null; //过滤已屏蔽章的小节
}
// 知识点
if($tag->fdLevel == 3){
$point = V2RelevanceService::factory()->getTagRelevancy($tag->id,null,null,array('tag'),'t.fdOrder ASC,t.id ASC');
if($point){
foreach ($point as $v){
$know = [];
$know['id'] = $v->fdTagID;
$know['name'] = $v->tag->fdName;
$know['level'] = $v->tag->fdLevel;
// 练习次数
$total = $this->getUserTeachCourseRecordTotal($teachCourseID, $v->fdTagID, $begin, $end);
if ($total['count']) {
$know['totalExamCount'] = $total['count'];
$know['scoreRates'] = round($total['scoreRates']);
$temp[$tag->id]['childNode'][$v->fdTagID] = $know;
}
}
}
}
}
$temp = $this->_arrConvert($temp);
if ($temp) {
$knowFirst['childNode'] = array_values($temp);
$courseChapter[$knowledge['id']] = $knowFirst;
}
}
}
$courseChapter = $this->_arrConvert($courseChapter);
foreach ($courseChapter as $k => $v) {
if ($v['childNode']) {
foreach ($v['childNode'] as $i => $j) {
if ($v['childNode'][$i]['childNode']) {
$courseChapter[$k]['childNode'][$i]['childNode'] = array_values($v['childNode'][$i]['childNode']);
}
}
}
}
return $courseChapter;
}
```
- 说明
- 开发任务
- 星课-真光
- 课表
- Excel Down
- 调课
- 课表修改
- 课表代码分析
- 课堂
- 课堂:应用商店通信管理协议
- 教师账号强制绑定手机或邮箱
- 强制绑定手机和修改密码的规则
- 学堂
- 课程学习:讨论功能
- 后台:课程讨论管理
- 课程直播接口
- 学习统计功能(旧版)
- 学习统计功能(新版)
- 同步课程统计功能
- 同步课程编辑-新增视频
- 第三方接口
- 学科网
- 安徽第三方
- 大赛
- 管控系统
- 日志管理
- 设备日志
- 平板接口
- 渝教
- 教学总结
- 空白目录
- Yii 1.1
- 学堂架构
- Yii 1.1一些方法的解读
- MVCS结构
- 基础使用语法
- 创建1个新模块
- 关联模型
- CDbCriteria
- 学生-课堂记录
- 学生端页面展示
- 教师端页面展示
- 编辑课程文档
- SQL
- 课堂项目运行入口
- 上传资源示意图
- 行为
- PHPStorm
- 源码阅读
- 会诊答卷页面
- 考点练习
- 资源首页
- 同步课程
- 同步课程:章节信息
- 升学复习
- 统计图-范例
- 模块
- 非法词
- 服务层
- MongoDB类
- 学堂作答记录从Mongo新集合获取数据
- MongoYii
- 错题集
- 小技巧
- 完善资料
- 邮件发送
- K12
- JSpang视频课程
- MongoDB
- 创业
- 项目
- 包包