老师若未设置测验的发布时间则提交后立即发布
This commit is contained in:
parent
7fb78e4816
commit
c7cf34500c
|
@ -446,6 +446,17 @@ class ExerciseController < ApplicationController
|
||||||
def commit_exercise
|
def commit_exercise
|
||||||
# 老师不需要提交
|
# 老师不需要提交
|
||||||
if User.current.allowed_to?(:as_teacher,@course)
|
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])
|
@exercise.update_attributes(:show_result => params[:show_result])
|
||||||
redirect_to exercise_url(@exercise)
|
redirect_to exercise_url(@exercise)
|
||||||
# REDO: 提示提交成功
|
# REDO: 提示提交成功
|
||||||
|
|
|
@ -122,8 +122,11 @@
|
||||||
alert("截止时间不能小于当前时间");
|
alert("截止时间不能小于当前时间");
|
||||||
} else if($.trim($("#exercise_time").val()) !="" && !/^[1-9][0-9]*$/.test($.trim($("#exercise_time").val()))) {
|
} else if($.trim($("#exercise_time").val()) !="" && !/^[1-9][0-9]*$/.test($.trim($("#exercise_time").val()))) {
|
||||||
alert("测验时长必须为非零开头的数字");
|
alert("测验时长必须为非零开头的数字");
|
||||||
}
|
} else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_publish_time").val()) < Date.now()) {
|
||||||
else {
|
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();
|
doc.parent().parent().parent().submit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,9 @@
|
||||||
<% mc_count = exercise.exercise_questions.where("question_type=1").count %>
|
<% mc_count = exercise.exercise_questions.where("question_type=1").count %>
|
||||||
<% mcq_count = exercise.exercise_questions.where("question_type=2").count %>
|
<% mcq_count = exercise.exercise_questions.where("question_type=2").count %>
|
||||||
<% single_count = exercise.exercise_questions.where("question_type=3").count %>
|
<% single_count = exercise.exercise_questions.where("question_type=3").count %>
|
||||||
<p class="f14">当前测验
|
<p class="f14">当前测验<%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%>总分为<span class="c_red"><%=current_score %></span>分。
|
||||||
<% 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 %>
|
|
||||||
总分为<span class="c_red"><%=current_score %></span>分。
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
是否确定提交该测验?
|
<% if exercise.publish_time.nil? %>点击提交后测验将立即发布,<% end %>是否确定提交该测验?
|
||||||
</p>
|
</p>
|
||||||
<div class="polls_btn_box">
|
<div class="polls_btn_box">
|
||||||
<a class="upload_btn" onclick="exercise_submit();">
|
<a class="upload_btn" onclick="exercise_submit();">
|
||||||
|
|
Loading…
Reference in New Issue