@ -1,29 +1,14 @@
import React , { Component } from 'react' ;
import {
Input ,
Select ,
Radio ,
Checkbox ,
Popconfirm ,
message ,
Modal ,
Icon ,
DatePicker ,
Breadcrumb ,
Upload ,
Button ,
notification ,
Tooltip ,
Tabs
} from 'antd' ;
import axios from 'axios' ;
import './css/TPMsettings.css' ;
import { getImageUrl , toPath , getUrl , appendFileSizeToUploadFileAll , getUploadActionUrl } from 'educoder' ;
import Bottomsubmit from "../../modals/Bottomsubmit" ;
const RadioGroup = Radio . Group ;
@ -32,144 +17,317 @@ const RadioGroup = Radio.Group;
export default class Shixuninformation extends Component {
constructor ( props ) {
super ( props )
this . state = { }
this . state = {
vnc : false ,
hide _code : false ,
is _secret _repository : false ,
code _hidden : false ,
forbid _copy : false ,
test _set _permission : true ,
task _pass : true ,
websshshow : false ,
multi _webssh : false ,
opensshRadio : null ,
loading : false
}
}
componentDidMount ( ) {
if ( this . props . data ) {
if ( this . props . data && this . props . data . shixun ) {
this . setState ( {
vnc : this . props . data && this . props . data . shixun . vnc ,
use _scope : this . props . data && this . props . data . shixun . use _scope ,
opening _time : this . props . data && this . props . data . shixun . opening _time ,
opentime : ! this . props . data && this . props . data . shixun . opening _time ? false : true ,
oldscope _partment : this . props . data && this . props . data . shixun . scope _partment ,
code _hidden : this . props . data && this . props . data . shixun . code _hidden ,
forbid _copy : this . props . data && this . props . data . shixun . forbid _copy ,
hide _code : this . props . data && this . props . data . shixun . hide _code ,
task _pass : this . props . data && this . props . data . shixun . task _pass ,
test _set _permission : this . props . data && this . props . data . shixun . test _set _permission ,
is _secret _repository : this . props . data && this . props . data . shixun . is _secret _repository ,
websshshow : this . props . data && this . props . data . shixun . webssh === 0 ? false : true ,
multi _webssh : this . props . data && this . props . data . shixun . multi _webssh ,
opensshRadio : this . props . data && this . props . data . shixun . webssh === 0 ? null : this . props . data && this . props . data . shixun . webssh ,
} )
// if(this.props.data && this.props.data.shixun.status===0){
// this.setState({
// task_pass:true
// })
// }
}
}
componentDidUpdate ( prevProps , prevState ) {
if ( prevProps . data != this . props . data ) {
if ( this . props . data ) {
this . setState ( {
vnc : this . props . data && this . props . data . shixun . vnc ,
code _hidden : this . props . data && this . props . data . shixun . code _hidden ,
forbid _copy : this . props . data && this . props . data . shixun . forbid _copy ,
hide _code : this . props . data && this . props . data . shixun . hide _code ,
task _pass : this . props . data && this . props . data . shixun . task _pass ,
test _set _permission : this . props . data && this . props . data . shixun . test _set _permission ,
is _secret _repository : this . props . data && this . props . data . shixun . is _secret _repository ,
websshshow : this . props . data && this . props . data . shixun . webssh === 0 ? false : true ,
multi _webssh : this . props . data && this . props . data . shixun . multi _webssh ,
opensshRadio : this . props . data && this . props . data . shixun . webssh === 0 ? null : this . props . data && this . props . data . shixun . webssh ,
} )
// if(this.props.data && this.props.data.shixun.status===0){
// this.setState({
// task_pass:true
// })
// }
}
}
let departmentsUrl = ` /shixuns/departments.json ` ;
axios . get ( departmentsUrl ) . then ( ( response ) => {
if ( response . status === 200 ) {
if ( response . data . message === undefined ) {
this . setState ( {
departmentslist : response . data . shools _name
} ) ;
}
}
onSubmits = ( ) => {
this . setState ( {
loading : true
} )
let id = this . props . match . params . shixunId ;
let url = ` /shixuns/ ${ id } /update_permission_setting.json ` ;
axios . post ( url ,
{
shixun : {
code _hidden : this . state . code _hidden ,
forbid _copy : this . state . forbid _copy ,
hide _code : this . state . hide _code ,
multi _webssh : this . state . multi _webssh ,
task _pass : this . state . task _pass ,
test _set _permission : this . state . test _set _permission ,
vnc : this . state . vnc ,
webssh : this . state . websshshow === false ? 0 : this . state . opensshRadio ,
} ,
is _secret _repository : this . state . is _secret _repository
}
) . then ( ( response ) => {
if ( response . data . status === - 1 ) {
} else {
this . props . getdatas ( )
this . props . showNotification ( "学习页面设置保存成功!" )
this . setState ( {
loading : false
} )
}
} ) . catch ( ( error ) => {
console . log ( error )
} ) ;
this . setState ( {
loading : false
} )
} )
}
Checkvnc = ( ) => {
console . log ( this . state . vnc )
if ( this . state . vnc === false ) {
this . setState ( {
hide _code : false ,
is _secret _repository : false ,
code _hidden : false ,
forbid _copy : false ,
multi _webssh : false ,
websshshow : false ,
} )
}
this . setState ( {
vnc : ! this . state . vnc
} )
}
Checkhide _code = ( ) => {
if ( this . state . hide _code === false ) {
this . setState ( {
is _secret _repository : false
} )
}
this . setState ( {
hide _code : ! this . state . hide _code
} )
}
Checkis _secret _repository = ( ) => {
this . setState ( {
is _secret _repository : ! this . state . is _secret _repository
} )
}
Checkcode _hidden = ( ) => {
this . setState ( {
code _hidden : ! this . state . code _hidden
} )
}
Checkforbid _copy = ( ) => {
this . setState ( {
forbid _copy : ! this . state . forbid _copy
} )
}
Checktask _pass = ( ) => {
this . setState ( {
task _pass : ! this . state . task _pass
} )
}
Checktest _set _permission = ( ) => {
this . setState ( {
test _set _permission : ! this . state . test _set _permission
} )
}
Checkwebsshshow = ( ) => {
if ( this . state . websshshow === false ) {
this . setState ( {
vnc : false ,
opensshRadio : 1
} )
} else {
this . setState ( {
multi _webssh : false ,
opensshRadio : null
} )
}
this . setState ( {
websshshow : ! this . state . websshshow
} )
}
Checkmulti _webssh = ( ) => {
this . setState ( {
multi _webssh : ! this . state . multi _webssh
} )
}
opensshRadio = ( e ) => {
if ( e . target . value === 1 ) {
this . setState ( {
multi _webssh : false
} )
} else {
this . setState ( {
multi _webssh : true
} )
}
this . setState ( {
opensshRadio : e . target . value
} ) ;
}
render ( ) {
console . log ( this . props )
return (
< div >
< div className = "educontent mb200 edu-back-white padding10-20 pdb30" >
< div className = "educontent mb200 edu-back-white padding10-20 pdb30 mb50 ">
< div className = "clearfix mb20" >
{ this . state . websshshow === true ? "" : < div className = "clearfix mb20" >
< span className = "color-grey-6 mt5 fl font-16" style = { { minWidth : '45px' } } > 开启图形化界面 : < / s p a n >
< span className = "fl mt8" >
< Checkbox
checked = { this . state . can _copy }
onChange = { this . CheckboxonChange } > < / C h e c k b o x >
checked = { this . state . vnc }
onChange = { this . Check vnc } > < / C h e c k b o x >
< label style = { { top : '6px' } } className = "color-grey-9 ml10" > ( 选中则给学员的实践任务启动Ubuntu系统的图形化界面 ) < / l a b e l >
< / s p a n >
< / d i v >
< / d i v > }
< div className = "clearfix mb20" >
{ this . state . vnc === true ? "" : < div className = "clearfix mb20" >
< span className = "color-grey-6 mt5 fl font-16 ml64" style = { { minWidth : '45px' } } > 命令行 : < / s p a n >
< span className = "fl mt8" >
< Checkbox
checked = { this . state . can _copy }
onChange = { this . CheckboxonChange } > < / C h e c k b o x >
checked = { this . state . websshshow }
onChange = { this . Check websshshow } > < / C h e c k b o x >
< label style = { { top : '6px' } } className = "color-grey-9 ml10" > ( 选中则给学员的实践任务提供命令行窗口 ) < / l a b e l >
< / s p a n >
< / d i v >
< / d i v > }
< div >
{ this . state . vnc === true ? "" : this . state . websshshow === true ? < div >
< span className = "fl ml160" >
< RadioGroup onChange = { this . SelectOpenpublic } value = { this . state . use _scope } >
< Radio className = "radioStyle font-14" value = { 0 } > < span > 命令行练习窗口 < / s p a n > < s p a n
< RadioGroup onChange = { this . opensshRadio} value = { this . state . opensshRadio } >
< Radio className = "radioStyle font-14" value = { 1 } > < span > 命令行练习窗口 < / s p a n > < s p a n
className = "color-grey-9" > ( 选中则给学员提供用于练习操作的命令行 , 命令行的操作不会对学生的实验环境造成影响 ) < / s p a n > < / R a d i o >
< Radio className = "radioStyle font-14" value = { 1 } > < span > 命令行评测窗口 < / s p a n > < s p a n
< Radio className = "radioStyle font-14" value = { 2 } > < span > 命令行评测窗口 < / s p a n > < s p a n
className = "color-grey-9" > ( 选中则给学员提供用于评测操作的命令行 , 命令行的操作可以对学生的实验环境产生影响 ) < / s p a n > < / R a d i o >
< / R a d i o G r o u p >
< / s p a n >
< span className = "fl ml180" >
{ this . state . opensshRadio === 2 ? < span className = "fl ml180" >
< div className = "clearfix mb20" >
< span className = "fl mt8 ml5" >
< Checkbox
checked = { this . state . can _copy }
onChange = { this . CheckboxonChange } > < / C h e c k b o x >
checked = { this . state . multi_webssh }
onChange = { this . Check multi_webssh } > < / C h e c k b o x >
< label style = { { top : '6px' } } className = "color-grey-9 ml10" >
< span className = "color-grey-6 font-14" style = { { minWidth : '45px' } } > 多个命令行窗口 : < / s p a n >
( 选中则允许学员同时开启多个命令行窗口 ) < / l a b e l >
< / s p a n >
< / d i v >
< / s p a n >
< / d i v >
< / s p a n > : " " }
< / d i v > : " " }
< div className = "clearfix mb20" >
{ this . state . vnc === true ? "" : < div className = "clearfix mb20" >
< span className = "color-grey-6 mt5 fl font-16 ml17" style = { { minWidth : '45px' } } > 隐藏代码窗口 : < / s p a n >
< span className = "fl mt8" >
< Checkbox
checked = { this . state . can_copy }
onChange = { this . Check boxonChang e} > < / C h e c k b o x >
checked = { this . state . hide_code }
onChange = { this . Check hide_cod e} > < / C h e c k b o x >
< label style = { { top : '6px' } } className = "color-grey-9 ml10" > ( 选中则学员页面不显示代码窗口 ) < / l a b e l >
< / s p a n >
< / d i v >
< / d i v > }
< div className = "clearfix mb20" >
{ this . state . vnc === true || this . state . hide _code === true ? "" : < div className = "clearfix mb20" >
< span className = "color-grey-6 mt5 fl font-16 ml33" style = { { minWidth : '45px' } } > 公开版本库 : < / s p a n >
< span className = "fl mt8" >
< Checkbox
checked = { this . state . can_cop y}
onChange = { this . Check boxonChange } > < / C h e c k b o x >
checked = { this . state . is_secret _repositor y}
onChange = { this . Check is_secret _repository } > < / C h e c k b o x >
< label style = { { top : '6px' } } className = "color-grey-9 ml10" > ( 选中则允许学员修改版本库中的全部文件 ) < / l a b e l >
< / s p a n >
< / d i v >
< / d i v > }
< div className = "clearfix mb20" >
< span className = "color-grey-6 mt5 fl font-16 ml 20 " style = { { minWidth : '45px' } } > 隐藏代码目录 : < / s p a n >
{ this . state . vnc === true ? "" : < div className = "clearfix mb20" >
< span className = "color-grey-6 mt5 fl font-16 ml 17 " style = { { minWidth : '45px' } } > 隐藏代码目录 : < / s p a n >
< span className = "fl mt8" >
< Checkbox
checked = { this . state . c an_copy }
onChange = { this . Check boxonChange } > < / C h e c k b o x >
checked = { this . state . c ode_hidden }
onChange = { this . Check code_hidden } > < / C h e c k b o x >
< label style = { { top : '6px' } } className = "color-grey-9 ml10" > ( 选中则学员页面不显示版本库目录 ) < / l a b e l >
< / s p a n >
< / d i v >
< / d i v > }
< div className = "clearfix mb20" >
< span className = "color-grey-6 mt5 fl font-16 ml 20 " style = { { minWidth : '45px' } } > 禁用复制粘贴 : < / s p a n >
{ this . state . vnc === true ? "" : < div className = "clearfix mb20" >
< span className = "color-grey-6 mt5 fl font-16 ml 17 " style = { { minWidth : '45px' } } > 禁用复制粘贴 : < / s p a n >
< span className = "fl mt8" >
< Checkbox
checked = { this . state . can _copy }
onChange = { this . Check boxonChange } > < / C h e c k b o x >
checked = { this . state . forbid _copy }
onChange = { this . Check forbid_copy } > < / C h e c k b o x >
< label style = { { top : '6px' } } className = "color-grey-9 ml10" > ( 选中则学员页面不允许使用复制和粘贴功能 ) < / l a b e l >
< / s p a n >
< / d i v >
< / d i v > }
< div className = "clearfix mb20" >
< span className = "color-grey-6 mt5 fl font-16 ml8 4 " style = { { minWidth : '45px' } } > 跳关 : < / s p a n >
< span className = "color-grey-6 mt5 fl font-16 ml8 0 " style = { { minWidth : '45px' } } > 跳关 : < / s p a n >
< span className = "fl mt8" >
< Checkbox
checked = { this . state . can_copy }
onChange = { this . Check boxonChange } > < / C h e c k b o x >
checked = { this . state . task_pass }
onChange = { this . Check task_pass } > < / C h e c k b o x >
< label style = { { top : '6px' } } className = "color-grey-9 ml10" > ( 选中则允许学员跳关学习实训关卡任务 ) < / l a b e l >
< / s p a n >
< / d i v >
< div className = "clearfix mb20" >
< span className = "color-grey-6 mt5 fl font-16 ml3 6 s" style = { { minWidth : '45px' } } > 测试集解锁 : < / s p a n >
< span className = "color-grey-6 mt5 fl font-16 ml3 2 s" style = { { minWidth : '45px' } } > 测试集解锁 : < / s p a n >
< span className = "fl mt8" >
< Checkbox
checked = { this . state . can_copy }
onChange = { this . Check boxonChange } > < / C h e c k b o x >
checked = { this . state . test_set _permission }
onChange = { this . Check test_set _permission } > < / C h e c k b o x >
< label style = { { top : '6px' } } className = "color-grey-9 ml10" > ( 选中则允许学员允许学员通过金币解锁查看隐藏测试集的内容 ) < / l a b e l >
< / s p a n >
< / d i v >
@ -179,7 +337,7 @@ export default class Shixuninformation extends Component {
{ this . props . identity < 5 ?
< Bottomsubmit { ... this . props } { ... this . state } url = { ` /shixuns/ ${ this . props . match . params . shixunId } /challenges ` }
onSubmits = { this . onSubmits } / > : "" }
onSubmits = { this . onSubmits } loadings = { this . state . loading } / > : "" }
< / d i v >
) ;
}