This commit is contained in:
z9hang 2014-07-19 16:53:02 +08:00
commit 162a4cfa84
3 changed files with 33 additions and 14 deletions

View File

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

View File

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

View File

@ -149,7 +149,7 @@
</div>
<div style="padding-bottom: 8px">
<div class="font_lighter_sidebar">
<div class="font_lighter_sidebar" style="word-break:break-all">
<%= textilizable @project.description %>
</div>
<div class="created_on_project">