插入题目

This commit is contained in:
cxt 2015-11-19 09:13:46 +08:00
parent 398a7da533
commit a173e924d0
8 changed files with 207 additions and 162 deletions

View File

@ -18,7 +18,7 @@
}
</script>
<div class="questionContainer">
<div class="questionContainer" style="width: 680px;">
<div class="ur_editor_title">
<label>问题:&nbsp;&nbsp;</label>
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">

View File

@ -18,7 +18,7 @@
}
</script>
<div class="questionContainer">
<div class="questionContainer" style="width: 680px;">
<div class="ur_editor_title">
<label>问题:&nbsp;&nbsp;</label>
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">

View File

@ -17,7 +17,7 @@
}
</script>
<div class="questionContainer">
<div class="questionContainer" style="width: 680px;">
<div class="ur_editor_title">
<label>问题:&nbsp;&nbsp;</label>
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">

View File

@ -60,51 +60,61 @@
}
function insert_MC(quest_type,quest_num,quest_id){
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
'<%= form_for(ExerciseQuestion.new,
:html => { :multipart => true },
:url => {:controller => 'exercise',
:action => 'create_exercise_question',
:course_id => @course.id
},:remote=>true ) do |f|%>'+
' <div class="ur_editor radio"> '+
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+
' <div class="questionContainer" style="width: 680px;"> '+
'<div class="ur_editor_title"> '+
'<label>问题:&nbsp;&nbsp;</label>'+
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
'<input type="hidden" name="question_type" value="1"/>'+
'<input maxlength="250" class="ur_question_title" type="text" name="poll_questions_title" id="poll_questions_title" placeholder="请输入单选题标题"/>'+
'<input type="checkbox" name="is_necessary" value="true" checked/>'+
'<label>必答</label>'+
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text"/>'+
'</div>'+
'<div class="ur_editor_content">'+
'<ul>'+
'<li class="ur_item">'+
'<label>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
'</li>'+
'<li class="ur_item">'+
'<label>选项A<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</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>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<label>选项B<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</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>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<label>选项C<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</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>&nbsp;&nbsp;&nbsp;</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 class="cl"></div>'+
'<li class="ur_item">'+
'<label>标准答案<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input name="exercise_choice" placeholder="若标准答案为A在此输入A即可" type="text">'+
'</li>'+
'<div class="cl"></div>'+
'</ul>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this));">'+
'<%= l(:label_button_ok)%>'+
'保存'+
'</a>'+
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
'<%= l(:button_cancel)%>'+
@ -114,6 +124,10 @@
'</div>'+
'<% end%>'
);
}
else {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
}
$("#poll_questions_title").focus();
}
@ -123,51 +137,61 @@
}
function insert_MCQ(quest_type,quest_num,quest_id){
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == ""){
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
'<%= form_for(ExerciseQuestion.new,
:html => { :multipart => true },
:url => {:controller => 'exercise',
:action => 'create_exercise_question',
:course_id => @course.id
},:remote=>true ) do |f|%>'+
'<div class="ur_editor checkbox">'+
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+
' <div class="questionContainer" style="width: 680px;"> '+
'<div class="ur_editor_title"> '+
'<label>问题:&nbsp;&nbsp;</label>'+
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
'<input type="hidden" name="question_type" value="2"/>'+
'<input maxlength="250" class="ur_question_title" type="text" name="poll_questions_title" id="poll_questions_title" placeholder="请输入多选题标题"/>'+
'<input type="checkbox" name="is_necessary" value="true" checked/>'+
'<label>必答</label>'+
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入多选题题目" type="text"/>'+
'</div>'+
'<div class="ur_editor_content">'+
'<ul>'+
'<li class="ur_item">'+
'<label>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
'</li>'+
'<li class="ur_item">'+
'<label>选项A<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</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>'+
'<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>&nbsp;&nbsp;&nbsp;</label>'+
'<label>选项B<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</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>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<label>选项C<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</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>&nbsp;&nbsp;&nbsp;</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 class="cl"></div>'+
'<li class="ur_item">'+
'<label>标准答案<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input name="exercise_choice" placeholder="若标准答案为A,B,C在答案输入框填入ABC即可" type="text">'+
'</li>'+
'<div class="cl"></div>'+
'</ul>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this));">'+
'<%= l(:label_button_ok)%>'+
'保存'+
'</a>'+
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
'<%= l(:button_cancel)%>'+
@ -177,6 +201,9 @@
'</div>'+
'<% end%>'
);
} else {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
}
$("#poll_questions_title").focus();
}
@ -186,28 +213,51 @@
}
function insert_SINGLE(quest_type,quest_num,quest_id){
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
'<%= form_for(ExerciseQuestion.new,
:html => { :multipart => true },
:url => {:controller => 'exercise',
:action => 'create_exercise_question',
:course_id => @course.id
},:remote=>true ) do |f|%>'+
'<div class="ur_editor text ">'+
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+
' <div class="questionContainer" style="width: 680px;"> '+
'<div class="ur_editor_title"> '+
'<label for="ur_question_title">问题:&nbsp;&nbsp;</label>'+
'<label>问题:&nbsp;&nbsp;</label>'+
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
'<input type="hidden" name="question_type" value="3"/>'+
'<input maxlength="250" id="poll_questions_title" class="ur_question_title" contenteditable="true" type="text" name="poll_questions_title" placeholder="请输入单行主观标题"/>'+
'<input type="checkbox" name="is_necessary" value="true" checked/>'+
'<label for="ur_question_require">必答</label>'+
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text"/>'+
'</div>'+
'<div class="ur_editor_content">'+
'<ul>'+
'<li class="ur_item">'+
'<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
'</li>'+
'<li class="ur_item">'+
'<label>候选答案一<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input type="text" name="exercise_choice[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>候选答案二<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input type="text" name="exercise_choice[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>候选答案三<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input maxlength="200" type="text" name="exercise_choice[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>'+
'</ul>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<a class="btn_submit c_white" data-button="ok" onclick="add_poll_question($(this));">'+
'<%= l(:label_button_ok)%>'+
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this));">'+
'保存'+
'</a>'+
'<a class="btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
'<%= l(:button_cancel)%>'+
'</a>'+
'</div>'+
@ -215,6 +265,9 @@
'</div>'+
'<% end%>'
);
} else {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
}
$("#poll_questions_title").focus();
}
@ -247,13 +300,13 @@
function add_poll_question(doc)
{
var title = $.trim($("#poll_questions_title").val());
if(title.length == 0){alert("标题不能为空");}else{doc.parent().parent().parent().submit();}
if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();}
}
//修改标题时确定按钮
function edit_poll_question(doc,id)
{
var title = $.trim($("#poll_questions_title_" + id).val());
if(title.length == 0){alert("标题不能为空");}else{doc.parent().parent().parent().submit();}
if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();}
}
//问卷头

