diff --git a/app/controllers/admins/shixun_settings_controller.rb b/app/controllers/admins/shixun_settings_controller.rb index fd06fddb3..37ca45674 100644 --- a/app/controllers/admins/shixun_settings_controller.rb +++ b/app/controllers/admins/shixun_settings_controller.rb @@ -5,9 +5,10 @@ class Admins::ShixunSettingsController < Admins::BaseController shixun_settings = Admins::ShixunSettingsQuery.call(params) @editing_shixuns = shixun_settings.where(status:0).size - @pending_shixuns = shixun_settings.where(status:1).size - @processed_shixuns = shixun_settings.where(status:2).size + @processed_shixuns = shixun_settings.where(status:2, public: 0).size @closed_shixuns = shixun_settings.where(status:3).size + @pending_public_shixuns = shixun_settings.where(public:1).size + @processed_pubic_shixuns = shixun_settings.where(public:2).size @sort_json = { can_copy: params[:can_copy].present? ? params[:can_copy] : false, diff --git a/app/controllers/admins/shixuns_controller.rb b/app/controllers/admins/shixuns_controller.rb index 6593f27c2..86cb9b45f 100644 --- a/app/controllers/admins/shixuns_controller.rb +++ b/app/controllers/admins/shixuns_controller.rb @@ -5,10 +5,8 @@ class Admins::ShixunsController < Admins::BaseController params[:sort_direction] = params[:sort_direction].presence || 'desc' shixuns = Admins::ShixunQuery.call(params) @editing_shixuns = shixuns.where(status:0).size - @pending_shixuns = shixuns.where(status:1).size - @processed_shixuns = shixuns.where(status:2).size + @processed_shixuns = shixuns.where(status:2, public: 0).size @closed_shixuns = shixuns.where(status:3).size - @none_public_shixuns = shixuns.where(public:0).size @pending_public_shixuns = shixuns.where(public:1).size @processed_pubic_shixuns = shixuns.where(public:2).size @shixuns_type_check = MirrorRepository.pluck(:type_name,:id) diff --git a/app/controllers/hack_user_lastest_codes_controller.rb b/app/controllers/hack_user_lastest_codes_controller.rb index 655fea471..ff0af5958 100644 --- a/app/controllers/hack_user_lastest_codes_controller.rb +++ b/app/controllers/hack_user_lastest_codes_controller.rb @@ -1,9 +1,9 @@ class HackUserLastestCodesController < ApplicationController before_action :require_login, except: [:listen_result] - before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code, :sync_code, + before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code, :sync_code, :add_notes, :listen_result, :result, :submit_records, :restore_initial_code] before_action :update_user_hack_status, only: [:code_debug, :code_submit] - #before_action :require_auth_identity, only: [:restore_initial_code, :sync_code] + before_action :require_auth_identity, only: [:add_notes] before_action :require_manager_identity, only: [:show, :update_code, :restore_initial_code, :sync_code] def show @@ -67,7 +67,6 @@ class HackUserLastestCodesController < ApplicationController end - # 提交记录详情 def record_detail @hack_user = HackUserCode.find params[:id] @@ -109,6 +108,11 @@ class HackUserLastestCodesController < ApplicationController end + def add_notes + @my_hack.update_attribute(:notes, params[:notes]) + render_ok + end + private def find_my_hack @my_hack = HackUserLastestCode.find_by(identifier: params[:identifier]) diff --git a/app/models/hack_set.rb b/app/models/hack_set.rb index 6afe05663..9e2186fb5 100644 --- a/app/models/hack_set.rb +++ b/app/models/hack_set.rb @@ -1,5 +1,5 @@ class HackSet < ApplicationRecord - #validates :input, presence: { message: "测试集输入不能为空" } + validates :input, presence: { message: "测试集输入不能为空" } validates :output, presence: { message: "测试集输出不能为空" } validates_uniqueness_of :input, scope: [:hack_id, :input], message: "多个测试集的输入不能相同" # 编程题测试集 diff --git a/app/models/hack_user_lastest_code.rb b/app/models/hack_user_lastest_code.rb index 830f16dde..99582af41 100644 --- a/app/models/hack_user_lastest_code.rb +++ b/app/models/hack_user_lastest_code.rb @@ -12,4 +12,6 @@ class HackUserLastestCode < ApplicationRecord scope :mine_hack, ->(author_id){ where(user_id: author_id) } scope :passed, -> {where(status: 1)} + validates_length_of :notes, maximum: 5000, message: "笔记不能超过5000个字" + end diff --git a/app/queries/admins/shixun_query.rb b/app/queries/admins/shixun_query.rb index 4f9f4676e..29e087332 100644 --- a/app/queries/admins/shixun_query.rb +++ b/app/queries/admins/shixun_query.rb @@ -13,25 +13,14 @@ class Admins::ShixunQuery < ApplicationQuery all_shixuns = Shixun.all status = case params[:status] - when "editing" then [0] - when "pending" then [1] - when "processed" then [2] - when "closed" then [3] - else - [0,1,2,3] + when "editing" then {status: 0} + when "processed" then {status: 2, public: 0} + when "pending" then {public: 1} + when "publiced" then {public: 2} + when "closed" then {status: 3} end - public = - case params[:public] - when "editing" then [0] - when "pending" then [1] - when "processed" then [2] - else - [0,1,2] - end - - all_shixuns = all_shixuns.where(status: status) if status.present? - all_shixuns = all_shixuns.where(public: public) if public.present? + all_shixuns = all_shixuns.where(status) if status.present? if params[:fork_status].present? all_shixuns = all_shixuns.where.not(fork_from: nil) diff --git a/app/queries/admins/shixun_settings_query.rb b/app/queries/admins/shixun_settings_query.rb index 377e7bf60..1e45952bf 100644 --- a/app/queries/admins/shixun_settings_query.rb +++ b/app/queries/admins/shixun_settings_query.rb @@ -15,16 +15,15 @@ class Admins::ShixunSettingsQuery < ApplicationQuery all_shixuns = all_shixuns.where(id: params[:id]) if params[:id].present? status = - case params[:status] - when "editing" then [0] - when "pending" then [1] - when "processed" then [2] - when "closed" then [3] - else - [0,1,2,3] - end - - all_shixuns = all_shixuns.where(status: status) if status.present? + case params[:status] + when "editing" then {status: 0} + when "processed" then {status: 2, public: 0} + when "pending" then {public: 1} + when "publiced" then {public: 2} + when "closed" then {status: 3} + end + + all_shixuns = all_shixuns.where(status) if status.present? if params[:tag].present? all_shixuns = all_shixuns.joins(:mirror_repositories).where("mirror_repositories.id = ?",params[:tag].to_i) diff --git a/app/services/shixun_search_service.rb b/app/services/shixun_search_service.rb index 248d7d176..32488a7c3 100644 --- a/app/services/shixun_search_service.rb +++ b/app/services/shixun_search_service.rb @@ -33,6 +33,10 @@ class ShixunSearchService < ApplicationService @shixuns = status == "published" ? @shixuns.where(status: 2) : @shixuns.where(status: [0, 1]) end + if params[:no_jupyter] + @shixuns = @shixuns.where(is_jupyter: 0) + end + ## 筛选 难度 if params[:diff].present? && params[:diff].to_i != 0 @shixuns = @shixuns.where(trainee: params[:diff]) diff --git a/app/views/admins/shixun_settings/index.html.erb b/app/views/admins/shixun_settings/index.html.erb index 66286926a..16a02ab96 100644 --- a/app/views/admins/shixun_settings/index.html.erb +++ b/app/views/admins/shixun_settings/index.html.erb @@ -8,7 +8,7 @@
- <% status_options = [['全部', ''], ["编辑中(#{@editing_shixuns})", "editing"], ["待审核(#{@pending_shixuns})", 'pending'], ["已发布(#{@processed_shixuns})", 'processed'],["已关闭(#{@closed_shixuns})",'closed']] %> + <% status_options = [['全部', ''], ["编辑中(#{@editing_shixuns})", "editing"], ["已发布未公开(#{@processed_shixuns})", 'processed'], ["待审核(#{@pending_public_shixuns})", 'pending'], ["已公开(#{@processed_pubic_shixuns})", 'publiced'], ["已关闭(#{@closed_shixuns})",'closed']] %> <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
diff --git a/app/views/admins/shixuns/index.html.erb b/app/views/admins/shixuns/index.html.erb index 9bb09f86f..4348f0f45 100644 --- a/app/views/admins/shixuns/index.html.erb +++ b/app/views/admins/shixuns/index.html.erb @@ -8,16 +8,10 @@
- <% status_options = [['全部', ''], ["编辑中(#{@editing_shixuns})", "editing"], ["待审核(#{@pending_shixuns})", 'pending'], ["已发布(#{@processed_shixuns})", 'processed'],["已关闭(#{@closed_shixuns})",'closed']] %> + <% status_options = [['全部', ''], ["编辑中(#{@editing_shixuns})", "editing"], ["已发布未公开(#{@processed_shixuns})", 'processed'], ["待审核(#{@pending_public_shixuns})", 'pending'], ["已公开(#{@processed_pubic_shixuns})", 'publiced'], ["已关闭(#{@closed_shixuns})",'closed']] %> <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
-
- - <% public_options = [['全部', ''], ["未公开(#{@none_public_shixuns})", "editing"], ["待审核(#{@pending_public_shixuns})", 'pending'], ["已公开(#{@processed_pubic_shixuns})", 'processed']] %> - <%= select_tag(:public, options_for_select(public_options), class: 'form-control') %> -
-
<%= select_tag(:tag, options_for_select(@shixuns_type_check.unshift(["",nil])), class: 'form-control',id:"tag-choosed") %> diff --git a/app/views/challenges/edit.json.jbuilder b/app/views/challenges/edit.json.jbuilder index c0ea68d9c..9a135ff56 100644 --- a/app/views/challenges/edit.json.jbuilder +++ b/app/views/challenges/edit.json.jbuilder @@ -14,7 +14,7 @@ if @tab == 0 elsif @tab == 1 # 评测设置的编辑模式 json.(@challenge, :id, :path, :exec_path, :show_type, :original_picture_path, :expect_picture_path, :picture_path, - :web_route, :test_set_score, :test_set_average) + :web_route, :test_set_score, :test_set_average, :exec_time) json.has_web_route @shixun.has_web_route? json.test_sets @challenge.test_sets do |set| json.hidden (set.is_public ? 0 : 1) diff --git a/app/views/hack_user_lastest_codes/show.json.jbuilder b/app/views/hack_user_lastest_codes/show.json.jbuilder index 098c24546..a158d074f 100644 --- a/app/views/hack_user_lastest_codes/show.json.jbuilder +++ b/app/views/hack_user_lastest_codes/show.json.jbuilder @@ -5,6 +5,7 @@ json.hack do json.code @my_hack.code json.pass_count @hack.pass_num json.submit_count @hack.submit_num + json.notes @my_hack.notes json.modify_code @modify json.comments_count @hack.discusses.count json.user_praise @hack.praise_treads.select{|pt| pt.user_id == current_user.id}.length > 0 diff --git a/config/routes.rb b/config/routes.rb index 7a68ed5e2..f9ed12dbe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -90,6 +90,7 @@ Rails.application.routes.draw do get :submit_records post :restore_initial_code post :sync_code + post :add_notes end collection do diff --git a/db/migrate/20191226083915_add_notes_hack_user_lastest_codes.rb b/db/migrate/20191226083915_add_notes_hack_user_lastest_codes.rb new file mode 100644 index 000000000..518e6d610 --- /dev/null +++ b/db/migrate/20191226083915_add_notes_hack_user_lastest_codes.rb @@ -0,0 +1,5 @@ +class AddNotesHackUserLastestCodes < ActiveRecord::Migration[5.2] + def change + add_column :hack_user_lastest_codes, :notes, :longtext + end +end diff --git a/db/migrate/20191226092304_modify_task_pass_2_for_challenges.rb b/db/migrate/20191226092304_modify_task_pass_2_for_challenges.rb new file mode 100644 index 000000000..f03039aa2 --- /dev/null +++ b/db/migrate/20191226092304_modify_task_pass_2_for_challenges.rb @@ -0,0 +1,8 @@ +class ModifyTaskPass2ForChallenges < ActiveRecord::Migration[5.2] + def change + challenges = Challenge.where("task_pass like '%frac%'") + challenges.find_each do |c| + c.update_column(:task_pass, c.task_pass.gsub('\f\frac', '\frac')) + end + end +end