作业增加按教师评分/匿评/时间排序
This commit is contained in:
parent
334a99bcef
commit
def7a7f5e3
|
@ -514,7 +514,7 @@ class BidsController < ApplicationController
|
|||
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = 3123) AS m_score
|
||||
FROM homework_attaches
|
||||
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
|
||||
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id}) AS table1
|
||||
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC) AS table1
|
||||
WHERE table1.m_score IS NULL")
|
||||
@is_student_batch_homework = true
|
||||
@cur_type = 4
|
||||
|
|
|
@ -21,8 +21,14 @@ class HomeworkAttachController < ApplicationController
|
|||
|
||||
#获取未批作业列表
|
||||
def get_not_batch_homework
|
||||
sort, direction = params[:sort], params[:direction]
|
||||
order_by = sort == 'socre'? "s_score #{direction}" : "created_at #{direction}"
|
||||
sort, direction = params[:sort] || "s_socre", params[:direction] || "desc"
|
||||
if sort == 't_socre'
|
||||
order_by = "t_score #{direction}"
|
||||
elsif sort == 's_socre'
|
||||
order_by = "s_score #{direction}"
|
||||
elsif sort == 'time'
|
||||
order_by = "created_at #{direction}"
|
||||
end
|
||||
teachers = find_course_teachers @course
|
||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score,
|
||||
|
@ -41,9 +47,14 @@ class HomeworkAttachController < ApplicationController
|
|||
|
||||
#获取已评作业列表
|
||||
def get_batch_homeworks
|
||||
sort, direction = params[:sort], params[:direction]
|
||||
teacher_proportion = get_teacher_proportion @bid
|
||||
order_by = sort == 'socre'? "(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) #{direction}" : "created_at #{direction}"
|
||||
sort, direction = params[:sort] || "s_socre", params[:direction] || "desc"
|
||||
if sort == 't_socre'
|
||||
order_by = "t_score #{direction}"
|
||||
elsif sort == 's_socre'
|
||||
order_by = "s_score #{direction}"
|
||||
elsif sort == 'time'
|
||||
order_by = "created_at #{direction}"
|
||||
end
|
||||
teachers = find_course_teachers @course
|
||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers} and stars IS NOT NULL) AS t_score,
|
||||
|
@ -62,9 +73,14 @@ class HomeworkAttachController < ApplicationController
|
|||
|
||||
#获取所有作业列表
|
||||
def get_homeworks
|
||||
sort, direction = params[:sort], params[:direction]
|
||||
teacher_proportion = get_teacher_proportion @bid
|
||||
order_by = sort == 'socre'? "(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) #{direction}" : "created_at #{direction}"
|
||||
sort, direction = params[:sort] || "s_socre", params[:direction] || "desc"
|
||||
if sort == 't_socre'
|
||||
order_by = "t_score #{direction}"
|
||||
elsif sort == 's_socre'
|
||||
order_by = "s_score #{direction}"
|
||||
elsif sort == 'time'
|
||||
order_by = "created_at #{direction}"
|
||||
end
|
||||
teachers = find_course_teachers @course
|
||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id in #{teachers}) AS t_score,
|
||||
|
@ -90,7 +106,7 @@ class HomeworkAttachController < ApplicationController
|
|||
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = 3123) AS m_score
|
||||
FROM homework_attaches
|
||||
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
|
||||
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id}) AS table1
|
||||
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC) AS table1
|
||||
WHERE table1.m_score IS NULL")
|
||||
@cur_page = params[:page] || 1
|
||||
@cur_type = 4
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
</font>)
|
||||
</span><span class="fr">
|
||||
按
|
||||
<%= link_to l(:label_work_rating), sort_homework_path(@bid, 'socre', @direction), {:remote => true}%>
|
||||
<%= link_to l(:label_teacher_score), sort_homework_path(@bid, 't_socre', @direction), {:remote => true}%>
|
||||
/
|
||||
<%= link_to l(:label_anonymous_comments), sort_homework_path(@bid, 's_socre', @direction), {:remote => true}%>
|
||||
/
|
||||
<%= link_to l(:label_time), sort_homework_path(@bid, 'time', @direction), {:remote => true}%>
|
||||
<%= l(:label_sort) %>
|
||||
|
|
Loading…
Reference in New Issue