|
|
|
@ -12,7 +12,7 @@ import { getImageUrl ,markdownToHTML} from 'educoder'
|
|
|
|
|
|
|
|
|
|
import { CircularProgress } from 'material-ui/Progress';
|
|
|
|
|
|
|
|
|
|
import { Modal, Spin, Tooltip ,message} from 'antd';
|
|
|
|
|
import { Modal, Spin, Tooltip ,message,Icon} from 'antd';
|
|
|
|
|
|
|
|
|
|
import 'antd/lib/pagination/style/index.css';
|
|
|
|
|
|
|
|
|
@ -35,7 +35,8 @@ class Challenges extends Component {
|
|
|
|
|
shixunsreplace:false,
|
|
|
|
|
shixunsmessage:"",
|
|
|
|
|
hidestartshixunsreplacevalue:"",
|
|
|
|
|
operationstrue:false
|
|
|
|
|
operationstrue:false,
|
|
|
|
|
isSpin:false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -154,33 +155,76 @@ class Challenges extends Component {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startgameid=(id)=>{
|
|
|
|
|
|
|
|
|
|
let url = "/shixuns/" + id + "/shixun_exec.json";
|
|
|
|
|
axios.get(url).then((response) => {
|
|
|
|
|
|
|
|
|
|
if (response.data.status === -2) {
|
|
|
|
|
this.setState({
|
|
|
|
|
shixunsreplace:true,
|
|
|
|
|
hidestartshixunsreplacevalue:response.data.message+".json"
|
|
|
|
|
})
|
|
|
|
|
} else if (response.data.status === -1) {
|
|
|
|
|
console.log(response)
|
|
|
|
|
}else if(response.data.status===-3){
|
|
|
|
|
this.setState({
|
|
|
|
|
shixunsmessage:response.data.message,
|
|
|
|
|
startshixunCombattype:true,
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
window.location.href = "/tasks/" + response.data.game_identifier;
|
|
|
|
|
// window.location.href = path
|
|
|
|
|
// let path="/tasks/"+response.data.game_identifier;
|
|
|
|
|
// this.props.history.push(path);
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hidestartshixunsreplace=(url)=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
isSpin:true,
|
|
|
|
|
})
|
|
|
|
|
axios.get(url).then((response) => {
|
|
|
|
|
if(response.status===200){
|
|
|
|
|
let path="/shixuns/"+response.data.shixun_identifier+"/challenges";
|
|
|
|
|
this.props.history.push(path);
|
|
|
|
|
// let path="/shixuns/"+response.data.shixun_identifier+"/challenges";
|
|
|
|
|
// this.props.history.push(path);
|
|
|
|
|
message.success('重置成功,正在进入实训!');
|
|
|
|
|
this.startgameid(response.data.shixun_identifier);
|
|
|
|
|
this.setState({
|
|
|
|
|
shixunsreplace:false
|
|
|
|
|
shixunsreplace:false,
|
|
|
|
|
isSpin:false,
|
|
|
|
|
})
|
|
|
|
|
message.success('重置成功,请继续!');
|
|
|
|
|
|
|
|
|
|
// message.success('重置成功,正在进入实训!');
|
|
|
|
|
// this.startshixunCombat();
|
|
|
|
|
}}
|
|
|
|
|
).catch((error) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
startbtns:false,
|
|
|
|
|
shixunsreplace:false
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//编辑实训题目选择题
|
|
|
|
|
EditTraining=(type, ids, path)=>{
|
|
|
|
|
let { ChallengesDataList } = this.state;
|
|
|
|
|
window.location.href = "/shixuns/" + ChallengesDataList.shixun_identifier + "/challenges/" + ids + path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//开始实战按钮
|
|
|
|
|
startshixunCombat = (type, ids, path) => {
|
|
|
|
|
startshixunCombat = (type, ids, id) => {
|
|
|
|
|
|
|
|
|
|
let { ChallengesDataList } = this.state;
|
|
|
|
|
if(path===null){
|
|
|
|
|
let id = this.props.match.params.shixunId;
|
|
|
|
|
// let id = this.props.match.params.shixunId;
|
|
|
|
|
this.setState({
|
|
|
|
|
startbtns: true
|
|
|
|
|
})
|
|
|
|
|
let url = "/shixuns/" + id + "/shixun_exec.json";
|
|
|
|
|
let url = "/shixuns/" + ChallengesDataList.shixun_identifier + "/shixun_exec.json?challenge_id="+id;
|
|
|
|
|
axios.get(url).then((response) => {
|
|
|
|
|
|
|
|
|
|
if (response.data.status === -2) {
|
|
|
|
@ -190,6 +234,9 @@ class Challenges extends Component {
|
|
|
|
|
hidestartshixunsreplacevalue:response.data.message+".json"
|
|
|
|
|
})
|
|
|
|
|
} else if (response.data.status === -1) {
|
|
|
|
|
this.setState({
|
|
|
|
|
startbtns: false
|
|
|
|
|
})
|
|
|
|
|
console.log(response)
|
|
|
|
|
}else if(response.data.status===-3){
|
|
|
|
|
this.setState({
|
|
|
|
@ -204,17 +251,18 @@ class Challenges extends Component {
|
|
|
|
|
// this.props.history.push(path);
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
startbtns: false
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
if (type > 4 || type === false) {
|
|
|
|
|
window.location.href = path;
|
|
|
|
|
} else {
|
|
|
|
|
window.location.href = "/shixuns/" + ChallengesDataList.shixun_identifier + "/challenges/" + ids + path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if(path===null){
|
|
|
|
|
// }else{
|
|
|
|
|
// if (type > 4 || type === false) {
|
|
|
|
|
// window.location.href = path;
|
|
|
|
|
// } else {
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -230,6 +278,7 @@ class Challenges extends Component {
|
|
|
|
|
this.updatamakedown("ReactMarkdown")
|
|
|
|
|
}
|
|
|
|
|
let id = this.props.match.params.shixunId;
|
|
|
|
|
const antIcon = <Icon type="loading" style={{ fontSize: 24 }} spin />;
|
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
{loadingContent ?
|
|
|
|
@ -340,10 +389,10 @@ class Challenges extends Component {
|
|
|
|
|
|
|
|
|
|
{this.props.identity<5?
|
|
|
|
|
item.st === 1 ?
|
|
|
|
|
<a onClick={() => this.startshixunCombat(this.props.identity, item.challenge_id, "/editquestion")}
|
|
|
|
|
<a onClick={() => this.EditTraining(this.props.identity, item.challenge_id, "/editquestion")}
|
|
|
|
|
className="font-16 color05101a">{item.name}</a>
|
|
|
|
|
:
|
|
|
|
|
<a onClick={() => this.startshixunCombat(this.props.identity, item.challenge_id, "/editcheckpoint")}
|
|
|
|
|
<a onClick={() => this.EditTraining(this.props.identity, item.challenge_id, "/editcheckpoint")}
|
|
|
|
|
className="font-16 color05101a">{item.name}</a>:<span
|
|
|
|
|
// onClick={() => this.startshixunCombat(this.props.identity, item.challenge_id, "/editcheckpoint")}
|
|
|
|
|
className="font-16 color05101a">{item.name}</span>
|
|
|
|
@ -431,7 +480,7 @@ class Challenges extends Component {
|
|
|
|
|
{/*判断比较复杂 有排第一不能是灰色按钮*/}
|
|
|
|
|
{item.status === 2 ?
|
|
|
|
|
<a className="edu-default-btn edu-blueline-btn fr Finish_button mtf3"
|
|
|
|
|
onClick={() => this.startshixunCombat(false,undefined, item.open_game)}
|
|
|
|
|
onClick={() => this.startshixunCombat(false,undefined, item.challenge_id)}
|
|
|
|
|
// onClick={() => this.startshixunCombat(false)}
|
|
|
|
|
>已完成</a> : ""
|
|
|
|
|
}
|
|
|
|
@ -440,7 +489,7 @@ class Challenges extends Component {
|
|
|
|
|
ChallengesDataList.allow_skip === true && item.status === 1?
|
|
|
|
|
<a className="edu-default-btn edu-blueback-btn fr Finish_button"
|
|
|
|
|
style={{marginTop: '-2px'}}
|
|
|
|
|
onClick={() => this.startshixunCombat(false,undefined, item.open_game)}
|
|
|
|
|
onClick={() => this.startshixunCombat(false,undefined, item.challenge_id)}
|
|
|
|
|
// onClick={() => this.startshixunCombat(false)}
|
|
|
|
|
>直接挑战</a> : ""
|
|
|
|
|
}
|
|
|
|
@ -451,14 +500,14 @@ class Challenges extends Component {
|
|
|
|
|
ChallengesDataList.allow_skip === false ? item.status === 1 && newstatus === 2 ?
|
|
|
|
|
<Tooltip placement="bottom" title={item.open_game!=""?"直接挑战":"请先完成前序关卡"}>
|
|
|
|
|
<a className={item.open_game!=""?"edu-default-btn edu-blueback-btn fr Finish_button":"edu-default-btn edu-greyback-btn fr Finish_button"}
|
|
|
|
|
onClick={item.open_game!=""?()=>this.startshixunCombat(false,undefined, item.open_game):""}
|
|
|
|
|
onClick={item.open_game!=""?()=>this.startshixunCombat(false,undefined, item.challenge_id):""}
|
|
|
|
|
style={{marginTop: '-2px'}}>直接挑战</a>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
|
|
: item.status === 1 && newstatus === 1 ?
|
|
|
|
|
<Tooltip placement="bottom" title={this.props.identity<5?"直接挑战":"请先完成前序关卡"}>
|
|
|
|
|
<a className={this.props.identity<5&&item.open_game!=""?"edu-default-btn edu-blueback-btn fr Finish_button":"edu-default-btn edu-greyback-btn fr Finish_button"}
|
|
|
|
|
onClick={this.props.identity<5&&item.open_game!=""?()=>this.startshixunCombat(false,undefined, item.open_game):""}
|
|
|
|
|
onClick={this.props.identity<5&&item.open_game!=""?()=>this.startshixunCombat(false,undefined, item.challenge_id):""}
|
|
|
|
|
style={{marginTop: '-2px'}}>直接挑战</a>
|
|
|
|
|
</Tooltip> : "" : ""
|
|
|
|
|
|
|
|
|
@ -469,7 +518,7 @@ class Challenges extends Component {
|
|
|
|
|
item.status === 0 ?
|
|
|
|
|
<Tooltip placement="bottom" title={this.props.identity<5&&item.open_game!=""?"直接挑战":"请先完成前序关卡"}>
|
|
|
|
|
<a className={this.props.identity<5&&item.open_game!=""?"edu-default-btn edu-blueback-btn fr Finish_button":"edu-default-btn edu-greyback-btn fr Finish_button"}
|
|
|
|
|
onClick={this.props.identity<5&&item.open_game!=""?()=>this.startshixunCombat(false,undefined, item.open_game):""}
|
|
|
|
|
onClick={this.props.identity<5&&item.open_game!=""?()=>this.startshixunCombat(false,undefined, item.challenge_id):""}
|
|
|
|
|
style={{marginTop: '-2px'}}>直接挑战</a>
|
|
|
|
|
</Tooltip>: ""
|
|
|
|
|
}
|
|
|
|
@ -530,12 +579,15 @@ class Challenges extends Component {
|
|
|
|
|
closable={false}
|
|
|
|
|
footer={null}
|
|
|
|
|
>
|
|
|
|
|
<Spin indicator={antIcon} spinning={this.state.isSpin}>
|
|
|
|
|
<div className="task-popup-content">
|
|
|
|
|
<p className="task-popup-text-center font-16 pb20">实训已经更新了,正在为您重置!</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="task-popup-submit clearfix">
|
|
|
|
|
<a className="task-btn task-btn-orange fr mr51" onClick={()=>this.hidestartshixunsreplace(hidestartshixunsreplacevalue)}>知道了</a>
|
|
|
|
|
<a className="task-btn task-btn-orange fr mr51"
|
|
|
|
|
onClick={() => this.hidestartshixunsreplace(hidestartshixunsreplacevalue)}>知道了</a>
|
|
|
|
|
</div>
|
|
|
|
|
</Spin>
|
|
|
|
|
</Modal>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|