Merge branch 'educoder' into dev_shixuns

dev_shixuns
daiao 6 years ago
commit 7b906e2348

@ -68,7 +68,8 @@ class ApplicationController < ActionController::Base
def ecloud_auth ucloud_user_id def ecloud_auth ucloud_user_id
euser = EcloudUser.where("id =? and opttype not in(3, 5)", ucloud_user_id).first euser = EcloudUser.where("id =? and opttype not in(3, 5)", ucloud_user_id).first
if euser.present? # 开通过业务 if euser.present? # 开通过业务
# # ni
else else
false false
end end

@ -33,10 +33,18 @@ class EcloudController < ApplicationController
def trustie_login def trustie_login
end end
CLIENT_ID = '1022' # 测试环境
CLIENT_SECRET = '2112037a-6d7a-432b-9081-feb1153d8668' # CLIENT_ID = '1022'
ROOT_URl = 'http://localhost:3000' # CLIENT_SECRET = '2112037a-6d7a-432b-9081-feb1153d8668'
SERVER_URL = "https://221.176.54.92:9081/restful/services/" # SERVER_URL = "https://221.176.54.92:9081/restful/services/"
#
# 正式环境
CLIENT_ID = '1056'
CLIENT_SECRET = '2e84256a-3de4-4713-9e02-10ee88a14592'
SERVER_URL = "https://221.176.53.130:44390/services/"
## 签名 ## 签名
def sign(timestamp) def sign(timestamp)
@ -55,12 +63,12 @@ class EcloudController < ApplicationController
begin begin
if params['opttype'] == 0 # 开通企业/个人业务 if params['opttype'] == 0 # 开通企业/个人业务
ecloud = Ecloud.create!(eloud_params) ecloud = Ecloud.create!(eloud_params)
create_service(params['services'], ecloud.try(:id)) create_service(params['services'], ecloud.try(:id)) if params['services'].present?
create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present? create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present?
# 为管理员添加一条记录 # 为管理员添加一条记录
# 开通的时候都是用户的opttype也是0 # 开通的时候都是用户的opttype也是0
# 如果管理员已经存在,则不用重复开通 # 如果管理员已经存在,则不用重复开通
euser = EcloudUser.where(id: params['userid'], custid: params['custid']).first euser = EcloudUser.where(userid: params['userid'], custid: params['custid']).first
unless euser unless euser
EcloudUser.create!(custid: params['custid'], opttype: params['opttype'], userid: params['userid'], EcloudUser.create!(custid: params['custid'], opttype: params['opttype'], userid: params['userid'],
username: params['username'], useralias: params['useralias'], username: params['username'], useralias: params['useralias'],
@ -88,7 +96,8 @@ class EcloudController < ApplicationController
elsif params['opttype'] == 1 # 业务变更 elsif params['opttype'] == 1 # 业务变更
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first
# 套餐变更 # 套餐变更
# 新增业务 # 操作代码 0新增业务1注销业务2修改业务
# # 新增服务
add_service = params['services'].select{|s| s['opttype'] == 0} add_service = params['services'].select{|s| s['opttype'] == 0}
create_service(add_service, ecloud.try(:id)) if add_service.present? create_service(add_service, ecloud.try(:id)) if add_service.present?
@ -106,8 +115,8 @@ class EcloudController < ApplicationController
if edt_services.present? if edt_services.present?
edt_services.each do |es| edt_services.each do |es|
ese = EcloudService.where(ecloud_id: ecloud.try(:id), code: es['code']).first ese = EcloudService.where(ecloud_id: ecloud.try(:id), code: es['code']).first
ese.update_attributes!(opttype: es['opttype'], begintime: es['begintime'], endtime: es['endtime']) ese.update_attributes!(opttype: es['opttype'], begintime: es['begintime'], endtime: es['endtime']) if ese.present?
create_serviceparas es['serviceparas'].first, ese.id create_serviceparas(es['serviceparas'].first, ese.id) if ese.present?
end end
end end
@ -120,6 +129,7 @@ class EcloudController < ApplicationController
# ecloud_id = ecloud.try(:id) # ecloud_id = ecloud.try(:id)
elsif params['opttype'] == 4 # 再次重复开通 elsif params['opttype'] == 4 # 再次重复开通
# 再次申请开通,这种情况就是累加时间
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first
create_service(params['services'], ecloud.try(:id)) create_service(params['services'], ecloud.try(:id))
create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present? create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present?

@ -508,7 +508,7 @@ class StudentWorkController < ApplicationController
end end
@tab = params[:tab].nil? ? 1 : params[:tab].to_i @tab = params[:tab].nil? ? 1 : params[:tab].to_i
if User.current.member_of_course?(@homework.course) && params[:order].nil? && params[:sort].nil? && params[:name].nil? && params[:group].nil? && params[:page].nil? if (User.current.member_of_course?(@homework.course) || User.current.admin?) && params[:order].nil? && params[:sort].nil? && params[:name].nil? && params[:group].nil? && params[:page].nil?
if !@course.is_end && @homework.homework_type == 4 && @homework.homework_detail_manual.comment_status > 0 && (@homework.end_time > Time.now || (@homework.end_time <= Time.now && @homework.allow_late)) if !@course.is_end && @homework.homework_type == 4 && @homework.homework_detail_manual.comment_status > 0 && (@homework.end_time > Time.now || (@homework.end_time <= Time.now && @homework.allow_late))
update_shixun_work_status @homework update_shixun_work_status @homework
end end

@ -4340,7 +4340,7 @@ module ApplicationHelper
candown = (attachment.is_public == 1 || attachment.is_public == true) candown = (attachment.is_public == 1 || attachment.is_public == true)
end end
else else
if attachment.container_type == "MarkDown" || attachment.container_type == "Shixun" || attachment.container_type == "Memo" || attachment.container_type == "Career" || attachment.container_type == "Exercise" || attachment.container_type == "ExerciseBank" if attachment.container_type == "MarkDown" || attachment.container_type.nil? || attachment.container_type == 'Subject' || attachment.container_type == "Shixun" || attachment.container_type == "Memo" || attachment.container_type == "Career" || attachment.container_type == "Exercise" || attachment.container_type == "ExerciseBank"
candown = true candown = true
end end
end end

@ -1,3 +1,4 @@
# 操作代码 0新增业务1注销业务2修改业务
class EcloudService < ActiveRecord::Base class EcloudService < ActiveRecord::Base
attr_accessible :begintime, :code, :endtime, :opttype, :ecloud_id, :packagecode, :bossorderid attr_accessible :begintime, :code, :endtime, :opttype, :ecloud_id, :packagecode, :bossorderid
belongs_to :ecloud belongs_to :ecloud

@ -78,7 +78,7 @@
placeholder: "请在此输入实训课程的简介", placeholder: "请在此输入实训课程的简介",
imageUpload : true, imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL : "<%= upload_with_markdown_path(:container_id => @subject.id, :container_type => @subject.class) %>" //url imageUploadURL : "<%= upload_with_markdown_path(:container_id => @subject.id, :container_type => 'MarkDown') %>" //url
}); });
md_elocalStorage(shixun_editormd, "subject_desc_<%= User.current.id %>", "desc"); md_elocalStorage(shixun_editormd, "subject_desc_<%= User.current.id %>", "desc");
/* --------------------------------- 学习须知 -------------------------------------- */ /* --------------------------------- 学习须知 -------------------------------------- */
@ -106,7 +106,7 @@
placeholder: "请在此输入实训课程的学习须知", placeholder: "请在此输入实训课程的学习须知",
imageUpload : true, imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL : "<%= upload_with_markdown_path(:container_id => @subject.id, :container_type => @subject.class) %>" //url imageUploadURL : "<%= upload_with_markdown_path(:container_id => @subject.id, :container_type => 'MarkDown') %>" //url
}); });
md_elocalStorage(shixun_propaedeutics, "subject_notes_<%= User.current.id %>", "notes"); md_elocalStorage(shixun_propaedeutics, "subject_notes_<%= User.current.id %>", "notes");

