问卷-答题列表

dev_home
caishi 5 years ago
commit 0fb5550d49

@ -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)

@ -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,24 +164,21 @@ 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
if ex_ordered
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
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,
@ -208,12 +191,31 @@ module ExercisesHelper
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,9 +483,18 @@ 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.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
if st_answer_text.include?(u_answer_text) #只要标准答案包含用户的答案,就有分数。同时,下一次循环时,就会删除该标准答案。防止用户的相同答案获分
u.update_column("score",q_score_2)
score2 = score2 + q_score_2
@ -493,6 +504,8 @@ module ExercisesHelper
score2 += 0.0
end
end
end
end
else
score2 += 0.0

@ -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页的相关信息

@ -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

@ -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

@ -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?"":<Divider />}
{opentitletype===true?<style>
{
`
.Osshackathonfontlist{
height: 180px;
overflow: hidden;
}
`
}
</style>:""}
{hackathonedit===true?"":<p className={"Osshackathonfontlist mb30"}>
{data&&data.hackathon.description===null?"":<div className={"markdown-body"}
dangerouslySetInnerHTML={{__html: markdownToHTML(data&&data.hackathon.description).replace(/▁/g, "▁▁▁")}}></div>}
</p>}
{opentitletype===true?<Divider dashed={true} onClick={()=>this.opentitle()} className={"pointer"}>展开阅读全文<Icon type="down" /></Divider>:""}
{hackathonedit===true?<Osshackathonmd
getosshackathon={()=>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?<Row className={"mb20"}>
{this.props.user&&this.props.user.admin===true?<Row className={"mb20 mt30"}>
<Col span={8}></Col>
<Col span={8}><Button type="primary" className={"OsshackprimaryButton OsshackprimaryButtonsyle"} onClick={()=>this.editSignupentry()}><Icon type="plus" />新建项目</Button></Col>
<Col span={8}></Col>

Loading…
Cancel
Save