增加开启匿评关闭匿评弹出框动态显示

This commit is contained in:
sw 2014-11-07 10:02:13 +08:00
parent 54aae26cbe
commit be500eb0d2
7 changed files with 80 additions and 6 deletions

View File

@ -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

View File

@ -0,0 +1,29 @@
<script type="text/javascript">
function clickOK()
{
hideModal("#alert_div");
$.ajax({
type: "GET",
url: "<%= bid.comment_status == 0 ? start_anonymous_comment_bid_path(bid) : stop_anonymous_comment_bid_path(bid)%>",
data: 'text',
success: function (data) {
}
});
}
function clickCanel(){hideModal("#alert_div");}
</script>
<div id="alert_div">
<% if @bid.comment_status == 0%>
<p>
目前<%= totle_size%>个学生,总共提交了<%= cur_size %>份作业,占<%= percent %>
</p>
<% elsif @bid.comment_status == 1%>
<p>
目前总共分配了目前总共分配了<%= totle_size%>份匿评作业,已评价<%= cur_size %>份作业,占<%= percent %>
</p>
<% end %>
<a onclick="clickOK();">确定</a>
<a onclick="clickCanel();">取消</a>
</div>

View File

@ -34,7 +34,16 @@
<% end %>
<% end %>
<% if (User.current.admin?||User.current.id==bid.author_id) %>
<%= anonymous_comment_link(bid, @course) %>
<span id="<%=bid.id %>_anonymous_comment">
<% 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 %>
</span>
<%= link_to(
l(:button_edit),
{:action => 'edit', :controller=>'bids', :course_id =>@course.id, :bid_id => bid.id},

View File

@ -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("<span style='float: right;cursor:pointer;padding-left: 513px;'>" +
"<a href='#' onclick='hidden_homework_atert_form("+
<%= @cur_page%> + "," + <%= @cur_type%> +
");'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("alert_box");

View File

@ -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%>

View File

@ -1,2 +1,2 @@
alert('关闭成功')
$("#<%= @bid.id %>_anonymous_comment").html('已关闭匿评')
alert('关闭成功');
$("#<%= @bid.id %>_anonymous_comment").html('匿评结束');

View File

@ -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