From b46aef7e984e0ea9dd690459d09cbc3b71d08508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 25 Dec 2019 14:27:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A2=98=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/question/Question.js | 28 ++++-- .../modules/question/Questionitem_banks.js | 97 +++++++++++++++++-- .../question/component/ChoquesEditor.js | 5 +- .../modules/question/component/Listjihe.js | 2 +- 4 files changed, 117 insertions(+), 15 deletions(-) diff --git a/public/react/src/modules/question/Question.js b/public/react/src/modules/question/Question.js index 83de3b2e3..d31f58b82 100644 --- a/public/react/src/modules/question/Question.js +++ b/public/react/src/modules/question/Question.js @@ -192,15 +192,31 @@ class Question extends Component { } handleVisibleChange=(boll)=>{ - this.setState({ - visiblemys:boll, - }) + if(this.state.visiblemyss===true){ + this.setState({ + visiblemys:boll, + visiblemyss:false, + }) + }else{ + this.setState({ + visiblemys:boll, + }) + } + } handleVisibleChanges=(boll)=>{ - this.setState({ - visiblemyss:boll, - }) + if(this.state.visiblemys===true){ + this.setState({ + visiblemyss:boll, + visiblemys:false, + }) + }else{ + this.setState({ + visiblemyss:boll, + }) + } + } setdatafunsval=(e)=>{ diff --git a/public/react/src/modules/question/Questionitem_banks.js b/public/react/src/modules/question/Questionitem_banks.js index 2b7d1c68b..63ffa6095 100644 --- a/public/react/src/modules/question/Questionitem_banks.js +++ b/public/react/src/modules/question/Questionitem_banks.js @@ -20,15 +20,17 @@ import Choicequestion from './component/Choicequestion'; import SingleEditor from "./component/SingleEditor"; import ChoquesEditor from "./component/ChoquesEditor" import JudquestionEditor from "./component/JudquestionEditor"; -var itembankstop=null; -var singleEditor=null; -var Judquestio=null; -var Choques=null; +// var itembankstop=null; +// var singleEditor=null; +// var Judquestio=null; +// var Choques=null; class Questionitem_banks extends Component { constructor(props) { super(props); this.contentMdRef = React.createRef(); this.answerMdRef = React.createRef(); + this.Choques= React.createRef(); + this.Judquestio= React.createRef(); this.state = { item_type:null @@ -120,7 +122,7 @@ class Questionitem_banks extends Component { if(this.state.item_type==="SINGLE"){ if( this.answerMdRef!=null){ //单选题 - console.log(this.answerMdRef.onSave()); + // console.log(this.answerMdRef.onSave()); if(this.answerMdRef.onSave().length===0){ return; @@ -168,14 +170,95 @@ class Questionitem_banks extends Component { if(this.state.item_type==="MULTIPLE"){ if(this.Choques!=null){ //多选题 - console.log(this.Choques.onSave()); + // console.log(this.Choques.onSave()); + if(this.Choques.onSave().length===0){ + return; + } + var anserdata=this.Choques.onSave(); + const choices=[]; + // 1: [3] + // 2: (4) ["1", "2", "3", "4"] + for(var k=0;k { + if (result.data.status == 0) { + this.props.showNotification(`新增多选题成功`); + + } + }).catch((error) => { + console.log(error); + }) + + + + + + } } if(this.state.item_type==="JUDGMENT"){ if( this.Judquestio !=null){ //判断题 - console.log(this.Judquestio.onSave()); + // console.log(this.Judquestio.onSave()); + if(this.Judquestio.onSave().length===0){ + return; + } + var anserdata=this.Judquestio.onSave(); + const choices=[]; + const choicesdata={ + choice_text:"正确", + is_answer:anserdata[1]==="0"?0:1, + } + choices.push(choicesdata); + + const choicesdatas={ + choice_text:"错误", + is_answer:anserdata[1]==="1"?0:1, + } + choices.push(choicesdatas); + var data={ + repertoire_id:1, + sub_repertoire_id:1, + tag_repertoire_id:[1,3], + name:anserdata[0], + item_type:"JUDGMENT", + difficulty:2, + analysis:anserdata[2], + choices:choices, + } + axios.post(url, data) + .then((result) => { + if (result.data.status == 0) { + this.props.showNotification(`新增判断题成功`); + } + }).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 5b82b7288..ff1798b95 100644 --- a/public/react/src/modules/question/component/ChoquesEditor.js +++ b/public/react/src/modules/question/component/ChoquesEditor.js @@ -105,12 +105,15 @@ class ChoquesEditor extends Component{ this.props.showNotification('请您输入题干'); return editordata; } - if(!answerArray || answerArray.length == 0) { this.props.showNotification('请先点击选择本选择题的正确选项'); return editordata; } + if(!answerArray || answerArray.length < 2) { + this.props.showNotification('多选题最小正确选项为2个'); + return editordata; + } for(let i = 0; i < question_choices.length; i++) { if (!question_choices[i]) { diff --git a/public/react/src/modules/question/component/Listjihe.js b/public/react/src/modules/question/component/Listjihe.js index 52b381c0f..cbc3cfac7 100644 --- a/public/react/src/modules/question/component/Listjihe.js +++ b/public/react/src/modules/question/component/Listjihe.js @@ -60,7 +60,7 @@ class Listjihe extends Component {

难度:{items.difficulty===1?"简单":items.difficulty===2?"适中":items.difficulty===3?"困难":""}

-

题型:{items.item_type==="SINGLE"?"单选题":""}

+

题型:{items.item_type==="SINGLE"?"单选题":items.item_type==="MULTIPLE"?"多选题":items.item_type==="JUDGMENT"?"判断题":items.item_type==="PROGRAM"?"编程题":""}

{/*内容*/}