dev_tpm_ui
杨树明 5 years ago
parent 5c25888110
commit c37ecc78bb

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

@ -534,7 +534,7 @@ export default class TPMchallengesnew extends Component {
<React.Fragment> <React.Fragment>
<div className="educontent mt30 mb30"> <div className="educontent mt30 mb30">
<div className="TPMchallengesnewtitles edu-back-white clearfix borderbottomf4"> <div className="TPMchallengesnewtitles edu-back-white clearfix borderbottomf4">
<span className="font-16 task-hide fl TPMtaskName">{position}{responsedata&&responsedata.st === 0 ?"实践题":"选择题"}</span> <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"> {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 type="primary" className="edu-default-btn edu-greenback-btn "
>新增实践任务</Button></a>} >新增实践任务</Button></a>}
@ -717,6 +717,8 @@ export default class TPMchallengesnew extends Component {
{/*<a href={go_back_url === undefined ? "" : go_back_url} className="defalutCancelbtn fl">取消</a>*/} {/*<a href={go_back_url === undefined ? "" : go_back_url} className="defalutCancelbtn fl">取消</a>*/}
{/*<Link to={go_back_url === undefined ? "" : go_back_url} className={"defalutCancelbtn fl"}>取消</Link>*/} {/*<Link to={go_back_url === undefined ? "" : go_back_url} className={"defalutCancelbtn fl"}>取消</Link>*/}
<Bottomsubmit url={go_back_url === undefined ? "" : go_back_url} <Bottomsubmit url={go_back_url === undefined ? "" : go_back_url}
{...this.props}
{...this.state}
bottomvalue={"提交"} bottomvalue={"提交"}
onSubmits={checkpointId===undefined?()=>this.CreatePracticesend():()=>this.editPracticesend()} onSubmits={checkpointId===undefined?()=>this.CreatePracticesend():()=>this.editPracticesend()}
loadings={CreatePracticesendtype===true?true:editPracticesendtype===true?true:false}/> loadings={CreatePracticesendtype===true?true:editPracticesendtype===true?true:false}/>

@ -690,7 +690,7 @@ export default class TPMevaluation extends Component {
<React.Fragment> <React.Fragment>
<div className="educontent mt30 mb30"> <div className="educontent mt30 mb30">
<div className="TPMchallengesnewtitles edu-back-white clearfix borderbottomf4"> <div className="TPMchallengesnewtitles edu-back-white clearfix borderbottomf4">
<span className="font-16 task-hide fl TPMtaskName">{position}{responsedata&&responsedata.st === 0 ?"实践题":"选择题"}</span> <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"> {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 type="primary" className="edu-default-btn edu-greenback-btn "
>新增实践任务</Button></a>} >新增实践任务</Button></a>}
@ -1078,7 +1078,10 @@ export default class TPMevaluation extends Component {
<Bottomsubmit url={"/shixuns/" + shixunId + "/challenges"} <Bottomsubmit url={"/shixuns/" + shixunId + "/challenges"}
bottomvalue={"提交"} bottomvalue={"提交"}
onSubmits={this.submitarbitrationevaluation} onSubmits={this.submitarbitrationevaluation}
loadings={false}/> {...this.props}
{...this.state}
loadings={false}
/>
</div>} </div>}
</React.Fragment> </React.Fragment>
) )

@ -315,4 +315,17 @@ a{
.height40pxtpm{ .height40pxtpm{
height:40px height:40px
}
.ml41{
margin-left: 41px;
}
.wind500height45{
width: 500px;
height: 45px;
}
.newaddswermargin{
margin: 0 auto;
} }
Loading…
Cancel
Save