微信增加分班相关功能

This commit is contained in:
yuanke 2016-09-19 13:22:29 +08:00
parent 04a2effcee
commit 3624d9d4ca
12 changed files with 195 additions and 23 deletions

View File

@ -757,12 +757,13 @@ module Mobile
desc '获取分班列表'
params do
requires :id, type: Integer
requires :token, type:String
end
get ':course_id/course_groups' do
get 'course_groups/:id' do
begin
authenticate!
course = Course.find(params[:course_id])
course = Course.find(params[:id])
groups = []
groups = course.course_groups if course.course_groups
present :data,groups
@ -772,6 +773,28 @@ module Mobile
end
end
desc "加入分班"
params do
requires :id, type: Integer
requires :token, type: String
requires :course_group_id, type: Integer
end
post 'join_coursegroup' do
begin
authenticate!
member = Member.where(:course_id => params[:id], :user_id => current_user.id).first
raise "你还不是该班级的学生!" unless member
member.course_group_id = params[:course_group_id].to_i
member.save
present :status,0
rescue Exception=>e
present :message,e.message
present :status,-1
end
end
end
end
end

View File

@ -19,6 +19,8 @@ module Mobile
(format_time(c[field]) if (c.is_a?(Hash) && c.key?(field))) || (format_time(c.send(field)) if c.respond_to?(field))
elsif field == :member_count
::Course===c ? c.members.count : 0
elsif field == :syllabus_title
c.syllabus.nil? ? "":c.syllabus.title
else
(c[field] if (c.is_a?(Hash) && c.key?(field))) || (c.send(field) if c.respond_to?(field))
end
@ -38,6 +40,7 @@ module Mobile
course_expose :lft
course_expose :location
course_expose :name
course_expose :syllabus_title
course_expose :open_student
# course_expose :password
course_expose :rgt

View File

@ -36,6 +36,8 @@ module Mobile
u.lastname
when :mail
u.mail
when :is_me
defined? u.is_me ? u.is_me : 0
end
end
end
@ -77,6 +79,8 @@ module Mobile
user_expose :name
user_expose :is_me
end
end

View File

@ -115,7 +115,7 @@ class CoursesService
role_name: m.roles.first.name,
name: m.user.show_name,
roles_id: role_ids.include?(7) ? 7 : (role_ids.include?(9) ? 9 : 10 ),
:brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname}
:brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname,:is_me => current_user.id == m.user.id ? 1:0 }
# end
end

View File

@ -25,7 +25,7 @@
<div class="post-wrapper">
<div class="post-main">
<div dataID = "{{act.act_id}}" ng-click="goDetail('homework',act.act_id, act.id)" id="act_{{act.id}}">
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
<div class="post-avatar fl mr10"><img female="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
<div class="post-dynamic-author hidden fl">
<span>{{act.author.real_name}}</span>
<img ng-if="act.author.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
@ -256,6 +256,7 @@
<div class="class-member-row f13 c-grey3" ng-repeat="student in students|filter:searchText">
<img ng-src="{{student.img_url}}" width="30" height="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{student.name}}</span><img ng-src="/images/wechat/{{student.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
<img src="/images/wechat/setting.png" ng-show = "isTeacher" width="15" class="class-list-setting" ng-click="onSetting(student)" />
<img src="/images/wechat/setting.png" ng-show = "!isTeacher && is_me" width="15" class="class-list-setting" ng-click="onSetting_1(student)" />
<div class="cl"></div>
</div>

View File

@ -3,12 +3,12 @@
<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>
<div class="course-list-row f13 c-grey3 mt10"><span class="fl ml15">选择分班{{selectid}}</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>
<li><span class="fl ml10 class-list-name hidden">暂无</span><span ng-click="selectid = 0" class="login-box fr mr10 mt12 img-circle" ng-class="[{'checked': selectid == 0}]"></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><span class="fl ml10 class-list-name hidden">{{group.course_group.name}}</span><span ng-click="selectGroup(group.course_group.id)" class="login-box fr mr10 mt12 img-circle" ng-class="[{'checked': selectid == group.course_group.id}]"></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>
@ -23,8 +23,8 @@
</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>
<a ng-click="cancel()" ng-click="cancel()" class="weixin-tab c-grey border-top">取消</a>
<a ng-click="confirm()" ng-click="joinClass()" class="weixin-tab link-blue2 border-top">确定</a>
</div>
</div>

View File

@ -0,0 +1,25 @@
<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/post-avatar.jpg" ng-src="current_edit_member.user.img_url" class="fl ml10 img-circle mt4" width="30"><span class="fl mt10 ml10 ng-binding">{{current_edit_member.user.show_name}}</span><img ng-src="/images/wechat/{{current_edit_member.user.gender==0 ? 'male' : 'female'}}.png" class="fl ml10 mt10" width="15"><div class="cl"></div> </div>
<div class="course-list-row f13 c-grey3 mt10"><span class="fl ml15">角色</span></div>
<div class="f13 ml35 mt10 c-grey3">学生</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>
<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>
</ul>
<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>
<div ng-show="!current_course" class="blue-title">{{tip_1}}</div>
<div ng-show="!vm.student" class="blue-title">{{tip_2}}</div>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
</div>

View File

@ -247,7 +247,6 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
resetMenu(vm.course.current_user_is_teacher,vm.currentTab);
}
vm.onSetting = function(user){
rms.save('current_edit_member', user);
rms.save("course",vm.course);
@ -255,6 +254,13 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
$location.path("/edit_class_member").search({id: courseid,user_id: user.id});
};
vm.onSetting_1 = function(user){
rms.save('current_edit_member', user);
rms.save("course",vm.course);
rms.save("tab_num",vm.currentTab);
$location.path("/select_my_coursegroup").search({id: courseid});
};
vm.review = function(user){
rms.save('current_review_member', user);
rms.save('current_course', vm.course);

View File

@ -67,7 +67,11 @@ app.controller('JoinClassController', ['$scope', '$http', 'auth', 'config', 'ale
}
});
} else {
vm.alertService.showMessage('提示', response.data.message);
vm.alertService.showMessage('提示', response.data.message,function(){
if(response.data.go_coursegroup_flag == 1) {
$location.path("/join_classgroup").search({id: response.data.course_id});
}
});
}
});
};

