From b58c54d6a37c551c33f6e25b05de8dab6edd55d0 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Mon, 24 Jun 2019 14:18:25 +0800 Subject: [PATCH 01/32] fix i18n issue --- config/locales/shixuns/en.yml | 8 ++++---- config/locales/shixuns/zh-CN.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/locales/shixuns/en.yml b/config/locales/shixuns/en.yml index 0f1a9f695..10de1eaef 100644 --- a/config/locales/shixuns/en.yml +++ b/config/locales/shixuns/en.yml @@ -1,7 +1,7 @@ 'en': shixun: status: - 0: editing - 1: applying - 2: published - 3: closed + '0': editing + '1': applying + '2': published + '3': closed diff --git a/config/locales/shixuns/zh-CN.yml b/config/locales/shixuns/zh-CN.yml index c5ba574d8..d7ad5f7e2 100644 --- a/config/locales/shixuns/zh-CN.yml +++ b/config/locales/shixuns/zh-CN.yml @@ -1,7 +1,7 @@ 'zh-CN': shixun: status: - 0: 编辑中 - 1: 审核中 - 2: 已发布 - 3: 已关闭 + '0': 编辑中 + '1': 审核中 + '2': 已发布 + '3': 已关闭 From bdc43fb9ce99905d97fb01eaeb50dca66cf6eb0d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 24 Jun 2019 14:29:19 +0800 Subject: [PATCH 02/32] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E8=AF=BE=E5=A0=82=E7=9A=84=E5=AD=A6=E7=94=9Fapi=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 6 ++++-- .../courses/get_historical_course_students.json.jbuilder | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 8de98f0cb..1bf81e87b 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -737,11 +737,13 @@ class CoursesController < ApplicationController end end - # 获取历史课堂,即用户管理的所有课堂以及课堂下的分班 + # 获取历史课堂,即用户管理的所有课堂以及课堂下的分班(去除当前课堂) def get_historical_courses user_id = current_user.id - @courses = Course.includes(:course_groups).where(tea_id: user_id, is_delete: 0) + @courses = Course.where.not(id: @course.id).joins(:course_members). + where(is_delete: 0, course_members: {user_id: current_user.id, role: %i[CREATOR PROFESSOR ASSISTANT_PROFESSOR]}).includes(:course_groups) + # @courses = Course.includes(:course_groups).where(id: current_user.course_members, is_delete: 0) end # 根据历史课堂的课堂id和分班id获取所有学生 diff --git a/app/views/courses/get_historical_course_students.json.jbuilder b/app/views/courses/get_historical_course_students.json.jbuilder index a2d3a3f57..8dc4e22ce 100644 --- a/app/views/courses/get_historical_course_students.json.jbuilder +++ b/app/views/courses/get_historical_course_students.json.jbuilder @@ -1,6 +1,6 @@ json.students do json.array! @students do |student| - json.course_member_id student.id + json.user_id student.user_id json.name student.user.real_name json.student_id student.user.user_extension.try(:student_id) json.school_name student.user.user_extension.school.try(:name) From 9034e1a53409bfd447baf2ad17aeb0ed8cd668da Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 14:43:07 +0800 Subject: [PATCH 03/32] fix bug --- app/models/exercise.rb | 104 ++++++++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 37 deletions(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 22e2c885b..fb2608632 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -98,59 +98,89 @@ class Exercise < ApplicationRecord #判断是否为分班,如果分班,试卷的截止时间为当前分班时间,否则为试卷的截止时间 def get_exercise_status(user_id) user_group = course.course_members.find_by(user_id: user_id) - if user_group.present? - if user_group.role == "STUDENT" #为学生 - is_teacher = false - else - is_teacher = true - end - ex_time = get_exercise_times(user_id,is_teacher) + if user_group.present? && user_group.role == "STUDENT" #当为学生的时候,需根据分班来判断试卷状态 + ex_time = get_exercise_times(user_id,false) - pb_time = ex_time[:publish_time] - ed_time = ex_time[:end_time] + pb_time = ex_time[:publish_time] + ed_time = ex_time[:end_time] - if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now - status = 2 - elsif ed_time.present? && ed_time <= Time.now - status = 3 - else - status = 1 - end + if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now + status = 2 + elsif ed_time.present? && ed_time <= Time.now + status = 3 + else + status = 1 + end else - status = exercise_status + status = exercise_status #当为老师的时候,则为试卷的总状态 end - Rails.logger.info("#################__________status___________####################{status}") + # if user_group.present? + # if user_group.role == "STUDENT" #为学生 + # is_teacher = false + # else + # is_teacher = true + # end + # ex_time = get_exercise_times(user_id,is_teacher) + # + # pb_time = ex_time[:publish_time] + # ed_time = ex_time[:end_time] + # + # if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now + # status = 2 + # elsif ed_time.present? && ed_time <= Time.now + # status = 3 + # else + # status = 1 + # end + # else + # status = exercise_status + # end status end #获取试卷的发布时间和截止时间。teacher 为boolean,当为true时,表示的是当前为老师 def get_exercise_times(user_id,teacher) - if unified_setting + if unified_setting || teacher #当试卷为统一设置或当前为老师的时候 pb_time = publish_time en_time = end_time + + if end_time <= Time.now && exercise_status != 3 + update_column("exercise_status",3) + end else ex_group_setting = exercise_group_settings - if teacher #当前为老师,为设置组的最大值和最小值 - user_group = course.teacher_course_groups.get_user_groups(user_id) - user_group_ids = user_group.present? ? user_group.pluck(:course_group_id) : course.course_groups.pluck(:id) - user_ex_group_settings = ex_group_setting.find_in_exercise_group("course_group_id",user_group_ids) - pb_time_min = user_ex_group_settings.publish_time_no_null.map(&:publish_time) - en_time_max = user_ex_group_settings.end_time_no_null.map(&:end_time) - pb_time = pb_time_min.size > 0 ? pb_time_min.min : nil - en_time = en_time_max.size > 0 ? en_time_max.max : nil + # if teacher #当前为老师,为设置组的最大值和最小值 + # user_group = course.teacher_course_groups.get_user_groups(user_id) + # user_group_ids = user_group.present? ? user_group.pluck(:course_group_id) : course.course_groups.pluck(:id) + # user_ex_group_settings = ex_group_setting.find_in_exercise_group("course_group_id",user_group_ids) + # pb_time_min = user_ex_group_settings.publish_time_no_null.map(&:publish_time) + # en_time_max = user_ex_group_settings.end_time_no_null.map(&:end_time) + # pb_time = pb_time_min.size > 0 ? pb_time_min.min : nil + # en_time = en_time_max.size > 0 ? en_time_max.max : nil + # else + # user_group = course.students.course_find_by_ids("user_id",user_id) + # if user_group.present? + # user_group_id = user_group.first.course_group_id + # user_ex_group_setting = ex_group_setting.find_in_exercise_group("course_group_id",user_group_id) + # pb_time = user_ex_group_setting.present? ? user_ex_group_setting.first.publish_time : nil + # en_time = user_ex_group_setting.present? ? user_ex_group_setting.first.end_time : nil + # else + # pb_time = nil + # en_time = nil + # end + # end + user_group = course.students.course_find_by_ids("user_id",user_id) + if user_group.present? + user_group_id = user_group.first.course_group_id + user_ex_group_setting = ex_group_setting.find_in_exercise_group("course_group_id",user_group_id) + pb_time = user_ex_group_setting.present? ? user_ex_group_setting.first.publish_time : nil + en_time = user_ex_group_setting.present? ? user_ex_group_setting.first.end_time : nil else - user_group = course.students.course_find_by_ids("user_id",user_id) - if user_group.present? - user_group_id = user_group.first.course_group_id - user_ex_group_setting = ex_group_setting.find_in_exercise_group("course_group_id",user_group_id) - pb_time = user_ex_group_setting.present? ? user_ex_group_setting.first.publish_time : nil - en_time = user_ex_group_setting.present? ? user_ex_group_setting.first.end_time : nil - else - pb_time = nil - en_time = nil - end + pb_time = nil + en_time = nil end end + { "publish_time":pb_time, "end_time":en_time From d8621fc366df1fb7141373d7bcda556ce9055185 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 24 Jun 2019 14:58:06 +0800 Subject: [PATCH 04/32] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=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 | 3 +-- .../courses/get_historical_course_students.json.jbuilder | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1bf81e87b..253bafa48 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -739,8 +739,6 @@ class CoursesController < ApplicationController # 获取历史课堂,即用户管理的所有课堂以及课堂下的分班(去除当前课堂) def get_historical_courses - user_id = current_user.id - @courses = Course.where.not(id: @course.id).joins(:course_members). where(is_delete: 0, course_members: {user_id: current_user.id, role: %i[CREATOR PROFESSOR ASSISTANT_PROFESSOR]}).includes(:course_groups) # @courses = Course.includes(:course_groups).where(id: current_user.course_members, is_delete: 0) @@ -756,6 +754,7 @@ class CoursesController < ApplicationController @students = @students.where(course_group_id: course_group_id) end + @students = @students.includes(user: [user_extension: :school]) @students_count = @students.size end diff --git a/app/views/courses/get_historical_course_students.json.jbuilder b/app/views/courses/get_historical_course_students.json.jbuilder index 8dc4e22ce..be58ff06a 100644 --- a/app/views/courses/get_historical_course_students.json.jbuilder +++ b/app/views/courses/get_historical_course_students.json.jbuilder @@ -2,8 +2,8 @@ json.students do json.array! @students do |student| json.user_id student.user_id json.name student.user.real_name - json.student_id student.user.user_extension.try(:student_id) - json.school_name student.user.user_extension.school.try(:name) + json.student_id student.user.student_id + json.school_name student.user.school_name end end json.students_count @students_count \ No newline at end of file From ff3e34510e95c875dc71d75b6f159479cdafef0f Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 15:19:38 +0800 Subject: [PATCH 05/32] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=9A=84=E7=8A=B6=E6=80=81=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise_answers_controller.rb | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/app/controllers/exercise_answers_controller.rb b/app/controllers/exercise_answers_controller.rb index df6550c0d..7298f2fe7 100644 --- a/app/controllers/exercise_answers_controller.rb +++ b/app/controllers/exercise_answers_controller.rb @@ -94,28 +94,39 @@ class ExerciseAnswersController < ApplicationController def get_exercise_question @exercise_question = ExerciseQuestion.find_by_id(params[:exercise_question_id]) - @exercise = @exercise_question.exercise - @course = @exercise.course - @exercise_user = @exercise.exercise_users.find_by(user_id: current_user.id) #当前用户 + @exercise = @exercise_question&.exercise + @course = @exercise&.course + @exercise_user = @exercise&.exercise_users.find_by(user_id: current_user.id) #当前用户 @exercise_user_status = @exercise.get_exercise_status(current_user.id) - if @exercise_question.blank? normal_status(-1,"试卷问题不存在!") elsif @exercise.blank? normal_status(-1,"试卷不存在!") elsif @course.blank? normal_status(-1,"该课堂不存在!") - elsif (@exercise_user.present? && @exercise_user&.commit_status == 1) || @exercise_user_status == 3 #已提交答案的/时间已结束的试卷不允许再修改 + elsif @exercise_user.blank? + normal_status(-1,"试卷用户不存在!") + elsif @exercise_user_status == 3 || @exercise_user.commit_status == 1 normal_status(-1,"已提交/已结束的试卷不允许修改!") - elsif @exercise.time > 0 - user_start_at = @exercise_user&.start_at - exercise_time = @exercise.time.to_i + 1 # - if (user_start_at + exercise_time.minutes) < Time.now - normal_status(-1,"限时试卷已结束!") + else + if @exercise.time > 0 && @exercise_user.start_at.present? && ((@exercise_user.start_at + (@exercise.time.to_i + 1).minutes) < Time.now) + objective_score = calculate_student_score(@exercise,current_user)[:total_score] + subjective_score = @exercise_user.subjective_score < 0.0 ? 0.0 : @exercise_user.subjective_score + total_score = objective_score + subjective_score + commit_option = { + :status => 1, + :commit_status => 1, + :end_at => Time.now, + :objective_score => objective_score, + :score => total_score, + :subjective_score => subjective_score + } + @exercise_user.update_attributes(commit_option) + normal_status(-1,"试卷提交时间已截止!") end - end + end end From 76d29f9559071fac481ccdcc5db4d4d1482db54a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 24 Jun 2019 15:38:36 +0800 Subject: [PATCH 06/32] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E6=B2=A1=E8=BF=87?= =?UTF-8?q?=E5=85=B3=E5=88=86=E6=95=B0=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 91cff3c19..035b43955 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -182,7 +182,13 @@ class MyshixunsController < ApplicationController test_set_percentage = test_set_score / 100.to_f # 测试集得分比 score = (challenge.score * test_set_percentage * answer_deduction_percentage).to_i # 如果分数比上次多,则更新成绩 - game.update_attributes!(:status => 0, :final_score => score) if game.final_score < score + game_update = + if game.final_score < score + {final_score: score, status: 0} + else + {status: 0} + end + game.update_attributes!(game_update) end end test_cases_time = format("%.3f", (Time.now.to_f - t1.to_f)).to_f From 13f1d15b337a184143eae10ee7bdd8769d8f5491 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 16:01:46 +0800 Subject: [PATCH 07/32] fix but --- app/models/exercise.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index fb2608632..3b3b93f09 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -144,7 +144,7 @@ class Exercise < ApplicationRecord pb_time = publish_time en_time = end_time - if end_time <= Time.now && exercise_status != 3 + if en_time.present? && (en_time <= Time.now) && (exercise_status != 3) update_column("exercise_status",3) end else From a5e63a512485e18145f13d07edb05ae384af557a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 16:07:43 +0800 Subject: [PATCH 08/32] fix but --- app/models/exercise.rb | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 3b3b93f09..0c8b97ca7 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -114,27 +114,6 @@ class Exercise < ApplicationRecord else status = exercise_status #当为老师的时候,则为试卷的总状态 end - # if user_group.present? - # if user_group.role == "STUDENT" #为学生 - # is_teacher = false - # else - # is_teacher = true - # end - # ex_time = get_exercise_times(user_id,is_teacher) - # - # pb_time = ex_time[:publish_time] - # ed_time = ex_time[:end_time] - # - # if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now - # status = 2 - # elsif ed_time.present? && ed_time <= Time.now - # status = 3 - # else - # status = 1 - # end - # else - # status = exercise_status - # end status end @@ -149,26 +128,6 @@ class Exercise < ApplicationRecord end else ex_group_setting = exercise_group_settings - # if teacher #当前为老师,为设置组的最大值和最小值 - # user_group = course.teacher_course_groups.get_user_groups(user_id) - # user_group_ids = user_group.present? ? user_group.pluck(:course_group_id) : course.course_groups.pluck(:id) - # user_ex_group_settings = ex_group_setting.find_in_exercise_group("course_group_id",user_group_ids) - # pb_time_min = user_ex_group_settings.publish_time_no_null.map(&:publish_time) - # en_time_max = user_ex_group_settings.end_time_no_null.map(&:end_time) - # pb_time = pb_time_min.size > 0 ? pb_time_min.min : nil - # en_time = en_time_max.size > 0 ? en_time_max.max : nil - # else - # user_group = course.students.course_find_by_ids("user_id",user_id) - # if user_group.present? - # user_group_id = user_group.first.course_group_id - # user_ex_group_setting = ex_group_setting.find_in_exercise_group("course_group_id",user_group_id) - # pb_time = user_ex_group_setting.present? ? user_ex_group_setting.first.publish_time : nil - # en_time = user_ex_group_setting.present? ? user_ex_group_setting.first.end_time : nil - # else - # pb_time = nil - # en_time = nil - # end - # end user_group = course.students.course_find_by_ids("user_id",user_id) if user_group.present? user_group_id = user_group.first.course_group_id From 9c1ab345193dea5f0248866986d15426b282564b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 16:19:07 +0800 Subject: [PATCH 09/32] fix bug --- app/controllers/exercise_answers_controller.rb | 4 ++-- app/controllers/exercises_controller.rb | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/controllers/exercise_answers_controller.rb b/app/controllers/exercise_answers_controller.rb index 7298f2fe7..cad482390 100644 --- a/app/controllers/exercise_answers_controller.rb +++ b/app/controllers/exercise_answers_controller.rb @@ -107,10 +107,10 @@ class ExerciseAnswersController < ApplicationController normal_status(-1,"该课堂不存在!") elsif @exercise_user.blank? normal_status(-1,"试卷用户不存在!") - elsif @exercise_user_status == 3 || @exercise_user.commit_status == 1 + elsif @exercise_user.commit_status == 1 normal_status(-1,"已提交/已结束的试卷不允许修改!") else - if @exercise.time > 0 && @exercise_user.start_at.present? && ((@exercise_user.start_at + (@exercise.time.to_i + 1).minutes) < Time.now) + if (@exercise_user_status == 3 && @exercise_user.commit_status == 0) || (@exercise.time > 0 && @exercise_user.start_at.present? && ((@exercise_user.start_at + (@exercise.time.to_i + 1).minutes) < Time.now)) objective_score = calculate_student_score(@exercise,current_user)[:total_score] subjective_score = @exercise_user.subjective_score < 0.0 ? 0.0 : @exercise_user.subjective_score total_score = objective_score + subjective_score diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index e1a5ce826..555da8e54 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1632,12 +1632,6 @@ class ExercisesController < ApplicationController normal_status(404,"答题用户不存在") elsif @exercise.get_exercise_status(current_user.id) != 2 || @answer_committed_user.commit_status == 1 # normal_status(-1,"提交错误,试卷已截止/用户已提交!") - # elsif @exercise.time > 0 - # user_start_at = @answer_committed_user.start_at - # exercise_time = @exercise.time.to_i - # if (user_start_at + exercise_time.minutes) < Time.now - # normal_status(-1,"限时试卷已结束,已自动提交!") - # end end end From 3d8c3ed9383547c14fac4ea5609325b0fbc69d3e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 24 Jun 2019 16:23:35 +0800 Subject: [PATCH 10/32] =?UTF-8?q?=E8=83=8C=E6=99=AF=E7=9F=A5=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 8359b14f9..a809e8d2b 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -409,7 +409,7 @@ class ShixunsController < ApplicationController end def propaedeutics - @content = Shixun.where(identifier: params[:identifier]).pluck(:propaedeutics) + @content = Shixun.find_by_identifier!(params[:identifier]).propaedeutics end # 更新背景知识 From 7d8af1c407f6af1c1f79ef059b86504fcb1010d3 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 24 Jun 2019 16:26:07 +0800 Subject: [PATCH 11/32] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E7=9F=A5=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index a809e8d2b..e7a1a8411 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -414,7 +414,7 @@ class ShixunsController < ApplicationController # 更新背景知识 def update_propaedeutics - @shixun.update_column(:propaedeutics, params[:content]) + @shixun.shixun_info.update_column(:propaedeutics, params[:content]) end # 获取推荐实训接口 2个热门实训 + 2个最新实训 From 799ec98df11c84f620559d800e9df32901dcdf2c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 16:46:03 +0800 Subject: [PATCH 12/32] fix but --- app/helpers/exercises_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 478b38204..3ffe177e7 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -56,8 +56,8 @@ module ExercisesHelper } @ex_sub_array.push(sub_score) end - @ex_obj_array.sort_by {|k| k[:q_position]} - @ex_sub_array.sort_by {|k| k[:q_position]} + @ex_obj_array = @ex_obj_array.sort_by {|k| k[:q_position]} + @ex_sub_array = @ex_sub_array.sort_by {|k| k[:q_position]} end #试卷的统计结果页面计算各题的 From a9749fd88615da6778014b2a487e3023448a31f3 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Mon, 24 Jun 2019 16:53:54 +0800 Subject: [PATCH 13/32] remove relationships && move user decorator methods to model --- app/controllers/shixuns_controller.rb | 4 +- app/decorators/user_decorator.rb | 56 --------------- app/libs/util.rb | 5 ++ app/models/relationship.rb | 2 + app/models/user.rb | 72 ++++++++++++++----- app/views/shixuns/collaborators.json.jbuilder | 2 +- 6 files changed, 63 insertions(+), 78 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 8359b14f9..c18e72efa 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -115,8 +115,8 @@ class ShixunsController < ApplicationController def show_right owner = @shixun.owner - #@fans_count = owner.followers.count - #@followed_count = owner.followed_users.count + #@fans_count = owner.fan_count + #@followed_count = owner.follow_count @user_own_shixuns = owner.shixuns.published.count end diff --git a/app/decorators/user_decorator.rb b/app/decorators/user_decorator.rb index 463d9a6e3..e00dead39 100644 --- a/app/decorators/user_decorator.rb +++ b/app/decorators/user_decorator.rb @@ -12,50 +12,6 @@ module UserDecorator logged_user? ? real_name : full_name end - # 关注数 - def follow_count - Watcher.where(user_id: id, watchable_type: %w(Principal User)).count - # User.watched_by(id).count - end - - # 粉丝数 - def fan_count - Watcher.where(watchable_type: %w(Principal User), watchable_id: id).count - # watchers.count - end - - # 是否绑定邮箱 - def email_binded? - mail.present? - end - - # 学院的url标识 - def college_identifier - - Department.find_by_id(department_members.pluck(:department_id).first)&.identifier - end - - # 是否能申请试用 - def can_apply_trial? - return false if certification == 1 - - apply = ApplyAction.order(created_at: :desc).find_by(user_id: id, container_type: 'TrialAuthorization') - - apply.present? && !apply.status.zero? - end - - # 是否已经签到 - def attendance_signed? - attendance = Attendance.find_by(user_id: id) - - attendance.present? && Util.days_between(Time.zone.now, attendance.created_at).zero? - end - - # 明日签到金币 - def tomorrow_attendance_gold - Attendance.find_by(user_id: id)&.next_gold || 50 - end - # ----------- 账号管理 ------------- def authentication_status if authentication? @@ -76,16 +32,4 @@ module UserDecorator 'uncertified' end end - - def base_info_completed? - user_columns = %i[nickname lastname] - user_extension_columns = %i[gender location location_city identity school_id department] - - user_columns.all? { |column| public_send(column).present? } && - user_extension_columns.all? { |column| user_extension.send(column).present? } - end - - def all_certified? - authentication? && professional_certification? - end end \ No newline at end of file diff --git a/app/libs/util.rb b/app/libs/util.rb index f6c8855b9..3485bebd7 100644 --- a/app/libs/util.rb +++ b/app/libs/util.rb @@ -28,4 +28,9 @@ module Util end end end + + def logger_error(exception) + Rails.logger.error(exception.message) + exception.backtrace.each { |message| Rails.logger.error(message) } + end end \ No newline at end of file diff --git a/app/models/relationship.rb b/app/models/relationship.rb index d5c754745..d71987867 100644 --- a/app/models/relationship.rb +++ b/app/models/relationship.rb @@ -1,6 +1,8 @@ +# TODO: 已废弃 class Relationship < ApplicationRecord belongs_to :follower, class_name: "User" belongs_to :followed, class_name: "User" + validates :follower_id, presence: true validates :followed_id, presence: true end diff --git a/app/models/user.rb b/app/models/user.rb index 8e25efe70..1b3349467 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -47,14 +47,6 @@ class User < ApplicationRecord has_many :graduation_works, dependent: :destroy - # 关注 - has_many :relationships, foreign_key: "follower_id", dependent: :destroy - has_many :followed_users, through: :relationships, source: :followed - # 粉丝 - has_many :reverse_relationships, foreign_key: "followed_id", - class_name: "Relationship", - dependent: :destroy - has_many :followers, through: :reverse_relationships, source: :follower has_many :students_for_courses, foreign_key: :student_id, dependent: :destroy has_one :onclick_time, :dependent => :destroy @@ -161,19 +153,16 @@ class User < ApplicationRecord self.user_extension.try(:student_id) end - # 关注总数 - def following?(other_user) - relationships.find_by(followed_id: other_user) - end - - # 关注 - def follow!(other_user) - relationships.create!(followed_id: other_user) + # 关注数 + def follow_count + Watcher.where(user_id: id, watchable_type: %w(Principal User)).count + # User.watched_by(id).count end - # 取消关注 - def unfollow!(other_user) - relationships.find_by(followed_id: other_user.id).destroy + # 粉丝数 + def fan_count + Watcher.where(watchable_type: %w(Principal User), watchable_id: id).count + # watchers.count end # 判断当前用户是否为老师 @@ -545,6 +534,51 @@ class User < ApplicationRecord Educoder::Utils.random_hex(16) end + # 基本资料是否完善 + def base_info_completed? + user_columns = %i[nickname lastname] + user_extension_columns = %i[gender location location_city identity school_id department] + + user_columns.all? { |column| public_send(column).present? } && + user_extension_columns.all? { |column| user_extension.send(column).present? } + end + + # 全部已认证 + def all_certified? + authentication? && professional_certification? + end + + # 是否绑定邮箱 + def email_binded? + mail.present? + end + + # 学院的url标识 + def college_identifier + Department.find_by_id(department_members.pluck(:department_id).first)&.identifier + end + + # 是否能申请试用 + def can_apply_trial? + return false if certification == 1 + + apply = ApplyAction.order(created_at: :desc).find_by(user_id: id, container_type: 'TrialAuthorization') + + apply.present? && !apply.status.zero? + end + + # 是否已经签到 + def attendance_signed? + attendance = Attendance.find_by(user_id: id) + + attendance.present? && Util.days_between(Time.zone.now, attendance.created_at).zero? + end + + # 明日签到金币 + def tomorrow_attendance_gold + Attendance.find_by(user_id: id)&.next_gold || 60 # 基础50,连续签到+10 + end + protected def validate_password_length # 管理员的初始密码是5位 diff --git a/app/views/shixuns/collaborators.json.jbuilder b/app/views/shixuns/collaborators.json.jbuilder index bd880c93e..0101f1e59 100644 --- a/app/views/shixuns/collaborators.json.jbuilder +++ b/app/views/shixuns/collaborators.json.jbuilder @@ -10,7 +10,7 @@ json.array! @members do |member| json.user do json.partial! 'users/user', locals: { user: member.user } json.user_shixuns_count member.user.shixuns.published.count - #json.fans_count member.user.followers.count + #json.fans_count member.user.fan_count json.brief_introduction member.user.user_extension.brief_introduction json.identity member.user.identity json.school_name member.user.school_name From 28c48c996eb3dc94f4e0388d7cd3fec38c7756fb Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 24 Jun 2019 16:57:32 +0800 Subject: [PATCH 14/32] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E5=85=B3=E5=8D=A1=E8=AE=BE=E7=BD=AE=E5=8A=A0=E5=94=AF?= =?UTF-8?q?=E4=B8=80=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 2 +- app/services/homeworks_service.rb | 2 +- ...20_add_uniq_index_to_homework_challenge_settings.rb | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20190624085120_add_uniq_index_to_homework_challenge_settings.rb diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 6217b08c3..6e2e1df40 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -530,7 +530,7 @@ class HomeworkCommonsController < ApplicationController if setting && setting.score != score score_change = true setting.update_attributes(score: score) - else + elsif setting.blank? score_change = true HomeworkChallengeSetting.create!(homework_common_id: @homework.id, challenge_id: challenge[:challenge_id], shixun_id: @homework.homework_commons_shixun.try(:shixun_id), score: score) diff --git a/app/services/homeworks_service.rb b/app/services/homeworks_service.rb index 536d62c66..2affec0ba 100644 --- a/app/services/homeworks_service.rb +++ b/app/services/homeworks_service.rb @@ -165,7 +165,7 @@ class HomeworksService homework = work.homework_common #logger.info("#############member_course_group_id: #{member.try(:course_group_id)}") setting_time = homework.homework_group_setting work.user_id - if setting_time.end_time.present? && (setting_time.end_time > Time.now || (homework.allow_late && !homework.course.is_end)) + if setting_time.end_time.present? && (setting_time.end_time > Time.now || (homework.allow_late && homework.late_time && homework.late_time > Time.now)) #logger.info("#############setting_time: #{setting_time.end_time}") user_total_score = 0 diff --git a/db/migrate/20190624085120_add_uniq_index_to_homework_challenge_settings.rb b/db/migrate/20190624085120_add_uniq_index_to_homework_challenge_settings.rb new file mode 100644 index 000000000..49a385ad9 --- /dev/null +++ b/db/migrate/20190624085120_add_uniq_index_to_homework_challenge_settings.rb @@ -0,0 +1,10 @@ +class AddUniqIndexToHomeworkChallengeSettings < ActiveRecord::Migration[5.2] + def change + remove_index :homework_challenge_settings, [:homework_common_id, :challenge_id] if index_exists?(:homework_challenge_settings, [:homework_common_id, :challenge_id]) + sql = %Q(delete from homework_challenge_settings where (homework_common_id, challenge_id) in + (select * from (select homework_common_id, challenge_id from homework_challenge_settings group by homework_common_id, challenge_id having count(*) > 1) a) + and id not in (select * from (select max(id) from homework_challenge_settings group by homework_common_id, challenge_id having count(*) > 1 order by id) b)) + ActiveRecord::Base.connection.execute sql + add_index :homework_challenge_settings, [:homework_common_id, :challenge_id], unique: true, name: "index_on_homework_common_id_challenge_id" + end +end From 13af28f9ba12fedd6b7d7dadf14913344d6c3d6d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 17:15:58 +0800 Subject: [PATCH 15/32] fix but --- app/controllers/exercises_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 555da8e54..bab1170de 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1016,10 +1016,15 @@ class ExercisesController < ApplicationController @exercise_user_current.update_attribute("start_at",Time.now) end end - if @exercise.time > 0 + ex_time = @exercise.time + if ex_time > 0 + time_mill = ex_time * 60 #转为秒 + exercise_end_time = @exercise.end_time.present? ? @exercise.end_time.to_i : 0 exercise_user_start = @exercise_user_current.present? ? @exercise_user_current.start_at.to_i : 0 - exercise_user_left_time = Time.now.to_i - exercise_user_start - time_mill = @exercise.time * 60 #转为毫秒 + if (exercise_user_start + time_mill) > exercise_end_time + time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时 + end + exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间 @user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 end From a0a109401f32b51900b5d678145f7f5467bacfc5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 24 Jun 2019 17:29:01 +0800 Subject: [PATCH 16/32] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index d603904c4..f2a964c8d 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -206,7 +206,7 @@ class ChallengesController < ApplicationController end # 关卡评测执行文件如果被修改,需要修改脚本内容 script = modify_shixun_script @shixun, @shixun.evaluate_script - @shixun.update_column(:evaluate_script, script) + @shixun.shixun_info.update_column(:evaluate_script, script) # TODO: # if path != params[:challenge][:path] # shixun_modify_status_without_publish(@shixun, 1) From 354b3a907bb8ef7495a696ec093b82d5850e3368 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 17:35:53 +0800 Subject: [PATCH 17/32] fix bug --- app/helpers/exercise_questions_helper.rb | 2 +- app/views/exercises/_shixun_details.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/exercise_questions_helper.rb b/app/helpers/exercise_questions_helper.rb index 28f3fddb0..69dee034f 100644 --- a/app/helpers/exercise_questions_helper.rb +++ b/app/helpers/exercise_questions_helper.rb @@ -32,7 +32,7 @@ module ExerciseQuestionsHelper def shixun_game_scores(challenge,ex_answerer,shixun_type,question_id) game_score = challenge.question_score - game_answers = challenge.exercise_shixun_answers.search_shixun_answers("user_id",ex_answerer.id).search_shixun_answers("exercise_question_id",question_id) + game_answers = challenge.exercise_shixun_answers.where(user_id:ex_answerer.id,exercise_question_id:question_id) if shixun_type == 2 && game_answers.present? #试卷已截止,用户才可以查看答案 s_score = game_answers.first.score else diff --git a/app/views/exercises/_shixun_details.json.jbuilder b/app/views/exercises/_shixun_details.json.jbuilder index 033ac3dc1..c788b8c1c 100644 --- a/app/views/exercises/_shixun_details.json.jbuilder +++ b/app/views/exercises/_shixun_details.json.jbuilder @@ -7,7 +7,7 @@ json.stage_list do json.evaluate_count game.evaluate_count json.finished_time finished_time game.end_time json.time_consuming time_consuming game - json.myself_experience game.final_score #经验值 + json.myself_experience game.final_score < 0 ? 0 : game.final_score #经验值 json.experience game.challenge.all_score #经验值 json.user_score user_score.round(1).to_s #用户获得的分数 json.game_score game_score.round(1).to_s #该关卡的总分数 From 84c714310c0229ba29e58e63df938f72f0adb79a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 18:17:21 +0800 Subject: [PATCH 18/32] fix but --- app/controllers/exercises_controller.rb | 32 ++++++++++++------- app/helpers/exercises_helper.rb | 17 +++++++++- .../exercises/common_header.json.jbuilder | 4 ++- app/views/exercises/index.json.jbuilder | 6 +++- 4 files changed, 45 insertions(+), 14 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index bab1170de..c3e8c4e5d 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -48,6 +48,7 @@ class ExercisesController < ApplicationController @exercises = @exercises_all #老师能看到全部的试卷,不管是已发布的/未发布的/已截止的/统一设置的/私有设置的(看到内容不同) elsif @user_course_identity == Course::STUDENT # 2为课堂成员,能看到统一设置的和自己班级的 @is_teacher_or = 2 + # get_exercise_left_time(@exercise,current_user) member_group_id = @current_student.first.try(:course_group_id).to_i # 成员的分班id,默认为0 if member_group_id == 0 #表示是课堂的未分班成员,只能查看统一设置的试卷(已发布的/已截止的) @exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : [] @@ -204,10 +205,12 @@ class ExercisesController < ApplicationController @is_teacher_or = 0 @user_exercise_answer = @exercise.check_user_answer_status(current_user) @user_commit_counts = 0 + get_exercise_left_time(@exercise,current_user) else @is_teacher_or = 1 @user_exercise_answer = 3 #教师页面 @user_commit_counts = @exercise.exercise_users.where(commit_status:1).count #已提交的用户数 + @user_left_time = nil end @ex_status = @exercise.get_exercise_status(current_user.id) @@ -222,6 +225,8 @@ class ExercisesController < ApplicationController @exercise_publish_count = 1 #试卷未发布,且课堂没有分班的时候 end end + + rescue Exception => e uid_logger_error(e.message) tip_exception("没有权限") @@ -1016,17 +1021,20 @@ class ExercisesController < ApplicationController @exercise_user_current.update_attribute("start_at",Time.now) end end - ex_time = @exercise.time - if ex_time > 0 - time_mill = ex_time * 60 #转为秒 - exercise_end_time = @exercise.end_time.present? ? @exercise.end_time.to_i : 0 - exercise_user_start = @exercise_user_current.present? ? @exercise_user_current.start_at.to_i : 0 - if (exercise_user_start + time_mill) > exercise_end_time - time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时 - end - exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间 - @user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 - end + + get_exercise_left_time(@exercise,@exercise_user_current) + + # ex_time = @exercise.time + # if ex_time > 0 + # time_mill = ex_time * 60 #转为秒 + # exercise_end_time = @exercise.end_time.present? ? @exercise.end_time.to_i : 0 + # exercise_user_start = @exercise_user_current.present? ? @exercise_user_current.start_at.to_i : 0 + # if (exercise_user_start + time_mill) > exercise_end_time + # time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时 + # end + # exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间 + # @user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 + # end @t_user_exercise_status = @exercise.get_exercise_status(current_user.id) @@ -1788,4 +1796,6 @@ class ExercisesController < ApplicationController end end + + end diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 3ffe177e7..b734d9685 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -419,13 +419,13 @@ module ExercisesHelper if game.present? exercise_cha_score = 0.0 answer_status = 0 - cha_path = challenge_path exercise_cha.challenge.path if game.status == 2 && game.final_score >= 0 exercise_cha_score = exercise_cha.question_score #每一关卡的得分 answer_status = 1 end ex_shixun_answer_content = answers_content.where(exercise_shixun_challenge_id: exercise_cha.id) if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 + cha_path = challenge_path exercise_cha.challenge.path game_challenge = game.game_codes.search_challenge_path(cha_path).first if game_challenge.present? game_code = game_challenge @@ -681,6 +681,21 @@ module ExercisesHelper result end + def get_exercise_left_time(exercise,exercise_user) + ex_time = exercise.time + if ex_time > 0 + 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 + if (exercise_user_start + time_mill) > exercise_end_time + time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时 + end + exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间 + @user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 + end + @user_left_time + end + #实训题学生代码的行数 def content_line(content) content.split(/\r?\n/).length diff --git a/app/views/exercises/common_header.json.jbuilder b/app/views/exercises/common_header.json.jbuilder index 68fa45a67..5d33aca66 100644 --- a/app/views/exercises/common_header.json.jbuilder +++ b/app/views/exercises/common_header.json.jbuilder @@ -1,5 +1,7 @@ json.course_is_end @course.is_end # true表示已结束,false表示未结束 -json.extract! @exercise, :id,:exercise_name,:exercise_description,:show_statistic,:time +json.extract! @exercise, :id,:exercise_name,:exercise_description,:show_statistic +json.time @user_left_time + json.exercise_status @ex_status json.user_permission do diff --git a/app/views/exercises/index.json.jbuilder b/app/views/exercises/index.json.jbuilder index 661a8886d..d7d51c343 100644 --- a/app/views/exercises/index.json.jbuilder +++ b/app/views/exercises/index.json.jbuilder @@ -21,7 +21,11 @@ if @exercises_count > 0 json.exercises do json.array! @exercises do |exercise| ex_index = exercise_index_show(exercise,@course,@is_teacher_or,@current_user_) - json.extract! exercise, :id, :exercise_name,:is_public,:created_at,:time + json.extract! exercise, :id, :exercise_name,:is_public,:created_at + if @is_teacher_or == 2 + json.time get_exercise_left_time(exercise,@current_user_) + end + json.exercise_status ex_index[:ex_status] json.lock_status ex_index[:lock_icon] json.publish_time ex_index[:publish_time] # 试卷的发布时间 From 01be5588be227918c6f8b74c70d9a2c9886d40bc Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 18:31:14 +0800 Subject: [PATCH 19/32] fix bug --- app/controllers/exercises_controller.rb | 8 ++++---- app/helpers/exercises_helper.rb | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index c3e8c4e5d..3e4dea5e3 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -201,16 +201,16 @@ class ExercisesController < ApplicationController def common_header ActiveRecord::Base.transaction do begin + @user_left_time = nil if @user_course_identity > Course::ASSISTANT_PROFESSOR @is_teacher_or = 0 @user_exercise_answer = @exercise.check_user_answer_status(current_user) @user_commit_counts = 0 - get_exercise_left_time(@exercise,current_user) + @user_left_time = get_exercise_left_time(@exercise,current_user) else @is_teacher_or = 1 @user_exercise_answer = 3 #教师页面 @user_commit_counts = @exercise.exercise_users.where(commit_status:1).count #已提交的用户数 - @user_left_time = nil end @ex_status = @exercise.get_exercise_status(current_user.id) @@ -1022,8 +1022,6 @@ class ExercisesController < ApplicationController end end - get_exercise_left_time(@exercise,@exercise_user_current) - # ex_time = @exercise.time # if ex_time > 0 # time_mill = ex_time * 60 #转为秒 @@ -1038,10 +1036,12 @@ class ExercisesController < ApplicationController @t_user_exercise_status = @exercise.get_exercise_status(current_user.id) + @user_left_time = nil if @user_course_identity < Course::STUDENT || (@t_user_exercise_status == 3) || (@exercise_user_current.present? && @exercise_user_current.commit_status == 1) @user_exercise_status = 1 #当前用户为老师/试卷已截止/试卷已提交不可编辑 else + @user_left_time = get_exercise_left_time(@exercise,current_user) @user_exercise_status = 0 #可编辑 end diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index b734d9685..3f3229136 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -681,9 +681,11 @@ module ExercisesHelper result end - def get_exercise_left_time(exercise,exercise_user) + def get_exercise_left_time(exercise,user) ex_time = exercise.time + user_left_time = nil if ex_time > 0 + 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 @@ -691,9 +693,9 @@ module ExercisesHelper time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时 end exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间 - @user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 + user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 end - @user_left_time + user_left_time end #实训题学生代码的行数 From 445e9605e5d6949f3a365d2a5b6d2f380cafd121 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 19:49:27 +0800 Subject: [PATCH 20/32] fix bug --- app/helpers/export_helper.rb | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 918995bef..dc2d4abc3 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -35,7 +35,7 @@ module ExportHelper else head_cells_add = [] end - normal_head_b_cells = %w(最终成绩 提交时间 更新时间) + normal_head_b_cells = %w(最终成绩 提交时间 更新时间 评语) @work_head_cells = (head_cells_format + group_cells + normal_head_cells + head_cells_add + allow_late_cell + normal_head_b_cells).reject(&:blank?) works.each_with_index do |w, index| w_user = w.user @@ -85,8 +85,21 @@ module ExportHelper w_15 = w.work_score.nil? ? "未评分" : w.work_score.round(1) w_16 = w.commit_time ? format_time(w.commit_time) : "--" w_17 = w.update_time ? format_time(w.update_time) : "--" + teacher_comments = w.student_works_scores + if teacher_comments.present? + w_18 = "" + teacher_comments.each do |t| + user_name = t.user.real_name + user_time = format_time(t.updated_at) + user_score = t.score + user_comment = t.comment + w_18 = w_18 + (user_name + " " + user_time + " " + user_score + "\n" + user_comment + "\n") + end + else + w_18 = "--" + end - row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16,w_17] + row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16,w_17,w_18] row_cells_column = row_cells_column.reject(&:blank?) @work_cells_column.push(row_cells_column) end @@ -102,7 +115,7 @@ module ExportHelper if allow_late_boolean #允许迟交 eff_score_cell.push("迟交扣分") end - shixun_time_cells = %w(最终成绩 更新时间 提交耗时) + shixun_time_cells = %w(最终成绩 更新时间 提交耗时 评语) @work_head_cells = (head_cells_format + shixun_head_cells + eff_score_cell + shixun_time_cells).reject(&:blank?) works.each_with_index do |w, index| myshixun = w.try(:myshixun) @@ -143,7 +156,20 @@ module ExportHelper w_15 = w.work_score.nil? ? "--" : w.work_score.round(1) w_16 = w.update_time ? format_time(w.update_time) : "--" "更新时间" w_17 = w.cost_time - row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16,w_17] + teacher_comments = w.student_works_scores + if teacher_comments.present? + w_18 = "" + teacher_comments.each do |t| + user_name = t.user.real_name + user_time = format_time(t.updated_at) + user_score = t.score + user_comment = t.comment + w_18 = w_18 + (user_name + " " + user_time + " " + user_score + "\n" + user_comment + "\n") + end + else + w_18 = "--" + end + row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16,w_17,w_18] row_cells_column = row_cells_column.reject(&:blank?) @work_cells_column.push(row_cells_column) end From 11c7b33f2c61c58fa852abce210ad07aa422d345 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 19:53:37 +0800 Subject: [PATCH 21/32] fix but --- 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 dc2d4abc3..ece85c304 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -93,7 +93,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t.score user_comment = t.comment - w_18 = w_18 + (user_name + " " + user_time + " " + user_score + "\n" + user_comment + "\n") + w_18 = w_18 + (user_name + " " + user_time.to_s + " " + user_score.to_s + "\n" + user_comment + "\n") end else w_18 = "--" @@ -164,7 +164,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t.score user_comment = t.comment - w_18 = w_18 + (user_name + " " + user_time + " " + user_score + "\n" + user_comment + "\n") + w_18 = w_18 + (user_name + " " + user_time.to_s + " " + user_score.to_s + "\n" + user_comment + "\n") end else w_18 = "--" From 15d6cb4e6fe950ac29302ee5f2fe0e943e6fa2e1 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 19:58:48 +0800 Subject: [PATCH 22/32] 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 ece85c304..af883131a 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -93,7 +93,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t.score user_comment = t.comment - w_18 = w_18 + (user_name + " " + user_time.to_s + " " + user_score.to_s + "\n" + user_comment + "\n") + w_18 = w_18 + ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n") end else w_18 = "--" @@ -164,7 +164,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t.score user_comment = t.comment - w_18 = w_18 + (user_name + " " + user_time.to_s + " " + user_score.to_s + "\n" + user_comment + "\n") + w_18 = w_18 + ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n") end else w_18 = "--" From edf8335349837f2ba159a14c376c0b09ba9366b0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:03:07 +0800 Subject: [PATCH 23/32] fix bug --- app/views/homework_commons/works_list.xlsx.axlsx | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/homework_commons/works_list.xlsx.axlsx b/app/views/homework_commons/works_list.xlsx.axlsx index 3809c6264..bd111c134 100644 --- a/app/views/homework_commons/works_list.xlsx.axlsx +++ b/app/views/homework_commons/works_list.xlsx.axlsx @@ -1,5 +1,6 @@ wb = xlsx_package.workbook +wb.use_autowidth = false wb.styles do |s| sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} From a1369a1e0c8eb099abbaa7a704e0d189c793d9b3 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:06:19 +0800 Subject: [PATCH 24/32] fix bug --- app/views/homework_commons/works_list.xlsx.axlsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_commons/works_list.xlsx.axlsx b/app/views/homework_commons/works_list.xlsx.axlsx index bd111c134..f8b7098ca 100644 --- a/app/views/homework_commons/works_list.xlsx.axlsx +++ b/app/views/homework_commons/works_list.xlsx.axlsx @@ -2,8 +2,8 @@ wb = xlsx_package.workbook wb.use_autowidth = false wb.styles do |s| - sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} - blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} + sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} + blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} wb.add_worksheet(:name => "学生成绩") do |sheet| sheet.sheet_view.show_grid_lines = false sheet.add_row table_columns, :style => blue_cell From b28bfa532dec085c35a9fbaf9358da977458ce92 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:11:54 +0800 Subject: [PATCH 25/32] fix bug --- app/views/homework_commons/works_list.xlsx.axlsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_commons/works_list.xlsx.axlsx b/app/views/homework_commons/works_list.xlsx.axlsx index f8b7098ca..826bfcc6a 100644 --- a/app/views/homework_commons/works_list.xlsx.axlsx +++ b/app/views/homework_commons/works_list.xlsx.axlsx @@ -1,8 +1,8 @@ wb = xlsx_package.workbook -wb.use_autowidth = false +# wb.use_autowidth = false wb.styles do |s| - sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} + sz_all = s.add_style :height => 20, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} wb.add_worksheet(:name => "学生成绩") do |sheet| sheet.sheet_view.show_grid_lines = false From 85eb3c79a5a2c12718231bc0e15fd997764562e5 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:13:49 +0800 Subject: [PATCH 26/32] fix bug --- app/views/homework_commons/works_list.xlsx.axlsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_commons/works_list.xlsx.axlsx b/app/views/homework_commons/works_list.xlsx.axlsx index 826bfcc6a..116cfb6ef 100644 --- a/app/views/homework_commons/works_list.xlsx.axlsx +++ b/app/views/homework_commons/works_list.xlsx.axlsx @@ -2,8 +2,8 @@ wb = xlsx_package.workbook # wb.use_autowidth = false wb.styles do |s| - sz_all = s.add_style :height => 20, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} - blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} + sz_all = s.add_style :height => 20, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} + blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} wb.add_worksheet(:name => "学生成绩") do |sheet| sheet.sheet_view.show_grid_lines = false sheet.add_row table_columns, :style => blue_cell From 39eba6a7bb5fa184fbddb242a1ca88fc6c4f3952 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:17:14 +0800 Subject: [PATCH 27/32] fix bug --- app/views/homework_commons/works_list.xlsx.axlsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_commons/works_list.xlsx.axlsx b/app/views/homework_commons/works_list.xlsx.axlsx index 116cfb6ef..aab3ac057 100644 --- a/app/views/homework_commons/works_list.xlsx.axlsx +++ b/app/views/homework_commons/works_list.xlsx.axlsx @@ -2,14 +2,14 @@ wb = xlsx_package.workbook # wb.use_autowidth = false wb.styles do |s| - sz_all = s.add_style :height => 20, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} + sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} wb.add_worksheet(:name => "学生成绩") do |sheet| sheet.sheet_view.show_grid_lines = false sheet.add_row table_columns, :style => blue_cell if task_users.count > 0 task_users.each do |user| - sheet.add_row user, :style => sz_all + sheet.add_row user, :height => 20,:style => sz_all end #each_widh_index end sheet.column_widths *([20]*sheet.column_info.count) From b43c58a39ab20fe77a52c9a7083c3d17e0e7657a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:35:51 +0800 Subject: [PATCH 28/32] fix bug --- .../_exercise_questions.json.jbuilder | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 7a05c2e11..04806540f 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -81,6 +81,17 @@ elsif question.question_type == 5 if (exercise_type == 3 || exercise_type == 4) && (shixun_type.present? && shixun_type > 0 ) #教师评阅/试卷截止后,答案公开/试卷未截止,但学生已做了实训题 json.shixun_details do json.array! shixun_challenges do |s| + + + exercise_cha_score = nil + game = Game.user_games(ex_answerer.id,s.challenge_id).first + if game.present? + if game.status == 2 && game.final_score >= 0 + exercise_cha_score = s.question_score #每一关卡的得分 + end + end + json.exercise_cha_socre exercise_cha_score + games_score = shixun_game_scores(s,ex_answerer,shixun_type,question.id) user_get_score = games_score[:s_score].present? ? games_score[:s_score] : 0.0 json.shixun_challenge_id s.id From 418077c59ae0d1086417b4a2e0bb5b9fa1f93ef3 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:42:09 +0800 Subject: [PATCH 29/32] fix bug --- .../_exercise_questions.json.jbuilder | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 04806540f..afba34c9b 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -82,15 +82,16 @@ elsif question.question_type == 5 json.shixun_details do json.array! shixun_challenges do |s| - - exercise_cha_score = nil - game = Game.user_games(ex_answerer.id,s.challenge_id).first - if game.present? - if game.status == 2 && game.final_score >= 0 - exercise_cha_score = s.question_score #每一关卡的得分 - end - end - json.exercise_cha_socre exercise_cha_score + # + # exercise_cha_score = nil + # game = Game.user_games(ex_answerer.id,s.challenge_id).first + # if game.present? + # if game.status == 2 && game.final_score >= 0 + # exercise_cha_score = s.question_score #每一关卡的得分 + # end + # end + user_shixun_score = s.exercise_shixun_answers.where(user_id:ex_answerer.id,exercise_question_id:question.id) + json.exercise_cha_socre user_shixun_score.present? ? user_shixun_score.first.score : -1 games_score = shixun_game_scores(s,ex_answerer,shixun_type,question.id) user_get_score = games_score[:s_score].present? ? games_score[:s_score] : 0.0 From b3bda4ab6596fb839980945d29fcfa286a4e9a34 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:56:59 +0800 Subject: [PATCH 30/32] fix but --- app/helpers/exercises_helper.rb | 64 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 3f3229136..285dbb37e 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -413,43 +413,41 @@ module ExercisesHelper score2 += 0.0 end elsif q.question_type == 5 #实训题时,主观题这里不评分 - if answers_content.present? - q.exercise_shixun_challenges.each do |exercise_cha| - game = Game.user_games(user.id,exercise_cha.challenge_id).first #当前用户的关卡 - if game.present? - exercise_cha_score = 0.0 - answer_status = 0 - if game.status == 2 && game.final_score >= 0 - exercise_cha_score = exercise_cha.question_score #每一关卡的得分 - answer_status = 1 - end - ex_shixun_answer_content = answers_content.where(exercise_shixun_challenge_id: exercise_cha.id) - if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 - cha_path = challenge_path exercise_cha.challenge.path - game_challenge = game.game_codes.search_challenge_path(cha_path).first - if game_challenge.present? - game_code = game_challenge - code = game_code.try(:new_code) - else - code = git_fle_content(exercise_cha.shixun.repo_path,cha_path) - end - sx_option = { - :exercise_question_id => q.id, - :exercise_shixun_challenge_id => exercise_cha.id, - :user_id => user.id, - :score => exercise_cha_score, - :answer_text => code, - :status => answer_status - } - ExerciseShixunAnswer.create(sx_option) + q.exercise_shixun_challenges.each do |exercise_cha| + game = Game.user_games(user.id,exercise_cha.challenge_id)&.first #当前用户的关卡 + if game.present? + exercise_cha_score = 0.0 + answer_status = 0 + if game.status == 2 && game.final_score >= 0 + exercise_cha_score = exercise_cha.question_score #每一关卡的得分 + answer_status = 1 + end + ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id) + if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 + cha_path = challenge_path exercise_cha.challenge.path + game_challenge = game.game_codes.search_challenge_path(cha_path).first + if game_challenge.present? + game_code = game_challenge + code = game_code.try(:new_code) else - ex_shixun_answer_content.first.update_column('score',exercise_cha_score) + code = git_fle_content(exercise_cha.shixun.repo_path,cha_path) end - score5 += exercise_cha_score + sx_option = { + :exercise_question_id => q.id, + :exercise_shixun_challenge_id => exercise_cha.id, + :user_id => user.id, + :score => exercise_cha_score, + :answer_text => code, + :status => answer_status + } + ExerciseShixunAnswer.create(sx_option) + else + ex_shixun_answer_content.first.update_column('score',exercise_cha_score) end + score5 += exercise_cha_score + else + score5 += 0.0 end - else - score5 += 0.0 end end user_scores = answers_content.present? ? answers_content.score_reviewed.pluck(:score).sum : 0.0 From 7f255328d786e88352e279ca9b6528aeb443c6cb Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 21:25:14 +0800 Subject: [PATCH 31/32] fix bug --- app/controllers/concerns/git_helper.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index f6724a654..445d67087 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -9,11 +9,13 @@ module GitHelper # 版本库文件内容,带转码 def git_fle_content(repo_path, path) begin - content = GitService.file_content(repo_path: repo_path, path: path)["content"] - logger.info("@@@@@@@@@@@@@@@@@@#{content}") + content = GitService.file_content(repo_path: repo_path, path: path) + logger.info("@@@@@@@@@@@@@@@@@@#{content}") decode_content = nil if content.present? + content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass + content = Base64.decode64(content) cd = CharDet.detect(content) logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}" @@ -27,6 +29,7 @@ module GitHelper end decode_content + rescue Exception => e uid_logger_error(e.message) raise Educoder::TipException.new("文档内容获取异常") From dae20069e579bd160eb52883b90a18daa2d2cda8 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 21:28:37 +0800 Subject: [PATCH 32/32] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E9=A2=98=E7=9A=84=E8=AF=84=E5=88=86=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_exercise_questions.json.jbuilder | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index afba34c9b..7a05c2e11 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -81,18 +81,6 @@ elsif question.question_type == 5 if (exercise_type == 3 || exercise_type == 4) && (shixun_type.present? && shixun_type > 0 ) #教师评阅/试卷截止后,答案公开/试卷未截止,但学生已做了实训题 json.shixun_details do json.array! shixun_challenges do |s| - - # - # exercise_cha_score = nil - # game = Game.user_games(ex_answerer.id,s.challenge_id).first - # if game.present? - # if game.status == 2 && game.final_score >= 0 - # exercise_cha_score = s.question_score #每一关卡的得分 - # end - # end - user_shixun_score = s.exercise_shixun_answers.where(user_id:ex_answerer.id,exercise_question_id:question.id) - json.exercise_cha_socre user_shixun_score.present? ? user_shixun_score.first.score : -1 - games_score = shixun_game_scores(s,ex_answerer,shixun_type,question.id) user_get_score = games_score[:s_score].present? ? games_score[:s_score] : 0.0 json.shixun_challenge_id s.id