dev_forum
SylorHuang 5 years ago
parent 05c95fdda9
commit 560332ab09

@ -216,10 +216,19 @@ module ExercisesHelper
ex.exercise_shixun_challenges.each do |c| ex.exercise_shixun_challenges.each do |c|
cha_score = c&.question_score cha_score = c&.question_score
cha_shixun_answer = effictive_users.search_shixun_keys("exercise_shixun_challenge_id",c.id) cha_shixun_answer = effictive_users.search_shixun_keys("exercise_shixun_challenge_id",c.id)
effictive_users_count = cha_shixun_answer.count #实训题的每个关卡的有效填写量 effictive_users_count = cha_shixun_answer.size #实训题的每个关卡的有效填写量
full_scores = cha_shixun_answer.search_shixun_keys("score",cha_score).count #满分人数 full_scores = cha_shixun_answer.search_shixun_keys("score",cha_score).size #满分人数
no_full_scores = cha_shixun_answer.shixun_no_full_scores(cha_score).count #部分分数人数c no_full_scores = cha_shixun_answer.shixun_no_full_scores(cha_score).size #部分分数人数c
all_zero_scores = cha_shixun_answer.search_shixun_keys("score",0.0).count #满分人数 all_zero_scores = cha_shixun_answer.search_shixun_keys("score",0.0).size #零分人数
shiun_scores = user_ids.count * cha_score
shixun_answered_scores = cha_shixun_answer.score_reviewed.pluck(:score).sum #该问题的全部得分
if shixun_answered_scores == 0.0
game_percent = 0.0
else
game_percent = (shixun_answered_scores / shiun_scores.to_f).round(3) * 100 #正确率
end
shixun_score_array = [full_scores,no_full_scores,all_zero_scores] shixun_score_array = [full_scores,no_full_scores,all_zero_scores]
shixun_chas = [] shixun_chas = []
shixun_score_array.each_with_index do |s,index| shixun_score_array.each_with_index do |s,index|
@ -242,7 +251,8 @@ module ExercisesHelper
:cha_id => c.challenge_id, :cha_id => c.challenge_id,
:cha_name => c.challenge.subject, :cha_name => c.challenge.subject,
:cha_position => c.position, :cha_position => c.position,
:cha_details => shixun_chas :cha_details => shixun_chas,
:cha_percent => game_percent
} }
question_answer_infos.push(shixun_new_chas) question_answer_infos.push(shixun_new_chas)
end end

@ -48,6 +48,7 @@ json.commit_results do
json.challenge_id cha[:cha_id] json.challenge_id cha[:cha_id]
json.challenge_name cha[:cha_name] json.challenge_name cha[:cha_name]
json.challenge_position cha[:cha_position] json.challenge_position cha[:cha_position]
json.challenge_percent cha[:cha_percent]
json.challenge_details do json.challenge_details do
json.array! cha[:cha_details] do |ch| json.array! cha[:cha_details] do |ch|
json.choice_position ch[:choice_position] json.choice_position ch[:choice_position]

@ -36,7 +36,7 @@ json.exercises_counts do
json.exercises_all_counts @exercises_select_count #选择后的全部试卷数 json.exercises_all_counts @exercises_select_count #选择后的全部试卷数
json.exercises_unpublish_counts @exercises_unpublish_counts #未发布试卷数 json.exercises_unpublish_counts @exercises_unpublish_counts #未发布试卷数
json.exercises_published_counts @exercises_published_counts #已发布试卷数 json.exercises_published_counts @exercises_published_counts #已发布试卷数
json.exercises_ended_counts @exercises_ended_counts #已截止试卷数 # json.exercises_ended_counts @exercises_ended_counts #已截止试卷数
json.left_banner_id @left_banner_id json.left_banner_id @left_banner_id
json.left_banner_name @left_banner_name json.left_banner_name @left_banner_name
end end

Loading…
Cancel
Save