View File

@ -5,14 +5,28 @@ app.controller('JoinClassGroupController', ['$scope', '$http', 'auth', 'config',
var course_id = $routeParams.id;
vm.alertService = alertService.create();
vm.selectid = 0;
$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("courses=");
console.log(response.data.data);
if(vm.current_course){
$http.get(config.apiUrl + 'courses/course_groups/'+course_id+'?token='+auth.token()).then(
function(response) {
console.log("groups=");
console.log(response);
if(response.data.status == 0) {
vm.groups = response.data.data;
}
else{
vm.groups = [];
}
});
}
}
else{
vm.alertService.showMessage('提示', response.data.message);
@ -23,17 +37,42 @@ app.controller('JoinClassGroupController', ['$scope', '$http', 'auth', 'config',
}
);
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 = [];
}
});
}
vm.selectGroup = function(id){
vm.selectid = id;
};
vm.cancel = function(){
};
vm.confirm = function(){
if(vm.selectid == 0){
rms.save('syllabuses',[]);
$location.path("/class_list");
return;
}
//加入分班
$http.post(config.apiUrl+'courses/join_coursegroup', {
token: auth.token(),
id: course_id,
course_group_id:vm.selectid
}).then(function(response){
console.log(response);
if(response.data.status == 0){
vm.alertService.showMessage('提示', "加入分班成功!",function(){
rms.save('syllabuses',[]);
$location.path("/class_list");
});
} else {
vm.alertService.showMessage('提示', response.data.message,function(){
rms.save('syllabuses',[]);
$location.path("/class_list");
});
}
});
};
}] );

View File

@ -0,0 +1,66 @@
app.controller('SelectMyCourseGroupController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){
// common.checkLogin();
var vm = $scope;
vm.current_review_member = rms.get('current_review_member');
vm.alertService = alertService.create();
vm.tip_1 = "";
vm.tip_2 = "";
var course_id = $routeParams.id;
if(!vm.current_course){
$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_edit_member){
$http.post(config.apiUrl+'courses/get_member_info', {
token: auth.token(),
id: course_id,
user_id:user_id
}).then(function(response){
if(response.data.status!=0){
vm.alertService.showMessage('提示', response.data.message,function(){
$location.path("/class").search({id: course_id,tag:1});
});
} else {
console.log(response);
course_id = response.data.course_id;
vm.current_edit_member = response.data.member_info;
vm.current_roles_id = vm.current_edit_member.roles_id;
for(var i in vm.current_roles_id){
if(vm.current_roles_id[i] == 10){
vm.student = true;
return;
}
}
if(!vm.student){
vm.tip_2 = "您不是该班级的学生!";
}
}
});
}
}] );

View File

@ -41,6 +41,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
.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('/select_my_coursegroup', makeRoute('select_my_coursegroup.html', 'SelectMyCourseGroupController'))
.when('/class_publishnotice', makeRoute('class_publishnotice.html', 'ClassPublishNoticeController'))
.when('/class_publishissue', makeRoute('class_publishissue.html', 'ClassPublishIssueController'))
.when('/project_list', makeRoute('project_list.html', 'ProjectListController'))