微信增加分班相关

This commit is contained in:
yuanke 2016-09-18 16:12:38 +08:00
parent b783ec5b44
commit 04a2effcee
7 changed files with 111 additions and 9 deletions

View File

@ -118,20 +118,18 @@ module Mobile
roles_ids << "10" roles_ids << "10"
end end
go_course_group = 0
if roles_ids.length <= 0 if roles_ids.length <= 0
{status:-1,message:"请至少选择一个角色"} {status:-1,message:"请至少选择一个角色"}
else else
cs = CoursesService.new cs = CoursesService.new
status = cs.join_course_roles({role: roles_ids, openid: params[:openid], invite_code: params[:invite_code]}, current_user) status = cs.join_course_roles({role: roles_ids, openid: params[:openid], invite_code: params[:invite_code]}, current_user)
if params[:student_flag] && status[:state] == 0
#查询分班信息
end
{ {
status: status[:state], status: status[:state],
message:CoursesService::JoinCourseError.message(status[:state]) message:CoursesService::JoinCourseError.message(status[:state]),
go_coursegroup_flag:status[:go_coursegroup_flag],
course_id:status[:course_id]
} }
end end
end end
@ -756,6 +754,24 @@ module Mobile
end end
out.merge(message: message) out.merge(message: message)
end end
desc '获取分班列表'
params do
requires :token, type:String
end
get ':course_id/course_groups' do
begin
authenticate!
course = Course.find(params[:course_id])
groups = []
groups = course.course_groups if course.course_groups
present :data,groups
present :status,0
rescue
present :status,-1
end
end
end end
end end
end end

View File

@ -565,6 +565,8 @@ class CoursesService
#多个角色加入课程 #多个角色加入课程
def join_course_roles params,current_user def join_course_roles params,current_user
course = Course.find_by_invite_code(params[:invite_code]) if params[:invite_code] course = Course.find_by_invite_code(params[:invite_code]) if params[:invite_code]
go_coursegroup_flag = 0
course_id = 0
@state = 10 @state = 10
if course if course
@ -621,6 +623,8 @@ class CoursesService
course.members << members course.members << members
StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id) StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id)
@state = 0 @state = 0
go_coursegroup_flag = 1 if course.course_groups
course_id = course.id
send_wechat_join_class_notice current_user,course,10,0 send_wechat_join_class_notice current_user,course,10,0
else else
is_stu = false is_stu = false
@ -630,6 +634,8 @@ class CoursesService
course.members << members course.members << members
StudentsForCourse.create(:student_id => current_user.id, :course_id =>course.id) StudentsForCourse.create(:student_id => current_user.id, :course_id =>course.id)
is_stu = true is_stu = true
go_coursegroup_flag = 1 if course.course_groups
course_id = course.id
send_wechat_join_class_notice current_user,course,10,0 send_wechat_join_class_notice current_user,course,10,0
end end
#如果已经发送过消息了,那么就要给个提示 #如果已经发送过消息了,那么就要给个提示
@ -674,7 +680,7 @@ class CoursesService
else else
@state = 4 @state = 4
end end
{:state => @state,:course => course} {:state => @state,:course => course,:go_coursegroup_flag => go_coursegroup_flag,:course_id=>course_id}
end end

View File

@ -25,5 +25,7 @@
</div> </div>
</div> </div>
<div ng-show="!current_course" class="blue-title">{{tip_1}}</div>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert> <my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
</div> </div>

View File

