微信分班功能

This commit is contained in:
yuanke 2016-09-20 14:58:37 +08:00
parent 5b61396410
commit 8b771a183c
21 changed files with 566 additions and 38 deletions

View File

@ -541,6 +541,7 @@ module Mobile
present :course_id,params[:id]
present :user_id,params[:user_id]
present :member_info,my_member, with: Mobile::Entities::ProjectMember
present :course_group_id,my_member.course_group_id
present :status, 0
else
present :status, -1
@ -779,7 +780,7 @@ module Mobile
requires :token, type: String
requires :course_group_id, type: Integer
end
post 'join_coursegroup' do
post 'user_join_coursegroup' do
begin
authenticate!
member = Member.where(:course_id => params[:id], :user_id => current_user.id).first
@ -795,6 +796,127 @@ module Mobile
end
end
desc "修改分班"
params do
requires :id, type: Integer
requires :token, type: String
requires :course_group_id, type: Integer
requires :user_id, type: Integer
end
post 'user_edit_coursegroup' do
begin
authenticate!
member = Member.where(:course_id => params[:id], :user_id => params[: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
desc '获取分班列表带上学生'
params do
requires :id, type: Integer
requires :token, type:String
end
get 'course_groups_withstudent/:id' do
begin
authenticate!
course = Course.find(params[:id])
groups = []
groups = course.course_groups if course.course_groups
present :data,groups, with: Mobile::Entities::CourseGroup
present :status,0
rescue
present :status,-1
end
end
desc "删除分班"
params do
requires :id, type: Integer
requires :token, type: String
requires :course_group_id, type: Integer
end
post 'delete_coursegroup' do
begin
authenticate!
c = Course.find("#{params[:id]}")
my_member = c.member_principals.where("users.id=#{current_user.id}").first
roles_ids = []
my_member.roles.each do |role|
roles_ids << role.id
end
if my_member && (roles_ids.include?(3) || roles_ids.include?(7) || roles_ids.include?(9) )
else
raise "您没有该权限!"
end
CourseGroup.delete(params[:course_group_id])
present :status,0
rescue Exception=>e
present :message,e.message
present :status,-1
end
end
desc "编辑分班"
params do
requires :id, type: Integer
requires :token, type: String
end
post 'edit_coursegroup' do
begin
authenticate!
c = Course.find("#{params[:id]}")
my_member = c.member_principals.where("users.id=#{current_user.id}").first
roles_ids = []
my_member.roles.each do |role|
roles_ids << role.id
end
if my_member && (roles_ids.include?(3) || roles_ids.include?(7) || roles_ids.include?(9) )
else
raise "您没有该权限!"
end
#增加分班和修改分班名
modify_groups = params[:modify_groups]
modify_groups.each do |g|
group = CourseGroup.find(g.id)
group.name = g.id.to_s + Time.now.to_i.to_s #只能先另取个名了不然原有的两个互换的话修改不了
group.save
end
modify_groups.each do |g|
group = CourseGroup.find(g.id)
group.name = g.name
group.save
end
#增加分班和修改分班名
add_groups = params[:add_groups]
add_groups.each do |name|
group = CourseGroup.new
group.name = name
group.course_id = params[:id]
group.save
end
present :status,0
rescue Exception=>e
present :message,e.message
present :status,-1
end
end
end
end
end

View File

@ -54,6 +54,7 @@ module Mobile
course_expose :updated_at
course_expose :course_student_num
course_expose :member_count
course_expose :groupnum
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
can_setting = false

View File

@ -0,0 +1,19 @@
module Mobile
module Entities
class CourseGroup < Grape::Entity
include Redmine::I18n
include ApplicationHelper
include ApiHelper
def self.course_group_expose(f)
expose f do |u,opt|
if u.is_a?(Hash) && u.key?(f)
u[f]
end
end
end
expose :id
expose :name
expose :users, using: Mobile::Entities::User
end
end
end

View File

@ -332,7 +332,9 @@ class CoursesService
# unless (course.is_public == 1 || current_user.member_of_course?(course) || current_user.admin?)
# raise '403'
# end
{:course => course,:syllabus_title => course.syllabus.nil? ? "":course.syllabus.title ,:work_unit => work_unit, :img_url => url_to_avatar(course),:current_user_is_member => current_user.nil? ? false : current_user.member_of_course?(course),:current_user_is_teacher => current_user.nil? ? false : is_course_teacher(current_user,course),:course_student_num => course ? course.student.count.to_s : 0}
groupnum = 0
groupnum = course.course_groups.length if course.course_groups
{:course => course,:syllabus_title => course.syllabus.nil? ? "":course.syllabus.title ,:work_unit => work_unit, :img_url => url_to_avatar(course),:current_user_is_member => current_user.nil? ? false : current_user.member_of_course?(course),:current_user_is_teacher => current_user.nil? ? false : is_course_teacher(current_user,course),:course_student_num => course ? course.student.count.to_s : 0,:groupnum => groupnum}
end
#创建课程

View File

@ -43,7 +43,7 @@
第<%= work.student_work_tests.count - index%>次测试
</p>
<span class="fr c_grey">
<%= test.created_at.to_s(:db) %>
<%= format_time(test.created_at).to_s %>
</span>
<div class="cl"></div>
</div>

View File

@ -256,13 +256,15 @@
<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)" />
<img src="/images/wechat/setting.png" ng-show = "!isTeacher && student.is_me==1" width="15" class="class-list-setting" ng-click="onSetting_1(student)" />
<div class="cl"></div>
</div>
<div ng-show="course.is_member" class="bottom-tab-wrap mt10" ng-class="{'undis': !showClassMate}">
<a ng-show="!course.is_creator" ng-click="quit()" class="weixin-tab link-blue2 border-top">退出班级</a>
<a ng-show="isTeacher" ng-click="goEditGroup()" class="weixin-tab link-blue2 border-top">分班管理</a>
</div>
</div>
<div ng-class="{'undis': !showHomework}">

View File

@ -0,0 +1,20 @@
<div class="post-container">
<div loading-spinner></div>
<div class="class-detail-name"><span class="course-name-width hidden inline-block">分班管理</span></div>
<div ng-repeat="group in groups">
<div class="member-banner f13 c-grey3">{{group.name+"("+group.users.length+")"}}</div>
<div class="class-member-row f13 c-grey3" ng-repeat="user in group.users">
<img ng-src="{{user.img_url}}" width="30" height="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{user.realname == "" ? user.name : user.realname}}</span><img ng-src="/images/wechat/{{user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
<div class="cl"></div>
</div>
</div>
<div ng-show="course.is_member" class="bottom-tab-wrap mt10">
<a ng-show="course.current_user_is_teacher" ng-click="goEditGroup()" class="weixin-tab link-blue2 border-top">编辑</a>
</div>
<div ng-show="tip_1" class="blue-title">{{tip_1}}</div>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
</div>

View File

@ -0,0 +1,14 @@
<div class="post-container">
<div loading-spinner></div>
<div class="blue-title">分班管理</div>
<div class="class-detail-row f13 c-grey3"><img src="images/logo.png" ng-src="course.img_url" class="fl ml10 img-circle mt4" width="30"><span class="fl mt10 ml10 ng-binding">{{course.name}}</span><div class="cl"></div> </div>
<form novalidate name="groupForm">
<div class="course-list-row f13 c-grey3 mt10" ng-repeat="group in groups" ><span class="fl ml15 c-grey3">分班名称</span><input ng-change="group.change = true" required ng-class="['new-class-input ml25', {'c-grey':group.change} ]" ng-model="group.tmpname" placeholder="如16级1班" /><a ng-click="deleteGroup($index)" class="fr mr10 c-grey6 delete-class-link">删除</a></div>
<div class="tac"><a ng-click="addGroup()" class="link-blue2 f13 mt15 inline-block add-class-link">+新增分班</a></div>
<a ng-click="newGroup(groupForm, groups)" ng-class="['finish-btn', {'btn-disabled':!groupForm.$valid} ]" >完成</a>
</form>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
<my-alert2 message="alertService_2.message" title="alertService_2.title" visible="alertService_2.visible" cb="alertService_2.cb"></my-alert2>
</div>

View File

@ -4,15 +4,25 @@
<div class="blue-title">成员管理</div>
<div class="class-detail-row f13 c-grey3"><img ng-src="{{current_edit_member.user.img_url}}" width="30" class="fl ml10 img-circle mt4" /><span class="fl mt10 ml10">{{current_edit_member.user.realname == "" ? current_edit_member.user.name : current_edit_member.user.realname}}</span><img ng-src="/images/wechat/{{current_edit_member.user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt10" /><div class="cl"></div> </div>
<div class="course-list-row f13 c-grey3 mt10" ng-click="clickChangeRole()"><span class="fl ml10">角色变更</span></div>
<ul class="class-list f13 c-grey3" ng-class="{'undis':current_edit_member.show}">
<ul class="class-list f13 c-grey3" ng-class="{'undis':!show_1}">
<li><span class="fl ml10 class-list-name hidden">教师</span><span ng-click="selectRole(9)" 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="selectRole(7)" 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">学生</span><span ng-click="selectRole(10)" ng-class="['login-box', 'fr', 'mr10', 'mt12', {'checked': student}]"></span></li>
</ul>
<div class="course-list-row f13 c-grey3 mt10" ng-click="current_edit_member.show = !current_edit_member.show;buttongrey = false;" id="manageDelete"><span class="fl ml10">删除成员</span></div>
<ul class="class-list f13 c-grey3" ng-class="{'undis':!current_edit_member.show}">
<div class="course-list-row f13 c-grey3 mt10" ng-click="clickDeleteMember()" id="manageDelete"><span class="fl ml10">删除成员</span></div>
<ul class="class-list f13 c-grey3" ng-class="{'undis':!show_2}">
<li class="border-bottom-none"><span class="fl ml10 class-list-name hidden">删除</span><input type="radio" name="delete" class="fr mr10 mt12" checked="checked" /></li>
</ul>
<div class="course-list-row f13 c-grey3 mt10" ng-click="clickSelectGroup()" id="manageDelete"><span class="fl ml10">编辑分班</span></div>
<ul class="class-list f13 c-grey3" ng-class="{'undis':!show_3}">
<li><span class="fl ml10 class-list-name hidden">暂无</span><span ng-click="selectGroup(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">{{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>
<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="edit_member_role()" class="weixin-tab border-top" ng-class="[{'bg-grey c-white':buttongrey},{'link-blue2':!buttongrey}]" >确定</a>

View File

@ -30,6 +30,7 @@
<input class="new-class-input ml25" type="email" name="email" ng-model="mail" placeholder="请输入您的邮箱地址" maxlength="60" />
<div ng-show="regFrm.$submitted || regFrm.email.$touched">
<span class="f12 c-red fl ml15" ng-show="regFrm.email.$error.required">电子邮箱地址不能为空</span>
<span class="f12 c-red fl ml15" ng-show="regFrm.email.$error.email">电子邮箱地址不合法</span>
</div>
</div>

View File

@ -25,7 +25,5 @@
</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>
</div>

View File

@ -1,11 +1,11 @@
<div class="post-container">
<div loading-spinner></div>
<div class="post-container" style="padding-bottom:50px;">
<div ng-show="current_course" 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">选择分班{{selectid}}</span></div>
<ul class="class-list f13 c-grey3">
<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>
<li><span class="fl ml10 class-list-name hidden">暂无</span><span ng-click="selectGroup(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">{{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>
@ -23,10 +23,12 @@
</div>
<div class="bottom-tab-wrap mt10">
<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>
<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>
<div ng-show="tip_1" class="blue-title">{{tip_1}}</div>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
</div>

View File

@ -2,24 +2,27 @@
<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="class-detail-row f13 c-grey3"><img 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.realname == "" ? current_edit_member.user.name : current_edit_member.user.realname}}</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>
<li><span class="fl ml10 class-list-name hidden">暂无</span><span ng-click="selectGroup(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">{{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>
<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 href="javascript:void(0);" ng-click="confirm()" 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>
<div ng-show="tip_1" class="blue-title">{{tip_1}}</div>
<div ng-show="tip_2" 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

@ -258,7 +258,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
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});
$location.path("/select_my_coursegroup").search({id: courseid,user_id: user.id});
};
vm.review = function(user){
@ -367,5 +367,24 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
};
vm.goEditGroup = function(){
if(!vm.isTeacher){
return;
}
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("tab_num",vm.currentTab);
rms.save("course",vm.course);
rms.save('current_course', vm.course);
if(vm.course.groupnum == 0){
$location.path("/edit_class_group").search({id: courseid});
}
else{
$location.path("/class_group").search({id: courseid});
}
}
}]);

View File

@ -0,0 +1,48 @@
app.controller('ClassGroupController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms','common','$timeout', function($scope, config, $http, auth, $location, $routeParams,alertService,rms,common,$timeout){
// common.checkLogin();
$scope.replaceUrl = function(url){
return url;
};
var vm = $scope;
var courseid = $routeParams.id;
vm.alertService = alertService.create();
if(!vm.course){
$http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then(
function(response) {
console.log(response.data);
if (response.data.status == 0){
vm.course = response.data.data;
console.log("courses");
console.log(response.data.data);
}
else{
vm.alertService.showMessage('提示', response.data.message);
}
if(!vm.course){
vm.tip_1 = "该班级不存在或已被删除";
}
}
);
}
$http.get(config.apiUrl + 'courses/course_groups_withstudent/'+courseid+'?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 = [];
}
});
vm.goEditGroup = function(){
$location.path("/edit_class_group").search({id: courseid});
}
}]);

