微信项目和班级加入修改

This commit is contained in:
yuanke 2016-08-02 15:50:15 +08:00
parent dde89b72fa
commit 614e877e6e
21 changed files with 779 additions and 95 deletions

View File

@ -100,16 +100,35 @@ module Mobile
params do
requires :token, type: String
requires :invite_code, type: String, desc: '邀请码'
requires :teacher_flag, type: Boolean
requires :assistant_flag, type: Boolean
requires :student_flag, type: Boolean
end
post "join" do
post "join_class" do
authenticate!
roles_ids = []
if params[:teacher_flag]
roles_ids << "9"
elsif params[:assistant_flag]
roles_ids << "7"
end
if params[:student_flag]
roles_ids << "10"
end
if roles_ids.length <= 0
{status:-1,message:"请至少选择一个角色"}
else
cs = CoursesService.new
status = cs.join_course({role: "10", 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)
{
status: status[:state],
message:CoursesService::JoinCourseError.message(status[:state])
}
end
end
desc "退出课程"
@ -166,7 +185,52 @@ module Mobile
present :status, 0
end
desc "设置教辅"
desc "课程未审核列表"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
end
get 'reviewers' do
authenticate!
cs = CoursesService.new
reviewers = cs.reviewers_list(params[:course_id])
present :data, reviewers, with: Mobile::Entities::User
present :status, 0
end
desc "课程单个未审核用户信息"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
requires :user_id, type: Integer, desc: "用户id"
end
post 'review_member_info' do
authenticate!
cs = CoursesService.new
reviewer = cs.get_reviewer_info(params)
present :data, reviewer, with: Mobile::Entities::User
present :status, 0
end
desc "处理教师或助教的身份申请"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
requires :user_id, type: Integer, desc: "用户id"
requires :type, type: Integer, desc: "同意或拒绝"
end
post 'deal_join_apply' do
authenticate!
cs = CoursesService.new
result = cs.deal_join_apply(params,current_user)
present :status, result[:status]
present :message, result[:message]
end
desc "设置助教"
params do
requires :token,type:String
requires :user_id,type:Integer,desc: '用户id'
@ -178,7 +242,7 @@ module Mobile
present :status, 0
end
desc "删除"
desc "删除"
params do
requires :token,type:String
requires :user_id,type:Integer,desc: '用户id'
@ -448,20 +512,35 @@ module Mobile
requires :id, type: Integer
requires :token, type: String
requires :user_id, type: Integer
requires :role_id, type: Integer
requires :teacher_flag, type: Boolean
requires :assistant_flag, type: Boolean
requires :student_flag, type: Boolean
end
post 'edit_member_role' do
authenticate!
roles_id = []
if params[:teacher_flag]
roles_id << 9
elsif params[:assistant_flag]
roles_id << 7
end
if params[:student_flag]
roles_id << 10
end
c = Course.find("#{params[:id]}")
#7教辅 9教师 10学生
if c.tea_id == params[:user_id] || c.tea_id != current_user.id || !(params[:role_id] == 7 || params[:role_id] == 9 || params[:role_id] == 10)
if c.tea_id == params[:user_id] || c.tea_id != current_user.id || roles_id.length <= 0
present :status, -1
else
cs = CoursesService.new
status = cs.modify_user_course_role params
status = cs.modify_user_course_role params,roles_id
present :status, status
end
end

View File

@ -163,14 +163,21 @@ module Mobile
params do
requires :token, type: String
requires :invite_code, type: String, desc: '邀请码'
requires :role_id, type: Integer, desc: '身份'
end
post "join" do
post "join_project" do
authenticate!
role_id = params[:role_id]
if role_id != 3 && role_id != 4 && role_id != 5
{status:-1,message:"请至少选择一个角色"}
else
ps = ProjectsService.new
status = ps.join_project({role: "5", openid: params[:openid], invite_code: params[:invite_code]}, current_user)
status = ps.join_project({role: role_id, openid: params[:openid], invite_code: params[:invite_code]}, current_user)
{status:status, message:ProjectsService::JoinProjectError.message(status)}
end
# {status:-1, message: '该功能将在近日开放,敬请期待!' }
end

View File

@ -14,11 +14,11 @@ module Mobile
else
case f
when :roles_id
u.roles[0].id
# u.roles[0].id
u.roles.map {|r| r.id}
end
end
end
end
end

View File

@ -111,6 +111,129 @@ class CoursesService
users
end
def reviewers_list course_id
reviewers = []
c = Course.find(course_id)
if c
messages = CourseMessage.where("course_id=? and course_message_type = 'JoinCourseRequest' and status = 0 ",course_id)
messages.each do |m|
user = User.find(m.course_message_id)
if user
img_url = url_to_avatar(user)
gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender
work_unit = get_user_work_unit user
location = get_user_location user
roles_ids = m.content.split(",")
reviewers << {:id => user.id, :img_url => img_url, :nickname => user.login, :gender => gender,
:work_unit => work_unit, :mail => user.mail, :location => location,
role_name: "",
name: user.show_name,
roles_id: roles_ids.include?("7") ? 7 : 9,
:brief_introduction => user.user_extensions.brief_introduction,:realname=>user.realname}
end
end
end
reviewers
end
def get_reviewer_info params
info = nil
c = Course.find(params[:course_id])
if c
messages = CourseMessage.where("course_id=? and course_message_id = ? and course_message_type = 'JoinCourseRequest' and status = 0 ",params[:course_id],params[:user_id]).first
if messages
user = User.find(params[:user_id])
if user
img_url = url_to_avatar(user)
gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender
work_unit = get_user_work_unit user
location = get_user_location user
roles_ids = messages.content.split(",")
info = {:id => user.id, :img_url => img_url, :nickname => user.login, :gender => gender,
:work_unit => work_unit, :mail => user.mail, :location => location,
role_name: "",
name: user.show_name,
roles_id: roles_ids.include?("7") ? 7 : 9,
:brief_introduction => user.user_extensions.brief_introduction,:realname=>user.realname}
end
end
end
info
end
def deal_join_apply params,current_user
status = -1
message = ""
c = Course.find(params[:course_id])
if c
messages = CourseMessage.where("course_id=? and course_message_id = ? and course_message_type = 'JoinCourseRequest' and status = 0 ",params[:course_id],params[:user_id]).first
if messages
apply_user = User.find(params[:user_id])
ids = messages.content.split(",") # content保存的是申请的职位角色
integer_ids = []
ids.each do |role_id|
integer_ids << role_id.to_i
end
if params[:type] == 0
if apply_user.member_of_course?(c)
#将角色改为老师或者教辅
member = c.members.where(:user_id=>apply_user.id).all[0]
member.role_ids = integer_ids
#删除为学生的记录
unless member.role_ids.include?(10)
joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,c.id)
joined.each do |join|
join.delete
end
end
member.course_group_id = 0
member.save
CourseMessage.create(:user_id => apply_user.id, :course_id => c.id, :viewed => false,:content=> messages.content,:course_message_id=>current_user.id,:course_message_type=>'CourseRequestDealResult',:status=>1)
messages.update_attributes(:status=>1,:viewed=>1)
else
members = []
members << Member.new(:role_ids => integer_ids, :user_id => apply_user.id)
c.members << members
CourseMessage.create(:user_id => apply_user.id, :course_id => c.id, :viewed => false,:content=> messages.content,:course_message_id=>current_user.id,:course_message_type=>'CourseRequestDealResult',:status=>1)
messages.update_attributes(:status=>1,:viewed=>1)
end
if integer_ids.include?(9)
message = "您已同意教师"+apply_user.show_name+",加入班级"
else
message = "您已同意助教"+apply_user.show_name+",加入班级"
end
else
CourseMessage.create(:user_id => apply_user.id, :course_id => c.id, :viewed => false,:content=> messages.content,:course_message_id=>current_user.id,:course_message_type=>'CourseRequestDealResult',:status=>2)
message.update_attributes(:status=>2,:viewed=>1)
if integer_ids.include?(9)
message = "您已拒绝教师"+apply_user.show_name+",加入班级"
else
message = "您已拒绝助教"+apply_user.show_name+",加入班级"
end
end
status = 0
else
message = "该申请不存在或已被处理"
end
else
message = "该班级不存在或已被删除"
end
{:status => status,:message => message}
end
#获取用户的工作单位
def get_user_work_unit user
work_unit = ""
@ -329,15 +452,17 @@ class CoursesService
0, '加入成功',
1, '密码错误',
2, '班级已过期 请联系班级管理员重启班级。',
3, '您已经加入了班级',
3, '您已经是该班级的成员了',
4, '您的邀请码不正确',
5, '您还未登录',
6, '申请成功,请等待审核完毕',
6, '您的申请已提交,请等待管理员审批',
7, '您已经发送过申请了,请耐心等待',
8, '您已经是该班级的教师了',
9, '您已经是该班级的教辅了',
10, '您已经是该班级的管理员了',
11, '该班级不存在或已被删除啦',
12, '您已经发送过申请了,请耐心等待',
13, '您的申请已提交,请等待管理员审批',
'未知错误,请稍后再试'
]
end
@ -460,15 +585,31 @@ class CoursesService
is_stu = true
end
#如果已经发送过消息了,那么就要给个提示
if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = '#{role_str}' and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0
if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = '#{role_str}' and course_message_id = #{current_user.id} and course_id = #{course.id} and status = 0").count != 0
if is_stu
@state = 12
else
@state = 7
end
else
Mailer.run.join_course_request(course, User.current, params[:role])
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> role_str,:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
Mailer.run.join_course_request(course, current_user, params[:role])
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> role_str,:course_message_id=>current_user.id,:course_message_type=>'JoinCourseRequest',:status=>0)
#----------------微信通知----------------------
if role_ids.include?("7") || role_ids.include?("9")
tea_user = User.find(course.tea_id)
count = ShieldWechatMessage.where("container_type='User' and container_id=#{tea_user.id} and shield_type='Course' and shield_id=#{course.id}").count
if count == 0
rolename = role_ids.include?("7") ? "助教" : "教师"
content = current_user.show_name + "申请以"+rolename+"身份加入班级,等待您的审批。"
ws = WechatService.new
ws.class_notice tea_user.id, "course_join_review", course.id, "班级成员审批通知", course.name, tea_user.show_name, format_time(Time.now), content, "点击查看申请详情"
end
end
#--------------------------------------------
if is_stu
@state = 13
else
@ -1054,20 +1195,21 @@ class CoursesService
# end
#修改班级成员角色
def modify_user_course_role params
def modify_user_course_role params,roles_id
status = -1
c = Course.find("#{params[:id]}")
member = c.member_principals.includes(:roles, :principal).where("user_id=?",params[:user_id]).first
# member = c.member_principals.includes(:roles, :principal).where("user_id=?",params[:user_id]).first
member = c.members.where("user_id=?",params[:user_id]).first
if member
role = Role.find(params[:role_id])
member.role_ids = roles_id
member.member_roles[0].role_id = params[:role_id]
role = Role.find(roles_id[0])
# 这里的判断只能通过角色名,可以弄成常量
if params[:role_id] == 10
if roles_id && roles_id.include?(10)
StudentsForCourse.create(:student_id => params[:user_id], :course_id =>params[:id])
else
joined = StudentsForCourse.where('student_id = ? and course_id = ?', params[:user_id],params[:id])
@ -1090,7 +1232,7 @@ class CoursesService
Role.givable.all[3..5]
if member.member_roles[0].save
if member.save
status = 0
end
end

