From c7cf34500ca8d3401c5ea6d35a60d7ec5ddd4723 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 25 Nov 2015 16:05:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=81=E5=B8=88=E8=8B=A5=E6=9C=AA=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B5=8B=E9=AA=8C=E7=9A=84=E5=8F=91=E5=B8=83=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=88=99=E6=8F=90=E4=BA=A4=E5=90=8E=E7=AB=8B=E5=8D=B3?= =?UTF-8?q?=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 11 +++++++++++ app/views/exercise/_exercise_form.html.erb | 7 +++++-- app/views/exercise/_exercise_submit_info.html.erb | 9 ++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 6fcbb0c6c..2c1ad31c1 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -446,6 +446,17 @@ class ExerciseController < ApplicationController def commit_exercise # 老师不需要提交 if User.current.allowed_to?(:as_teacher,@course) + if @exercise.publish_time.nil? + @exercise.update_attributes(:show_result => params[:show_result]) + @exercise.update_attributes(:exercise_status => 2) + @exercise.update_attributes(:publish_time => Time.now) + redirect_to exercise_url(@exercise) + return + elsif Time.parse(@exercise.publish_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") > Time.now.strftime("%Y-%m-%d-%H-%M-%S") + @exercise.update_attributes(:show_result => params[:show_result]) + redirect_to exercise_url(@exercise) + return + end @exercise.update_attributes(:show_result => params[:show_result]) redirect_to exercise_url(@exercise) # REDO: 提示提交成功 diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 6b8e93bd0..66558936a 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -122,8 +122,11 @@ alert("截止时间不能小于当前时间"); } else if($.trim($("#exercise_time").val()) !="" && !/^[1-9][0-9]*$/.test($.trim($("#exercise_time").val()))) { alert("测验时长必须为非零开头的数字"); - } - else { + } else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_publish_time").val()) < Date.now()) { + alert("发布时间不能小于当前时间"); + } else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_end_time").val()) <= Date.parse($("#exercise_publish_time").val())) { + alert("截止时间必须大于发布时间"); + } else { doc.parent().parent().parent().submit(); } } diff --git a/app/views/exercise/_exercise_submit_info.html.erb b/app/views/exercise/_exercise_submit_info.html.erb index 0d7e8928c..0744b4fd1 100644 --- a/app/views/exercise/_exercise_submit_info.html.erb +++ b/app/views/exercise/_exercise_submit_info.html.erb @@ -19,14 +19,9 @@ <% mc_count = exercise.exercise_questions.where("question_type=1").count %> <% mcq_count = exercise.exercise_questions.where("question_type=2").count %> <% single_count = exercise.exercise_questions.where("question_type=3").count %> -

当前测验 - <% if question_count > 0 %>共有<%= question_count %>道题,其中<% end %> - <% if mc_count > 0 %><%= mc_count %>道单选、<% end %> - <% if mcq_count > 0 %><%= mcq_count %>道多选、<% end %> - <% if single_count > 0%><%= single_count %>道填空,<% end %> - 总分为<%=current_score %>分。 +

当前测验<%if question_count >0%>共有<%= question_count %>道题,其中<%end%><%if mc_count > 0%><%=mc_count %>道单选、<%end%><%if mcq_count > 0%><%=mcq_count %>道多选、<%end%><%if single_count > 0%><%=single_count %>道填空,<%end%>总分为<%=current_score %>分。

- 是否确定提交该测验? + <% if exercise.publish_time.nil? %>点击提交后测验将立即发布,<% end %>是否确定提交该测验?