编辑作业时点击取消和发送按钮后的页面跳转

This commit is contained in:
cxt 2015-11-04 10:45:02 +08:00
parent ec42f9413c
commit c8eb0a076f
8 changed files with 53 additions and 16 deletions

View File

@ -6,8 +6,8 @@ class HomeworkCommonController < ApplicationController
include StudentWorkHelper
before_filter :find_course, :only => [:index,:new,:create]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment]
before_filter :member_of_course, :only => [:index]
def index
@ -38,6 +38,7 @@ class HomeworkCommonController < ApplicationController
def edit
@user = User.current
@is_in_course = params[:is_in_course].to_i
@course_activity = params[:course_activity].to_i
respond_to do |format|
format.html{render :layout => 'new_base_user'}
end
@ -88,8 +89,12 @@ class HomeworkCommonController < ApplicationController
@homework_detail_programing.save if @homework_detail_programing
if params[:is_in_course] == "1"
redirect_to homework_common_index_path(:course => @course.id)
else
elsif params[:is_in_course] == "0"
redirect_to user_homeworks_user_path(User.current.id)
elsif params[:is_in_course] == "-1" && params[:course_activity] == "0"
redirect_to user_path(User.current.id)
elsif params[:is_in_course] == "-1" && params[:course_activity] == "1"
redirect_to course_path(@course.id)
end
end
end
@ -101,8 +106,12 @@ class HomeworkCommonController < ApplicationController
format.html {
if params[:is_in_course] == "1"
redirect_to homework_common_index_path(:course => @course.id)
else
elsif params[:is_in_course] == "0"
redirect_to user_homeworks_user_path(User.current.id)
elsif params[:is_in_course] == "-1" && params[:course_activity] == "0"
redirect_to user_path(User.current.id)
elsif params[:is_in_course] == "-1" && params[:course_activity] == "1"
redirect_to course_path(@course.id)
end
}
end
@ -184,6 +193,19 @@ class HomeworkCommonController < ApplicationController
end
end
def alert_forbidden_anonymous_comment
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] if params[:is_in_course]
@course_activity = params[:course_activity] if params[:course_Activity]
respond_to do |format|
format.js
end
end
def programing_test
test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]}
@index = params[:index]

View File

@ -2,6 +2,6 @@
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>");
init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%");
<% else%>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>");
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>");
init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%");
<% end %>

View File

@ -1,3 +1,3 @@
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>");
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
init_activity_KindEditor_data('<%= @user_activity_id%>',"","87%");

View File

@ -8,6 +8,17 @@
homework_description_editor.html("");
$("#homework_editor").toggle();
}
function cancel_edit(){
<% if @is_in_course == 1 %>
window.location.href='<%=homework_common_index_path(:course => @course.id) %>';
<% elsif @is_in_course == 0 %>
window.location.href='<%=user_homeworks_user_path(User.current.id) %>';
<% elsif @is_in_course == -1 && @course_activity == 0 %>
window.location.href='<%=user_path(User.current.id) %>';
<% elsif @is_in_course == -1 && @course_activity == 1 %>
window.location.href='<%=course_path(@course.id) %>';
<% end %>
}
</script>
<div class="homepageRightBanner mb10">
<div class="NewsBannerName">编辑作业</div>
@ -18,6 +29,7 @@
<div class="HomeWork mb10">
<%= form_for @homework do |f| %>
<input type="text" name="is_in_course" class="none" value="<%= @is_in_course%>"/>
<input type="text" name="course_activity" class="none" value="<%= @course_activity%>"/>
<div id="HomeWorkCon">
<%= render :partial => 'users/user_homework_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
</div>

View File

@ -1,3 +1,3 @@
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>");
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id}) %>");
init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%");

View File

@ -1,6 +1,6 @@
<%if @project%>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>");
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%elsif @course%>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>");
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%end%>
init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%");

View File

@ -40,10 +40,12 @@
<span class="f14 fontGrey3 mr10">教辅评分</span>
<%= select_tag :ta_proportion,options_for_select(ta_proportion_option_to(100-(homework.homework_detail_programing ? homework.homework_detail_programing.ta_proportion * 100 : 0).to_i),homework.homework_detail_manual.ta_proportion), {:class => "markPercentage"} %>
</div>
<div>
<span class="f14 fontGrey3 mr10">学生匿评</span>
<input type="text" id="student_proportion" value="<%= (100 - homework.homework_detail_manual.ta_proportion * 100).to_i - (homework.homework_detail_programing ? homework.homework_detail_programing.ta_proportion * 100 : 0).to_i%>%" class="markPercentage" readonly>
</div>
<% if homework.anonymous_comment == 0 %>
<div>
<span class="f14 fontGrey3 mr10">学生匿评</span>
<input type="text" id="student_proportion" value="<%= (100 - homework.homework_detail_manual.ta_proportion * 100).to_i - (homework.homework_detail_programing ? homework.homework_detail_programing.ta_proportion * 100 : 0).to_i%>%" class="markPercentage" readonly>
</div>
<% end %>
<div class="mb20">
<span class="f14 fontGrey3 mr10">教师优先</span>
<input type="checkbox" name="teacher_priority" <%= homework.teacher_priority == 1 ? 'checked' : ''%>/>
@ -51,7 +53,7 @@
</div>
<div>
<div class="courseSendSubmit">
<a href="javascript:void(0);" class="sendSourceText" onclick="$('#ajax-modal').find('form').submit();">确定</a>
<a href="javascript:void(0);" class="sendSourceText" onclick="$('#ajax-modal').find('form').submit();clickCanel();">确定</a>
</div>
<div class="courseSendCancel">
<a href="javascript:void(0);" class="sendSourceText linkGrey6" onclick="clickCanel();">取消</a>

View File

@ -56,8 +56,9 @@
<% if edit_mode %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_homework('edit_homework_common_<%= homework.id%>');">确定</a>
<span class="fr mr10 mt3">或</span>
<%= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%>
<% else %>
<%#= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="cancel_edit();">取消</a>
<% else %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_homework('new_homework_common');">发送</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class=" fr mr10 mt3" onclick="reset_homework();">取消</a>