课程作业发布功能

设置教辅功能
学生列表及成绩查看功能
This commit is contained in:
lizanle 2015-05-15 09:06:36 +08:00
parent 7112d91706
commit a047bd3d18
6 changed files with 97 additions and 4 deletions

View File

@ -170,10 +170,26 @@ module Mobile
desc "设置教辅"
params do
requires :token,type:String
requires :user_id,type:Integer,desc: '用户id'
requires :course_id,type:Integer,desc:'课程id'
end
get 'set_user_as_assitant' do
cs = CoursesService.new
cs.set_as_assitant_teacher params
present :status, 0
end
post 'set_user_as_assitant' do
desc "删除教辅"
params do
requires :token,type:String
requires :user_id,type:Integer,desc: '用户id'
requires :course_id,type:Integer,desc:'课程id'
end
get 'del_user_as_assitant' do
cs = CoursesService.new
cs.del_assitant_teacher params
present :status, 0
end
desc "返回单个课程"
@ -187,7 +203,7 @@ module Mobile
course = cs.show_course(params,(current_user.nil? ? User.find(2):current_user))
#course = Course.find(params[:id])
present :data, course, with: Mobile::Entities::Course
present :status, 0
{ status: 0}
end
end

View File

@ -96,6 +96,21 @@ module Mobile
present :status, 0
end
desc '创建作业'
params do
requires :token,type:String
requires :work_name,type:String,desc:'作业名称'
requires :work_desc,type:String,desc:'作业描述'
requires :work_deadline,type:String,desc:'截止日期'
requires :is_blind_appr,type:Integer,desc:'是否匿评'
requires :blind_appr_num,type:Integer,desc:'匿评分配数'
requires :course_id,type:Integer,desc: '课程id'
end
post 'create_home_work' do
Homeworks.get_service.create_home_work params,current_user
present :status, 0
end
end
end

View File

@ -84,6 +84,7 @@ module Mobile
requires :name, type: String, desc: '用户名关键字'
requires :search_by, type: String,desc: '搜索依据0 昵称1 用户名2 邮箱,3 昵称和姓名'
optional :is_search_assitant,type:Integer,desc:'是否搜索注册用户来作为助教'
optional :course_id,type:Integer,desc: '课程id搜索注册用户不为该课程教师的其他用户'
end
get 'search/search_user' do
us = UsersService.new

View File

@ -473,6 +473,41 @@ class CoursesService
result
end
# 设置人员为课程教辅
def set_as_assitant_teacher params
members = []
#找到课程
course = Course.find(params[:course_id])
#新建课程人员
member = Member.new(:role_ids =>[7], :user_id => params[:user_id],:course_id=>params[:course_id])
joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,course.id)
joined.each do |join|
join.delete
end
member.course_group_id = 0
members << member
course.members << members
#将课程人员设置为教辅
end
def del_assitant_teacher params
member = Member.where("user_id = ? and course_id = ?",params[:user_id],params[:course_id])
member.each do |m|
m.destroy
end
user_admin = CourseInfos.where("user_id = ? and course_id = ?",params[:user_id], params[:course_id])
if user_admin.size > 0
user_admin.each do |user|
user.destroy
end
end
joined = StudentsForCourse.where('student_id = ? and course_id = ?', params[:user_id],params[:course_id])
joined.each do |join|
join.delete
end
end
private
def searchmember_by_name members, name
#searchPeopleByRoles(project, StudentRoles)
@ -576,4 +611,6 @@ class CoursesService
end

View File

@ -231,6 +231,29 @@ class HomeworkService
anonymous_repy(jour)
end
end
# 发布作业
def create_home_work params,current_user
@bid = Bid.new
@bid.name = params[:work_name]
@bid.description = params[:work_desc]
# @bid.is_evaluation = params[:is_blind_appr]
@bid.evaluation_num = params[:blind_appr_num]
@bid.open_anonymous_evaluation = params[:is_blind_appr]
@bid.reward_type = 3
@bid.deadline = params[:work_deadline]
@bid.budget = 0
@bid.author_id = current_user.id
@bid.commit = 0
@bid.homework_type = 1
# @bid.
if @bid.save
HomeworkForCourse.create(:course_id => params[:course_id], :bid_id => @bid.id)
unless @bid.watched_by?(current_user)
@bid.add_watcher(current_user)
end
end
end
# 学生匿评列表
def student_jour_list params

View File

@ -211,7 +211,8 @@ class UsersService
search_by = params[:search_by] ? params[:search_by] : "0"
scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present?
else
scope = scope.like(params[:name],search_by) if params[:name].present?
teachers = searchTeacherAndAssistant(Course.find(params[:course_id]))
scope = scope.where("id not in (?)",teachers.map{|t| t.user_id}).like(params[:name],search_by) if params[:name].present?
end
scope
end