From 73e9a00a1ae038563104fd619edbd95a920c0359 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 7 Dec 2015 11:25:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8A=A8=E6=80=81=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=9B=9E=E5=A4=8D=E7=9A=84=E5=88=A0=E9=99=A4=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/words_controller.rb | 11 +++++++++-- app/views/users/_course_homework.html.erb | 4 ++++ app/views/users/_user_homework_detail.html.erb | 6 +++++- app/views/words/destroy.js.erb | 10 +++++++++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index f965a0285..df9fd30f2 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -104,8 +104,15 @@ class WordsController < ApplicationController @user = User.find(@journal_destroyed.jour_id) @jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count @is_user = true - elsif @journal_destroyed.jour_ype == 'HomeworkCommon' - + elsif @journal_destroyed.jour_type == 'HomeworkCommon' + @homework = HomeworkCommon.find @journal_destroyed.jour_id + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i end respond_to do |format| format.js diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index a529c4c32..4e8553ee8 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -154,6 +154,10 @@ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> + <% if User.current.admin? ||is_teacher || comment.user == User.current%> + <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "replyGrey fr ml10", :title => l(:button_delete)) %> + <% end %>
<%= comment.notes.html_safe %>
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 539b8b603..23f65e03e 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -95,7 +95,7 @@ <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
  • - <%= link_to("评分设置", score_rule_set_homework_common_path(homework_common, :is_in_course => is_in_course),:class => "postOptionLink", :remote => true) %> + <%= link_to("评分设置", score_rule_set_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=>-1),:class => "postOptionLink", :remote => true) %>
  • <% if homework_common.anonymous_comment == 0 &&(comment_status == 0 || comment_status == 1)%>
  • @@ -161,6 +161,10 @@ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> + <% if User.current.admin? ||is_teacher || comment.user == User.current%> + <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:is_in_course => is_in_course,:course_activity=>-1}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "replyGrey fr ml10", :title => l(:button_delete)) %> + <% end %>
    <%= comment.notes.html_safe %>
    diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index c138a7ea7..7194a16a4 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -1,6 +1,6 @@ <% if @journal_destroyed.nil? %> alert('<%=l(:notice_failed_delete)%>'); -<% elsif (['Principal','Project','Course', 'Bid', 'Contest', 'Softapplication'].include? @journal_destroyed.jour_type)%> +<% elsif (['Principal','Project','Course', 'Bid', 'Contest', 'Softapplication','HomeworkCommon'].include? @journal_destroyed.jour_type)%> <% if @is_user%> var destroyedItem = $('#<%=@journal_destroyed.id%>'); destroyedItem.fadeOut(600,function(){ @@ -13,6 +13,14 @@ $('#course_jour_count').html("(<%= @jours_count %>)"); <% elsif @user && @jours_count%> $('#jour_count').html("<%= @jours_count %>"); + <% elsif @homework%> + <% 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 %> <% end %> var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>') destroyedItem.fadeOut(600,function(){