From 61eb3ecc621e90a26bd9398a4fc1a501f1275e63 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Tue, 16 Jun 2015 14:45:57 +0800
Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=BB=BA=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=E4=B8=8A=E4=B8=80=E6=AD=A5=E4=B8=8B=E4=B8=80=E6=AD=A5=E6=94=B9?=
=?UTF-8?q?=E4=B8=BA=E9=A1=B5=E9=9D=A2=E5=88=B7=E6=96=B0=202=E3=80=81?=
=?UTF-8?q?=E4=B8=8B=E4=B8=80=E6=AD=A5=E8=B7=AF=E7=94=B1=E6=94=B9=E4=B8=BA?=
=?UTF-8?q?post?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/homework_common_controller.rb | 11 +++-
app/views/homework_common/new.html.erb | 56 +++++++------------
app/views/homework_common/next_step.html.erb | 31 ++++++++++
config/routes.rb | 2 +-
public/javascripts/course.js | 21 +++++--
5 files changed, 79 insertions(+), 42 deletions(-)
create mode 100644 app/views/homework_common/next_step.html.erb
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) {
+ }
+ );
}
//新建作业,上一步按钮