View File

@ -20,17 +20,23 @@
<li class="ur_item">
<label>候选答案一<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input name="exercise_choice[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>
<li class="ur_item">
<label>候选答案二<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input name="exercise_choice[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>
<li class="ur_item">
<label>候选答案三<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input name="exercise_choice[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>
</ul>
</div>

View File

@ -7,7 +7,7 @@
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
<a class='ur_icon_add' title='向下插入' id="add_mc_<%=exercise_question.id%>" onclick="chooseQuestionType('mc',<%=exercise_question.id%>);"></a>
<a class='ur_icon_add' title='向下插入' id="add_mc_<%=exercise_question.id%>" onclick="dismiss('mc',<%=exercise_question.id%>);insert_MC('mc',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
@ -29,10 +29,3 @@
<!-- 新增问题 -->
<div id="insert_new_poll_question_mc_<%=exercise_question.id%>">
</div>
<div id="div_mc_<%=exercise_question.id%>" style="width: 50px;border: 1px solid #cbcbcb; display:none;position: absolute;padding: 5px;background: white">
<ul>
<!--<li><a href="javascript:void(0);" onclick=" dismiss('mc',<%#=exercise_question.id%>);insert_MC('mc',<%#=exercise_question.question_number%>,<%#=exercise_question.id%>);">单选</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mc',<%#=poll_question.id%>);insert_MCQ('mc',<%#=poll_question.question_number%>,<%#=poll_question.id%>);">多选</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mc',<%#=poll_question.id%>);insert_SINGLE('mc',<%#=poll_question.question_number%>,<%#=poll_question.id%>);">单行主观</a></li>-->
</ul>
</div>

View File

@ -6,7 +6,7 @@
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
<a class='ur_icon_add' title='向下插入' id="add_mcq_<%=exercise_question.id%>" onclick="chooseQuestionType('mcq',<%=exercise_question.id%>);"></a>
<a class='ur_icon_add' title='向下插入' id="add_mcq_<%=exercise_question.id%>" onclick="dismiss('mcq',<%=exercise_question.id%>);insert_MCQ('mcq',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">

View File

@ -5,7 +5,7 @@
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
<a class='ur_icon_add' title='向下插入' id="add_single_<%=exercise_question.id%>" onclick="chooseQuestionType('single',<%=exercise_question.id%>);"></a>
<a class='ur_icon_add' title='向下插入' id="add_single_<%=exercise_question.id%>" onclick="dismiss('single',<%=exercise_question.id%>);insert_SINGLE('single',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
<div class="cl"></div>
<div>
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
@ -16,10 +16,3 @@
<!-- 新增问题 -->
<div id="insert_new_poll_question_single_<%=exercise_question.id%>">
</div>
<div id="div_single_<%=exercise_question.id%>" style="width: 50px;border: 1px solid #cbcbcb; display:none;position: absolute;padding: 5px;background: white">
<ul>
<!--<li><a href="javascript:void(0);" onclick=" dismiss('single',<%#=poll_question.id%>);insert_MC('single',<%#=poll_question.question_number%>,<%#=poll_question.id%>);">单选</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('single',<%#=poll_question.id%>);insert_MCQ('single',<%#=poll_question.question_number%>,<%#=poll_question.id%>);">多选</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('single',<%#=poll_question.id%>);insert_SINGLE('single',<%#=poll_question.question_number%>,<%#=poll_question.id%>);">单行主观</a></li>-->
</ul>
</div>