diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index ce3412caa..6f275530e 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,7 +1,7 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] + before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list,:edit] def index @is_teacher = User.current.allowed_to?(:as_teacher,@course) if @is_teacher @@ -27,10 +27,28 @@ class ExerciseController < ApplicationController end def create - + if params[:exercise] + exercise = Exercise.find(params[:exercise_id]) if params[:exercise_id] + exercise ||= Exercise.new + exercise.exercise_name = params[:exercise][:exercise_name] + exercise.exercise_description = params[:exercise][:exercise_description] + exercise.end_time = params[:exercise][:end_time] + exercise.publish_time = params[:exercise][:publish_time] + exercise.user_id = User.current.id + exercise.time = params[:exercise][:time] + exercise.course_id = params[:course_id] + exercise.exercise_status = 1 + if exercise.save + @exercise = exercise + respond_to do |format| + format.js + end + end + end end def edit + @exercise = Exercise.find params[:id] respond_to do |format| format.html{render :layout => 'base_courses'} end diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index b315d343c..a66d9dbb2 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -1,24 +1,38 @@ -
-
- -
- <%# if edit_mode %> - - <%# end %> -
- - <%= calendar_for('homework_end_time')%> -
- <%# if edit_mode %> - - <%# end %> -
- - <%= calendar_for('homework_publish_time')%> -
-
考试时长:分钟
-
- - 保存 取消 -
-
\ No newline at end of file +<%= form_for(@exercise, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create', + :course_id => @course.id + },:remote=>true ) do |f| %> +
+
+ +
+ <%# if edit_mode %> + + <%# end %> +
+ + <%= calendar_for('exercise_publish_time')%> +
+ <%# if edit_mode %> + + <%# end %> +
+ + <%= calendar_for('exercise_end_time')%> +
+
考试时长:分钟
+
+ + +
+
+<% end %> \ No newline at end of file diff --git a/app/views/exercise/_exercise_content.html.erb b/app/views/exercise/_exercise_content.html.erb index 76bad6a83..bffd7e221 100644 --- a/app/views/exercise/_exercise_content.html.erb +++ b/app/views/exercise/_exercise_content.html.erb @@ -1,5 +1,5 @@ -<% poll.exercise_questions.each do |poll_question|%> +<% exercise.exercise_questions.each do |poll_question|%>
- <%= render :partial => 'edit_head', :locals => {:poll => @exercise}%> + <%= render :partial => 'edit_head', :locals => {:exercise => @exercise}%>
- <%= render :partial => 'exercise_content', :locals => {:poll => @exercise}%> + <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%>
@@ -321,7 +334,11 @@
-
发布 + +
+
+ +
提交
diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index 0082303b7..8ef1e1e04 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -2,23 +2,23 @@
- +
  • - +
  • - +
  • - +
diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb new file mode 100644 index 000000000..f7d2b9295 --- /dev/null +++ b/app/views/exercise/_show_head.html.erb @@ -0,0 +1,6 @@ +
+ +

<%= exercise.exercise_name%>

+ <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%> +
+
\ No newline at end of file diff --git a/app/views/exercise/create.js.erb b/app/views/exercise/create.js.erb new file mode 100644 index 000000000..65b8dd327 --- /dev/null +++ b/app/views/exercise/create.js.erb @@ -0,0 +1,4 @@ +$("#polls_head_show").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:exercise => @exercise}) %>"); +$("#polls_head_edit").html("<%= escape_javascript(render :partial => 'edit_head', :locals => {:exercise => @exercise}) %>"); +$("#polls_head_edit").hide(); +$("#polls_head_show").show(); \ No newline at end of file diff --git a/app/views/exercise/edit.html.erb b/app/views/exercise/edit.html.erb index 0b20dc90e..aef506ad8 100644 --- a/app/views/exercise/edit.html.erb +++ b/app/views/exercise/edit.html.erb @@ -1 +1,2 @@ -<%= render :partial => 'exercise_form'%> \ No newline at end of file +<%#= render :partial => 'exercise_form'%> +111 \ No newline at end of file diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index fdba7426a..da393afaa 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -713,6 +713,7 @@ img.ui-datepicker-trigger { width:16px; height:15px; float:left; + margin: 7px; } .label{ width:80px; text-align:right; font-size:14px; display:block; float:left;} @@ -1146,7 +1147,7 @@ input.sendSourceText { /*20151117在线测验byTim*/ .testContainer {width:698px; border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px;} .testTitle{ width:678px; height:40px; padding:0 10px; text-align:center; font-size:16px; font-weight:bold; background:#fff;border-style:solid; border:1px solid #CBCBCB;} -.testDes{ width:678px; height:120px; padding:10px; margin-bottom:10px; background:#fff; border-style:solid; border:1px solid #CBCBCB; resize:none;} +.testDes{ width:678px; height:60px; padding:10px; margin-bottom:10px; background:#fff; border-style:solid; border:1px solid #CBCBCB; resize:none;} .btn_submit{ width:56px; height:24px; padding-top:4px;background:#269ac9; color:#fff; text-align:center; display:block; float:left; margin-right:10px;} a:hover.btn_submit{background:#297fb8;} .btn_cancel{width:54px; height:22px; padding-top:4px;background:#fff; color:#999; border:1px solid #999; text-align:center; display:block; float:left; }