diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 06bc1fd38..351feb979 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -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 diff --git a/app/views/homework_common/new.html.erb b/app/views/homework_common/new.html.erb index 6a67c17d1..bace02de9 100644 --- a/app/views/homework_common/new.html.erb +++ b/app/views/homework_common/new.html.erb @@ -1,45 +1,29 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor" %> <%= error_messages_for 'homework_common' %> -

<%= l(:label_course_homework_new)%>

-

请选择将要发布的作业类型 -

- 人工评分的作业(支持匿名互评、灵活设置评分比例) -
- 自动评测的编程作业(支持C++程序的自动评分) -
- 下一步 + <%= form_for("new_homework_common",:url => next_step_homework_common_index_path) do |f|%> + +

+ 请选择将要发布的作业类型 +

+ + + 人工评分的作业(支持匿名互评、灵活设置评分比例) + +
+ + + 自动评测的编程作业(支持C++程序的自动评分) + +
+ + 下一步 + + <% end%>
-
- -
-
- <%= 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 } %> - 提交 - 上一步 - <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> - <% end%> -
-
-
-
-
- <%= 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 } %> - 提交 - 上一步 - <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> - <% end%> -
-
-
\ No newline at end of file +
\ No newline at end of file diff --git a/app/views/homework_common/next_step.html.erb b/app/views/homework_common/next_step.html.erb new file mode 100644 index 000000000..148379f9e --- /dev/null +++ b/app/views/homework_common/next_step.html.erb @@ -0,0 +1,31 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<%= error_messages_for 'homework_common' %> +
+

+ <%= l(:label_course_homework_new)%> +

+
+<% if @homework_type == "1"%> +
+ <%= 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 } %> + 提交 + <%= 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%> +
+<% elsif @homework_type == "2"%> +
+ <%= 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 } %> + 提交 + <%= 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%> +
+
+<% end%> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c92c732d2..dcdca73d4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -85,7 +85,7 @@ RedmineApp::Application.routes.draw do get 'alert_anonymous_comment' end collection do - + post 'next_step' end end diff --git a/public/javascripts/course.js b/public/javascripts/course.js index b493277fd..62769f2f5 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -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) { + } + ); } //新建作业,上一步按钮