保存测验信息
This commit is contained in:
parent
034a92bb7b
commit
cc08e5e32e
|
@ -1,7 +1,7 @@
|
||||||
class ExerciseController < ApplicationController
|
class ExerciseController < ApplicationController
|
||||||
layout "base_courses"
|
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
|
def index
|
||||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||||
if @is_teacher
|
if @is_teacher
|
||||||
|
@ -27,10 +27,28 @@ class ExerciseController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
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
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@exercise = Exercise.find params[:id]
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html{render :layout => 'base_courses'}
|
format.html{render :layout => 'base_courses'}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,24 +1,38 @@
|
||||||
<div class="testContainer">
|
<%= form_for(@exercise,
|
||||||
<div>
|
:html => { :multipart => true },
|
||||||
<input class="testTitle mb10" type="text" placeholder="测验标题" />
|
:url => {:controller => 'exercise',
|
||||||
</div>
|
:action => 'create',
|
||||||
<%# if edit_mode %>
|
:course_id => @course.id
|
||||||
<!--<label class="fl c_grey f14" style="margin-top: 4px;">截止日期:</label>-->
|
},:remote=>true ) do |f| %>
|
||||||
<%# end %>
|
<div class="testContainer">
|
||||||
<div class="calendar_div fl mr10">
|
<div>
|
||||||
<input type="text" name="homework_common[end_time]" id="homework_end_time" placeholder="截止日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.end_time%>" >
|
<input name="exercise[exercise_name]" maxlength="100" id="exercise_name" class="testTitle mb10" type="text" placeholder="测验标题" value="<%=@exercise.exercise_name%>" />
|
||||||
<%= calendar_for('homework_end_time')%>
|
</div>
|
||||||
</div>
|
<%# if edit_mode %>
|
||||||
<%# if edit_mode %>
|
<!--<label class="fl c_grey f14" style="margin-top: 4px;">发布日期(可选):</label>-->
|
||||||
<!--<label class="fl c_grey f14" style="margin-top: 4px;">发布日期(可选):</label>-->
|
<%# end %>
|
||||||
<%# end %>
|
<div class="calendar_div fl mr10">
|
||||||
<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="<%= exercise.publish_time%>" >
|
||||||
<input type="text" name="homework_common[publish_time]" id="homework_publish_time" placeholder="发布日期(可选)" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.publish_time%>" >
|
<%= calendar_for('exercise_publish_time')%>
|
||||||
<%= calendar_for('homework_publish_time')%>
|
</div>
|
||||||
</div>
|
<%# if edit_mode %>
|
||||||
<div class="fl ml10 f14 fontGrey2"><span class="mr5">考试时长:</span><input type="text" class="examTime mr5" />分钟</div>
|
<!--<label class="fl c_grey f14" style="margin-top: 4px;">截止日期:</label>-->
|
||||||
<div class="cl"></div>
|
<%# end %>
|
||||||
<textarea class="testDes mt10" placeholder="发布须知:试题类型有选择和填空两种,其中选择题包括单选题和多选题。多选题的答案格式为:若标准答案为A,B,C,在答案输入框填入ABC即可。填空题问题格式为:”电脑的核心部件是()?”根据问题设置与答案相关的关键词,系统会根据关键词匹配学生上交的答案,关键词可设置多个。谢谢您的配合(您可以在此处填写测验相关说明)。" ></textarea>
|
<div class="calendar_div fl">
|
||||||
<a href="javascript:void(0);" class="btn_submit c_white" >保存</a> <a href="javascript:void(0);" class="btn_cancel" >取消</a>
|
<input type="text" name="exercise[end_time]" id="exercise_end_time" placeholder="截止时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= exercise.end_time%>" >
|
||||||
<div class="cl"></div>
|
<%= calendar_for('exercise_end_time')%>
|
||||||
</div>
|
</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="cl"></div>
|
||||||
|
<textarea class="testDes mt10" name="exercise[exercise_description]" id="exercise_description" value="<%=exercise.exercise_description %>" placeholder="发布须知:试题类型有选择和填空两种,其中选择题包括单选题和多选题。您可以在此处填写测验相关说明。" ></textarea>
|
||||||
|
<div class="ur_editor_footer" style="padding-top: 10px;">
|
||||||
|
<a class="btn_submit c_white" data-button="ok" onclick="pollsSubmit($(this));">
|
||||||
|
保存
|
||||||
|
</a>
|
||||||
|
<a class="btn_cancel" data-button="cancel" onclick="pollsCancel();">
|
||||||
|
<%= l(:button_cancel)%>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
<% poll.exercise_questions.each do |poll_question|%>
|
<% exercise.exercise_questions.each do |poll_question|%>
|
||||||
<div id="poll_questions_<%= poll_question.id%>">
|
<div id="poll_questions_<%= poll_question.id%>">
|
||||||
<!--<div id="show_poll_questions_<%= poll_question.id %>">
|
<!--<div id="show_poll_questions_<%= poll_question.id %>">
|
||||||
<%# if poll_question.question_type == 1%>
|
<%# if poll_question.question_type == 1%>
|
||||||
|
|
|
@ -244,8 +244,21 @@
|
||||||
//问卷头
|
//问卷头
|
||||||
function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();}
|
function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();}
|
||||||
function pollsSubmit(doc){
|
function pollsSubmit(doc){
|
||||||
var title = $.trim($("#polls_title").val());
|
var title = $.trim($("#exercise_name").val());
|
||||||
if(title.length == 0){alert("测验标题不能为空");}else{doc.parent().parent().parent().submit();}
|
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 {
|
||||||
|
doc.parent().parent().parent().submit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();}
|
function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();}
|
||||||
//
|
//
|
||||||
|
@ -285,7 +298,7 @@
|
||||||
alert("测验标题不能为空");
|
alert("测验标题不能为空");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'poll_submit', locals: { :poll => @exercise,:is_remote => false}) %>');
|
$('#ajax-modal').html('<%#= escape_javascript(render :partial => 'poll_submit', locals: { :poll => @exercise,:is_remote => false}) %>');
|
||||||
showModal('ajax-modal', '310px');
|
showModal('ajax-modal', '310px');
|
||||||
$('#ajax-modal').css('height','120px');
|
$('#ajax-modal').css('height','120px');
|
||||||
$('#ajax-modal').siblings().remove();
|
$('#ajax-modal').siblings().remove();
|
||||||
|
@ -301,15 +314,15 @@
|
||||||
<div class="resources">
|
<div class="resources">
|
||||||
<!-- 头部 -->
|
<!-- 头部 -->
|
||||||
<div id="polls_head_show" style="display: none;">
|
<div id="polls_head_show" style="display: none;">
|
||||||
<%#= render :partial => 'show_head', :locals => {:poll => @exercise}%>
|
<%= render :partial => 'show_head', :locals => {:exercise => @exercise}%>
|
||||||
</div>
|
</div>
|
||||||
<div id="polls_head_edit">
|
<div id="polls_head_edit">
|
||||||
<%= render :partial => 'edit_head', :locals => {:poll => @exercise}%>
|
<%= render :partial => 'edit_head', :locals => {:exercise => @exercise}%>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 问题 -->
|
<!-- 问题 -->
|
||||||
<div id="poll_content">
|
<div id="poll_content">
|
||||||
<%= render :partial => 'exercise_content', :locals => {:poll => @exercise}%>
|
<%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="testQuestion">
|
<div class="testQuestion">
|
||||||
|
@ -321,7 +334,11 @@
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div><!--选项 end-->
|
</div><!--选项 end-->
|
||||||
|
|
||||||
<div class="ur_buttons"> <a class="ur_button_submit" onclick="poll_submit();"> 发布 </a>
|
<!-- 新增问题 -->
|
||||||
|
<div id="new_poll_question">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ur_buttons"> <a class="ur_button_submit" onclick="poll_submit();"> 提交 </a>
|
||||||
<div class="polls_cha">
|
<div class="polls_cha">
|
||||||
<input name="" value="" type="checkbox">
|
<input name="" value="" type="checkbox">
|
||||||
<label for="">允许学生查看测验结果</label>
|
<label for="">允许学生查看测验结果</label>
|
||||||
|
|
|
@ -2,23 +2,23 @@
|
||||||
<div class="ur_editor_title">
|
<div class="ur_editor_title">
|
||||||
<label>问题: </label>
|
<label>问题: </label>
|
||||||
<input name="question_type" value="1" type="hidden">
|
<input name="question_type" value="1" type="hidden">
|
||||||
<input maxlength="250" class="questionTitle" name="poll_questions_title" id="poll_questions_title" placeholder="请输入填空题题目" type="text">
|
<input maxlength="250" class="questionTitle" name="poll_questions_title" id="poll_questions_title" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text">
|
||||||
</div>
|
</div>
|
||||||
<div class="ur_editor_content">
|
<div class="ur_editor_content">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="ur_item">
|
<li class="ur_item">
|
||||||
<label>候选答案一<span class="ur_index"></span>: </label>
|
<label>候选答案一<span class="ur_index"></span>: </label>
|
||||||
<input name="question_answer[0]" placeholder="关键词一" type="text">
|
<input name="question_answer[0]" placeholder="请输入候选答案一" type="text">
|
||||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> </li>
|
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> </li>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<li class="ur_item">
|
<li class="ur_item">
|
||||||
<label>候选答案二<span class="ur_index"></span>: </label>
|
<label>候选答案二<span class="ur_index"></span>: </label>
|
||||||
<input name="question_answer[1]" placeholder="关键词二(选填)" type="text">
|
<input name="question_answer[1]" placeholder="请输入候选答案二(选填)" type="text">
|
||||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> </li>
|
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> </li>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<li class="ur_item">
|
<li class="ur_item">
|
||||||
<label>候选答案三<span class="ur_index"></span>: </label>
|
<label>候选答案三<span class="ur_index"></span>: </label>
|
||||||
<input name="question_answer[2]" placeholder="关键词三(选填)" type="text">
|
<input name="question_answer[2]" placeholder="请输入候选答案三(选填)" type="text">
|
||||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> </li>
|
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> </li>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<div class="ur_page_head ur_editor02" ><!--头部显示 start-->
|
||||||
|
<a href="javascript:" class="ur_icon_edit" title="编辑" onclick="pollsEdit();"></a>
|
||||||
|
<h1 class="ur_page_title" id="polls_name_h"><%= exercise.exercise_name%></h1>
|
||||||
|
<%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div><!--头部显示 end-->
|
|
@ -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();
|
|
@ -1 +1,2 @@
|
||||||
<%= render :partial => 'exercise_form'%>
|
<%#= render :partial => 'exercise_form'%>
|
||||||
|
111
|
|
@ -713,6 +713,7 @@ img.ui-datepicker-trigger {
|
||||||
width:16px;
|
width:16px;
|
||||||
height:15px;
|
height:15px;
|
||||||
float:left;
|
float:left;
|
||||||
|
margin: 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.label{ width:80px; text-align:right; font-size:14px; display:block; float:left;}
|
.label{ width:80px; text-align:right; font-size:14px; display:block; float:left;}
|
||||||
|
@ -1146,7 +1147,7 @@ input.sendSourceText {
|
||||||
/*20151117在线测验byTim*/
|
/*20151117在线测验byTim*/
|
||||||
.testContainer {width:698px; border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px;}
|
.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;}
|
.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;}
|
.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;}
|
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; }
|
.btn_cancel{width:54px; height:22px; padding-top:4px;background:#fff; color:#999; border:1px solid #999; text-align:center; display:block; float:left; }
|
||||||
|
|
Loading…
Reference in New Issue