issues25489
杨树林 5 years ago
parent 15f02ce89e
commit 4031798e88

@ -43,7 +43,7 @@ class CompetitionCommon extends Component{
// }) // })
// } // }
// }).catch((error) => { // }).catch((error) => {
// console.log(error) // //console.log(error)
// }) // })
} }
} }
@ -51,8 +51,8 @@ class CompetitionCommon extends Component{
componentDidUpdate = (prevProps) => { componentDidUpdate = (prevProps) => {
if (prevProps.user != this.props.user) { if (prevProps.user != this.props.user) {
console.log("componentDidUpdatess"); //console.log("componentDidUpdatess");
console.log(this.props.user); //console.log(this.props.user);
if (this.props.user && this.props.user.login != "") { if (this.props.user && this.props.user.login != "") {
const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`; const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`;
axios.get((zul)).then((result) => { axios.get((zul)).then((result) => {
@ -64,7 +64,7 @@ class CompetitionCommon extends Component{
} }
} }
}).catch((error) => { }).catch((error) => {
//console.log(error); ////console.log(error);
}) })
} }
} }
@ -103,7 +103,7 @@ class CompetitionCommon extends Component{
} }
} }
}).catch((error) => { }).catch((error) => {
console.log(error) //console.log(error)
}) })
//this.props.user 有可能为空 //this.props.user 有可能为空
@ -119,7 +119,7 @@ class CompetitionCommon extends Component{
} }
} }
}).catch((error) => { }).catch((error) => {
//console.log(error); ////console.log(error);
}) })
} }
@ -161,7 +161,7 @@ class CompetitionCommon extends Component{
} }
}).catch((error) => { }).catch((error) => {
console.log(error) //console.log(error)
}) })
} }
} }
@ -192,7 +192,7 @@ class CompetitionCommon extends Component{
} }
}).catch((error) => { }).catch((error) => {
console.log(error) //console.log(error)
}) })
}else{ }else{
if (module_url.substring(0, 7) == 'http://' || module_url.substring(0, 8) == 'https://') { if (module_url.substring(0, 7) == 'http://' || module_url.substring(0, 8) == 'https://') {
@ -309,7 +309,7 @@ class CompetitionCommon extends Component{
}) })
} }
}).catch((error) => { }).catch((error) => {
console.log(error) //console.log(error)
}) })
} }