@ -0,0 +1,32 @@
<div class="post-container">
<div loading-spinner></div>
<div class="post-container" style="padding-bottom:50px;">
<div class="blue-title">欢迎加入班级</div>
<div class="class-detail-row f13 c-grey3"><img src="images/logo.png" ng-src="current_course.img_url" class="fl ml10 img-circle mt4" width="30"><span class="fl mt10 ml10 ng-binding">{{current_course.name}}</span><div class="cl"></div> </div>
<div class="course-list-row f13 c-grey3 mt10"><span class="fl ml15">选择分班</span></div>
<ul class="class-list f13 c-grey3">
<li><span class="fl ml10 class-list-name hidden">暂无</span><span class="login-box fr mr10 mt12 img-circle" ng-class="['login-box', 'fr', 'mr10', 'mt12', {'bg-grey':assistant,'checked': teacher}]"></span></li>
<div ng-repeat="group in groups">
<li><span class="fl ml10 class-list-name hidden">分班1</span><span class="login-box fr mr10 mt12 img-circle" ng-class="['login-box', 'fr', 'mr10', 'mt12', {'bg-grey':teacher, 'checked': assistant}]"></span></li>
<!--<li class="border-bottom-none"><span class="fl ml10 class-list-name hidden">分班2</span><span class="login-box fr mr10 mt12 img-circle" ng-class="['login-box', 'fr', 'mr10', 'mt12', {'checked': student}]"></span></li>-->
</div>
</ul>
<div class="f12 c-grey6 mt10 ml15">
<span class="f13 c-grey3">提示</span>
<ul class="mb15 mt5 ml10 new-tip">
<li><span class="project-intro-dot"></span>该班级存在分班信息,请选择属于您的小班</li>
<li><span class="project-intro-dot"></span>老师可以在班级的成员管理页,对所有成员进行修改</li>
<li><span class="project-intro-dot"></span>学生可以在班级的我的同学页,对自己进行修改</li>
</ul>
</div>
<div class="bottom-tab-wrap mt10">
<a href="javascript:void(0);" ng-click="cancel()" class="weixin-tab c-grey border-top">取消</a>
<a href="javascript:void(0);" ng-click="joinClass()" class="weixin-tab link-blue2 border-top">确定</a>
</div>
</div>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
</div>

View File

@ -55,10 +55,16 @@ app.controller('JoinClassController', ['$scope', '$http', 'auth', 'config', 'ale
assistant_flag:vm.assistant, assistant_flag:vm.assistant,
student_flag:vm.student student_flag:vm.student
}).then(function(response){ }).then(function(response){
console.log(response);
if(response.data.status == 0){ if(response.data.status == 0){
vm.alertService.showMessage('提示', response.data.message,function(){ vm.alertService.showMessage('提示', response.data.message,function(){
rms.save('syllabuses',[]); rms.save('syllabuses',[]);
if(response.data.go_coursegroup_flag == 0){
$location.path("/class_list"); $location.path("/class_list");
}
else{
$location.path("/join_classgroup").search({id: response.data.course_id});
}
}); });
} else { } else {
vm.alertService.showMessage('提示', response.data.message); vm.alertService.showMessage('提示', response.data.message);

View File

@ -0,0 +1,39 @@
app.controller('JoinClassGroupController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','wx','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,wx,common){
var vm = $scope;
var course_id = $routeParams.id;
vm.alertService = alertService.create();
$http.get(config.apiUrl+ 'courses/'+course_id+"?token="+auth.token()).then(
function(response) {
console.log(response.data);
if (response.data.status == 0){
vm.current_course = response.data.data;
console.log("courses");
console.log(response.data.data);
}
else{
vm.alertService.showMessage('提示', response.data.message);
}
if(!vm.current_course){
vm.tip_1 = "该班级不存在或已被删除";
}
}
);
if(vm.current_course){
$http.get(config.apiUrl + 'courses/course_groups?token='+auth.token()+'&course_id='+course_id).then(
function(response) {
if(response.data.status == 0) {
vm.groups = response.data.groups;
}
else{
vm.groups = [];
}
});
}
}] );

View File

@ -39,6 +39,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
.when('/invite_code', {templateUrl: rootPath + 'invite_code.html', controller: 'InviteCodeController'}) .when('/invite_code', {templateUrl: rootPath + 'invite_code.html', controller: 'InviteCodeController'})
.when('/send_class_list', makeRoute('send_class_list.html', 'SendClassListController')) .when('/send_class_list', makeRoute('send_class_list.html', 'SendClassListController'))
.when('/join_class', makeRoute('join_class.html', 'JoinClassController')) .when('/join_class', makeRoute('join_class.html', 'JoinClassController'))
.when('/join_classgroup', makeRoute('join_classgroup.html', 'JoinClassGroupController'))
.when('/review_class_member', makeRoute('review_class_member.html', 'ReviewClassMemberController')) .when('/review_class_member', makeRoute('review_class_member.html', 'ReviewClassMemberController'))
.when('/class_publishnotice', makeRoute('class_publishnotice.html', 'ClassPublishNoticeController')) .when('/class_publishnotice', makeRoute('class_publishnotice.html', 'ClassPublishNoticeController'))
.when('/class_publishissue', makeRoute('class_publishissue.html', 'ClassPublishIssueController')) .when('/class_publishissue', makeRoute('class_publishissue.html', 'ClassPublishIssueController'))