From 92d85591167d20a7b7753ef5ac397795f157405a Mon Sep 17 00:00:00 2001 From: p31729568 Date: Wed, 13 Nov 2019 09:35:22 +0800 Subject: [PATCH 01/16] competition course 2019 rank data --- .../20191113013258_gcc_course_competition_rank_data.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20191113013258_gcc_course_competition_rank_data.rb diff --git a/db/migrate/20191113013258_gcc_course_competition_rank_data.rb b/db/migrate/20191113013258_gcc_course_competition_rank_data.rb new file mode 100644 index 000000000..344d8061c --- /dev/null +++ b/db/migrate/20191113013258_gcc_course_competition_rank_data.rb @@ -0,0 +1,9 @@ +class GccCourseCompetitionRankData < ActiveRecord::Migration[5.2] + def change + competition = Competition.find_by(identifier: 'gcc-course-2019') + stage = competition.competition_stages.first + return if competition.blank? || stage.blank? + + competition.competition_scores.update_all(competition_stage_id: stage.id) + end +end From 0caae866a35dd2e6e9b049b46d2ba850de72d92e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 10:18:26 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A1=AB=E7=A9=BA?= =?UTF-8?q?=E9=A2=98=E7=9A=84=E5=A4=9A=E7=A9=BA=E7=9A=84=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=8E=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 82 +++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 14 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index ea58ddb55..f5a1e0709 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -185,29 +185,83 @@ module ExercisesHelper standard_answer_count = 0 each_null_score = null_stand_choice.size > 0 ? (ex&.question_score.to_f / null_stand_choice.uniq.size).round(3) : 0.0 all_user_count = 0 - null_stand_choice.each_with_index do |s,index| - user_count = 0 - if ex_ordered #有序排列 + + if ex_ordered + null_stand_choice.each_with_index do |s,index| + user_count = 0 s_choice_text = null_stand_text[index] user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size - else - null_stand_text = null_stand_text.uniq - s_choice_text = null_stand_text[index] - user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户 + # if ex_ordered #有序排列,或者有重复答案的时候,不按无序排列 + # + # else + # # null_stand_text = null_stand_text.uniq + # s_choice_text = null_stand_text[index] + # user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户 + # end + + answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) + answer_option = { + :choice_position => index+1, + :choice_text => s_choice_text, + :choice_users_count => user_count, + :choice_percent => answer_percent.round(2).to_s, + :right_answer => true + } + question_answer_infos.push(answer_option) + all_user_count += user_count + standard_answer_count += 1 end + else + cycled_stand = {} + null_stand_text.each_with_index do |stand, index| + user_count = 0 + if cycled_stand.length > 0 && cycled_stand.keys.include?(stand) + cycled_stand.store(stand, cycled_stand["#{stand}"]) + user_count = cycled_stand["#{stand}"] + calculate_user_count = 0 + else + user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.size + cycled_stand.store(stand, user_count) + calculate_user_count = user_count + end - answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) - answer_option = { + answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) + answer_option = { :choice_position => index+1, - :choice_text => s_choice_text, + :choice_text => stand, :choice_users_count => user_count, :choice_percent => answer_percent.round(2).to_s, :right_answer => true - } - question_answer_infos.push(answer_option) - all_user_count += user_count - standard_answer_count += 1 + } + question_answer_infos.push(answer_option) + all_user_count += calculate_user_count + standard_answer_count += 1 + end end + + # null_stand_choice.each_with_index do |s,index| + # user_count = 0 + # if ex_ordered #有序排列,或者有重复答案的时候,不按无序排列 + # s_choice_text = null_stand_text[index] + # user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size + # else + # # null_stand_text = null_stand_text.uniq + # s_choice_text = null_stand_text[index] + # user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户 + # end + # + # answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) + # answer_option = { + # :choice_position => index+1, + # :choice_text => s_choice_text, + # :choice_users_count => user_count, + # :choice_percent => answer_percent.round(2).to_s, + # :right_answer => true + # } + # question_answer_infos.push(answer_option) + # all_user_count += user_count + # standard_answer_count += 1 + # end answer_user_score = all_user_count * each_null_score percent = (ex_total_score == 0.0 ? 0.0 : (answer_user_score / ex_total_score.to_f).round(3) * 100) #正确率 From 7338ad6e24ae330faa655eb19d7e0eac65b8bbf7 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 10:21:28 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E5=88=A0=E9=99=A4exercise=5Fhelper?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=9A=84=E6=B3=A8=E9=87=8A=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index f5a1e0709..f457ce257 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -238,30 +238,6 @@ module ExercisesHelper standard_answer_count += 1 end end - - # null_stand_choice.each_with_index do |s,index| - # user_count = 0 - # if ex_ordered #有序排列,或者有重复答案的时候,不按无序排列 - # s_choice_text = null_stand_text[index] - # user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size - # else - # # null_stand_text = null_stand_text.uniq - # s_choice_text = null_stand_text[index] - # user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户 - # end - # - # answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) - # answer_option = { - # :choice_position => index+1, - # :choice_text => s_choice_text, - # :choice_users_count => user_count, - # :choice_percent => answer_percent.round(2).to_s, - # :right_answer => true - # } - # question_answer_infos.push(answer_option) - # all_user_count += user_count - # standard_answer_count += 1 - # end answer_user_score = all_user_count * each_null_score percent = (ex_total_score == 0.0 ? 0.0 : (answer_user_score / ex_total_score.to_f).round(3) * 100) #正确率 From d13ec1b18570a6013d87e08e94b24eda99e3527c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 11:41:44 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E5=A1=AB=E7=A9=BA?= =?UTF-8?q?=E9=A2=98=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index f457ce257..adce7a5ac 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -511,17 +511,28 @@ module ExercisesHelper end end else - st_answer_text = standard_answer_array.pluck(:answer_text).reject(&:blank?).map{|a| a.strip.downcase} + st_answer_text = standard_answer_array.pluck(:answer_text).reject(&:blank?).map{|a| a.strip.downcase}.uniq answers_content.each do |u| u_answer_text = u.answer_text.strip.downcase - if st_answer_text.include?(u_answer_text) #只要标准答案包含用户的答案,就有分数。同时,下一次循环时,就会删除该标准答案。防止用户的相同答案获分 - u.update_column("score",q_score_2) - score2 = score2 + q_score_2 - st_answer_text.delete(u_answer_text) + if st_answer_text.size == 1 + if st_answer_text.first == u + u.update_column("score",q_score_2) + score2 = score2 + q_score_2 + else + u.update_column('score',-1.0) + score2 += 0.0 + end else - u.update_column('score',-1.0) - score2 += 0.0 + if st_answer_text.include?(u_answer_text) #只要标准答案包含用户的答案,就有分数。同时,下一次循环时,就会删除该标准答案。防止用户的相同答案获分 + u.update_column("score",q_score_2) + score2 = score2 + q_score_2 + st_answer_text.delete(u_answer_text) + else + u.update_column('score',-1.0) + score2 += 0.0 + end end + end end else From 49c27a00173a1ddabb88733a8c8220384a3075c2 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 14:15:09 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E7=99=BD=E6=A0=87=E5=87=86=E7=AD=94=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index adce7a5ac..f2208e751 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -181,7 +181,7 @@ module ExercisesHelper ex_ordered = ex.is_ordered null_standard_answer = ex.exercise_standard_answers null_stand_choice = null_standard_answer.pluck(:exercise_choice_id).uniq #一个exercise_choice_id可能对应多个answer_text - null_stand_text = null_standard_answer.pluck(:answer_text) + null_stand_text = null_standard_answer.pluck(:answer_text).reject(&:blank?) standard_answer_count = 0 each_null_score = null_stand_choice.size > 0 ? (ex&.question_score.to_f / null_stand_choice.uniq.size).round(3) : 0.0 all_user_count = 0 @@ -191,13 +191,6 @@ module ExercisesHelper user_count = 0 s_choice_text = null_stand_text[index] user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size - # if ex_ordered #有序排列,或者有重复答案的时候,不按无序排列 - # - # else - # # null_stand_text = null_stand_text.uniq - # s_choice_text = null_stand_text[index] - # user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户 - # end answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) answer_option = { From 59edc4eab80259e58e3a8bc671f5fad780be3689 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 14:31:59 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A1=AB=E7=A9=BA?= =?UTF-8?q?=E9=A2=98=E7=9A=84=E6=9C=89=E5=BA=8F=E6=8E=92=E5=BA=8F=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index f2208e751..ae15b0ba3 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -180,7 +180,7 @@ module ExercisesHelper elsif ex.question_type == Exercise::COMPLETION #填空题 ex_ordered = ex.is_ordered null_standard_answer = ex.exercise_standard_answers - null_stand_choice = null_standard_answer.pluck(:exercise_choice_id).uniq #一个exercise_choice_id可能对应多个answer_text + null_stand_choice = null_standard_answer.pluck(:exercise_choice_id) #一个exercise_choice_id可能对应多个answer_text null_stand_text = null_standard_answer.pluck(:answer_text).reject(&:blank?) standard_answer_count = 0 each_null_score = null_stand_choice.size > 0 ? (ex&.question_score.to_f / null_stand_choice.uniq.size).round(3) : 0.0 @@ -191,7 +191,6 @@ module ExercisesHelper user_count = 0 s_choice_text = null_stand_text[index] user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size - answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) answer_option = { :choice_position => index+1, From 25de4363ef03a799c116277a52fc4141ae7ee99c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 15:28:34 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E5=A1=AB?= =?UTF-8?q?=E7=A9=BA=E9=A2=98=E7=9A=84=E7=BB=9F=E8=AE=A1=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index ae15b0ba3..57c4c1aae 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -120,21 +120,7 @@ module ExercisesHelper if ex.question_type > Exercise::COMPLETION #当为主观题和实训题时, ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率 - end - - # if ex.question_type != Exercise::MULTIPLE - # ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 - # percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率 - # else - # multiple_score = 0 - # user_ids.each do |user_id| - # ex_answer_score = ex_answers.select{|answer| answer.user_id == user_id}&.first&.score.to_f - # multiple_score += ex_answer_score - # end - # percent = (ex_total_score == 0.0 ? 0.0 : (multiple_score / ex_total_score.to_f).round(3) * 100) #正确率 - # end - question_answer_infos = [] if ex.question_type <= Exercise::JUDGMENT #选择题和判断题 ex_choices = ex.exercise_choices @@ -178,19 +164,22 @@ module ExercisesHelper question_answer_infos.push(answer_option) end elsif ex.question_type == Exercise::COMPLETION #填空题 + effictive_users_count = effictive_users.pluck(:user_id).uniq.size + ex_ordered = ex.is_ordered null_standard_answer = ex.exercise_standard_answers null_stand_choice = null_standard_answer.pluck(:exercise_choice_id) #一个exercise_choice_id可能对应多个answer_text - null_stand_text = null_standard_answer.pluck(:answer_text).reject(&:blank?) + null_stand_text = null_standard_answer.pluck(:answer_text) standard_answer_count = 0 each_null_score = null_stand_choice.size > 0 ? (ex&.question_score.to_f / null_stand_choice.uniq.size).round(3) : 0.0 all_user_count = 0 if ex_ordered null_stand_choice.each_with_index do |s,index| - user_count = 0 s_choice_text = null_stand_text[index] - user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size + user_count = 0 + user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.pluck(:user_id).uniq.size + # user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) answer_option = { :choice_position => index+1, @@ -212,7 +201,7 @@ module ExercisesHelper user_count = cycled_stand["#{stand}"] calculate_user_count = 0 else - user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.size + user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.pluck(:user_id).uniq.size cycled_stand.store(stand, user_count) calculate_user_count = user_count end From 29afe02630781fc034e2223441f06257fe975849 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 15:42:25 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=A1=AB=E7=A9=BA=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 57c4c1aae..6d95f7c6f 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -178,7 +178,7 @@ module ExercisesHelper null_stand_choice.each_with_index do |s,index| s_choice_text = null_stand_text[index] user_count = 0 - user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.pluck(:user_id).uniq.size + user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.distinct.size # user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) answer_option = { @@ -193,18 +193,21 @@ module ExercisesHelper standard_answer_count += 1 end else - cycled_stand = {} - null_stand_text.each_with_index do |stand, index| + # cycled_stand = {} + null_stand_text.uniq.each_with_index do |stand, index| user_count = 0 - if cycled_stand.length > 0 && cycled_stand.keys.include?(stand) - cycled_stand.store(stand, cycled_stand["#{stand}"]) - user_count = cycled_stand["#{stand}"] - calculate_user_count = 0 - else - user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.pluck(:user_id).uniq.size - cycled_stand.store(stand, user_count) - calculate_user_count = user_count - end + # if cycled_stand.length > 0 && cycled_stand.keys.include?(stand) + # cycled_stand.store(stand, cycled_stand["#{stand}"]) + # user_count = cycled_stand["#{stand}"] + # calculate_user_count = 0 + # else + # user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.pluck(:user_id).uniq.size + # cycled_stand.store(stand, user_count) + # calculate_user_count = user_count + # end + user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.distinct.size + # cycled_stand.store(stand, user_count) + # calculate_user_count = user_count answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) answer_option = { @@ -215,7 +218,7 @@ module ExercisesHelper :right_answer => true } question_answer_infos.push(answer_option) - all_user_count += calculate_user_count + all_user_count += user_count standard_answer_count += 1 end end From 55b0127f114754367516c5794b02f1858e90b203 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 15:43:51 +0800 Subject: [PATCH 09/16] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=A1=AB=E7=A9=BA=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 6d95f7c6f..0229755e2 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -178,7 +178,7 @@ module ExercisesHelper null_stand_choice.each_with_index do |s,index| s_choice_text = null_stand_text[index] user_count = 0 - user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.distinct.size + user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.pluck(:user_id).uniq.size # user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) answer_option = { @@ -205,7 +205,7 @@ module ExercisesHelper # cycled_stand.store(stand, user_count) # calculate_user_count = user_count # end - user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.distinct.size + user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.pluck(:user_id).uniq.size # cycled_stand.store(stand, user_count) # calculate_user_count = user_count From a81d7e660962726e2eb778b912e4bb0b17af846f Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 16:02:00 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E5=A4=9A=E7=A9=BA=E5=A1=AB=E7=A9=BA?= =?UTF-8?q?=E9=A2=98=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 0229755e2..3301330b5 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -165,7 +165,6 @@ module ExercisesHelper end elsif ex.question_type == Exercise::COMPLETION #填空题 effictive_users_count = effictive_users.pluck(:user_id).uniq.size - ex_ordered = ex.is_ordered null_standard_answer = ex.exercise_standard_answers null_stand_choice = null_standard_answer.pluck(:exercise_choice_id) #一个exercise_choice_id可能对应多个answer_text @@ -178,7 +177,7 @@ module ExercisesHelper null_stand_choice.each_with_index do |s,index| s_choice_text = null_stand_text[index] user_count = 0 - user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.pluck(:user_id).uniq.size + user_count = user_count + effictive_users.where("exercise_choice_id = ? and answer_text = ?",s,s_choice_text).pluck(:user_id).uniq.size # user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) answer_option = { @@ -196,19 +195,7 @@ module ExercisesHelper # cycled_stand = {} null_stand_text.uniq.each_with_index do |stand, index| user_count = 0 - # if cycled_stand.length > 0 && cycled_stand.keys.include?(stand) - # cycled_stand.store(stand, cycled_stand["#{stand}"]) - # user_count = cycled_stand["#{stand}"] - # calculate_user_count = 0 - # else - # user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.pluck(:user_id).uniq.size - # cycled_stand.store(stand, user_count) - # calculate_user_count = user_count - # end - user_count = user_count + effictive_users.select{|answer| answer.answer_text == stand }.pluck(:user_id).uniq.size - # cycled_stand.store(stand, user_count) - # calculate_user_count = user_count - + user_count = user_count + effictive_users.where("answer_text = ?",stand).pluck(:user_id).uniq.size answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) answer_option = { :choice_position => index+1, @@ -227,7 +214,7 @@ module ExercisesHelper # percent = commit_user_ids > 0 ? (all_user_count / commit_user_ids.to_f).round(3)*100 : 0.0 - user_wrong_count = (effictive_users_count - all_user_count) + user_wrong_count = effictive_users.where("score < 0").size if effictive_users_count > 0 && user_wrong_count >= 0 wrong_percent = (user_wrong_count / effictive_users_count.to_f ).round(3) From 9af4d4144e0538bb5649a50cdfc4506571611ea7 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 16:04:28 +0800 Subject: [PATCH 11/16] xx --- app/helpers/exercises_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 3301330b5..13ab4706c 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -214,7 +214,7 @@ module ExercisesHelper # percent = commit_user_ids > 0 ? (all_user_count / commit_user_ids.to_f).round(3)*100 : 0.0 - user_wrong_count = effictive_users.where("score < 0").size + user_wrong_count = effictive_users.where("score < 0").pluck(:user_id).uniq.size if effictive_users_count > 0 && user_wrong_count >= 0 wrong_percent = (user_wrong_count / effictive_users_count.to_f ).round(3) From c7c605a2a6aa186af893c192a953473278ed19cf Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 16:19:44 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E7=AD=94?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 13ab4706c..b5168344d 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -213,8 +213,9 @@ module ExercisesHelper percent = (ex_total_score == 0.0 ? 0.0 : (answer_user_score / ex_total_score.to_f).round(3) * 100) #正确率 # percent = commit_user_ids > 0 ? (all_user_count / commit_user_ids.to_f).round(3)*100 : 0.0 - - user_wrong_count = effictive_users.where("score < 0").pluck(:user_id).uniq.size + user_right_count = effictive_users.where("score > 0.0").pluck(:user_id).uniq.size + user_wrong_counts = effictive_users.where("score < 0.0").pluck(:user_id).uniq.size + user_wrong_count = user_wrong_counts - user_right_count if effictive_users_count > 0 && user_wrong_count >= 0 wrong_percent = (user_wrong_count / effictive_users_count.to_f ).round(3) From 0edc8490321e17d7577bc712920d029da445015e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 16:22:35 +0800 Subject: [PATCH 13/16] xx --- app/helpers/exercises_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index b5168344d..bacb95309 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -213,9 +213,9 @@ module ExercisesHelper percent = (ex_total_score == 0.0 ? 0.0 : (answer_user_score / ex_total_score.to_f).round(3) * 100) #正确率 # percent = commit_user_ids > 0 ? (all_user_count / commit_user_ids.to_f).round(3)*100 : 0.0 - user_right_count = effictive_users.where("score > 0.0").pluck(:user_id).uniq.size - user_wrong_counts = effictive_users.where("score < 0.0").pluck(:user_id).uniq.size - user_wrong_count = user_wrong_counts - user_right_count + user_right_count = effictive_users.where("score > 0.0").pluck(:user_id).uniq + user_wrong_counts = effictive_users.where("score < 0.0").pluck(:user_id).uniq + user_wrong_count = (user_wrong_counts - user_right_count).size if effictive_users_count > 0 && user_wrong_count >= 0 wrong_percent = (user_wrong_count / effictive_users_count.to_f ).round(3) From 41eef4c543acc2a8da2809b9eda2ce7a80cd6f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 13 Nov 2019 16:32:47 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E9=BB=91=E5=AE=A2=E6=9D=BE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=82=B9=E5=87=BB=E5=B1=95=E5=BC=80=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/osshackathon/Osshackathon.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/osshackathon/Osshackathon.js b/public/react/src/modules/osshackathon/Osshackathon.js index bf2fdd306..834a6f413 100644 --- a/public/react/src/modules/osshackathon/Osshackathon.js +++ b/public/react/src/modules/osshackathon/Osshackathon.js @@ -20,6 +20,7 @@ class Osshackathon extends Component { hackathonedit:false, Osshackathonmodeltype:false, spinning:false, + opentitletype:true } } @@ -218,8 +219,14 @@ class Osshackathon extends Component { search:e.target.value }) } + + opentitle=()=>{ + this.setState({ + opentitletype:false + }) + } render() { - let {page,data,hackathonedit}=this.state; + let {page,data,hackathonedit,opentitletype}=this.state; return ( @@ -288,11 +295,23 @@ class Osshackathon extends Component { {hackathonedit===true?"":} + {opentitletype===true?:""} {hackathonedit===true?"":

