1.修复匿评列表查询有错
2.修复当身份改变时修改分数初始分数为之前身份的评分,修改为修改之前身份的评分的BUG 3.是否已经评分判断增加在当前角色下是否已经评分
This commit is contained in:
parent
8dc9b223b1
commit
70083789cb
|
@ -493,17 +493,17 @@ class BidsController < ApplicationController
|
|||
@homework = HomeworkAttach.new
|
||||
@is_teacher = is_course_teacher(User.current,@bid.courses.first)
|
||||
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.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 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 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
|
||||
WHERE table1.t_score IS NULL")
|
||||
@cur_type = 1
|
||||
else
|
||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).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 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 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} AND is_teacher_score = #{@is_teacher ? 1 : 0}) 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} ORDER BY s_score DESC")
|
||||
|
|
|
@ -86,7 +86,7 @@ class HomeworkAttachController < ApplicationController
|
|||
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 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 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} AND is_teacher_score = 0) 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} ORDER BY m_score DESC")
|
||||
|
@ -353,11 +353,11 @@ class HomeworkAttachController < ApplicationController
|
|||
# 作业打分列表
|
||||
@stars_reates = @homework.rates(:quality)
|
||||
#我的评分
|
||||
@has_evaluation = @stars_reates.where("rater_id = #{User.current.id}").first
|
||||
@is_teacher = is_course_teacher User.current,@course
|
||||
@has_evaluation = @stars_reates.where("rater_id = #{User.current.id} and is_teacher_score=#{@is_teacher ? 1 : 0}").first
|
||||
@m_score = @has_evaluation.nil? ? 0 : @has_evaluation.stars
|
||||
@teacher_stars = @stars_reates.where("is_teacher_score = 1") #老师评分列表
|
||||
@student_stars = @stars_reates.where("is_teacher_score = 0") #学生评分列表
|
||||
@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 #判断是不是匿评(开启匿评,当前用户不是作业的创建者或者参与者,不是老师)
|
||||
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 #留言
|
||||
|
@ -418,15 +418,15 @@ class HomeworkAttachController < ApplicationController
|
|||
@is_teacher,@is_anonymous_comments,@m_score = params[:is_teacher]=="true",params[:is_anonymous_comments]=="true",params[:stars_value]
|
||||
@cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5
|
||||
@homework = HomeworkAttach.find(params[:homework_id])
|
||||
|
||||
is_teacher = @is_teacher ? 1 : 0
|
||||
#保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0))
|
||||
if @m_score
|
||||
if @homework.has_rated?(User.current, :quality)
|
||||
rate = @homework.rates(:quality).where(:rater_id => User.current.id).first
|
||||
rate = @homework.rates(:quality).where(:rater_id => User.current.id, :is_teacher_score => is_teacher).first
|
||||
if rate
|
||||
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!
|
||||
@homework.rates(:quality).new(:stars => @m_score, :rater_id => User.current.id, :is_teacher_score => is_teacher).save!
|
||||
end
|
||||
end
|
||||
#保存评论
|
||||
|
@ -445,21 +445,21 @@ class HomeworkAttachController < ApplicationController
|
|||
@bid = @homework.bid
|
||||
get_not_batch_homework_list "s_socre","desc",@homework.bid_id
|
||||
elsif @cur_type == "2" #老师已批列表
|
||||
@result_homework = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
||||
@result_homework = 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 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 is_teacher_score = 0) AS s_score
|
||||
FROM homework_attaches WHERE id = #{@homework.id}").first
|
||||
elsif @cur_type == "3" #全部作业列表
|
||||
@result_homework = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
||||
@result_homework = 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 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 is_teacher_score = 0) AS s_score
|
||||
FROM homework_attaches WHERE id = #{@homework.id}").first
|
||||
elsif @cur_type == "4" #匿评作业列表
|
||||
@is_student_batch_homework = true
|
||||
@result_homework = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
||||
@result_homework = 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 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 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} AND is_teacher_score = #{is_teacher}) AS m_score
|
||||
FROM homework_attaches
|
||||
WHERE homework_attaches.id = #{@homework.id}").first
|
||||
else #其他的不用管
|
||||
|
|
Loading…
Reference in New Issue