diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 6f71b5d69..1de222c7c 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.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) respond_to do |format| format.js end @@ -1084,6 +1111,5 @@ class BidsController < ApplicationController render_404 end end - end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a5ff44417..8544b2cf3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1931,7 +1931,7 @@ module ApplicationHelper when 0 @student_size ||= searchStudent(course).size @homework_size = bid.homeworks.size - percent = @homework_size.to_f / @student_size + percent = @homework_size.to_f / (@student_size == 0 ? 1 : @student_size) confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n" when 1 @homework_evaluations = 0 @@ -1948,7 +1948,7 @@ module ApplicationHelper @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 + percent = @has_evaluations.to_f / (@homework_evaluations == 0 ? 1 : @homework_evaluations) confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作业,已评价#{@has_evaluations}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n" end confirm_info diff --git a/app/views/bids/_alert_anonyoms.html.erb b/app/views/bids/_alert_anonyoms.html.erb new file mode 100644 index 000000000..e533048f5 --- /dev/null +++ b/app/views/bids/_alert_anonyoms.html.erb @@ -0,0 +1,90 @@ + + + + 开启匿评功能 + + + + + + +
+
+ <% 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..2ec98fcc2 --- /dev/null +++ b/app/views/bids/alert_anonymous_comment.js.erb @@ -0,0 +1,8 @@ +$('#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', '500px'); +$('#ajax-modal').css('height','180px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("anonymos"); \ 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/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 5a25cf262..fd1dd3e00 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -16,7 +16,7 @@
<%= l(:label_message_new) %>
- <%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => true, :id => 'message-form'} do |f| %> + <%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => false, :id => 'message-form'} do |f| %> <%= render :partial => 'messages/form', :locals => {:f => f} %>

diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 69b7b6fc9..6a1db48d5 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -106,7 +106,16 @@ <% 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 %> + <% end %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index fa8f46bb0..8a8c9e9ce 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -603,7 +603,7 @@ zh: #by young label_requirement: 需求 label_new_course: 课程列表 - label_course_practice: 课程实践 + label_course_practice: 课程作业 label_course_all: 课程列表 label_teacher_all: 所有教师 label_project_deposit: 项目托管 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