diff --git a/app/controllers/admins/laboratory_subjects_controller.rb b/app/controllers/admins/laboratory_subjects_controller.rb index 866a20a76..c09697c7e 100644 --- a/app/controllers/admins/laboratory_subjects_controller.rb +++ b/app/controllers/admins/laboratory_subjects_controller.rb @@ -17,9 +17,15 @@ class Admins::LaboratorySubjectsController < Admins::BaseController def destroy return render_js_error('不能删除自建课程', type: :notify) if current_laboratory_subject.ownership? - current_laboratory_subject.destroy! - - render_delete_success + ActiveRecord::Base.transaction do + current_subject = current_laboratory_subject.subject + current_subject.shixuns.each do |shixun| + shixun.destroy! + end + current_subject.destroy! + + render_delete_success + end end diff --git a/app/controllers/admins/schools_controller.rb b/app/controllers/admins/schools_controller.rb index 8c4f1d59e..7e1626d98 100644 --- a/app/controllers/admins/schools_controller.rb +++ b/app/controllers/admins/schools_controller.rb @@ -5,7 +5,7 @@ class Admins::SchoolsController < Admins::BaseController schools = Admins::SchoolQuery.call(params) - @schools = paginate schools + @schools = paginate schools.includes(:user_extensions) school_ids = @schools.map(&:id) @department_count = Department.where(school_id: school_ids).group(:school_id).count diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index c21a493e0..0b5140743 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -308,6 +308,7 @@ class ChallengesController < ApplicationController end def challenge_params + tip_exception("评测时间不能超过300秒") if params[:challenge][:exec_time].to_i > 300 params.require(:challenge).permit(:subject, :task_pass, :difficulty, :score, :st, :modify_time, :test_set_average, :path, :exec_path, :show_type, :original_picture_path, :test_set_score, :expect_picture_path, :picture_path, :web_route, :answer, :exec_time) diff --git a/app/controllers/hack_user_lastest_codes_controller.rb b/app/controllers/hack_user_lastest_codes_controller.rb index d03b9bd7d..37102a166 100644 --- a/app/controllers/hack_user_lastest_codes_controller.rb +++ b/app/controllers/hack_user_lastest_codes_controller.rb @@ -12,11 +12,13 @@ class HackUserLastestCodesController < ApplicationController def update_code @my_hack.update_attribute(:code, params[:code]) + render_ok end # 回复初始代码 def restore_initial_code @my_hack.update_attribute(:code, @hack.code) + render_ok end # 调试代码 @@ -126,6 +128,7 @@ class HackUserLastestCodesController < ApplicationController # 正则错误行数 def regular_match_error_line content, language + content = Base64.decode64(content).force_encoding("utf-8") case language when 'Java' content.scan(/.java.\d+/).map{|s| s.match(/\d+/)[0].to_i}.min diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index 67f2af3d4..993cba4e6 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -47,6 +47,8 @@ class HacksController < ApplicationController hack.identifier = generate_identifier Hack, 8 hack.save! # 创建测试集与代码 + logger.info("hack_sets_params:#{hack_sets_params}") + logger.info("hack_code_params:#{hack_code_params}") hack.hack_sets.create!(hack_sets_params) hack.hack_codes.create!(hack_code_params) end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 65a1d345a..e31c77499 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -30,10 +30,10 @@ class HomeController < ApplicationController @main_shixuns = Shixun.where(homepage_show: true).includes(:tag_repertoires, :challenges).limit(8) @main_subjects = Subject.where(homepage_show: true).includes(:shixuns, :repertoire).limit(8) - if current_laboratory.main_site? - @tea_users = User.where(homepage_teacher: 1).includes(:user_extension).limit(10).order("experience desc") - @stu_users = User.where(is_test: 0).includes(:user_extension).where(user_extensions: {identity: 1}).limit(10).order("experience desc") - end + # if current_laboratory.main_site? + # @tea_users = User.where(homepage_teacher: 1).includes(:user_extension).limit(10).order("experience desc") + # @stu_users = User.where(is_test: 0).includes(:user_extension).where(user_extensions: {identity: 1}).limit(10).order("experience desc") + # end end def search diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 28940db10..a321beb25 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -14,7 +14,7 @@ class ShixunsController < ApplicationController before_action :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns, :propaedeutics, :departments, :apply_shixun_mirror, - :get_mirror_script, :download_file, :shixun_list, :review_shixuns] + :get_mirror_script, :download_file, :shixun_list, :batch_send_to_course] before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy, :add_file] before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, @@ -515,7 +515,7 @@ class ShixunsController < ApplicationController end # 添加第二仓库 if params[:is_secret_repository] - add_secret_repository + add_secret_repository if @shixun.shixun_secret_repository.blank? else # 如果有仓库,就要删 if @shixun.shixun_secret_repository&.repo_name diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index a846e6a45..096a0fe52 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -227,7 +227,7 @@ class SubjectsController < ApplicationController GitService.add_repository(repo_path: repo_path) # todo: 为什么保存的时候要去除后面的.git呢?? @shixun.update_column(:repo_name, repo_path.split(".")[0]) - mirror_id = MirrorRepository.find_by(type_name: 'Python').id + mirror_id = MirrorRepository.find_by(type_name: 'Python3.6')&.id if mirror_id ShixunMirrorRepository.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror_id) @shixun.shixun_service_configs.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror_id) diff --git a/app/models/hack_set.rb b/app/models/hack_set.rb index 669fa10b1..5dab862b5 100644 --- a/app/models/hack_set.rb +++ b/app/models/hack_set.rb @@ -1,6 +1,6 @@ class HackSet < ApplicationRecord validates :input, presence: { message: "测试集输入不能为空" } - validates :output, uniqueness: { message: "测试集输出不能为空" } + validates :output, presence: { message: "测试集输出不能为空" } # 编程题测试集 belongs_to :hack end diff --git a/app/models/shixun_tag_repertoire.rb b/app/models/shixun_tag_repertoire.rb index 6cb311f7a..afd956350 100644 --- a/app/models/shixun_tag_repertoire.rb +++ b/app/models/shixun_tag_repertoire.rb @@ -3,5 +3,5 @@ class ShixunTagRepertoire < ApplicationRecord belongs_to :tag_repertoire has_many :memos, :through => :memo_tag_repertoires - has_many :memo_tag_repertoires, :dependent => :destroy + # has_many :memo_tag_repertoires, :dependent => :destroy end diff --git a/app/queries/admins/school_query.rb b/app/queries/admins/school_query.rb index 7361588c4..888cded97 100644 --- a/app/queries/admins/school_query.rb +++ b/app/queries/admins/school_query.rb @@ -13,11 +13,10 @@ class Admins::SchoolQuery < ApplicationQuery schools = School.all keyword = strip_param(:keyword) - schools = schools.where('schools.name LIKE ?', "%#{keyword}%") if keyword - - schools = schools.joins(:user_extensions).group(:id) - schools = schools.select('schools.*, COUNT(*) AS users_count') - + Rails.logger.info("###########{keyword}") + if keyword + schools = schools.where('schools.name LIKE ?', "%#{keyword}%") + end custom_sort schools, params[:sort_by], params[:sort_direction] end end \ No newline at end of file diff --git a/app/views/admins/schools/shared/_list.html.erb b/app/views/admins/schools/shared/_list.html.erb index b1453f1a1..ec7475028 100644 --- a/app/views/admins/schools/shared/_list.html.erb +++ b/app/views/admins/schools/shared/_list.html.erb @@ -31,7 +31,7 @@
实训项目
DEVELOPMENT COMMUNITY
@@ -411,160 +411,160 @@ class ShixunsHome extends Component { {/*导师排行榜*/} - { homedatalist !== undefined && homedatalist.teachers !== undefined && ( - this.props.user&&this.props.user.main_site===true?导师排行榜
-MENTOR RANKING
-{item.username}
- -{item.username}
- -{item.username}
- -{item.username}
- -导师排行榜
*/} + {/*MENTOR RANKING
*/} + {/*{item.username}
*/} + {/* */} + {/*{item.username}
*/} + {/* */} + {/*{item.username}
*/} + {/* */} + {/*{item.username}
*/} + {/* */} + {/*程序员排行榜
-PROGRAMMER RANKING
-{item.username}
- -{item.username}
- -{item.username}
- -{item.username}
- -程序员排行榜
*/} + {/*PROGRAMMER RANKING
*/} + {/*{item.username}
*/} + {/* */} + {/*{item.username}
*/} + {/* */} + {/*{item.username}
*/} + {/* */} + {/*{item.username}
*/} + {/* */} + {/*