Merge branch 'sw_new_course' of http://repository.trustie.net/xianbo/trustie2 into sw_new_course
Conflicts: app/views/exercise/_edit_single.html.erb
This commit is contained in:
commit
27c88fda4f
|
@ -189,7 +189,7 @@ class ExerciseController < ApplicationController
|
|||
@exercise_question = ExerciseQuestion.find params[:exercise_question]
|
||||
@exercise_question.question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title]
|
||||
@exercise_question.question_score = params[:question_score]
|
||||
# 处理选项
|
||||
# 处理选项:如果选了某个选项,那么则要删除之前的选项
|
||||
if params[:question_answer]
|
||||
@exercise_question.exercise_choices.each do |answer|
|
||||
answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
|
||||
|
@ -198,21 +198,45 @@ class ExerciseController < ApplicationController
|
|||
question = @exercise_question.exercise_choices.find_by_id params[:question_answer].keys[i-1]
|
||||
answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
|
||||
if question
|
||||
question.exercise_choices_id = i
|
||||
question.answer_text = answer
|
||||
question.choice_position = i
|
||||
question.choice_text = answer
|
||||
question.save
|
||||
else
|
||||
question_option = {
|
||||
:exercise_choice_id => i,
|
||||
:answer_text => answer
|
||||
:choice_position => i,
|
||||
:choice_text => answer
|
||||
}
|
||||
@exercise_question.exercise_answers.new question_option
|
||||
@exercise_question.exercise_choices.new question_option
|
||||
end
|
||||
end
|
||||
end
|
||||
@exercise_question.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
# 更新标准答案
|
||||
if params[:exercise_choice]
|
||||
if @exercise_question.question_type == 3
|
||||
for i in 1..params[:exercise_choice].count
|
||||
# 找到对应的标准答案
|
||||
question_standart = @exercise_question.exercise_standard_answers.find_by_id params[:exercise_choice].keys[i-1]
|
||||
# 标准答案值
|
||||
answer_standart = (params[:exercise_choice].values[i-1].nil? || params[:exercise_choice].values[i-1].empty?) ? l(:label_new_answer) : params[:exercise_choice].values[i-1]
|
||||
if question_standart
|
||||
question_standart.answer_text = answer_standart
|
||||
question_standart.save
|
||||
else
|
||||
standart_answer_option = {
|
||||
:answer_text => question_standart
|
||||
}
|
||||
@exercise_question.exercise_standard_answers.new standart_answer_option
|
||||
end
|
||||
end
|
||||
else
|
||||
answer_standart = @exercise_question.exercise_standard_answers.first
|
||||
answer_standart.exercise_choice_id = @exercise_question.question_type == 1 ? sigle_selection_standard_answer(params[:exercise_choice]) : multiselect_standard_answer(params[:exercise_choice])
|
||||
answer_standart.save
|
||||
end
|
||||
@exercise_question.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -232,7 +256,7 @@ class ExerciseController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#发布问卷
|
||||
# 发布试卷
|
||||
def publish_excercise
|
||||
@exercise.exercise_status = 2
|
||||
@exercise.publish_time = Time.now
|
||||
|
@ -247,6 +271,19 @@ class ExerciseController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 重新发布试卷
|
||||
def republish_excercise
|
||||
@exercise.exercise_questions.each do |exercise_question|
|
||||
exercise_question.exercise_ansers.destroy_all
|
||||
end
|
||||
# @poll.poll_users.destroy_all
|
||||
# @poll.polls_status = 1
|
||||
# @poll.save
|
||||
# respond_to do |format|
|
||||
# format.js
|
||||
# end
|
||||
end
|
||||
|
||||
def student_exercise_list
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
||||
@exercise = Exercise.find params[:id]
|
||||
|
@ -265,7 +302,7 @@ class ExerciseController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 学生提交答卷,选着答案的课程中提交
|
||||
# 学生提交答卷,选中答案的过程中提交
|
||||
def commit_answer
|
||||
eq = ExerciseQuestion.find(params[:exercise_question_id])
|
||||
# 已提交过的则不允许答题
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<% 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>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[<%=index %>]' placeholder='输入选项内容' value="<%=exercise_choice.choice_text %>">
|
||||
<input maxlength="200" type='text' name='question_answer[<%=exercise_choice.id %>]' 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>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
$("#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>: </label>" +
|
||||
"<input maxlength='200' type='text' name='question_answer[<%= index%>]' placeholder='输入选项内容' value='<%=exercise_choice.choice_text %>'/>" +
|
||||
"<input maxlength='200' type='text' name='question_answer[<%= exercise_choice.id %>]' 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>" +
|
||||
|
@ -35,7 +35,7 @@
|
|||
<% 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>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容' value="<%=exercise_choice.choice_text %>">
|
||||
<input maxlength="200" type='text' name='question_answer[<%= exercise_choice.id %>]' 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>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"<li class='ur_item'>" +
|
||||
"<label>候选答案<span class='ur_index'></span>: </label>" +
|
||||
"<input name='exercise_choice[<%=index %>]' placeholder='请输入候选答案' type='text' value='<%=exercise_choice.answer_text %>'/>" +
|
||||
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_candidate_answer($(this));'></a>" +
|
||||
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" +
|
||||
"</li>" +
|
||||
|
@ -34,7 +35,7 @@
|
|||
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
|
||||
<li class="ur_item">
|
||||
<label>候选答案<span class="ur_index"></span>: </label>
|
||||
<input name="exercise_choice[<%=index %>]" placeholder="请输入候选答案" type="text" value="<%=exercise_choice.answer_text %>"/>
|
||||
<input name="exercise_choice[<%=exercise_choice.id %>]" placeholder="请输入候选答案" type="text" value="<%=exercise_choice.answer_text %>"/>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this));"></a>
|
||||
</li>
|
||||
|
|
Loading…
Reference in New Issue