Merge branch 'dev_aliyun' into dev_tj

merge aliyun
yslnewtiku
tangjiang 5 years ago
commit cd6e4916da

@ -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,

@ -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)

@ -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])

@ -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: "多个测试集的输入不能相同"
# 编程题测试集

@ -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

@ -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)

@ -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)

@ -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])

@ -8,7 +8,7 @@
<div class="d-flex position-r">
<div class="form-group mr-2">
<label for="status">状态:</label>
<% 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') %>
</div>
<div class="form-group mr-2">

@ -8,16 +8,10 @@
<div class="d-flex position-r">
<div class="form-group">
<label for="status">状态:</label>
<% 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') %>
</div>
<div class="form-group mr-2">
<label for="status">公开:</label>
<% 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') %>
</div>
<div class="form-group mr-2">
<label for="tag-choosed">技术平台:</label>
<%= select_tag(:tag, options_for_select(@shixuns_type_check.unshift(["",nil])), class: 'form-control',id:"tag-choosed") %>

@ -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)

@ -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

@ -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

@ -0,0 +1,5 @@
class AddNotesHackUserLastestCodes < ActiveRecord::Migration[5.2]
def change
add_column :hack_user_lastest_codes, :notes, :longtext
end
end

@ -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
Loading…
Cancel
Save