{data&&data.hackathon.description===null?"":

}

} + {opentitletype===true?this.opentitle()} className={"pointer"}>展开阅读全文:""} + {hackathonedit===true?this.getosshackathonlist()} hidehackathonedit={()=>this.hidehackathonedit()} @@ -305,7 +324,7 @@ class Osshackathon extends Component { {...this.props} {...this.state} />:""} - {this.props.user&&this.props.user.admin===true? + {this.props.user&&this.props.user.admin===true? From af89b0d051bfff4f6f80c66f058b3992922b7701 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 16:52:14 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E7=9A=84=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E7=BB=93=E6=9E=9C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/polls_helper.rb | 2 +- app/views/polls/commit_result.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index 03210fccd..866d28254 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -13,7 +13,7 @@ module PollsHelper end def poll_votes_count(votes,user_ids) - votes.find_current_vote("user_id",user_ids.uniq).reject(&:blank?).size + votes.find_current_vote("user_id",user_ids.uniq).pluck(:user_id).uniq.reject(&:blank?).size end #公用tab页的相关信息 diff --git a/app/views/polls/commit_result.json.jbuilder b/app/views/polls/commit_result.json.jbuilder index 795d609a7..f5e983acf 100644 --- a/app/views/polls/commit_result.json.jbuilder +++ b/app/views/polls/commit_result.json.jbuilder @@ -14,7 +14,7 @@ if @poll_questions_count > 0 json.array! @poll_questions do |question| json.partial! "polls/commit_answers_result", question: question, answers:question.poll_answers, - question_votes:question.poll_votes.where(user_id:@poll_commit_ids) #问题的全部答案 + question_votes: question.poll_votes.where(user_id:@poll_commit_ids) #问题的全部答案 end end else From 27d363713effe5b8b40ee82a685e2bdead98a914 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Wed, 13 Nov 2019 16:52:31 +0800 Subject: [PATCH 16/16] fix --- app/controllers/cooperative/base_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/cooperative/base_controller.rb b/app/controllers/cooperative/base_controller.rb index 5ab08582d..556cd7aa9 100644 --- a/app/controllers/cooperative/base_controller.rb +++ b/app/controllers/cooperative/base_controller.rb @@ -16,7 +16,7 @@ class Cooperative::BaseController < ApplicationController private def current_laboratory - @_current_laboratory ||= Laboratory.find_by_subdomain('hut' || request.subdomain) + @_current_laboratory ||= Laboratory.find_by_subdomain(request.subdomain) end def current_setting_or_default(name)