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

merge code
chromesetting
tangjiang 5 years ago
commit da1ae67a08

@ -3,7 +3,7 @@ class GamesController < ApplicationController
before_action :find_game, except: [:jupyter]
before_action :find_shixun, only: [:show, :answer, :rep_content, :choose_build, :game_build, :game_status]
before_action :allowed
before_action :allowed, except: [:jupyter]
#require 'iconv'
@ -95,6 +95,9 @@ class GamesController < ApplicationController
def jupyter
# Jupyter没有challenge
@myshixun = Myshixun.find_by_identifier params[:identifier]
unless current_user.id == @myshixun.user_id || current_user.admin_or_business?
raise Educoder::TipException.new(403, "..")
end
@shixun = @myshixun.shixun
# 判断tpm是否修改了
begin

@ -1,4 +1,3 @@
require 'net/http'
class JupytersController < ApplicationController
include JupyterService
@ -6,8 +5,8 @@ class JupytersController < ApplicationController
before_action :shixun, only: [:open, :open1, :test, :save]
def save_with_tpi
game = Game.find_by(identifier: params[:identifier])
jupyter_save_with_game(game, params[:jupyter_port])
myshixun = Myshixun.find_by(identifier: params[:identifier])
jupyter_save_with_game(myshixun, params[:jupyter_port])
render json: {status: 0}
end
@ -18,9 +17,9 @@ class JupytersController < ApplicationController
end
def get_info_with_tpi
game = Game.find_by(identifier: params[:identifier])
url = jupyter_url_with_game(game)
port = jupyter_port_with_game(game)
myshixun = Myshixun.find_by(identifier: params[:identifier])
url = jupyter_url_with_game(myshixun)
port = jupyter_port_with_game(myshixun)
render json: {status: 0, url: url, port: port}
end
@ -32,89 +31,4 @@ class JupytersController < ApplicationController
end
private
def open
#打开tpm - juypter接口
shixun = @shixun
shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/jupyter/get"
tpiID = "tpm#{shixun.id}"
params = {tpiID: tpiID, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
logger.info "test_juypter: uri->#{uri}, params->#{params}"
res = uri_post uri, params
logger.info "test_juypter: #{res}"
render plain: "https://#{res['port']}.jupyter.educoder.net/notebooks/data/workspace/myshixun_#{tpiID}/01.ipynb"
end
def open1
## 打开tpi
game = Game.find(2170158)
shixun = game.myshixun.shixun
shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/jupyter/get"
tpiID = game.myshixun.id
params = {tpiID: tpiID, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
res = uri_post uri, params
logger.info "test_juypter: #{res}"
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级99")
end
repo_save_path = game.myshixun.repo_save_path
render plain: "https://#{res['port']}.jupyter.educoder.net/notebooks/data/workspace/myshixun_#{tpiID}/#{repo_save_path}/01.ipynb"
end
def test
render plain: 'test'
end
def save()
# 保存01.ipy
author_name = current_user.real_name
author_email = current_user.git_mail
message = "User submitted"
#https://47526.jupyter.educoder.net/nbconvert/notebook/data/workspace/myshixun_570461/f2ef5p798r20191210163135/01.ipynb?download=true
src_url = URI("https://47519.jupyter.educoder.net/nbconvert/notebook/data/workspace/myshixun_tpm3575/01.ipynb?download=true")
response = Net::HTTP.get_response(src_url)
if response.code.to_i != 200
raise("获取文件内容失败:#{response.code}")
end
content = response.body
c = GitService.update_file(repo_path: @shixun.repo_path,
file_path: "01.ipynb",
message: message,
content: content,
author_name: author_name,
author_email: author_email)
render plain: 'save: #{c.size}'
end
private
def shixun
@shixun = Shixun.find(3575)
end
end

@ -716,7 +716,7 @@ class ShixunsController < ApplicationController
project_fork(@myshixun, @repo_path, current_user.login)
rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path)
uri = "#{cloud_bridge}/bridge/game/openGameInstance"
params = {tpiID: "#{myshixun.id}", tpmGitURL: rep_url, tpiRepoName: myshixun.repo_name.split("/").last}
params = {tpiID: "#{@myshixun.id}", tpmGitURL: rep_url, tpiRepoName: @myshixun.repo_name.split("/").last}
interface_post uri, params, 83, "实训云平台繁忙繁忙等级83"
end
end

@ -36,15 +36,15 @@ module JupyterService
end
def _open_game_jupyter(game)
def _open_game_jupyter(myshixun)
## 打开tpi
shixun = game.myshixun.shixun
shixun = myshixun.shixun
if shixun.is_jupyter?
shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/jupyter/get"
tpiID = game.myshixun.id
tpiID = myshixun.id
params = {tpiID: tpiID, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
res = uri_post uri, params
@ -56,20 +56,20 @@ module JupyterService
@game_jupyter_port = res['port']
repo_save_path = game.myshixun.repo_save_path
repo_save_path = myshixun.repo_save_path
"https://#{res['port']}.jupyter.educoder.net/notebooks/data/workspace/myshixun_#{tpiID}/#{repo_save_path}/01.ipynb"
end
end
def jupyter_url_with_game(game)
_open_game_jupyter(game)
def jupyter_url_with_game(myshixun)
_open_game_jupyter(myshixun)
end
def jupyter_port_with_game(game)
def jupyter_port_with_game(myshixun)
if @game_jupyter_port.to_i <=0
_open_game_jupyter(shixun)
_open_game_jupyter(myshixun)
end
@game_jupyter_port
end
@ -82,11 +82,11 @@ module JupyterService
tpiID = "tpm#{shixun.id}"
#https://47526.jupyter.educoder.net/nbconvert/notebook/data/workspace/myshixun_570461/f2ef5p798r20191210163135/01.ipynb?download=true
src_url = URI("https://#{jupyter_port}.jupyter.educoder.net/nbconvert/notebook/data/workspace/myshixun_#{tpiID}/01.ipynb?download=true")
response = Net::HTTP.get_response(src_url)
src_url = "https://#{jupyter_port}.jupyter.educoder.net/nbconvert/notebook/data/workspace/myshixun_#{tpiID}/01.ipynb?download=true"
response = Faraday.get(src_url)
if response.code.to_i != 200
raise("获取文件内容失败:#{response.code}")
if response.status.to_i != 200
raise("获取文件内容失败:#{response.status}")
end
content = response.body
@ -101,25 +101,25 @@ module JupyterService
return c.size
end
def jupyter_save_with_game(game,jupyter_port)
def jupyter_save_with_game(myshixun,jupyter_port)
author_name = current_user.real_name
author_email = current_user.git_mail
message = "User submitted"
tpiID = game.myshixun.id
tpiID = myshixun.id
repo_save_path = game.myshixun.repo_save_path
repo_save_path = myshixun.repo_save_path
src_url = URI("https://#{jupyter_port}.jupyter.educoder.net/nbconvert/notebook/data/workspace/myshixun_#{tpiID}/#{repo_save_path}/01.ipynb?download=true")
response = Net::HTTP.get_response(src_url)
src_url = "https://#{jupyter_port}.jupyter.educoder.net/nbconvert/notebook/data/workspace/myshixun_#{tpiID}/#{repo_save_path}/01.ipynb?download=true"
response = Faraday.get(src_url)
if response.code.to_i != 200
raise("获取文件内容失败:#{response.code}")
if response.status.to_i != 200
raise("获取文件内容失败:#{response.status}")
end
content = response.body
c = GitService.update_file(repo_path: game.myshixun.repo_path,
c = GitService.update_file(repo_path: myshixun.repo_path,
file_path: "01.ipynb",
message: message,
content: content,

@ -327,7 +327,7 @@ module.exports = {
},
compress: {
drop_debugger: true,
drop_console: false
drop_console: true
}
}
}),

@ -4005,7 +4005,7 @@ class Listofworksstudentone extends Component {
height: 58px;
}
.ysltableows .ant-table-thead > tr > th, .ant-table-tbody > tr > td {
padding: 9px;
padding: 9px;
}
`
}

@ -334,6 +334,33 @@ class ShixunsHome extends Component {
.square-Item:nth-child(4n+0) {
margin-right: 25px;
}
.tag-org{
position: absolute;
left: 0px;
top: 20px;
}
.tag-org-name{
width:66px;
height:28px;
background:#FF6802;
width:66px;
height:28px;
border-radius:0px 20px 20px 0px;
}
.tag-org-name-test{
width:45px;
height:23px;
font-size:14px;
color:#FFFFFF;
line-height:19px;
margin-right: 6px;
}
.intermediatecenter{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
`
}
</style>
@ -345,7 +372,13 @@ class ShixunsHome extends Component {
<span className="tag-name"> {item.tag_name}</span>
{/*<img style={{display:item.tag_name===null?"none":'block'}} src={require(`./tag2.png`)}/>*/}
</div>
{
item.is_jupyter===true?
<div className="tag-org">
<p className="tag-org-name intermediatecenter"> <span className="tag-org-name-test">Jupyter</span></p>
{/*<img style={{display:'block',height: '28px'}} src={require(`./shixunCss/tag2.png`)}/>*/}
</div>
:""}
<div className={item.power === false ? "closeSquare" : "none"}>
<img src={getImageUrl("images/educoder/icon/lockclose.svg")}
className="mt80 mb25"/>

@ -10,7 +10,8 @@ class Bottomsubmit extends Component {
}
cannelfun=()=>{
window.location.href=this.props.url
// window.location.href=
this.props.history.replace(this.props.url);
}

@ -16,7 +16,6 @@ class TPMDataset extends Component {
constructor(props) {
super(props)
this.state = {
datas: [0, 1, 2, 3, 4, 5],
value: undefined,
columns: [
{
@ -80,10 +79,15 @@ class TPMDataset extends Component {
datalist:[],
data_sets_count:0,
selectedRowKeysdata:[],
loadingstate:false,
checked: false,
}
}
componentDidMount() {
this.setState({
loadingstate:true,
})
this.getdatas()
}
@ -98,18 +102,20 @@ class TPMDataset extends Component {
datas.push(i);
}
this.setState({
selectedRowKeysdata:mydata,
selectedRowKeys: datas,
checked:true,
})
// console.log(mydata);
// console.log(datas);
} else {
this.setState({
selectedRowKeysdata:[],
selectedRowKeys: [],
checked:false,
})
}
}
@ -143,11 +149,26 @@ class TPMDataset extends Component {
collaboratorList: response.data,
data_sets_count:response.data.data_sets_count,
datalist:datalists,
selectedRowKeysdata:[],
selectedRowKeys: [],
checked:false,
});
}
}
setTimeout(() => {
this.setState({
loadingstate:false,
})
}, 500)
}).catch((error)=>{
setTimeout(() => {
this.setState({
loadingstate:false,
})
}, 500)
console.log(error)
});
@ -181,34 +202,39 @@ class TPMDataset extends Component {
collaboratorList: response.data,
data_sets_count:response.data.data_sets_count,
datalist:datalists,
selectedRowKeysdata:[],
selectedRowKeys: [],
checked:false,
});
}
}
setTimeout(() => {
this.setState({
loadingstate:false,
})
}, 500)
}).catch((error)=>{
setTimeout(() => {
this.setState({
loadingstate:false,
})
}, 500)
console.log(error)
});
}
showModal = (id, status) => {
};
handleOk = (id, editid) => {
};
handleCancel = (e) => {
};
paginationonChanges = (pageNumber) => {
// //console.log('Page: ');
this.setState({
page: pageNumber,
loadingstate:true,
})
this.getdatastwo(pageNumber,10);
}
onSelectChange = (selectedRowKeys, selectedRows) => {
console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
this.setState(
@ -241,22 +267,33 @@ class TPMDataset extends Component {
let {fileList} = this.state;
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
console.log("handleChange1");
console.log("handleChange1fileLists");
// if(fileList.length===0){
let fileLists = info.fileList;
// console.log(fileLists);
this.setState({
// fileList:appendFileSizeToUploadFileAll(fileList),
fileList: fileLists,
deleteisnot: false
});
}
if(info.file.status === 'done'){
//done 成功就会调用这个方法
this.getdatas();
// }
// this.props.showNotification(`上传文件成功`);
}else if(info.file.status === 'removed'){
// this.props.showNotification(`上传文件失败`);
}else if(info.file.status === 'uploading'){
// this.props.showNotification(`正在上传文件中`);
}
}
}
onAttachmentRemove = (file) => {
debugger
// debugger
if(!file.percent || file.percent == 100){
confirm({
title: '确定要删除这个附件吗?',
@ -277,28 +314,48 @@ class TPMDataset extends Component {
}
deleteRemovedata(){
debugger
console.log("删除");
console.log(this.state.selectedRowKeysdata);
const url = `/attachments/destroy_files.json`;
axios.delete(url, {
id:this.state.selectedRowKeysdata,
})
.then((response) => {
if (response.data) {
const { status } = response.data;
if (status == 0) {
this.props.showNotification(`删除成功`);
this.getdatas()
}
}
})
.catch(function (error) {
console.log(error);
});
if(this.state.selectedRowKeysdata===undefined || this.state.selectedRowKeysdata===null ||this.state.selectedRowKeysdata.length===0){
this.props.showNotification(`请选择要删除的文件`);
return
}
confirm({
title: '确定要删除文件吗?',
okText: '确定',
cancelText: '取消',
// content: 'Some descriptions',
onOk: () => {
const url = `/attachments/destroy_files.json`;
axios.delete(url,
{ params: {
id:this.state.selectedRowKeysdata,
}}
)
.then((response) => {
if (response.data) {
const { status } = response.data;
if (status == 0) {
this.props.showNotification(`删除成功`);
this.getdatas()
}
}
})
.catch(function (error) {
console.log(error);
});
},
onCancel() {
console.log('Cancel');
},
});
}
deleteAttachment = (file) => {
console.log(file);
// console.log(file);
let id=file.response ==undefined ? file.id : file.response.id
const url = `/attachements/destroy_files.json`
axios.delete(url, {
@ -332,7 +389,7 @@ class TPMDataset extends Component {
render() {
const {tpmLoading, shixun, user, match} = this.props;
const {columns, datas, page, limit, selectedRowKeys,mylistansum,fileList,datalist,data_sets_count} = this.state;
const {columns, page, limit, selectedRowKeys,mylistansum,fileList,datalist,data_sets_count,loadingstate} = this.state;
const rowSelection = {
selectedRowKeys,
onChange: this.onSelectChange,
@ -371,7 +428,6 @@ class TPMDataset extends Component {
message: '提示',
description:
'文件大小必须小于50MB',
}
)
}
@ -385,8 +441,6 @@ class TPMDataset extends Component {
file:file
})
}
console.log("handleChange2");
return isLt150M;
},
}
@ -407,7 +461,7 @@ class TPMDataset extends Component {
<div className="padding20 edu-back-white mt20 " style={{minHeight: '463px'}}>
<div className="sortinxdirection">
<div className="tpmwidth">
<Checkbox onChange={this.mysonChange}>全选</Checkbox>
<Checkbox checked={this.state.checked} onChange={this.mysonChange}>全选</Checkbox>
</div>
<div className="tpmwidth xaxisreverseorder">
<style>
@ -506,6 +560,8 @@ class TPMDataset extends Component {
className="mysjysltable4"
rowSelection={rowSelection}
rowClassName={this.rowClassName}
loading={loadingstate}
/>
</div>
}

@ -42,13 +42,16 @@ class Shixuninformation extends Component {
this.state = {
NAME_COUNT: 60,
shixunmemoMDvalue: "",
language: "java",
testscripttiptype:false,
shixunName:'',
trainee:undefined,
choice_small_type:[],
simichecked:false,
testscripttiptype: false,
shixunName: '',
trainee: undefined,
choice_small_type: [],
simichecked: false,
Executivetyoe: false,
Executiveordervalue: "",
Compilecommandvalue: "",
shixun_service_configs: undefined,
fileList:[]
}
}
@ -57,20 +60,56 @@ class Shixuninformation extends Component {
}
componentDidUpdate(prevProps, prevState) {
if(prevProps.data!=this.props.data){
if(this.props.data){
if (prevProps.data != this.props.data) {
if (this.props.data) {
this.setState({
shixunName: this.props.data.shixun.name,
trainee: this.props.data.shixun.trainee,
choice_main_type: this.props.data.shixun.choice_main_type,
choice_small_type: this.props.data.shixun.choice_small_type,
choice_standard_scripts: this.props.data.shixun.choice_standard_scripts,
shixunmemoMDvalue: this.props.data.shixun.evaluate_script,
simichecked: this.props.data.shixun.is_secret_repository,
shixun_service_configs: this.props.data.shixun.shixun_service_configs,
standard_scripts:this.props.data.shixun.standard_scripts,
})
if(this.props.data.shixun.choice_standard_scripts===null){
this.setState({
choice_standard_scripts:{id: this.props.data.shixun.standard_scripts[0].id, value: ""},
choice_standard_scriptssum:this.props.data.shixun.standard_scripts[0].id
})
this.props.form.setFieldsValue({
selectscripts:this.props.data.shixun.standard_scripts[0].id
})
this.get_mirror_script(this.props.data.shixun.standard_scripts[0].id)
}
let newlist = ""
this.props.data.shixun.choice_small_type.map((item, key) => {
this.props.data.shixun.small_type.map((i,k)=>{
if (item===i.id) {
newlist = newlist + `${i.description}`
}
})
})
this.setState({
shixunName:this.props.data.shixun.name,
trainee:this.props.data.shixun.trainee,
choice_main_type:this.props.data.shixun.choice_main_type,
choice_small_type:this.props.data.shixun.choice_small_type,
choice_standard_scripts:this.props.data.shixun.choice_standard_scripts,
shixunmemoMDvalue:this.props.data.shixun.evaluate_script,
simichecked:this.props.data.shixun.is_secret_repository,
subvalues: newlist
})
this.props.data.shixun.main_type.map((item,key)=>{
if(item.id===this.props.data.shixun.choice_main_type){
this.setState({
mainvalues:item.description,
})
}
})
this.props.form.setFieldsValue({
name:this.props.data.shixun.name,
name: this.props.data.shixun.name,
trainee: this.props.data.shixun.trainee,
selectleft: this.props.data.shixun.choice_main_type,
selectright:this.props.data.shixun.choice_small_type,
})
this.contentMdRef.current.setValue(this.props.data.shixun.description);
}
@ -84,14 +123,14 @@ class Shixuninformation extends Component {
})
}
testscripttip=(val)=>{
if(val===0){
testscripttip = (val) => {
if (val === 0) {
this.setState({
testscripttiptype:true
testscripttiptype: true
})
}else if(val===1){
} else if (val === 1) {
this.setState({
testscripttiptype:false
testscripttiptype: false
})
}
}
@ -223,82 +262,244 @@ class Shixuninformation extends Component {
}
bigClass = (value) => {
let list=[]
setlanguage = (e) => {
this.setState({
language: e.target.value
})
if (e.target.value) {
this.setState({
languagewritetype: false
})
}
}
setruntime = (e) => {
this.setState({
runtime: e.target.value
})
if (e.target.value) {
this.setState({
systemenvironmenttype: false
})
}
}
setrun_method = (e) => {
this.setState({
run_method: e.target.value
})
if (e.target.value) {
this.setState({
testcoderunmodetype: false
})
}
}
// 附件相关 START
handleChange = (info) => {
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
let {fileList} = this.state;
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
console.log("handleChange1");
// if(fileList.length===0){
let fileLists = info.fileList;
this.setState({
// fileList:appendFileSizeToUploadFileAll(fileList),
fileList: fileLists,
deleteisnot: false
});
// }
}
}
}
onAttachmentRemove = (file) => {
if (!file.percent || file.percent == 100) {
Modal.confirm({
title: '确定要删除这个附件吗?',
okText: '确定',
cancelText: '取消',
// content: 'Some descriptions',
onOk: () => {
console.log("665")
this.deleteAttachment(file)
},
onCancel() {
console.log('Cancel');
},
});
return false;
}
}
deleteAttachment = (file) => {
console.log(file);
let id = file.response == undefined ? file.id : file.response.id
const url = `/attachments/${id}.json`
axios.delete(url, {})
.then((response) => {
if (response.data) {
const {status} = response.data;
if (status == 0) {
// console.log('--- success')
this.setState((state) => {
const index = state.fileList.indexOf(file);
const newFileList = state.fileList.slice();
newFileList.splice(index, 1);
return {
fileList: newFileList,
deleteisnot: true
};
});
}
}
})
.catch(function (error) {
console.log(error);
});
}
bigClass = (value,e) => {
this.setState({
mainvalues:e.props.name
})
let list = []
list.push(this.props.data.shixun.choice_main_type)
this.props.data.shixun.choice_small_type.map((item,key)=>{
this.props.data.shixun.choice_small_type.map((item, key) => {
list.push(item)
})
let newshixun_service_configs=this.props.data.shixun.shixun_service_configs;
let newshixun_service_configsagin=[];
newshixun_service_configs.map((item,key)=>{
list.map((its,index)=>{
if(item.mirror_repository_id===its){
let newshixun_service_configs = this.props.data.shixun.shixun_service_configs;
let newshixun_service_configsagin = [];
newshixun_service_configs.map((item, key) => {
list.map((its, index) => {
if (item.mirror_repository_id === its) {
newshixun_service_configsagin.push(item)
}
})
})
this.props.data.shixun.main_type.some((item,key)=> {
this.props.data.shixun.main_type.some((item, key) => {
if (item.id === value) {
newshixun_service_configsagin[0]={
mirror_repository_id:value,
name:item.type_name,
cpu_limit:1,
lower_cpu_limit:0.1,
memory_limit:1024,
request_limit:10
newshixun_service_configsagin[0] = {
mirror_repository_id: value,
name: item.type_name,
cpu_limit: 1,
lower_cpu_limit: 0.1,
memory_limit: 1024,
request_limit: 10
}
return true
}
}
)
let url = `/shixuns/get_mirror_script.json?mirror_id=`+value;
this.props.form.setFieldsValue({
selectleft: value,
})
let url = `/shixuns/get_mirror_script.json?mirror_id=` + value;
axios.get(url).then((response) => {
if (response.status === 200) {
// console.log(response.data)
console.log(response.data[0].id)
this.get_mirror_script(response.data[0].id)
this.setState({
choice_main_type: value,
standard_scripts:response.data,
choice_standard_scripts:null,
shixun_service_configs:newshixun_service_configsagin,
shixun_service_configlist:newshixun_service_configsagin,
standard_scripts: response.data,
shixun_service_configs: newshixun_service_configsagin,
shixun_service_configlist: newshixun_service_configsagin,
})
this.setState({
choice_standard_scripts:{id: response.data[0].id, value: ""},
choice_standard_scriptssum:response.data[0].id
})
this.props.form.setFieldsValue({
selectscripts:response.data[0].id
})
}
}).catch((error) => {
console.log(error)
});
}
Deselectlittle = (value,e) => {
let {shixun_service_configs, choice_small_type} = this.state;
let newshixun_service_configs = shixun_service_configs;
let newchoice_small_type = choice_small_type;
newshixun_service_configs.some((item, key) => {
if (item.mirror_repository_id === value) {
newshixun_service_configs.splice(key, 1)
return true
}
}
)
newchoice_small_type.some((item, key) => {
if (item === value) {
newchoice_small_type.splice(key, 1)
return true
}
}
)
littleClass = (value) => {
let newshixun_service_configs=this.props.data.shixun.shixun_service_configs;
let newchoice_small_type=this.props.data.shixun.choice_small_type;
let list=[]
this.setState({
choice_small_type: newchoice_small_type,
shixun_service_configs: newshixun_service_configs,
shixun_service_configlist: newshixun_service_configs,
})
}
showlittleClass=(value,e)=>{
let newlist = ""
e.map((item, key) => {
if (item.props.name != "") {
newlist = newlist + `${item.props.name}`
}
})
this.setState({
subvalues: newlist
})
this.props.form.setFieldsValue({
selectright: value,
})
}
littleClass = (value,e) => {
let newshixun_service_configs = this.props.data.shixun.shixun_service_configs;
let newchoice_small_type = this.props.data.shixun.choice_small_type;
let list = []
list.push(this.props.data.shixun.choice_main_type)
newchoice_small_type.map((item,key)=>{
newchoice_small_type.map((item, key) => {
list.push(item)
})
let newshixun_service_configsagin=[]
let newshixun_service_configsagin = []
newshixun_service_configs.map((item,key)=>{
list.map((its,index)=>{
if(item.mirror_repository_id===its){
newshixun_service_configs.map((item, key) => {
list.map((its, index) => {
if (item.mirror_repository_id === its) {
newshixun_service_configsagin.push(item)
}
})
})
this.props.data.shixun.small_type.some((items,keys)=> {
this.props.data.shixun.small_type.some((items, keys) => {
if (items.id === value) {
newshixun_service_configsagin.push({
mirror_repository_id:value,
name:items.type_name,
cpu_limit:1,
lower_cpu_limit:0.1,
memory_limit:1024,
request_limit:10
mirror_repository_id: value,
name: items.type_name,
cpu_limit: 1,
lower_cpu_limit: 0.1,
memory_limit: 1024,
request_limit: 10
})
return true
}
@ -309,38 +510,44 @@ class Shixuninformation extends Component {
this.setState({
choice_small_type: newchoice_small_type,
shixun_service_configs:newshixun_service_configsagin,
shixun_service_configlist:newshixun_service_configsagin,
shixun_service_configs: newshixun_service_configsagin,
shixun_service_configlist: newshixun_service_configsagin,
})
}
SelectScput = (value, e) => {
this.setState({
choice_standard_scriptssum: value,
language:e.props.name,
choice_standard_scripts: {id:e.props.value,value:""},
standard_scriptsModal:true
language: e.props.name,
choice_standard_scripts: {id: e.props.value, value: ""},
standard_scriptsModal: true
})
}
hidestandard_scriptsModal=()=>{
hidestandard_scriptsModal = () => {
this.setState({
standard_scriptsModal:false,
standard_scriptsModals:false
standard_scriptsModal: false,
standard_scriptsModals: false
})
}
get_mirror_script=()=>{
let {choice_standard_scriptssum}=this.state;
get_mirror_script = (ids) => {
let {choice_standard_scriptssum} = this.state;
let id = this.props.match.params.shixunId;
let pul = "/shixuns/" + id + "/get_script_contents.json?script_id=" + choice_standard_scriptssum;
axios.get(pul).then((response) => {
if(response.status===200){
let url = `/shixuns/${id}/get_script_contents.json`;
axios.get((url),{params:{
script_id:ids?ids:choice_standard_scriptssum
}}).then((response) => {
if (response.status === 200) {
// this.evaluate_scriptMD(response.data.content, "shixunmemoMD");
if(ids==undefined){
this.setState({
standard_scriptsModal: false,
standard_scriptsModals: true,
})
}
this.setState({
standard_scriptsModal:false,
standard_scriptsModals:true,
shixunmemoMDvalue:response.data.content
shixunmemoMDvalue: response.data.content
})
}
@ -349,22 +556,143 @@ class Shixuninformation extends Component {
})
}
simionChange=(e)=>{
simionChange = (e) => {
this.setState({
simichecked: e.target.checked
})
}
showModal = () => {
this.setState({
visibleTemplate: true,
});
}
handleCancelTemplate = (e) => {
this.setState({
Executiveordervalue: "",
Compilecommandvalue: "",
visibleTemplate: false
})
}
hideModalTemplate = (e) => {
let id = this.props.match.params.shixunId;
let {Executiveordervalue, Compilecommandvalue} = this.state;
if (Executiveordervalue === "" || Executiveordervalue === undefined) {
this.setState({
Executivetyoe: true,
});
return
}
// Executiveordervalue=String(Executiveordervalue);
// Compilecommandvalue=String(Compilecommandvalue);
let trl = `/shixuns/${id}/get_custom_script.json?compile=${Executiveordervalue}&excutive=${Compilecommandvalue}`
axios.get(trl).then((response) => {
// this.evaluate_scriptMD(response.data.shixun_script, "shixunmemoMD");
this.setState({
shixunmemoMDvalue: response.data.shixun_script
})
}).catch((error) => {
console.log(error)
});
this.setState({
simichecked:e.target.checked
visibleTemplate: false
})
}
Executiveorder = (e) => {
this.setState({
Executiveordervalue: e.target.value
})
}
Compilecommand = (e) => {
this.setState({
Compilecommandvalue: e.target.value
})
}
setConfigsInputs=(e,keys,str)=>{
let {shixun_service_configs}=this.state;
let newshixun_service_configs=shixun_service_configs;
newshixun_service_configs.map((item,key)=>{
if(key===keys){
switch (str) {
case 1:
item.cpu_limit=e.target.value
break;
case 2:
item.lower_cpu_limit=e.target.value
break;
case 3:
item.memory_limit=e.target.value
break;
case 4:
item.request_limit=e.target.value
break;
}
}
})
this.setState({
shixun_service_configs:newshixun_service_configs,
shixun_service_configlist:newshixun_service_configs,
})
}
onSubmits=()=>{
const mdContnet = this.contentMdRef.current.getValue().trim();
console.log(mdContnet)
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
console.log('Received values of form: ', values);
// let Url = `/shixuns.json`;
// axios.post(Url, {
// description: mdContnet,
// main_type: values.main_type,
// sub_type: values.sub_type,
// shixun: {
// name: values.name,
// trainee: values.select,
// is_jupyter: values.is_jupyter === "2" ? true : false,
// }
// }
// ).then((response) => {
// if (response.status === 200) {
// window.location.href = "/shixuns/" + response.data.shixun_identifier + "/challenges";
// // window.open("/shixuns/"+response.data.shixun_identifier+"/challenges");
// } else {
// this.setState({
// bottonloading: false
// })
// }
// }).catch((error) => {
// console.log(error)
// this.setState({
// bottonloading: false
// })
// })
}
});
}
render() {
let operateauthority=this.props.identity===1?true:this.props.identity<5&&this.props.data.shixun.status==0?true:false;
// console.log(operateauthority)
let operateauthority = this.props.identity === 1 ? true : this.props.identity < 5 && this.props.data.shixun.status == 0 ? true : false;
// console.log(operateauthority)
const {getFieldDecorator} = this.props.form;
const {languagewrite, systemenvironment, testcoderunmode, fileList, choice_standard_scripts, postapplyvisible, shixunmemoMDvalue} = this.state;
const { fileList, choice_standard_scripts, postapplyvisible, shixunmemoMDvalue} = this.state;
// console.log("1222")
// console.log(choice_standard_scripts)
const {shixun_service_configs}=this.props;
const uploadProps = {
width: 600,
fileList,
@ -394,7 +722,6 @@ class Shixuninformation extends Component {
)
}
if (this.state.file !== undefined) {
console.log("763")
this.setState({
file: file
})
@ -403,15 +730,10 @@ class Shixuninformation extends Component {
file: file
})
}
console.log("handleChange2");
return isLt150M;
},
}
return (
<div>
<div className="educontent mb50 edu-back-white padding10-20">
@ -487,9 +809,10 @@ class Shixuninformation extends Component {
rules: [{required: true, message: '请选择主类别'}],
})(
<div className="width100 fl mr20">
<Select placeholder="请选择主类别" value={this.state.choice_main_type === "" ? undefined : this.state.choice_main_type}
<Select placeholder="请选择主类别"
value={this.state.choice_main_type === "" ? undefined : this.state.choice_main_type}
style={{width: 180}}
onChange={operateauthority?this.bigClass:""}
onChange={operateauthority ? this.bigClass : ""}
optionFilterProp="children"
filterOption={(input, option) =>
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
@ -499,8 +822,8 @@ class Shixuninformation extends Component {
{
this.props.data === undefined ? "" : this.props.data.shixun.main_type.map((item, key) => {
return (
<Option value={item.id} key={key} >
<Tooltip placement="right" title={item.description=== ""?"无描述":item.description} >
<Option value={item.id} key={key} name={item.description}>
<Tooltip placement="right" title={item.description === "" ? "无描述" : item.description}>
{item.type_name}
</Tooltip>
</Option>
@ -516,29 +839,29 @@ class Shixuninformation extends Component {
<Form.Item
style={{"borderBottom": 'none', 'width': '61%', 'float': 'left', 'marginTop': '40px'}}
style={{"borderBottom": 'none', 'width': '81%', 'float': 'left', 'marginTop': '40px'}}
className="chooseDes pr"
>
<div className=" fl pr mr20">
{getFieldDecorator('selectright', {
rules: [{required: true, message: '请选择小类别'}],
rules: [{required: false, message: '请选择小类别'}],
})(
<div className=" fl pr mr20">
<Select placeholder="请选择小类别"
mode="multiple"
onChange={this.selectright}
value={this.state.choice_small_type.length===0||this.state.choice_small_type[0]===""||this.state.choice_small_type===[]?undefined:this.state.choice_small_type}
style={{width: 180,height:30}}
disabled={operateauthority?false:true}
onDeselect={operateauthority?this.Deselectlittle:""}
onSelect={operateauthority?this.littleClass:""}
value={this.state.choice_small_type.length === 0 || this.state.choice_small_type[0] === "" || this.state.choice_small_type === [] ? undefined : this.state.choice_small_type}
style={{width: 200}}
disabled={operateauthority ? false : true}
onDeselect={operateauthority ? this.Deselectlittle : ""}
onSelect={operateauthority ? this.littleClass : ""}
onChange={this.showlittleClass}
defaultOpen={false}
>
{
this.props.data === undefined ? "" : this.props.data.shixun.small_type.map((item, key) => {
return(
<Option value={item.id} key={key}>
<Tooltip placement="right" title={item.description=== ""?"无描述":item.description} >
this.props.data === undefined ? "" : this.props.data.shixun.small_type.map((item, key) => {
return (
<Option value={item.id} key={key} name={item.description}>
<Tooltip placement="right" title={item.description === "" ? "无描述" : item.description}>
{item.type_name}
</Tooltip>
</Option>
@ -549,15 +872,16 @@ class Shixuninformation extends Component {
</div>
)}
<span className="fl ml20 color-grey lineh-20">
<div>
<div className={"font-12"}>
已安装软件hadoop3.1.0jdk1.8
</div>
<div className={"font-12"}>
说明添加了hadoop3.1.0jdk1.8的源码包添加了hadoop3.1.0jdk1.8的源码包
</div>
</div>
</span>
<div>
{this.state.mainvalues === undefined && this.state.subvalues === undefined || this.state.mainvalues === "" && this.state.subvalues === "" ? "" :
<div className={"font-12"} style={{'max-width': '600px'}}>
{`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : `已安装软件:` + this.state.mainvalues}`}
{`${this.state.subvalues === undefined || this.state.subvalues === "" ? "" : this.state.mainvalues === undefined || this.state.mainvalues === "" ? `已安装软件:` + this.state.subvalues : this.state.subvalues}`}
{`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : `说明:添加了` + this.state.mainvalues}${this.state.subvalues === undefined || this.state.subvalues === "" ? "" :
this.state.mainvalues === undefined || this.state.mainvalues === "" ? `说明:添加了` + this.state.subvalues : this.state.subvalues}`}
</div>}
</div>
</span>
</div>
</Form.Item>
@ -573,18 +897,18 @@ class Shixuninformation extends Component {
style={{"borderBottom": 'none'}}
className="chooseDes pr"
>
{getFieldDecorator('select123', {
{getFieldDecorator('selectscripts', {
rules: [{required: true, message: '请选择评测脚本'}],
})(
<div className="with15 fl pr">
<Select placeholder="请选择选择脚本"
style={{width: 180}}
className="fl"
disabled={operateauthority?false:true}
value={choice_standard_scripts === undefined||choice_standard_scripts === null ? undefined :choice_standard_scripts.id===undefined?choice_standard_scripts:choice_standard_scripts.id}
onChange={operateauthority?this.SelectScput:""}>
disabled={operateauthority ? false : true}
value={choice_standard_scripts === undefined || choice_standard_scripts === null ? undefined : choice_standard_scripts.id === undefined ? choice_standard_scripts : choice_standard_scripts.id}
onChange={operateauthority ? this.SelectScput : ""}>
{
this.props.data === undefined ? "" : this.props.data.shixun.standard_scripts.map((item, key) => {
this.state.standard_scripts=== undefined ? "" : this.state.standard_scripts.map((item, key) => {
return (
<Option value={parseInt(item.id)} name={item.scptname} key={key}>{item.scptname}</Option>
)
@ -594,13 +918,19 @@ class Shixuninformation extends Component {
</Select>
</div>
)}
<span className="fl ml20 color-blue">
使用自定义脚本
<span className={"color-grey ml10"} onClick={()=>this.testscripttip(0)}>
<span className="fl ml20 color-blue" style={{'line-height': '30px'}}>
<span onClick={() => this.showModal()}>使用自定义脚本</span>
<span className={"color-grey ml10"} onClick={() => this.testscripttip(0)}>
<Icon type="exclamation-circle"/>
</span>
<div className="invite-tip clearfix none " id="test_script_tip"
style={{top: '33px', left: '-15px',width: '450px',zIndex: '10',display: this.state.testscripttiptype===true?'block':"none"}}>
style={{
top: '33px',
left: '-15px',
width: '450px',
zIndex: '10',
display: this.state.testscripttiptype === true ? 'block' : "none"
}}>
<style>
{
`
@ -634,7 +964,7 @@ class Shixuninformation extends Component {
</p>
</div>
<p className="inviteTipbtn with100 fl">
<a onClick={()=>this.testscripttip(1)}>知道了</a>
<a onClick={() => this.testscripttip(1)}>知道了</a>
</p>
</div>
</span>
@ -649,7 +979,7 @@ class Shixuninformation extends Component {
<MonacoEditor
height="450"
width="1150"
language={this.state.language}
// language={this.state.language}
value={shixunmemoMDvalue}
options={{
selectOnLineNumbers: true
@ -663,15 +993,16 @@ class Shixuninformation extends Component {
</Form>
<span className="ant-form-text mt20" >私密版本库
<Checkbox onChange={this.simionChange} value={this.state.simichecked}>若需要对学员隐藏部分版本库内容时请选中选中即启用私密版本库请将需要对学员隐藏的文件存储在私密版本库</Checkbox>
<span className="ant-form-text mt20">私密版本库
<Checkbox onChange={this.simionChange}
value={this.state.simichecked}>若需要对学员隐藏部分版本库内容时请选中选中即启用私密版本库请将需要对学员隐藏的文件存储在私密版本库</Checkbox>
</span>
{this.props.identity<3?<div className="edu-back-white padding40-20 mb20">
{this.props.identity < 3 ? <div className="edu-back-white padding40-20 mb20">
<p className="color-grey-6 font-16 mb30">服务配置</p>
{ shixun_service_configs&&shixun_service_configs.map((item,key)=>{
{this.state.shixun_service_configs && this.state.shixun_service_configs.map((item, key) => {
return(
return (
<div key={key}>
<div id="5">
<div className="color-grey-6 font-16 mt30 mb20" id="shixun_scenario_type_name">
@ -681,34 +1012,36 @@ class Shixuninformation extends Component {
<div className="clearfix mb5">
<label className="panel-form-label fl">CPU()</label>
<div className="pr fl with80 status_con">
<input type="text" value={item.cpu_limit} onInput={(e)=>this.setConfigsInputs(e,key,1)}
className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" />
<input type="text" value={item.cpu_limit} onInput={(e) => this.setConfigsInputs(e, key, 1)}
className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称"/>
</div>
<div className="cl"></div>
</div>
<div className="clearfix mb5">
<label className="panel-form-label fl">最低CPU()</label>
<div className="pr fl with80 status_con">
<input type="text" value={item.lower_cpu_limit} onInput={(e)=>this.setConfigsInputs(e,key,2)}
className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" />
<input type="text" value={item.lower_cpu_limit}
onInput={(e) => this.setConfigsInputs(e, key, 2)}
className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称"/>
</div>
<div className="cl"></div>
</div>
<div className="clearfix mb5">
<label className="panel-form-label fl">内存限制(M)</label>
<div className="pr fl with80 status_con">
<input type="text" value={item.memory_limit} onInput={(e)=>this.setConfigsInputs(e,key,3)}
className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" />
<input type="text" value={item.memory_limit} onInput={(e) => this.setConfigsInputs(e, key, 3)}
className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称"/>
</div>
<div className="cl"></div>
</div>
<div className="clearfix mb5">
<label className="panel-form-label fl">内存要求(M)</label>
<div className="pr fl with20 status_con">
<input type="text" value={item.request_limit} onInput={(e)=>this.setConfigsInputs(e,key,4)}
className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" />
<input type="text" value={item.request_limit} onInput={(e) => this.setConfigsInputs(e, key, 4)}
className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称"/>
</div>
<label className="panel-form-label fl" style={{width: '48%'}}>温馨提示纯编程类型实训建议使用默认值对于大数据等建议使用最大内存的30%</label>
<label className="panel-form-label fl"
style={{width: '48%'}}>温馨提示纯编程类型实训建议使用默认值对于大数据等建议使用最大内存的30%</label>
<div className="cl"></div>
</div>
</div>
@ -716,7 +1049,7 @@ class Shixuninformation extends Component {
)
})}
</div> :""}
</div> : ""}
{postapplyvisible === true ? <style>
@ -742,8 +1075,8 @@ class Shixuninformation extends Component {
</div>
<div className="task-popup-submit clearfix mt10">
<a onClick={()=>this.hidestandard_scriptsModal()} className="task-btn fl">取消</a>
<a className="task-btn task-btn-orange fr" onClick={()=>this.get_mirror_script()}>确定</a>
<a onClick={() => this.hidestandard_scriptsModal()} className="task-btn fl">取消</a>
<a className="task-btn task-btn-orange fr" onClick={() => this.get_mirror_script()}>确定</a>
</div>
</Modal>
@ -756,10 +1089,48 @@ class Shixuninformation extends Component {
>
<div className="task-popup-content"><p className="task-popup-text-center font-16">评测脚本生成成功</p></div>
<div className="task-popup-sure clearfix">
<a className="task-btn task-btn-orange" onClick={()=>this.hidestandard_scriptsModal()} >确定</a>
<a className="task-btn task-btn-orange" onClick={() => this.hidestandard_scriptsModal()}>确定</a>
</div>
</Modal>
<Modal
keyboard={false}
title="自定义模板"
visible={this.state.visibleTemplate}
onCancel={this.handleCancelTemplate}
onOk={this.hideModalTemplate}
okText="确认"
cancelText="取消"
>
<div>
<li className="clearfix mb15">
<label className="panel-form-label fl"><span
className="color-orange mr5">*</span></label>
<textarea className="task-form-80 task-height-150 panel-box-sizing fl mt10"
onInput={this.Executiveorder}
value={this.state.Executiveordervalue}
style={{width: '100%'}}
id="executive_command"
>
</textarea>
<p className="-text-danger fl mt5"
id="executive_command_notice"
style={{display: this.state.Executivetyoe === false ? "none" : "block"}}
>执行命令不能为空</p>
</li>
<li className="clearfix mb15">
<label className="panel-form-label fl">编译命令</label>
<textarea className="task-form-80 task-height-150 panel-box-sizing fl mt10"
value={this.state.Compilecommandvalue}
onInput={this.Compilecommand}
id="compile_command"
style={{width: '100%'}}
>
</textarea>
</li>
</div>
</Modal>
<Modal
keyboard={false}
@ -777,20 +1148,21 @@ class Shixuninformation extends Component {
<textarea
className={this.state.languagewritetype === true ? "fl task-form-80 task-height-150 bor-reds" : "fl task-form-80 task-height-150"}
style={{width: '89%', height: '100px'}}
onInput={this.setlanguagewrite}
value={languagewrite}
onInput={this.setlanguage}
value={this.state.language}
placeholder="请填写该镜像是基于什么语言示例Python"
id="demand_info"></textarea>
</li>
<div className={"color-red shixunspanred"}>{this.state.languagewritetype === true ? "请填写该镜像语言" : ""}</div>
<div
className={"color-red shixunspanred"}>{this.state.languagewritetype === true ? "请填写该镜像语言" : ""}</div>
<li className="clearfix ml1">
<label className="panel-form-label fl ml50"><span
className="color-red fl mt3">*</span>&nbsp;&nbsp;</label>
<textarea
className={this.state.systemenvironmenttype === true ? "fl task-form-80 task-height-150 bor-reds" : "fl task-form-80 task-height-150"}
onInput={this.setsystemenvironment}
onInput={this.setruntime}
style={{height: '100px'}}
value={systemenvironment}
value={this.state.runtime}
placeholder="请填写该镜像是基于什么linux系统环境,代码运行环境"
id="demand_info"></textarea>
</li>
@ -802,8 +1174,8 @@ class Shixuninformation extends Component {
<textarea
className={this.state.testcoderunmodetype === true ? "fl task-form-80 task-height-150 bor-reds" : "fl task-form-80 task-height-150"}
onInput={this.settestcoderunmode}
value={testcoderunmode}
onInput={this.setrun_method}
value={this.state.run_method}
style={{height: '100px'}}
placeholder="请填写该镜像中测试代码运行方式"
id="demand_info"></textarea>
@ -837,10 +1209,11 @@ class Shixuninformation extends Component {
</li>
<div className="cl"></div>
</div>
{/*</Form>*/}
</Modal>
</div>
<Bottomsubmit url={`/shixuns/${this.props.match.params.shixunId}/challenges`} onSubmits={ this.sendsure_apply}/>
{this.props.identity < 5 ?
<Bottomsubmit {...this.props} {...this.state} url={`/shixuns/${this.props.match.params.shixunId}/challenges`}
onSubmits={this.onSubmits}/> : ""}
</div>
);

@ -2,7 +2,8 @@ import React, {Component} from 'react';
import {
Button,
Tabs
Tabs,
Modal
} from 'antd';
import TopShixuninformation from './Shixuninformation';
@ -23,15 +24,10 @@ const {TabPane} = Tabs;
export default class TPMsettings extends Component {
constructor(props) {
super(props)
this.state = {
}
this.state = {}
}
componentDidMount() {
let id = this.props.match.params.shixunId;
@ -41,9 +37,9 @@ export default class TPMsettings extends Component {
axios.get(Url).then((response) => {
// alert(response.data.shixun.choice_standard_scripts)
if (response.status === 200) {
this.setState({
data:response.data
})
this.setState({
data: response.data
})
if (response.data.shixun.multi_webssh === true) {
this.setState({
SelectTheCommandtype: true
@ -79,15 +75,63 @@ export default class TPMsettings extends Component {
}
operateshixuns = (value) => {
this.setState({
operateshixunstype: true,
delType: value
})
}
hideoperateshixuns = () => {
this.setState({
operateshixunstype: false
})
}
shixunsdel = () => {
let id = this.props.match.params.shixunId;
let cul = `/shixuns/` + id + `.json`;
axios.delete(cul).then((response) => {
if (response.data.status === 1) {
this.props.showSnackbar("操作成功");
this.setState({
operateshixunstype: false,
});
window.location.href = "/shixuns";
}
}).catch((error) => {
console.log(error)
})
}
shixunsclose = () => {
let id = this.props.match.params.shixunId;
let cul = `/shixuns/` + id + `/close.json`;
axios.post(cul).then((response) => {
if (response.data.status === 1) {
this.props.showSnackbar("操作成功");
this.setState({
operateshixunstype: false,
});
window.location.href = "/shixuns/" + id + "/challenges";
}
}).catch((error) => {
console.log(error)
})
}
render() {
return (
<div>
<style>
{
`
<div>
<style>
{
`
.ant-tabs-bar{
width: 1200px;
margin: 0 auto;
@ -96,38 +140,69 @@ export default class TPMsettings extends Component {
margin-top: 30px!important;
}
`
}
</style>
<Tabs tabBarExtraContent={
<div className={"mb20 mr20"}>
{
this.props.identity < 5 && this.state.data && this.state.data.shixun.status == 0 ?
<Button type="primary" ghost className={"Permanentban mr20"} onClick={() => this.operateshixuns(1)}>
删除实训
</Button>
: ""
}
{
this.props.identity == 1 && this.state.data && this.state.data.shixun.status == 2 ?
<Button type="primary" ghost className={"Permanentban mr20"} onClick={() => this.operateshixuns(1)}>
删除实训
</Button> : ""
}
{
this.props.identity === 1 && this.state.data && this.state.data.shixun.status == 2 ?
<Button type="primary" ghost className={"Permanentban"} onClick={() => this.operateshixuns(2)}>
永久关闭
</Button> : ""
}
</style>
<Tabs tabBarExtraContent={
<div className={"mb20 mr20"}>
<Button type="primary" ghost className={"Permanentban"}>
永久关闭
</Button>
<Button type="primary" ghost className={"Permanentban ml20"}>
删除实训
</Button>
</div>
}>
<TabPane tab="基本信息" key="1">
<TopShixuninformation
{...this.state}
{...this.props}
/>
</TabPane>
<TabPane tab="权限配置" key="2">
<Configuration
{...this.state}
{...this.props}
/>
</TabPane>
<TabPane tab="学习页面设置" key="3">
<LearningSettings
{...this.state}
{...this.props}
/>
</TabPane>
</Tabs>
</div>
</div>
}>
<TabPane tab="基本信息" key="1">
<TopShixuninformation
{...this.state}
{...this.props}
/>
</TabPane>
<TabPane tab="权限配置" key="2">
<Configuration
{...this.state}
{...this.props}
/>
</TabPane>
<TabPane tab="学习页面设置" key="3">
<LearningSettings
{...this.state}
{...this.props}
/>
</TabPane>
</Tabs>
<Modal
keyboard={false}
title="提示"
visible={this.state.operateshixunstype}
closable={false}
footer={null}
>
<div className="task-popup-content">
{this.state.delType === 1 ? <p className="task-popup-text-center font-16 pb20">是否确认删除 </p> :
<p className="task-popup-text-center font-16 pb20">关闭后,<br/>用户不能再开始挑战了是否确认关闭 </p>}
</div>
<div className="task-popup-submit clearfix">
<a onClick={this.hideoperateshixuns} className="task-btn fl">取消</a>
{this.state.delType === 1 ? <a className="task-btn task-btn-orange fr" onClick={this.shixunsdel}>确定</a> :
<a className="task-btn task-btn-orange fr" onClick={this.shixunsclose}>确定</a>}
</div>
</Modal>
</div>
);
}

@ -5,9 +5,9 @@ import { BrowserRouter as Router, Route, Link } from "react-router-dom";
class TPMNav extends Component {
render() {
console.log("componentDidMount");
console.log("TPMNavTPMNavTPMNavTPMNav");
console.log(this.props);
// console.log("componentDidMount");
// console.log("TPMNavTPMNavTPMNavTPMNav");
// console.log(this.props);
const { user, match, shixun, secret_repository,is_jupyter} = this.props;
let isAdminOrCreator = false;
@ -53,20 +53,44 @@ class TPMNav extends Component {
{/*jupyter*/}
{
this.props.is_jupyter===true?
<Link to={`/shixuns/${shixunId}/dataset`}
className={`${match.url.indexOf('dataset') != -1 ? 'active' : ''} fl mr40`}>数据集</Link>
(
is_teacher===true?
<Link to={`/shixuns/${shixunId}/dataset`}
className={`${match.url.indexOf('dataset') != -1 ? 'active' : ''} fl mr40`}>数据集</Link>
:""
)
:""
}
{
this.props.is_jupyter === false ?
<Link to={`/shixuns/${shixunId}/shixun_discuss`}
className={`${match.url.indexOf('shixun_discuss') != -1 ? 'active' : ''} fl mr40`}>评论</Link>
:""
}
{
this.props.is_jupyter === false ?
<Link to={`/shixuns/${shixunId}/ranking_list`}
className={`${match.url.indexOf('ranking_list') != -1 ? 'active' : ''} fl mr40`}>排行榜</Link>:""
}
<Link to={`/shixuns/${shixunId}/shixun_discuss`}
className={`${match.url.indexOf('shixun_discuss') != -1 ? 'active' : ''} fl mr40`}>评论</Link>
{this.props.identity >2||this.props.identity===undefined?"":
(this.props.is_jupyter === false?
<Link to={`/shixuns/${shixunId}/audit_situation`}
className={`${match.url.indexOf('audit_situation') != -1 ? 'active' : ''} fl`}>审核情况</Link>
:
is_teacher===true?
<Link to={`/shixuns/${shixunId}/audit_situation`}
className={`${match.url.indexOf('audit_situation') != -1 ? 'active' : ''} fl`}>审核情况</Link>
:
""
)
<Link to={`/shixuns/${shixunId}/ranking_list`}
className={`${match.url.indexOf('ranking_list') != -1 ? 'active' : ''} fl mr40`}>排行榜</Link>
{this.props.identity >2||this.props.identity===undefined?"":<Link to={`/shixuns/${shixunId}/audit_situation`}
className={`${match.url.indexOf('audit_situation') != -1 ? 'active' : ''} fl`}>审核情况</Link>}
}
{this.props.identity >4||this.props.identity===undefined ? "":<Link to={`/shixuns/${shixunId}/settings`} className="edu-default-btn edu-blueline-btn ml20 fr"
>配置</Link>}

@ -4,7 +4,7 @@ import {TPMIndexHOC} from '../TPMIndexHOC';
import {SnackbarHOC} from 'educoder';
import {Select, Radio, Input, Modal, Button, Form, Tooltip, Upload, Icon,notification} from 'antd';
import {Select, Radio, Input, Modal, Button, Form, Tooltip, Upload, Icon, notification} from 'antd';
import axios from 'axios';
@ -145,7 +145,7 @@ class Newshixuns extends Component {
});
let newlist = ""
e.map((item, key) => {
if(item.props.name!=""){
if (item.props.name != "") {
newlist = newlist + `${item.props.name}`
}
})
@ -316,7 +316,7 @@ class Newshixuns extends Component {
// 附件相关 START
handleChange = (info) => {
if(info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
let {fileList} = this.state;
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
@ -334,7 +334,7 @@ class Newshixuns extends Component {
}
onAttachmentRemove = (file) => {
if(!file.percent || file.percent == 100){
if (!file.percent || file.percent == 100) {
Modal.confirm({
title: '确定要删除这个附件吗?',
okText: '确定',
@ -355,13 +355,12 @@ class Newshixuns extends Component {
deleteAttachment = (file) => {
console.log(file);
let id=file.response ==undefined ? file.id : file.response.id
let id = file.response == undefined ? file.id : file.response.id
const url = `/attachments/${id}.json`
axios.delete(url, {
})
axios.delete(url, {})
.then((response) => {
if (response.data) {
const { status } = response.data;
const {status} = response.data;
if (status == 0) {
// console.log('--- success')
@ -372,7 +371,7 @@ class Newshixuns extends Component {
newFileList.splice(index, 1);
return {
fileList: newFileList,
deleteisnot:true
deleteisnot: true
};
});
}
@ -503,8 +502,8 @@ class Newshixuns extends Component {
>
<Option value={1}>初级</Option>
<Option value={2}>中级</Option>
<Option value={3}>高级</Option>
<Option value={4}></Option>
<Option value={3}>高级</Option>
<Option value={4}></Option>
</Select>
</div>
@ -567,7 +566,7 @@ class Newshixuns extends Component {
<div className=" fl pr mr20">
<Select placeholder="请选择小类别"
mode="multiple"
style={{width: 180}}
style={{width: 280}}
onChange={this.sub_type}
defaultOpen={false}
className={"Selectlittle"}
@ -589,12 +588,12 @@ class Newshixuns extends Component {
)}
<span className="fl ml20 color-grey lineh-20">
<div>
{this.state.mainvalues === undefined && this.state.subvalues === undefined||this.state.mainvalues === "" && this.state.subvalues === "" ? "" :
<div className={"font-12"} style={{'max-width':'700px'}}>
{`${this.state.mainvalues===undefined||this.state.mainvalues=== ""?"":`已安装软件:`+this.state.mainvalues}`}
{`${this.state.subvalues===undefined||this.state.subvalues=== ""?"":this.state.mainvalues===undefined||this.state.mainvalues=== ""?`已安装软件:`+this.state.subvalues:this.state.subvalues}`}
{`${this.state.mainvalues===undefined||this.state.mainvalues=== ""?"":`说明:添加了`+this.state.mainvalues}${this.state.subvalues===undefined||this.state.subvalues=== ""?"":
this.state.mainvalues===undefined||this.state.mainvalues=== ""?`说明:添加了`+this.state.subvalues:this.state.subvalues}`}
{this.state.mainvalues === undefined && this.state.subvalues === undefined || this.state.mainvalues === "" && this.state.subvalues === "" ? "" :
<div className={"font-12"} style={{'max-width': '600px'}}>
{`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : `已安装软件:` + this.state.mainvalues}`}
{`${this.state.subvalues === undefined || this.state.subvalues === "" ? "" : this.state.mainvalues === undefined || this.state.mainvalues === "" ? `已安装软件:` + this.state.subvalues : this.state.subvalues}`}
{`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : `说明:添加了` + this.state.mainvalues}${this.state.subvalues === undefined || this.state.subvalues === "" ? "" :
this.state.mainvalues === undefined || this.state.mainvalues === "" ? `说明:添加了` + this.state.subvalues : this.state.subvalues}`}
</div>}
</div>
@ -704,7 +703,7 @@ class Newshixuns extends Component {
</div>
</div>
</div>
<Bottomsubmit url={"/shixuns"} onSubmits={() => this.handleSubmit()}/>
<Bottomsubmit {...this.props} {...this.state} url={"/shixuns"} onSubmits={() => this.handleSubmit()}/>
</div>
);

@ -392,9 +392,9 @@ a.white-btn.use_scope-btn:hover{
border-color: #096dd9;
}
.ant-btn:hover, .ant-btn:focus, .ant-btn:active, .ant-btn.active{
background-color: #4CACFF;
}
/*.ant-btn:hover, .ant-btn:focus, .ant-btn:active, .ant-btn.active{*/
/* background-color: #4CACFF;*/
/*}*/
.newViewAfter .ant-input{
line-height: 40px !important;

@ -54,7 +54,7 @@ class Challengesjupyter extends Component {
}
}
}).catch((error) => {
console.log(error)
//console.log(error)
});
}
@ -74,8 +74,8 @@ class Challengesjupyter extends Component {
if (response.data.status === 403||response.data.status === 401||response.data.status === 500) {
}else{
// console.log("componentDidMountChallengesjupyter");
// console.log(response.data);
// //console.log("componentDidMountChallengesjupyter");
// //console.log(response.data);
if(response.data.status===0){
this.setState({
jupyter_url:response.data.url,
@ -88,7 +88,7 @@ class Challengesjupyter extends Component {
}
}
}).catch((error) => {
console.log(error)
//console.log(error)
});
@ -148,8 +148,8 @@ class Challengesjupyter extends Component {
};
modifyjupyter=()=>{
// console.log("propsysl");
// console.log(propsysl);
// //console.log("propsysl");
// //console.log(propsysl);
let id=this.props.match.params.shixunId;
var jupyter_port="";
try{
@ -173,12 +173,12 @@ class Challengesjupyter extends Component {
}
sendToken=()=>{
// console.log("sendToken");
// //console.log("sendToken");
// const iframe = document.getElementById('iframe');
// console.log("modifyjupyter");
// //console.log("modifyjupyter");
// const frameWindow = iframe.contentWindow;
// console.log("frameWindow");
// console.log(frameWindow);
// //console.log("frameWindow");
// //console.log(frameWindow);
}
render() {
@ -201,12 +201,12 @@ class Challengesjupyter extends Component {
// window.onload=()=>{
// debugger
// var _iframe = document.getElementById('header');
// console.log(_iframe);
// //console.log(_iframe);
// // .contentWindow.document.getElementById('shutdown_widget') //get iframe下的id
// // _iframe.style.display= "none"; //修改样式
// }
const is_teacher = this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false;
@ -257,16 +257,22 @@ class Challengesjupyter extends Component {
this.state.jupyter_url === null || this.state.jupyter_url === undefined ?
""
:
<div className="sortinxdirection mt60">
<div className="renwuxiangssi sortinxdirection">
<div><p className="renwuxiangqdiv">任务详情</p></div>
<div><p className="renwuxiangqdivtest ml24">请将实训题目写在下方</p></div>
</div>
<div className="renwuxiangssit xaxisreverseorder">
<div className="challenbaocun" onClick={() => this.modifyjupyter(this.state)}><p
className="challenbaocuntest">应用到实训</p></div>
</div>
</div>
(
is_teacher===true?
<div className="sortinxdirection mt60">
<div className="renwuxiangssi sortinxdirection">
<div><p className="renwuxiangqdiv">任务详情</p></div>
<div><p className="renwuxiangqdivtest ml24">请将实训题目写在下方</p></div>
</div>
<div className="renwuxiangssit xaxisreverseorder">
<div className="challenbaocun" onClick={() => this.modifyjupyter(this.state)}><p
className="challenbaocuntest">应用到实训</p></div>
</div>
</div>
:
""
)
}
<style>
@ -290,21 +296,25 @@ class Challengesjupyter extends Component {
`
}
</style>
<div className="mt35">
{/*https://48888.jupyter.educoder.net/tree?*/}
<div className="pb47">
{
this.state.jupyter_url===null || this.state.jupyter_url===undefined?
""
:
<iframe src={this.state.jupyter_url}
sandbox="allow-same-origin allow-scripts allow-top-navigation " scrolling="no" id="frame"
name="framename" width="100%" height="700" frameBorder="0"
></iframe>
}
</div>
</div>
{
is_teacher===true?
<div className="mt35">
{/*https://48888.jupyter.educoder.net/tree?*/}
<div className="pb47">
{
this.state.jupyter_url===null || this.state.jupyter_url===undefined?
""
:
<iframe src={this.state.jupyter_url}
sandbox="allow-same-origin allow-scripts allow-top-navigation " scrolling="no" id="frame"
name="framename" width="100%" height="700" frameBorder="0"
></iframe>
}
</div>
</div>
:""
}
</div>
</div>

@ -275,10 +275,10 @@ render() {
}
<div className="fl pr shaiAllItem mt1">
<li className={this.state.diff===0?"shaiItems shixun_repertoire active":"shaiItems shixun_repertoire"} onClick={()=>this.diff_search(0)}>全部难度</li>
<li className={this.state.diff===1?"shaiItems shixun_repertoire active":"shaiItems shixun_repertoire"} onClick={()=>this.diff_search(1)}>初级学员</li>
<li className={this.state.diff===2?"shaiItems shixun_repertoire active":"shaiItems shixun_repertoire"} onClick={()=>this.diff_search(2)}>中级学员</li>
<li className={this.state.diff===3?"shaiItems shixun_repertoire active":"shaiItems shixun_repertoire"} onClick={()=>this.diff_search(3)}>高级学员</li>
<li className={this.state.diff===4?"shaiItems shixun_repertoire active":"shaiItems shixun_repertoire"} onClick={()=>this.diff_search(4)}>顶级学员</li>
<li className={this.state.diff===1?"shaiItems shixun_repertoire active":"shaiItems shixun_repertoire"} onClick={()=>this.diff_search(1)}>初级</li>
<li className={this.state.diff===2?"shaiItems shixun_repertoire active":"shaiItems shixun_repertoire"} onClick={()=>this.diff_search(2)}>中级</li>
<li className={this.state.diff===3?"shaiItems shixun_repertoire active":"shaiItems shixun_repertoire"} onClick={()=>this.diff_search(3)}>高级</li>
<li className={this.state.diff===4?"shaiItems shixun_repertoire active":"shaiItems shixun_repertoire"} onClick={()=>this.diff_search(4)}>高级</li>
</div>
</div>

@ -329,6 +329,34 @@ class InfosShixun extends Component{
bottom: 100px;
}
.square-list{width: 100%;box-sizing: border-box;margin-top:10px}
.tag-org{
position: absolute;
left: 0px;
top: 20px;
}
.tag-org-name{
width:66px;
height:28px;
background:#FF6802;
width:66px;
height:28px;
border-radius:0px 20px 20px 0px;
}
.tag-org-name-test{
width:45px;
height:23px;
font-size:14px;
color:#FFFFFF;
line-height:19px;
margin-right: 6px;
}
.intermediatecenter{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
`
}
</style>
@ -350,6 +378,15 @@ class InfosShixun extends Component{
{/*<img className="fl" src={setImagesUrl("images/educoder/tag2.png")}/>*/}
</div>
}
{
item.is_jupyter===true?
<div className="tag-org">
<p className="tag-org-name intermediatecenter"> <span className="tag-org-name-test">Jupyter</span></p>
{/*<img style={{display:'block',height: '28px'}} src={require(`./shixunCss/tag2.png`)}/>*/}
</div>
:""}
<a href="javascript:void(0)" className="square-img">
<img src={setImagesUrl(`${item.image_url}`)}/>
</a>

Loading…
Cancel
Save