Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange
This commit is contained in:
commit
f33feb7d84
|
@ -11,7 +11,9 @@ module Mobile
|
|||
end
|
||||
get do
|
||||
authenticate!
|
||||
data = current_user.course_attachments
|
||||
rs = ResourcesService.new
|
||||
# data = current_user.course_attachments
|
||||
data = rs.all_course_attachments current_user
|
||||
present :data, data, with: Mobile::Entities::Attachment
|
||||
present :status, 0
|
||||
|
||||
|
@ -26,7 +28,8 @@ module Mobile
|
|||
get 'homeworks' do
|
||||
authenticate!
|
||||
|
||||
homeworks = current_user.homework_commons
|
||||
rs = ResourcesService.new
|
||||
homeworks = rs.all_homework_commons current_user
|
||||
|
||||
present :data, homeworks, with: Mobile::Entities::Homework
|
||||
present :status, 0
|
||||
|
@ -40,7 +43,8 @@ module Mobile
|
|||
get 'exercies' do
|
||||
authenticate!
|
||||
|
||||
exercises = current_user.exercises
|
||||
rs = ResourcesService.new
|
||||
exercises = rs.all_exercises current_user
|
||||
present :data, exercises, with: Mobile::Entities::Exercise
|
||||
present :status, 0
|
||||
end
|
||||
|
|
|
@ -29,6 +29,8 @@ module Mobile
|
|||
attachment_expose :quotes
|
||||
attachment_expose :created_on
|
||||
attachment_expose :file_dir
|
||||
attachment_expose :attafile_size
|
||||
attachment_expose :coursename #所属班级名
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,6 +3,7 @@ module Mobile
|
|||
class Exercise < Grape::Entity
|
||||
expose :exercise_name
|
||||
expose :exercise_description
|
||||
expose :coursename #所属班级名
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -94,6 +94,8 @@ module Mobile
|
|||
|
||||
homework_expose :homework_anony_type #是否是匿评作业
|
||||
|
||||
homework_expose :coursename #所属班级名
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
#coding=utf-8
|
||||
|
||||
class ResourcesService
|
||||
|
||||
include ActionView::Helpers::NumberHelper
|
||||
#发送资源到课程
|
||||
def send_resource_to_course user,params
|
||||
send_id = params[:send_id]
|
||||
|
@ -50,4 +50,56 @@ class ResourcesService
|
|||
[@ori, @flag, @save_message]
|
||||
end
|
||||
|
||||
# 我的资源-课件 已发布的
|
||||
def all_course_attachments user
|
||||
|
||||
courses = user.courses.not_deleted
|
||||
|
||||
courses_ids = courses.empty? ? '(-1)' :"(" + courses.map(&:id).join(",") + ")"
|
||||
|
||||
attchments = Attachment.where("(author_id = #{user.id} and is_publish = 1 and container_id in #{courses_ids} and container_type = 'Course') or (container_type = 'Course' and is_publish = 1 and container_id in #{courses_ids})" ).order("created_on desc")
|
||||
|
||||
attchments.each do |v|
|
||||
course = Course.where("id=?",v.container_id).first
|
||||
v[:coursename] = course.nil? ? "未知" : course.name
|
||||
v[:attafile_size] = (number_to_human_size(v[:filesize])).gsub("ytes", "").to_s
|
||||
end
|
||||
|
||||
attchments
|
||||
end
|
||||
|
||||
# 我的资源-作业 已发布的
|
||||
def all_homework_commons user
|
||||
|
||||
courses = user.courses.not_deleted
|
||||
|
||||
courses_ids = courses.empty? ? '(-1)' :"(" + courses.map(&:id).join(",") + ")"
|
||||
|
||||
homeworks = HomeworkCommon.where("course_id in #{courses_ids} and publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
|
||||
|
||||
homeworks.each do |v|
|
||||
course = Course.where("id=?",v.course_id).first
|
||||
v[:coursename] = course.nil? ? "未知" : course.name
|
||||
end
|
||||
|
||||
homeworks
|
||||
end
|
||||
|
||||
# 我的资源-测验 已发布的
|
||||
def all_exercises user
|
||||
|
||||
courses = user.courses.not_deleted
|
||||
|
||||
courses_ids = courses.empty? ? '(-1)' :"(" + courses.map(&:id).join(",") + ")"
|
||||
|
||||
exercises = Exercise.where("exercise_status <> 1 and course_id in #{courses_ids}").order("created_at desc")
|
||||
|
||||
exercises.each do |v|
|
||||
course = Course.where("id=?",v.course_id).first
|
||||
v[:coursename] = course.nil? ? "未知" : course.name
|
||||
end
|
||||
|
||||
exercises
|
||||
end
|
||||
|
||||
end
|
|
@ -1,34 +1,35 @@
|
|||
<div class="post-container" style="padding-bottom: 50px;">
|
||||
<div loading-spinner></div>
|
||||
<div class="blue-title">课程列表</div>
|
||||
|
||||
<div ng-repeat="syllabus in syllabuses">
|
||||
<div>
|
||||
<div class="course-diff-row"><span class="c-blue f13 ml10">我创建的课程</span></div>
|
||||
<div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3"><img src="/images/wechat/plus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">{{syllabus.title}}</span><img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="fr mr10 mt10" ng-click="onSetting(syllabus)" /></div>
|
||||
<ul ng-show="!syllabus.show_plus" class="class-list f13 c-grey3">
|
||||
<li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}">
|
||||
<img src="/images/wechat/dot.png" width="15px" class="class-list-dot" />
|
||||
<span class="fl ml10 class-list-name hidden">{{course.name}}</span>
|
||||
<span class="fr c-grey4">></span>
|
||||
<span class="students-amount f12 fr mt10">{{course.member_count}}人</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div ng-show = "syllabus.can_setting" ng-repeat="syllabus in syllabuses">
|
||||
<div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3"><img src="/images/wechat/plus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">{{syllabus.title}}</span><img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="fr mr10 mt10" ng-click="onSetting(syllabus)" /></div>
|
||||
<ul ng-show="!syllabus.show_plus" class="class-list f13 c-grey3">
|
||||
<li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}">
|
||||
<img src="/images/wechat/dot.png" width="15px" class="class-list-dot" />
|
||||
<span class="fl ml10 class-list-name hidden">{{course.name}}</span>
|
||||
<span class="fr c-grey4">></span>
|
||||
<span class="students-amount f12 fr mt10">{{course.member_count}}人</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-repeat="syllabus in syllabuses">
|
||||
<div>
|
||||
<div class="course-diff-row border-top mt10"><span class="c-blue f13 ml10">我参与的课程</span></div>
|
||||
<div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3"><img src="/images/wechat/plus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">{{syllabus.title}}</span><img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="fr mr10 mt10" ng-click="onSetting(syllabus)" /></div>
|
||||
<ul ng-show="!syllabus.show_plus" class="class-list f13 c-grey3">
|
||||
<li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}">
|
||||
<img src="/images/wechat/dot.png" width="15px" class="class-list-dot" />
|
||||
<span class="fl ml10 class-list-name hidden">{{course.name}}</span>
|
||||
<span class="fr c-grey4">></span>
|
||||
<span class="students-amount f12 fr mt10">{{course.member_count}}人</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div ng-show = "!syllabus.can_setting" ng-repeat="syllabus in syllabuses">
|
||||
<div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3"><img src="/images/wechat/plus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">{{syllabus.title}}</span><img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="fr mr10 mt10" ng-click="onSetting(syllabus)" /></div>
|
||||
<ul ng-show="!syllabus.show_plus" class="class-list f13 c-grey3">
|
||||
<li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}">
|
||||
<img src="/images/wechat/dot.png" width="15px" class="class-list-dot" />
|
||||
<span class="fl ml10 class-list-name hidden">{{course.name}}</span>
|
||||
<span class="fr c-grey4">></span>
|
||||
<span class="students-amount f12 fr mt10">{{course.member_count}}人</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="bottom-tab-wrap mt10">
|
||||
<a ng-click="newClass()" href="javascript:void(0);" class="weixin-tab link-blue2 border-top">新建课程</a>
|
||||
<a ng-click="joinClass()" class="weixin-tab link-blue2 border-top">加入班级</a>
|
||||
|
|
|
@ -12,22 +12,22 @@
|
|||
|
||||
<div ng-class="{'undis': currentTab!=1}">
|
||||
<div ng-repeat="r in resources|filter:{filename:searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]">
|
||||
<img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /> <span class="fl ml10 resource-width">{{r.filename}}</span><a ng-click="sendFile(r)" class="fr mr10 link-blue2">发送</a><div class="cl"></div>
|
||||
<span class="f12 mt5 ml35 c-grey4">课件来源:</span><span class="f12 ml10 mt5 c-grey4">大小:</span>
|
||||
<img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /> <a ng-href="/attachments/download/{{r.id}}/{{r.filename}}" target="_blank" class="fl ml10 resource-width">{{r.filename}}</a><a ng-click="sendFile(r)" class="fr mr10 link-blue2">发送</a><div class="cl"></div>
|
||||
<span class="f12 mt5 ml35 c-grey4">课件来源:{{r.coursename}}</span><span class="f12 ml10 mt5 c-grey4">大小:{{r.attafile_size}}</span>
|
||||
</div>
|
||||
<p ng-show="resources && resources.length<=0" class="class-test-tip">暂无课件,<br />
|
||||
请登录Trustie网站,在PC浏览器中上传课件。</p>
|
||||
</div>
|
||||
<div ng-class="{'undis': currentTab!=2}">
|
||||
<div ng-repeat="r in homeworks|filter:{homework_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/homework.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.homework_name}}</span><a ng-click="sendFile(r)" class="fr mr10 link-blue2">发送</a><div class="cl"></div>
|
||||
<span class="f12 mt5 ml35 c-grey4">作业来源:</span>
|
||||
<span class="f12 mt5 ml35 c-grey4">作业来源:{{r.coursename}}</span>
|
||||
</div>
|
||||
<p ng-show="homeworks && homeworks.length<=0" class="class-test-tip">暂无作业,<br />
|
||||
请登录Trustie网站,在PC浏览器中创建作业。</p>
|
||||
</div>
|
||||
<div ng-class="{'undis': currentTab!=3}">
|
||||
<div ng-repeat="r in exercise|filter:{exercise_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/test.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.exercise_name}}</span><a ng-click="sendFile(r)" class="fr mr10 link-blue2">发送</a><div class="cl"></div>
|
||||
<span class="f12 mt5 ml35 c-grey4">题目来源:</span>
|
||||
<span class="f12 mt5 ml35 c-grey4">题目来源:{{r.coursename}}</span>
|
||||
</div>
|
||||
<p ng-show="exercise && exercise.length<=0" class="class-test-tip">暂无测验,<br />
|
||||
请登录Trustie网站,在PC浏览器中创建测验。</p>
|
||||
|
|
|
@ -137,6 +137,9 @@ app.controller('ActivityController',
|
|||
//跳到详情页
|
||||
$scope.goDetail = function(type, act_id,id){
|
||||
rms.save("yoffset", window.document.body.scrollTop);
|
||||
rms.save("activities",$scope.activities);
|
||||
rms.save("course_activities",$scope.course_activities);
|
||||
rms.save("project_activities",$scope.project_activities);
|
||||
$location.path('/'+type+'/'+act_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
|
||||
app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location', function($scope, $http, auth, config, alertService, $location){
|
||||
app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','rms', function($scope, $http, auth, config, alertService, $location,rms){
|
||||
var vm = $scope;
|
||||
|
||||
vm.alertService = alertService.create();
|
||||
|
@ -40,7 +40,9 @@ app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'aler
|
|||
vm.alertService.showMessage('出错了', response.data.message);
|
||||
} else {
|
||||
vm.alertService.showMessage('提示', '新建课程成功', function(){
|
||||
window.history.back();
|
||||
// window.history.back();
|
||||
rms.save('syllabuses',[]);
|
||||
$location.path("/class_list");
|
||||
});
|
||||
}
|
||||
console.log(response.data.data);
|
||||
|
|
|
@ -86,7 +86,7 @@ app.factory('rms', function(){
|
|||
return {save: save, get: get};
|
||||
});
|
||||
|
||||
app.factory('common', ['$http', 'auth', '$routeParams', function($http, auth, $routeParams){
|
||||
app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, auth, $routeParams,rms){
|
||||
var addCommonReply = function(id, type, data, cb){
|
||||
|
||||
if(!data.comment || data.comment.length<=0){
|
||||
|
@ -174,8 +174,71 @@ app.factory('common', ['$http', 'auth', '$routeParams', function($http, auth, $r
|
|||
}
|
||||
});
|
||||
};
|
||||
args.scope.addPraise = addCommonPraise;
|
||||
args.scope.decreasePraise = decreaseCommonPraise;
|
||||
|
||||
// 动态详情界面点赞与动态界面的数据要同步 保证进入详情点赞后出来显示一致
|
||||
args.scope.addPraise = function(act){
|
||||
activities = rms.get("activities") || [];
|
||||
course_activities = rms.get("course_activities") || [];
|
||||
project_activities = rms.get("project_activities") || [];
|
||||
for(var i in activities){
|
||||
if(activities[i].act_id == act.act_id){
|
||||
activities[i].praise_count += 1;
|
||||
activities[i].has_praise = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(var i in course_activities){
|
||||
if(course_activities[i].act_id == act.act_id){
|
||||
course_activities[i].praise_count += 1;
|
||||
course_activities[i].has_praise = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(var i in project_activities){
|
||||
if(project_activities[i].act_id == act.act_id){
|
||||
project_activities[i].praise_count += 1;
|
||||
project_activities[i].has_praise = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
rms.save("activities",activities);
|
||||
rms.save("course_activities",course_activities);
|
||||
rms.save("project_activities",project_activities);
|
||||
|
||||
addCommonPraise(act);
|
||||
};
|
||||
|
||||
args.scope.decreasePraise = function(act){
|
||||
activities = rms.get("activities") || [];
|
||||
course_activities = rms.get("course_activities") || [];
|
||||
project_activities = rms.get("project_activities") || [];
|
||||
for(var i in activities){
|
||||
if(activities[i].act_id == act.act_id){
|
||||
activities[i].praise_count -= 1;
|
||||
activities[i].has_praise = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(var i in course_activities){
|
||||
if(course_activities[i].act_id == act.act_id){
|
||||
course_activities[i].praise_count -= 1;
|
||||
course_activities[i].has_praise = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(var i in project_activities){
|
||||
if(project_activities[i].act_id == act.act_id){
|
||||
project_activities[i].praise_count -= 1;
|
||||
project_activities[i].has_praise = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
rms.save("activities",activities);
|
||||
rms.save("course_activities",course_activities);
|
||||
rms.save("project_activities",project_activities);
|
||||
|
||||
decreaseCommonPraise(act);
|
||||
};
|
||||
}
|
||||
|
||||
return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise};
|
||||
|
|
Loading…
Reference in New Issue