|
|
|
@ -433,18 +433,48 @@ class CoursesService
|
|
|
|
|
result = []
|
|
|
|
|
@course = Course.find(params[:course_id])
|
|
|
|
|
@attachments = @course.attachments.order("created_on desc")
|
|
|
|
|
@attachments.each do |atta|
|
|
|
|
|
result << {:filename => atta.filename,:description => atta.description,:downloads => atta.downloads,:quotes => atta.quotes.nil? ? 0 :atta.quotes }
|
|
|
|
|
if !params[:name].nil? && params[:name] != ""
|
|
|
|
|
@attachments.each do |atta|
|
|
|
|
|
result << {:filename => atta.filename,
|
|
|
|
|
:description => atta.description,
|
|
|
|
|
:downloads => atta.downloads,
|
|
|
|
|
:quotes => atta.quotes.nil? ? 0 :atta.quotes } if atta.filename.include?(params[:name])
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
@attachments.each do |atta|
|
|
|
|
|
result << {:filename => atta.filename,
|
|
|
|
|
:description => atta.description,
|
|
|
|
|
:downloads => atta.downloads,
|
|
|
|
|
:quotes => atta.quotes.nil? ? 0 :atta.quotes }
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
result
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 课程学生列表
|
|
|
|
|
def course_members params
|
|
|
|
|
@all_members = student_homework_score(0,params[:course_id], 10,"desc")
|
|
|
|
|
@all_members = searchmember_by_name(student_homework_score(0,params[:course_id], 10,"desc"),params[:name])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
def searchmember_by_name members, name
|
|
|
|
|
#searchPeopleByRoles(project, StudentRoles)
|
|
|
|
|
mems = []
|
|
|
|
|
if name != ""
|
|
|
|
|
name = name.to_s.downcase
|
|
|
|
|
members.each do |m|
|
|
|
|
|
username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase
|
|
|
|
|
if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
|
|
|
|
|
mems << m
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
mems = members
|
|
|
|
|
end
|
|
|
|
|
mems
|
|
|
|
|
end
|
|
|
|
|
def show_homework_info course,bid,current_user,is_course_teacher
|
|
|
|
|
author_real_name = bid.author.lastname + bid.author.firstname
|
|
|
|
|
many_times = course.homeworks.index(bid) + 1
|
|
|
|
|