题库单选题编辑

yslnewtiku
杨树林 5 years ago
parent 9347c049fd
commit 29432d8b9c

@ -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<this.props.item_banksedit.choices.length;p++){
}
this.props.item_banksedit.choices.forEach((item, index) => {
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)

@ -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)

@ -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 {
}
)(
<InputGroup compact>
<Select style={{ width: '258px' }} defaultValue={this.state.rbtx} value={this.state.rbtx} onChange={this.handleFormtixing} placeholder="请选择...">
<Select style={{ width: '258px' }} value={this.state.rbtx} onChange={this.handleFormtixing} placeholder="请选择...">
<Option value="SINGLE">单选题</Option>
<Option value="MULTIPLE">多选题</Option>
<Option value="JUDGMENT">判断题</Option>
@ -382,7 +387,7 @@ class Itembankstop extends Component {
}
)(
<Radio.Group defaultValue={this.state.rbnd} onChange={this.handleFormLayoutChange} >
<Radio.Group value={this.state.rbnd} onChange={this.handleFormLayoutChange} >
<Radio.Button value="1">简单</Radio.Button>
<Radio.Button value="2">适中</Radio.Button>
<Radio.Button value="3">困难</Radio.Button>

@ -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],

Loading…
Cancel
Save