diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 7e0b612ff..14d2bdbd0 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -497,7 +497,6 @@ class ExerciseQuestionsController < ApplicationController ex_obj_score = @exercise_current_user.objective_score #全部客观题得分 ex_subj_score = @exercise_current_user.subjective_score < 0.0 ? 0.0 : @exercise_current_user.subjective_score #全部主观题得分 ex_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分 - ex_answer_create = nil if @exercise_question.question_type == Exercise::MULTIPLE if ex_answers.present? #学生有回答时 取学生的答题得分,否则0分 answer_choice_array = [] @@ -526,7 +525,7 @@ class ExerciseQuestionsController < ApplicationController :score => @c_score, :answer_text => "" } - ExerciseAnswer.new(answer_option) + ExerciseAnswer.create(answer_option) ex_answer_old = 0 end if ex_obj_score <= 0.0 @@ -538,6 +537,8 @@ class ExerciseQuestionsController < ApplicationController total_scores = new_obj_score + ex_subj_score if total_scores < 0.0 total_scores = 0.0 + elsif total_scores > @exercise.score + total_scores = @exercise.score end ex_scores = { :objective_score => new_obj_score, @@ -566,6 +567,8 @@ class ExerciseQuestionsController < ApplicationController total_scores = new_obj_score + ex_subj_score if total_scores < 0.0 total_scores = 0.0 + elsif total_scores > @exercise.score + total_scores = @exercise.score end ex_scores = { :objective_score => new_obj_score, @@ -590,6 +593,8 @@ class ExerciseQuestionsController < ApplicationController total_scores = ex_obj_score + new_sub_score if total_scores < 0.0 total_scores = 0.0 + elsif total_scores > @exercise.score + total_scores = @exercise.score end ex_scores = { :subjective_score => new_sub_score, @@ -618,6 +623,8 @@ class ExerciseQuestionsController < ApplicationController total_scores = new_obj_score + ex_subj_score if total_scores < 0.0 total_scores = 0.0 + elsif total_scores > @exercise.score + total_scores = @exercise.score end ex_scores = { :objective_score => new_obj_score, @@ -630,7 +637,7 @@ class ExerciseQuestionsController < ApplicationController if question_comment.present? comment_option = { - :comment => comments.present? ? comments : question_comment.comment, + :comment => comments, :score => @c_score, :exercise_answer_id => ex_answers.present? ? ex_answers.first.id : nil, :user_id => current_user.id