From 674b6652130d29eea9d78106fdbb7b5d545b040d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 14 Aug 2019 11:42:50 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E5=A4=AA=E9=95=BF=E6=97=A0=E6=B3=95=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/course.rb b/app/models/course.rb index bab02be01..16cb7a8c6 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -91,7 +91,7 @@ class Course < ApplicationRecord NORMAL = 6 # 普通用户 Anonymous = 7 # 普未登录 - validates :name, presence: true, length: { maximum: 30 } + validates :name, presence: true, length: { maximum: 60 } after_create :create_board_sync, :act_as_course_activity, :send_tiding From 9d0b61d459ba377cfddbce73c2ab314e5a6dacfb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 14 Aug 2019 13:50:30 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=BA=AF=E9=80=89=E6=8B=A9=E9=A2=98?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=87=8D=E7=BD=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index c36ad09b6..1af7e482d 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -37,7 +37,7 @@ class MyshixunsController < ApplicationController end end # 删除版本库 - GitService.delete_repository(repo_path: @repo_path) + GitService.delete_repository(repo_path: @repo_path) unless @shixun.is_choice_type? rescue Exception => e if e.message != "ActiveRecord::RecordInvalid" logger.error("######delete_repository_error:#{e.message}") From dc2a00a6a9e2ce82bb87ddd51b6f58c48dc323a5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 14 Aug 2019 14:06:33 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E9=87=8D=E7=BD=AE=E5=AE=9E=E8=AE=AD?= =?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/myshixuns_controller.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 1af7e482d..69bd01dde 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -23,14 +23,9 @@ class MyshixunsController < ApplicationController begin ActiveRecord::Base.transaction do begin - @shixun = Shixun.select(:id, :identifier).find(@myshixun.shixun_id) + @shixun = Shixun.select(:id, :identifier, :challenges_count).find(@myshixun.shixun_id) @myshixun.destroy! - StudentWork.where(:myshixun_id => @myshixun.id).update_all(:myshixun_id => 0, :work_status => 0) - - # 实训在申请发布前,是否玩过实训,如果玩过需要更改记录,防止二次重置 - shixun_mod = ShixunModify.where(:shixun_id => @shixun.id, :myshixun_id => @myshixun.id, :status => 1).take - shixun_mod.update_column(:status, 0) if shixun_mod rescue Exception => e logger.error("######reset_my_game_failed:#{e.message}") raise("ActiveRecord::RecordInvalid") @@ -40,7 +35,7 @@ class MyshixunsController < ApplicationController GitService.delete_repository(repo_path: @repo_path) unless @shixun.is_choice_type? rescue Exception => e if e.message != "ActiveRecord::RecordInvalid" - logger.error("######delete_repository_error:#{e.message}") + logger.error("######delete_repository_error-:#{e.message}") end raise "delete_repository_error:#{e.message}" end From 157cfdd59061db70c8bfcf8cd3e75de1bc1ee69f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 14 Aug 2019 15:56:31 +0800 Subject: [PATCH 4/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/courses_controller.rb | 4 ++-- app/models/course.rb | 2 +- dump.rdb | Bin 1888 -> 1992 bytes 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index ce9c9af6c..106ba3dd4 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1129,12 +1129,12 @@ class CoursesController < ApplicationController def validate_course_name tip_exception("课堂名称不能为空!") if params[:course][:name].blank? - if params[:subject_id].blank? || @course.subject.blank? + if params[:subject_id].blank? || (@course && @course.subject.blank?) tip_exception("课程名称不能为空!") if params[:course_list_name].blank? tip_exception("课堂名称应以课程名称开头命名") unless params[:course][:name].index(params[:course_list_name]) && params[:course][:name].index(params[:course_list_name]) == 0 else - @subject = @course ? @course.subject : Subject.find_by!(id: params[:subject_id]) + @subject = @course.present? ? @course.subject : Subject.find_by!(id: params[:subject_id]) tip_exception("开始时间不能为空") if params[:start_date].blank? tip_exception("结束时间不能为空") if params[:end_date].blank? tip_exception("结束时间必须晚于开始时间") if params[:end_date] <= params[:start_date] diff --git a/app/models/course.rb b/app/models/course.rb index 16cb7a8c6..b7bea6ec0 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -5,7 +5,7 @@ class Course < ApplicationRecord belongs_to :teacher, class_name: 'User', foreign_key: :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, class_name: 'School', foreign_key: :school_id #定义一个方法school,该方法通过school_id来调用School表 - belongs_to :course_list + belongs_to :course_list, optional: true # 所属实践课程 belongs_to :subject, optional: true diff --git a/dump.rdb b/dump.rdb index c4edd44ed9369cb224d86d4db8d9b1e4349f94f5..d3784bb931ede1f45cc279e5c502909dc4ba43f4 100644 GIT binary patch delta 436 zcmWN}J8Kj{902g$*?Z+YF9elf6mLBr2s-P`{O2j8P|j!}X;Nq-GOsIy1k?+p30PT} zLS;XI_9q6hv9hqT^dlUDh#tw0$;X=? z^8V=b>e67TpJj`^ENj>M`O8bp5zx*94xT#9jj>oWZZL7ys-SdXB&hm5T5d2Py8eS6 z+&c-(djmE&2NWVB9)PGaFL%!Rr_oMgcw{HT8&pW4qyZ%=0KteUH?j@8H9IzF8N#;@ z4)e5&>KEwpo%4gViV6zEq<|K+;@(6`J#fjm48#ZJ8S`aIZPb&7QYI_OsOBPd(JVje zwAelm+~jnYBRf^_!A+)-M#8NF$4(1Q;P# TBJdccA~myoKg?I&e_#Ir0 Date: Wed, 14 Aug 2019 16:00:46 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E9=87=91=E8=AF=BE=E8=AF=BE=E5=A0=82?= =?UTF-8?q?=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/views/courses/settings.json.jbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/courses/settings.json.jbuilder b/app/views/courses/settings.json.jbuilder index 1a67fbe27..be4470a66 100644 --- a/app/views/courses/settings.json.jbuilder +++ b/app/views/courses/settings.json.jbuilder @@ -1,5 +1,5 @@ -json.course_list_id @course.course_list.id -json.course_list_name @course.course_list.name +json.course_list_id @course.course_list&.id +json.course_list_name @course.course_list&.name json.name @course.name json.course_id @course.id json.school @course.school&.name