|
|
@ -49,7 +49,7 @@ class CoursesService
|
|
|
|
url_to_avatar(obj)
|
|
|
|
url_to_avatar(obj)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#课程老师或课程学生列表 TODO:更新业务逻辑,当前版本未包含分班功能
|
|
|
|
#课程老师或课程学生列表
|
|
|
|
def course_teacher_or_student_list params,course,current_user
|
|
|
|
def course_teacher_or_student_list params,course,current_user
|
|
|
|
if course.is_a?(Course)
|
|
|
|
if course.is_a?(Course)
|
|
|
|
c = course
|
|
|
|
c = course
|
|
|
@ -110,8 +110,20 @@ class CoursesService
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#创建课程
|
|
|
|
#创建课程
|
|
|
|
def create_course params
|
|
|
|
#current_user当前用户对象(不是id)
|
|
|
|
if User.current.user_extensions.identity
|
|
|
|
# params[:course][:name]:课程名称
|
|
|
|
|
|
|
|
#params[:course][:password]:密码
|
|
|
|
|
|
|
|
#params[:course][:description]:描述
|
|
|
|
|
|
|
|
#params[:course][:is_public]:是否公开1公开,0私有
|
|
|
|
|
|
|
|
#params[:course][:open_student]:是否公开学生列表1公开,0不公开,不公开时非课程成员无法看到学生列表
|
|
|
|
|
|
|
|
#params[:course][:course_type]:暂时默认给1值。
|
|
|
|
|
|
|
|
#params[:term]:学期(秋季学期或春季学期)
|
|
|
|
|
|
|
|
#params[:time]: 年份(例:2014)
|
|
|
|
|
|
|
|
#params[:setup_time]:暂不传(貌似已经没用了)
|
|
|
|
|
|
|
|
#params[:endup_time]: 暂不传(貌似已经没用了)
|
|
|
|
|
|
|
|
#params[:class_period]:学时总数
|
|
|
|
|
|
|
|
def create_course params,current_user
|
|
|
|
|
|
|
|
if current_user.user_extensions.identity
|
|
|
|
@course = Course.new
|
|
|
|
@course = Course.new
|
|
|
|
@course.extra = 'course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
|
|
|
|
@course.extra = 'course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
|
|
|
|
@course.safe_attributes = params[:course]
|
|
|
|
@course.safe_attributes = params[:course]
|
|
|
@ -145,6 +157,7 @@ class CoursesService
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#验证编辑课程的权限
|
|
|
|
#验证编辑课程的权限
|
|
|
|
|
|
|
|
#当前
|
|
|
|
def edit_course_authorize(current_user,course)
|
|
|
|
def edit_course_authorize(current_user,course)
|
|
|
|
unless current_user.allowed_to?({:controller => 'courses', :action => 'update'}, course)
|
|
|
|
unless current_user.allowed_to?({:controller => 'courses', :action => 'update'}, course)
|
|
|
|
raise '403'
|
|
|
|
raise '403'
|
|
|
@ -152,6 +165,15 @@ class CoursesService
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#编辑课程 需验证权限
|
|
|
|
#编辑课程 需验证权限
|
|
|
|
|
|
|
|
# params[:course][:name]:课程名称
|
|
|
|
|
|
|
|
#params[:course][:password]:密码
|
|
|
|
|
|
|
|
#params[:course][:description]:描述
|
|
|
|
|
|
|
|
#params[:course][:is_public]:是否公开1公开,0私有
|
|
|
|
|
|
|
|
#params[:course][:open_student]:是否公开学生列表1公开,0不公开,不公开时非课程成员无法看到学生列表
|
|
|
|
|
|
|
|
#params[:course][:course_type]:暂时默认给1值。
|
|
|
|
|
|
|
|
#params[:term]:学期(秋季学期或春季学期)
|
|
|
|
|
|
|
|
#params[:time]: 年份(例:2014)
|
|
|
|
|
|
|
|
#params[:class_period]:学时总数
|
|
|
|
def edit_course params,course
|
|
|
|
def edit_course params,course
|
|
|
|
course.safe_attributes = params[:course]
|
|
|
|
course.safe_attributes = params[:course]
|
|
|
|
course.time = params[:time]
|
|
|
|
course.time = params[:time]
|
|
|
@ -171,6 +193,8 @@ class CoursesService
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#退出课程
|
|
|
|
#退出课程
|
|
|
|
|
|
|
|
#object_id: 课程id
|
|
|
|
|
|
|
|
#user:当前用户
|
|
|
|
def exit_course params,user
|
|
|
|
def exit_course params,user
|
|
|
|
@member = Member.where('course_id = ? and user_id = ?', params[:object_id], user.id)
|
|
|
|
@member = Member.where('course_id = ? and user_id = ?', params[:object_id], user.id)
|
|
|
|
@member.first.destroy
|
|
|
|
@member.first.destroy
|
|
|
@ -182,6 +206,8 @@ class CoursesService
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#加入课程
|
|
|
|
#加入课程
|
|
|
|
|
|
|
|
#object_id:课程id
|
|
|
|
|
|
|
|
#course_password :加入课程的密码
|
|
|
|
#@state == 0 加入成功
|
|
|
|
#@state == 0 加入成功
|
|
|
|
#@state == 1 密码错误
|
|
|
|
#@state == 1 密码错误
|
|
|
|
#@state == 2 课程已过期 请联系课程管理员重启课程。(在配置课程处)
|
|
|
|
#@state == 2 课程已过期 请联系课程管理员重启课程。(在配置课程处)
|
|
|
|