教师在课程内编辑、删除作业之后仍然跳转回当前课程作业列表

This commit is contained in:
sw 2015-09-19 10:45:42 +08:00
parent 3e57aa1392
commit 7ba27026ae
4 changed files with 18 additions and 6 deletions

View File

@ -137,6 +137,7 @@ class HomeworkCommonController < ApplicationController
def edit
@user = User.current
@is_in_course = params[:is_in_course]
respond_to do |format|
format.html{render :layout => 'new_base_user'}
end
@ -173,7 +174,11 @@ class HomeworkCommonController < ApplicationController
if @homework.save
@homework_detail_manual.save if @homework_detail_manual
@homework_detail_programing.save if @homework_detail_programing
redirect_to user_homeworks_user_path(User.current.id)
if params[:is_in_course] == "1"
redirect_to homework_common_index_path(:course => @course.id)
else
redirect_to user_homeworks_user_path(User.current.id)
end
end
end
end
@ -181,7 +186,13 @@ class HomeworkCommonController < ApplicationController
def destroy
if @homework.destroy
respond_to do |format|
format.html {redirect_to user_homeworks_user_path(User.current.id)}
format.html {
if params[:is_in_course] == "1"
redirect_to homework_common_index_path(:course => @course.id)
else
redirect_to user_homeworks_user_path(User.current.id)
end
}
end
end
end

View File

@ -16,6 +16,7 @@
<!-- 老师身份才可以发布作业 -->
<div class="HomeWork mb10">
<%= form_for @homework do |f| %>
<input type="text" name="is_in_course" class="none" value="<%= @is_in_course%>"/>
<div id="HomeWorkCon">
<%= render :partial => 'users/user_homework_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
</div>

View File

@ -26,8 +26,8 @@
</p>
<% if @is_teacher%>
<%= homework_anonymous_comment(homework)%>
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "fr mr10 work_edit") %>
<%= link_to(l(:button_edit),edit_homework_common_path(homework), :class => "fr mr10 work_edit") %>
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework,:is_in_course => 1),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "fr mr10 work_edit") %>
<%= link_to(l(:button_edit),edit_homework_common_path(homework,:is_in_course => 1), :class => "fr mr10 work_edit") %>
<% elsif @is_student%>
<%= student_anonymous_comment homework %>
<%= student_new_homework homework %>

View File

@ -59,10 +59,10 @@
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<%= link_to l(:button_edit),edit_homework_common_path(homework_common), :class => "postOptionLink"%>
<%= link_to l(:button_edit),edit_homework_common_path(homework_common,:is_in_course => 0), :class => "postOptionLink"%>
</li>
<li>
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => 0),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
</li>
<li>
<%= homework_anonymous_comment homework_common %>