View File

@ -125,6 +125,8 @@ class ProjectsService
status = member.member_roles[0].role_id
else
if params[:invite_code].present?
if params[:role_id] == 5
members = []
user_grades = []
project_info = []
@ -140,6 +142,9 @@ class ProjectsService
status = 0
else
end
else
status = 4
end
end

View File

@ -34,9 +34,17 @@
<img ng-src="/images/wechat/{{teacher.gender==0 ? 'male' : 'female'}}.jpg" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{teacher.name}}</span><img ng-src="/images/wechat/{{teacher.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
<img src="/images/wechat/setting.png" ng-show = "course.is_creator && teacher.id != course.tea_id" width="15" class="fr mr10" style="margin-top:7px;" ng-click="onSetting(teacher)" />
<span class = "fr mr25 mt5" ng-show ="teacher.id == course.tea_id">管理员</span>
<span ng-class="['fr','mt5',{'mr10': course.is_creator,'mr25': !course.is_creator}]" ng-show ="teacher.id != course.tea_id && teacher.roles_id == 7"></span>
<span ng-class="['fr','mt5',{'mr10': course.is_creator,'mr25': !course.is_creator}]" ng-show ="teacher.id != course.tea_id && teacher.roles_id == 7"></span>
<div class="cl"></div>
</div>
<div ng-show ="course.is_creator" class="class-member-row f13 c-grey3" ng-repeat="reviewer in reviewers|filter:searchText">
<img ng-src="/images/wechat/{{reviewer.gender==0 ? 'male' : 'female'}}.jpg" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{reviewer.name}}</span><img ng-src="/images/wechat/{{reviewer.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
<span ng-click="review(reviewer)" class = "fr mr25 mt5">待审批</span>
<div class="cl"></div>
</div>
<div class="member-banner f13 mt10 c-grey3">我的同学</div>
<div class="class-member-row f13 c-grey3" ng-repeat="student in students|filter:searchText">
<img ng-src="/images/wechat/{{student.gender==0 ? 'male' : 'female'}}.jpg" width="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" />

