Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_course
daiao 5 years ago
commit fe1231ff52

@ -538,6 +538,7 @@ class GamesController < ApplicationController
# 编程题评测 # 编程题评测
def game_build def game_build
sec_key = params[:sec_key]
game_challenge = Challenge.select([:id, :position, :picture_path]).find(@game.challenge_id) game_challenge = Challenge.select([:id, :position, :picture_path]).find(@game.challenge_id)
# 更新评测次数 # 更新评测次数
@ -585,7 +586,7 @@ class GamesController < ApplicationController
:instanceChallenge => "#{step}", :testCases => "#{testCases}", :resubmit => "#{resubmit}", :instanceChallenge => "#{step}", :testCases => "#{testCases}", :resubmit => "#{resubmit}",
:times => params[:first].to_i, :podType => @shixun.webssh, :content_modified => content_modified, :times => params[:first].to_i, :podType => @shixun.webssh, :content_modified => content_modified,
:containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}", :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}",
:persistenceName => @shixun.identifier, :tpmScript => "#{tpmScript}", :persistenceName => @shixun.identifier, :tpmScript => "#{tpmScript}", :sec_key => sec_key,
:timeLimit => "#{@shixun.exec_time}", :isPublished => (@shixun.status < 2 ? 0 : 1) } :timeLimit => "#{@shixun.exec_time}", :isPublished => (@shixun.status < 2 ? 0 : 1) }
# 评测有文件输出的需要特殊传字段 path表示文件存储的位置 # 评测有文件输出的需要特殊传字段 path表示文件存储的位置

@ -1,10 +1,15 @@
class GitsController < ApplicationController class GitsController < ApplicationController
#供git-workhorse反向调用认证 # 说明:
# 以下Git认证只针对新版gitGitlab的Git认证不走该控制器
# 思路:
# 1、用户通过Git客户端推送代码的时候这个时候Git客户端肯定会强制用户输入邮箱的
# 2、通过web端版本库界面更新代码如果用户邮箱不存在则用系统备用邮箱
# 供 git-workhorse反向调用认证
def auth def auth
# HTTP_AUTHORIZATION: "Basic 这里base64编码的的密码(user:passwd)" # HTTP_AUTHORIZATION: "Basic 这里base64编码的的密码(user:passwd)"
logger.info("11111112222223333 HTTP_AUTHORIZATION: #{request.env["HTTP_AUTHORIZATION"]}") logger.info("11111112222223333 HTTP_AUTHORIZATION: #{request.env["HTTP_AUTHORIZATION"]}")
#logger.info("#########-----request_env: #{request.env}") # logger.info("#########-----request_env: #{request.env}")
# {"service"=>"git-receive-pack", "controller"=>"gits", "action"=>"auth", # {"service"=>"git-receive-pack", "controller"=>"gits", "action"=>"auth",
# "url"=>"forge01/cermyt39.git/info/refs"} # "url"=>"forge01/cermyt39.git/info/refs"}
# #

