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