@ -16,8 +16,8 @@ const $ = window.$
const { Option } = Select; const { Option } = Select;
const tagArray = [ const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
] ]
class SingleEditor extends Component{ class SingleEditor extends Component{
@ -92,13 +92,13 @@ class SingleEditor extends Component{
} }
const intScore = parseFloat(question_score) const intScore = parseFloat(question_score)
if (intScore == 0) { if (intScore == 0) {
this.props.showNotification('分值必须大于0'); return; this.props.showNotification('分值必须大于0'); return;
} else if(!question_score || intScore == NaN) { } else if(!question_score || intScore == NaN) {
this.props.showNotification('分值:不能为空'); return; this.props.showNotification('分值:不能为空'); return;
} }
if(!answerArray || answerArray.length == 0) { if(!answerArray || answerArray.length == 0) {
this.props.showNotification('请先点击选择本选择题的正确选项'); return; this.props.showNotification('请先点击选择本选择题的正确选项'); return;
} }
@ -119,9 +119,9 @@ class SingleEditor extends Component{
"question_type":1, "question_type":1,
"question_score":5, "question_score":5,
"question_choices":["a答案","b答案","c答案","d答案"], "question_choices":["a答案","b答案","c答案","d答案"],
"standard_answers":[1] "standard_answers":[1]
}*/ }*/
const Id = this.props.match.params.Id const Id = this.props.match.params.Id
if (question_id) { if (question_id) {
const editUrl = this.props.getEditQuestionUrl(question_id); const editUrl = this.props.getEditQuestionUrl(question_id);
axios.put(editUrl, { axios.put(editUrl, {
@ -144,7 +144,7 @@ class SingleEditor extends Component{
}); });
} else { } else {
const url = this.props.getAddQuestionUrl(); const url = this.props.getAddQuestionUrl();
axios.post(url, { axios.post(url, {
exercise_bank_id: Id, exercise_bank_id: Id,
question_title, question_title,
@ -162,16 +162,16 @@ class SingleEditor extends Component{
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
}); });
} }
} }
onCancel = () => { onCancel = () => {
this.props.onEditorCancel() this.props.onEditorCancel()
} }
componentDidMount = () => { componentDidMount = () => {
} }
onOptionClick = (index) => { onOptionClick = (index) => {
// if (this.props.exerciseIsPublish) { // if (this.props.exerciseIsPublish) {
@ -186,7 +186,7 @@ class SingleEditor extends Component{
// TODO 新建然后删除CD选项再输入题干会调用到这里且index是3 // TODO 新建然后删除CD选项再输入题干会调用到这里且index是3
return; return;
} }
let question_choices = this.state.question_choices.slice(0); let question_choices = this.state.question_choices.slice(0);
question_choices[index] = value; question_choices[index] = value;
this.setState({ question_choices }) this.setState({ question_choices })
} }
@ -200,19 +200,19 @@ class SingleEditor extends Component{
mdReactObject.toShowMode() mdReactObject.toShowMode()
} }
this.mdReactObject = that; this.mdReactObject = that;
} }
toShowMode = () => { toShowMode = () => {
} }
render() { render() {
let { question_title, question_score, question_type, question_choices, standard_answers } = this.state; let { question_title, question_score, question_type, question_choices, standard_answers } = this.state;
let { question_id, index, exerciseIsPublish, let { question_id, index, exerciseIsPublish,
// question_title, // question_title,
// question_type, // question_type,
// question_score, // question_score,
isNew } = this.props; isNew } = this.props;
// const { getFieldDecorator } = this.props.form; // const { getFieldDecorator } = this.props.form;
const isAdmin = this.props.isAdmin() const isAdmin = this.props.isAdmin()
@ -221,8 +221,8 @@ class SingleEditor extends Component{
const qNumber = `question_${index}`; const qNumber = `question_${index}`;
// TODO show模式 isNew为false isEdit为false // TODO show模式 isNew为false isEdit为false
// [true, false, true] -> [0, 2] // [true, false, true] -> [0, 2]
const answerTagArray = standard_answers.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1); const answerTagArray = standard_answers.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1);
return( return(
<div className="padding20-30 bor-bottom-greyE signleEditor" id={qNumber}> <div className="padding20-30 bor-bottom-greyE signleEditor" id={qNumber}>
@ -253,8 +253,8 @@ class SingleEditor extends Component{
ref="titleEditor" ref="titleEditor"
></TPMMDEditor> ></TPMMDEditor>
{question_choices.map( (item, index) => { {question_choices.map( (item, index) => {
const bg = standard_answers[index] ? 'check-option-bg' : '' const bg = standard_answers[index] ? 'check-option-bg' : ''
return <div className="df optionRow " > return <div className="df optionRow " >
{/* 点击设置答案 */} {/* 点击设置答案 */}
@ -268,7 +268,7 @@ class SingleEditor extends Component{
</span> </span>
{/* </Tooltip> */} {/* </Tooltip> */}
<div style={{ flex: '0 0 1038px'}}> <div style={{ flex: '0 0 1038px'}}>
<DMDEditor <DMDEditor
ref={`optionEditor${index}`} ref={`optionEditor${index}`}
toMDMode={this.toMDMode} toShowMode={this.toShowMode} toMDMode={this.toMDMode} toShowMode={this.toShowMode}
height={166} className={'optionMdEditor'} noStorage={true} height={166} className={'optionMdEditor'} noStorage={true}
@ -293,15 +293,16 @@ class SingleEditor extends Component{
<div className="mb20"> <div className="mb20">
{/* {!exerciseIsPublish && <ActionBtn style="grey" className="middle mr20" onClick={this.addOption}>新增选项</ActionBtn>} */} {/* {!exerciseIsPublish && <ActionBtn style="grey" className="middle mr20" onClick={this.addOption}>新增选项</ActionBtn>} */}
<span style={{color: '#FF6800'}}>{!exerciseIsPublish ? '温馨提示:点击选项标题,可以直接设置答案;选择多个答案即为多选题' : ' '}</span> <span
style={{color: '#FF6800'}}>{!exerciseIsPublish ? '温馨提示:点击选项输入框可设置答案;选中的选项即为正确答案,选择多个答案即为多选题' : ' '}</span>
{ answerTagArray && !!answerTagArray.length ? { answerTagArray && !!answerTagArray.length ?
<React.Fragment> <React.Fragment>
<span className="fr color-orange">{answerTagArray.join(' ')}</span> <span className="fr color-orange">{answerTagArray.join(' ')}</span>
<span className="fr">标准答案</span> <span className="fr">标准答案</span>
</React.Fragment> </React.Fragment>
: :
<span className="fr color-orange">请点击正确选项</span> <span className="fl color-orange">温馨提示点击选项输入框可设置答案选中的选项即为正确答案选择多个答案即为多选题</span>
} }
</div> </div>
@ -310,18 +311,18 @@ class SingleEditor extends Component{
<InputNumber step={0.1} precision={1} min={0} max={100} style={{width: 100}} value={question_score} onChange={this.on_question_score_change} <InputNumber step={0.1} precision={1} min={0} max={100} style={{width: 100}} value={question_score} onChange={this.on_question_score_change}
disabled={exerciseIsPublish} disabled={exerciseIsPublish}
></InputNumber>&nbsp; ></InputNumber>&nbsp;
<span className="fr"> <span className="fr">
<ActionBtn style="greyBack" className="middle mr20" onClick={this.onCancel} <ActionBtn style="greyBack" className="middle mr20" onClick={this.onCancel}
>取消</ActionBtn> >取消</ActionBtn>
<ActionBtn style="blue" className="middle" onClick={this.onSave}>保存</ActionBtn> <ActionBtn style="blue" className="middle" onClick={this.onSave}>保存</ActionBtn>
</span> </span>
</div> </div>
</div> </div>
) )
} }
} }
// RouteHOC() // RouteHOC()
export default (SingleEditor); export default (SingleEditor);

Loading…
Cancel
Save