修复进入课程作业报错的问题

This commit is contained in:
sw 2014-07-10 11:27:06 +08:00
parent 76db0e61c3
commit 65c137e617
2 changed files with 7 additions and 1 deletions

View File

@ -343,6 +343,9 @@ 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"
end
student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars")
student_stars_count = 0
student_stars.each do |star|
@ -354,6 +357,9 @@ module CoursesHelper
#获取作业的教师评分
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"
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)
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140704034832) do
ActiveRecord::Schema.define(:version => 20140708023356) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false