sql
This commit is contained in:
parent
999b856d84
commit
1c7923e5bd
|
@ -410,9 +410,7 @@ class BidsController < ApplicationController
|
|||
@homework = HomeworkAttach.new
|
||||
#@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")
|
||||
@homework_list = @bid.homeworks.joins(:user).includes(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC')
|
||||
if params[:student_id].present?
|
||||
@temp = []
|
||||
@homework_list.each do |pro|
|
||||
|
|
|
@ -158,7 +158,7 @@ module BidsHelper
|
|||
#当前用户是不是指定课程的学生
|
||||
def is_cur_course_student? course
|
||||
people = []
|
||||
course.members.each do |member|
|
||||
course.members.includes(:user, :roles).each do |member|
|
||||
if [5,10].include? member.roles.first.id
|
||||
people << member.user
|
||||
end
|
||||
|
|
|
@ -139,7 +139,7 @@ module CoursesHelper
|
|||
#判断制定用户是不是当前课程的老师
|
||||
def is_course_teacher user,course
|
||||
people = []
|
||||
course.members.each do |member|
|
||||
course.members.includes(:roles, :user).each do |member|
|
||||
role_id = member.roles.first.id
|
||||
if TeacherRoles.include? role_id
|
||||
people << member.user
|
||||
|
|
|
@ -137,7 +137,7 @@ class User < Principal
|
|||
has_one :user_extensions,:dependent => :destroy
|
||||
## end
|
||||
|
||||
#default_scope -> { includes(:user_extensions, :user_score) }
|
||||
default_scope -> { includes(:user_extensions, :user_score) }
|
||||
scope :teacher, -> {
|
||||
joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::TEACHER)
|
||||
}
|
||||
|
|
|
@ -83,13 +83,8 @@
|
|||
</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) %>
|
||||
|
||||
<%= format("%.2f", homework.rate_averages.first.try(:avg).to_i ) %>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
|
||||
|
@ -100,7 +95,7 @@
|
|||
<tr>
|
||||
<td valign="top">
|
||||
<% if User.current.member_of?(@bid.courses.first) %>
|
||||
<strong><%= l(:label_bidding_user_studentcode) %> : <%= homework.user.user_extensions.student_id%></strong>
|
||||
<strong><%= l(:label_bidding_user_studentcode) %> : <%= homework.user.student_id%></strong>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
<%= yield :header_tags -%>
|
||||
</head>
|
||||
<body class="<%= h body_css_classes %>">
|
||||
<% project = @bid.courses.first %>
|
||||
<% course = Course.find_by_extra(project.identifier) %>
|
||||
<% project = @bid.courses.includes(:course_extra).first %>
|
||||
<% course = project.course_extra %>
|
||||
<div id="wrapper">
|
||||
<div id="wrapper2">
|
||||
<div id="wrapper3">
|
||||
|
|
Loading…
Reference in New Issue