From be500eb0d274107a5397669499559d3eb532cef6 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 7 Nov 2014 10:02:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=80=E5=90=AF=E5=8C=BF?= =?UTF-8?q?=E8=AF=84=E5=85=B3=E9=97=AD=E5=8C=BF=E8=AF=84=E5=BC=B9=E5=87=BA?= =?UTF-8?q?=E6=A1=86=E5=8A=A8=E6=80=81=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 28 +++++++++++++++++- app/views/bids/_alert_anonyoms.html.erb | 29 +++++++++++++++++++ app/views/bids/_bid_homework_show.html.erb | 11 ++++++- app/views/bids/alert_anonymous_comment.js.erb | 10 +++++++ app/views/bids/start_anonymous_comment.js.erb | 3 +- app/views/bids/stop_anonymous_comment.js.erb | 4 +-- config/routes.rb | 1 + 7 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 app/views/bids/_alert_anonyoms.html.erb create mode 100644 app/views/bids/alert_anonymous_comment.js.erb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 6f71b5d69..96dfc9b25 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -1040,6 +1040,33 @@ class BidsController < ApplicationController @bid.update_column('comment_status', 2) + respond_to do |format| + format.js + end + end + + def alert_anonymous_comment + @bid = Bid.find params[:id] + @course = @bid.courses.first + if @bid.comment_status == 0 + @totle_size = searchStudent(@course).size + @cur_size = @bid.homeworks.size + elsif @bid.comment_status == 1 + @totle_size = 0 + @bid.homeworks.map { |homework| @totle_size += 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 + @cur_size = 0 + @bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count} + end + @percent = format("%.2f",((@cur_size == 0 ? 1 : @cur_size) / @totle_size.to_f) * 100) respond_to do |format| format.js end @@ -1084,6 +1111,5 @@ class BidsController < ApplicationController render_404 end end - end diff --git a/app/views/bids/_alert_anonyoms.html.erb b/app/views/bids/_alert_anonyoms.html.erb new file mode 100644 index 000000000..6ce7845c8 --- /dev/null +++ b/app/views/bids/_alert_anonyoms.html.erb @@ -0,0 +1,29 @@ + + +
+ <% if @bid.comment_status == 0%> +

+ 目前<%= totle_size%>个学生,总共提交了<%= cur_size %>份作业,占<%= percent %> +

+ <% elsif @bid.comment_status == 1%> +

+ 目前总共分配了目前总共分配了<%= totle_size%>份匿评作业,已评价<%= cur_size %>份作业,占<%= percent %> +

+ <% end %> + 确定 + 取消 +
diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index 41dd39e6f..73a9bc6bd 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -34,7 +34,16 @@ <% end %> <% end %> <% if (User.current.admin?||User.current.id==bid.author_id) %> - <%= anonymous_comment_link(bid, @course) %> + + <% case bid.comment_status %> + <% when 0 %> + <%= link_to '启动匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, disable_with: '加载中...' %> + <% when 1 %> + <%= link_to '关闭匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true %> + <% when 2 %> + 匿评结束 + <% end %> + <%= link_to( l(:button_edit), {:action => 'edit', :controller=>'bids', :course_id =>@course.id, :bid_id => bid.id}, diff --git a/app/views/bids/alert_anonymous_comment.js.erb b/app/views/bids/alert_anonymous_comment.js.erb new file mode 100644 index 000000000..0f227727b --- /dev/null +++ b/app/views/bids/alert_anonymous_comment.js.erb @@ -0,0 +1,10 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'alert_anonyoms', locals: { bid: @bid, totle_size:@totle_size, cur_size:@cur_size, percent:@percent}) %>'); +showModal('ajax-modal', '513px'); +$('#ajax-modal').css('height','569px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("alert_box"); \ No newline at end of file diff --git a/app/views/bids/start_anonymous_comment.js.erb b/app/views/bids/start_anonymous_comment.js.erb index 9ae2a712b..5b13b2f77 100644 --- a/app/views/bids/start_anonymous_comment.js.erb +++ b/app/views/bids/start_anonymous_comment.js.erb @@ -1,8 +1,7 @@ <% if @statue == 1%> alert('启动成功'); $("#<%= @bid.id %>_start_anonymous_comment").remove(); - $("#<%= @bid.id %>_anonymous_comment").append('<%= link_to "关闭匿评", stop_anonymous_comment_bid_path(@bid), remote: true, id:"#{@bid.id}_stop_anonymous_comment" %>'); - $("#<%= @bid.id%>_stop_anonymous_comment").attr("data-confirm","关闭匿评后学生将不能对作业进行评分,且学生作业列表将会被公开\n是否确定关闭匿评?"); + $("#<%= @bid.id %>_anonymous_comment").append('<%= link_to "关闭匿评", alert_anonymous_comment_bid_path(@bid), remote: true, id:"#{@bid.id}_stop_anonymous_comment" %>'); <% elsif @statue == 2 %> alert('启动失败\n作业总数大于等于2份时才能启动匿评'); <% elsif @statue == 3%> diff --git a/app/views/bids/stop_anonymous_comment.js.erb b/app/views/bids/stop_anonymous_comment.js.erb index 18081c4ab..0769944ac 100644 --- a/app/views/bids/stop_anonymous_comment.js.erb +++ b/app/views/bids/stop_anonymous_comment.js.erb @@ -1,2 +1,2 @@ -alert('关闭成功') -$("#<%= @bid.id %>_anonymous_comment").html('已关闭匿评') +alert('关闭成功'); +$("#<%= @bid.id %>_anonymous_comment").html('匿评结束'); diff --git a/config/routes.rb b/config/routes.rb index 30662e3dd..5a34319c4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -331,6 +331,7 @@ RedmineApp::Application.routes.draw do match 'homework_ajax_modal' get 'start_anonymous_comment', as: 'start_anonymous_comment' get 'stop_anonymous_comment', as: 'stop_anonymous_comment' + get 'alert_anonymous_comment' end end resources :projects do