@ -25,49 +25,52 @@ class CreateShixunStudentWorks < ActiveRecord::Migration
begin begin
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
if shixun.present? && user.present? if shixun.present? && user.present?
# 创建新的myshixun和games myshixun = Myshixun.where(:user_id => user.id, :shixun_id => shixun.id).first
# fork版本库如果用户没有同步则先同步用户 if myshixun.blank?
g = Gitlab.client # 创建新的myshixun和games
if user.gid.nil? # fork版本库如果用户没有同步则先同步用户
s = Trustie::Gitlab::Sync.new g = Gitlab.client
s.sync_user(user) if user.gid.nil?
end s = Trustie::Gitlab::Sync.new
gshixun = g.fork(shixun.gpid, user.gid) s.sync_user(user)
shixun_tomcat = Redmine::Configuration['shixun_tomcat'] end
gshixun = g.fork(shixun.gpid, user.gid)
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
code = down_generate_identifier("myshixun") code = down_generate_identifier("myshixun")
# 一般通过默认分支是否存在来判断一个项目是否fork成功 # 一般通过默认分支是否存在来判断一个项目是否fork成功
if gshixun.try(:id).present? if gshixun.try(:id).present?
commit_id = g.commits(shixun.gpid).first.try(:id) commit_id = g.commits(shixun.gpid).first.try(:id)
# educoder 加入到myshixun中 # educoder 加入到myshixun中
myshixun_admin_gid = User.where(:login => "educoder").first.try(:gid) myshixun_admin_gid = User.where(:login => "educoder").first.try(:gid)
g.add_team_member(gshixun.id, myshixun_admin_gid, 40) # 40代表角色master 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, myshixun = Myshixun.create!(:shixun_id => shixun.id, :user_id => user.id, :identifier => code,
:modify_time => shixun.modify_time, :reset_time => shixun.reset_time, :modify_time => shixun.modify_time, :reset_time => shixun.reset_time,
:onclick_time => Time.now, :gpid => gshixun.id, :onclick_time => Time.now, :gpid => gshixun.id,
:git_url => gshixun.try(:path_with_namespace), :commit_id => commit_id) :git_url => gshixun.try(:path_with_namespace), :commit_id => commit_id)
url = "#{Redmine::Configuration['gitlab_address_ip']}/#{g.project(shixun.try(:gpid)).try(:path_with_namespace)}.git" url = "#{Redmine::Configuration['gitlab_address_ip']}/#{g.project(shixun.try(:gpid)).try(:path_with_namespace)}.git"
rep_url = Base64.urlsafe_encode64(url) # 注意educoder为默认给实训创建版本库的用户如果换成别的用户名字要相应的修改 rep_url = Base64.urlsafe_encode64(url) # 注意educoder为默认给实训创建版本库的用户如果换成别的用户名字要相应的修改
uri = "#{shixun_tomcat}/bridge/game/openGameInstance" uri = "#{shixun_tomcat}/bridge/game/openGameInstance"
params = {tpiID: "#{myshixun.id}", tpmGitURL:rep_url, tpiRepoName: gshixun.try(:name)} params = {tpiID: "#{myshixun.id}", tpmGitURL:rep_url, tpiRepoName: gshixun.try(:name)}
logger.info("openGameInstance params is #{params}") logger.info("openGameInstance params is #{params}")
uri = URI.parse(URI.encode(uri.strip)) uri = URI.parse(URI.encode(uri.strip))
res = Net::HTTP.post_form(uri, params).body res = Net::HTTP.post_form(uri, params).body
res = JSON.parse(res) res = JSON.parse(res)
if (res && res['code'].to_i != 0) if (res && res['code'].to_i != 0)
raise("实训云平台繁忙繁忙等级83") raise("实训云平台繁忙繁忙等级83")
end end
# 其它创建关卡等操作 # 其它创建关卡等操作
challenges = shixun.challenges challenges = shixun.challenges
# 之所以增加user_id是为了方便统计查询性能 # 之所以增加user_id是为了方便统计查询性能
challenges.each_with_index do |challenge, index| challenges.each_with_index do |challenge, index|
status = (index == 0 ? 0 : 3) status = (index == 0 ? 0 : 3)
code = down_generate_identifier("game") code = down_generate_identifier("game")
Game.create!(:challenge_id => challenge.id, :myshixun_id => myshixun.id, :status => status, :user_id => myshixun.user_id, 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) :open_time => Time.now, :identifier => code, :modify_time => challenge.modify_time)
end
end end
work_score = work.final_score work_score = work.final_score
work.homework_common.homework_challenge_settings.each do |setting| work.homework_common.homework_challenge_settings.each do |setting|
@ -78,6 +81,8 @@ class CreateShixunStudentWorks < ActiveRecord::Migration
end end
end end
work.update_column("myshixun_id", myshixun.id) work.update_column("myshixun_id", myshixun.id)
else
work.update_attributes(:myshixun_id => 0, :work_status => 0)
end end
end end
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 293 KiB

Loading…
Cancel
Save