From 9a61ad3e9d6db68f1177bdf8420193d1f54662b1 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Sep 2019 14:53:44 +0800 Subject: [PATCH 1/5] =?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/views/shixun_lists/index.json.jbuilder | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/shixun_lists/index.json.jbuilder b/app/views/shixun_lists/index.json.jbuilder index 526fcaab9..83437af77 100644 --- a/app/views/shixun_lists/index.json.jbuilder +++ b/app/views/shixun_lists/index.json.jbuilder @@ -2,7 +2,6 @@ json.shixuns_count @results.total_count json.shixun_list do json.array! @results.with_highlights(multiple: true) do |obj, highlights| - puts obj json.merge! obj.to_searchable_json json.challenge_names obj.challenges.pluck(:subject) @@ -12,7 +11,7 @@ json.shixun_list do highlights[:content]&.first&.sub!(reg, '') 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..Searchable::MAXIMUM_LENGTH] json.content highlights json.level level_to_s(obj.trainee) From 4e1bc05a28e02d60db897eb4ab463f4658d07dfc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Sep 2019 14:55:29 +0800 Subject: [PATCH 2/5] =?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/views/shixun_lists/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shixun_lists/index.json.jbuilder b/app/views/shixun_lists/index.json.jbuilder index 83437af77..d6c651743 100644 --- a/app/views/shixun_lists/index.json.jbuilder +++ b/app/views/shixun_lists/index.json.jbuilder @@ -11,7 +11,7 @@ json.shixun_list do highlights[:content]&.first&.sub!(reg, '') json.title highlights.delete(:name)&.join('...') || obj.searchable_title - json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..Searchable::MAXIMUM_LENGTH] + json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300] json.content highlights json.level level_to_s(obj.trainee) From 33ea0976273852f45fbb3b4063bdbbada82f28db Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 12 Sep 2019 15:00:54 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise_questions_controller.rb | 18 +++++++++- app/helpers/exercises_helper.rb | 34 ++++++++++--------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index e8889847d..8cefa5071 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -526,9 +526,16 @@ class ExerciseQuestionsController < ApplicationController ExerciseAnswer.create(answer_option) ex_answer_old = 0 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 + if total_scores < 0.0 + total_scores = 0.0 + end ex_scores = { :objective_score => new_obj_score, :score => total_scores @@ -554,6 +561,9 @@ class ExerciseQuestionsController < ApplicationController end total_scores = new_obj_score + ex_subj_score + if total_scores < 0.0 + total_scores = 0.0 + end ex_scores = { :objective_score => new_obj_score, :score => total_scores @@ -575,6 +585,9 @@ class ExerciseQuestionsController < ApplicationController new_sub_score = ex_subj_score + @c_score end total_scores = ex_obj_score + new_sub_score + if total_scores < 0.0 + total_scores = 0.0 + end ex_scores = { :subjective_score => new_sub_score, :score => total_scores @@ -600,6 +613,9 @@ class ExerciseQuestionsController < ApplicationController new_obj_score = @c_score end total_scores = new_obj_score + ex_subj_score + if total_scores < 0.0 + total_scores = 0.0 + end ex_scores = { :objective_score => new_obj_score, :score => total_scores diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 2c417ea74..1f421557e 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -775,22 +775,24 @@ module ExercisesHelper user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil elsif ques_type == 5 || ques_type == 3 user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0 - else - if exercise_answers.present? #判断题和选择题时, - answer_choice_array = [] - exercise_answers.each do |a| - answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 - end - user_answer_content = answer_choice_array.sort - standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 - if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 - user_score = q.question_score - else - user_score = 0.0 - end - else - user_score = 0.0 - end + else #选择题,判断题根据第一个记录查分 + user_score = user_score_pre.present? ? user_score_pre.first.score : 0.0 + + # if exercise_answers.present? #判断题和选择题时, + # answer_choice_array = [] + # exercise_answers.each do |a| + # answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 + # end + # user_answer_content = answer_choice_array.sort + # standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 + # if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 + # user_score = q.question_score + # else + # user_score = 0.0 + # end + # else + # user_score = 0.0 + # end end end From 8105df7623f050d5dd9fd7114de2f5280251aa15 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 12 Sep 2019 15:18:53 +0800 Subject: [PATCH 4/5] change answer_status --- app/helpers/exercises_helper.rb | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 1f421557e..98a580ecc 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -16,18 +16,26 @@ module ExercisesHelper end if q_type <= Exercise::JUDGMENT - if answers_content.present? #学生有回答时 - answer_choice_array = [] - answers_content.each do |a| - answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 - end - user_answer_content = answer_choice_array.sort - standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 - if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 - ques_score = q.question_score - else - ques_score = 0.0 - end + if answers_content.present? #学生有回答时,分数已经全部存到exercise_answer 表,所以可以直接取第一个值 + ques_score = answers_content.first.score + ques_score = ques_score < 0 ? 0.0 : ques_score + # answer_choice_array = [] + # answers_content.each do |a| + # answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 + # end + # user_answer_content = answer_choice_array.sort + # standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 + # if q_type == Exercise::MULTIPLE && standard_answer.size == 1 # 老数据的问题 + # ques_score = answers_content.first.score + # else + # + # end + + # if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 + # ques_score = q.question_score + # else + # ques_score = 0.0 + # end else ques_score = 0.0 end @@ -58,7 +66,6 @@ module ExercisesHelper exercise_sub_status.each do |s| sub_answer = s.exercise_answers.search_answer_users("user_id",user_id) #主观题只有一个回答 if sub_answer.present? && sub_answer.first.score >= 0.0 - if s.question_score <= sub_answer.first.score stand_status = 1 else From f0f7bba75f94c9b31fa12f791428af19f0625fd0 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Sep 2019 15:21:48 +0800 Subject: [PATCH 5/5] =?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/controllers/shixun_lists_controller.rb | 2 +- app/services/shixun_search_service.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/shixun_lists_controller.rb b/app/controllers/shixun_lists_controller.rb index a39a6b34f..e92e857ad 100644 --- a/app/controllers/shixun_lists_controller.rb +++ b/app/controllers/shixun_lists_controller.rb @@ -5,6 +5,6 @@ class ShixunListsController < ApplicationController private 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 \ No newline at end of file diff --git a/app/services/shixun_search_service.rb b/app/services/shixun_search_service.rb index 820919dd1..911f341f8 100644 --- a/app/services/shixun_search_service.rb +++ b/app/services/shixun_search_service.rb @@ -42,7 +42,7 @@ class ShixunSearchService < ApplicationService def search_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!(order: {"myshixuns_count" => sort_str})