View File

@ -5,9 +5,9 @@
<div class="class-detail-row f13 c-grey3"><img ng-src="/images/wechat/{{current_edit_member.user.gender==0 ? 'male' : 'female'}}.jpg" 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"><span class="fl ml10">角色</span></div>
<ul class="class-list f13 c-grey3">
<li><span class="fl ml10 class-list-name hidden">教师</span><span ng-click="selectRole(9)" ng-class="['login-box', 'fr', 'mr10', 'mt12','img-circle', {'checked': current_edit_member.roles_id == 9}]"></span></li>
<li><span class="fl ml10 class-list-name hidden"></span><span ng-click="selectRole(7)" ng-class="['login-box', 'fr', 'mr10', 'mt12','img-circle', {'checked': current_edit_member.roles_id == 7}]"></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','img-circle', {'checked': current_edit_member.roles_id == 10}]"></span></li>
<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="bottom-tab-wrap mt10">
<a href="javascript:void(0);" ng-click="cancel()" class="weixin-tab c-grey border-top">取消</a>
@ -15,7 +15,5 @@
</div>
</div>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
</div>

View File

@ -0,0 +1,19 @@
<div class="post-container">
<div loading-spinner></div>
<div class="post-container" style="padding-bottom:50px;">
<div class="blue-title">欢迎加入班级</div>
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">班级邀请码</span><input class="new-class-input ml25" ng-model="invite_code" required placeholder="请输入5位邀请码" /></div>
<div class="course-list-row f13 c-grey3 mt10"><span class="fl ml10">角色</span></div>
<ul class="class-list f13 c-grey3">
<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="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

