From c08c327f7333bf9d9a2fc3335c24f990a124883b Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 6 Nov 2015 11:26:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=81=AB=E7=8B=90=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E5=99=A8=E4=B8=8B=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A=E7=9A=84?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E6=97=A0=E6=B3=95=E8=87=AA=E5=8A=A8=E5=88=B7?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/words_controller.rb | 1 + app/views/users/_course_homework.html.erb | 1 + app/views/words/leave_homework_message.js.erb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 6ad1a66b4..8590b836a 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -272,6 +272,7 @@ class WordsController < ApplicationController format.js{ @user_activity_id = params[:user_activity_id] @is_in_course = params[:is_in_course] + @course_activity = params[:course_activity] @homework_common_id = params[:homework_common_id] } end diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index f442e34e4..f77dd13bf 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -167,6 +167,7 @@
<%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%> <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> + <%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %>
diff --git a/app/views/words/leave_homework_message.js.erb b/app/views/words/leave_homework_message.js.erb index 91525c889..08fed725c 100644 --- a/app/views/words/leave_homework_message.js.erb +++ b/app/views/words/leave_homework_message.js.erb @@ -1,5 +1,5 @@ <% if @user_activity_id %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework_common,:user_activity_id =>@user_activity_id}) %>"); + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework_common,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); <% elsif @homework_common_id && @is_in_course %> $("#homework_common_<%= @homework_common_id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework_common,:is_in_course => @is_in_course}) %>"); From 5d03a27170714fc59f376d01ada6096609ac2ad0 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 6 Nov 2015 14:57:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E5=8C=BF=E8=AF=84?= =?UTF-8?q?=E5=92=8C=E5=85=B3=E9=97=AD=E5=8C=BF=E8=AF=84=E6=97=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=88=B7=E6=96=B0=E8=AF=A5=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 9 +++++++++ app/helpers/application_helper.rb | 6 +++--- app/helpers/homework_common_helper.rb | 6 +++--- .../homework_common/_alert_anonyoms.html.erb | 2 +- .../start_anonymous_comment.js.erb | 19 +++++++++++++------ .../stop_anonymous_comment.js.erb | 12 ++++++++++-- app/views/users/_course_homework.html.erb | 2 +- .../users/_user_homework_detail.html.erb | 2 +- 8 files changed, 41 insertions(+), 17 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 1e68ed2ed..687ef9503 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 795147446..e5cd9b52b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/helpers/homework_common_helper.rb b/app/helpers/homework_common_helper.rb index a03c4ccd7..2d3c72c20 100644 --- a/app/helpers/homework_common_helper.rb +++ b/app/helpers/homework_common_helper.rb @@ -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 diff --git a/app/views/homework_common/_alert_anonyoms.html.erb b/app/views/homework_common/_alert_anonyoms.html.erb index 73f240b02..3b1f6f692 100644 --- a/app/views/homework_common/_alert_anonyoms.html.erb +++ b/app/views/homework_common/_alert_anonyoms.html.erb @@ -34,7 +34,7 @@

<% end %>
- + 确  定 diff --git a/app/views/homework_common/start_anonymous_comment.js.erb b/app/views/homework_common/start_anonymous_comment.js.erb index b0424bf7a..ea63ea12c 100644 --- a/app/views/homework_common/start_anonymous_comment.js.erb +++ b/app/views/homework_common/start_anonymous_comment.js.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/homework_common/stop_anonymous_comment.js.erb b/app/views/homework_common/stop_anonymous_comment.js.erb index 4725d5731..214a157dc 100644 --- a/app/views/homework_common/stop_anonymous_comment.js.erb +++ b/app/views/homework_common/stop_anonymous_comment.js.erb @@ -1,2 +1,10 @@ -$("#<%= @homework.id %>_stop_anonymous_comment").replaceWith(''); -alert('关闭成功'); \ No newline at end of file +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('');*/ diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index f77dd13bf..38a4d6edd 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -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%>
  • - <%= homework_anonymous_comment activity %> + <%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %>
  • <% end %> <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index e920cf409..0c2a28e5c 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -100,7 +100,7 @@ <% end %> <% if homework_common.anonymous_comment == 0%>
  • - <%= homework_anonymous_comment homework_common %> + <%= homework_anonymous_comment(homework_common, is_in_course) %>
  • <% end %> <% if homework_common.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>