Merge branch 'sw_new_course' of http://repository.trustie.net/xianbo/trustie2 into sw_new_course

This commit is contained in:
huang 2015-11-18 18:28:37 +08:00
commit 8e4b2bd7d4
4 changed files with 69 additions and 5 deletions

View File

@ -178,7 +178,7 @@ class ExerciseController < ApplicationController
# params[:question_answer] eg:A、B、C选项
def update_exercise_question
@exercise_question = ExerciseQuestion.find params[:exercise_question]
@exercise_questions.question_title = params[:exercise_questions_title].nil? || params[:exercise_questions_title].empty? ? l(:label_enter_single_title) : params[:exercise_questions_title]
@exercise_question.question_title = params[:exercise_questions_title].nil? || params[:exercise_questions_title].empty? ? l(:label_enter_single_title) : params[:exercise_questions_title]
################处理选项
if params[:question_answer]
@exercise_question.exercise_answers.each do |answer|
@ -194,7 +194,7 @@ class ExerciseController < ApplicationController
question.save
else
question_option = {
:exercise_choices_id => i,
:exercise_choice_id => i,
:answer_text => answer
}
@exercise_question.exercise_answers.new question_option

View File

@ -0,0 +1,63 @@
<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
<!--编辑单选start-->
<script type="text/javascript">
function resetQuestion<%=exercise_question.id%>()
{
$("#poll_questions_title_<%=exercise_question.id%>").val("<%= exercise_question.question_title%>")
$("#poll_question_score_<%=exercise_question.id %>").val("<%= exercise_question.question_score%>")
$("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>")
$("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" +
"<li class='ur_item'>" +
"<label>选项<%=convert_to_char (index+1).to_s %><span class='ur_index'></span>&nbsp;&nbsp;&nbsp;</label>" +
"<input maxlength='200' type='text' name='question_answer[0]' placeholder='输入选项内容' value='<%=exercise_choice.choice_text %>'/>" +
"<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>" +
"<% end%>");
}
</script>
<div class="questionContainer">
<div class="ur_editor_title">
<label>问题:&nbsp;&nbsp;</label>
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
<input name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入单选题题目" type="text" value="<%=exercise_question.question_title %>">
</div>
<div class="ur_editor_content">
<ul>
<li class="ur_item">
<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input type="text" id="poll_question_score_<%=exercise_question.id %>" name="question_score" style="width:40px; text-align:center; padding-left:0px;" value="<%= exercise_question.question_score %>">分
</li>
<div class="cl"></div>
<div id="poll_answers_<%=exercise_question.id%>">
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<li class="ur_item">
<label>选项<%=convert_to_char (index+1).to_s %><span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容' value="<%=exercise_choice.choice_text %>">
<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>
<% end %>
</div>
<li class="ur_item">
<label>标准答案<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input id="poll_question_standard_answer_<%=exercise_question.id %>" name="exercise_choice" placeholder="若标准答案为A在此输入A即可" type="text" value="<%=convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>">
</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="edit_poll_question($(this),<%= exercise_question.id %>);">
保存
</a>
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="resetQuestion<%=exercise_question.id%>();pollQuestionCancel(<%= exercise_question.id%>);">
<%= l(:button_cancel)%>
</a>
</div>
<div class="cl"></div>
</div>
<!--编辑单选 end-->
<% end%>

View File

@ -19,17 +19,17 @@
<div class="cl"></div>
<li class="ur_item">
<label>候选答案一<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input name="question_answer[0]" placeholder="请输入候选答案一" type="text">
<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>
<div class="cl"></div>
<li class="ur_item">
<label>候选答案二<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input name="question_answer[1]" placeholder="请输入候选答案二(选填)" type="text">
<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>
<div class="cl"></div>
<li class="ur_item">
<label>候选答案三<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input name="question_answer[2]" placeholder="请输入候选答案三(选填)" type="text">
<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>
<div class="cl"></div>
</ul>

View File

@ -157,6 +157,7 @@ RedmineApp::Application.routes.draw do
collection do #生成路径为 /exercise/方法名
delete 'delete_exercise_question'
post 'update_exercise_question'
end
end