|
|
|
@ -1,48 +1,21 @@
|
|
|
|
|
import React, {Component} from 'react';
|
|
|
|
|
|
|
|
|
|
import {Input, InputNumber, Select, Radio, Checkbox, Popconfirm, message, Modal, Tooltip} from 'antd';
|
|
|
|
|
import {Input, InputNumber, Button, Tooltip} from 'antd';
|
|
|
|
|
|
|
|
|
|
import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom";
|
|
|
|
|
|
|
|
|
|
// import "antd/dist/antd.css";
|
|
|
|
|
|
|
|
|
|
import { getImageUrl, toPath, getUrl } from 'educoder';
|
|
|
|
|
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
|
|
|
|
import './css/TPMchallengesnew.css';
|
|
|
|
|
|
|
|
|
|
import TPMMDEditor from './TPMMDEditor';
|
|
|
|
|
|
|
|
|
|
import Bottomsubmit from "../../modals/Bottomsubmit";
|
|
|
|
|
|
|
|
|
|
let origin = getUrl();
|
|
|
|
|
|
|
|
|
|
let path = getUrl("/editormd/lib/")
|
|
|
|
|
import './css/TPMchallengesnew.css';
|
|
|
|
|
|
|
|
|
|
const $ = window.$;
|
|
|
|
|
|
|
|
|
|
let timeout;
|
|
|
|
|
|
|
|
|
|
let currentValue;
|
|
|
|
|
|
|
|
|
|
const Option = Select.Option;
|
|
|
|
|
|
|
|
|
|
const RadioGroup = Radio.Group;
|
|
|
|
|
|
|
|
|
|
// const testAnswers = [{
|
|
|
|
|
// "id": 4337,
|
|
|
|
|
// "name": "解题思路1",
|
|
|
|
|
// "contents": "答案的解题思路1",
|
|
|
|
|
// "level": 1,
|
|
|
|
|
// "score": 25
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 4338,
|
|
|
|
|
// "name": "解题思路2",
|
|
|
|
|
// "contents": "答案的解题思路2",
|
|
|
|
|
// "level": 2,
|
|
|
|
|
// "score": 25
|
|
|
|
|
// }]
|
|
|
|
|
export default class TPManswer extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props)
|
|
|
|
@ -94,7 +67,7 @@ export default class TPManswer extends Component {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
answer:response.data.answer,
|
|
|
|
|
answer:response.data.answer,
|
|
|
|
|
power: response.data.power,
|
|
|
|
|
choice_url: newchoice_url, // 导航中的新建选择题url
|
|
|
|
|
practice_url: newpractice_url, //string 导航中新建实践题url
|
|
|
|
@ -102,10 +75,11 @@ export default class TPManswer extends Component {
|
|
|
|
|
position: response.data.position, //int 关卡位置,导航栏中的第几关
|
|
|
|
|
prev_challenge: newprev_challenge,
|
|
|
|
|
next_challenge: next_challenge,
|
|
|
|
|
responsedata:response.data,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if(response.data.power===false){
|
|
|
|
|
this.props.showSnackbar("没有权限修改");
|
|
|
|
|
this.props.showNotification("没有权限修改");
|
|
|
|
|
}
|
|
|
|
|
// if(response.data.answer===undefined||response.data.answer===null){
|
|
|
|
|
// this.answerMD("", "answerMD");
|
|
|
|
@ -133,7 +107,7 @@ export default class TPManswer extends Component {
|
|
|
|
|
// this.refs.md0
|
|
|
|
|
const { answers } = this.state;
|
|
|
|
|
const answersParams = answers.slice(0)
|
|
|
|
|
console.log(answersParams)
|
|
|
|
|
// console.log(answersParams)
|
|
|
|
|
let isValidate = true;
|
|
|
|
|
let totalScore = 0;
|
|
|
|
|
answersParams.forEach( (item, index) => {
|
|
|
|
@ -147,10 +121,10 @@ export default class TPManswer extends Component {
|
|
|
|
|
totalScore += item.score;
|
|
|
|
|
delete item.id;
|
|
|
|
|
if (!item.name) {
|
|
|
|
|
this.props.showSnackbar("请先填写参考答案名称");
|
|
|
|
|
this.props.showNotification("请先填写参考答案名称");
|
|
|
|
|
isValidate = false;
|
|
|
|
|
} else if (!mdContnet) {
|
|
|
|
|
this.props.showSnackbar("请先填写参考答案内容");
|
|
|
|
|
this.props.showNotification("请先填写参考答案内容");
|
|
|
|
|
isValidate = false;
|
|
|
|
|
}
|
|
|
|
|
if (!isValidate) {
|
|
|
|
@ -161,7 +135,7 @@ export default class TPManswer extends Component {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (answersParams.length != 0 && totalScore != 100) {
|
|
|
|
|
this.props.showSnackbar("请先保证占比和为100%");
|
|
|
|
|
this.props.showNotification("请先保证占比和为100%");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let id = this.props.match.params.shixunId;
|
|
|
|
@ -174,7 +148,7 @@ export default class TPManswer extends Component {
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if (response.data) {
|
|
|
|
|
if (response.data.message) {
|
|
|
|
|
this.props.showSnackbar(response.data.message);
|
|
|
|
|
this.props.showNotification(response.data.message);
|
|
|
|
|
}
|
|
|
|
|
if (response.data.status == 1) {
|
|
|
|
|
window.location.href=`/shixuns/${id}/challenges`;
|
|
|
|
@ -233,12 +207,16 @@ export default class TPManswer extends Component {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gotocheckpoint=(url)=>{
|
|
|
|
|
this.props.history.replace(url);
|
|
|
|
|
}
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
|
|
let {
|
|
|
|
|
choice_url,
|
|
|
|
|
practice_url,
|
|
|
|
|
go_back_url,
|
|
|
|
|
responsedata,
|
|
|
|
|
position,
|
|
|
|
|
task_pass_default,
|
|
|
|
|
submit_url,
|
|
|
|
@ -256,60 +234,51 @@ export default class TPManswer extends Component {
|
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<div className="educontent mt30 mb30 tpmAnswer">
|
|
|
|
|
<div className="padding10-20 mb10 edu-back-white clearfix">
|
|
|
|
|
<span className="fl ring-blue mr10 mt7">
|
|
|
|
|
<img src={getImageUrl("images/educoder/icon/code.svg")} data-tip-down="实训任务" className="fl mt2 ml2"/>
|
|
|
|
|
</span>
|
|
|
|
|
<span className="font-16 task-hide fl TPMtaskName">第{position}关</span>
|
|
|
|
|
<Link to={go_back_url === undefined ? "" : go_back_url}
|
|
|
|
|
className="color-grey-6 fr font-15 mt3">返回</Link>
|
|
|
|
|
|
|
|
|
|
{prev_challenge === undefined ? "" :
|
|
|
|
|
<a href={prev_challenge} className="fr color-blue mr15 mt4">上一关</a>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{next_challenge === undefined ? "" :
|
|
|
|
|
<a href={next_challenge} className="fr color-blue mr15 mt4">下一关</a>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<a href={practice_url === undefined ? "" : practice_url}
|
|
|
|
|
className="fr color-blue mr15 mt4"
|
|
|
|
|
style={{display:this.props.status===2||this.props.status===1?'none':'block'}}
|
|
|
|
|
data-tip-down="新增代码编辑类型的任务">+ 实践类型</a>
|
|
|
|
|
<a href={choice_url === undefined ? "" : choice_url}
|
|
|
|
|
className="fr color-blue mr15 mt4"
|
|
|
|
|
style={{display:this.props.status===2||this.props.status===1?'none':'block'}}
|
|
|
|
|
data-tip-down="新增选择题类型的任务">+ 选择题类型</a>
|
|
|
|
|
|
|
|
|
|
<div className="TPMchallengesnewtitles edu-back-white clearfix borderbottomf4">
|
|
|
|
|
<span className="font-16 task-hide fl TPMtaskName">第{position}关:{responsedata&&responsedata.st === 0 ?"实践题":responsedata&&responsedata.st === 1?"选择题":""}</span>
|
|
|
|
|
{this.props.identity>4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"":<a href={practice_url === undefined ? "" : practice_url} className="fr ml15 mt13">
|
|
|
|
|
<Button type="primary" className="edu-default-btn edu-greenback-btn "
|
|
|
|
|
>新增实践任务</Button></a>}
|
|
|
|
|
{this.props.identity>4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"":<Link to={choice_url === undefined ? "" : choice_url}
|
|
|
|
|
className="fr ml15 mt13">
|
|
|
|
|
<Button type="primary"
|
|
|
|
|
className="edu-default-btn edu-greenback-btn mr5"
|
|
|
|
|
>新增选择题任务</Button></Link>}
|
|
|
|
|
{next_challenge===undefined?"":
|
|
|
|
|
<Button type="primary" ghost onClick={()=>this.gotocheckpoint(next_challenge)}
|
|
|
|
|
className="edu-default-btn edu-greenback-btn mr5 fr ml15 mt13"
|
|
|
|
|
>下一关</Button> }
|
|
|
|
|
{prev_challenge===undefined?"":
|
|
|
|
|
<Button type="primary" ghost onClick={()=>this.gotocheckpoint(prev_challenge)}
|
|
|
|
|
className="edu-default-btn edu-greenback-btn mr5 fr ml15 mt13"
|
|
|
|
|
>上一关</Button>}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="challenge_nav clearfix edu-back-white">
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
|
|
<Link to={tab1url}>本关任务</Link>
|
|
|
|
|
<Link to={tab1url}>1、本关任务 </Link>
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
{tab2url === "" ? "":<li> > </li>}
|
|
|
|
|
<li >
|
|
|
|
|
<Link to={tab2url}>评测设置</Link>
|
|
|
|
|
<Link to={tab2url} >2、评测设置</Link>
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
{tab3url === "" ? "":<li> > </li>}
|
|
|
|
|
<li className="active">
|
|
|
|
|
<Link to={tab3url}>参考答案</Link>
|
|
|
|
|
<Link to={tab3url} className={"color-blue"}> 3、参考答案</Link>
|
|
|
|
|
</li>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="edu-back-white mb10 clearfix">
|
|
|
|
|
|
|
|
|
|
<div className="padding30-20">
|
|
|
|
|
<p className=" font-12" style={{ paddingBottom: '5px'
|
|
|
|
|
, color: '#666666'}}>
|
|
|
|
|
可以将参考答案分级设置,让学员自行选择级别,每级查看后按照比例扣分值(学员已完成任务再查看,则不影响原因已获得的成绩)
|
|
|
|
|
<p className=" font-14" style={{ paddingBottom: '5px'
|
|
|
|
|
, color: '#333'}}>
|
|
|
|
|
可以将参考答案分级设置,让学员自行选择级别,每级查看后按照比例扣分值(学员已完成任务再查看,则不影响学员已获得的成绩)
|
|
|
|
|
</p>
|
|
|
|
|
<p className=" font-12 "
|
|
|
|
|
style={{ maxWidth: "782px"
|
|
|
|
|
, color: '#999999'}}>
|
|
|
|
|
示例:级别1,扣减分值占比25%;级别2,扣减分值占比35%;级别3,扣减分值占比40%;则学员选择查看级别1的答案,将被扣减25%的分值;
|
|
|
|
|
选择查看级别2的答案,将被扣减60%的分值;选择查看级别3的答案,将被扣减100%的分值。
|
|
|
|
|
<p className=" font-14 mt15 "
|
|
|
|
|
style={{ color: '#888'}}>
|
|
|
|
|
<div>示例:级别1,扣减分值占比25%;级别2,扣减分值占比35%;级别3,扣减分值占比40%;</div>
|
|
|
|
|
<div className={"mt5 ml41"}>若学员选择查看级别1的答案,将被扣减25%的分值;选择查看级别2的答案,将被扣减60%的分值;选择查看级别3的答案,将被扣减100%的分值。</div>
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<style>{`
|
|
|
|
@ -320,25 +289,31 @@ export default class TPManswer extends Component {
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
answers.map((answer, index) => {
|
|
|
|
|
return <div className="levelSection" id={`levelSection${index}`} style={{ clear: 'both' }}>
|
|
|
|
|
return <div className="levelSection mt30" id={`levelSection${index}`} style={{ clear: 'both' }}>
|
|
|
|
|
<span className="mr4 color-orange pt10">*</span>
|
|
|
|
|
<p className="color-grey-6 font-16 mb30 mt10" style={{ display: "inline" }}>级别{index + 1}</p>
|
|
|
|
|
<p className="color-grey-6 font-16 mb30 mt10" style={{ display: "inline" }}>级别:{index + 1}</p>
|
|
|
|
|
<Tooltip title="删除">
|
|
|
|
|
<a className="fr sample_icon_remove mr30 mt8" onClick={()=>this.delanswers(index)}>
|
|
|
|
|
<i className="fa fa-times-circle color-grey-c font-16 fl" ></i>
|
|
|
|
|
<a className="fr sample_icon_remove mr10 mt8" onClick={()=>this.delanswers(index)}>
|
|
|
|
|
<i className={"iconfont icon-shanchu_Hover font-16 fl"}></i>
|
|
|
|
|
</a>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
<div className=" color-grey-6 font-16" style={{ marginLeft: "9px", margin: '8px 9px'}}>
|
|
|
|
|
<div className=" color-grey-6 font-16 bortopeeetpm pt20 mt20" style={{ marginLeft: "9px", margin: '8px 9px'}}>
|
|
|
|
|
<div className=" ">
|
|
|
|
|
<span>名称:</span>
|
|
|
|
|
<Input value={answer.name} onChange={(e) => this.onNameChange(e, index)}></Input>
|
|
|
|
|
|
|
|
|
|
<span style={{ marginLeft: "20px"}} >扣减分值占比:</span>
|
|
|
|
|
<InputNumber className="score" step={1} min={1} max={100} defaultValue={answer.score}
|
|
|
|
|
onChange={(e) => this.onScoreChange(e, index)} ></InputNumber>%
|
|
|
|
|
<div className={"wind500height45"}>
|
|
|
|
|
<div className={"fl"} style={{'width':'240px'}}>名称:</div>
|
|
|
|
|
<div className={"fl"} style={{ marginLeft: "20px"}} >扣减分值占比:</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className={"wind500height45"}>
|
|
|
|
|
<Input value={answer.name} onChange={(e) => this.onNameChange(e, index)}></Input>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<InputNumber className="score" step={1} min={1} max={100} defaultValue={answer.score}
|
|
|
|
|
style={{ marginLeft: "32px"}}
|
|
|
|
|
onChange={(e) => this.onScoreChange(e, index)} ></InputNumber> %
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="mt10">
|
|
|
|
|
<span>参考答案:</span>
|
|
|
|
|
<span>内容:</span>
|
|
|
|
|
<TPMMDEditor ref={`md${index}`} mdID={index} initValue={answer.contents}
|
|
|
|
|
onChange={(val) => this.answerOnChange(val, index)}></TPMMDEditor>
|
|
|
|
|
</div>
|
|
|
|
@ -348,19 +323,28 @@ export default class TPManswer extends Component {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<div className="clearfix mt20" style={{display:this.props.identity>4||this.props.identity===undefined||power===false?"none":"block"}}>
|
|
|
|
|
<a href={"javascript:void(0)"} className="defalutCancelbtn fl" onClick={this.addAnswer}>新增</a>
|
|
|
|
|
{/*<a href={"javascript:void(0)"} className="defalutCancelbtn fl" >新增参考答案</a>*/}
|
|
|
|
|
<Button type="primary" ghost className="edu-default-btn edu-greenback-btn mt20 mb20 newaddswermargin" onClick={this.addAnswer}>新增参考答案</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="clearfix mt20" style={{display:this.props.identity>4||this.props.identity===undefined||power===false?"none":"block"}}>
|
|
|
|
|
<a className="defalutSubmitbtn fl mr20" onClick={this.challenge_answer_submit}>提交</a>
|
|
|
|
|
{/*<a href={"/shixuns/" + shixunId + "/challenges"} className="defalutCancelbtn fl">取消</a>*/}
|
|
|
|
|
<Link to={"/shixuns/" + shixunId + "/challenges"} className={"defalutCancelbtn fl"}>取消</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{this.props.identity>4||this.props.identity===undefined||power===false?"":<div className="clearfix mt20" >
|
|
|
|
|
{/*<a className="defalutSubmitbtn fl mr20" onClick={this.challenge_answer_submit}>提交</a>*/}
|
|
|
|
|
{/*/!*<a href={"/shixuns/" + shixunId + "/challenges"} className="defalutCancelbtn fl">取消</a>*!/*/}
|
|
|
|
|
{/*<Link to={"/shixuns/" + shixunId + "/challenges"} className={"defalutCancelbtn fl"}>取消</Link>*/}
|
|
|
|
|
<Bottomsubmit url={"/shixuns/" + shixunId + "/challenges"}
|
|
|
|
|
bottomvalue={"提交"}
|
|
|
|
|
onSubmits={this.challenge_answer_submit}
|
|
|
|
|
{...this.props}
|
|
|
|
|
{...this.state}
|
|
|
|
|
loadings={false}
|
|
|
|
|
/>
|
|
|
|
|
</div>}
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|