From 13557bb96f20c1897555a82d310c3a96c819132b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 24 Jul 2019 08:47:10 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=8F=82=E8=80=83=E7=AD=94=E6=A1=88?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E4=B8=8D=E8=83=BD=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 9b5f0b869..fdaa30305 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -230,11 +230,16 @@ class ChallengesController < ApplicationController def crud_answer raise '参考答案不能为空' if params[:challenge_answer].empty? raise '占比之和必须为100%' if params[:challenge_answer].map{|a| a[:score]}.sum != 100 - @challenge.challenge_answers.destroy_all if @challenge.challenge_answers - params[:challenge_answer].each_with_index do |answer, index| - ChallengeAnswer.create(name: answer[:name], contents: answer[:contents], - level: index+1, score: answer[:score], challenge_id: @challenge.id) + ActiveRecord::Base.transaction do + @challenge.challenge_answers.destroy_all if @challenge.challenge_answers + params[:challenge_answer].each_with_index do |answer, index| + # 内容为空不保存 + next if answer[:contents].blank? + ChallengeAnswer.create(name: answer[:name], contents: answer[:contents], + level: index+1, score: answer[:score], challenge_id: @challenge.id) + end end + end # 查看参考答案接口 From 2887de4c4e0bfbb9527e49efdf5070c95f51b2a7 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 24 Jul 2019 09:36:16 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=85=B3=E5=8D=A1=E6=AF=94=E4=BE=8B?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=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/models/game.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/game.rb b/app/models/game.rb index ae056a702..d81b794a5 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -31,7 +31,7 @@ class Game < ApplicationRecord # 根据得分比例来算实际得分(试卷、实训作业) def real_score score - (final_score.to_f / challenge.all_score) * score + ((final_score < 0 ? 0 : final_score).to_f / challenge.all_score) * score end # 判断实训是否全部通关 From 3cf598eeecd30613b59786ae8bc7f677a623892d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 24 Jul 2019 09:58:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=99=E5=B8=88?= =?UTF-8?q?=E5=BC=B9=E6=A1=86=E7=9A=84=E6=95=99=E5=B8=88=E5=A7=93=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/search_teacher_candidate.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/search_teacher_candidate.json.jbuilder b/app/views/courses/search_teacher_candidate.json.jbuilder index 33bed4100..49109b729 100644 --- a/app/views/courses/search_teacher_candidate.json.jbuilder +++ b/app/views/courses/search_teacher_candidate.json.jbuilder @@ -1,7 +1,7 @@ json.candidates do json.array! @users do |user| json.id user.id - json.name user.firstname + user.lastname + json.name user.real_name json.nickname user.nickname json.school_name user.user_extension.school.try(:name) json.school_id user.user_extension.school.try(:id) From 50cf5000faf869668f754b926fe374dfa2f50d5a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 24 Jul 2019 10:20:42 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=99=E5=B8=88?= =?UTF-8?q?=E7=9A=84=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 6042fbc9a..973e73dac 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -315,7 +315,7 @@ class CoursesController < ApplicationController # @users = User.where.not(id: user_ids_of_course_members) @users = User.where(status: User::STATUS_ACTIVE) - @users = @users.where("concat(users.firstname, users.lastname) like '%#{name}%'") if name.present? + @users = @users.where("concat(users.lastname, users.firstname) like '%#{name}%'") if name.present? # REDO:Extension @users = @users.joins(user_extension: :school).where("schools.name like '%#{school_name}%'") if school_name.present?