From c6e9b35a9f24dd9e0c8d305a9c9c4dec3e8e735b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Thu, 2 Jan 2020 17:16:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E9=A2=98=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/question/component/Contentpart.js | 20 +++++-- .../modules/question/component/Listjihe.js | 54 +++++++++++-------- 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/public/react/src/modules/question/component/Contentpart.js b/public/react/src/modules/question/component/Contentpart.js index bff3c4e6f..20ad3b096 100644 --- a/public/react/src/modules/question/component/Contentpart.js +++ b/public/react/src/modules/question/component/Contentpart.js @@ -23,7 +23,8 @@ class Contentpart extends Component { super(props); this.state = { page:1, - + chakanjiexibool:false, + chakanjiexiboolindex:"无", } } //初始化 @@ -32,7 +33,18 @@ class Contentpart extends Component { } - + chakanjiexibool=(index)=>{ + debugger + if(this.state.chakanjiexiboolindex===index){ + this.setState({ + chakanjiexiboolindex:"无", + }) + return + } + this.setState({ + chakanjiexiboolindex:index, + }) + } render() { let {page}=this.state; @@ -203,7 +215,9 @@ class Contentpart extends Component { : this.props.Contentdata.items.map((object, index) => { return ( this.chakanjiexibool(keindex)} + listjihe={index+1} + keindex={index} items={object} key={index} getitem_basketss={(id)=>this.props.getitem_basketss(id)} diff --git a/public/react/src/modules/question/component/Listjihe.js b/public/react/src/modules/question/component/Listjihe.js index d31390e75..69d31f0e8 100644 --- a/public/react/src/modules/question/component/Listjihe.js +++ b/public/react/src/modules/question/component/Listjihe.js @@ -22,7 +22,6 @@ class Listjihe extends Component { page:1, name:"单选题", nd:"简单", - chakanjiexibool:false, } } //初始化 @@ -31,18 +30,6 @@ class Listjihe extends Component { } - chakanjiexibool=()=>{ - if(this.state.chakanjiexibool===true){ - this.setState({ - chakanjiexibool:false - }) - }else{ - this.setState({ - chakanjiexibool:true - }) - } - - } //选用 Selectingpracticaltraining=(id)=>{ let data={ @@ -61,18 +48,41 @@ class Listjihe extends Component { render() { - let {page,name,nd,chakanjiexibool}=this.state; - let {defaultActiveKey,items,listjihe}=this.props; + let {page,name,nd}=this.state; + let {defaultActiveKey,items,listjihe,chakanjiexiboolindex,keindex}=this.props; + + // 编程答案 + var rightkey=null + + if(items){ + if(items.item_type){ + if(items.item_type==="PROGRAM"){ + }else{ + if(items.choices){ + if(items.choices.length>0){ + + var arr= items.choices; + for(let data of arr) { + if(data.is_answer===true){ + rightkey=data.choice_text; + break; + } + } + } + } + } + } + + } + - ////console.log("Listjihe"); - ////console.log(this.props); return ( -
+
{/*顶部*/}
{ - this.props.listjihe+1 + this.props.listjihe }
@@ -174,7 +184,7 @@ class Listjihe extends Component { items.item_type==="PROGRAM"? "" : -

this.chakanjiexibool()}> +

this.props.chakanjiexibool(keindex)}> 查看解析

} @@ -184,13 +194,13 @@ class Listjihe extends Component {
{ - chakanjiexibool===true?
+ chakanjiexiboolindex===keindex?