From e10c978c7a4f419cd7c3c3d59026cd5f2ed46bd2 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 22 Aug 2019 13:03:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_answers_controller.rb | 2 +- app/controllers/exercise_questions_controller.rb | 4 ---- app/helpers/exercises_helper.rb | 14 +++++++------- .../20190822022306_add_exercise_user_update.rb | 1 + 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/controllers/exercise_answers_controller.rb b/app/controllers/exercise_answers_controller.rb index babdd50f7..3fc27c8f2 100644 --- a/app/controllers/exercise_answers_controller.rb +++ b/app/controllers/exercise_answers_controller.rb @@ -8,7 +8,7 @@ class ExerciseAnswersController < ApplicationController begin q_type = @exercise_question.question_type #试卷的类型 choice_id = params[:exercise_choice_id].present? ? params[:exercise_choice_id] : "" - answer_text = params[:answer_text].present? ? params[:answer_text] : "" #为字符串 + answer_text = params[:answer_text].present? ? params[:answer_text].strip : "" #为字符串 if q_type < Exercise::SUBJECTIVE && (q_type != Exercise::MULTIPLE) && choice_id.blank? normal_status(-1,"请选择序号") else diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 58f3a7e71..4ce18b59d 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -361,7 +361,6 @@ class ExerciseQuestionsController < ApplicationController if ex_users_committed.size > 0 ex_users_committed.each do |ex_user| update_objective_score = update_single_score(@exercise_question,ex_user.user_id,standard_answer) - Rails.logger.info("#####_________update_objective_score___________##############{update_objective_score}") if update_objective_score != 0 objective_score = ex_user.objective_score new_objective_score = objective_score + update_objective_score @@ -369,9 +368,6 @@ class ExerciseQuestionsController < ApplicationController total_score = total_score < 0.0 ? 0.0 : total_score ex_user.update_attributes(objective_score:new_objective_score,score:total_score) end - Rails.logger.info("#####_________ex_user.score___________##############{ex_user.score}") - # user = ex_user.user - # objective_score = calculate_student_score(@exercise,user)[:total_score] end end normal_status(0,"试卷更新成功,因标准答案修改,需重新计算学生成绩!") diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index d4ecf6d1a..7994e2c6a 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -438,8 +438,8 @@ module ExercisesHelper end if q.is_ordered answers_content.each do |u| - i_standard_answer = standard_answer_array.where(exercise_choice_id:u.exercise_choice_id).pluck(:answer_text).reject(&:blank?).map!(&:downcase) #该选项的全部标准答案 - if i_standard_answer.include?(u.answer_text.downcase) #该空的标准答案包含用户的答案才有分数 + i_standard_answer = standard_answer_array.where(exercise_choice_id:u.exercise_choice_id).pluck(:answer_text).reject(&:blank?).map{|a| a.strip.downcase} #该选项的全部标准答案 + if i_standard_answer.include?(u.answer_text.strip.downcase) #该空的标准答案包含用户的答案才有分数 u.update_column('score',q_score_2) score2 = score2 + q_score_2 else @@ -448,9 +448,9 @@ module ExercisesHelper end end else - st_answer_text = standard_answer_array.pluck(:answer_text).reject(&:blank?).map!(&:downcase) + st_answer_text = standard_answer_array.pluck(:answer_text).reject(&:blank?).map{|a| a.strip.downcase} answers_content.each do |u| - u_answer_text = u.answer_text.downcase + 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 @@ -582,8 +582,8 @@ module ExercisesHelper i_standard_answer += a[:answer_text] end end - i_standard_answer = i_standard_answer.map(&:downcase) - if i_standard_answer.include?(u.answer_text.downcase) #该空的标准答案包含用户的答案才有分数 + i_standard_answer = i_standard_answer.map{|a| a.strip.downcase} + if i_standard_answer.include?(u.answer_text.strip.downcase) #该空的标准答案包含用户的答案才有分数 u.update_column('score',q_score_2) score1 = score1 + q_score_2 else @@ -592,7 +592,7 @@ module ExercisesHelper end end else - st_answer_text = standard_answer.pluck(:answer_text).sum.map(&:downcase) + st_answer_text = standard_answer.pluck(:answer_text).sum.map{|a| a.strip.downcase} answers_content.each do |u| u_answer_text = u.answer_text.downcase if st_answer_text.include?(u_answer_text) #只要标准答案包含用户的答案,就有分数。同时,下一次循环时,就会删除该标准答案。防止用户的相同答案获分 diff --git a/db/migrate/20190822022306_add_exercise_user_update.rb b/db/migrate/20190822022306_add_exercise_user_update.rb index 059553306..f45e6a8ee 100644 --- a/db/migrate/20190822022306_add_exercise_user_update.rb +++ b/db/migrate/20190822022306_add_exercise_user_update.rb @@ -1,6 +1,7 @@ class AddExerciseUserUpdate < ActiveRecord::Migration[5.2] include ExercisesHelper def change + #2019,8,22添加 exs = Exercise.all.is_exercise_published.where("publish_time > ?",(Time.now - 2.months)).includes(:exercise_questions,:exercise_users) exs.each do |ex| ex_users = ex.exercise_users.exercise_user_committed.where("end_at is not null and end_at > ?",(Time.now - 2.months)) From 2461351ce7bcdbb8dc2529d2e96de5157b9699d4 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 22 Aug 2019 13:49:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=A1=B5=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 1 + app/models/course.rb | 2 +- app/views/courses/settings.json.jbuilder | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 14276b4dd..ce6c7f601 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -117,6 +117,7 @@ class CoursesController < ApplicationController # Get /courses/:id/settings # Edit Page def settings + @course_modules = @course.course_modules.where.not(module_type: 'activity') end # POST /courses diff --git a/app/models/course.rb b/app/models/course.rb index baed1efe6..b46464ea6 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -185,7 +185,7 @@ class Course < ApplicationRecord end def all_course_module_types - %w[activity announcement online_learning shixun_homework common_homework group_homework graduation exercise poll attachment board course_group] + %w[activity announcement online_learning shixun_homework common_homework group_homework exercise attachment course_group graduation poll board] end def get_course_module_by_type(type) diff --git a/app/views/courses/settings.json.jbuilder b/app/views/courses/settings.json.jbuilder index 376dc6f6d..27dc9aac4 100644 --- a/app/views/courses/settings.json.jbuilder +++ b/app/views/courses/settings.json.jbuilder @@ -9,7 +9,11 @@ json.start_date @course.start_date json.end_date @course.end_date json.is_public @course.is_public json.course_module_types @course.course_modules.where(hidden: 0).pluck(:module_type) -json.course_module_names @course.course_modules.where(hidden: 0).pluck(:module_name) +json.course_modules @course_modules do |module_type| + json.module_type module_type.module_type + json.hidden module_type.hidden + json.module_name module_type.module_name +end json.authentication @course.authentication json.professional_certification @course.professional_certification json.subject_id @course.subject_id