View File

@ -63,7 +63,7 @@ app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'ale
vm.syllabus.courses.splice(index, 1);
}
}
};
vm.newClass = function (frm, syllabus) {
frm.$setSubmitted();

View File

@ -0,0 +1,136 @@
app.controller('EditClassGroupController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){
var vm = $scope;
var courseid = $routeParams.id;
vm.alertService = alertService.create();
vm.alertService_2 = alertService.create();
if(!vm.course){
$http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then(
function(response) {
console.log(response.data);
if (response.data.status == 0){
vm.course = response.data.data;
console.log("courses");
console.log(response.data.data);
}
else{
vm.alertService.showMessage('提示', response.data.message);
}
if(!vm.course){
vm.tip_1 = "该班级不存在或已被删除";
}
}
);
}
$http.get(config.apiUrl + 'courses/course_groups/'+courseid+'?token='+auth.token()).then(
function(response) {
console.log("groups=");
console.log(response);
if(response.data.status == 0) {
vm.groups = response.data.data;
for(var i in vm.groups){
vm.groups[i].tmpname = vm.groups[i].course_group.name;
}
}
else{
vm.groups = [];
}
});
vm.addGroup = function(){
vm.groups.push({tmpname:""});
};
vm.deleteGroup = function(index){
var group = vm.groups[index];
if(group.course_group){
vm.alertService_2.showMessage('提示', '您确定要删除该分班吗?', function() {
$http.post(config.apiUrl+'courses/delete_coursegroup', {
token: auth.token(),
id: courseid,
course_group_id:group.course_group.id
}).then(function(response){
console.log(response);
if(response.data.status == 0){
vm.alertService.showMessage('提示', "删除成功!",function(){
vm.groups.splice(index, 1);
});
} else {
vm.alertService.showMessage('提示', response.data.message);
}
});
});
} else {
vm.groups.splice(index, 1);
}
};
vm.newGroup = function (frm, groups) {
frm.$setSubmitted();
console.log(groups);
if(!frm.$valid){
console.log(frm.$error);
return;
}
if(vm.groups.length == 0){
$location.path("/class").search({id: courseid,tag:1});
return;
}
//不能有相同名称的分班
for(var i=0;i< vm.groups.length-1;i++) {
for (var j=i+1;j<vm.groups.length;j++){
if(vm.groups[i].tmpname == vm.groups[j].tmpname){
vm.alertService.showMessage('提示', "分班名称不能重复!");
return;
}
}
};
var add_groups = [];
var modify_groups = [];
for(var i in vm.groups){
var group = vm.groups[i];
if(!group.course_group){
add_groups.push(group.tmpname);
}
else if(group.tmpname != group.course_group.name){
modify_groups.push({id:group.course_group.id,name:group.tmpname});
}
}
if(add_groups.length == 0 && modify_groups.length == 0){
vm.alertService.showMessage('提示', "保存分班成功!",function(){
$location.path("/class").search({id: courseid,tag:1});
return;
});
}
//编辑分班
$http.post(config.apiUrl+'courses/edit_coursegroup', {
token: auth.token(),
id: courseid,
add_groups: add_groups,
modify_groups: modify_groups
}).then(function(response){
console.log(response);
if(response.data.status == 0){
vm.alertService.showMessage('提示', "保存分班成功!",function(){
$location.path("/class").search({id: courseid,tag:1});
});
} else {
vm.alertService.showMessage('提示', response.data.message,function(){
$location.path("/class").search({id: courseid,tag:1});
});
}
});
}
}] );

