1、新建作业上一步下一步改为页面刷新

2、下一步路由改为post
This commit is contained in:
sw 2015-06-16 14:45:57 +08:00
parent 8f645f840c
commit 61eb3ecc62
5 changed files with 79 additions and 42 deletions

View File

@ -1,6 +1,6 @@
class HomeworkCommonController < ApplicationController
layout "base_courses"
before_filter :find_course, :only => [:index,:new,:create]
before_filter :find_course, :only => [:index,:new,:create,:next_step]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment]
@ -15,6 +15,15 @@ class HomeworkCommonController < ApplicationController
end
def new
respond_to do |format|
format.html
end
end
#新建作业下一步
def next_step
@homework_type = params[:homework_common_type]
@homework = HomeworkCommon.new
@homework.safe_attributes = params[:homework_common]
@homework.late_penalty = 0

View File

@ -1,45 +1,29 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= error_messages_for 'homework_common' %>
<div class="project_r_h">
<h2 class="project_h2">
<%= l(:label_course_homework_new)%>
</h2>
</div>
<div class="hwork_new" id="hwork_new">
<h3 class="c_blue f16 mb10">请选择将要发布的作业类型
</h3>
<input type="radio" class="mb10 fl" name="homework_common_type" id="homework_detail_manual_radio" checked/><span class="ml5 fl">人工评分的作业(支持匿名互评、灵活设置评分比例)</span>
<div class="cl"></div>
<input type="radio" class="mb20 fl" name="homework_common_type" id="homework_detail_programing_radio"/><span class="ml5 fl">自动评测的编程作业支持C++程序的自动评分)</span>
<div class="cl"></div>
<a href="javascript:void(0);" class=" orange_btn" onclick="select_homework_common_type()">下一步</a>
<%= form_for("new_homework_common",:url => next_step_homework_common_index_path) do |f|%>
<input type="hidden" name="course" value="<%= @course.id%>">
<h3 class="c_blue f16 mb10">
请选择将要发布的作业类型
</h3>
<input type="radio" class="mb10 fl" name="homework_common_type" value="1" id="homework_detail_manual_radio" checked/>
<span class="ml5 fl">
人工评分的作业(支持匿名互评、灵活设置评分比例)
</span>
<div class="cl"></div>
<input type="radio" class="mb20 fl" name="homework_common_type" value="2" id="homework_detail_programing_radio"/>
<span class="ml5 fl">
自动评测的编程作业支持C++程序的自动评分)
</span>
<div class="cl"></div>
<a href="javascript:void(0);" class=" orange_btn" onclick="$(this).parent().submit();">
下一步
</a>
<% end%>
</div><!--hwork_new end-->
<div class="cl"></div>
<div id="homework_detail_manual" class="undis">
<div class="hwork_new">
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
<%= hidden_field_tag "course",@course.id%>
<%= hidden_field_tag "homework_common_tyle","homework_detail_manual"%>
<%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
<a href="javascript:void(0);" class="orange_btn_homework fl" onclick="return_homework_common_type()">上一步</a>
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
<% end%>
</div><!--hwork_new end-->
<div class="cl"></div>
</div>
<div id="homework_detail_programing" class="undis">
<div class="hwork_new">
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
<%= hidden_field_tag "course",@course.id%>
<%= hidden_field_tag "homework_common_tyle","homework_detail_programing"%>
<%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
<a href="javascript:void(0);" class="orange_btn_homework fl" onclick="return_homework_common_type()">上一步</a>
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
<% end%>
</div><!--hwork_new end-->
<div class="cl"></div>
</div>
<div class="cl"></div>

View File

@ -0,0 +1,31 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= error_messages_for 'homework_common' %>
<div class="project_r_h">
<h2 class="project_h2">
<%= l(:label_course_homework_new)%>
</h2>
</div>
<% if @homework_type == "1"%>
<div class="hwork_new">
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
<%= hidden_field_tag "course",@course.id%>
<%= hidden_field_tag "homework_common_tyle","homework_detail_manual"%>
<%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
<%= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%>
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
<% end%>
</div><!--hwork_new end-->
<% elsif @homework_type == "2"%>
<div class="hwork_new">
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
<%= hidden_field_tag "course",@course.id%>
<%= hidden_field_tag "homework_common_tyle","homework_detail_programing"%>
<%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
<%= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%>
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
<% end%>
</div><!--hwork_new end-->
<div class="cl"></div>
<% end%>

View File

@ -85,7 +85,7 @@ RedmineApp::Application.routes.draw do
get 'alert_anonymous_comment'
end
collection do
post 'next_step'
end
end

View File

@ -396,15 +396,28 @@ function show_bid_dead_line(year,month,day,divname)
}
//新建作业,下一步按钮
function select_homework_common_type()
function select_homework_common_type(url,course_id)
{
var homework_common_type = "";
if($("#homework_detail_manual_radio").attr("checked") == "checked"){
$("#homework_detail_manual").show();
homework_common_type = "homework_detail_manual";
}
else if($("#homework_detail_programing_radio").attr("checked") == "checked"){
$("#homework_detail_programing").show();
homework_common_type = "homework_detail_programing";
}
$("#hwork_new").hide();
else{
alert("未知错误,请联系管理员");
return;
}
$.get(
url,
{
course: course_id,
homework_common_type: homework_common_type
},
function (data) {
}
);
}
//新建作业,上一步按钮