diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d07e00090..cb31067cb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,6 +23,8 @@ class ApplicationController < ActionController::Base # 所有请求必须合法签名 def check_sign + uid_logger("educoder_session is #{cookies[:_educoder_session]}") + uid_logger("autologin trustie is #{cookies[:autologin_trustie]}") uid_logger("check sign start: session[:user_id] is #{session[:user_id]}") uid_logger("check sign start: default_yun_session is #{default_yun_session}, session[:current_user_id] is #{session[:"#{default_yun_session}"]}") if !Rails.env.development? @@ -222,7 +224,7 @@ class ApplicationController < ActionController::Base # 未授权的捕捉407,弹试用申请弹框 def require_login #6.13 -hs - tip_exception(401, "..") unless User.current.logged? + tip_exception(401, "请登录后再操作") unless User.current.logged? end # 异常提醒 diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 354d63f6d..088c6ff6f 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -181,7 +181,7 @@ class ChallengesController < ApplicationController begin ActiveRecord::Base.transaction do tab = params[:tab].to_i - @challenge.update_attributes(challenge_params) + @challenge.update_attributes!(challenge_params) if tab == 0 && @challenge.st == 0 @challenge.challenge_tags.delete_all if params[:challenge_tag].present? @@ -211,7 +211,7 @@ class ChallengesController < ApplicationController # last: 末尾匹配, full: 全完匹配 logger.info("set: #{set}; match_rule : #{set[:match_rule]}") match_rule = set[:match_rule] == 'last' ? 'last' : 'full' - TestSet.create(:challenge_id => @challenge.id, + TestSet.create!(:challenge_id => @challenge.id, :input => "#{set[:input]}", :output => "#{set[:output]}", :is_public => params_hidden[index], @@ -237,9 +237,9 @@ class ChallengesController < ApplicationController end end - rescue => e - logger_error("##update_challenges: ##{e.message}") - tip_exception("更新失败!") + rescue Exception => e + logger.error("##update_challenges: ##{e.message}") + tip_exception("#{e.message}") end end @@ -262,7 +262,7 @@ class ChallengesController < ApplicationController params[:challenge_answer].each_with_index do |answer, index| # 内容为空不保存 next if answer[:contents].blank? - ChallengeAnswer.create(name: answer[:name], contents: answer[:contents], + ChallengeAnswer.create!(name: answer[:name], contents: answer[:contents], level: index+1, score: answer[:score], challenge_id: @challenge.id) end end diff --git a/app/models/challenge_answer.rb b/app/models/challenge_answer.rb index 514f3471a..8196a7b7e 100644 --- a/app/models/challenge_answer.rb +++ b/app/models/challenge_answer.rb @@ -3,7 +3,7 @@ class ChallengeAnswer < ApplicationRecord belongs_to :challenge has_many :game_answers, :dependent => :destroy - validates :contents, length: { maximum: 5000 , too_long: "不能超过5000个字符"} + validates :contents, length: { maximum: 25000 , too_long: "不能超过25000个字符"} def view_answer_time(user_id) game_answers.where(user_id: user_id).last&.view_time diff --git a/app/models/test_set.rb b/app/models/test_set.rb index 01bc2b767..861f5b3ed 100644 --- a/app/models/test_set.rb +++ b/app/models/test_set.rb @@ -1,7 +1,7 @@ class TestSet < ApplicationRecord # match_rule: 匹配规则: full: 完全匹配, last: 末尾匹配 # - validates :input, length: { maximum: 5000, too_long: "不能超过5000个字符" } - validates :output, length: { maximum: 5000, too_long: "不能超过5000个字符" } + validates :input, length: { maximum: 65000, too_long: "不能超过65000个字符" } + validates :output, length: { maximum: 65000, too_long: "不能超过65000个字符" } end diff --git a/app/views/admins/repertoires/edit.js.erb b/app/views/admins/repertoires/edit.js.erb index 0aafcb632..d66078123 100644 --- a/app/views/admins/repertoires/edit.js.erb +++ b/app/views/admins/repertoires/edit.js.erb @@ -1,2 +1,2 @@ $('.admin-modal-container').html("<%= j( render partial: 'admins/repertoires/shared/edit_repertoire_modal', locals: { repertoire: @repertoire } ) %>"); -$('.modal.admin-edit-repertoires-modal').modal('show'); \ No newline at end of file +$('.modal.admin-edit-repertoire-modal').modal('show'); \ No newline at end of file