parent
4d9fb3e3c4
commit
d61eb60aba
|
@ -12,13 +12,13 @@ class HomeworkAttachController < ApplicationController
|
|||
#获取未批作业列表
|
||||
def get_not_batch_homework
|
||||
sort, direction = params[:sort], params[:direction]
|
||||
order_by = sort == 'score'? "s_score #{direction}" : "created_at #{direction}"
|
||||
|
||||
order_by = sort == 'socre'? "s_score #{direction}" : "created_at #{direction}"
|
||||
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,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}) AS table1
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id}
|
||||
ORDER BY #{order_by}) AS table1
|
||||
WHERE table1.t_score IS NULL")
|
||||
|
||||
@homework_list = paginateHelper all_homework_list,10
|
||||
|
@ -31,13 +31,14 @@ class HomeworkAttachController < ApplicationController
|
|||
#获取已评作业列表
|
||||
def get_batch_homeworks
|
||||
sort, direction = params[:sort], params[:direction]
|
||||
teachers = find_course_teachers @course
|
||||
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}"
|
||||
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,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id}
|
||||
ORDER BY (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) DESC,created_at ASC) AS table1
|
||||
ORDER BY #{order_by}) AS table1
|
||||
WHERE table1.t_score IS NOT NULL")
|
||||
@homework_list = paginateHelper all_homework_list,10
|
||||
@direction = direction == 'asc'? 'desc' : 'asc'
|
||||
|
@ -49,13 +50,14 @@ class HomeworkAttachController < ApplicationController
|
|||
#获取所有作业列表
|
||||
def get_homeworks
|
||||
sort, direction = params[:sort], params[:direction]
|
||||
teachers = find_course_teachers @course
|
||||
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}"
|
||||
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,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id not in #{teachers}) AS s_score
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id}
|
||||
ORDER BY (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) DESC,created_at ASC")
|
||||
ORDER BY #{order_by}")
|
||||
@homework_list = paginateHelper all_homework_list,10
|
||||
@direction = direction == 'asc'? 'desc' : 'asc'
|
||||
respond_to do |format|
|
||||
|
|
Loading…
Reference in New Issue