View File

@ -24,6 +24,11 @@ app.controller('EditClassMemberController', ['$scope', '$http', 'auth', 'config'
vm.tmpstudent = false; //学生
vm.buttongrey = true;
vm.selectid = 0;
vm.show_1 = true;
vm.show_2 = false;
vm.show_3 = false;
if(!vm.current_edit_member){
@ -42,6 +47,8 @@ app.controller('EditClassMemberController', ['$scope', '$http', 'auth', 'config'
user_id = response.data.user_id;
vm.current_edit_member = response.data.member_info;
vm.current_roles_id = vm.current_edit_member.roles_id;
vm.selectid = response.data.course_group_id;
vm.course_group_id = vm.selectid;
for(var i in vm.current_roles_id){
if(vm.current_roles_id[i] == 9){
@ -57,6 +64,18 @@ app.controller('EditClassMemberController', ['$scope', '$http', 'auth', 'config'
vm.tmpstudent = true;
}
}
$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 = [];
}
});
}
});
}
@ -96,10 +115,29 @@ app.controller('EditClassMemberController', ['$scope', '$http', 'auth', 'config'
return;
}
if(vm.current_edit_member.show){
if(vm.show_2){
//删除成员
vm.deleteMember(vm.current_edit_member.user.id);
}
else if(vm.show_3){
//加入分班
$http.post(config.apiUrl+'courses/user_edit_coursegroup', {
token: auth.token(),
id: course_id,
course_group_id:vm.selectid,
user_id:vm.current_edit_member.user.id
}).then(function(response){
console.log(response);
if(response.data.status == 0){
vm.alertService.showMessage('提示', "修改分班成功!",function(){
$location.path("/class").search({id: course_id,tag:1});
});
} else {
vm.alertService.showMessage('提示', response.data.message);
}
});
}
else{
if((vm.teacher == vm.tmpteacher)&& (vm.assistant == vm.tmpassistant)&&(vm.student == vm.tmpstudent)){
vm.alertService.showMessage('提示', "该用户当前已是该角色");
@ -159,14 +197,53 @@ app.controller('EditClassMemberController', ['$scope', '$http', 'auth', 'config'
};
vm.clickChangeRole = function(){
vm.current_edit_member.show = !vm.current_edit_member.show;
if((vm.teacher == vm.tmpteacher)&& (vm.assistant == vm.tmpassistant)&&(vm.student == vm.tmpstudent)){
vm.buttongrey = true;
}
else{
vm.clickDeleteMember = function(){
vm.show_2 = !vm.show_2;
if(vm.show_2){
vm.show_1 = false;
vm.show_3 = false;
vm.buttongrey = false;
}
};
vm.clickChangeRole = function(){
vm.show_1 = !vm.show_1;
if(vm.show_1){
vm.show_2 = false;
vm.show_3 = false;
if((vm.teacher == vm.tmpteacher)&& (vm.assistant == vm.tmpassistant)&&(vm.student == vm.tmpstudent)){
vm.buttongrey = true;
}
else{
vm.buttongrey = false;
}
}
};
vm.clickSelectGroup = function(){
vm.show_3 = !vm.show_3;
if(vm.show_3){
vm.show_1 = false;
vm.show_2 = false;
if(vm.selectid != vm.course_group_id){
vm.buttongrey = false;
}
else{
vm.buttongrey = true;
}
}
};
vm.selectGroup = function(id){
vm.selectid = id;
if(vm.course_group_id != vm.selectid){
vm.buttongrey = false;
}
else{
vm.buttongrey = true;
}
};
}] );

View File

@ -5,7 +5,7 @@ app.controller('JoinClassGroupController', ['$scope', '$http', 'auth', 'config',
var course_id = $routeParams.id;
vm.alertService = alertService.create();
vm.selectid = 0;
vm.selectid = null;
$http.get(config.apiUrl+ 'courses/'+course_id+"?token="+auth.token()).then(
function(response) {
@ -43,32 +43,33 @@ app.controller('JoinClassGroupController', ['$scope', '$http', 'auth', 'config',
vm.cancel = function(){
$location.path("/class").search({id: course_id,tag:1});
};
vm.confirm = function(){
if(vm.selectid == null){
vm.alertService.showMessage('提示', "请选择分班!");
return;
}
if(vm.selectid == 0){
rms.save('syllabuses',[]);
$location.path("/class_list");
return;
}
//加入分班
$http.post(config.apiUrl+'courses/join_coursegroup', {
$http.post(config.apiUrl+'courses/user_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',[]);
vm.alertService.showMessage('提示', "选择分班成功!",function(){
$location.path("/class_list");
});
} else {
vm.alertService.showMessage('提示', response.data.message,function(){
rms.save('syllabuses',[]);
$location.path("/class_list");
});
}

View File

@ -13,6 +13,8 @@ app.controller('SelectMyCourseGroupController', ['$scope', '$http', 'auth', 'con
vm.tip_2 = "";
var course_id = $routeParams.id;
var user_id = $routeParams.user_id;
vm.selectid = null;
if(!vm.current_course){
$http.get(config.apiUrl+ 'courses/'+course_id+"?token="+auth.token()).then(
function(response) {
@ -48,19 +50,68 @@ app.controller('SelectMyCourseGroupController', ['$scope', '$http', 'auth', 'con
course_id = response.data.course_id;
vm.current_edit_member = response.data.member_info;
vm.current_roles_id = vm.current_edit_member.roles_id;
vm.selectid = response.data.course_group_id;
vm.course_group_id = vm.selectid;
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 = "您不是该班级的学生!";
}
else{
$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 = [];
}
});
}
}
});
}
vm.cancel = function(){
window.history.back();
};
vm.confirm = function(){
if(vm.course_group_id == vm.selectid){
$location.path("/class").search({id: course_id,tag:1});
return;
}
//加入分班
$http.post(config.apiUrl+'courses/user_edit_coursegroup', {
token: auth.token(),
id: course_id,
course_group_id:vm.selectid,
user_id:user_id
}).then(function(response){
console.log(response);
if(response.data.status == 0){
vm.alertService.showMessage('提示', "修改分班成功!",function(){
$location.path("/class").search({id: course_id,tag:1});
});
} else {
vm.alertService.showMessage('提示', response.data.message,function(){
$location.path("/class").search({id: course_id,tag:1});
});
}
});
};
vm.selectGroup = function(id){
vm.selectid = id;
};
}] );

View File

@ -33,6 +33,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
.when('/class', makeRoute('class.html', 'ClassController'))
.when('/new_class', makeRoute('new_class.html', 'NewClassController'))
.when('/edit_class', makeRoute('edit_class.html', 'EditClassController'))
.when('/edit_class_group', makeRoute('edit_class_group.html', 'EditClassGroupController'))
.when('/class_list', makeRoute('class_list.html', 'ClassListController'))
.when('/edit_class_member', makeRoute('edit_class_member.html', 'EditClassMemberController'))
.when('/myresource', makeRoute('myresource.html', 'MyResourceController'))
@ -44,6 +45,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
.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('/class_group', makeRoute('class_group.html', 'ClassGroupController'))
.when('/project_list', makeRoute('project_list.html', 'ProjectListController'))
.when('/project', makeRoute('project.html', 'ProjectController'))
.when('/edit_project_member', makeRoute('edit_project_member.html', 'EditProjectMemberController'))