@ -0,0 +1,20 @@
<div class="post-container">
<div loading-spinner></div>
<div class="post-container" style="padding-bottom:50px;">
<div class="blue-title">欢迎加入项目</div>
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">项目邀请码</span><input class="new-class-input ml25" ng-model="syllabus.title" required placeholder="请输入6位邀请码" /></div>
<div class="course-list-row f13 c-grey3 mt10"><span class="fl ml10">角色</span></div>
<ul class="class-list f13 c-grey3">
<li><span class="fl ml10 class-list-name hidden">管理人员</span><span ng-click="selectRole(3)" ng-class="['login-box', 'fr', 'mr10', 'mt12','img-circle', {'checked': role_id == 3}]"></span></li>
<li><span class="fl ml10 class-list-name hidden">开发人员</span><span ng-click="selectRole(4)" ng-class="['login-box', 'fr', 'mr10', 'mt12','img-circle', {'checked': role_id == 4}]"></span></li>
<li class="border-bottom-none"><span class="fl ml10 class-list-name hidden">报告人员</span><span ng-click="selectRole(5)" ng-class="['login-box', 'fr', 'mr10', 'mt12','img-circle', {'checked': role_id == 5}]"></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="join_project()" 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

@ -0,0 +1,18 @@
<div class="post-container">
<div loading-spinner></div>
<div ng-show="current_course && current_review_member " class="post-container" style="padding-bottom:50px;">
<div class="blue-title">{{current_course.name}}</div>
<div class="class-detail-row f13 c-grey3"><img ng-src="/images/wechat/{{current_review_member.gender==0 ? 'male' : 'female'}}.jpg" width="30" class="fl ml10 img-circle mt4" /><span class="fl mt10 ml10">{{current_review_member.realname == "" ? current_review_member.name : current_review_member.realname}}</span><img ng-src="/images/wechat/{{current_review_member.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"><span class="fl ml10">角色</span></div>
<ul class="class-list f13 c-grey3">
<li><span class="fl ml10 class-list-name hidden">教师</span><span ng-class="['login-box', 'fr', 'mr10', 'mt12', {'bg-grey':current_review_member.roles_id == 7,'checked': current_review_member.roles_id == 9}]"></span></li>
<li><span class="fl ml10 class-list-name hidden">助教</span><span ng-class="['login-box', 'fr', 'mr10', 'mt12', {'bg-grey':current_review_member.roles_id == 9, 'checked': current_review_member.roles_id == 7}]"></span></li>
</ul>
<div class="bottom-tab-wrap mt10">
<a href="javascript:void(0);" ng-click="deal(1)" class="weixin-tab c-grey border-top">拒绝</a>
<a href="javascript:void(0);" ng-click="deal(0)" 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

