启动匿评和关闭匿评时自动刷新该动态

This commit is contained in:
cxt 2015-11-06 14:57:39 +08:00
parent c08c327f73
commit 5d03a27170
8 changed files with 41 additions and 17 deletions

View File

@ -147,6 +147,9 @@ class HomeworkCommonController < ApplicationController
else
@statue = 3
end
@user_activity_id = params[:user_activity_id].to_i
@is_in_course = params[:is_in_course].to_i
@course_activity = params[:course_activity].to_i
end
#关闭匿评
@ -162,6 +165,9 @@ class HomeworkCommonController < ApplicationController
# 匿评关闭消息邮件通知
send_message_anonymous_comment(@homework, m_status = 3)
Mailer.send_mail_anonymous_comment_close(@homework).deliver
@user_activity_id = params[:user_activity_id].to_i
@is_in_course = params[:is_in_course].to_i
@course_activity = params[:course_activity].to_i
respond_to do |format|
format.js
end
@ -188,6 +194,9 @@ class HomeworkCommonController < ApplicationController
@homework.student_works.map { |work| @cur_size += work.student_works_scores.where(:reviewer_role => 3).count}
end
@percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100)
@user_activity_id = params[:user_activity_id].to_i
@is_in_course = params[:is_in_course].to_i
@course_activity = params[:course_activity].to_i
respond_to do |format|
format.js
end

View File

@ -2307,15 +2307,15 @@ module ApplicationHelper
end
#获取匿评相关连接代码
def homework_anonymous_comment homework
def homework_anonymous_comment (homework, is_in_course, user_activity_id = -1, course_activity = -1)
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "作业截止日期之前不可以启动匿评"
elsif homework.student_works.count >= 2 && homework.homework_detail_manual#作业份数大于2
case homework.homework_detail_manual.comment_status
when 1
link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink'
link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink'
when 2
link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink'
link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink'
when 3
# link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束"
end

View File

@ -57,12 +57,12 @@ module HomeworkCommonHelper
end
#根据传入作业确定跳转到开启匿评还是关闭匿评功能
def alert_anonyoms_path homework,homework_detail_manual
def alert_anonyoms_path homework,homework_detail_manual,user_activity_id,is_in_course,course_activity
link = ""
if homework_detail_manual.comment_status == 1
link = start_anonymous_comment_homework_common_url homework.id
link = start_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity
elsif homework_detail_manual.comment_status == 2
link = stop_anonymous_comment_homework_common_url homework.id
link = stop_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity
end
link
end

View File

@ -34,7 +34,7 @@
</p>
<% end %>
<div class="ni_btn">
<a href="javascript:" class="tijiao" onclick="clickOK('<%= alert_anonyoms_path @homework,@homework_detail_manual%>');" style="margin-bottom: 20px;" >
<a href="javascript:" class="tijiao" onclick="clickOK('<%= alert_anonyoms_path @homework,@homework_detail_manual,@user_activity_id,@is_in_course,@course_activity%>');" style="margin-bottom: 20px;" >
确&nbsp;&nbsp;定
</a>
<a href="javascript:" class="tijiao" onclick="clickCanel();" style="margin-bottom: 20px;">

View File

@ -1,12 +1,19 @@
<% if @statue == 1%>
alert('启动成功');
$("#<%= @homework.id %>_start_anonymous_comment").replaceWith('<%= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "postOptionLink")%>');
alert('启动成功');
<% if @user_activity_id == -1 %>
$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>");
init_activity_KindEditor_data(<%= @homework.id%>,"","87%");
<% else %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>");
init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%");
<% end %>
/*$("#<%#= @homework.id %>_start_anonymous_comment").replaceWith('<%#= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "postOptionLink")%>');*/
<% elsif @statue == 2 %>
alert('启动失败\n作业总数大于等于2份时才能启动匿评');
alert('启动失败\n作业总数大于等于2份时才能启动匿评');
<% elsif @statue == 3%>
alert("已开启匿评,请务重复开启");
alert("已开启匿评,请务重复开启");
<% elsif @statue == 4%>
alert("您没有权限开启匿评");
alert("您没有权限开启匿评");
<% elsif @statue == 5%>
alert("作业提交截止之后才能启动匿评");
alert("作业提交截止之后才能启动匿评");
<% end %>

View File

@ -1,2 +1,10 @@
$("#<%= @homework.id %>_stop_anonymous_comment").replaceWith('');
alert('关闭成功');
<% if @user_activity_id == -1 %>
$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>");
init_activity_KindEditor_data(<%= @homework.id%>,"","87%");
<% else %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>");
init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%");
<% end %>
/*
$("#<%#= @homework.id %>_stop_anonymous_comment").replaceWith('');*/

View File

@ -93,7 +93,7 @@
<%= link_to("匿评设置", start_evaluation_set_homework_common_path(activity),:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%>
</li>
<li>
<%= homework_anonymous_comment activity %>
<%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %>
</li>
<% end %>
<% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>

View File

@ -100,7 +100,7 @@
<% end %>
<% if homework_common.anonymous_comment == 0%>
<li>
<%= homework_anonymous_comment homework_common %>
<%= homework_anonymous_comment(homework_common, is_in_course) %>
</li>
<% end %>
<% if homework_common.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>