Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_cs
杨树明 5 years ago
commit 5ca87f9941

@ -526,9 +526,16 @@ class ExerciseQuestionsController < ApplicationController
ExerciseAnswer.create(answer_option) ExerciseAnswer.create(answer_option)
ex_answer_old = 0 ex_answer_old = 0
end end
if ex_obj_score <= 0.0
new_obj_score = @c_score
else
new_obj_score = ex_obj_score - ex_answer_old + @c_score
end
new_obj_score = ex_obj_score - ex_answer_old + @c_score
total_scores = new_obj_score + ex_subj_score total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0
total_scores = 0.0
end
ex_scores = { ex_scores = {
:objective_score => new_obj_score, :objective_score => new_obj_score,
:score => total_scores :score => total_scores
@ -554,6 +561,9 @@ class ExerciseQuestionsController < ApplicationController
end end
total_scores = new_obj_score + ex_subj_score total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0
total_scores = 0.0
end
ex_scores = { ex_scores = {
:objective_score => new_obj_score, :objective_score => new_obj_score,
:score => total_scores :score => total_scores
@ -575,6 +585,9 @@ class ExerciseQuestionsController < ApplicationController
new_sub_score = ex_subj_score + @c_score new_sub_score = ex_subj_score + @c_score
end end
total_scores = ex_obj_score + new_sub_score total_scores = ex_obj_score + new_sub_score
if total_scores < 0.0
total_scores = 0.0
end
ex_scores = { ex_scores = {
:subjective_score => new_sub_score, :subjective_score => new_sub_score,
:score => total_scores :score => total_scores
@ -600,6 +613,9 @@ class ExerciseQuestionsController < ApplicationController
new_obj_score = @c_score new_obj_score = @c_score
end end
total_scores = new_obj_score + ex_subj_score total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0
total_scores = 0.0
end
ex_scores = { ex_scores = {
:objective_score => new_obj_score, :objective_score => new_obj_score,
:score => total_scores :score => total_scores

@ -5,6 +5,6 @@ class ShixunListsController < ApplicationController
private private
def search_params def search_params
params.permit(:keyword, :type, :page, :per_page, :order, :type, :status, :diff) params.permit(:keyword, :type, :page, :limit, :order, :type, :status, :diff)
end end
end end

@ -16,18 +16,26 @@ module ExercisesHelper
end end
if q_type <= Exercise::JUDGMENT if q_type <= Exercise::JUDGMENT
if answers_content.present? #学生有回答时 if answers_content.present? #学生有回答时,分数已经全部存到exercise_answer 表,所以可以直接取第一个值
answer_choice_array = [] ques_score = answers_content.first.score
answers_content.each do |a| ques_score = ques_score < 0 ? 0.0 : ques_score
answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 # answer_choice_array = []
end # answers_content.each do |a|
user_answer_content = answer_choice_array.sort # answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 # end
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 # user_answer_content = answer_choice_array.sort
ques_score = q.question_score # standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
else # if q_type == Exercise::MULTIPLE && standard_answer.size == 1 # 老数据的问题
ques_score = 0.0 # ques_score = answers_content.first.score
end # else
#
# end
# if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
# ques_score = q.question_score
# else
# ques_score = 0.0
# end
else else
ques_score = 0.0 ques_score = 0.0
end end
@ -58,7 +66,6 @@ module ExercisesHelper
exercise_sub_status.each do |s| exercise_sub_status.each do |s|
sub_answer = s.exercise_answers.search_answer_users("user_id",user_id) #主观题只有一个回答 sub_answer = s.exercise_answers.search_answer_users("user_id",user_id) #主观题只有一个回答
if sub_answer.present? && sub_answer.first.score >= 0.0 if sub_answer.present? && sub_answer.first.score >= 0.0
if s.question_score <= sub_answer.first.score if s.question_score <= sub_answer.first.score
stand_status = 1 stand_status = 1
else else
@ -775,22 +782,24 @@ module ExercisesHelper
user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil
elsif ques_type == 5 || ques_type == 3 elsif ques_type == 5 || ques_type == 3
user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0 user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0
else else #选择题,判断题根据第一个记录查分
if exercise_answers.present? #判断题和选择题时, user_score = user_score_pre.present? ? user_score_pre.first.score : 0.0
answer_choice_array = []
exercise_answers.each do |a| # if exercise_answers.present? #判断题和选择题时,
answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 # answer_choice_array = []
end # exercise_answers.each do |a|
user_answer_content = answer_choice_array.sort # answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 # end
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 # user_answer_content = answer_choice_array.sort
user_score = q.question_score # standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
else # if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
user_score = 0.0 # user_score = q.question_score
end # else
else # user_score = 0.0
user_score = 0.0 # end
end # else
# user_score = 0.0
# end
end end
end end

@ -42,7 +42,7 @@ class ShixunSearchService < ApplicationService
def search_options def search_options
model_options = { model_options = {
includes: Shixun.searchable_includes includes: [ :shixun_info, :challenges, :subjects, user: { user_extension: :school } ]
} }
model_options.merge!(where: { id: @shixuns.pluck(:id) }) model_options.merge!(where: { id: @shixuns.pluck(:id) })
model_options.merge!(order: {"myshixuns_count" => sort_str}) model_options.merge!(order: {"myshixuns_count" => sort_str})

@ -2,7 +2,6 @@ json.shixuns_count @results.total_count
json.shixun_list do json.shixun_list do
json.array! @results.with_highlights(multiple: true) do |obj, highlights| json.array! @results.with_highlights(multiple: true) do |obj, highlights|
puts obj
json.merge! obj.to_searchable_json json.merge! obj.to_searchable_json
json.challenge_names obj.challenges.pluck(:subject) json.challenge_names obj.challenges.pluck(:subject)
@ -12,7 +11,7 @@ json.shixun_list do
highlights[:content]&.first&.sub!(reg, '') highlights[:content]&.first&.sub!(reg, '')
json.title highlights.delete(:name)&.join('...') || obj.searchable_title json.title highlights.delete(:name)&.join('...') || obj.searchable_title
json.description highlights[:description]&.join('...') || obj.description json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]
json.content highlights json.content highlights
json.level level_to_s(obj.trainee) json.level level_to_s(obj.trainee)

Loading…
Cancel
Save