258 lines
10 KiB
Plaintext
258 lines
10 KiB
Plaintext
<div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20" id="exercise_head">
|
|
<div class="<%= is_edit ? '' : 'none' %>" id="exercise_head_show">
|
|
<%= render :partial => 'show_head', :locals => {:exercise => @exercise} %>
|
|
</div>
|
|
<div class="<%= is_edit ? 'none' : '' %>" id="exercise_head_edit">
|
|
<% if is_edit %>
|
|
<%= render :partial => 'edit_head', :locals => {:exercise => @exercise} %>
|
|
<% else %>
|
|
<%= render :partial => 'new_head', :locals => {:exercise => @exercise} %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="total_questions_score">
|
|
<%= render :partial => "exercise/total_questions_score" %>
|
|
</div>
|
|
|
|
<div id="exercise_question_list">
|
|
<% if is_edit %>
|
|
<%= render :partial => "exercise/exercise_content" %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20" id="new_exercise_question">
|
|
<%= render :partial => "exercise/new_question" %>
|
|
</div>
|
|
|
|
<div id="new_poll_question">
|
|
|
|
</div>
|
|
|
|
<script id="t:set-option-list" type="text/html">
|
|
<li class="clearfix pr mb20">
|
|
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" name="option_span" onclick="selectchoice(this)" data-tip-down="点击设置答案">A</span></label>
|
|
<input type="hidden" name="choice[answer][]">
|
|
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question_answer[]" placeholder="请输入选项内容"></textarea>
|
|
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeSingle(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
|
</li>
|
|
</script>
|
|
|
|
<script id="t:set-option-lists" type="text/html">
|
|
<li class="clearfix pr mb20">
|
|
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectMul(this)" name="option_spans" data-tip-down="点击设置答案">A</span></label>
|
|
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question_answer[]" placeholder="请输入选项内容"></textarea>
|
|
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeMuli(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
|
</li>
|
|
</script>
|
|
|
|
<script id="t:set-fillin-lists" type="text/html">
|
|
<li class="clearfix pr mb20">
|
|
<label class="panel-form-label fl"><span class="fr mr10 color-grey" name="fill_span">答案 2</span></label>
|
|
<textarea class="candiate_answer panel-form-width2-690 fl panel-box-sizing" name="exercise_choice[]" placeholder="请输入参考答案(可选)"></textarea>
|
|
<a title="移除" href="javascript:void(0)" onclick="removefill(this)" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
|
</li>
|
|
</script>
|
|
|
|
<script>
|
|
/*填空题操作*/
|
|
function addfill(item){
|
|
var bt = baidu.template;
|
|
bt.LEFT_DELIMITER = '<!';
|
|
bt.RIGHT_DELIMITER = '!>';
|
|
var html = bt('t:set-fillin-lists', null);
|
|
$(item).parent().parent('.clearfix').before(html);
|
|
$(item).parent().parent('.clearfix').prev().find('textarea').attr("name", "exercise_choice["+new Date().getTime()+"]");
|
|
var inputs = document.getElementsByName("exercise_choice[]");
|
|
var inputs_spans=$(item).parents(".fillin_Temp").find("li span[name='fill_span']");
|
|
//var inputs_spans = document.getElementsByName("fill_span");
|
|
for (var j = 0; j < inputs_spans.length; j++) {
|
|
var countChar=convert_to_chi_num(j+1);
|
|
$(inputs_spans[j]).html("答案 "+countChar);
|
|
}
|
|
// for (var i = 0; i < inputs.length; i++) {
|
|
// autoTextarea(inputs[i], 0, 140);
|
|
// }
|
|
$(inputs[inputs.length - 1]).focus();
|
|
}
|
|
|
|
function convert_to_chi_num(num){
|
|
var toChar="";
|
|
switch(num){
|
|
case 1:
|
|
return toChar="一";
|
|
break;
|
|
case 2:
|
|
return toChar="二";
|
|
break;
|
|
case 3:
|
|
return toChar="三";
|
|
break;
|
|
case 4:
|
|
return toChar="四";
|
|
break;
|
|
case 5:
|
|
return toChar="五";
|
|
break;
|
|
case 6:
|
|
return toChar="六";
|
|
break;
|
|
case 7:
|
|
return toChar="七";
|
|
break;
|
|
case 8:
|
|
return toChar="八";
|
|
break;
|
|
case 9:
|
|
return toChar="九";
|
|
break;
|
|
}
|
|
}
|
|
|
|
function removefill(item){
|
|
var temp=$(item).parents(".fillin_Temp");
|
|
$(item).parents('li').remove();
|
|
var inputs_spans=temp.find("li span[name='fill_span']");
|
|
//var inputs_spans = document.getElementsByName("fill_span");
|
|
for (var j = 0; j < parseInt(inputs_spans.length); j++) {
|
|
var countChar=convert_to_chi_num(j+1);
|
|
$(inputs_spans[j]).html("答案 "+countChar);
|
|
}
|
|
}
|
|
|
|
/*选择题操作*/
|
|
function removeMuli(item){
|
|
var temp=$(item).parents("li").siblings("div").find(".current-option");
|
|
var count=0;
|
|
var exercise_choice = $(item).parents(".multiple_Temp").find("input[name='exercise_choice']");
|
|
var muil=$(item).parents(".multiple_Temp").find(".check-option-bg");
|
|
var pare=$(item).parents(".multiple_Temp");
|
|
if($(item).parents("li").find("label span").hasClass("check-option-bg")){
|
|
count++;
|
|
}
|
|
$(item).parents('li').remove();
|
|
var inputs_spans=pare.find("li span[name='option_spans']");
|
|
//var inputs_spans = document.getElementsByName("option_spans");
|
|
for (var j = 0; j < parseInt(inputs_spans.length)-count; j++) {
|
|
if(j >= 0 && j <= 26){
|
|
if(j >= 0 && j <= 26){
|
|
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
|
}
|
|
}
|
|
}
|
|
|
|
temp.html("");
|
|
if(parseInt(muil.length)-count>0){
|
|
for(var i=0;i<parseInt(muil.length)-count;i++){
|
|
temp.html(temp.html()+muil.eq(i).html());
|
|
}
|
|
exercise_choice.val(temp.html());
|
|
}else{
|
|
exercise_choice.val('');
|
|
temp.html("请点击正确选项");
|
|
}
|
|
}
|
|
|
|
function addMuli(item){
|
|
var bt = baidu.template;
|
|
bt.LEFT_DELIMITER = '<!';
|
|
bt.RIGHT_DELIMITER = '!>';
|
|
var html = bt('t:set-option-lists', null);
|
|
$(item).parent().parent('.clearfix').before(html);
|
|
$(item).parent().parent('.clearfix').prev().find('textarea').attr("name", "question_answer["+new Date().getTime()+"]");
|
|
var inputs = document.getElementsByName("question_answer[]");
|
|
var inputs_spans=$(item).parents(".multiple_Temp").find("li span[name='option_spans']");
|
|
//var inputs_spans = document.getElementsByName("option_spans");
|
|
for (var j = 0; j < inputs_spans.length; j++) {
|
|
if(j >= 0 && j <= 26){
|
|
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
|
}
|
|
}
|
|
$(inputs[inputs.length - 1]).focus();
|
|
}
|
|
|
|
function selectMul(item){
|
|
var temp=$(item).parents(".multiple_Temp");
|
|
var exercise_choice = $(temp).find("input[name='exercise_choice']");
|
|
temp.find("li").removeClass("check-option-bg");
|
|
$(item).toggleClass("check-option-bg");
|
|
|
|
temp.find(".current-option").html("");
|
|
if(temp.find(".check-option-bg").length>0){
|
|
for(var i=0;i<temp.find(".check-option-bg").length;i++){
|
|
temp.find(".current-option").html(temp.find(".current-option").html()+temp.find(".check-option-bg").eq(i).html());
|
|
}
|
|
exercise_choice.val(temp.find(".current-option").html());
|
|
}else{
|
|
temp.find(".current-option").html("请点击正确选项");
|
|
exercise_choice.val('');
|
|
}
|
|
}
|
|
|
|
/*单选题操作*/
|
|
function addSingle(item){
|
|
var bt = baidu.template;
|
|
bt.LEFT_DELIMITER = '<!';
|
|
bt.RIGHT_DELIMITER = '!>';
|
|
var html = bt('t:set-option-list', null);
|
|
$(item).parent().parent('.clearfix').before(html);
|
|
$(item).parent().parent('.clearfix').prev().find('textarea').attr("name", "question_answer["+new Date().getTime()+"]");
|
|
var inputs = document.getElementsByName("question_answer[]");
|
|
var inputs_spans=$(item).parents(".single_Temp").find("li span[name='option_span']");
|
|
//var inputs_spans = document.getElementsByName("option_span");
|
|
for (var j = 0; j < inputs_spans.length; j++) {
|
|
if(j >= 0 && j <= 26){
|
|
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
|
}
|
|
}
|
|
$(inputs[inputs.length - 1]).focus();
|
|
}
|
|
function removeSingle(item){
|
|
var temp=$(item).parents("li").siblings("div").find(".current-option");
|
|
var exercise_choice = $(item).parents(".single_Temp").find("input[name='exercise_choice']");
|
|
var singl=$(item).parents(".single_Temp").find(".check-option-bg");
|
|
var pare=$(item).parents(".single_Temp");
|
|
temp.html("");
|
|
var count=0;
|
|
if($(item).parents("li").find("label span").hasClass("check-option-bg")){
|
|
count++;
|
|
}
|
|
$(item).parents('li').remove();
|
|
var inputs_spans=pare.find("li span[name='option_span']");
|
|
//var inputs_spans = document.getElementsByName("option_span");
|
|
for (var j = 0; j < parseInt(inputs_spans.length)-count; j++) {
|
|
if(j >= 0 && j <= 26){
|
|
if(j >= 0 && j <= 26){
|
|
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
|
}
|
|
}
|
|
}
|
|
|
|
if(parseInt(singl.length)-count>0){
|
|
for(var i=0;i<parseInt(singl.length)-count;i++){
|
|
temp.html(temp.html()+singl.eq(i).html());
|
|
}
|
|
exercise_choice.val(temp.html());
|
|
}else{
|
|
temp.html("请点击正确选项");
|
|
exercise_choice.val('');
|
|
}
|
|
}
|
|
function selectchoice(item){
|
|
var temp=$(item).parents(".single_Temp");
|
|
var exercise_choice = $(temp).find("input[name='exercise_choice']");
|
|
$(temp).find("li span").removeClass("check-option-bg");
|
|
$(item).toggleClass("check-option-bg");
|
|
|
|
temp.find(".current-option").html("");
|
|
if(temp.find(".check-option-bg").length>0){
|
|
for(var i=0;i<temp.find(".check-option-bg").length;i++){
|
|
temp.find(".current-option").html(temp.find(".current-option").html()+temp.find(".check-option-bg").eq(i).html());
|
|
}
|
|
exercise_choice.val(temp.find(".current-option").html());
|
|
}else{
|
|
temp.find(".current-option").html("请点击正确选项");
|
|
exercise_choice.val('');
|
|
}
|
|
}
|
|
</script> |