dev_hs
SylorHuang 6 years ago
parent 620a00cc2a
commit 77496f2858

@ -461,6 +461,10 @@ module ExercisesHelper
end
elsif q.question_type == 5 #实训题时,主观题这里不评分
q.exercise_shixun_challenges&.each do |exercise_cha|
user_shixun_score = exercise_cha&.exercise_shixun_answers&.where(user_id:user.id,exercise_question_id:q.id)
if user_shixun_score.present?
score5 += user_shixun_score&.first.score
else
game = Game.user_games(user.id,exercise_cha.challenge_id)&.first #当前用户的关卡
if game.present?
exercise_cha_score = 0.0
@ -503,6 +507,7 @@ module ExercisesHelper
end
end
end
end
user_scores = answers_content.blank? ? 0.0 : answers_content.score_reviewed.pluck(:score).sum
if user_scores > 0.0
stand_answer = 1

@ -1,38 +0,0 @@
class ReCalculateExerciseUsersSocre < ActiveRecord::Migration[5.2]
include ExercisesHelper
def change
#2019,8,22添加
two_months = Time.now - 2.months
exs = Exercise.all.is_exercise_published.where("publish_time > ?",two_months).includes(:exercise_questions,:exercise_users)
exs.each do |ex|
if ex.exercise_questions.where("created_at < ?",Time.now - 1.month).pluck(:question_type).include?(1) #含有多选题,且是1个月前创建的才更新
ex_users = ex.exercise_users.exercise_user_committed.where("end_at is not null and end_at > ?",two_months)
if ex_users.exists?
ex_users.each do |ex_user|
calculate_score = calculate_student_score(ex,ex_user.user)[:total_score]
subjective_score = ex_user.subjective_score
total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
total_score = calculate_score + total_score_subjective_score
ex_user.update_attributes(score:total_score,objective_score:calculate_score)
puts ex_user.id
end
end
end
end
# #1936的试卷成绩有问题。
# # #https://www.educoder.net/courses/2935/exercises/1936/users/pizfnr5ts
# ex_special = Exercise.find_by_id(1936)
# ex_special_users = ex_special.exercise_users.exercise_user_committed.where("end_at is not null and end_at > ?",two_months)
# if ex_special.present? && ex_special_users.exists?
# ex_special_users.each do |ex_user|
# calculate_score = calculate_student_score(ex_special,ex_user.user)[:total_score]
# subjective_score = ex_user.subjective_score
# total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
# total_score = calculate_score + total_score_subjective_score
# ex_user.update_attributes(score:total_score,objective_score:calculate_score)
# puts ex_user.id
# end
# end
end
end
Loading…
Cancel
Save