parent
999b856d84
commit
8e2288a362
|
@ -412,7 +412,7 @@ class BidsController < ApplicationController
|
|||
#增加作业按评分排序,
|
||||
@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")
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY score DESC",:include => [:attachments])
|
||||
if params[:student_id].present?
|
||||
@temp = []
|
||||
@homework_list.each do |pro|
|
||||
|
|
|
@ -168,4 +168,15 @@ module CoursesHelper
|
|||
seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count
|
||||
seem_count > 0
|
||||
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
|
||||
|
|
|
@ -43,14 +43,6 @@
|
|||
<% else %>
|
||||
<% homework_filename = attachment.filename %>
|
||||
<% end %>
|
||||
<!--
|
||||
<% if attachments.count > 1 && attachment != attachments.first %>
|
||||
<br/>
|
||||
<% for item in 1..7 %>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
-->
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% homework_filename = homework.name %>
|
||||
|
@ -83,13 +75,7 @@
|
|||
</td>
|
||||
<td>
|
||||
<strong>作业评分:</strong>
|
||||
<% 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) %>
|
||||
<%= homework_score homework %>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
|
||||
|
@ -104,8 +90,7 @@
|
|||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? &&
|
||||
(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) %>
|
||||
<% if (User.current == homework.user) || is_teacher %>
|
||||
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
||||
<%= link_to(l(:label_bid_respond_delete), homework,
|
||||
method: :delete, :confirm => l(:text_are_you_sure)) %>
|
||||
|
|
|
@ -22,27 +22,27 @@
|
|||
<% course = Course.find_by_extra(project.identifier) %>
|
||||
<div id="wrapper">
|
||||
<div id="wrapper2">
|
||||
<div id="wrapper3">
|
||||
<%= render :partial => 'layouts/base_header'%>
|
||||
<div id="wrapper3">
|
||||
<%= render :partial => 'layouts/base_header'%>
|
||||
<div id="main">
|
||||
<!--added by huang-->
|
||||
<div class="top-content">
|
||||
<div class="top-content">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
||||
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
||||
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
||||
<span><%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%></span> >
|
||||
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
||||
<span><%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%></span> >
|
||||
<%=link_to(@bid.name, respond_path(@bid)) %></p></td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
</div>
|
||||
<!--end-->
|
||||
|
||||
|
||||
<div id="sidebar">
|
||||
<div class="main_context">
|
||||
<div class="spaceleft">
|
||||
|
|
Loading…
Reference in New Issue