socialforge/app/views/exercise/_show_MCQ.html.erb

133 lines
9.5 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div onmouseover="$('#menu_div_<%= exercise_question.id %>').show();" onmouseout="$('#menu_div_<%= exercise_question.id %>').hide();">
<div class="exercise_title">
<div>
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分&nbsp;&nbsp;
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %></span>
<div class="fr none" id="menu_div_<%= exercise_question.id %>">
<% type = exercise_question.question_type %>
<% exercise = exercise_question.exercise %>
<% count = exercise.exercise_questions.where(:question_type => type).count %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
<a href="javascript:void(0)" class="ur_icon_de" title="删除" onclick="delete_confirm_box('<%= delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number) %>', '确定要删除该题目吗?')"></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>
<% if exercise_question.question_number < count %>
<%= link_to('', {:controller => 'exercise', :action => 'update_question_num', :id => exercise.id, :ques_id => exercise_question.id, :opr => 'down'},:remote => true, :method => 'post', :class => "poll-down up_and_down", :title => '下移') %>
<% end %>
<% unless exercise_question.question_number == 1 %>
<%= link_to('', {:controller => 'exercise', :action => 'update_question_num', :id => exercise.id, :ques_id => exercise_question.id, :opr => 'up'},:remote => true, :method => 'post', :class => "poll-up up_and_down", :title => '上移') %>
<% end %>
</div>
<div class="cl"></div>
</div>
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
</div>
<div class="exercise_inputs">
<table class="" style="width:100%;">
<tbody>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<tr>
<td>
<label>
<input class="ur_radio" type="checkbox" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" >
<%= convert_to_char((index+1).to_s)%>&nbsp;&nbsp;<%= exercise_choice.choice_text%>
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div><!--多选题显示 end-->
<!-- 新增问题 -->
<div id="insert_new_poll_question_mcq_<%=exercise_question.id%>">
</div>
<script type="text/javascript">
function insert_MCQ(quest_type,quest_num,quest_id){
var forms = $("form.new_exercise_question");
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == ""){
if(forms.length > 0){
notice_box("请先保存正在编辑的题目再新建。");
} else {
<% score =exercise_question.question_score %>
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
'<div class="questionContainer" style="width: 680px;"> '+
'<div class="mb10 ur_item">'+
'<label>分值<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:60px; text-align:center; padding-left:0px;">分'+
'<span class="fr c_red" style="width: 60px;" id="question_standard_answer_2">请点击选项</span>'+
'<span class="fr">标准答案:</span>'+
'<div class="cl"></div>'+
'</div>'+
'<div class="ur_editor_title">'+
'<label class="questionLabel mt8">问题:&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"/>'+
'<textarea name="question_title" style="width: 625px;" id="poll_questions_title" class="questionTitle" placeholder="请输入多选题的题干" type="text"></textarea>'+
'</div>'+
'<div class="ur_editor_content">'+
'<ul>'+
'<div>'+
'<input style="display: none;" name="exercise_choice" id="exercise_choice_2"/>'+
'<li class="ur_item new_answer">'+
'<a class="question_choice_white fl mr10 choice_btn" title="设为答案" href="javascript:void(0)" onclick="toggle_select($(this), 2, 2);">A</a>'+
'<input maxlength="200" class="w600" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
'</li>'+
'<div class="cl"></div>'+
'<li class="ur_item new_answer">'+
'<a class="question_choice_white fl mr10 choice_btn" title="设为答案" href="javascript:void(0)" onclick="toggle_select($(this), 2, 2);">B</a>'+
'<input maxlength="200" class="w600" type="text" name="question_answer[1]" placeholder="输入选项内容"/>'+
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
'</li>'+
'<div class="cl"></div>'+
'<li class="ur_item new_answer">'+
'<a class="question_choice_white fl mr10 choice_btn" title="设为答案" href="javascript:void(0)" onclick="toggle_select($(this), 2, 2);">C</a>'+
'<input maxlength="200" class="w600" type="text" name="question_answer[2]" placeholder="输入选项内容"/>'+
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
'</li>'+
'<div class="cl"></div>'+
'<li class="ur_item new_answer">'+
'<a class="question_choice_white fl mr10 choice_btn" title="设为答案" href="javascript:void(0)" onclick="toggle_select($(this), 2, 2);">D</a>'+
'<input maxlength="200" class="w600" type="text" name="question_answer[3]" placeholder="输入选项内容"/>'+
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
'</li>'+
'<div class="cl"></div>'+
'<li class="ur_item">'+
'<a class="question_choice_dash fl mr10 choice_btn">E</a>'+
'<div class="dash-block new-question w600" onclick="add_single_answer($(this), 2);">新建选项</div>'+
'</li>'+
'<div class="cl"></div>'+
'</div> </ul>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<span class="fl c_red mt10">温馨提示:[多选题]属于客观题将由系统自动评分,请设置标准答案</span>'+
'<a class="big_blue_btn borderRadius fr" data-button="ok" id="add_new_question">'+
'保存'+
'</a>'+
'<a class="big_grey_btn borderRadius fr mr10" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
'<%= l(:button_cancel)%>'+
'</a>'+
'</div>'+
'<div class="cl"></div>'+
'</div>'+
'<% end%>'
);
$("#poll_questions_title").focus();
$("#add_new_question").one('click', function(){
add_poll_question($(this),2);
});
$(".questionTitle").on("input",function(){
$(this).height(30);
var scrollVal = $(this)[0].scrollHeight;
$(this).height(scrollVal);
});
}
}else {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
}
}
</script>