This commit is contained in:
guange 2016-07-08 17:44:13 +08:00
commit 1413fe82dc
10 changed files with 43 additions and 45 deletions

View File

@ -56,7 +56,7 @@ module Mobile
authenticate!
rs = ResourcesService.new
ori, flag, save_message = rs.send_resource_to_course(params)
ori, flag, save_message = rs.send_resource_to_course(current_user,params)
if flag
present :status, 0
else

View File

@ -28,7 +28,7 @@ module Mobile
ss = SyllabusesService.new
sy = ::Syllabus.find(params[:id])
sy.courses = sy.courses.not_deleted
sy = ss.judge_can_setting(sy,current_user)
present :data, sy, with: Mobile::Entities::Syllabus

View File

@ -3,7 +3,7 @@
class ResourcesService
#发送资源到课程
def send_resource_to_course params
def send_resource_to_course user,params
send_id = params[:send_id]
@ori = Attachment.find_by_id(send_id)
course_ids = params[:course_ids]
@ -26,7 +26,7 @@ class ResourcesService
attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联
attach_copied_obj.container = Course.find(id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.author_id = user.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil

View File

@ -46,28 +46,16 @@ class SyllabusesService
courses = user.courses.not_deleted
syllabus_ids = courses.empty? ? '(-1)' : "(" + courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")"
syllabuses = Syllabus.where("id in #{syllabus_ids} or user_id = #{user.id}").order("updated_at desc")
user.syllabuses.each do |syllabus|
syllabus.courses = syllabus.courses.not_deleted
end
syllabuses.to_a << other
#管理权限 can_setting
syllabuses.each do |s|
s = judge_can_setting(s,user)
# s[:can_setting] = s.user_id == user.id ? true : false
# s.courses.each do |c|
# c[:can_setting] = false
#
# member = c.members.where("user_id=#{user.id} and course_id=#{c.id}")[0]
# roleName = member.roles[0].name if member
#
# if roleName && (roleName == "TeachingAsistant" || roleName == "Teacher" )
# c[:can_setting] = true
# end
#
# if c.tea_id == user.id
# c[:can_setting] = true
# end
# end
end
syllabuses
@ -138,8 +126,8 @@ class SyllabusesService
#新增班级
add_courses = option[:add_courses]
add_courses.each do |c|
course = ::Course.new(c)
course.name = add_courses
course = Course.new()
course.name = c
course.tea_id = user.id
course.syllabus_id = sy.id
course.update_default_value

View File

@ -1,18 +1,21 @@
<div class="post-container">
<div loading-spinner></div>
<div class="class-detail-name">{{course.name}}<span ng-click="invite()" class="f13 blue-title-sub">邀请码</span></div>
<div class="slice3 fl"></div>
<div ng-repeat="menu in menus">
<div id="class_tab_1" ng-class="[{'class-detail-tab': isTeacher},{'class-detail-tab3': !isTeacher},{'class-tab-active':currentTab==$index+1}]" ng-click="tab($index+1);"><a herf="javascript:void(0);">{{menu}}</a></div>
<div ng-if="!$last" class="slice2 fl">
<div class="slice-line2"></div>
</div>
<div class="tab-wrap">
<a ng-click="tab($index+1)" ng-repeat="menu in menus" id="class_tab_1" href="javascript:void(0);" ng-class="['weixin-tab', {'class-tab-active': currentTab == $index+1}]">{{menu}}</a>
</div>
<!--<div class="slice3 fl"></div>-->
<div class="slice3 fl"></div>
<div class="cl"></div>
<!--<div ng-repeat="menu in menus">-->
<!--<div id="class_tab_1" ng-class="[{'class-detail-tab': isTeacher},{'class-detail-tab3': !isTeacher},{'class-tab-active':currentTab==$index+1}]" ng-click="tab($index+1);"><a herf="javascript:void(0);">{{menu}}</a></div>-->
<!--<div ng-if="!$last" class="slice2 fl">-->
<!--<div class="slice-line2"></div>-->
<!--</div>-->
<!--</div>-->
<!--<div class="slice3 fl"></div>-->
<!--<div class="cl"></div>-->
<div class="class-search-wrap">
<div class="class-search-inner"> <img src="/images/wechat/search.png" width="18" class="class-search-icon" />
<input class="class-detail-search" ng-model="searchText" placeholder="输入关键词进行搜索" />

View File

@ -5,10 +5,10 @@
<div class="blue-title">发送课程列表</div>
<div ng-repeat="syllabus in syllabuses">
<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 mt10"><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></div>
<ul ng-show="!syllabus.show_plus" class="class-list f13 c-grey3">
<li ng-click="selectCourse(course)" ng-class="{'border-bottom-none': $last }" ng-repeat="course in syllabus.courses"><img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /><span class="fl ml10 class-list-name hidden">{{course.name}}</span><span ng-class="['login-box', 'fr', 'mr5', 'mt12', {'checked': course.checked}]"></span></li>
<li ng-show="course.can_setting" ng-click="selectCourse(course)" ng-class="{'border-bottom-none': $last }" ng-repeat="course in syllabus.courses"><img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /><span class="fl ml10 class-list-name hidden">{{course.name}}</span><span ng-class="['login-box', 'fr', 'mr5', 'mt12', {'checked': course.checked}]"></span></li>
</ul>
</div>

View File

@ -3,7 +3,7 @@ app.factory("alertService",function(){function t(){this.title=null,this.message=
app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]),app.filter("identify",function(){return function(t){return"TeachingAsistant"==t?"教辅":""}});
app.controller("ActivityController",["$anchorScroll","$location","$scope","$http","$timeout","auth","rms","common","alertService",function(e,a,t,c,o,i,r,s,n){t.replaceUrl=function(e){return e},t.menus=["所有动态","课程动态","项目动态"],t.alertService=n.create(),console.log("ActivityController load"),t.page=r.get("page")||0,t.activities=r.get("activities")||[],t.has_more=r.get("has_more"),t.course_page=r.get("course_page")||0,t.course_activities=r.get("course_activities")||[],t.course_has_more=r.get("course_has_more"),t.project_page=r.get("project_page")||0,t.project_activities=r.get("project_activities")||[],t.project_has_more=r.get("project_has_more"),t.loadActData=function(e,a){switch(container_type="All",e){case 1:container_type="All",t.page=a;break;case 2:container_type="Course",t.course_page=a;break;case 3:container_type="Project",t.project_page=a}c({method:"POST",url:apiUrl+"activities",data:{token:i.token(),page:a,container_type:container_type}}).then(function(e){if(e.data.page>0)switch(e.data.container_type){case"All":t.activities=t.activities.concat(e.data.data);break;case"Course":t.course_activities=t.course_activities.concat(e.data.data);break;case"Project":t.project_activities=t.project_activities.concat(e.data.data);break;case 3:}else switch(e.data.container_type){case"All":t.activities=e.data.data;break;case"Course":t.course_activities=e.data.data;break;case"Project":t.project_activities=e.data.data;break;case 3:}switch(e.data.container_type){case"All":r.save("activities",t.activities),t.has_more=e.data.count+10*e.data.page<e.data.all_count,r.save("has_more",t.has_more),r.save("page",e.data.page);break;case"Course":r.save("course_activities",t.course_activities),t.course_has_more=e.data.count+10*e.data.page<e.data.all_count,r.save("course_has_more",t.course_has_more),r.save("course_page",e.data.page);break;case"Project":r.save("project_activities",t.project_activities),t.project_has_more=e.data.count+10*e.data.page<e.data.all_count,r.save("project_has_more",t.project_has_more),r.save("project_page",e.data.page);break;case 3:}console.log(e.data)},function(e){})},t.tab=function(e){switch(t.currentTab=e,e){case 1:t.activities.length<=0&&t.loadActData(e,0);break;case 2:t.course_activities.length<=0&&t.loadActData(e,0);break;case 3:t.project_activities.length<=0&&t.loadActData(e,0)}},t.currentTab=1,t.activities.length<=0?t.loadActData(1,0):o(function(){window.scrollTo(0,r.get("yoffset"))}),t.goDetail=function(e,t,c){r.save("yoffset",window.document.body.scrollTop),a.path("/"+e+"/"+t)},t.addPraise=function(e){s.addCommonPraise(e)},t.decreasePraise=function(e){s.decreaseCommonPraise(e)}}]);
app.controller("BlogController",["$scope","$http","$routeParams","auth","common",function(o,l,t,n,a){a.init({id:t.id,scope:o,type:"blog_comments",replyType:"BlogComment",loadCallback:function(l){o.blog=l.data},replyCallback:function(){}})}]);
app.controller("ClassController",["$scope","config","$http","auth","$location","$routeParams",function(e,s,t,o,a,n){var r=e,c=n.id,u=function(){r.teachers.length<=0&&t.get(s.apiUrl+"courses/teachers?token="+o.token()+"&course_id="+c).then(function(e){console.log(e.data),r.teachers=e.data.data}),r.students.length<=0&&t.get(s.apiUrl+"courses/students?token="+o.token()+"&course_id="+c).then(function(e){console.log(e.data),r.students=e.data.data})},i=function(){r.resources.length<=0&&t.post(s.apiUrl+"courses/"+c+"/attachments",{token:o.token(),name:""}).then(function(e){r.resources=e.data.data,r.resources_tag=!0})},h=function(){r.homeworks.length<=0&&t.get(s.apiUrl+"courses/homeworks/"+c+"?token="+o.token()).then(function(e){r.homeworks=e.data.data,console.log(e.data),r.homeworks_tag=!0})},l=function(){r.exercises.length<=0&&t.get(s.apiUrl+"courses/"+c+"/exercises?token="+o.token()).then(function(e){r.exercises=e.data.data,console.log(e.data),r.exercises_tag=!0})};r.isTeacher=!1,r.currentTab=1,r.tab=function(e){r.currentTab=e,r.searchText="",r.showClassMate=!1,r.showResources=!1,r.showHomework=!1,r.showTestcase=!1,r.resources_tag=!1,r.homeworks_tag=!1,r.exercises_tag=!1,r.isTeacher?1==e?(i(),r.showResources=!0):2==e?(h(),r.showHomework=!0):3==e?(l(),r.showTestcase=!0):4==e&&(u(),r.showClassMate=!0):2==e?(u(),r.showClassMate=!0):1==e&&(i(),r.showResources=!0)},r.course={},r.students=[],r.teachers=[],r.resources=[],r.homeworks=[],r.exercises=[],r.invite=function(){a.path("/invite_code").search({id:c})},r.sendFile=function(e){a.path("/send_class_list").search({id:e.id})},t.get(s.apiUrl+"courses/"+c+"?token="+o.token()).then(function(e){console.log(e.data),r.course=e.data.data,d(r.course.current_user_is_teacher),r.tab(1)});var d=function(e){r.isTeacher=e,e?r.menus=["课件","作业","小测验","学生管理"]:r.menus=["课堂资源","我的同学"]}}]);
app.controller("ClassController",["$scope","config","$http","auth","$location","$routeParams",function(e,s,t,o,a,n){var r=e,c=n.id,u=function(){r.teachers.length<=0&&t.get(s.apiUrl+"courses/teachers?token="+o.token()+"&course_id="+c).then(function(e){console.log(e.data),r.teachers=e.data.data}),r.students.length<=0&&t.get(s.apiUrl+"courses/students?token="+o.token()+"&course_id="+c).then(function(e){console.log(e.data),r.students=e.data.data})},i=function(){r.resources.length<=0&&t.post(s.apiUrl+"courses/"+c+"/attachments",{token:o.token(),name:""}).then(function(e){r.resources=e.data.data,r.resources_tag=!0})},h=function(){r.homeworks.length<=0&&t.get(s.apiUrl+"courses/homeworks/"+c+"?token="+o.token()).then(function(e){r.homeworks=e.data.data,console.log(e.data),r.homeworks_tag=!0})},l=function(){r.exercises.length<=0&&t.get(s.apiUrl+"courses/"+c+"/exercises?token="+o.token()).then(function(e){r.exercises=e.data.data,console.log(e.data),r.exercises_tag=!0})};r.isTeacher=!1,r.currentTab=1,r.tab=function(e){r.currentTab=e,r.searchText="",r.showClassMate=!1,r.showResources=!1,r.showHomework=!1,r.showTestcase=!1,r.resources_tag=!1,r.homeworks_tag=!1,r.exercises_tag=!1,r.isTeacher?1==e?(i(),r.showResources=!0):2==e?(h(),r.showHomework=!0):3==e?(l(),r.showTestcase=!0):4==e&&(u(),r.showClassMate=!0):2==e?(u(),r.showClassMate=!0):1==e&&(i(),r.showResources=!0)},r.course={},r.students=[],r.teachers=[],r.resources=[],r.homeworks=[],r.exercises=[],r.invite=function(){a.path("/invite_code").search({id:c})},r.sendFile=function(e){a.path("/send_class_list").search({id:e.id})},t.get(s.apiUrl+"courses/"+c+"?token="+o.token()).then(function(e){console.log(e.data),r.course=e.data.data,d(r.course.current_user_is_teacher),r.tab(1)});var d=function(e){r.isTeacher=e,e?r.menus=["课件","作业","小测验","学生管理"]:r.menus=["课","我的同学"]}}]);
app.controller("ClassListController",["$scope","config","auth","$http","$location","alertService","rms",function(e,s,a,t,o,l,n){var c=e;c.syllabuses=n.get("syllabuses")||[],c.alertService=l.create();var i=function(){t.get(s.apiUrl+"syllabuses?token="+a.token()).then(function(e){console.log(e.data),c.syllabuses=e.data.data,n.save("syllabuses",c.syllabuses)})};c.syllabuses.length<=0&&i(),c.goClass=function(e){console.log(e),o.path("/class").search({id:e})},c.newClass=function(){o.path("/new_class")},c.goResource=function(){o.path("/myresource")},c.joinClass=function(){var e=window.prompt("请输入5位班级邀请码(不区分大小写)");e&&5==e.length?t.post(s.apiUrl+"courses/join",{token:a.token(),invite_code:e}).then(function(e){console.log(e.data),0!=e.data.status?c.alertService.showMessage("错误",e.data.message):(c.alertService.showMessage("提示","加入课程成功"),i())}):e&&c.alertService.showMessage("错误","邀请码格式不正确")},c.onSetting=function(e){console.log(e),n.save("current_edit_syllobus",e),o.path("/edit_class").search({id:e.id})}}]);
app.controller("CourseNoticeController",["$scope","$http","$routeParams","auth","common",function(o,e,t,n,a){a.init({id:t.id,scope:o,type:"newss",replyType:"News",loadCallback:function(e){o.news=e.data},replyCallback:function(){}})}]);
app.controller("DiscussionController",["$scope","$http","$routeParams","auth","common",function(o,s,a,e,n){n.init({id:a.id,scope:o,type:"messages",replyType:"Message",loadCallback:function(s){o.discussion=s.data},replyCallback:function(){}})}]);

View File

@ -4,24 +4,31 @@ app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'ale
var vm = $scope;
vm.syllabus = rms.get('current_edit_syllobus');
console.log(vm.syllabus);
var syllabus_id = $routeParams.id;
if(!vm.syllabus){
$http.get(config.apiUrl+"syllabuses/"+syllabus_id+"?token="+auth.token()).then(function(response){
console.log(response.data);
vm.syllabus = response.data.data;
if (vm.syllabus) {
for (var i in vm.syllabus.courses) {
var course = vm.syllabus.courses[i];
course.tmpname = course.name;
}
vm.syllabus.tmptitle = vm.syllabus.title;
}
});
}
console.log(vm.syllabus);
//名字用两份
for(var i in vm.syllabus.courses){
var course = vm.syllabus.courses[i];
course.tmpname = course.name;
if (vm.syllabus) {
for (var i in vm.syllabus.courses) {
var course = vm.syllabus.courses[i];
course.tmpname = course.name;
}
vm.syllabus.tmptitle = vm.syllabus.title;
}
vm.syllabus.tmptitle = vm.syllabus.title;
//单弹框
vm.alertService_1 = alertService.create();

View File

@ -10,7 +10,7 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co
function (response) {
console.log(response.data);
vm.syllabuses = response.data.data;
rms.save('syllabuses', vm.syllabuses);
// rms.save('syllabuses', vm.syllabuses);
}
);
};

File diff suppressed because one or more lines are too long