未批作业排序
This commit is contained in:
parent
811b6383f7
commit
6cb2a5562f
|
@ -12,11 +12,13 @@ class HomeworkAttachController < ApplicationController
|
|||
#获取未批作业列表
|
||||
def get_not_batch_homework
|
||||
sort, direction = params[:sort], params[:direction]
|
||||
order_by = sort == 'score'? "s_score #{direction}" : "created_at #{direction}"
|
||||
|
||||
teachers = find_course_teachers @course
|
||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}) AS table1
|
||||
WHERE table1.t_score IS NULL")
|
||||
|
||||
@homework_list = paginateHelper all_homework_list,10
|
||||
|
@ -40,7 +42,7 @@ class HomeworkAttachController < ApplicationController
|
|||
@homework_list = paginateHelper all_homework_list,10
|
||||
@direction = direction == 'asc'? 'desc' : 'asc'
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.js.
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue