problem_set
cxt 5 years ago
parent beab5fecbe
commit 9767091ba4

@ -1129,7 +1129,7 @@ class ExercisesController < ApplicationController
:subjective_score => subjective_score,
:commit_method => @answer_committed_user&.commit_method.to_i > 0 ? @answer_committed_user&.commit_method.to_i : params[:commit_method].to_i
}
@answer_committed_user.update_attributes(commit_option)
@answer_committed_user.update_attributes!(commit_option)
CommitExercsieNotifyJobJob.perform_later(@exercise.id, current_user.id)
normal_status(0,"试卷提交成功!")
else

@ -414,7 +414,7 @@ module ExercisesHelper
score2 = 0.0 #填空题
score5 = 0.0 #实训题
ques_stand = [] #问题是否正确
exercise_questions = exercise.exercise_questions.includes(:exercise_answers,:exercise_shixun_answers,:exercise_standard_answers,:exercise_shixun_challenges)
exercise_questions = exercise.exercise_questions.includes(:exercise_standard_answers,:exercise_shixun_challenges)
exercise_questions&.each do |q|
begin
if q.question_type != 5

@ -69,7 +69,7 @@ class ExercisePublishTask
:subjective_score => subjective_score,
:commit_method => exercise_user&.commit_method.to_i > 0 ? exercise_user&.commit_method.to_i : 3
}
exercise_user.update_attributes(commit_option)
exercise_user.update_attributes!(commit_option)
end
rescue Exception => e
Rails.logger.info("rescue errors ___________________________#{e}")

@ -0,0 +1,25 @@
class MigrateExerciseChallengeScore < ActiveRecord::Migration[5.2]
include ExercisesHelper
def change
exercise = Exercise.find_by(id: 2734)
if exercise
exercise.exercise_users.where("start_at is not null").each do |exercise_user|
if exercise_user.end_at.nil?
calculate_score = calculate_student_score(exercise, exercise_user.user)[:total_score]
subjective_score = exercise_user.subjective_score
total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
total_score = calculate_score + total_score_subjective_score
exercise_user.update_attributes!(score:total_score,objective_score:calculate_score,end_at:exercise.end_time,commit_status:1,status:1,commit_method:3)
puts exercise_user.id
else
calculate_score = ExerciseShixunAnswer.where(user_id: exercise_user.user_id, exercise_question_id: exercise.exercise_questions.pluck(:id)).pluck(:score).sum
subjective_score = exercise_user.subjective_score
total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
total_score = calculate_score + total_score_subjective_score
exercise_user.update_attributes!(score:total_score,objective_score:calculate_score) if total_score > exercise_user.score
puts exercise_user.id
end
end
end
end
end
Loading…
Cancel
Save