This commit is contained in:
huang 2015-05-06 09:26:31 +08:00
commit 615184fc38
2 changed files with 35 additions and 3 deletions

View File

@ -232,6 +232,7 @@ module Mobile
params do
requires :token, type: String
requires :course_id,type: Integer,desc: '课程id'
optional :name,type:String,desc:'课件名称可能包含的字符'
end
get ":course_id/attachments" do
cs = CoursesService.new
@ -244,6 +245,7 @@ module Mobile
params do
requires :token,type:String
requires :course_id,type:Integer,desc: '课程id'
optional :name,type:String,desc:'学生的姓名或者昵称或者学号可能包含的字符'
end
get ":course_id/members" do
cs = CoursesService.new

View File

@ -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