From 0be306704cda33b3ab90eb208d6d974fb9451987 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 25 Jun 2019 18:16:03 +0800 Subject: [PATCH 1/4] fix bug --- app/helpers/exercises_helper.rb | 12 ++++++------ app/views/exercises/index.json.jbuilder | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 856f808d7..604258c32 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -369,11 +369,11 @@ module ExercisesHelper standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 if standard_answer.count > 0 - multi_each_score = (q.question_score / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。 + q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。 else - multi_each_score = 0.0 + q_score_1 = 0.0 end - answers_content.update_all(:score => multi_each_score) + answers_content.update_all(:score => q_score_1) score1 = score1 + q.question_score end else @@ -461,13 +461,13 @@ module ExercisesHelper "q_type":q.question_type, "q_position":q.question_number, #该问题的位置 "stand_status":stand_answer, #该问题是否正确,1为正确,0为错误 - "user_score":user_scores #每个问题的总得分 + "user_score":user_scores.round(1) #每个问题的总得分 } ques_stand.push(ques_option) end total_score = score1 + score2 + score5 { - "total_score":total_score, + "total_score":total_score.round(1), "stand_status":ques_stand } end @@ -687,7 +687,7 @@ module ExercisesHelper exercise_user = exercise.exercise_users.find_by(user_id:user.id) time_mill = ex_time * 60 #转为秒 exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0 - exercise_user_start = exercise_user.present? ? exercise_user.start_at.to_i : 0 + exercise_user_start = exercise_user&.start_at.present? ? exercise_user.start_at.to_i : 0 #用户未开始答题时,即exercise_user_start为0 if exercise_user_start == 0 if (exercise_end_time - time_now_i) > time_mill diff --git a/app/views/exercises/index.json.jbuilder b/app/views/exercises/index.json.jbuilder index d7d51c343..4694ecdf0 100644 --- a/app/views/exercises/index.json.jbuilder +++ b/app/views/exercises/index.json.jbuilder @@ -23,7 +23,8 @@ if @exercises_count > 0 ex_index = exercise_index_show(exercise,@course,@is_teacher_or,@current_user_) json.extract! exercise, :id, :exercise_name,:is_public,:created_at if @is_teacher_or == 2 - json.time get_exercise_left_time(exercise,@current_user_) + second_left = get_exercise_left_time(exercise,@current_user_) + json.time second_left.present? ? (second_left / 60) : nil end json.exercise_status ex_index[:ex_status] From d3e0ecc33afe5bba8f21e085e962cff3256355f3 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 25 Jun 2019 18:17:25 +0800 Subject: [PATCH 2/4] fix bug --- app/helpers/export_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 22c10bdb3..b6720c66c 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -92,7 +92,7 @@ module ExportHelper user_name = t.user&.real_name user_time = format_time(t.updated_at) user_score = t&.score - user_comment = t&.comment + user_comment = t.comment.present? ? t.comment : "--" comment_title = "教师:#{user_name}\n时间:#{user_time.to_s}\n分数:#{user_score.to_s}分\n评语:#{user_comment}\n\n" w_18 = w_18 + comment_title end @@ -164,7 +164,7 @@ module ExportHelper user_name = t.user&.real_name user_time = format_time(t.updated_at) user_score = t&.score - user_comment = t&.comment + user_comment = t.comment.present? ? t.comment : "--" comment_title = "教师:#{user_name}\n时间:#{user_time.to_s}\n分数:#{user_score.to_s}分\n评语:#{user_comment}\n\n" # ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n") w_18 = w_18 + comment_title From f6faab935392c4a07d9f83771ebee3b90cfc5407 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 18:21:50 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=BC=93=E5=AD=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/edu_setting.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/edu_setting.rb b/app/models/edu_setting.rb index 4b39dea81..aadb6540c 100644 --- a/app/models/edu_setting.rb +++ b/app/models/edu_setting.rb @@ -20,6 +20,6 @@ class EduSetting < ApplicationRecord private def expire_value_cache - Rails.cache.clear(value_cache_key) + Rails.cache.write(value_cache_key, nil) end end From 264ffe91439482092b9a19dccc8823f7d825c9cd Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 18:40:02 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/edu_setting.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/edu_setting.rb b/app/models/edu_setting.rb index aadb6540c..835aaec76 100644 --- a/app/models/edu_setting.rb +++ b/app/models/edu_setting.rb @@ -20,6 +20,6 @@ class EduSetting < ApplicationRecord private def expire_value_cache - Rails.cache.write(value_cache_key, nil) + Rails.cache.write(value_cache_key, value) end end