diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 4b6a84b57..b4b89bb0f 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 72d49adf4..26c82491d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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