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)
diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb
index ea58ddb55..bacb95309 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,42 +164,58 @@ 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).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)
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 #有序排列
- 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 = {
+ if ex_ordered
+ 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.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 = {
: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
+ }
+ question_answer_infos.push(answer_option)
+ all_user_count += user_count
+ standard_answer_count += 1
+ end
+ else
+ # cycled_stand = {}
+ null_stand_text.uniq.each_with_index do |stand, index|
+ user_count = 0
+ 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,
+ :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
+ end
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) #正确率
# 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_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)
@@ -481,17 +483,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
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
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
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?"":
{data&&data.hackathon.description===null?"":
} } + {opentitletype===true?