diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 369185ca2..b28d3eca0 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -287,6 +287,30 @@ module Mobile end end + desc "获取课程动态" + params do + requires :id, type: Integer + requires :token, type: String + end + post 'activities' do + authenticate! + + user = current_user + + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + activities = UserActivity.where("(container_type = 'Course' and container_id = #{params[:id]} and act_type in #{course_types})").order('updated_at desc') + + page = params[:page] ? params[:page] : 0 + all_count = activities.count + activities = activities.limit(10).offset(page * 10) + count = activities.count + present :data, activities, with: Mobile::Entities::Activity,user: user + present :all_count, all_count + present :count, count + present :page, page + present :status, 0 + end + desc "课程作业列表" params do requires :token, type: String diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index e720c90c9..a1eb45a52 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -16,7 +16,139 @@ -
+ +
+
+
+
+
+
+
+
+
+ +
{{act.latest_update}}
+
+ +
+
+ 迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
+ 缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}} +
+
+
+ +
+
+
{{act.praise_count}}
+
{{act.praise_count}}
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
{{act.latest_update}}
+
+ +
+
+
+
+
+ +
+
+
{{act.praise_count}}
+
{{act.praise_count}}
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
{{act.latest_update}}
+
+ +
+
+
+ +
+
+ +
+
+
{{act.praise_count}}
+
{{act.praise_count}}
+
+ +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
更多
+
+
+ +
diff --git a/public/javascripts/wechat/controllers/class.js b/public/javascripts/wechat/controllers/class.js index d372f6826..a0c575d92 100644 --- a/public/javascripts/wechat/controllers/class.js +++ b/public/javascripts/wechat/controllers/class.js @@ -5,6 +5,39 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location var courseid = $routeParams.id; var tag = $routeParams.tag; + vm.course_activities_page = rms.get('course_activities_page') || 0; + vm.course_activities = rms.get("course_activities") || []; + vm.course_has_more = rms.get("course_has_more"); + + vm.course = rms.get("course") || null; + + var getClassActivities = function(page){ + $http({ + method: 'POST', + url: apiUrl + "courses/activities?id=" + courseid, + data:{token:auth.token(),page:page} + }).then(function successCallback(response) { + console.log(response.data); + if(response.data.status == 0){ + vm.class_activities_page = response.data.page; + if(response.data.page > 0) + { + vm.course_activities = vm.class_activities.concat(response.data.data); + } + else{ + vm.course_activities = response.data.data; + vm.course_activities_page = 0; + vm.course_has_more = (response.data.count + response.data.page * 10) < response.data.all_count; + } + } + else{ + vm.alertService.showMessage('提示', response.data.message); + } + + + }, function errorCallback(response) { + }); + }; var getUsers = function(){ if(vm.teachers.length<=0){ @@ -35,7 +68,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location } ) } - } + }; var getResources = function(){ if(vm.resources.length<=0){ @@ -46,7 +79,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location vm.resources_tag = true; }); } - } + }; var getHomeworks = function(){ if(vm.homeworks.length <=0){ @@ -56,7 +89,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location vm.homeworks_tag = true; }); } - } + }; var getExercises = function(){ if(vm.exercises.length <=0){ @@ -66,7 +99,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location vm.exercises_tag = true; }); } - } + }; vm.isTeacher = false; @@ -75,6 +108,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location vm.currentTab = index; vm.searchText = ''; + vm.showActivities = false; vm.showClassMate = false; vm.showResources = false; vm.showHomework = false; @@ -84,35 +118,43 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location vm.exercises_tag = false; if(vm.isTeacher){ - if(index == 1){ //课件 + if(index == 1){ + getClassActivities(0); + vm.showActivities = true; + } + else if(index == 2){ //课件 getResources(); vm.showResources = true; - } else if(index==2){ //作业 + } + else if(index==3){ //作业 getHomeworks(); vm.showHomework = true; - } else if(index==3){ //小测验 - getExercises(); - vm.showTestcase = true; - } else if(index==4){ //学生管理 + } + else if(index==4){ //学生管理 getUsers(); vm.showClassMate = true; } } else { - if(index == 2){ + if(index == 1){ + getClassActivities(0); + vm.showActivities = true; + } + else if(index == 3){ getUsers(); vm.showClassMate = true; - } else if(index==1){ + } + else if(index==2){ getResources(); vm.showResources = true; } } rms.save("tab_num",index); - } + }; vm.tabRecord = rms.get('tab_num') || 1; - vm.course = {}; +// vm.course = {}; vm.students = []; vm.teachers = []; vm.reviewers = []; //待审批 @@ -126,6 +168,11 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location vm.alertService = alertService.create(); vm.invite = function(){ + rms.save('course_activities_page',vm.course_activities_page); + rms.save("course_activities",vm.course_activities); + rms.save("course_has_more",vm.course_has_more); + rms.save("course",vm.course); + $location.path("/invite_code").search({id: courseid}); }; @@ -133,7 +180,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location vm.myresource_sendIndex = index; rms.save('myresource_sendIndex',index); $location.path("/send_class_list").search({id: r.id}); - } + }; $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( function(response) { @@ -161,12 +208,12 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location var resetMenu = function(is_teacher){ vm.isTeacher = is_teacher; if(is_teacher){ - vm.menus = ["课件", "作业", "测验", "成员管理"]; + vm.menus = ["动态", "课件", "作业", "成员管理"]; } else { - vm.menus = ['课件', "我的同学"]; + vm.menus = ['动态','课件', "我的同学"]; } - } + }; vm.onSetting = function(user){ rms.save('current_edit_member', user); @@ -178,8 +225,41 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location rms.save('current_course', vm.course); $location.path("/review_class_member").search({id: courseid,user_id: user.id}); - } + }; + //跳到详情页 + vm.goDetail = function(type, act_id,id){ + rms.save("yoffset", document.documentElement.scrollTop || document.body.scrollTop); + rms.save('course_activities_page',vm.course_activities_page); + rms.save("course_activities",vm.course_activities); + rms.save('course_has_more', vm.course_has_more); + rms.save("course",vm.course); +// $location.path('/'+type+'/'+act_id); + $location.path("/"+type).search({id: act_id}); + }; + vm.addPraise = function(act){ + for(var i in vm.course_activities){ + if(vm.course_activities[i].act_id == act.act_id){ + vm.course_activities[i].praise_count += 1; + vm.course_activities[i].has_praise = true; + break; + } + } + + common.addCommonPraise(act); + }; + + vm.decreasePraise = function(act){ + for(var i in vm.course_activities){ + if(vm.course_activities[i].act_id == act.act_id){ + vm.course_activities[i].praise_count -= 1; + vm.course_activities[i].has_praise = false; + break; + } + } + + common.decreaseCommonPraise(act); + }; }]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/project.js b/public/javascripts/wechat/controllers/project.js index 08987e491..826a16424 100644 --- a/public/javascripts/wechat/controllers/project.js +++ b/public/javascripts/wechat/controllers/project.js @@ -114,6 +114,7 @@ app.controller('ProjectController', ['$scope', 'config','$http','$timeout', 'aut //跳到详情页 vm.goDetail = function(type, act_id,id){ rms.save("yoffset", document.documentElement.scrollTop || document.body.scrollTop); + rms.save('project_activities_page',vm.project_activities_page); rms.save("project_activities",vm.project_activities); rms.save('project_has_more', vm.project_has_more); rms.save("project",vm.project);