增加作业按评分排序

This commit is contained in:
sw 2014-06-05 10:47:22 +08:00
parent 39ce95a950
commit b0a88eb5ac
1 changed files with 4 additions and 1 deletions

View File

@ -407,7 +407,10 @@ class BidsController < ApplicationController
if @bid.homework_type == 1
@homework = HomeworkAttach.new
@homework_list = @bid.homeworks
#@homework_list = @bid.homeworks
@homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id) AS score
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY score DESC")
if params[:student_id].present?
@temp = []
@homework_list.each do |pro|