测验的发布日期和测验时长做成可选的

This commit is contained in:
cxt 2015-11-25 09:38:13 +08:00
parent 0e7cf4b122
commit 1ae514ca48
6 changed files with 53 additions and 48 deletions

View File

@ -65,7 +65,6 @@ class ExerciseController < ApplicationController
:end_time => "",
:publish_time => "",
:exercise_description => "",
:show_result => "",
:show_result => 1
}
@exercise = Exercise.create option
@ -104,10 +103,10 @@ class ExerciseController < ApplicationController
def update
@exercise.exercise_name = params[:exercise][:exercise_name]
@exercise.exercise_description = params[:exercise][:exercise_description]
@exercise.time = params[:exercise][:time]
@exercise.time = params[:exercise][:time].blank? ? -1 : params[:exercise][:time]
@exercise.end_time = params[:exercise][:end_time]
@exercise.publish_time = params[:exercise][:publish_time]
@exercise.show_result = params[:exercise][:show_result]
@exercise.show_result = params[:exercise][:show_result].blank? ? 1 : params[:exercise][:show_result]
if @exercise.save
respond_to do |format|
format.js

View File

@ -6,18 +6,17 @@
<%# if edit_mode %>
<!--<label class="fl c_grey f14" style="margin-top: 4px;">发布日期(可选)</label>-->
<%# end %>
<div class="calendar_div fl mr10">
<input type="text" name="exercise[publish_time]" id="exercise_publish_time" placeholder="发布时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if exercise.publish_time %>" >
<%= calendar_for('exercise_publish_time')%>
</div>
<%# if edit_mode %>
<!--<label class="fl c_grey f14" style="margin-top: 4px;">截止日期:</label>-->
<%# end %>
<label class="fl c_grey f14" style="margin-top: 4px;">截止时间:</label>
<div class="calendar_div fl">
<input type="text" name="exercise[end_time]" id="exercise_end_time" placeholder="截止时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d") if exercise.end_time %>" >
<input type="text" name="exercise[end_time]" id="exercise_end_time" placeholder="截止时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d") if exercise.end_time %>"/>
<%= calendar_for('exercise_end_time')%>
</div>
<div class="fl ml10 f14 fontGrey2"><span class="mr5">测验时长:</span><input name="exercise[time]" id="exercise_time" type="text" class="examTime mr5" value="<%=exercise.time %>" />分钟</div>
<div class="fl ml15 f14 fontGrey2"><span class="mr5">测验时长:</span><input name="exercise[time]" id="exercise_time" type="text" class="examTime mr5" placeholder="不填即不限时" value="<%=exercise.time if exercise.time!= -1 %>" />分钟</div>
<label class="fl c_grey ml15 f14" style="margin-top: 4px;">发布时间(可选)</label>
<div class="calendar_div fl">
<input type="text" name="exercise[publish_time]" id="exercise_publish_time" placeholder="发布时间(可选)" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if !exercise.publish_time.nil? %>"/>
<%= calendar_for('exercise_publish_time')%>
</div>
<div class="cl"></div>
<textarea class="testDes mt10" name="exercise[exercise_description]" id="exercise_description" placeholder="发布须知:试题类型有选择和填空两种,其中选择题包括单选题和多选题。您可以在此处填写测验相关说明。" ><%=exercise.exercise_description %></textarea>
<div class="ur_editor_footer" style="padding-top: 10px;">

View File

