diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 29a7760d6..0cf8ea45d 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -496,11 +496,18 @@ class BidsController < ApplicationController #@homework_list = @bid.homeworks #增加作业按评分排序, #@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC") - @homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, + all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{@bid.author_id}) AS t_score, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id <> #{@bid.author_id}) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY (CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) DESC,created_at ASC") + + limit = 10 + feedback_count = all_homework_list.count + @feedback_pages = Paginator.new feedback_count, limit, params['page'] + offset ||= @feedback_pages.offset + @homework_list = all_homework_list[offset, limit] + if params[:student_id].present? @temp = [] @homework_list.each do |pro| diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 514092988..3ed809fe0 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -153,4 +153,11 @@
-<% end %> \ No newline at end of file +<% end %> + + + \ No newline at end of file