@ -0,0 +1,20 @@
<div class="post-container">
<div loading-spinner></div>
<div ng-show="current_edit_member" class="post-container" style="padding-bottom:50px;">
<div class="blue-title">角色变更</div>
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">项目邀请码</span><input class="new-class-input ml25" ng-model="syllabus.title" required placeholder="请输入6位邀请码" /></div>
<div class="course-list-row f13 c-grey3 mt10"><span class="fl ml10">角色</span></div>
<ul class="class-list f13 c-grey3">
<li><span class="fl ml10 class-list-name hidden">管理人员</span><span ng-click="selectRole(3)" ng-class="['login-box', 'fr', 'mr10', 'mt12','img-circle', {'checked': role_id == 3}]"></span></li>
<li><span class="fl ml10 class-list-name hidden">开发人员</span><span ng-click="selectRole(4)" ng-class="['login-box', 'fr', 'mr10', 'mt12','img-circle', {'checked': role_id == 4}]"></span></li>
<li class="border-bottom-none"><span class="fl ml10 class-list-name hidden">报告人员</span><span ng-click="selectRole(5)" ng-class="['login-box', 'fr', 'mr10', 'mt12','img-circle', {'checked': role_id == 5}]"></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="join_project()" 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

@ -15,6 +15,17 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
)
}
if(vm.course.is_creator){
if(vm.reviewers.length<=0){
$http.get(config.apiUrl + 'courses/reviewers?token='+auth.token()+'&course_id='+courseid).then(
function(response) {
console.log(response.data);
vm.reviewers = response.data.data;
}
)
}
}
if(vm.students.length<=0){
$http.get(config.apiUrl + 'courses/students?token='+auth.token()+'&course_id='+courseid).then(
function(response) {
@ -100,6 +111,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
vm.course = {};
vm.students = [];
vm.teachers = [];
vm.reviewers = []; //待审批
vm.resources = [];
vm.homeworks = [];
vm.exercises = [];
@ -157,6 +169,12 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
$location.path("/edit_class_member").search({id: courseid,user_id: user.id});
};
vm.review = function(user){
rms.save('current_review_member', user);
rms.save('current_course', vm.course);
$location.path("/review_class_member").search({id: courseid,user_id: user.id});
}

View File

@ -51,27 +51,30 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo
}
vm.joinClass = function () {
vm.alertService_3.showMessage('提示', '请输入5位班级邀请码(不区分大小写)', function(){
if (vm.alertService_3.invite && vm.alertService_3.invite.length == 5) {
$http.post(config.apiUrl + "courses/join", {
token: auth.token(),
invite_code: vm.alertService_3.invite
}).then(function (response) {
console.log(response.data);
if (response.data.status != 0) {
vm.alertService_1.showMessage('提示', response.data.message);
} else {
vm.alertService_1.showMessage('提示', '加入课程成功');
vm.alertService_3.invite = "";
loadClassList();
}
});
} else {
if(vm.alertService_3.invite){
vm.alertService_1.showMessage('提示', '邀请码格式不正确');
}
}
});
// vm.alertService_3.showMessage('提示', '请输入5位班级邀请码(不区分大小写)', function(){
// if (vm.alertService_3.invite && vm.alertService_3.invite.length == 5) {
// $http.post(config.apiUrl + "courses/join", {
// token: auth.token(),
// invite_code: vm.alertService_3.invite
// }).then(function (response) {
// console.log(response.data);
// if (response.data.status != 0) {
// vm.alertService_1.showMessage('提示', response.data.message);
// } else {
// vm.alertService_1.showMessage('提示', '加入课程成功');
// vm.alertService_3.invite = "";
// loadClassList();
// }
// });
// } else {
// if(vm.alertService_3.invite){
// vm.alertService_1.showMessage('提示', '邀请码格式不正确');
// }
// }
// });
$location.path("/join_class");
};
vm.onSetting = function (syllabus) {

View File

@ -10,6 +10,16 @@ app.controller('EditClassMemberController', ['$scope', '$http', 'auth', 'config'
var course_id = $routeParams.id;
var user_id = $routeParams.user_id;
vm.teacher = false; //教师
vm.assistant = false; //教辅
vm.student = false; //学生.
vm.tmpteacher = false; //教师
vm.tmpassistant = false; //教辅
vm.tmpstudent = false; //学生
if(!vm.current_edit_member){
$http.post(config.apiUrl+'courses/get_member_info', {
token: auth.token(),
@ -19,16 +29,30 @@ app.controller('EditClassMemberController', ['$scope', '$http', 'auth', 'config'
if(response.data.status!=0){
vm.alertService.showMessage('提示', response.data.message);
} else {
console.log(response);
course_id = response.data.course_id;
user_id = response.data.user_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] == 9){
vm.teacher = true;
vm.tmpteacher = true;
}
else if(vm.current_roles_id[i] == 7){
vm.assistant = true;
vm.tmpassistant = true;
}
else if(vm.current_roles_id[i] == 10){
vm.student = true;
vm.tmpstudent = true;
}
}
}
});
}
console.log(vm.current_edit_member);
vm.cancel = function(){
// vm.alertService.showMessage('提示', '您确定不对角色进行变更吗?', function(){
// window.history.back();
@ -37,33 +61,49 @@ app.controller('EditClassMemberController', ['$scope', '$http', 'auth', 'config'
};
vm.edit_member_role = function(){
if(vm.current_roles_id == vm.current_edit_member.roles_id){
if((vm.teacher == vm.tmpteacher)&& (vm.assistant == vm.tmpassistant)&&(vm.student == vm.tmpstudent)){
vm.alertService.showMessage('提示', "该用户当前已是该角色");
return;
}
if((vm.teacher == false)&& (vm.assistant == false)&&(vm.student == false)){
vm.alertService.showMessage('提示', "请至少选择一种角色");
return;
}
$http.post(config.apiUrl+'courses/edit_member_role', {
token: auth.token(),
id: course_id,
user_id:vm.current_edit_member.user.id,
role_id:vm.current_edit_member.roles_id
teacher_flag:vm.teacher,
assistant_flag:vm.assistant,
student_flag:vm.student
}).then(function(response){
if(response.data.status!=0){
vm.alertService.showMessage('提示', response.data.message);
} else {
vm.alertService.showMessage('提示', '修改角色成功', function(){
// window.history.back();
$location.path("/class").search({id: course_id,tag:1});
});
}
});
};
vm.selectRole = function(role_id){
vm.current_edit_member.roles_id = role_id;
if (role_id == 7){
if(!vm.teacher){
vm.assistant = !vm.assistant;
}
}
else if (role_id == 9){
if(!vm.assistant){
vm.teacher = !vm.teacher;
}
}
else if (role_id == 10){
vm.student = !vm.student;
}
}
}] );

View File

@ -23,6 +23,7 @@ app.controller('EditProjectMemberController', ['$scope', '$http', 'auth', 'confi
project_id = response.data.project_id;
user_id = response.data.user_id;
vm.current_edit_member = response.data.member_info;
vm.current_edit_member.roles_id = vm.current_edit_member.roles_id[0];
vm.current_roles_id = vm.current_edit_member.roles_id;
}
});

View File

@ -0,0 +1,72 @@
app.controller('JoinClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms', function($scope, $http, auth, config, alertService, $location,$routeParams, rms){
var vm = $scope;
// vm.current_edit_member = rms.get('current_edit_member');
vm.current_edit_member = null;
vm.alertService = alertService.create();
vm.invite_code = "";
vm.teacher = false; //教师
vm.assistant = false; //教辅
vm.student = false; //学生.
vm.cancel = function(){
// vm.alertService.showMessage('提示', '您确定不对角色进行变更吗?', function(){
// window.history.back();
// });
window.history.back();
};
vm.joinClass = function(){
if((vm.teacher == false)&& (vm.assistant == false)&&(vm.student == false)){
vm.alertService.showMessage('提示', "请至少选择一个角色");
return;
}
if(vm.invite_code.length == 0)
{
vm.alertService.showMessage('提示', '请输入5位邀请码');
return;
}
if(vm.invite_code.length != 5)
{
vm.alertService.showMessage('提示', '邀请码格式不正确');
return;
}
$http.post(config.apiUrl+'courses/join_class', {
token: auth.token(),
invite_code: vm.invite_code,
teacher_flag:vm.teacher,
assistant_flag:vm.assistant,
student_flag:vm.student
}).then(function(response){
if(response.data.status == 0){
vm.alertService.showMessage('提示', response.data.message);
$location.path("/class_list");
} else {
vm.alertService.showMessage('提示', response.data.message);
}
});
};
vm.selectRole = function(role_id){
if (role_id == 7){
if(!vm.teacher){
vm.assistant = !vm.assistant;
}
}
else if (role_id == 9){
if(!vm.assistant){
vm.teacher = !vm.teacher;
}
}
else if (role_id == 10){
vm.student = !vm.student;
}
}
}] );

View File

@ -0,0 +1,52 @@
app.controller('JoinProjectController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms', function($scope, $http, auth, config, alertService, $location,$routeParams, rms){
var vm = $scope;
// vm.current_edit_member = rms.get('current_edit_member');
vm.role_id = 0;
vm.alertService = alertService.create();
vm.cancel = function(){
window.history.back();
};
vm.join_project = function(){
if(vm.role_id == 0){
vm.alertService.showMessage('提示', "请至少选择一个角色");
return;
}
if(vm.invite_code.length == 0)
{
vm.alertService.showMessage('提示', '请输入6位邀请码');
return;
}
if(vm.invite_code.length != 6)
{
vm.alertService.showMessage('提示', '邀请码格式不正确');
return;
}
$http.post(config.apiUrl+'projects/join_project', {
token: auth.token(),
invite_code: vm.invite_code,
role_id:vm.role_id
}).then(function(response){
if(response.data.status == 0){
vm.alertService.showMessage('提示', response.data.message);
$location.path("/project_list");
} else {
vm.alertService.showMessage('提示', response.data.message);
}
});
};
vm.selectRole = function(role_id){
vm.role_id = role_id;
}
}] );

View File

@ -47,27 +47,28 @@ app.controller('ProjectListController', ['$scope', 'config', 'auth', '$http', '$
vm.joinProject = function () {
// vm.alertService_1.showMessage('提示', "该功能将在近日开放,敬请期待!");
vm.alertService_3.showMessage('提示', '请输入6位项目邀请码(不区分大小写)', function(){
if (vm.alertService_3.invite && vm.alertService_3.invite.length == 6) {
$http.post(config.apiUrl + "projects/join", {
token: auth.token(),
invite_code: vm.alertService_3.invite
}).then(function (response) {
console.log(response.data);
if (response.data.status != 0) {
vm.alertService_1.showMessage('提示', response.data.message);
} else {
vm.alertService_1.showMessage('提示', '加入项目成功');
vm.alertService_3.invite = "";
loadProjectList();
}
});
} else {
if(vm.alertService_3.invite){
vm.alertService_1.showMessage('提示', '邀请码格式不正确');
}
}
});
// vm.alertService_3.showMessage('提示', '请输入6位项目邀请码(不区分大小写)', function(){
// if (vm.alertService_3.invite && vm.alertService_3.invite.length == 6) {
// $http.post(config.apiUrl + "projects/join", {
// token: auth.token(),
// invite_code: vm.alertService_3.invite
// }).then(function (response) {
// console.log(response.data);
// if (response.data.status != 0) {
// vm.alertService_1.showMessage('提示', response.data.message);
// } else {
// vm.alertService_1.showMessage('提示', '加入项目成功');
// vm.alertService_3.invite = "";
// loadProjectList();
// }
// });
// } else {
// if(vm.alertService_3.invite){
// vm.alertService_1.showMessage('提示', '邀请码格式不正确');
// }
// }
// });
$location.path("/join_project");
};
vm.onSetting = function (project) {

View File

@ -0,0 +1,68 @@
app.controller('ReviewClassMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms', function($scope, $http, auth, config, alertService, $location,$routeParams, rms){
var vm = $scope;
// vm.current_edit_member = rms.get('current_edit_member');
vm.current_review_member = rms.get('current_review_member');
vm.current_course = rms.get('current_course');
vm.alertService = alertService.create();
var course_id = $routeParams.id;
var user_id = $routeParams.user_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_review_member){
$http.post(config.apiUrl+'courses/review_member_info', {
token: auth.token(),
course_id: course_id,
user_id:user_id
}).then(function(response){
if(response.data.status!=0){
vm.alertService.showMessage('提示', response.data.message);
} else {
vm.current_review_member = response.data.data;
console.log("review_member_info");
console.log(response.data.data);
}
});
}
vm.deal = function(result){
$http.post(config.apiUrl+'courses/deal_join_apply', {
token: auth.token(),
course_id: course_id,
user_id:user_id,
type:result
}).then(function(response) {
if (response.data.status == 0) {
vm.alertService.showMessage('提示', response.data.message, function () {
$location.path("/class_list");
});
}
else{
vm.alertService.showMessage('提示', response.data.message);
}
});
};
}] );

View File

@ -0,0 +1,109 @@
app.controller('ReviewProjectMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms', function($scope, $http, auth, config, alertService, $location,$routeParams, rms){
var vm = $scope;
// vm.current_edit_member = rms.get('current_edit_member');
vm.current_edit_member = null;
vm.alertService = alertService.create();
var course_id = $routeParams.id;
var user_id = $routeParams.user_id;
vm.teacher = false; //教师
vm.assistant = false; //教辅
vm.student = false; //学生.
vm.tmpteacher = false; //教师
vm.tmpassistant = false; //教辅
vm.tmpstudent = false; //学生
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);
} else {
console.log(response);
course_id = response.data.course_id;
user_id = response.data.user_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] == 9){
vm.teacher = true;
vm.tmpteacher = true;
}
else if(vm.current_roles_id[i] == 7){
vm.assistant = true;
vm.tmpassistant = true;
}
else if(vm.current_roles_id[i] == 10){
vm.student = true;
vm.tmpstudent = true;
}
}
}
});
}
vm.cancel = function(){
// vm.alertService.showMessage('提示', '您确定不对角色进行变更吗?', function(){
// window.history.back();
// });
window.history.back();
};
vm.edit_member_role = function(){
if((vm.teacher == vm.tmpteacher)&& (vm.assistant == vm.tmpassistant)&&(vm.student == vm.tmpstudent)){
vm.alertService.showMessage('提示', "该用户当前已是该角色");
return;
}
if((vm.teacher == false)&& (vm.assistant == false)&&(vm.student == false)){
vm.alertService.showMessage('提示', "请至少选择一种角色");
return;
}
$http.post(config.apiUrl+'courses/edit_member_role', {
token: auth.token(),
id: course_id,
user_id:vm.current_edit_member.user.id,
teacher_flag:vm.teacher,
assistant_flag:vm.assistant,
student_flag:vm.student
}).then(function(response){
if(response.data.status!=0){
vm.alertService.showMessage('提示', response.data.message);
} else {
vm.alertService.showMessage('提示', '修改角色成功', function(){
// window.history.back();
$location.path("/class").search({id: course_id,tag:1});
});
}
});
};
vm.selectRole = function(role_id){
if (role_id == 7){
if(!vm.teacher){
vm.assistant = !vm.assistant;
}
}
else if (role_id == 9){
if(!vm.assistant){
vm.teacher = !vm.teacher;
}
}
else if (role_id == 10){
vm.student = !vm.student;
}
}
}] );

View File

@ -38,11 +38,15 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
.when('/myresource', makeRoute('myresource.html', 'MyResourceController'))
.when('/invite_code', {templateUrl: rootPath + 'invite_code.html', controller: 'InviteCodeController'})
.when('/send_class_list', makeRoute('send_class_list.html', 'SendClassListController'))
.when('/join_class', makeRoute('join_class.html', 'JoinClassController'))
.when('/review_class_member', makeRoute('review_class_member.html', 'ReviewClassMemberController'))
.when('/project_list', makeRoute('project_list.html', 'ProjectListController'))
.when('/project', makeRoute('project.html', 'ProjectController'))
.when('/edit_project_member', makeRoute('edit_project_member.html', 'EditProjectMemberController'))
.when('/new_project', makeRoute('new_project.html', 'NewProjectController'))
.when('/project_invite_code', {templateUrl: rootPath + 'project_invite_code.html', controller: 'ProjectInviteCodeController'})
.when('/join_project', makeRoute('join_project.html', 'JoinProjectController'))
.when('/review_project_member', makeRoute('review_project_member.html', 'ReviewProjectMemberController'))
.otherwise({
redirectTo: '/activites'
});