diff --git a/public/react/src/modules/question/Questionitem_banks.js b/public/react/src/modules/question/Questionitem_banks.js index b8b19ae4f..d50cc341d 100644 --- a/public/react/src/modules/question/Questionitem_banks.js +++ b/public/react/src/modules/question/Questionitem_banks.js @@ -82,29 +82,9 @@ class Questionitem_banks extends Component { ////console.log("item_banks"); console.log("Questionitem_banks"); console.log(response.data); - var choicescomy=[]; - try { - if(this.props.item_banksedit){ - if(this.props.item_banksedit.choices){ - for(var p=0;p { - choicescomy.push({ - choice_text:item.choice_text, - standard_boolean:item.is_answer, - }) - }) - } - - } - }catch (e) { - } this.setState({ item_banksedit:response.data, - myquestion_choicesco:choicescomy, }) }).catch((error) => { ////console.log(error) diff --git a/public/react/src/modules/question/component/ChoquesEditor.js b/public/react/src/modules/question/component/ChoquesEditor.js index ff1798b95..96abe28b6 100644 --- a/public/react/src/modules/question/component/ChoquesEditor.js +++ b/public/react/src/modules/question/component/ChoquesEditor.js @@ -42,6 +42,31 @@ class ChoquesEditor extends Component{ _standard_answers.push(item.standard_boolean) _question_choices.push(item.choice_text) }) + } + const choicescomy=[]; + try { + if(this.props.item_banksedit){ + if(this.props.item_banksedit.choices){ + + this.props.item_banksedit.choices.forEach((item, index) => { + console.log("SingleEditor"); + console.log(item); + choicescomy.push({ + choice_text:item.choice_text, + standard_boolean:item.is_answer, + }) + }) + + _question_choices = [] + choicescomy.forEach((item, index) => { + _standard_answers.push(item.standard_boolean) + _question_choices.push(item.choice_text) + }) + } + + } + }catch (e) { + } this.state = { question_choices: _question_choices || ['', '', '', ''], @@ -157,6 +182,34 @@ class ChoquesEditor extends Component{ }catch (e) { } + try { + this.setState({ + item_banksedit:this.props.item_banksedit, + question_title:this.props.item_banksedit.name, + question_titles:this.props.item_banksedit.analysis, + mychoicess:this.props.item_banksedit.choices, + + }) + + + }catch (e) { + + } + } + componentDidUpdate(prevProps) { + console.log("componentDidUpdate"); + // console.log(prevProps); + // console.log(this.props.item_banksedit); + + if(prevProps.item_banksedit !== this.props.item_banksedit) { + this.setState({ + item_banksedit: this.props.item_banksedit, + question_title: this.props.item_banksedit.name, + question_titles: this.props.item_banksedit.analysis, + mychoicess: this.props.item_banksedit.choices, + + }) + } } onOptionClick = (index) => { let standard_answers = this.state.standard_answers.slice(0) diff --git a/public/react/src/modules/question/component/Itembankstop.js b/public/react/src/modules/question/component/Itembankstop.js index 36d75f57b..a0d118c3c 100644 --- a/public/react/src/modules/question/component/Itembankstop.js +++ b/public/react/src/modules/question/component/Itembankstop.js @@ -59,7 +59,7 @@ class Itembankstop extends Component { this.state = { page:1, Knowpoints:[], - rbtx:"", + rbtx:undefined, } } //初始化 @@ -93,9 +93,14 @@ class Itembankstop extends Component { // console.log(this.props.item_banksedit); if(prevProps.item_banksedit !== this.props.item_banksedit){ - this.handleFormtixing(this.props.item_banksedit.item_type); + if(this.props.item_banksedit.item_type){ + this.handleFormtixing(this.props.item_banksedit.item_type); + } + if(this.props.item_banksedit.difficulty){ this.handleFormLayoutChange(this.props.item_banksedit.difficulty); } + + } } onChange=(e)=> { //console.log(`checked = ${e.target.checked}`); @@ -311,7 +316,7 @@ class Itembankstop extends Component { } )( - @@ -382,7 +387,7 @@ class Itembankstop extends Component { } )( - + 简单 适中 困难 diff --git a/public/react/src/modules/question/component/SingleEditor.js b/public/react/src/modules/question/component/SingleEditor.js index eea70b8a2..97e43879d 100644 --- a/public/react/src/modules/question/component/SingleEditor.js +++ b/public/react/src/modules/question/component/SingleEditor.js @@ -31,6 +31,7 @@ class SingleEditor extends Component{ choice_text: "1" standard_boolean: true */ + const {question_choices} = this.props; let _standard_answers = undefined; let _question_choices = undefined; @@ -43,6 +44,32 @@ class SingleEditor extends Component{ _question_choices.push(item.choice_text) }) } + + const choicescomy=[]; + try { + if(this.props.item_banksedit){ + if(this.props.item_banksedit.choices){ + + this.props.item_banksedit.choices.forEach((item, index) => { + console.log("SingleEditor"); + console.log(item); + choicescomy.push({ + choice_text:item.choice_text, + standard_boolean:item.is_answer, + }) + }) + + _question_choices = [] + choicescomy.forEach((item, index) => { + _standard_answers.push(item.standard_boolean) + _question_choices.push(item.choice_text) + }) + } + + } + }catch (e) { + + } this.state = { question_choices: _question_choices || ['', '', '', ''], standard_answers: _standard_answers || [false, false, false, false],