From fe65e3619c95696ef5d447cef588f5bdee84389b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 30 Oct 2014 19:32:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E5=87=BB=E8=AF=84=E5=88=86=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BC=B9=E5=87=BA=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 10 +- app/helpers/courses_helper.rb | 7 +- app/views/bids/_homework_list.html.erb | 2 + .../homework_attach/_homeworks_list.html.erb | 6 +- app/views/homework_attach/_show.html.erb | 128 ++++++++++++++++++ app/views/homework_attach/show.js.erb | 3 + public/stylesheets/css.css | 2 +- 7 files changed, 144 insertions(+), 14 deletions(-) create mode 100644 app/views/homework_attach/_show.html.erb create mode 100644 app/views/homework_attach/show.js.erb 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..545a4e9c2 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -37,5 +37,7 @@ + +