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 5f5eddddc..d5405fd71 100644 --- a/app/controllers/hack_user_lastest_codes_controller.rb +++ b/app/controllers/hack_user_lastest_codes_controller.rb @@ -1,10 +1,10 @@ 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: [:update_code, :restore_initial_code, :sync_code] - before_action :require_manager_identity, only: [:update_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 @my_hack.update_attribute(:submit_status, 0) if @my_hack.submit_status == 1 @@ -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]) @@ -168,7 +172,7 @@ class HackUserLastestCodesController < ApplicationController # 编程题已经发布,且之前未通关奖励积分 @hack.increment!(:pass_num) if @hack.status == 1 && !@my_hack.passed? - reward_attrs = { container_id: game.id, container_type: 'Hack', score: @hack.score } + reward_attrs = { container_id: @hack.id, container_type: 'Hack', score: @hack.score } RewardGradeService.call(@my_hack.user, reward_attrs) RewardExperienceService.call(@my_hack.user, reward_attrs) # 评测完成更新通过数 diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index f93b2dab5..fec768a19 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -188,10 +188,13 @@ class HacksController < ApplicationController def param_update_sets sets, all_sets_id delete_set_ids = all_sets_id - sets.map{|set|set[:id]} @hack.hack_sets.where(id: delete_set_ids).destroy_all + logger.info("#######sets:#{sets}") sets.each do |set| + logger.info("###set[:id]: #{set[:id]}") + logger.info("###all_sets: #{all_sets_id.include?(set[:id])}") if all_sets_id.include?(set[:id]) update_attrs = {input: set[:input], output: set[:output], position: set[:position]} - @hack.hack_sets.find_by!(id: set[:id]).update_attributes(update_attrs) + @hack.hack_sets.find_by!(id: set[:id]).update_attributes!(update_attrs) end end end 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 @@
+ {/* 系统繁忙,请稍后重试 */} + {error_msg} +
+ ) + } else if (state === 3) { return (
系统繁忙,请稍后重试
diff --git a/public/react/src/modules/developer/components/initTabCtx/index.scss b/public/react/src/modules/developer/components/initTabCtx/index.scss
index 5427aa374..992d49534 100644
--- a/public/react/src/modules/developer/components/initTabCtx/index.scss
+++ b/public/react/src/modules/developer/components/initTabCtx/index.scss
@@ -41,7 +41,7 @@
}
}
.flex_l{
- padding: 0 10px 0 20px;
+ padding: 0 10px 0 10px;
color: #fff;
}
.flex_r{
diff --git a/public/react/src/modules/developer/components/myMonacoEditor/index.js b/public/react/src/modules/developer/components/myMonacoEditor/index.js
index 261818092..facff0b75 100644
--- a/public/react/src/modules/developer/components/myMonacoEditor/index.js
+++ b/public/react/src/modules/developer/components/myMonacoEditor/index.js
@@ -3,8 +3,8 @@
* @Author: tangjiang
* @Github:
* @Date: 2019-11-27 15:02:52
- * @LastEditors: tangjiang
- * @LastEditTime: 2019-12-20 20:07:11
+ * @LastEditors : tangjiang
+ * @LastEditTime : 2019-12-26 15:19:34
*/
import './index.scss';
import React, { useState, useRef, useEffect } from 'react';
@@ -155,7 +155,7 @@ function MyMonacoEditor (props, ref) {
onClick={handleUpdateNotice}
>
{/*