From 718f94ac32db0576bbb9b0f81a1cde8cb9692e49 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 18 Jul 2019 16:53:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BA=B5=E5=8C=85?= =?UTF-8?q?=E5=92=8C=E6=95=99=E5=AD=A6=E6=A1=88=E4=BE=8B=E5=AF=BC=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/get_navigation_info.json.jbuilder | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/users/get_navigation_info.json.jbuilder b/app/views/users/get_navigation_info.json.jbuilder index 586ddbd7c..96f54d3d0 100644 --- a/app/views/users/get_navigation_info.json.jbuilder +++ b/app/views/users/get_navigation_info.json.jbuilder @@ -13,6 +13,9 @@ json.top do json.message_url "#{@old_domain}#{@user_url}/user_tidings" json.new_message @new_message + json.moop_cases_url "#{@old_domain}/moop_cases" + json.crowdsourcing_url "#{@old_domain}/crowdsourcing" + json.career_url do json.array! @career.to_a do |c| if c[1].present? From 4482276cbd2f067364a16d75423b91b260c1155d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 18 Jul 2019 17:08:42 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 5ec9bcad4..6f30ba6c3 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -103,9 +103,9 @@ module ExercisesHelper end effictive_users_count = effictive_users.size #有效回答数,可能有重复的用户id,这里仅统计是否回答这个问题的全部人数 - ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 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 @@ -116,15 +116,21 @@ module ExercisesHelper right_users_count = 0 #该问题的正确率 if ex.question_type == Exercise::MULTIPLE #多选题 - user_ids.each do |user_id| - ex_choice_ids = effictive_users.map{|e| e.exercise_choice_id if e.user_id == user_id}.reject(&:blank?).uniq - answer_choice_array = ex_choices.map{|a| a.choice_position if ex_choice_ids.include?(a.id)}.reject(&:blank?).uniq - if answer_choice_array.sort == standard_answer - right_users_count += 1 - end + right_user_ids = user_ids + standard_answer.each do |choice_position| + standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == choice_position}.first.id + right_user_ids = right_user_ids & effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.pluck(:user_id) end + right_users_count = right_user_ids.size + # user_ids.each do |user_id| + # ex_choice_ids = effictive_users.map{|e| e.exercise_choice_id if e.user_id == user_id}.reject(&:blank?).uniq + # answer_choice_array = ex_choices.map{|a| a.choice_position if ex_choice_ids.include?(a.id)}.reject(&:blank?).uniq + # if answer_choice_array.sort == standard_answer + # right_users_count += 1 + # end + # end else #单选题和判断题 - standard_answer_choice_id = ex.exercise_choices.find_by(choice_position: standard_answer.first)&.id + standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first.id right_users_count = effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.size end @@ -157,13 +163,7 @@ module ExercisesHelper user_count = 0 s_choice_text = null_stand_text[index] if ex_ordered #有序排列 - user_ids.each do |u| - user_answers = ex_answers.where(user_id:u,exercise_choice_id:s).select(:answer_text) - user_answers_choice = user_answers.exists? ? user_answers&.first&.answer_text.to_s : "" - if s_choice_text == user_answers_choice - user_count += 1 - end - end + user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size else user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户 end From efd83e4f81db45815cb373e967b2434a8512fe44 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 18 Jul 2019 17:12:19 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=B0=83=E6=95=B4?= 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 6f30ba6c3..ace9e062e 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -118,7 +118,7 @@ module ExercisesHelper if ex.question_type == Exercise::MULTIPLE #多选题 right_user_ids = user_ids standard_answer.each do |choice_position| - standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == choice_position}.first.id + standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == choice_position}.first&.id right_user_ids = right_user_ids & effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.pluck(:user_id) end right_users_count = right_user_ids.size @@ -130,7 +130,7 @@ module ExercisesHelper # end # end else #单选题和判断题 - standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first.id + standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first&.id right_users_count = effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.size end From e25427ff02958e333f99ddf057135c85c82f4a69 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 18 Jul 2019 17:20:13 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index d089c49c3..3ed327c0c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -416,7 +416,7 @@ class User < ApplicationRecord def real_name return '游客' unless logged? name = lastname + firstname - name.blank? ? (nickname.blank? ? login : nickname) : name + name = name.blank? ? (nickname.blank? ? login : nickname) : name name.gsub(/\s+/, '').strip #6.11 -hs end