@ -112,14 +112,10 @@
var title = $.trim($("#exercise_name").val());
if(title.length == 0){
alert("测验标题不能为空");
} else if($.trim($("#exercise_publish_time").val()) =="") {
alert("发布时间不能为空");
} else if($.trim($("#exercise_end_time").val()) =="") {
alert("截止时间不能为空");
} else if($.trim($("#exercise_time").val()) =="") {
alert("考试时长不能为空");
} else if(Date.parse($("#exercise_end_time").val()) <= Date.parse($("#exercise_publish_time").val())) {
alert("截止时间必须大于发布时间");
} else if(Date.parse($("#exercise_end_time").val()) < Date.now()) {
alert("截止时间不能小于当前时间");
}
else {
doc.parent().parent().parent().submit();
@ -162,33 +158,35 @@
}
</script>
<div class="homepageRight mt0 ml10">
<div class="resources">
<!-- 头部 -->
<div id="polls_head_show" style="display: none;">
<%= render :partial => 'show_head', :locals => {:exercise => @exercise}%>
</div>
<div id="polls_head_edit">
<%= render :partial => 'edit_head', :locals => {:exercise => @exercise}%>
</div>
<% current_score = get_current_score @exercise %>
<div class="mb5" style="display: <%= current_score == 0 ? "none" : "" %>" id="current_score_div">目前试卷总分:<span class="c_red" id="current_score"><%=current_score %>分</span></div>
<!-- 问题 -->
<div id="poll_content">
<%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%>
</div>
<div class="resources">
<!-- 头部 -->
<div id="polls_head_show" style="display: none;">
<%= render :partial => 'show_head', :locals => {:exercise => @exercise} %>
</div>
<div id="polls_head_edit">
<%= render :partial => 'edit_head', :locals => {:exercise => @exercise} %>
</div>
<% current_score = get_current_score @exercise %>
<div class="mb5" style="display: <%= current_score == 0 ? "none" : "" %>" id="current_score_div">目前试卷总分:<span class="c_red" id="current_score"><%= current_score %>
分</span></div>
<!-- 问题 -->
<div id="poll_content">
<%= render :partial => 'exercise_content', :locals => {:exercise => @exercise} %>
</div>
<div class="testQuestion" id="new_exercise_question">
<%= render :partial => 'new_question', :locals => {:exercise => @exercise} %>
</div><!--选项 end-->
<div class="testQuestion" id="new_exercise_question">
<%= render :partial => 'new_question', :locals => {:exercise => @exercise} %>
</div>
<!--选项 end-->
<!-- 新增问题 -->
<div id="new_poll_question">
</div>
<!-- 新增问题 -->
<div id="new_poll_question">
</div>
<div id="exercise_submit">
<%= render :partial => 'exercise_submit', :locals => {:exercise => @exercise} %>
<div id="exercise_submit">
<%= render :partial => 'exercise_submit', :locals => {:exercise => @exercise} %>
</div>
<div class="cl"></div>
<!--contentbox end-->
</div>
<div class="cl"></div>
<!--contentbox end-->
</div>
</div><!--编辑end-->

View File

@ -10,9 +10,13 @@
<div class="testStatus"><!--头部显示 start-->
<h1 class="ur_page_title" id="polls_name_h"><%= exercise.exercise_name%></h1>
<div class="fontGrey2">
<span class="mr130">发布时间:<%=format_time(exercise.publish_time.to_s) %></span>
<% unless exercise.publish_time.nil? %>
<span class="mr130">发布时间:<%=format_time(exercise.publish_time.to_s) %></span>
<% end %>
<span class="mr130">截止时间:<%=format_time(exercise.end_time.to_s) %></span>
<span class="fr">测验时长:<%=exercise.time %>分钟</span>
<% if exercise.time != -1 %>
<span class="fr">测验时长:<%=exercise.time %>分钟</span>
<% end %>
</div>
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
<div class="cl"></div>

View File

@ -3,9 +3,14 @@
<!-- <a class='ur_icon_add' title='导入' id="import_btn" onclick="importPoll();"></a> -->
<h1 class="ur_page_title" id="polls_name_h"><%= exercise.exercise_name%></h1>
<div class="fontGrey2">
<span class="mr100">发布时间:<%=Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%></span>
<% unless exercise.publish_time.nil? %>
<span class="mr100">发布时间:<%=Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%></span>
<% end %>
<span class="mr100">截止时间:<%=Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %></span>
<span>测验时长:<%= exercise.time %>分钟</span></div>
<% if exercise.time != -1 %>
<span>测验时长:<%= exercise.time %>分钟</span>
<% end %>
</div>
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
<div class="cl"></div>
<div class="cl"></div>

View File

@ -1156,7 +1156,7 @@ a:hover.btn_cancel{ color:#666;}
.mr118 {margin-right:118px !important;}
.questionContainer {width:698px; border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px;}
.questionTitle{ width:644px; height:30px; border:1px solid #cbcbcb; padding-left:5px; background:#fff;}
.examTime {width:40px; border:1px solid #cbcbcb; outline:none; height:28px; text-align:center; padding-left:0px; }
.examTime {width:90px; border:1px solid #cbcbcb; outline:none; height:28px; text-align:center; padding-left:0px; }
.testStatus{width:698px; border:1px solid #cbcbcb; padding:10px; margin-bottom:10px; background:#ffffff; position:relative; color:#767676;}
.testEdit{ background:url(images/icons.png) 0px -272px no-repeat; width:16px; height:27px; display:block;float:right; bottom:10px; right:10px; position:absolute;}
a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;}