修改当用户角色改变时,该用户评分所属角色也跟着改变的BUG
This commit is contained in:
parent
0a58fce251
commit
aa06251fd3
|
@ -492,26 +492,17 @@ class BidsController < ApplicationController
|
||||||
if @bid.homework_type
|
if @bid.homework_type
|
||||||
@homework = HomeworkAttach.new
|
@homework = HomeworkAttach.new
|
||||||
@is_teacher = is_course_teacher(User.current,@bid.courses.first)
|
@is_teacher = is_course_teacher(User.current,@bid.courses.first)
|
||||||
teachers = "("
|
|
||||||
teacher_members = searchTeacherAndAssistant(@bid.courses.first)
|
|
||||||
teacher_members.each do |member|
|
|
||||||
if member == teacher_members.last
|
|
||||||
teachers += member.user_id.to_s + ")"
|
|
||||||
else
|
|
||||||
teachers += member.user_id.to_s + ","
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if @is_teacher
|
if @is_teacher
|
||||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
|
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 is_teacher_score = 1) 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
|
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score
|
||||||
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1
|
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1
|
||||||
WHERE table1.t_score IS NULL")
|
WHERE table1.t_score IS NULL")
|
||||||
@cur_type = 1
|
@cur_type = 1
|
||||||
else
|
else
|
||||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
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 is_teacher_score = 1) 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,
|
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score,
|
||||||
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score
|
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score
|
||||||
FROM homework_attaches
|
FROM homework_attaches
|
||||||
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
|
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
|
||||||
|
@ -1056,17 +1047,8 @@ class BidsController < ApplicationController
|
||||||
elsif @bid.comment_status == 1
|
elsif @bid.comment_status == 1
|
||||||
@totle_size = 0
|
@totle_size = 0
|
||||||
@bid.homeworks.map { |homework| @totle_size += homework.homework_evaluations.count}
|
@bid.homeworks.map { |homework| @totle_size += homework.homework_evaluations.count}
|
||||||
teachers = "("
|
|
||||||
teacher_members = searchTeacherAndAssistant(@course)
|
|
||||||
teacher_members.each do |member|
|
|
||||||
if member == teacher_members.last
|
|
||||||
teachers += member.user_id.to_s + ")"
|
|
||||||
else
|
|
||||||
teachers += member.user_id.to_s + ","
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@cur_size = 0
|
@cur_size = 0
|
||||||
@bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
|
@bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.rater_id is_teacher_score = 0").count}
|
||||||
end
|
end
|
||||||
@percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100)
|
@percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
@ -22,8 +22,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
#获取未批作业列表
|
#获取未批作业列表
|
||||||
def get_not_batch_homework
|
def get_not_batch_homework
|
||||||
sort, direction = params[:sort] || "s_socre", params[:direction] || "desc"
|
sort, direction = params[:sort] || "s_socre", params[:direction] || "desc"
|
||||||
teachers = find_course_teachers @course
|
get_not_batch_homework_list sort,direction, @bid.id
|
||||||
get_not_batch_homework_list sort,direction,teachers, @bid.id
|
|
||||||
@cur_page = params[:page] || 1
|
@cur_page = params[:page] || 1
|
||||||
@cur_type = 1
|
@cur_type = 1
|
||||||
@direction = direction == 'asc'? 'desc' : 'asc'
|
@direction = direction == 'asc'? 'desc' : 'asc'
|
||||||
|
@ -42,10 +41,9 @@ class HomeworkAttachController < ApplicationController
|
||||||
elsif sort == 'time'
|
elsif sort == 'time'
|
||||||
order_by = "created_at #{direction}"
|
order_by = "created_at #{direction}"
|
||||||
end
|
end
|
||||||
teachers = find_course_teachers @course
|
|
||||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
|
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 is_teacher_score = 1 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
|
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score
|
||||||
FROM homework_attaches WHERE bid_id = #{@bid.id}
|
FROM homework_attaches WHERE bid_id = #{@bid.id}
|
||||||
ORDER BY #{order_by}) AS table1
|
ORDER BY #{order_by}) AS table1
|
||||||
WHERE table1.t_score IS NOT NULL")
|
WHERE table1.t_score IS NOT NULL")
|
||||||
|
@ -68,10 +66,9 @@ class HomeworkAttachController < ApplicationController
|
||||||
elsif sort == 'time'
|
elsif sort == 'time'
|
||||||
order_by = "created_at #{direction}"
|
order_by = "created_at #{direction}"
|
||||||
end
|
end
|
||||||
teachers = find_course_teachers @course
|
|
||||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
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 is_teacher_score = 1) 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
|
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score
|
||||||
FROM homework_attaches WHERE bid_id = #{@bid.id}
|
FROM homework_attaches WHERE bid_id = #{@bid.id}
|
||||||
ORDER BY #{order_by}")
|
ORDER BY #{order_by}")
|
||||||
@cur_page = params[:page] || 1
|
@cur_page = params[:page] || 1
|
||||||
|
@ -86,10 +83,9 @@ class HomeworkAttachController < ApplicationController
|
||||||
#获取学生匿评列表
|
#获取学生匿评列表
|
||||||
def get_student_batch_homework
|
def get_student_batch_homework
|
||||||
@is_student_batch_homework = true
|
@is_student_batch_homework = true
|
||||||
teachers = find_course_teachers @course
|
|
||||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
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 is_teacher_score = 1) 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,
|
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score,
|
||||||
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score
|
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score
|
||||||
FROM homework_attaches
|
FROM homework_attaches
|
||||||
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
|
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
|
||||||
|
@ -105,17 +101,16 @@ class HomeworkAttachController < ApplicationController
|
||||||
#获取我的作业
|
#获取我的作业
|
||||||
def get_my_homework
|
def get_my_homework
|
||||||
@is_my_homework = true
|
@is_my_homework = true
|
||||||
teachers = find_course_teachers @course
|
|
||||||
all_homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*,
|
all_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 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 is_teacher_score = 1) 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
|
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score
|
||||||
FROM homework_attaches
|
FROM homework_attaches
|
||||||
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_attaches.user_id = #{User.current.id}")
|
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_attaches.user_id = #{User.current.id}")
|
||||||
#如果我没有创建过作业,就检索我是否参与了某个作业
|
#如果我没有创建过作业,就检索我是否参与了某个作业
|
||||||
if all_homework_list.empty?
|
if all_homework_list.empty?
|
||||||
all_homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*,
|
all_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 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 is_teacher_score = 1) 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
|
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score
|
||||||
FROM homework_attaches
|
FROM homework_attaches
|
||||||
INNER JOIN homework_users ON homework_users.homework_attach_id = homework_attaches.id
|
INNER JOIN homework_users ON homework_users.homework_attach_id = homework_attaches.id
|
||||||
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_users.user_id = #{User.current.id}")
|
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_users.user_id = #{User.current.id}")
|
||||||
|
@ -360,9 +355,8 @@ class HomeworkAttachController < ApplicationController
|
||||||
#我的评分
|
#我的评分
|
||||||
@has_evaluation = @stars_reates.where("rater_id = #{User.current.id}").first
|
@has_evaluation = @stars_reates.where("rater_id = #{User.current.id}").first
|
||||||
@m_score = @has_evaluation.nil? ? 0 : @has_evaluation.stars
|
@m_score = @has_evaluation.nil? ? 0 : @has_evaluation.stars
|
||||||
teachers = find_course_teachers(@course)
|
@teacher_stars = @stars_reates.where("is_teacher_score = 1") #老师评分列表
|
||||||
@teacher_stars = @stars_reates.where("rater_id in (#{teachers})") #老师评分列表
|
@student_stars = @stars_reates.where("is_teacher_score = 0") #学生评分列表
|
||||||
@student_stars = @stars_reates.where("rater_id not in (#{teachers})") #学生评分列表
|
|
||||||
@is_teacher = is_course_teacher User.current,@course
|
@is_teacher = is_course_teacher User.current,@course
|
||||||
@is_anonymous_comments = @bid.comment_status == 1 && !@homework.users.include?(User.current) && @homework.user != User.current && !@is_teacher #判断是不是匿评(开启匿评,当前用户不是作业的创建者或者参与者,不是老师)
|
@is_anonymous_comments = @bid.comment_status == 1 && !@homework.users.include?(User.current) && @homework.user != User.current && !@is_teacher #判断是不是匿评(开启匿评,当前用户不是作业的创建者或者参与者,不是老师)
|
||||||
jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据
|
jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据
|
||||||
|
@ -385,10 +379,9 @@ class HomeworkAttachController < ApplicationController
|
||||||
@journal_destroyed = JournalsForMessage.find(params[:object_id])
|
@journal_destroyed = JournalsForMessage.find(params[:object_id])
|
||||||
if @journal_destroyed.is_comprehensive_evaluation == 3 && @journal_destroyed.destroy
|
if @journal_destroyed.is_comprehensive_evaluation == 3 && @journal_destroyed.destroy
|
||||||
render_403 unless User.current == @journal_destroyed.user || User.current.admin?
|
render_403 unless User.current == @journal_destroyed.user || User.current.admin?
|
||||||
teachers = find_course_teachers(@homework.bid.courses.first)
|
|
||||||
@stars_reates = @homework.rates(:quality)
|
@stars_reates = @homework.rates(:quality)
|
||||||
@teacher_stars = @stars_reates.where("rater_id in (#{teachers})") #老师评分列表
|
@teacher_stars = @stars_reates.where("is_teacher_score = 1)") #老师评分列表
|
||||||
@student_stars = @stars_reates.where("rater_id not in (#{teachers})") #学生评分列表
|
@student_stars = @stars_reates.where("is_teacher_score = 0") #学生评分列表
|
||||||
jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据
|
jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据
|
||||||
@jour = paginateHelper jours,5 #留言
|
@jour = paginateHelper jours,5 #留言
|
||||||
else
|
else
|
||||||
|
@ -426,39 +419,46 @@ class HomeworkAttachController < ApplicationController
|
||||||
@cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5
|
@cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5
|
||||||
@homework = HomeworkAttach.find(params[:homework_id])
|
@homework = HomeworkAttach.find(params[:homework_id])
|
||||||
|
|
||||||
#保存评分
|
#保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0))
|
||||||
@homework.rate(@m_score.to_i,User.current.id,:quality) if @m_score
|
if @m_score
|
||||||
|
if @homework.has_rated?(User.current, :quality)
|
||||||
|
rate = @homework.rates(:quality).where(:rater_id => User.current.id).first
|
||||||
|
rate.stars = @m_score
|
||||||
|
rate.save!
|
||||||
|
else
|
||||||
|
@homework.rates(:quality).new(:stars => @m_score, :rater_id => User.current.id, :is_teacher_score => (@is_teacher ? 1 : 0)).save!
|
||||||
|
end
|
||||||
|
end
|
||||||
#保存评论
|
#保存评论
|
||||||
@is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言
|
@is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言
|
||||||
if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #有没有留言
|
if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #有没有留言
|
||||||
@homework.addjours User.current.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation
|
@homework.addjours User.current.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation
|
||||||
end
|
end
|
||||||
|
|
||||||
teachers = find_course_teachers(@homework.bid.courses.first)
|
|
||||||
@stars_reates = @homework.rates(:quality)
|
@stars_reates = @homework.rates(:quality)
|
||||||
@teacher_stars = @stars_reates.where("rater_id in (#{teachers})") #老师评分列表
|
@teacher_stars = @stars_reates.where("is_teacher_score = 1") #老师评分列表
|
||||||
@student_stars = @stars_reates.where("rater_id not in (#{teachers})") #学生评分列表
|
@student_stars = @stars_reates.where("is_teacher_score = 0") #学生评分列表
|
||||||
jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据
|
jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据
|
||||||
@jour = paginateHelper jours,5 #留言
|
@jour = paginateHelper jours,5 #留言
|
||||||
|
|
||||||
if @cur_type == "1" #如果当前是老师未批列表,需要刷新整个作业列表界面
|
if @cur_type == "1" #如果当前是老师未批列表,需要刷新整个作业列表界面
|
||||||
@bid = @homework.bid
|
@bid = @homework.bid
|
||||||
get_not_batch_homework_list "s_socre","desc",teachers,@homework.bid_id
|
get_not_batch_homework_list "s_socre","desc",@homework.bid_id
|
||||||
elsif @cur_type == "2" #老师已批列表
|
elsif @cur_type == "2" #老师已批列表
|
||||||
@result_homework = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
@result_homework = 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}) 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 is_teacher_score = 1 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
|
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score
|
||||||
FROM homework_attaches WHERE id = #{@homework.id}").first
|
FROM homework_attaches WHERE id = #{@homework.id}").first
|
||||||
elsif @cur_type == "3" #全部作业列表
|
elsif @cur_type == "3" #全部作业列表
|
||||||
@result_homework = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
@result_homework = 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 is_teacher_score = 1) 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
|
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score
|
||||||
FROM homework_attaches WHERE id = #{@homework.id}").first
|
FROM homework_attaches WHERE id = #{@homework.id}").first
|
||||||
elsif @cur_type == "4" #匿评作业列表
|
elsif @cur_type == "4" #匿评作业列表
|
||||||
@is_student_batch_homework = true
|
@is_student_batch_homework = true
|
||||||
@result_homework = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
@result_homework = 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 is_teacher_score = 1) 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,
|
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score,
|
||||||
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score
|
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score
|
||||||
FROM homework_attaches
|
FROM homework_attaches
|
||||||
WHERE homework_attaches.id = #{@homework.id}").first
|
WHERE homework_attaches.id = #{@homework.id}").first
|
||||||
|
@ -552,7 +552,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
teacher_proportion
|
teacher_proportion
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_not_batch_homework_list sort,direction,teachers,bid_id
|
def get_not_batch_homework_list sort,direction,bid_id
|
||||||
if sort == 't_socre'
|
if sort == 't_socre'
|
||||||
order_by = "t_score #{direction}"
|
order_by = "t_score #{direction}"
|
||||||
elsif sort == 's_socre'
|
elsif sort == 's_socre'
|
||||||
|
@ -561,8 +561,8 @@ class HomeworkAttachController < ApplicationController
|
||||||
order_by = "created_at #{direction}"
|
order_by = "created_at #{direction}"
|
||||||
end
|
end
|
||||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
|
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 is_teacher_score = 1) 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
|
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score
|
||||||
FROM homework_attaches WHERE bid_id = #{bid_id}
|
FROM homework_attaches WHERE bid_id = #{bid_id}
|
||||||
ORDER BY #{order_by}) AS table1
|
ORDER BY #{order_by}) AS table1
|
||||||
WHERE table1.t_score IS NULL")
|
WHERE table1.t_score IS NULL")
|
||||||
|
|
Loading…
Reference in New Issue