|
|
|
@ -461,45 +461,50 @@ module ExercisesHelper
|
|
|
|
|
end
|
|
|
|
|
elsif q.question_type == 5 #实训题时,主观题这里不评分
|
|
|
|
|
q.exercise_shixun_challenges&.each do |exercise_cha|
|
|
|
|
|
game = Game.user_games(user.id,exercise_cha.challenge_id)&.first #当前用户的关卡
|
|
|
|
|
if game.present?
|
|
|
|
|
exercise_cha_score = 0.0
|
|
|
|
|
answer_status = 0
|
|
|
|
|
# if game.status == 2 && game.final_score >= 0
|
|
|
|
|
if game.final_score > 0
|
|
|
|
|
exercise_cha_score = game.real_score(exercise_cha.question_score)
|
|
|
|
|
# exercise_cha_score = exercise_cha.question_score #每一关卡的得分
|
|
|
|
|
answer_status = 1
|
|
|
|
|
end
|
|
|
|
|
ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id)
|
|
|
|
|
code = nil
|
|
|
|
|
if exercise_cha.challenge&.path.present?
|
|
|
|
|
cha_path = challenge_path(exercise_cha.challenge&.path)
|
|
|
|
|
game_challenge = game.game_codes.search_challenge_path(cha_path)&.first
|
|
|
|
|
if game_challenge.present?
|
|
|
|
|
game_code = game_challenge
|
|
|
|
|
code = game_code.try(:new_code)
|
|
|
|
|
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
|
|
|
|
|
answer_status = 0
|
|
|
|
|
# if game.status == 2 && game.final_score >= 0
|
|
|
|
|
if game.final_score > 0
|
|
|
|
|
exercise_cha_score = game.real_score(exercise_cha.question_score)
|
|
|
|
|
# exercise_cha_score = exercise_cha.question_score #每一关卡的得分
|
|
|
|
|
answer_status = 1
|
|
|
|
|
end
|
|
|
|
|
ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id)
|
|
|
|
|
code = nil
|
|
|
|
|
if exercise_cha.challenge&.path.present?
|
|
|
|
|
cha_path = challenge_path(exercise_cha.challenge&.path)
|
|
|
|
|
game_challenge = game.game_codes.search_challenge_path(cha_path)&.first
|
|
|
|
|
if game_challenge.present?
|
|
|
|
|
game_code = game_challenge
|
|
|
|
|
code = game_code.try(:new_code)
|
|
|
|
|
else
|
|
|
|
|
code = git_fle_content(game.myshixun.repo_path,cha_path)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里
|
|
|
|
|
### Todo 实训题的_shixun_details里的代码是不是直接从这里取出就可以了?涉及到code的多个版本库的修改
|
|
|
|
|
sx_option = {
|
|
|
|
|
:exercise_question_id => q.id,
|
|
|
|
|
:exercise_shixun_challenge_id => exercise_cha.id,
|
|
|
|
|
:user_id => user.id,
|
|
|
|
|
:score => exercise_cha_score.round(1),
|
|
|
|
|
:answer_text => code,
|
|
|
|
|
:status => answer_status
|
|
|
|
|
}
|
|
|
|
|
ExerciseShixunAnswer.create(sx_option)
|
|
|
|
|
else
|
|
|
|
|
code = git_fle_content(game.myshixun.repo_path,cha_path)
|
|
|
|
|
ex_shixun_answer_content.first.update_attributes(score:exercise_cha_score.round(1),answer_text:code)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里
|
|
|
|
|
### Todo 实训题的_shixun_details里的代码是不是直接从这里取出就可以了?涉及到code的多个版本库的修改
|
|
|
|
|
sx_option = {
|
|
|
|
|
:exercise_question_id => q.id,
|
|
|
|
|
:exercise_shixun_challenge_id => exercise_cha.id,
|
|
|
|
|
:user_id => user.id,
|
|
|
|
|
:score => exercise_cha_score.round(1),
|
|
|
|
|
:answer_text => code,
|
|
|
|
|
:status => answer_status
|
|
|
|
|
}
|
|
|
|
|
ExerciseShixunAnswer.create(sx_option)
|
|
|
|
|
score5 += exercise_cha_score
|
|
|
|
|
else
|
|
|
|
|
ex_shixun_answer_content.first.update_attributes(score:exercise_cha_score.round(1),answer_text:code)
|
|
|
|
|
score5 += 0.0
|
|
|
|
|
end
|
|
|
|
|
score5 += exercise_cha_score
|
|
|
|
|
else
|
|
|
|
|
score5 += 0.0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|