dev_shixuns
cxt 6 years ago
commit 0b7593c4ec

@ -436,7 +436,15 @@ class AccountController < ApplicationController
# 注册完/绑定邮箱 后完善资料
def user_info
@user = User.current
#是否是Oschina过来的
@is_ecoder_user = @user.ecoder_user_id.to_i>0
#是否没设置过密码
@is_set_password = @user.hashed_password.present?
if request.get?
# 如果是登录的请求进来,则需要判断登录名是否合法
if (@user.login =~ /(^(?=.*?[a-zA-Z]).*$)/).nil? || !(@user.login =~ /[@#\$%\^&\*\.]+/).nil?
@login_error = true
@ -454,6 +462,22 @@ class AccountController < ApplicationController
apply_user.update_all(:status => 2) unless apply_user.blank?
end
if @is_ecoder_user && !@is_set_password
@user.password = params[:new_password]
@user.password_confirmation = params[:new_password_confirmation]
if @user.password.size<8
@password_len_error = true
render :user_info and return
end
if @user.password != @user.password_confirmation
@password_match_error = true
render :user_info and return
end
end
@user.lastname = params[:lastname]
@user.firstname = ""
@user.show_realname = params[:hide_realname] ? 0 : 1
@ -525,6 +549,7 @@ class AccountController < ApplicationController
return
else
@user.login = lg
logger.info "save user: #{@user.errors}"
end
end
end

@ -38,8 +38,6 @@ class EcloudController < ApplicationController
ROOT_URl = 'http://localhost:3000'
SERVER_URL = "https://221.176.54.92:9081/restful/services/"
## 签名
def sign(timestamp)
Digest::MD5.hexdigest("client_id=#{CLIENT_ID}client_key=#{CLIENT_SECRET}timestamp=#{timestamp}").upcase
@ -50,61 +48,87 @@ class EcloudController < ApplicationController
# applyno 申请单号,唯一
# ecordercode 唯一标志一个企业的订购关系
# params['opttype']操作类型。0开通1变更2试用转商用4再次开通
# 业务列表opttype: 0新增1注销2修改
# serviceparas: 但是由于企业版是按成员收费的所以serviceparas里面会传成员数个人版是包月计费的serviceparas不会传成员数
def bs_new
ActiveRecord::Base.transaction do
begin
ecloud_id = 0
if params['opttype'] == 0 # 开通企业/个人业务
ecloud = Ecloud.create!(eloud_params)
ecloud_id = ecloud.try(:id)
create_service(params['services'], ecloud.try(:id))
create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present?
# 为管理员添加一条记录
# 开通的时候都是用户的opttype也是0
EcloudUser.create!(custid: params['custid'], opttype: params['opttype'], userid: params['userid'],
username: params['username'], useralias: params['useralias'],
mobile: params['mobile'], email: params['email'], begintime: params['begintime'],
endtime: params['endtime'])
elsif params['opttype'] == 2 # 试用转商用 # 变更企业/个人业务
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode']).first
ecloud.update_attributes!(eloud_params)
ecloud.ecloud_productparas.destroy
ecloud.ecloud_services.destroy
ecloud_id = ecloud.try(:id)
elsif params['opttype'] == 1 # 业务变更
ecloud = Ecloud.where(bossorderid: params['bossorderid']).first
ecloud.update_attributes!(eloud_params)
ecloud.ecloud_productparas.destroy
ecloud.ecloud_services.destroy
ecloud_id = ecloud.try(:id)
# 业务列表:注销业务(注销试用的套餐),另一个业务项的操作代码是:新增业务(开通商用的套餐)
# 需要通过产品服务编号和业务编码来区分哪个产品
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode'], trial: true).first
# 注销试用的套餐
## 需要注销的套餐; 试用转商用是不会有批量操作的所以可以使用first
des_service = params['services'].select{|s| s['opttype'] == 1}.first
esd = EcloudService.where(ecloud_id: ecloud.try(:id), code: des_service['code'], productcode: params['productcode']).first
ecloud.update_attribute(:trial, params['trial'])
esd.update_attributes!(opttype: des_service['opttype'], begintime: des_service['begintime'], endtime: des_service['endtime'])
# 试用转商用是不会有批量操作的
# 新增业务
add_service = params['services'].select{|s| s['opttype'] == 0}
create_service(add_service, ecloud.try(:id))
#
elsif params['opttype'] == 4 # 再次重复开通
REDO
ecloud = Ecloud.where(bossorderid: params['bossorderid']).first
end
# 业务列表
services = params['services']
if services.present?
services.each do |service|
es = EcloudService.create(opttype: service['opttype'], code: service['code'], begintime: service['begintime'],
endtime: service['endtime'], ecloud_id: ecloud_id)
if service['serviceparas'].present?
service['serviceparas'].each do |servicepara|
EcloudServieceServicepara.create!(ecloud_service_id: es.id, key: servicepara['key'], value: servicepara['value'])
end
elsif params['opttype'] == 1 # 业务变更
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first
# 套餐变更
# 新增业务
add_service = params['services'].select{|s| s['opttype'] == 0}
create_service(add_service, ecloud.try(:id)) if add_service.present?
# 如果有注销业务,注销业务
des_services = params['services'].select{|s| s['opttype'] == 1}
if des_services.present?
des_services.each do |ds|
esd = EcloudService.where(ecloud_id: ecloud.try(:id), code: ds['code']).first
esd.update_attributes!(opttype: ds['opttype'], begintime: ds['begintime'], endtime: ds['endtime'])
end
end
end
# 应用开通参数
productparas = params['productparas']
if productparas.present?
productparas.each do |productpara|
EcloudProductpara.create!(key: productpara['key'], value: productpara['value'], ecloud_id: ecloud_id)
# 变更业务
edt_services = params['services'].select{|s| s['opttype'] == 2}
if edt_services.present?
edt_services.each do |es|
ese = EcloudService.where(ecloud_id: ecloud.try(:id), code: es['code']).first
ese.update_attributes!(opttype: es['opttype'], begintime: es['begintime'], endtime: es['endtime'])
create_serviceparas es['serviceparas'].first, ese.id
end
end
end
# 非试用情况下,为管理员单独创建一条账号,企业账号
unless params['trial']
EcloudUser.create!(ecloud_id: ecloud.try(:id), opttype: params['opttype'], userid: params['userid'],
username: params['username'], useralias: params['useralias'],
mobile: params['mobile'], email: params['email'])
# ecloud = Ecloud.where(bossorderid: params['bossorderid']).first
# ecloud.update_attributes!(eloud_params)
# ecloud.ecloud_productparas.destroy
# ecloud.ecloud_services.destroy
#
# ecloud_id = ecloud.try(:id)
elsif params['opttype'] == 4 # 再次重复开通
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first
create_service(params['services'], ecloud.try(:id))
create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present?
end
#
# # 非试用情况下,为管理员单独创建一条账号,企业账号
# unless params['trial']
# EcloudUser.create!(ecloud_id: ecloud.try(:id), opttype: params['opttype'], userid: params['userid'],
# username: params['username'], useralias: params['useralias'],
# mobile: params['mobile'], email: params['email'])
# end
render :json => {result: true, errmsg: ""}
rescue Exception => e
logger.error(e.message)
@ -115,17 +139,31 @@ class EcloudController < ApplicationController
end
# 企业/个人业务变更、注销
# 处理业务平台退订、暂停(欠费暂停,信控暂停等)、暂停后恢复应用业务
# 这个接口是不会新增业务的
# 试用退订的时候bossorderid传空字符
def bs_update
ActiveRecord::Base.transaction do
begin
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode']).first
ecloud.update_attributes!(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'],
custid: params['custid'], custcode: params['custcode'], productcode: params['productcode'],
operatime: params['operatime'], effecttime: params['effecttime'])
services = params['services'].first
ecloud.ecloud_service.update_attributes!(packagecode: services['packagecode'], bossorderid: services['bossorderid'])
case params['opttype']
when 0 # 退订
opttype = 6
when 1 # 暂停
opttype = 7
when 2 # 恢复
opttype = 8
end
if params['bossorderid'].present?
ecloud = Ecloud.where(bossorderid: params['bossorderid']).first
ecloud.update_attribute(:opttype, opttype)
else
# 试用退订
params['services'].each do |service|
ecloud_id = EcloudService.where(code: service['packagecode']).first.try(:ecloud_id)
Ecloud.find(ecloud_id).update_attribute(:opttype, opttype)
end
end
render :json => {result: true, errmsg: ""}
rescue Exception => e
logger.error(e.message)
render :json => {code: 500, msg: "#{e.message}"}
@ -136,37 +174,55 @@ class EcloudController < ApplicationController
# 用户业务开通与变更接口
# 授权statu为1取消授权status为0
# user['opttype']: 操作类型0开通1变更3: 取消授权4暂停5恢复
def ps_new
begin
user_params = params['users']
user_params.each do |user_param|
EcloudUser.create!(custid: params['custid'], opttype: user_param['opttype'], userid: user_param['userid'],
username: user_param['username'], useralias: user_param['useralias'],
mobile: user_param['mobile'], email: user_param['email'], begintime: user_param['begintime'].to_s,
endtime: user_param['endtime'].to_s, status: 1)
ActiveRecord::Base.transaction do
begin
user_params = params['users']
user_params.each do |user_param|
if user_param['opttype'] == 0 # 开通
EcloudUser.create!(custid: params['custid'], opttype: user_param['opttype'], userid: user_param['userid'],
username: user_param['username'], useralias: user_param['useralias'],
mobile: user_param['mobile'], email: user_param['email'], begintime: user_param['begintime'].to_s,
endtime: user_param['endtime'].to_s)
elsif user_param['opttype'] == 1 # 变更
ecloud_user = EcloudUser.where(custid: params['custid'], userid: user_param['userid']).first
ecloud_user.update_attributes!(opttype: user_param['opttype'], username: user_param['username'],
useralias: user_param['useralias'], mobile: user_param['mobile'], email: user_param['email'],
begintime: user_param['begintime'].to_s, endtime: user_param['endtime'].to_s)
end
end
render :json => {success: true, errmsg: ""}
# end
rescue Exception => e
logger.error(e.message)
render :json => {code: 500, msg: "#{e.message}"}
raise ActiveRecord::Rollback
end
render :json => {success: true, errmsg: ""}
# end
rescue Exception => e
logger.error(e.message)
render :json => {code: 500, msg: "#{e.message}"}
end
end
# 用户业务状态变更
# 授权statu为1取消授权status为0
# user['opttype']: 操作类型0开通1变更3: 取消授权4暂停5恢复
def ps_update
begin
user_params = params['users']
user_params.each do |user_param|
ecloud_user = EcloudUser.where(userid: user_param['userid'], status: 1).first
ecloud_user.update_attributes(opttype: user_param['opttype'], userid: user_param['userid'], status: 0)
case user_param['opttype']
when 0 # 取消授权
opttype = 3
when 1 # 暂停
opttype = 4
when 2 # 恢复
opttype = 5
end
ecloud_user = EcloudUser.where(custid: params['custid'], userid: user_param['userid']).first
ecloud_user.update_attributes!(opttype: opttype, operatime: params['operatime'], effecttime: params['effecttime'])
end
render :json => {success: true, errmsg: ""}
# else
# render :json => {code: 404, msg: "企业ID不存在"}
# end
rescue Exception => e
logger.error(e.message)
render :json => {code: 500, msg: "#{e.message}"}
@ -174,39 +230,53 @@ class EcloudController < ApplicationController
end
def ecloud_login_callback
#获取code
logger.info "oauth2 login_callback: #{params}"
raise "没有code" unless params[:code]
unless params["test"] == 'true'
#获取code
logger.info "oauth2 login_callback: #{params}"
raise "没有code" unless params[:code]
url = "#{SERVER_URL}/oauth2/authorization?grant_type=authorization_code" +
"&client_id=#{CLIENT_ID}&scope=&redirect_uri=&code=#{params[:code]}"
url = "#{SERVER_URL}/oauth2/authorization?grant_type=authorization_code" +
"&client_id=#{CLIENT_ID}&scope=&redirect_uri=&code=#{params[:code]}"
res = post(url)
logger.info "oauth2 authorization resp: #{res}"
res = post(url)
logger.info "oauth2 authorization resp: #{res}"
# {"access_token":"ae673b2d-88b4-46cc-aa74-0b031f24b76f","expires":6,"refresh_token":"7380cc67-a59c-4c21-9000-70e12a58d175","username":"15111030087@QW_er","uid":2147}
body = decode(res)
#{"access_token":"21a80f20ff736b54aecd002b60210943","token_type":"bearer","expires_in":86400,"refresh_token":"be92e2c137a8c6dd22f0d8c4a622b3aeceb054087a95d293130f04ec60fd3e3f","scope":"user_info","created_at":1542684088}
body = decode(res)
raise '登录失败' unless body["access_token"]
raise '登录失败' unless body["access_token"]
#获取此用户信息
#获取此用户信息
res = get("#{SERVER_URL}/user/info?access_token=#{body['access_token']}&userid=#{body['uid']}")
logger.info "oauth2 get user info: #{res}"
# {"userid":2147,"custid":2104,"custcode":"E0002018042810010054","custtype":2,"status":2,"username":"15111030087@QW_er","useralias":"15111030087","isadmin":true,"entprise":"04**004","departments":"","departmentnames":"","mobile":"15365386520","email":"15111030087@139.com"}
else
res = '{"userid":2147,"custid":2104,"custcode":"E0002018042810010054","custtype":2,"status":2,"username":"15111030087@QW_er","useralias":"15111030087","isadmin":true,"entprise":"04**004","departments":"","departmentnames":"","mobile":"15365386520","email":"15111030087@139.com"}'
end
# res = get("https://gitee.com/api/v5/user?access_token=#{body["access_token"]}")
res = get("#{SERVER_URL}/user/info?access_token=#{body['access_token']}&userid=#{body['uid']}")
logger.info "oauth2 get user info: #{res}"
# 同步用户
# info = decode(res)
#
# user = User.find_by_oschina_user_id(info["id"])
# unless user
# user = User.create_with_oschina!(info)
# end
#
# @current_user = user
render :index
info = decode(res)
user = User.find_by_ecoder_user_id(info["userid"])
unless user
#新建用户
user = User.create_with_ecoder!(info)
end
self.logged_user = user
user = UserExtensions.where(:user_id => User.current.id).first
if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil?
redirect_to my_account_path
elsif user.identity == 3 && user.school_id.nil?
redirect_to my_account_path
else
redirect_to User.current
end
end
@ -257,6 +327,28 @@ class EcloudController < ApplicationController
endtime: params['endtime']}
end
# 新增套餐
def create_service services, ecloud_id
services.each do |service|
ese = EcloudService.create!(opttype: service['opttype'], code: service['code'], begintime: service['begintime'],
endtime: service['endtime'], ecloud_id: ecloud_id)
if service['serviceparas'].present?
create_serviceparas(service['serviceparas'].first, ese.id)
end
end
end
def create_serviceparas params_serviceparas, ese_id
if params_serviceparas.present?
EcloudServieceServicepara.create(key: params_serviceparas['key'], value: params_serviceparas['value'], ecloud_service_id: ese_id)
end
end
def create_product_params params, ecloud_id
params.each do |p|
EcloudProductpara.create(key: p['key'], value: p['value'], ecloud_id: ecloud_id)
end
end
def check_sign
sign = sign(params['timestamp'])
@ -267,7 +359,8 @@ class EcloudController < ApplicationController
end
def save_para
EcloudLog.create(url: request.url, para_value: params, applyno: params['applyno'], custid: params['custid'], custcode: params['custcode'])
EcloudLog.create(url: request.url, para_value: params, applyno: params['applyno'], custid: params['custid'],
custcode: params['custcode'], userid: params['userid'], username: params['username'])
end
end

@ -141,6 +141,10 @@ class MyController < ApplicationController
# Edit user's account
def account
@user = params[:user_id].nil? ? User.current : User.find(params[:user_id])
ue = @user.user_extensions
if @user.lastname.blank? || ue.try(:identity).nil? || (ue.try(:identity) == 1 && ue.try(:student_id).blank?) || (ue.try(:identity) != 1 && ue.try(:technical_title).blank?) || ue.try(:gender).blank? || ue.try(:school_id).blank?
redirect_to user_info_path
@ -152,7 +156,8 @@ class MyController < ApplicationController
applied_message = AppliedMessage.where(:id => params[:applied_message_id]).first
applied_message.update_attribute(:viewed, true)
end
# @user = User.current
# 认证
@trail_authentication = ApplyAction.where(:user_id => User.current.id, :container_type => "TrialAuthorization").order("created_at desc").first
if @trail_authentication && (@trail_authentication.status == 1 || @trail_authentication.status == 2) && !@trail_authentication.noticed

@ -2592,6 +2592,7 @@ class UsersController < ApplicationController
def user_info
end
# 连续签到六天则每天累加10个金币

@ -1,3 +1,3 @@
class EcloudLog < ActiveRecord::Base
attr_accessible :para_value, :url, :applyno, :custid, :custcode
end

@ -1,3 +1,3 @@
class EcloudUser < ActiveRecord::Base
attr_accessible :begintime, :email, :endtime, :mobile, :opttype, :paras, :useralias, :userid, :username, :custid, :status, :ecloud_id
has_many :ecloud_user_paras
end

@ -0,0 +1,3 @@
class EcloudUserPara < ActiveRecord::Base
belongs_to :ecloud_user
end

@ -1692,6 +1692,36 @@ class User < Principal
end
end
def self.create_with_ecoder!(info)
user = User.new
user.admin = false
user.login = "ecoder_" + info["mobile"]
user.phone = info["mobile"]
unless User.find_by_mail(info["email"])
user.mail = info["email"]
end
user.nickname = info["username"]
user.activate
user.last_login_on = Time.now
user.ecoder_user_id = info["userid"]
user.save!(:validate => false)
UserStatus.create!(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
ue = user.user_extensions ||= UserExtensions.new
ue.user_id = user.id
ue.save!
user
end
end
class AnonymousUser < User

@ -88,15 +88,28 @@ class GamesService
# tpm_script_modified = (shixun.reset_time > myshixun.reset_time ? true : false) # 新结构脚本是实时传送的,所以不会影响
# 区分评测过未评测过,未评测过按需求取数据
if max_query_index > 0
qurey_test_sets = TestSet.find_by_sql("SELECT o.actual_output, o.out_put, o.result, o.test_set_position, o.query_index,t.is_public,t.input, t.output, g.id as game_id, c.id as challenge_id FROM outputs o,games g ,challenges c,test_sets t where
g.id=#{game.id} and o.query_index=#{max_query_index} and g.id = o.game_id and c.id= g.challenge_id and t.challenge_id = c.id and t.position =o.test_set_position order by o.query_index
")
else
qurey_test_sets = TestSet.find_by_sql("SELECT t.is_public,t.input, t.output,t.position FROM games g ,challenges c,test_sets t where
g.id=#{game.id} and c.id= g.challenge_id and t.challenge_id = c.id
")
end
sql =
if max_query_index > 0
"SELECT
b.actual_output, b.out_put, b.result, a.is_public, a.input, a.output
FROM
(SELECT position, input, output, challenge_id, is_public FROM test_sets where challenge_id=6000) a
LEFT JOIN
(SELECT
result, test_set_position, g.challenge_id, o.actual_output, o.out_put
FROM
outputs o left join games g on g.id=o.game_id
WHERE
game_id=#{game.id} and query_index = #{max_query_index}
) b
ON
b.challenge_id = a.challenge_id and b.test_set_position = a.position"
else
"SELECT t.is_public, t.input, t.output, t.position
FROM games g ,challenges c,test_sets t
WHERE g.id=#{game.id} and c.id= g.challenge_id and t.challenge_id = c.id"
end
qurey_test_sets = TestSet.find_by_sql(sql)
# 测试集统计及处理
unless qurey_test_sets.blank?

@ -39,6 +39,20 @@
</li>
<% end %>
<% if @is_ecoder_user && !@is_set_password %>
<li class="clearfix">
<label class="second-label fl"><span class="color-orange">* </span>密码:</label>
<input name="new_password" type="password" class="winput-240-40 fl" placeholder="请输入密码">
<p class="notice color-orange fl"><span id="new_password_hint" class="none"><i class="fa fa-exclamation-circle mt7 mr5 fl"></i>密码最小长度为8位</span></p>
</li>
<li class="clearfix">
<label class="second-label fl"><span class="color-orange">* </span>重复密码:</label>
<input name="new_password_confirmation" type="password" class="winput-240-40 fl" placeholder="请输入密码">
<p class="notice color-orange fl"><span id="new_password_confirmation_hint" class="none"><i class="fa fa-exclamation-circle mt7 mr5 fl"></i>两次密码不匹配</span></p>
</li>
<% end %>
<li class="<%= @user.show_realname ? 'none' : '' %> clearfix" id="nickname_li">
<label class="second-label fl"><span class="color-orange">* </span>昵称:</label>
<input type="text" id="nickname" name="nickname" maxlength="20" value="<%= @user.nickname %>" class="winput-240-40 fl" placeholder="填写昵称">

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/react/build/css/css_min_all.css"><link rel="stylesheet" href="/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.c95e49c6.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/react/build/js/js_min_all.js"></script><script type="text/javascript" src="/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/react/build/js/create_kindeditor.js"></script><script type="text/javascript" src="/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.ea3ca4b2.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/react/build/css/css_min_all.css"><link rel="stylesheet" href="/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.c95e49c6.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/react/build/js/js_min_all.js"></script><script type="text/javascript" src="/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/react/build/js/create_kindeditor.js"></script><script type="text/javascript" src="/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.8971eeae.js"></script></body></html>

@ -101,7 +101,7 @@
<% when "subjects" %>
$("#header-nav").children("li").eq(2).addClass("active");
<% when "courses" %>
$header.length == 7 ? $header.eq(4).addClass("active") : $header.eq(3).addClass("active");
$header.length == 7 ? $header.eq(2).addClass("active") : $header.eq(3).addClass("active");
<% when "competitions" %>
$header.length == 7 ? $header.eq(5).addClass("active") : $header.eq(4).addClass("active");
<% when "forums" %>

@ -0,0 +1,6 @@
class AddEcoderUserIdToUsers < ActiveRecord::Migration
def change
add_column :users, :ecoder_user_id, :integer, default: 0
add_index :users, :ecoder_user_id
end
end

@ -0,0 +1,5 @@
class AddProductcodeToUcloudService < ActiveRecord::Migration
def change
add_column :ecloud_services, :productcode, :string
end
end

@ -1,30 +0,0 @@
class MigrationShixunStudentWork < ActiveRecord::Migration
def up
works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and (work_score is null or work_score = 0)")
works.update_all(:myshixun_id => 0, :work_status => 0, :work_score => nil, :final_score => nil,
:cost_time => 0, :update_time => nil, :compelete_status => 0, :commit_time => nil)
shixun_works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and work_score > 0")
shixun_works.each do |work|
if work.homework_common && work.homework_common.homework_commons_shixuns.try(:shixun)
shixun = work.homework_common.homework_commons_shixuns.try(:shixun)
# 创建新的myshixun和games
myshixun = nil
work_score = work.final_score
work.homework_common.homework_challenge_settings.each do |setting|
if work_score > 1
myshixun.games.where(:challenge_id => setting.challenge_id).first.update_attributes(:status => 2)
work_score -= setting.score
end
end
work.update_column("myshixun_id", myshixun.id)
end
end
end
def down
end
end

@ -0,0 +1,6 @@
class AddUseridToEcloudLog < ActiveRecord::Migration
def change
add_column :ecloud_logs, :userid, :integer
add_column :ecloud_logs, :username, :string
end
end

@ -0,0 +1,11 @@
class CreateEcloudUserParas < ActiveRecord::Migration
def change
create_table :ecloud_user_paras do |t|
t.string :key
t.string :value
t.integer :ecloud_user_id
t.timestamps
end
end
end

@ -0,0 +1,6 @@
class AddOperatimeToEcloudUsers < ActiveRecord::Migration
def change
add_column :ecloud_users, :operatime, :bigint
add_column :ecloud_users, :effecttime, :bigint
end
end

@ -0,0 +1,75 @@
class CreateShixunStudentWorks < ActiveRecord::Migration
def up
ActiveRecord::Base.transaction do
begin
works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and (work_score is null or work_score = 0)")
works.update_all(:myshixun_id => 0, :work_status => 0, :work_score => nil, :final_score => nil,
:cost_time => 0, :update_time => nil, :compelete_status => 0, :commit_time => nil)
shixun_works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and work_score > 0")
shixun_works.each do |work|
shixun = work.homework_common.try(:homework_commons_shixuns).try(:shixun)
user = work.user
if shixun.present? && user.present?
# 创建新的myshixun和games
# fork版本库如果用户没有同步则先同步用户
g = Gitlab.client
if user.gid.nil?
s = Trustie::Gitlab::Sync.new
s.sync_user(user)
end
gshixun = g.fork(shixun.gpid, user.gid)
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
code = down_generate_identifier("myshixun")
# 一般通过默认分支是否存在来判断一个项目是否fork成功
if gshixun.try(:id).present?
commit_id = g.commits(shixun.gpid).first.try(:id)
# educoder 加入到myshixun中
myshixun_admin_gid = User.where(:login => "educoder").first.try(:gid)
g.add_team_member(gshixun.id, myshixun_admin_gid, 40) # 40代表角色master
myshixun = Myshixun.create!(:shixun_id => shixun.id, :user_id => user.id, :identifier => code,
:modify_time => shixun.modify_time, :reset_time => shixun.reset_time,
:onclick_time => Time.now, :gpid => gshixun.id,
:git_url => gshixun.try(:path_with_namespace), :commit_id => commit_id)
rep_url = Base64.urlsafe_encode64(gitlab_url shixun) # 注意educoder为默认给实训创建版本库的用户如果换成别的用户名字要相应的修改
uri = "#{shixun_tomcat}/bridge/game/openGameInstance"
params = {tpiID: "#{myshixun.id}", tpmGitURL:rep_url, tpiRepoName: gshixun.try(:name)}
logger.info("openGameInstance params is #{params}")
res = uri_exec uri, params
if (res && res['code'].to_i != 0)
raise("实训云平台繁忙繁忙等级83")
end
# 其它创建关卡等操作
challenges = shixun.challenges
# 之所以增加user_id是为了方便统计查询性能
challenges.each_with_index do |challenge, index|
status = (index == 0 ? 0 : 3)
code = down_generate_identifier("game")
Game.create!(:challenge_id => challenge.id, :myshixun_id => myshixun.id, :status => status, :user_id => myshixun.user_id,
:open_time => Time.now, :identifier => code, :modify_time => challenge.modify_time)
end
work_score = work.final_score
work.homework_common.homework_challenge_settings.each do |setting|
if work_score > 1
games = myshixun.games.where(:challenge_id => setting.challenge_id).first
games.update_attributes(:status => 2, :end_time => Time.now, :final_score => setting.challenge.score)
work_score -= setting.score
end
end
work.update_column("myshixun_id", myshixun.id)
end
end
end
rescue Exception => e
puts ("###failed to exec shixun: current task id is #{e}")
g.delete_project(gshixun.id) if gshixun.try(:id).present?
raise ActiveRecord::Rollback
end
end
end
def down
end
end

@ -152,7 +152,7 @@ function changeDepValue(value, data) {
// 基本资料页面提交表单时,判断身份与单位是否合法
function my_account_form_submit() {
if ($("#nickname").val().trim() == '') {
if ($("#nickname").val().trim() === "") {
$("#nickname").focus();
$("#nickname_hint").show();
e.stopImmediatePropagation();
@ -161,6 +161,8 @@ function my_account_form_submit() {
$("#nickname_hint").hide();
}
//姓名不能为空
if ($("#lastname").val().trim() == '') {
$("#lastname").focus();

File diff suppressed because it is too large Load Diff

@ -67,8 +67,8 @@
"./static/js/9.e77edf45.chunk.js.map": "./static/js/9.e77edf45.chunk.js.map",
"main.css": "./static/css/main.c95e49c6.css",
"main.css.map": "./static/css/main.c95e49c6.css.map",
"main.js": "./static/js/main.ea3ca4b2.js",
"main.js.map": "./static/js/main.ea3ca4b2.js.map",
"main.js": "./static/js/main.8971eeae.js",
"main.js.map": "./static/js/main.8971eeae.js.map",
"static/media/ERASBD.ttf": "static/media/ERASBD.d5213044.ttf",
"static/media/background1.png": "static/media/background1.a34df396.png",
"static/media/background2.png": "static/media/background2.22ee659e.png",

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/css/css_min_all.css"><link rel="stylesheet" href="http://testbdweb.educoder.net/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.c95e49c6.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/js/js_min_all.js"></script><script type="text/javascript" src="http://testbdweb.educoder.net/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/js/create_kindeditor.js"></script><script type="text/javascript" src="http://testbdweb.educoder.net/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.ea3ca4b2.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/css/css_min_all.css"><link rel="stylesheet" href="http://testbdweb.educoder.net/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.c95e49c6.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/js/js_min_all.js"></script><script type="text/javascript" src="http://testbdweb.educoder.net/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/js/create_kindeditor.js"></script><script type="text/javascript" src="http://testbdweb.educoder.net/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.8971eeae.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -197,6 +197,7 @@ class Index extends Component {
time_limit={context.time_limit}
resetTestSetsExpandedArray={context.resetTestSetsExpandedArray}
onRunCodeTestFinish={context.onRunCodeTestFinish}
onRunChooseTestFinish={context.onRunChooseTestFinish}
testSetUnlock={context.testSetUnlock}

@ -613,13 +613,13 @@ class MainContentContainer extends Component {
}
// 之前的task_commit方法
gameBuild(fileUpdateResponse, first) {
const { st, challenge, output_sets, onRunCodeTestFinish, showSnackbar, time_limit } = this.props
const { st, challenge, output_sets, onRunCodeTestFinish, resetTestSetsExpandedArray, showSnackbar, time_limit } = this.props
const { resubmit, content_modified } = fileUpdateResponse.data;
const timeOut = time_limit;
// http://localhost:3000/myshixuns/so5w6iap97/stages/zl6kx8f7vfpo/game_build?first=1&resubmit=GDBEX741_1993
const game_build_url = `${locationPath}/game_build?first=${first}&resubmit=${resubmit}&content_modified=${content_modified}`
// var timeOut = parseInt(<%= @myshixun.main_mirror.try(:time_limit) %>); // 超时参数
resetTestSetsExpandedArray()
axios.get(game_build_url, {
withCredentials: true,
}).then((gameBuildResponse) => {

@ -249,15 +249,18 @@ class NewHeader extends Component {
activeShixuns = true;
} else if(match.path.startsWith('/careers')){
activeCareers = true;
}else if(match.path === '/ec_major_schools/:major_school_id/academic_years/:ec_year_id/requirement_vs_courses'){
activeCourses=true;
}else if(match.path === '/ec_courses/:ec_course_id/ec_course_reach_setting'){
activeCourses=true;
}else if(match.path === '/ec_courses/:ec_course_id/competition_calculation_info'){
activeCourses=true;
} else if(match.path.startsWith('/ec_courses')){
activeCourses=true;
}else if(match.path.startsWith('/ec_major_schools')){
activeCourses=true;
}else{
activeIndex = true;
}
console.log(match.path)
console.log(match.path.startsWith("/ec_courses"))
return (
<div className="newHeader" id="nHeader">
<div className="educontent clearfix">
@ -293,7 +296,7 @@ class NewHeader extends Component {
</li>
<li><a href="/competitions">竞赛</a></li>
<li className={`${activeForums === true ? 'active' : ''}`}><a href="/forums">问答</a></li>
<li className={`${activeCourses === true ? 'active' : ''}`} style={{display:ecUrl===null?'none':'block'}}><a href={ecUrl}>{ecUrl===null?'':'认证'}</a></li>
<li className={`${activeCourses === true ? 'active' : ''}`} style={{display:ecUrl===null||ecUrl===undefined||ecUrl===""?'none':'block'}}><a href={ecUrl}>{ecUrl===null||ecUrl===undefined||ecUrl===""?'':'认证'}</a></li>
</ul>
<div className="posi-search" id="posi-search" style={{display: 'none'}}>
<div className="search-all clearfix">

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :ecloud_user_para do
key "MyString"
value "MyString"
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe EcloudUserPara, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save