1.优化作业显示界面加载效率

2.修复获取作业的互评得分、综评得分、教师评分不准确的问题
This commit is contained in:
sw 2014-07-19 16:38:29 +08:00
parent 6186ff343e
commit ba66cde840
2 changed files with 32 additions and 13 deletions

View File

@ -357,26 +357,44 @@ module CoursesHelper
#获取作业的互评得分 #获取作业的互评得分
def student_score_for_homework homework def student_score_for_homework homework
member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first #member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
if member.nil? #if member.nil?
return "0.00" # return "0.00"
#end
#student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars")
members = searchStudent(homework.bid.courses.first)
user_ids = []
members.each do |user|
user_ids << user.user_id
end end
student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars") student_stars = homework.rates(:quality).where("rater_id in (:user_ids)",{:user_ids => user_ids}).select("stars")
student_stars_count = 0 student_stars_count = 0
student_stars.each do |star| student_stars.each do |star|
student_stars_count = student_stars_count + star.stars student_stars_count = student_stars_count + star.stars
end end
return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count)) return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count))
end end
#获取作业的教师评分 #获取作业的教师评分
#多个教师只获取一份教师评分
def teacher_score_for_homework homework def teacher_score_for_homework homework
member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first members = searchTeacherAndAssistant(homework.bid.courses.first)#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
if member.nil? #if member.nil?
return "0.00" # return "0.00"
#end
teacher_ids = []
members.each do |user|
teacher_ids << user.user_id
end end
teacher_stars = homework.rates(:quality).where("rater_id = #{member.user_id}").select("stars").first teacher_stars = homework.rates(:quality).where("rater_id in (:teacher_ids)",{:teacher_ids => teacher_ids}).select("stars")
return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars) teacher_stars_count = 0
teacher_stars.each do |star|
teacher_stars_count = teacher_stars_count + star.stars
end
return format("%.2f",teacher_stars_count)
end end
#获取指定项目的得分 #获取指定项目的得分

View File

@ -117,9 +117,9 @@
</td> </td>
<td> <td>
<strong>互评得分:&nbsp; <strong>互评得分:&nbsp;
<% student_homework_score = student_score_for_homework(homework) %> <%# student_homework_score = student_score_for_homework(homework) %>
<span style="color:<%= student_homework_score == "0.00"? "#727272" : "#EC6300"%>;"> <span style="color:<%= homework.s_score.nil? ? "#727272" : "#EC6300"%>;">
<% score = student_homework_score == "0.00"? "N/A" : student_homework_score %> <% score = homework.s_score.nil? ? "N/A" : format("%.2f",homework.s_score) %>
<%= score %> <%= score %>
</span>&nbsp;&nbsp; </span>&nbsp;&nbsp;
<% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%> <% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%>
@ -136,7 +136,8 @@
</td> </td>
<td> <td>
<strong>终评得分:&nbsp; <strong>终评得分:&nbsp;
<% totle_homework_score = score_for_homework(homework) %> <%# totle_homework_score = score_for_homework(homework) %>
<% totle_homework_score = format("%.2f",(homework.t_score.nil? ? 0.00 : homework.t_score) * (@bid.proportion * 1.0 / 100) + (homework.s_score.nil? ? 0.00 : homework.s_score) * (1 - @bid.proportion * 1.0 / 100)) %>
<span style="color:<%= totle_homework_score == "0.00"? "#727272" : "#EC6300"%> ;"> <span style="color:<%= totle_homework_score == "0.00"? "#727272" : "#EC6300"%> ;">
<% score = totle_homework_score == "0.00"? "N/A" : totle_homework_score %> <% score = totle_homework_score == "0.00"? "N/A" : totle_homework_score %>
<%= score %> <%= score %>