diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 364742aea..138030a3c 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -268,11 +268,9 @@ class HomeworkAttachController < ApplicationController def show if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first) # 打分统计 - stars_reates = @homework. - rates(:quality) + stars_reates = @homework. rates(:quality) stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count - stars_status = stars_reates.select("stars, count(*) as scount"). - group("stars") + stars_status = stars_reates.select("stars, count(*) as scount").group("stars") @stars_status_map = Hash.new(0.0) stars_status.each do |star_status| percent = (star_status.scount * 1.0/ stars_reates_count) * 100.to_f @@ -294,6 +292,10 @@ class HomeworkAttachController < ApplicationController @totle_score = score_for_homework @homework @teaher_score = teacher_score_for_homework @homework + + respond_to do |format| + format.js + end else render_403 :message => :notice_not_authorized end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 1afb94220..eeedbd19d 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -394,10 +394,7 @@ module CoursesHelper #获取作业的教师评分 #多个教师只获取一份教师评分 def teacher_score_for_homework homework - members = searchTeacherAndAssistant(homework.bid.courses.first)#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first - #if member.nil? - # return "0.00" - #end + members = searchTeacherAndAssistant(homework.bid.courses.first) teacher_ids = [] members.each do |user| teacher_ids << user.user_id @@ -407,7 +404,7 @@ module CoursesHelper teacher_stars.each do |star| teacher_stars_count = teacher_stars_count + star.stars end - return format("%.2f",teacher_stars_count) + return format("%.2f",teacher_stars.count > 0 ? teacher_stars_count/teacher_stars.count : 0) end #获取指定项目的得分 diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 95b805ba3..960e3acff 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -36,6 +36,7 @@ - + +