|
|
@ -223,7 +223,6 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#试卷未发布时,当标准答案存在时,可修改标准答案内容,可增删标准答案,否则只能修改标准答案,不能增删标准答案
|
|
|
|
#试卷未发布时,当标准答案存在时,可修改标准答案内容,可增删标准答案,否则只能修改标准答案,不能增删标准答案
|
|
|
|
st_count = 0
|
|
|
|
|
|
|
|
@exercise_answers_array = @exercise_question.exercise_standard_answers #问卷的全部标准答案
|
|
|
|
@exercise_answers_array = @exercise_question.exercise_standard_answers #问卷的全部标准答案
|
|
|
|
if standard_answer.present?
|
|
|
|
if standard_answer.present?
|
|
|
|
if @exercise_question.question_type <= 2 #选择题/判断题,标准答案为一个或多个
|
|
|
|
if @exercise_question.question_type <= 2 #选择题/判断题,标准答案为一个或多个
|
|
|
@ -232,7 +231,6 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
old_left_standard_choices = exercise_standard_choices - common_standard_choices # 以前的差集共同的,剩余的表示需要删掉
|
|
|
|
old_left_standard_choices = exercise_standard_choices - common_standard_choices # 以前的差集共同的,剩余的表示需要删掉
|
|
|
|
new_left_standard_choices = standard_answer - common_standard_choices # 传入的标准答案差集共同的,剩余的表示需要新建
|
|
|
|
new_left_standard_choices = standard_answer - common_standard_choices # 传入的标准答案差集共同的,剩余的表示需要新建
|
|
|
|
if old_left_standard_choices.count > 0
|
|
|
|
if old_left_standard_choices.count > 0
|
|
|
|
st_count += 1
|
|
|
|
|
|
|
|
@exercise_answers_array.standard_by_ids(old_left_standard_choices).destroy_all
|
|
|
|
@exercise_answers_array.standard_by_ids(old_left_standard_choices).destroy_all
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if new_left_standard_choices.count > 0 #新建标准答案
|
|
|
|
if new_left_standard_choices.count > 0 #新建标准答案
|
|
|
@ -258,7 +256,6 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
#删除多余的选项
|
|
|
|
#删除多余的选项
|
|
|
|
if old_ex_answer_choice_ids.count > new_ex_answer_choice_ids.count #有减少的填空
|
|
|
|
if old_ex_answer_choice_ids.count > new_ex_answer_choice_ids.count #有减少的填空
|
|
|
|
st_count += 1
|
|
|
|
|
|
|
|
delete_ex_answer_choice_ids = old_ex_answer_choice_ids - new_ex_answer_choice_ids
|
|
|
|
delete_ex_answer_choice_ids = old_ex_answer_choice_ids - new_ex_answer_choice_ids
|
|
|
|
old_ex_answer.standard_by_ids(delete_ex_answer_choice_ids).destroy_all
|
|
|
|
old_ex_answer.standard_by_ids(delete_ex_answer_choice_ids).destroy_all
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -284,7 +281,6 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
ex_answer_pre[n-1].update(standard_option)
|
|
|
|
ex_answer_pre[n-1].update(standard_option)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if new_add_choice.count > 0 #表示有新增的
|
|
|
|
if new_add_choice.count > 0 #表示有新增的
|
|
|
|
st_count += 1
|
|
|
|
|
|
|
|
new_add_choice.each do |i|
|
|
|
|
new_add_choice.each do |i|
|
|
|
|
standard_option = {
|
|
|
|
standard_option = {
|
|
|
|
:exercise_question_id => @exercise_question.id,
|
|
|
|
:exercise_question_id => @exercise_question.id,
|
|
|
@ -306,7 +302,6 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
ex_answer_pre[index].update(standard_option)
|
|
|
|
ex_answer_pre[index].update(standard_option)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if new_delete_choice.count > 0 #表示填空题的答案有删减的
|
|
|
|
if new_delete_choice.count > 0 #表示填空题的答案有删减的
|
|
|
|
st_count += 1
|
|
|
|
|
|
|
|
new_delete_choice.each do |d|
|
|
|
|
new_delete_choice.each do |d|
|
|
|
|
ex_answer_pre[d-1].destroy
|
|
|
|
ex_answer_pre[d-1].destroy
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -350,8 +345,21 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
@exercise_question.shixun_name = shixun_name
|
|
|
|
@exercise_question.shixun_name = shixun_name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#当标准答案修改时,如有已提交的学生,需重新计算分数
|
|
|
|
#当试卷已发布时(试卷的总状态),当标准答案修改时,如有已提交的学生,需重新计算分数.
|
|
|
|
if st_count > 0
|
|
|
|
|
|
|
|
|
|
|
|
# if @exercise.exercise_status == 2
|
|
|
|
|
|
|
|
# ex_users_committed = @exercise.exercise_users.exercise_user_committed
|
|
|
|
|
|
|
|
# if ex_users_committed.size > 0
|
|
|
|
|
|
|
|
# ex_users_committed.each do |ex_user|
|
|
|
|
|
|
|
|
# user = ex_user.user
|
|
|
|
|
|
|
|
# objective_score = calculate_student_score(@exercise,user)[:total_score]
|
|
|
|
|
|
|
|
# subjective_score = ex_user.subjective_score
|
|
|
|
|
|
|
|
# total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
|
|
|
|
|
|
|
|
# total_score = objective_score + total_score_subjective_score
|
|
|
|
|
|
|
|
# ex_user.update_attributes(objective_score:objective_score,score:total_score)
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
# end
|
|
|
|
ex_users_committed = @exercise.exercise_users.exercise_user_committed
|
|
|
|
ex_users_committed = @exercise.exercise_users.exercise_user_committed
|
|
|
|
if ex_users_committed.size > 0
|
|
|
|
if ex_users_committed.size > 0
|
|
|
|
ex_users_committed.each do |ex_user|
|
|
|
|
ex_users_committed.each do |ex_user|
|
|
|
@ -363,7 +371,6 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
ex_user.update_attributes(objective_score:objective_score,score:total_score)
|
|
|
|
ex_user.update_attributes(objective_score:objective_score,score:total_score)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if @exercise_question.save
|
|
|
|
if @exercise_question.save
|
|
|
|
normal_status(0,"试卷更新成功!")
|
|
|
|
normal_status(0,"试卷更新成功!")
|
|
|
@ -587,15 +594,15 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
if @exercise_question.present?
|
|
|
|
if @exercise_question.present?
|
|
|
|
@exercise = @exercise_question.exercise
|
|
|
|
@exercise = @exercise_question.exercise
|
|
|
|
if @exercise.blank?
|
|
|
|
if @exercise.blank?
|
|
|
|
tip_exception(404)
|
|
|
|
tip_exception(404,"试卷不存在")
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@course = @exercise.course
|
|
|
|
@course = @exercise.course
|
|
|
|
if @course.blank?
|
|
|
|
if @course.blank?
|
|
|
|
tip_exception(404)
|
|
|
|
tip_exception(404,"课堂不存在")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
tip_exception(404)
|
|
|
|
tip_exception(404,"试卷问题不存在")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|