From b8c96510792f41cc757ff7a5fdb5b268a5621c0a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 6 Nov 2014 15:50:39 +0800 Subject: [PATCH 1/2] 111 --- app/controllers/bids_controller.rb | 1 + app/helpers/application_helper.rb | 47 +++++++++++++++--------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 334bc3413..6f71b5d69 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -1007,6 +1007,7 @@ class BidsController < ApplicationController # 启动匿评 def start_anonymous_comment @bid = Bid.find(params[:id]) + @course = @bid.courses.first if(@bid.comment_status == 0) homeworks = @bid.homeworks if(homeworks && homeworks.size >= 2) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index eb05c0528..a5ff44417 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1927,31 +1927,30 @@ module ApplicationHelper end def anonymous_comment_notice(bid, course) - link = - case bid.comment_status - when 0 - @student_size ||= searchStudent(course).size - @homework_size = bid.homeworks.size - percent = @homework_size.to_f / @student_size - confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n" - when 1 - @homework_evaluations = 0 - bid.homeworks.map { |homework| @homework_evaluations += homework.homework_evaluations.count} - teachers = "(" - teacher_members = searchTeacherAndAssistant(course) - teacher_members.each do |member| - if member == teacher_members.last - teachers += member.user_id.to_s + ")" - else - teachers += member.user_id.to_s + "," - end - end - @has_evaluations = 0 - bid.homeworks.map { |homework| @has_evaluations += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count} - - percent = @has_evaluations.to_f / @homework_evaluations - confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作业,已评价#{@has_evaluations}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n" + case bid.comment_status + when 0 + @student_size ||= searchStudent(course).size + @homework_size = bid.homeworks.size + percent = @homework_size.to_f / @student_size + confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n" + when 1 + @homework_evaluations = 0 + bid.homeworks.map { |homework| @homework_evaluations += homework.homework_evaluations.count} + teachers = "(" + teacher_members = searchTeacherAndAssistant(course) + teacher_members.each do |member| + if member == teacher_members.last + teachers += member.user_id.to_s + ")" + else + teachers += member.user_id.to_s + "," end + end + @has_evaluations = 0 + bid.homeworks.map { |homework| @has_evaluations += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count} + + percent = @has_evaluations.to_f / @homework_evaluations + confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作业,已评价#{@has_evaluations}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n" + end confirm_info end end From f3edbe4b794b302d82132e0b5d4e530f57d6f5a8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 6 Nov 2014 16:01:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/_bid_homework_show.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index 22645113b..41dd39e6f 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -23,10 +23,10 @@ <%= link_to(bid.name, course_for_bid_path(bid), :class => 'bid_path') %> - <% if(User.current.logged? && (!Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)) %> + <% if User.current.logged? && is_cur_course_student(@course) %> <% cur_user_homework = cur_user_homework_for_bid(bid) %> - <% if cur_user_homework!= nil && cur_user_homework.count == 0 %> - <%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %> + <% if cur_user_homework!= nil && cur_user_homework.empty? %> + <%= link_to l(:label_commit_homework),new_exercise_book_path(bid) %> <% else %> <%= l(:lable_has_commit_homework)%>