@ -85,9 +85,6 @@ class MyshixunsController < ApplicationController
# "createPod":"1.610","evaluateAllTime":2820,"evaluateStart":"2017-11-24 11:04:35","execute":"0.294"}' # "createPod":"1.610","evaluateAllTime":2820,"evaluateStart":"2017-11-24 11:04:35","execute":"0.294"}'
# params[:pics] = "a.png,b.png,c.png" # params[:pics] = "a.png,b.png,c.png"
def training_task_status def training_task_status
logger.info("123################{params[:jsonTestDetails]}")
logger.info("456################{params[:timeCost]}")
logger.info("666###############{params}")
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
@ -98,13 +95,14 @@ class MyshixunsController < ApplicationController
return_back_time = format("%.3f", ( t1.to_f - brige_end_time.to_f)).to_f return_back_time = format("%.3f", ( t1.to_f - brige_end_time.to_f)).to_f
status = jsonTestDetails['status'] status = jsonTestDetails['status']
game_id = jsonTestDetails['buildID'] game_id = jsonTestDetails['buildID']
sec_key = jsonTestDetails['sec_key']
logger.info("training_task_status start#1**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") logger.info("training_task_status start#1**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
resubmit = jsonTestDetails['resubmit'] resubmit = jsonTestDetails['resubmit']
outPut = tran_base64_decode64(jsonTestDetails['outPut']) outPut = tran_base64_decode64(jsonTestDetails['outPut'])
jenkins_testsets = jsonTestDetails['msg'] jenkins_testsets = jsonTestDetails['msg']
compile_success = jsonTestDetails['compileSuccess'] compile_success = jsonTestDetails['compileSuccess']
# message = Base64.decode64(params[:msg]) unless params[:msg].blank? # message = Base64.decode64(params[:msg]) unless params[:msg].blank?
logger.info(outPut)
game = Game.find(game_id) game = Game.find(game_id)
myshixun = game.myshixun myshixun = game.myshixun
challenge = game.challenge challenge = game.challenge
@ -125,7 +123,7 @@ class MyshixunsController < ApplicationController
logger.info "actual_output:################################################# #{actual_output}" logger.info "actual_output:################################################# #{actual_output}"
Output.create!(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'], Output.create!(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'],
:actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => max_query_index, :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => max_query_index,
:compile_success => compile_success.to_i) :compile_success => compile_success.to_i, :sec_key => sec_key)
# 如果设置了按测试集给分,则需要统计测试集的分值 # 如果设置了按测试集给分,则需要统计测试集的分值
if challenge.test_set_score && j_test_set['passed'].to_i == 1 if challenge.test_set_score && j_test_set['passed'].to_i == 1
test_set_score += challenge.test_sets.where(:position => j_test_set['caseId']).pluck(:score).first test_set_score += challenge.test_sets.where(:position => j_test_set['caseId']).pluck(:score).first

@ -0,0 +1,25 @@
class Users::InterestsController < Users::BaseController
before_action :require_login
before_action :private_user_resources!
def create
identity = params[:identity].to_s.strip
extension = observed_user.user_extension || observed_user.build_user_extension
return render_error('请选择职业') unless %w(teacher student professional).include?(identity)
ActiveRecord::Base.transaction do
extension.update_column(:identity, identity)
# 兴趣
observed_user.user_interests.delete_all
UserInterest.bulk_insert(:user_id, :repertoire_id) do |worker|
(Repertoire.pluck(:id) & Array.wrap(params[:interest_ids]).map(&:to_i)).each do |repertoire_id|
worker.add(user_id: observed_user.id, repertoire_id: repertoire_id)
end
end
end
render_ok
end
end

@ -2,4 +2,5 @@ class Repertoire < ApplicationRecord
has_many :sub_repertoires, ->{order(updated_at: :desc)}, :dependent => :destroy has_many :sub_repertoires, ->{order(updated_at: :desc)}, :dependent => :destroy
has_many :tag_repertoires, through: :sub_repertoires has_many :tag_repertoires, through: :sub_repertoires
has_many :user_interests, dependent: :delete_all
end end

@ -115,6 +115,10 @@ class User < ApplicationRecord
has_many :attendances has_many :attendances
# 兴趣
has_many :user_interests, dependent: :delete_all
has_many :interests, through: :user_interests, source: :repertoire
# Groups and active users # Groups and active users
scope :active, lambda { where(status: STATUS_ACTIVE) } scope :active, lambda { where(status: STATUS_ACTIVE) }

@ -0,0 +1,4 @@
class UserInterest < ApplicationRecord
belongs_to :user
belongs_to :repertoire
end

@ -47,6 +47,7 @@ Rails.application.routes.draw do
resource :experience_records, only: [:show] resource :experience_records, only: [:show]
resource :grade_records, only: [:show] resource :grade_records, only: [:show]
resource :watch, only: [:create, :destroy] resource :watch, only: [:create, :destroy]
resource :interest, only: [:create]
end end

@ -0,0 +1,5 @@
class AddSecKeyToOutputs < ActiveRecord::Migration[5.2]
def change
add_column :outputs, :sec_key, :string
end
end

@ -0,0 +1,8 @@
class CreateUserInterests < ActiveRecord::Migration[5.2]
def change
create_table :user_interests do |t|
t.references :user
t.references :repertoire
end
end
end
Loading…
Cancel
Save