parent
999b856d84
commit
8e2288a362
|
@ -412,7 +412,7 @@ class BidsController < ApplicationController
|
||||||
#增加作业按评分排序,
|
#增加作业按评分排序,
|
||||||
@homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*,
|
@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
|
(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")
|
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY score DESC",:include => [:attachments])
|
||||||
if params[:student_id].present?
|
if params[:student_id].present?
|
||||||
@temp = []
|
@temp = []
|
||||||
@homework_list.each do |pro|
|
@homework_list.each do |pro|
|
||||||
|
|
|
@ -168,4 +168,15 @@ module CoursesHelper
|
||||||
seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count
|
seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count
|
||||||
seem_count > 0
|
seem_count > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#获取指定作业的平均评分
|
||||||
|
def homework_score homework
|
||||||
|
stars_reates = homework.rates(:quality)
|
||||||
|
sum = 0
|
||||||
|
stars_reates.each do |star_reates|
|
||||||
|
sum = sum + star_reates.stars
|
||||||
|
end
|
||||||
|
stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count
|
||||||
|
format("%.2f", sum * 1.0 / stars_reates_count)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,14 +43,6 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<% homework_filename = attachment.filename %>
|
<% homework_filename = attachment.filename %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!--
|
|
||||||
<% if attachments.count > 1 && attachment != attachments.first %>
|
|
||||||
<br/>
|
|
||||||
<% for item in 1..7 %>
|
|
||||||
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
-->
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% homework_filename = homework.name %>
|
<% homework_filename = homework.name %>
|
||||||
|
@ -83,13 +75,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<strong>作业评分:</strong>
|
<strong>作业评分:</strong>
|
||||||
<% stars_reates = homework.rates(:quality) %>
|
<%= homework_score homework %>
|
||||||
<% sum = 0 %>
|
|
||||||
<% stars_reates.each do |star_reates| %>
|
|
||||||
<% sum = sum + star_reates.stars %>
|
|
||||||
<% end %>
|
|
||||||
<% stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count %>
|
|
||||||
<%= format("%.2f", sum * 1.0 / stars_reates_count) %>
|
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" align="right">
|
<td valign="top" align="right">
|
||||||
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
|
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
|
||||||
|
@ -104,8 +90,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? &&
|
<% if (User.current == homework.user) || is_teacher %>
|
||||||
(Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %>
|
|
||||||
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
||||||
<%= link_to(l(:label_bid_respond_delete), homework,
|
<%= link_to(l(:label_bid_respond_delete), homework,
|
||||||
method: :delete, :confirm => l(:text_are_you_sure)) %>
|
method: :delete, :confirm => l(:text_are_you_sure)) %>
|
||||||
|
|
Loading…
Reference in New Issue