|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
class CoursesService
|
|
|
|
|
include ApplicationHelper
|
|
|
|
|
include CoursesHelper
|
|
|
|
|
#TODO:尚未整合权限系统
|
|
|
|
|
#参数school_id为0或不传时返回所有课程,否则返回对应学校的课程
|
|
|
|
|
#参数per_page_count分页功能,每页显示的课程数
|
|
|
|
|
#参数page分页功能,当前页码
|
|
|
|
@ -48,20 +49,28 @@ class CoursesService
|
|
|
|
|
url_to_avatar(obj)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#课程老师或课程学生列表
|
|
|
|
|
def course_teacher_or_student_list params,course
|
|
|
|
|
@teachers= searchTeacherAndAssistant(course)
|
|
|
|
|
#课程老师或课程学生列表 TODO:更新业务逻辑,当前版本未包含分班功能
|
|
|
|
|
def course_teacher_or_student_list params,course,current_user
|
|
|
|
|
if course.is_a?(Course)
|
|
|
|
|
c = course
|
|
|
|
|
else
|
|
|
|
|
c = Course.find(course)
|
|
|
|
|
end
|
|
|
|
|
if !(current_user.admin? || c.is_public == 1 || (c.is_public == 0 && current_user.member_of_course?(c)))
|
|
|
|
|
raise '403'
|
|
|
|
|
end
|
|
|
|
|
@teachers= searchTeacherAndAssistant(c)
|
|
|
|
|
#@canShowCode = isCourseTeacher(User.current.id,course) && params[:role] != '1'
|
|
|
|
|
case params[:role]
|
|
|
|
|
when '1'
|
|
|
|
|
#@subPage_title = l :label_teacher_list
|
|
|
|
|
@members = searchTeacherAndAssistant(course)
|
|
|
|
|
@members = searchTeacherAndAssistant(c)
|
|
|
|
|
when '2'
|
|
|
|
|
#@subPage_title = l :label_student_list
|
|
|
|
|
@members = searchStudent(course)
|
|
|
|
|
@members = searchStudent(c)
|
|
|
|
|
else
|
|
|
|
|
#@subPage_title = ''
|
|
|
|
|
@members = @course.member_principals.includes(:roles, :principal).all.sort
|
|
|
|
|
@members = c.member_principals.includes(:roles, :principal).all.sort
|
|
|
|
|
end
|
|
|
|
|
@members
|
|
|
|
|
end
|
|
|
|
@ -74,6 +83,11 @@ class CoursesService
|
|
|
|
|
scope = @course ? @course.news.course_visible : News.course_visible
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#显示课程通知
|
|
|
|
|
def show_course_news
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def show_course params
|
|
|
|
|
course = Course.find(params[:id])
|
|
|
|
|
course
|
|
|
|
@ -178,4 +192,17 @@ class CoursesService
|
|
|
|
|
[@state,course]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#作业列表
|
|
|
|
|
#已提交的作业数量获取 bid.homeworks.count
|
|
|
|
|
#学生提问数量获取 bid.commit.nil? ? 0 : bid.commit
|
|
|
|
|
def homework_list params,current_user
|
|
|
|
|
if @course.is_public != 0 || current_user.member_of_course?(@course)
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
|
@bids = @course.homeworks.order('deadline DESC')
|
|
|
|
|
@bids = @bids.like(params[:name]) if params[:name].present?
|
|
|
|
|
else
|
|
|
|
|
raise '403'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|