educoder/app/views/exercise/_new_question.html.erb

153 lines
7.1 KiB
Plaintext

<% content_for :header_tags do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
<% end %>
<a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_MC();">+&nbsp;单选题</a>
<a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_MCQ();">+&nbsp;多选题</a>
<a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_single();">+&nbsp;填空题</a>
<a href="javascript:void(0);" class="fl add_item_part" onclick="add_multi();">+&nbsp;简答题</a>
<div id="hidden_div_block" class="undis">
<textarea style="display: none" id="hidden_textarea"></textarea>
</div>
<script type="text/javascript">
$(function(){
KindEditor.ready(function(K){
$("#hidden_div_block").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.placeholder = "请输入单选题的题干";
params.textarea = $("#hidden_textarea",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
//new_quetion_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
});
function add_MC(){
var forms = $("form.new_exercise_question");
if($("#exercise_head_edit").is(":visible")){
notice_box("请先保存试卷标题等信息。");
}else if(forms.length > 0){
notice_box("请先保存正在编辑的题目再新建。");
} else{
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC', :locals => {:exercise=>@exercise}) %>");
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入单选题的题干";
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[name='question_title']",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
//div_form = $("div[nhname='new_exercise_mc_q']");
//$(".ke-edit", div_form).css("height","48px");
}
}
function add_MCQ(){
var forms = $("form.new_exercise_question");
if($("#exercise_head_edit").is(":visible")){
notice_box("请先保存试卷标题等信息。");
}else if(forms.length > 0){
notice_box("请先保存正在编辑的题目再新建。");
} else{
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MCQ', :locals => {:exercise=>@exercise}) %>");
$("#poll_questions_title").focus();
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入多选题的题干";
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[name='question_title']",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
}
}
function add_single(){
var forms = $("form.new_exercise_question");
if($("#exercise_head_edit").is(":visible")){
notice_box("请先保存试卷标题等信息。");
}else if(forms.length > 0){
notice_box("请先保存正在编辑的题目再新建。");
} else{
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_single', :locals => {:exercise=>@exercise}) %>");
$("#poll_questions_title").focus();
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入填空题的题干(注意:目前仅支持一个空)";
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[name='question_title']",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
}
}
function add_multi(){
var forms = $("form.new_exercise_question");
if($("#exercise_head_edit").is(":visible")){
notice_box("请先保存试卷标题等信息。");
}else if(forms.length > 0){
notice_box("请先保存正在编辑的题目再新建。");
} else{
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_multi', :locals => {:exercise=>@exercise}) %>");
$("#poll_questions_title").focus();
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入简答题的题干";
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[name='question_title']",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
}
}
</script>