diff --git a/app/assets/javascripts/common.js b/app/assets/javascripts/common.js index fa7bef244..dc0818b64 100644 --- a/app/assets/javascripts/common.js +++ b/app/assets/javascripts/common.js @@ -1,5 +1,6 @@ function createMDEditor(element, opts){ var defaults = { + height: 600, path: '/editormd/lib/', syncScrolling: "single", tex: true, diff --git a/app/controllers/admins/base_controller.rb b/app/controllers/admins/base_controller.rb index 6f89e7afa..345df3e31 100644 --- a/app/controllers/admins/base_controller.rb +++ b/app/controllers/admins/base_controller.rb @@ -5,6 +5,8 @@ class Admins::BaseController < ApplicationController layout 'admin' + skip_before_action :verify_authenticity_token + before_action :require_login, :require_admin! after_action :rebind_event_if_ajax_render_partial diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 8cb68b1d4..c21a493e0 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -191,21 +191,28 @@ class ChallengesController < ApplicationController sets_input = test_set.map(&:input) sets_open = test_set.map(&:is_public) set_score = test_set.map(&:score) + set_match_rule = test_set.map(&:match_rule) params_hidden = params[:test_set].map{|set| set[:hidden].to_i == 0} params_output = params[:test_set].map{|set| set[:output] } params_input = params[:test_set].map{|set| set[:input] } params_score = params[:test_set].map{|set| set[:score]} + params_test_set = params[:test_set].map{|set| set[:match_rule]} # 测试集变化则需要更新(输入、 输出、 是否隐藏) - if sets_output != params_output || sets_open != params_hidden || sets_input != params_input || set_score != params_score + if sets_output != params_output || sets_open != params_hidden || sets_input != params_input || + set_score != params_score || params_test_set != set_match_rule test_set.delete_all unless test_set.blank? - params[:test_set].each_with_index do |set, index| - TestSet.create(:challenge_id => @challenge.id, - :input => "#{set[:input]}", - :output => "#{set[:output]}", - :is_public => params_hidden[index], - :score => set[:score], - :position => (index + 1)) - end + params[:test_set].each_with_index do |set, index| + # 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, + :input => "#{set[:input]}", + :output => "#{set[:output]}", + :is_public => params_hidden[index], + :score => set[:score], + :match_rule => "#{match_rule}", + :position => (index + 1)) + end @challenge.update_column(:modify_time, Time.now) # 测试集的 @shixun.myshixuns.update_all(:system_tip => 0) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 2039dbc6f..f6fae91db 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -33,10 +33,11 @@ class CoursesController < ApplicationController before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate, :transfer_to_course_group, :delete_from_course, :export_member_scores_excel, :search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, - :add_teacher, :export_couser_info, :export_member_act_score] + :add_teacher, :export_couser_info, :export_member_act_score, + :update_informs, :new_informs, :delete_informs] before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :change_course_admin, - :set_course_group, :create_group_by_importing_file, :update_informs, :new_informs, - :update_task_position, :tasks_list, :delete_informs] + :set_course_group, :create_group_by_importing_file, + :update_task_position, :tasks_list] before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group, :change_course_teacher, :course_group_list, :teacher_application_review, :apply_teachers, :delete_course_teacher] diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index ac72577e0..b35f2996f 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -67,13 +67,19 @@ class GamesController < ApplicationController uri = "#{shixun_tomcat}/bridge/vnc/getvnc" params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}"} res = uri_post uri, params + logger.info("###############---- ") if res && res['code'].to_i != 0 raise("实训云平台繁忙(繁忙等级:99)") end - # 无域名版本 - #@vnc_url = "http://#{service_host}:#{res['port']}/vnc_lite.html?password=headless" - # 有域名版本 - @vnc_url = "https://#{res['port']}.#{service_host}/vnc_lite.html?password=headless" + + if request.subdomain == "pre-newweb" + # 无域名版本 + @vnc_url = "http://#{service_host}:#{res['port']}/vnc_lite.html?password=headless" + else + # 有域名版本 + @vnc_url = "https://#{res['port']}.#{service_host}/vnc_lite.html?password=headless" + end + @vnc_evaluate = @shixun.vnc_evaluate rescue Exception => e Rails.logger.error(e.message) @@ -531,10 +537,12 @@ class GamesController < ApplicationController game_challenge.test_sets.each do |test_set| input = test_set.input.nil? ? "" : test_set.input.gsub("\r\n", "\n") output = test_set.output.nil? ? "" : test_set.output.gsub("\r\n", "\n") - test_cases = {:input => input, :output => output} + test_cases = {:input => input, :output => output, :matchRule => test_set.match_rule} testSet << test_cases end + logger.info("##############testSet: #{testSet}") + testCases = Base64.urlsafe_encode64(testSet.to_json) unless testSet.blank? # 评测类型: 0,1,2 用于webssh的评测, 3用于vnc podType = @shixun.vnc_evaluate ? 3 : @shixun.webssh @@ -554,6 +562,15 @@ class GamesController < ApplicationController # needPortMapping: web类型需要pod端口映射 br_params[:needPortMapping] = 8080 if @myshixun.mirror_name.include?("Web") + # 私密仓库的设置 + secret_rep = @shixun.shixun_secret_repository + logger.info("############secret_rep: #{secret_rep}") + if secret_rep&.repo_name + secretGitUrl = repo_url secret_rep.repo_path + br_params.merge!({secretGitUrl: Base64.urlsafe_encode64(secretGitUrl), secretDir: secret_rep.secret_dir_path}) + logger.info("#######br_params:#{br_params}") + end + # 中间层交互 uri = "#{shixun_tomcat}/bridge/game/gameEvaluate" res = interface_post uri, br_params, 502, "gameEvaluate failed" diff --git a/app/controllers/graduation_topics_controller.rb b/app/controllers/graduation_topics_controller.rb index 0242bff21..0e6135e8c 100644 --- a/app/controllers/graduation_topics_controller.rb +++ b/app/controllers/graduation_topics_controller.rb @@ -109,8 +109,8 @@ class GraduationTopicsController < ApplicationController @attachments = @graduation_topic.attachments left_banner_content = @course.course_modules.search_by_module_type("graduation") if left_banner_content.present? - @left_banner_id = left_banner_content.first.course_second_categories.first.id - @left_banner_name = left_banner_content.first.course_second_categories.first.name + @left_banner_id = left_banner_content.first.id + @left_banner_name = "毕设选题" end end diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index e7be8b395..b4e98e05f 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -265,6 +265,7 @@ class QuestionBanksController < ApplicationController # exercise.update_column(:quotes, exercise.quotes+1) # end new_exercise if new_exercise.save! + exercise.update_column(:quotes, exercise.quotes+1) end end @@ -292,6 +293,7 @@ class QuestionBanksController < ApplicationController # poll.update_column(:quotes, poll.quotes+1) # end new_poll if new_poll.save! + poll.update_column(:quotes, poll.quotes+1) end end diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 180c269b5..5f69f1b91 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -220,6 +220,16 @@ class ShixunsController < ApplicationController evaluate_script: @shixun.evaluate_script) end + # 同步私密版本库 + if @shixun.shixun_secret_repository + repo_name = "#{current_user.login}/secret_#{@shixun.identifier}" + fork_repository_name = "#{current_user.login}/secret_#{@new_shixun.identifier}" + ShixunSecretRepository.create!(shixun_id: @new_shixun.id, + repo_name: "#{repo_name}", + secret_dir_path: @shixun.shixun_secret_repository.secret_dir_path) + GitService.fork_repository(repo_path: "#{repo_name}.git", fork_repository_path: (fork_repository_name + ".git")) + end + # 同步镜像 if @shixun.mirror_repositories.present? @shixun.mirror_repositories.each do |mirror| @@ -448,6 +458,7 @@ class ShixunsController < ApplicationController ShixunMirrorRepository.create(:shixun_id => @shixun.id, :mirror_repository_id => mirror) end end + logger.info("#########shixun_params#{shixun_params}") @shixun.update_attributes(shixun_params) logger.info("##########shixun_info_params: #{shixun_info_params}") logger.info("##########params[:shixun_info][:evaluate_script]: #{params[:shixun_info][:evaluate_script]}") @@ -472,8 +483,20 @@ class ShixunsController < ApplicationController @shixun.shixun_service_configs.create!(config) if name.present? end end + # 添加第二仓库 + if params[:is_secret_repository] + add_secret_repository + else + # 如果有仓库,就要删 + if @shixun.shixun_secret_repository&.repo_name + @shixun.shixun_secret_repository.lock! + GitService.delete_repository(repo_path: @shixun.shixun_secret_repository.repo_path) + @shixun.shixun_secret_repository.destroy + end + end + rescue Exception => e - uid_logger_error(e.message) + uid_logger_error("实训保存失败--------#{e.message}") tip_exception("实训保存失败") raise ActiveRecord::Rollback end @@ -818,6 +841,30 @@ class ShixunsController < ApplicationController end end + # 设置私密版本库的在tpm中的目录 + def set_secret_dir + raise("设置路径不能为空") if params[:secret_dir_path].blank? + raise("请先配置私密版本库") if @shixun.shixun_secret_repository.blank? + @shixun.shixun_secret_repository.update_attributes(:secret_dir_path => params[:secret_dir_path]) + normal_status("设置成功") + end + + def secret_repository + begin + @repo_path = @shixun.shixun_secret_repository&.repo_path + @repo_url = repo_url @repo_path + @trees = GitService.file_tree(repo_path: @repo_path, path: params[:path]) + logger.info("#11@@#@#@#@111#@@@@###{@trees}") + if @trees + logger.info("#@@#@#@#@#@@@@###{@trees.try(:count)}") + @latest_commit = [GitService.commits(repo_path: @repo_path).first] + Rails.logger.info("########## #{@latest_commit}") + end + rescue Exception => e + logger.error(e.message) + end + end + include GitCommon def update_file @@ -954,7 +1001,13 @@ private end def find_repo_name - @repo_path = @shixun.try(:repo_path) + # 有私密版本库的参数时,需要拿私密仓库 + @repo_path = if params[:secret_repository] + @shixun.shixun_secret_repository&.repo_path + else + @shixun.try(:repo_path) + end + logger.info("######{@repo_path}") @path = params[:path] end @@ -989,4 +1042,13 @@ private modify_shixun = ShixunModify.exists?(:myshixun_id => current_myshixun.id, :shixun_id => @shixun.id, :status => 1) games.size != min_challenges.size || modify_shixun end + + # 添加私密仓库 + def add_secret_repository + # 防止跟tpm版本库重名,加了前缀secret + repo_path = repo_namespace(current_user.login, "secret_#{@shixun.identifier}") + GitService.add_repository(repo_path: repo_path) + ShixunSecretRepository.create!(repo_name: repo_path.split(".")[0], shixun_id: @shixun.id) + end + end diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 526535157..ab62cbd45 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -458,7 +458,7 @@ class StudentWorksController < ApplicationController @shixun = @homework.shixuns.take # 提示: 这里如果includes outputs表的话: sum(:evaluate_count)会出现错误 @games = @work.myshixun.games.joins(:challenge).reorder("challenges.position asc") if @work.myshixun - @comment = @work.student_works_scores.shixun_comment.first + @comment = @work.shixun_work_comments.find_by(challenge_id: 0) # 用户最大评测次数 if @games @@ -474,19 +474,37 @@ class StudentWorksController < ApplicationController # 实训作品的评阅 def shixun_work_comment - tip_exception("评阅不能为空") if params[:comment].blank? - tip_exception("缺少is_hidden参数") if params[:is_hidden].blank? || ![1, 0].include?(params[:is_hidden]) - comment = @work.student_works_scores.shixun_comment.first || StudentWorksScore.new(student_work_id: @work.id, user_id: current_user.id) - comment.comment = params[:comment] - comment.is_hidden = params[:is_hidden] - comment.save! - normal_status("评阅成功") + tip_exception("请至少输入一个评阅") if params[:comment].blank? && params[:hidden_comment].blank? + ActiveRecord::Base.transaction do + challenge = @homework.shixuns.first&.challenges.find_by(id: params[:challenge_id]) unless params[:challenge_id].blank? + if challenge.present? + @comment = @work.shixun_work_comments.find_by(challenge_id: challenge.id) || + ShixunWorkComment.new(student_work_id: @work.id, user_id: current_user.id, challenge_id: challenge.id) + else + @comment = @work.shixun_work_comments.find_by(challenge_id: 0) || + ShixunWorkComment.new(student_work_id: @work.id, user_id: current_user.id, challenge_id: 0) + end + @comment.comment = params[:comment] + @comment.hidden_comment = params[:hidden_comment] + @comment.save! + end end # 删除实训作品评阅 def destroy_work_comment - @work.student_works_scores.shixun_comment.first.destroy! if @work.student_works_scores.shixun_comment.first.present? - normal_status("删除成功") + ActiveRecord::Base.transaction do + # tip_exception("visible_comment参数有误") if params[:visible_comment].nil? + + comment = @work.shixun_work_comments.find_by!(id: params[:comment_id]) + comment.destroy! + # params[:visible_comment] ? comment.comment = nil : comment.hidden_comment = nil + # if comment.comment.nil? && comment.hidden_comment.nil? + # comment.destroy! + # else + # comment.save! + # end + normal_status("删除成功") + end end def export_shixun_work_report diff --git a/app/controllers/task_banks_controller.rb b/app/controllers/task_banks_controller.rb index 82ce14b0c..2b1a400ef 100644 --- a/app/controllers/task_banks_controller.rb +++ b/app/controllers/task_banks_controller.rb @@ -12,7 +12,7 @@ class TaskBanksController < ApplicationController ActiveRecord::Base.transaction do begin @bank.update_attributes(gtask_bank_params) - Attachment.associate_container(params[:attachment_ids], @bank.id, @bank.class) if params[:attachment_ids].blank? + Attachment.associate_container(params[:attachment_ids], @bank.id, @bank.class) if params[:attachment_ids] normal_status(0, "更新成功") rescue Exception => e uid_logger(e.message) diff --git a/app/controllers/users/question_banks_controller.rb b/app/controllers/users/question_banks_controller.rb index 76523eca4..c5b837d0b 100644 --- a/app/controllers/users/question_banks_controller.rb +++ b/app/controllers/users/question_banks_controller.rb @@ -1,11 +1,12 @@ class Users::QuestionBanksController < Users::BaseController before_action :require_login - before_action :private_user_resources! + skip_before_action :check_observed_user_exists! + # before_action :private_user_resources! before_action :check_query_params! before_action :check_user_permission! def index - service = Users::QuestionBankService.new(observed_user, query_params) + service = Users::QuestionBankService.new(User.current, query_params) question_banks = service.call @count = question_banks.count @@ -30,7 +31,7 @@ class Users::QuestionBanksController < Users::BaseController .where(commit_status: 1, exercises: { exercise_bank_id: question_bank_ids }) .group('exercises.exercise_bank_id').count when 'poll' then - PollUser.joins(:poll).where(polls: { exercise_bank_id: question_bank_ids }) + PollUser.joins(:poll).where(commit_status: 1, polls: { exercise_bank_id: question_bank_ids }) .group('polls.exercise_bank_id').count when 'gtask' then GraduationWork.has_committed.joins(:graduation_task) diff --git a/app/models/gtopic_bank.rb b/app/models/gtopic_bank.rb index af5b267a6..609219711 100644 --- a/app/models/gtopic_bank.rb +++ b/app/models/gtopic_bank.rb @@ -1,7 +1,7 @@ class GtopicBank < ApplicationRecord belongs_to :user - belongs_to :graduation_topic - belongs_to :course_list + belongs_to :graduation_topic, optional: true + belongs_to :course_list, optional: true has_many :attachments, as: :container, dependent: :destroy has_many :graduation_topics, dependent: :nullify diff --git a/app/models/searchable/course.rb b/app/models/searchable/course.rb index 5060d9ddd..794dec0e2 100644 --- a/app/models/searchable/course.rb +++ b/app/models/searchable/course.rb @@ -24,7 +24,7 @@ module Searchable::Course author_name: teacher&.real_name, author_school_name: teacher&.school_name, visits_count: visits, - members_count: members_count, + members_count: course_members_count, is_public: is_public == 1, first_category_url: ApplicationController.helpers.module_url(none_hidden_course_modules.first, self) } diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 9ad3cbcdf..83d97f822 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -38,6 +38,9 @@ class Shixun < ApplicationRecord has_one :shixun_info, dependent: :destroy + # 第二版本库 + has_one :shixun_secret_repository, dependent: :destroy + belongs_to :user # 实训服务配置 has_many :shixun_service_configs, :dependent => :destroy diff --git a/app/models/shixun_secret_repository.rb b/app/models/shixun_secret_repository.rb new file mode 100644 index 000000000..699c6dd30 --- /dev/null +++ b/app/models/shixun_secret_repository.rb @@ -0,0 +1,11 @@ +class ShixunSecretRepository < ApplicationRecord + # repo_name: 仓库名 + # secret_dir_name: 在tpm仓库的那个目录下 + + belongs_to :shixun + + def repo_path + "#{repo_name}.git" + end + +end diff --git a/app/models/shixun_work_comment.rb b/app/models/shixun_work_comment.rb new file mode 100644 index 000000000..7a67238ab --- /dev/null +++ b/app/models/shixun_work_comment.rb @@ -0,0 +1,5 @@ +class ShixunWorkComment < ApplicationRecord + belongs_to :student_work + belongs_to :user + belongs_to :challenge, optional: true +end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 168cfeb68..9c9efa17c 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -7,6 +7,7 @@ class StudentWork < ApplicationRecord belongs_to :myshixun, optional: true has_many :student_works_evaluation_distributions, dependent: :destroy has_many :student_works_scores, dependent: :destroy + has_many :shixun_work_comments, dependent: :destroy belongs_to :project, optional: true # attachtype: 1(正常提交的附件), 7(补交的附件) diff --git a/app/models/test_set.rb b/app/models/test_set.rb index 148cb8720..7772a3a00 100644 --- a/app/models/test_set.rb +++ b/app/models/test_set.rb @@ -1,2 +1,3 @@ class TestSet < ApplicationRecord + # match_rule: 匹配规则: full: 完全匹配, last: 末尾匹配 end diff --git a/app/views/challenges/edit.json.jbuilder b/app/views/challenges/edit.json.jbuilder index 5ae15cf67..3e7f5b425 100644 --- a/app/views/challenges/edit.json.jbuilder +++ b/app/views/challenges/edit.json.jbuilder @@ -16,7 +16,7 @@ elsif @tab == 1 json.has_web_route @shixun.has_web_route? json.test_sets @challenge.test_sets do |set| json.hidden (set.is_public ? 0 : 1) - json.(set, :input, :output, :score) + json.(set, :input, :output, :score, :match_rule) end elsif @tab == 2 # 参考答案 diff --git a/app/views/searchs/index.json.jbuilder b/app/views/searchs/index.json.jbuilder index 5fa0c2744..e12ebbca8 100644 --- a/app/views/searchs/index.json.jbuilder +++ b/app/views/searchs/index.json.jbuilder @@ -6,6 +6,12 @@ json.results do json.title highlights.delete(:name)&.join('...') || obj.searchable_title # json.description highlights.values[0,5].each { |arr| arr.is_a?(Array) ? arr.join('...') : arr }.join('
') + + # 去除开头标点符号 + reg = /^[,。?:;‘’!“”—……、]/ + highlights[:description]&.first&.sub!(reg, '') + highlights[:content]&.first&.sub!(reg, '') + json.content highlights end end \ No newline at end of file diff --git a/app/views/shixuns/secret_repository.json.jbuilder b/app/views/shixuns/secret_repository.json.jbuilder new file mode 100644 index 000000000..482a683a8 --- /dev/null +++ b/app/views/shixuns/secret_repository.json.jbuilder @@ -0,0 +1,8 @@ +json.trees @trees + +if @trees.present? + json.partial! 'shixuns/commit', locals: { commits: @latest_commit } +end + +json.git_url @repo_url +json.secret_dir_path @shixun.shixun_secret_repository&.secret_dir_path \ No newline at end of file diff --git a/app/views/shixuns/settings.json.jbuilder b/app/views/shixuns/settings.json.jbuilder index ad29f4176..c9142dab0 100644 --- a/app/views/shixuns/settings.json.jbuilder +++ b/app/views/shixuns/settings.json.jbuilder @@ -30,6 +30,8 @@ json.shixun do json.scope_partment @shixun.schools.map(&:name) # 公开范围 json.opening_time @shixun.opening_time json.forbid_copy @shixun.forbid_copy + # 私密仓库 + json.is_secret_repository @shixun.shixun_secret_repository.present? # 实训服务配置 json.shixun_service_configs do diff --git a/app/views/shixuns/show.json.jbuilder b/app/views/shixuns/show.json.jbuilder index 8e49a99f4..4a0c3ebd6 100644 --- a/app/views/shixuns/show.json.jbuilder +++ b/app/views/shixuns/show.json.jbuilder @@ -2,3 +2,4 @@ json.fork_from @fork_from json.identity User.current.shixun_identity(@shixun) json.power @power json.partial! 'shixuns/top', locals: { shixun: @shixun, current_myshixun: @current_myshixun } +json.secret_repository @shixun.shixun_secret_repository.present? diff --git a/app/views/student_works/shixun_work_comment.json.jbuilder b/app/views/student_works/shixun_work_comment.json.jbuilder new file mode 100644 index 000000000..f9f47cba5 --- /dev/null +++ b/app/views/student_works/shixun_work_comment.json.jbuilder @@ -0,0 +1,3 @@ +json.comment_id @comment.id +json.status 0 +json.message "评阅成功" \ No newline at end of file diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder index 29a5c1874..2c9558fdc 100644 --- a/app/views/student_works/shixun_work_report.json.jbuilder +++ b/app/views/student_works/shixun_work_report.json.jbuilder @@ -36,6 +36,10 @@ if @shixun challenge_score = @homework.challenge_score game.challenge_id json.game_score_full challenge_score json.game_score @work.work_challenge_score game, challenge_score + challenge_comment = @work.shixun_work_comments.find_by(challenge_id: game.challenge_id) + json.challenge_comment challenge_comment&.comment + json.challenge_comment_hidden @user_course_identity < Course::STUDENT ? challenge_comment&.hidden_comment : nil + json.comment_id challenge_comment&.id end end @@ -54,8 +58,9 @@ if @shixun json.passed_time @work.myshixun&.passed_time # 评阅信息 - json.work_comment @user_course_identity < Course::STUDENT || !@comment&.is_hidden ? @comment&.comment : nil - json.work_comment_hidden @comment&.is_hidden + json.work_comment @comment&.comment + json.work_comment_hidden @user_course_identity < Course::STUDENT ? @comment&.hidden_comment : nil + json.comment_id @comment&.id # 图形统计 # 1: 效率 diff --git a/config/initializers/session_extenstions.rb b/config/initializers/session_extenstions.rb index 36a8ae8c7..cee3dfc06 100644 --- a/config/initializers/session_extenstions.rb +++ b/config/initializers/session_extenstions.rb @@ -1,35 +1,33 @@ -#coding=utf-8 - -module SessionExtenstions - - module EntryExtension - def compressed? - @compressed - end - - def value - if @value - begin - Marshal.load(compressed? ? Zlib::Inflate.inflate(@value) : @value) - rescue TypeError - compressed? ? Zlib::Inflate.inflate(@value) : @value - end - end - end - - def size - if @value.nil? - 0 - else - @value.bytesize - end - end - end - - -end - -ActiveSupport::Cache::Entry.const_set("DEFAULT_COMPRESS_LIMIT", 1) -ActiveSupport::Cache::Entry.send(:prepend, SessionExtenstions::EntryExtension) - - +#coding=utf-8 + +module SessionExtenstions + + module EntryExtension + def compressed? + @compressed + end + + def value + if @value + begin + Marshal.load(compressed? ? Zlib::Inflate.inflate(@value) : @value) + rescue TypeError + compressed? ? Zlib::Inflate.inflate(@value) : @value + end + end + end + + def size + if @value.nil? + 0 + else + @value.bytesize + end + end + end + + +end + +ActiveSupport::Cache::Entry.const_set("DEFAULT_COMPRESS_LIMIT", 1) +ActiveSupport::Cache::Entry.send(:prepend, SessionExtenstions::EntryExtension) diff --git a/config/routes.rb b/config/routes.rb index 0d1b979b1..0d6e108ad 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -55,12 +55,14 @@ Rails.application.routes.draw do get :homepage_info end + get :question_banks, on: :collection, to: 'users/question_banks#index' + scope module: :users do resources :courses, only: [:index] resources :shixuns, only: [:index] resources :projects, only: [:index] resources :subjects, only: [:index] - resources :question_banks, only: [:index] + # resources :question_banks, only: [:index] resource :experience_records, only: [:show] resource :grade_records, only: [:show] resource :watch, only: [:create, :destroy] @@ -195,6 +197,8 @@ Rails.application.routes.draw do get :get_script_contents get :get_custom_script post :repository + post :secret_repository + post :set_secret_dir post :commits post :file_content post :update_file diff --git a/db/migrate/20190907021100_migrate_bank_reference_id.rb b/db/migrate/20190907021100_migrate_bank_reference_id.rb new file mode 100644 index 000000000..c71034167 --- /dev/null +++ b/db/migrate/20190907021100_migrate_bank_reference_id.rb @@ -0,0 +1,31 @@ +class MigrateBankReferenceId < ActiveRecord::Migration[5.2] + def change + HomeworkBank.all.each do |bank| + if bank.homework_common + bank.homework_common.update_column("homework_bank_id", bank.id) if bank.homework_common.homework_bank_id.nil? + end + end + + GtopicBank.all.each do |bank| + if bank.graduation_topic + bank.graduation_topic.update_column("gtopic_bank_id", bank.id) if bank.graduation_topic.gtopic_bank_id.nil? + end + end + + GtaskBank.all.each do |bank| + if bank.graduation_task + bank.graduation_task.update_column("gtask_bank_id", bank.id) if bank.graduation_task.gtask_bank_id.nil? + end + end + + ExerciseBank.all.each do |bank| + if bank.container_type == 'Exercise' + exercise = Exercise.find_by(id: bank.container_id) + exercise.update_column("exercise_bank_id", bank.id) if exercise && exercise.exercise_bank_id.nil? + elsif bank.container_type == 'Poll' + poll = Poll.find_by(id: bank.container_id) + poll.update_column("exercise_bank_id", bank.id) if poll && poll.exercise_bank_id.nil? + end + end + end +end diff --git a/db/migrate/20190907061918_migrate_bank_quotes.rb b/db/migrate/20190907061918_migrate_bank_quotes.rb new file mode 100644 index 000000000..9f278860d --- /dev/null +++ b/db/migrate/20190907061918_migrate_bank_quotes.rb @@ -0,0 +1,28 @@ +class MigrateBankQuotes < ActiveRecord::Migration[5.2] + def change + HomeworkBank.all.each do |bank| + task_count = bank.homework_commons.count + bank.update_column("quotes", task_count == 0 ? 1 : task_count) + end + + GtopicBank.all.each do |bank| + task_count = bank.graduation_topics.count + bank.update_column("quotes", task_count == 0 ? 1 : task_count) + end + + GtaskBank.all.each do |bank| + task_count = bank.graduation_tasks.count + bank.update_column("quotes", task_count == 0 ? 1 : task_count) + end + + ExerciseBank.all.each do |bank| + if bank.container_type == 'Exercise' + task_count = bank.exercises.count + bank.update_column("quotes", task_count == 0 ? 1 : task_count) + elsif bank.container_type == 'Poll' + task_count = bank.polls.count + bank.update_column("quotes", task_count == 0 ? 1 : task_count) + end + end + end +end diff --git a/db/migrate/20190909061930_create_shixun_secret_repositories.rb b/db/migrate/20190909061930_create_shixun_secret_repositories.rb new file mode 100644 index 000000000..5526869f8 --- /dev/null +++ b/db/migrate/20190909061930_create_shixun_secret_repositories.rb @@ -0,0 +1,10 @@ +class CreateShixunSecretRepositories < ActiveRecord::Migration[5.2] + def change + create_table :shixun_secret_repositories do |t| + t.references :shixun + t.string :repo_name + t.string :secret_dir_path + t.timestamps + end + end +end diff --git a/db/migrate/20190909072626_add_match_rule_for_test_sets.rb b/db/migrate/20190909072626_add_match_rule_for_test_sets.rb new file mode 100644 index 000000000..2d9d53f0f --- /dev/null +++ b/db/migrate/20190909072626_add_match_rule_for_test_sets.rb @@ -0,0 +1,7 @@ +class AddMatchRuleForTestSets < ActiveRecord::Migration[5.2] + def change + add_column :test_sets, :match_rule, :string + TestSet.update_all(match_rule: 'full') + + end +end diff --git a/db/migrate/20190909080508_create_shixun_work_comments.rb b/db/migrate/20190909080508_create_shixun_work_comments.rb new file mode 100644 index 000000000..eb21f0d04 --- /dev/null +++ b/db/migrate/20190909080508_create_shixun_work_comments.rb @@ -0,0 +1,13 @@ +class CreateShixunWorkComments < ActiveRecord::Migration[5.2] + def change + create_table :shixun_work_comments do |t| + t.references :student_work, index: true, type: :integer + t.references :challenge, index: true, type: :integer, default: 0 + t.references :user, index: true, type: :integer + t.text :comment + t.text :hidden_comment + + t.timestamps + end + end +end diff --git a/db/migrate/20190909082555_migrate_shixun_work_comment.rb b/db/migrate/20190909082555_migrate_shixun_work_comment.rb new file mode 100644 index 000000000..f58531b80 --- /dev/null +++ b/db/migrate/20190909082555_migrate_shixun_work_comment.rb @@ -0,0 +1,13 @@ +class MigrateShixunWorkComment < ActiveRecord::Migration[5.2] + def change + StudentWorksScore.where(is_ultimate: 0, score: nil).where("created_at > '2019-09-04 00:00:00'").each do |work_score| + if work_score.student_work && work_score.student_work.homework_common&.shixuns + if work_score.is_hidden + ShixunWorkComment.create!(student_work_id: work_score.student_work_id, user_id: work_score.user_id, hidden_comment: work_score.comment) + else + ShixunWorkComment.create!(student_work_id: work_score.student_work_id, user_id: work_score.user_id, comment: work_score.comment) + end + end + end + end +end diff --git a/public/javascripts/educoder/edu_application.js b/public/javascripts/educoder/edu_application.js index 612a5a44b..7f8f8ac4d 100644 --- a/public/javascripts/educoder/edu_application.js +++ b/public/javascripts/educoder/edu_application.js @@ -218,7 +218,7 @@ function _initSider() { }) } $(function() { - loadHeader(); + // loadHeader(); _initSider(); $(window).scroll(function() { @@ -436,86 +436,86 @@ function editormd_to_html(id, callback) { } function loadHeader() { - //头部导航条的----------显示搜索框 - $("#search-open").on("click", function(e) { - $(this).hide(); - // $("#header-nav").animate({opacity:"0"},1000); - $(".posi-search").show() - // .animate({opacity:"1"},1000); - $("#header-nav").css("z-index", "2"); - $(".posi-search").css("z-index", "3"); - // $(".search-input").val(""); // 不清空 - $(".search-input").focus(); - $(".search-all .search-content").hide(); - e.stopPropagation(); - //阻止冒泡 - }); - $(".search-input").on("click", function(e) { - e.stopPropagation(); - //阻止冒泡 - }); - //搜索框输入内容 - $(".search-input").on("input", function(e) { - if ($(".search-input").val() == "") { - $(".search-all .search-content").hide(); - } else { - $(".search-all .search-content").show(); - } - e.stopPropagation(); - //阻止冒泡 - }); - //搜索 - $("#header_keyword_search").on("click", header_search); - $("input[name='search_keyword']").on("keydown", function(event) { - var code; - if (!event) { - event = window.event; - //针对ie浏览器 - code = event.keyCode; - } else { - code = event.keyCode; - } - if (code == 13) { - header_search(); - return false; - } - }); - $(".search-clear").click(function(e) { - e.stopPropagation(); - }); - //切换搜索条件 - $("#searchkey li").click(function(e) { - var key = $($(this).children("a")[0]).html(); - switch (key) { - case '实训': - $("#search_type").val('1'); - break; - case '课堂': - $("#search_type").val('2'); - break; - case '用户': - $("#search_type").val('3'); - break; - } - $("#searchkey").siblings(".searchkey").html(key); - // $("#searchkey").hide(); - e.stopPropagation(); - //阻止冒泡 - }); - //切换选择导航条 - $("#header-nav li").click(function() { - $("#header-nav li").removeClass("active"); - $(this).addClass("active"); - }); - //点击页面其它(与搜索框无关的地方)都会将搜索框隐藏,所以与搜索框有关的地方需要阻止冒泡 - $("body").on("click", function() { - closeSearch(); - }); - - $(".search_history").on("click", function() { - $("input[name='search_keyword']").val($(this).html()); - header_search(); - }); + // //头部导航条的----------显示搜索框 + // $("#search-open").on("click", function(e) { + // $(this).hide(); + // // $("#header-nav").animate({opacity:"0"},1000); + // $(".posi-search").show() + // // .animate({opacity:"1"},1000); + // $("#header-nav").css("z-index", "2"); + // $(".posi-search").css("z-index", "3"); + // // $(".search-input").val(""); // 不清空 + // $(".search-input").focus(); + // $(".search-all .search-content").hide(); + // e.stopPropagation(); + // //阻止冒泡 + // }); + // $(".search-input").on("click", function(e) { + // e.stopPropagation(); + // //阻止冒泡 + // }); + // //搜索框输入内容 + // $(".search-input").on("input", function(e) { + // if ($(".search-input").val() == "") { + // $(".search-all .search-content").hide(); + // } else { + // $(".search-all .search-content").show(); + // } + // e.stopPropagation(); + // //阻止冒泡 + // }); + // //搜索 + // $("#header_keyword_search").on("click", header_search); + // $("input[name='search_keyword']").on("keydown", function(event) { + // var code; + // if (!event) { + // event = window.event; + // //针对ie浏览器 + // code = event.keyCode; + // } else { + // code = event.keyCode; + // } + // if (code == 13) { + // header_search(); + // return false; + // } + // }); + // $(".search-clear").click(function(e) { + // e.stopPropagation(); + // }); + // //切换搜索条件 + // $("#searchkey li").click(function(e) { + // var key = $($(this).children("a")[0]).html(); + // switch (key) { + // case '实训': + // $("#search_type").val('1'); + // break; + // case '课堂': + // $("#search_type").val('2'); + // break; + // case '用户': + // $("#search_type").val('3'); + // break; + // } + // $("#searchkey").siblings(".searchkey").html(key); + // // $("#searchkey").hide(); + // e.stopPropagation(); + // //阻止冒泡 + // }); + // //切换选择导航条 + // $("#header-nav li").click(function() { + // $("#header-nav li").removeClass("active"); + // $(this).addClass("active"); + // }); + // //点击页面其它(与搜索框无关的地方)都会将搜索框隐藏,所以与搜索框有关的地方需要阻止冒泡 + // $("body").on("click", function() { + // closeSearch(); + // }); + // + // $(".search_history").on("click", function() { + // $("input[name='search_keyword']").val($(this).html()); + // header_search(); + // }); } function header_search() { diff --git a/public/react/public/images/share_logo_icon.jpg b/public/react/public/images/share_logo_icon.jpg new file mode 100644 index 000000000..079ac4342 Binary files /dev/null and b/public/react/public/images/share_logo_icon.jpg differ diff --git a/public/react/public/index.html b/public/react/public/index.html index b252ccf36..de539ffba 100755 --- a/public/react/public/index.html +++ b/public/react/public/index.html @@ -22,6 +22,8 @@ --> EduCoder