Merge branch 'szzh' of http://xianbo_trustie2@repository.trustie.net/xianbo/trustie2.git into szzh
This commit is contained in:
commit
36eca5e425
|
@ -492,27 +492,18 @@ class BidsController < ApplicationController
|
|||
if @bid.homework_type
|
||||
@homework = HomeworkAttach.new
|
||||
@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
|
||||
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
|
||||
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.*,
|
||||
(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,
|
||||
(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
|
||||
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} 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")
|
||||
|
@ -1056,17 +1047,8 @@ class BidsController < ApplicationController
|
|||
elsif @bid.comment_status == 1
|
||||
@totle_size = 0
|
||||
@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
|
||||
@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
|
||||
@percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100)
|
||||
respond_to do |format|
|
||||
|
|
|
@ -22,8 +22,7 @@ class HomeworkAttachController < ApplicationController
|
|||
#获取未批作业列表
|
||||
def get_not_batch_homework
|
||||
sort, direction = params[:sort] || "s_socre", params[:direction] || "desc"
|
||||
teachers = find_course_teachers @course
|
||||
get_not_batch_homework_list sort,direction,teachers, @bid.id
|
||||
get_not_batch_homework_list sort,direction, @bid.id
|
||||
@cur_page = params[:page] || 1
|
||||
@cur_type = 1
|
||||
@direction = direction == 'asc'? 'desc' : 'asc'
|
||||
|
@ -42,10 +41,9 @@ class HomeworkAttachController < ApplicationController
|
|||
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,
|
||||
(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 = 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 bid_id = #{@bid.id}
|
||||
ORDER BY #{order_by}) AS table1
|
||||
WHERE table1.t_score IS NOT NULL")
|
||||
|
@ -55,9 +53,31 @@ class HomeworkAttachController < ApplicationController
|
|||
@direction = direction == 'asc'? 'desc' : 'asc'
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.csv {
|
||||
send_data(homework_to_csv(all_homework_list), :type => 'text/csv; header=present', :filename => 'issues.csv')
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def homework_to_csv items
|
||||
encoding = l(:general_csv_encoding)
|
||||
columns = ["student_id","user_name","login","student_num","mail","work_name","teacher_score","ni_score","commit_time"]
|
||||
|
||||
|
||||
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
|
||||
# csv header fields
|
||||
csv << columns.collect {|c| Redmine::CodesetUtil.from_utf8(c, encoding) }
|
||||
# csv lines
|
||||
items.each do |homework|
|
||||
csv << [homework.user.id,Redmine::CodesetUtil.from_utf8(homework.user.lastname.to_s + homework.user.firstname.to_s, encoding),Redmine::CodesetUtil.from_utf8(homework.user.login, encoding),
|
||||
Redmine::CodesetUtil.from_utf8(homework.user.user_extensions.student_id, encoding),Redmine::CodesetUtil.from_utf8(homework.user.mail, encoding),Redmine::CodesetUtil.from_utf8(homework.name, encoding),
|
||||
Redmine::CodesetUtil.from_utf8((homework.t_score.nil? || (homework.t_score && homework.t_score.to_i == 0)) ? l(:label_without_score) : format("%.2f",homework.t_score), encoding),
|
||||
Redmine::CodesetUtil.from_utf8( homework.s_score.nil? ? l(:label_without_score) : format("%.2f",homework.s_score), encoding),Redmine::CodesetUtil.from_utf8(format_time(homework.created_at), encoding)]
|
||||
end
|
||||
end
|
||||
export
|
||||
end
|
||||
|
||||
#获取所有作业列表
|
||||
def get_homeworks
|
||||
sort, direction = params[:sort] || "s_socre", params[:direction] || "desc"
|
||||
|
@ -68,10 +88,9 @@ class HomeworkAttachController < ApplicationController
|
|||
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,
|
||||
(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 = 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 #{order_by}")
|
||||
@cur_page = params[:page] || 1
|
||||
|
@ -86,11 +105,10 @@ class HomeworkAttachController < ApplicationController
|
|||
#获取学生匿评列表
|
||||
def get_student_batch_homework
|
||||
@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.*,
|
||||
(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,
|
||||
(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 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} 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")
|
||||
|
@ -105,17 +123,16 @@ class HomeworkAttachController < ApplicationController
|
|||
#获取我的作业
|
||||
def get_my_homework
|
||||
@is_my_homework = true
|
||||
teachers = find_course_teachers @course
|
||||
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 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 = 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 homework_attaches.bid_id = #{@bid.id} AND homework_attaches.user_id = #{User.current.id}")
|
||||
#如果我没有创建过作业,就检索我是否参与了某个作业
|
||||
if all_homework_list.empty?
|
||||
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 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 = 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
|
||||
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}")
|
||||
|
@ -358,12 +375,11 @@ class HomeworkAttachController < ApplicationController
|
|||
# 作业打分列表
|
||||
@stars_reates = @homework.rates(:quality)
|
||||
#我的评分
|
||||
@has_evaluation = @stars_reates.where("rater_id = #{User.current.id}").first
|
||||
@m_score = @has_evaluation.nil? ? 0 : @has_evaluation.stars
|
||||
teachers = find_course_teachers(@course)
|
||||
@teacher_stars = @stars_reates.where("rater_id in (#{teachers})") #老师评分列表
|
||||
@student_stars = @stars_reates.where("rater_id not in (#{teachers})") #学生评分列表
|
||||
@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_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 #留言
|
||||
|
@ -385,10 +401,9 @@ class HomeworkAttachController < ApplicationController
|
|||
@journal_destroyed = JournalsForMessage.find(params[:object_id])
|
||||
if @journal_destroyed.is_comprehensive_evaluation == 3 && @journal_destroyed.destroy
|
||||
render_403 unless User.current == @journal_destroyed.user || User.current.admin?
|
||||
teachers = find_course_teachers(@homework.bid.courses.first)
|
||||
@stars_reates = @homework.rates(:quality)
|
||||
@teacher_stars = @stars_reates.where("rater_id in (#{teachers})") #老师评分列表
|
||||
@student_stars = @stars_reates.where("rater_id not in (#{teachers})") #学生评分列表
|
||||
@teacher_stars = @stars_reates.where("is_teacher_score = 1)") #老师评分列表
|
||||
@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条件用以兼容历史数据
|
||||
@jour = paginateHelper jours,5 #留言
|
||||
else
|
||||
|
@ -425,41 +440,48 @@ 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])
|
||||
|
||||
#保存评分
|
||||
@homework.rate(@m_score.to_i,User.current.id,:quality) if @m_score
|
||||
is_teacher = @is_teacher ? 1 : 0
|
||||
#保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0))
|
||||
if @m_score
|
||||
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).save!
|
||||
end
|
||||
end
|
||||
#保存评论
|
||||
@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] != "" #有没有留言
|
||||
@homework.addjours User.current.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation
|
||||
end
|
||||
|
||||
teachers = find_course_teachers(@homework.bid.courses.first)
|
||||
@stars_reates = @homework.rates(:quality)
|
||||
@teacher_stars = @stars_reates.where("rater_id in (#{teachers})") #老师评分列表
|
||||
@student_stars = @stars_reates.where("rater_id not in (#{teachers})") #学生评分列表
|
||||
@teacher_stars = @stars_reates.where("is_teacher_score = 1") #老师评分列表
|
||||
@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条件用以兼容历史数据
|
||||
@jour = paginateHelper jours,5 #留言
|
||||
|
||||
if @cur_type == "1" #如果当前是老师未批列表,需要刷新整个作业列表界面
|
||||
@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" #老师已批列表
|
||||
@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 rater_id NOT IN (#{teachers})) AS s_score
|
||||
@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.*,
|
||||
(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
|
||||
@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.*,
|
||||
(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,
|
||||
(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
|
||||
@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} AND is_teacher_score = #{is_teacher}) AS m_score
|
||||
FROM homework_attaches
|
||||
WHERE homework_attaches.id = #{@homework.id}").first
|
||||
else #其他的不用管
|
||||
|
@ -552,7 +574,7 @@ class HomeworkAttachController < ApplicationController
|
|||
teacher_proportion
|
||||
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'
|
||||
order_by = "t_score #{direction}"
|
||||
elsif sort == 's_socre'
|
||||
|
@ -561,8 +583,8 @@ class HomeworkAttachController < ApplicationController
|
|||
order_by = "created_at #{direction}"
|
||||
end
|
||||
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
|
||||
(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 #{order_by}) AS table1
|
||||
WHERE table1.t_score IS NULL")
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class SeemsRateableRates < ActiveRecord::Base
|
||||
attr_accessible :rater_id, :rateable_id, :rateable_type, :stars, :dimension, :is_teacher_score
|
||||
end
|
|
@ -62,11 +62,6 @@
|
|||
:is_student_batch_homework => @is_student_batch_homework}%>
|
||||
</div>
|
||||
</div>
|
||||
<% if @is_teacher %>
|
||||
<!--<div>
|
||||
导出 <a>csv</a>
|
||||
</div>-->
|
||||
<% end %>
|
||||
</div>
|
||||
<div id="show_homework_attach_model"></div>
|
||||
</body>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
a{ text-decoration:none; }
|
||||
a:hover{ }
|
||||
|
||||
|
||||
.alert_box {width:488px;height:550px;position:fixed;z-index:1002;left:50%;top:40%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; padding:5px; overflow:auto; }
|
||||
#popbox{width:488px;height:308px;}
|
||||
.alert .C{width:476px;height:296px;position:absolute;left:5px;top:5px; }
|
||||
.C_top{ margin-top:20px; width:368px; height:100px; background:#e9e9e9; padding:0px 60px; }
|
||||
|
@ -21,7 +21,7 @@
|
|||
.C_top p{ color:#a9aaaa; line-height:22px;}
|
||||
.C_form{ margin:20px 0 0 60px;}
|
||||
.C_form ul li{ font-size:14px; color:#3f3a39; line-height:30px; }
|
||||
.C_form ul li input{ margin-left:30px; border:0px; border:1px solid #e1e1e1; color:#898989; padding-left:5px; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; }
|
||||
.C_form ul li input{ margin-left:20px; border:0px; border:1px solid #e1e1e1; color:#898989; padding-left:5px; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; padding: 0 !important; }
|
||||
.C_form ul li.mB5{ color:#898989; font-size:12px; padding-left:90px;}
|
||||
.width190{ width:190px; height:26px; border-color:#e1e1e1;}
|
||||
.C_form a{ font-size:12px; color:#15bccf; float:left; display:block; height:40px; width:200px; margin-top:25px;}
|
||||
|
@ -35,6 +35,11 @@
|
|||
hideModal(obj);
|
||||
$("#new-watcher-form").submit();
|
||||
}
|
||||
|
||||
function hidden_join_course_form()
|
||||
{
|
||||
hideModal($("#popbox"));
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
@ -55,6 +60,7 @@
|
|||
<li>
|
||||
<span class="tips">课 程 ID:</span>
|
||||
<input class=" width190" name="object_id" id="object_id" type="text" value="" >
|
||||
<input type="text" style="display: none"/>
|
||||
</li>
|
||||
<li class="mB5">课程ID是所在课程网址中显示的序号</li>
|
||||
<li>
|
||||
|
@ -62,8 +68,12 @@
|
|||
<input class=" width190" type="password" name="course_password" id="course_password" value="" >
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="btn" style="margin-left: 50px;" onclick="submit_form(this);"><%= l(:label_new_join) %></a>
|
||||
<a href="#" class="btn" style="margin-left: 20px;" onclick="hideModal(this);"><%= l(:button_cancel)%></a>
|
||||
<a href="#" class="btn" style="margin-left: 50px;" onclick="submit_form(this);">
|
||||
<%= l(:label_new_join) %>
|
||||
</a>
|
||||
<a href="#" class="btn" style="margin-left: 20px;" onclick="hideModal(this);">
|
||||
<%= l(:button_cancel)%>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<% end%>
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_private_course') %>');
|
||||
showModal('ajax-modal', '510px');
|
||||
$('#ajax-modal').css('height','330px');
|
||||
$('#ajax-modal').css('height','330px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'>" +
|
||||
"<a href='#' onclick='hidden_join_course_form();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().removeClass("alert_praise");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("alert_box");
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<tr>
|
||||
<td colspan="2" width="580px">
|
||||
<p class="info-break">
|
||||
<%= h(truncate(strip_tags(e.event_description).gsub(/ /, ' '), length: 30, omission: '...')) %>
|
||||
<%= e.event_description %>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -63,4 +63,10 @@
|
|||
<span style="color: red;">
|
||||
<%= anonymous_comment_notice(@bid, @bid.courses.first) %>
|
||||
</span>
|
||||
<% other_formats_links do |f| %>
|
||||
<%= f.link_to 'CSV', :url => params %>
|
||||
<% end %>
|
||||
<!--<div>
|
||||
导出 <a>csv</a>
|
||||
</div> -->
|
||||
<% end %>
|
||||
|
|
|
@ -55,13 +55,19 @@
|
|||
<% end %>
|
||||
</span>
|
||||
<% unless @course_page.nil? %>
|
||||
<span class="font_welcome_trustie"><%= @course_page.title %> </span>
|
||||
<span class="font_welcome_trustie">
|
||||
<%= @course_page.title %>
|
||||
</span>
|
||||
|
||||
<% if @school_id.nil? and (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) %>
|
||||
<span class="font_welcome_tdescription">, <%= @course_page.description %></span>
|
||||
<span class="font_welcome_tdescription">,
|
||||
<%= @course_page.description %>
|
||||
</span>
|
||||
<% else %>
|
||||
<% if @school_id == "0" %>
|
||||
<span class="font_welcome_tdescription">, <%= @course_page.description %></span>
|
||||
<span class="font_welcome_tdescription">,
|
||||
<%= @course_page.description %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
@ -77,7 +83,11 @@
|
|||
|
||||
|
||||
<div id="J_Slide" class="d-p-index-box d-p-index-hot">
|
||||
<h3><strong><%= l(:lable_hot_course)%></strong></h3>
|
||||
<h3>
|
||||
<strong>
|
||||
<%= l(:lable_hot_course)%>
|
||||
</strong>
|
||||
</h3>
|
||||
|
||||
<% month_now = Time.now.strftime("%m").to_i %>
|
||||
<% year_now = Time.new.strftime("%Y") %>
|
||||
|
@ -86,7 +96,9 @@
|
|||
<% @school_id.nil? ? cur_school_course = [] : cur_school_course = find_miracle_course(10,7,@school_id, year_now, course_term) %>
|
||||
|
||||
<% if cur_school_course.count == 0 %>
|
||||
<span><%= render :partial => 'more_course', :locals => {:school_id => nil}%></span>
|
||||
<span>
|
||||
<%= render :partial => 'more_course', :locals => {:school_id => nil}%>
|
||||
</span>
|
||||
<div class="d-p-projectlist-box">
|
||||
<ul class="d-p-projectlist">
|
||||
<% if User.current.logged? %>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddColumToSeemsRateableRates < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :seems_rateable_rates, :is_teacher_score, :integer, default: 0
|
||||
end
|
||||
end
|
|
@ -0,0 +1,27 @@
|
|||
class ChangeSeemsRateableRates < ActiveRecord::Migration
|
||||
def up
|
||||
Course.all.each do |course|
|
||||
teachers = []
|
||||
course.members.each do |m|
|
||||
teachers << m.user_id if m && m.user && m.user.allowed_to?(:as_teacher,course)
|
||||
end
|
||||
course.homeworks.each do |bid|
|
||||
bid.homeworks.each do |homework|
|
||||
SeemsRateableRates.where("rateable_type = 'HomeworkAttach' and rateable_id = #{homework.id}").each do |rate|
|
||||
if teachers.include?(rate.rater_id)
|
||||
rate.is_teacher_score = 1
|
||||
rate.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
SeemsRateableRates.where("is_teacher_score = 1").each do |rate|
|
||||
rate.is_teacher_score = 0
|
||||
rate.save
|
||||
end
|
||||
end
|
||||
end
|
11
db/schema.rb
11
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20141229081716) do
|
||||
ActiveRecord::Schema.define(:version => 20141229025925) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -977,13 +977,14 @@ ActiveRecord::Schema.define(:version => 20141229081716) do
|
|||
end
|
||||
|
||||
create_table "seems_rateable_rates", :force => true do |t|
|
||||
t.integer "rater_id", :limit => 8
|
||||
t.integer "rater_id", :limit => 8
|
||||
t.integer "rateable_id"
|
||||
t.string "rateable_type"
|
||||
t.float "stars", :null => false
|
||||
t.float "stars", :null => false
|
||||
t.string "dimension"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "is_teacher_score", :default => 0
|
||||
end
|
||||
|
||||
create_table "settings", :force => true do |t|
|
||||
|
|
|
@ -37,9 +37,9 @@ module SeemsRateable
|
|||
|
||||
def update_users_rating(stars, user_id, dimension=nil)
|
||||
obj = rates(dimension).where(:rater_id => user_id).first
|
||||
#current_record = average(dimension)
|
||||
#current_record.avg = (current_record.avg*current_record.cnt - obj.stars + stars) / (current_record.cnt)
|
||||
#current_record.save!
|
||||
current_record = average(dimension)
|
||||
current_record.avg = (current_record.avg*current_record.cnt - obj.stars + stars) / (current_record.cnt)
|
||||
current_record.save!
|
||||
obj.stars = stars
|
||||
obj.save!
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue