填空题的候选答案不能为空,选择题和填空题至少得有一个选项或一个候选答案
This commit is contained in:
parent
2cd1c07028
commit
6f4b6a6b67
|
@ -8,7 +8,7 @@
|
|||
$("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>" +
|
||||
"<li class='ur_item'>" +
|
||||
"<label>候选答案<span class='ur_index'></span>: </label>" +
|
||||
"<input name='exercise_choice[<%=exercise_choice.id %>]' placeholder='请输入候选答案' type='text' value='<%=exercise_choice.answer_text %>'/>" +
|
||||
"<input class='candiate_answer' name='exercise_choice[<%=exercise_choice.id %>]' placeholder='请输入候选答案' type='text' value='<%=exercise_choice.answer_text %>'/>" +
|
||||
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_candidate_answer($(this));'></a>" +
|
||||
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" +
|
||||
|
@ -24,7 +24,7 @@
|
|||
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
|
||||
<input name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text" value="<%=exercise_question.question_title %>">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<div class="ur_editor_content" id="edit_single">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<label>分数<span class="ur_index"></span>: </label>
|
||||
|
@ -35,7 +35,7 @@
|
|||
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
|
||||
<li class="ur_item">
|
||||
<label>候选答案<span class="ur_index"></span>: </label>
|
||||
<input name="exercise_choice[<%=exercise_choice.id %>]" placeholder="请输入候选答案" type="text" value="<%=exercise_choice.answer_text %>"/>
|
||||
<input class="candiate_answer" name="exercise_choice[<%=exercise_choice.id %>]" placeholder="请输入候选答案" type="text" value="<%=exercise_choice.answer_text %>"/>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this));"></a>
|
||||
</li>
|
||||
|
|
|
@ -106,6 +106,24 @@
|
|||
alert("分数必须是非零开头的数字");
|
||||
}else if(quest_type !=3 && standard_ans.length == 0) {
|
||||
alert("标准答案不能为空");
|
||||
}else if(quest_type ==3) {
|
||||
var div = $("#poll_answers_" + id);
|
||||
var candiate_answer = $(".candiate_answer",div);
|
||||
if(candiate_answer.length > 0) {
|
||||
for(i=0;i<candiate_answer.length;i++) {
|
||||
if(i<candiate_answer.length-1 && $.trim($(candiate_answer[i]).val()) == "") {
|
||||
continue;
|
||||
} else if(i == (candiate_answer.length-1) && $.trim($(candiate_answer[i]).val()) == "") {
|
||||
alert("候选答案不能为空");
|
||||
} else if($.trim($(candiate_answer[i]).val()) != ""){
|
||||
doc.parent().parent().parent().submit();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
} else{
|
||||
alert("候选答案不能为空");
|
||||
}
|
||||
}else{
|
||||
doc.parent().parent().parent().submit();}
|
||||
}
|
||||
|
@ -158,7 +176,7 @@
|
|||
{
|
||||
if(doc.parent().siblings("li").length == 0)
|
||||
{
|
||||
alert("选择题至少有一个选项");
|
||||
alert("至少有一个选项或一个候选答案");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -16,33 +16,35 @@
|
|||
<input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项A<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项B<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项C<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'/>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项D<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'/>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div>
|
||||
<li class="ur_item">
|
||||
<label>选项A<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项B<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项C<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'/>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项D<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'/>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>标准答案<span class="ur_index"></span>: </label>
|
||||
|
|
|
@ -16,33 +16,35 @@
|
|||
<input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项A<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项B<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项C<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项D<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div>
|
||||
<li class="ur_item">
|
||||
<label>选项A<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项B<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项C<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'>
|
||||
<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>
|
||||
<li class="ur_item">
|
||||
<label>选项D<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>标准答案<span class="ur_index"></span>: </label>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<input name="question_type" value="3" type="hidden">
|
||||
<input maxlength="250" class="questionTitle" name="question_title" id="poll_questions_title" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<div class="ur_editor_content" id="new_single">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %>
|
||||
|
@ -16,26 +16,28 @@
|
|||
<input id="question_score" value="<%= score%>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案一<span class="ur_index"></span>: </label>
|
||||
<input name="exercise_choice[0]" placeholder="请输入候选答案一" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案二<span class="ur_index"></span>: </label>
|
||||
<input name="exercise_choice[1]" placeholder="请输入候选答案二(选填)" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案三<span class="ur_index"></span>: </label>
|
||||
<input name="exercise_choice[2]" placeholder="请输入候选答案三(选填)" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案一<span class="ur_index"></span>: </label>
|
||||
<input class="candiate_answer" name="exercise_choice[0]" placeholder="请输入候选答案一" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案二<span class="ur_index"></span>: </label>
|
||||
<input class="candiate_answer" name="exercise_choice[1]" placeholder="请输入候选答案二(选填)" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案三<span class="ur_index"></span>: </label>
|
||||
<input class="candiate_answer" name="exercise_choice[2]" placeholder="请输入候选答案三(选填)" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
'<li class="ur_item">'+
|
||||
'<label>分数<span class="ur_index"></span>: </label>'+
|
||||
'<input value="<%=score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
|
||||
'</li>'+
|
||||
'</li><div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项A<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+
|
||||
|
@ -80,7 +80,7 @@
|
|||
'<input maxlength="200" type="text" name="question_answer[3]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'</li></div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>标准答案<span class="ur_index"></span>: </label>'+
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
'<li class="ur_item">'+
|
||||
'<label>分数<span class="ur_index"></span>: </label>'+
|
||||
'<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
|
||||
'</li>'+
|
||||
'</li><div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项A<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+
|
||||
|
@ -79,7 +79,7 @@
|
|||
'<input maxlength="200" type="text" name="question_answer[3]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'</li></div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>标准答案<span class="ur_index"></span>: </label>'+
|
||||
|
|
|
@ -35,32 +35,32 @@
|
|||
'<input type="hidden" name="question_type" value="3"/>'+
|
||||
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text"/>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_content">'+
|
||||
'<div class="ur_editor_content" id="new_single">'+
|
||||
'<ul>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>分数<span class="ur_index"></span>: </label>'+
|
||||
'<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
|
||||
'</li>'+
|
||||
'</li><div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>候选答案一<span class="ur_index"></span>: </label>'+
|
||||
'<input type="text" name="exercise_choice[0]" placeholder="请输入候选答案一"/>'+
|
||||
'<input class="candiate_answer" type="text" name="exercise_choice[0]" placeholder="请输入候选答案一"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>候选答案二<span class="ur_index"></span>: </label>'+
|
||||
'<input type="text" name="exercise_choice[1]" placeholder="请输入候选答案二(选填)"/>'+
|
||||
'<input class="candiate_answer" type="text" name="exercise_choice[1]" placeholder="请输入候选答案二(选填)"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>候选答案三<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="exercise_choice[2]" placeholder="请输入候选答案三(选填)"/>'+
|
||||
'<input class="candiate_answer" type="text" name="exercise_choice[2]" placeholder="请输入候选答案三(选填)"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'</li></div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</ul>'+
|
||||
'</div>'+
|
||||
|
|
Loading…
Reference in New Issue