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

dev_cs
杨树林 5 years ago
commit 0b31885462

@ -61,29 +61,7 @@ class GamesController < ApplicationController
tomcat_url: edu_setting('cloud_tomcat_php'), is_teacher: is_teacher,
myshixun_manager: myshixun_manager, git_url: (@shixun.vnc ? repo_url(@myshixun.repo_path) : "")}
if @shixun.vnc
begin
shixun_tomcat = edu_setting('cloud_bridge')
service_host = edu_setting('vnc_url')
uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}"}
res = uri_post uri, params
logger.info("###############---- ")
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级99")
end
if request.subdomain == "pre-newweb"
# 无域名版本
@vnc_url = "http://#{service_host}:#{res['port']}/vnc_lite.html?password=headless"
else
# 有域名版本
@vnc_url = "https://#{res['port']}.#{service_host}/vnc_lite.html?password=headless"
end
@vnc_evaluate = @shixun.vnc_evaluate
rescue Exception => e
Rails.logger.error(e.message)
end
get_vnc_link(@game)
end
# 区分选择题和编程题st0编程题
@ -110,6 +88,21 @@ class GamesController < ApplicationController
end
end
def reset_vnc_link
begin
# 删除vnc的pod
delete_vnc(@game)
# 重新连接
get_vnc_link(@game)
render :json => {status: 1, message: "重置VNC成功", data: {vnc_url: @vnc_url, vnc_evaluate: @vnc_evaluate}}
rescue Exception => e
logger.error("############'#{e.message}'")
tip_exception("实训云平台繁忙")
end
end
# 查看效果
# todo : 这块代码有很大的改进空间
# todo : 中文排序问题
@ -941,4 +934,47 @@ class GamesController < ApplicationController
game.myshixun.update_column(:updated_at, Time.now)
end
# vnc连接
def get_vnc_link game
begin
shixun = game.myshixun.shixun
shixun_tomcat = edu_setting('cloud_bridge')
service_host = edu_setting('vnc_url')
uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
params = {tpiID: game.myshixun.id, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
res = uri_post uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级99")
end
@vnc_url =
if request.subdomain == "pre-newweb" || request.subdomain == "test-newweb"
# 无域名版本
"http://#{service_host}:#{res['port']}/vnc_lite.html?password=headless"
else
# 有域名版本
"https://#{res['port']}.#{service_host}/vnc_lite.html?password=headless"
end
@vnc_evaluate = shixun.vnc_evaluate
rescue Exception => e
Rails.logger.error(e.message)
end
end
# 删除pod
def delete_vnc game
myshixun_id = game.myshixun_id
digest = game.identifier + edu_setting('bridge_secret_key')
digest_key = Digest::SHA1.hexdigest("#{digest}")
begin
shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/vnc/delete"
Rails.logger.info("#{current_user} => cloese_vnc digest is #{digest}")
params = {:tpiID => myshixun_id, :digestKey => digest_key, :identifier => game.identifier}
res = uri_post uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级110")
end
end
end
end

@ -113,7 +113,7 @@ class HomeworkCommonsController < ApplicationController
if @user_course_identity == Course::STUDENT
@work = @homework.user_work(current_user.id)
# 学生访问列表时计算个人成绩
if @homework.homework_type == "practice"
if @homework.homework_type == "practice" && !@homework.end_or_late
myshixun = Myshixun.find_by(shixun_id: @shixun.id, user_id: current_user.id)
if @work && myshixun
challenge_settings = @homework.homework_challenge_settings

@ -131,7 +131,7 @@ class ShixunsController < ApplicationController
offset = (page.to_i - 1) * (limit.to_i)
order = params[:order] || "desc"
## 搜索关键字创建者、实训名称、院校名称
keyword = params[:search]
keyword = params[:search].blank? ? "*" : params[:search]
@shixuns = Shixun.search keyword, where: {id: @shixuns.pluck(:id)}, order: {"myshixuns_count" => order}, limit: limit, offset: offset
@total_count = @shixuns.total_count
@ -978,7 +978,7 @@ private
raise("实训名称不能为空") if params[:shixun][:name].blank?
params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission,
:task_pass, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden,
:hide_code, :forbid_copy, :vnc_evaluate)
:hide_code, :forbid_copy, :vnc_evaluate, :code_edit_permission)
end
def shixun_info_params

@ -237,4 +237,9 @@ module HomeworkCommonsHelper
def anon_comments user, work_id
StudentWorksScore.where(student_work_id: work_id, reviewer_role: 3, user_id: user.id)
end
def student_redo_work work, homework
publish_time = homework.homework_group_setting(work.user_id)&.publish_time
work.myshixun && publish_time && work.myshixun.games.where("status = 2 and answer_open = 1 and end_time <= '#{publish_time}'").count > 0
end
end

@ -5,6 +5,7 @@ end
# json.description @subject&.description
json.start_learning @start_learning
json.subject_id @subject.id
json.learned @start_learning ? @course.my_subject_progress : 0

@ -31,7 +31,7 @@ elsif @user_course_identity == Course::STUDENT
json.left_time left_time @homework, @current_user.id
if @homework.homework_type == "practice"
json.(@work, :id, :work_status, :update_time, :ultimate_score)
json.(@work, :id, :work_status, :update_time, :ultimate_score, :myshixun_id)
json.calculation_time @work.calculation_time
json.late_penalty @work.late_penalty if @homework.allow_late
json.cost_time @work.myshixun.try(:total_spend_time)
@ -40,6 +40,7 @@ elsif @user_course_identity == Course::STUDENT
json.efficiency work_score_format(@work.efficiency, true, @score_open)
json.eff_score work_score_format(@work.eff_score, true, @score_open)
json.complete_count @work.myshixun.try(:passed_count)
json.redo_work @homework.end_or_late ? false : student_redo_work(@work, @homework)
else
json.(@work, :id, :work_status, :update_time, :ultimate_score)

@ -30,6 +30,7 @@ json.shixun do
json.scope_partment @shixun.schools.map(&:name) # 公开范围
json.opening_time @shixun.opening_time
json.forbid_copy @shixun.forbid_copy
json.code_edit_permission @shixun.code_edit_permission # tpi学员是否有编辑所有代码的权限
# 私密仓库
json.is_secret_repository @shixun.shixun_secret_repository.present?

@ -161,6 +161,7 @@ Rails.application.routes.draw do
get :picture_display
get :sync_codes
get :close_webssh
get :reset_vnc_link
get :get_answer_info
get :unlock_answer
get :check_test_sets

@ -0,0 +1,6 @@
class AddCodeEditPermissionForShixun < ActiveRecord::Migration[5.2]
def change
add_column :shixuns, :code_edit_permission, :boolean, default: false
end
end

@ -2355,10 +2355,10 @@ export default class TPMsettings extends Component {
return(
<div key={key}>
<div id="5">
<p className="color-grey-6 font-16 mt30 mb20" id="shixun_scenario_type_name">
<div className="color-grey-6 font-16 mt30 mb20" id="shixun_scenario_type_name">
<span className={"fl"}>{item.name}</span>
{/*<span className={"fr mr40"} onClick={()=>this.Deselectlittle(item.mirror_repository_id)}><i className="fa fa-times-circle color-grey-c font-16 fl"></i></span>*/}
</p>
</div>
<div className="clearfix mb5">
<label className="panel-form-label fl">CPU()</label>
<div className="pr fl with80 status_con">

Loading…
Cancel
Save