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

88 lines
6.3 KiB
Plaintext
Raw Normal View History

<div>
<div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br />
<%= exercise_question.question_title %>
</div>
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %>
<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="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| %>
候选答案<%= convert_to_chi_num(index+1) %><%= exercise_choice.answer_text%><br />
<% end %>
</div>
</div>
<!-- 新增问题 -->
<div id="insert_new_poll_question_single_<%=exercise_question.id%>">
</div>
<script type="text/javascript">
function insert_SINGLE(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){
alert("请先保存正在编辑的题目再新建。");
} 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="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="3"/>'+
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text"/>'+
'</div>'+
'<div class="ur_editor_content" id="new_single">'+
'<ul>'+
'<li class="ur_item">'+
'<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
'</li><div>'+
'<li class="ur_item">'+
'<label name="candiate_items">候选答案一<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<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 name="candiate_items">候选答案二<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<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 name="candiate_items">候选答案三<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<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></div>'+
'<div class="cl"></div>'+
'</ul>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<a class="btn btn_dark btn_submit c_white" data-button="ok" id="add_new_question">'+
'保存'+
'</a>'+
'<a class="btn btn_light btn_cancel" 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),3);
});
}
} else {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
}
}
</script>