调整题库

yslnewtiku
杨树林 5 years ago
parent 2a256ee057
commit 9347c049fd

@ -33,7 +33,9 @@ class Questionitem_banks extends Component {
this.Judquestio= React.createRef(); this.Judquestio= React.createRef();
this.state = { this.state = {
item_type:null, item_type:null,
item_banksedit:[] item_banksedit:[],
myquestion_choicesco:[],
} }
} }
@ -80,8 +82,29 @@ class Questionitem_banks extends Component {
////console.log("item_banks"); ////console.log("item_banks");
console.log("Questionitem_banks"); console.log("Questionitem_banks");
console.log(response.data); 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({ this.setState({
item_banksedit:response.data, item_banksedit:response.data,
myquestion_choicesco:choicescomy,
}) })
}).catch((error) => { }).catch((error) => {
////console.log(error) ////console.log(error)
@ -124,7 +147,6 @@ class Questionitem_banks extends Component {
} }
getJudquestio=(Ref)=>{ getJudquestio=(Ref)=>{
debugger
this.Judquestio=Ref; this.Judquestio=Ref;
} }
@ -139,7 +161,20 @@ class Questionitem_banks extends Component {
////console.log(this.contentMdRef.Getdatas()); ////console.log(this.contentMdRef.Getdatas());
////console.log("preservation3333"); ////console.log("preservation3333");
////console.log(this.answerMdRef.onSave()); ////console.log(this.answerMdRef.onSave());
var url="/item_banks.json"; const params= this.props&&this.props.match&&this.props.match.params;
var url="";
var boolnew=true;
if(JSON.stringify(params)==="{}"){
// "新增"
url="/item_banks.json";
boolnew=true;
}else{
url=`/item_banks/${params.id}.json`;
boolnew=false;
// "编辑"
}
if(this.contentMdRef !=null){ if(this.contentMdRef !=null){
console.log(this.contentMdRef.Getdatas()); console.log(this.contentMdRef.Getdatas());
} }
@ -185,7 +220,9 @@ class Questionitem_banks extends Component {
analysis:anserdata[3], analysis:anserdata[3],
choices:choices, choices:choices,
} };
if(boolnew===true){
axios.post(url, data) axios.post(url, data)
.then((result) => { .then((result) => {
if (result.data.status == 0) { if (result.data.status == 0) {
@ -195,6 +232,18 @@ class Questionitem_banks extends Component {
}).catch((error) => { }).catch((error) => {
console.log(error); console.log(error);
}) })
}else{
axios.put(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`编辑单选题成功`);
}
}).catch((error) => {
console.log(error);
})
}
} }
@ -230,6 +279,7 @@ class Questionitem_banks extends Component {
analysis:anserdata[3], analysis:anserdata[3],
choices:choices, choices:choices,
} }
if(boolnew===true) {
axios.post(url, data) axios.post(url, data)
.then((result) => { .then((result) => {
if (result.data.status == 0) { if (result.data.status == 0) {
@ -240,6 +290,19 @@ class Questionitem_banks extends Component {
console.log(error); console.log(error);
}) })
}else{
axios.put(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`编辑多选题成功`);
}
}).catch((error) => {
console.log(error);
})
}
@ -278,6 +341,8 @@ class Questionitem_banks extends Component {
analysis:anserdata[2], analysis:anserdata[2],
choices:choices, choices:choices,
} }
if(boolnew===true) {
axios.post(url, data) axios.post(url, data)
.then((result) => { .then((result) => {
if (result.data.status == 0) { if (result.data.status == 0) {
@ -287,6 +352,18 @@ class Questionitem_banks extends Component {
console.log(error); console.log(error);
}) })
}else{
axios.put(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`编辑判断题成功`);
}
}).catch((error) => {
console.log(error);
})
}
@ -363,6 +440,7 @@ class Questionitem_banks extends Component {
<SingleEditor <SingleEditor
{...this.state} {...this.state}
{...this.props} {...this.props}
question_choices={this.state.myquestion_choicesco}
getanswerMdRef={(ref)=>this.getanswerMdRef(ref)} getanswerMdRef={(ref)=>this.getanswerMdRef(ref)}
> >
@ -385,6 +463,7 @@ class Questionitem_banks extends Component {
<JudquestionEditor <JudquestionEditor
{...this.state} {...this.state}
{...this.props} {...this.props}
item_banksedit={this.state.item_banksedit}
getanswerMdRef={(ref)=>this.getJudquestio(ref)} getanswerMdRef={(ref)=>this.getJudquestio(ref)}
> >

@ -88,12 +88,11 @@ class Itembankstop extends Component {
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
console.log("componentDidUpdate"); // console.log("componentDidUpdate");
console.log(prevProps); // console.log(prevProps);
console.log(this.props.item_banksedit); // console.log(this.props.item_banksedit);
if(prevProps.item_banksedit !== this.props.item_banksedit){ if(prevProps.item_banksedit !== this.props.item_banksedit){
debugger
this.handleFormtixing(this.props.item_banksedit.item_type); this.handleFormtixing(this.props.item_banksedit.item_type);
this.handleFormLayoutChange(this.props.item_banksedit.difficulty); this.handleFormLayoutChange(this.props.item_banksedit.difficulty);
} }
@ -136,10 +135,10 @@ class Itembankstop extends Component {
//console.log("难度塞选"); //console.log("难度塞选");
//console.log(value); //console.log(value);
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
rbnd:value, rbnd:value+"",
}); });
this.setState({ this.setState({
rbnd:value, rbnd:value+"",
}) })
} }
@ -169,12 +168,12 @@ class Itembankstop extends Component {
//题型 //题型
console.log("题型"); console.log("题型");
console.log(value); console.log(value);
this.props.form.setFieldsValue({
rbtx:value,
});
this.setState({ this.setState({
rbtx:value, rbtx:value+"",
}) })
this.props.form.setFieldsValue({
rbtx:value+"",
});
this.props.setitem_type(value); this.props.setitem_type(value);
} }
preventDefault=(e)=> { preventDefault=(e)=> {
@ -212,6 +211,8 @@ class Itembankstop extends Component {
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
console.log("renderrenderrender"); console.log("renderrenderrender");
console.log(this.props.item_banksedit); console.log(this.props.item_banksedit);
console.log("renderrenderrendersssss");
console.log(this.state.rbtx);
return ( return (
<div className=" clearfix educontent Contentquestionbankstyle w100s w1200fpx mt19" > <div className=" clearfix educontent Contentquestionbankstyle w100s w1200fpx mt19" >
@ -310,7 +311,7 @@ class Itembankstop extends Component {
} }
)( )(
<InputGroup compact> <InputGroup compact>
<Select style={{ width: '258px' }} defaultValue onChange={this.handleFormtixing} placeholder="请选择..."> <Select style={{ width: '258px' }} defaultValue={this.state.rbtx} value={this.state.rbtx} onChange={this.handleFormtixing} placeholder="请选择...">
<Option value="SINGLE">单选题</Option> <Option value="SINGLE">单选题</Option>
<Option value="MULTIPLE">多选题</Option> <Option value="MULTIPLE">多选题</Option>
<Option value="JUDGMENT">判断题</Option> <Option value="JUDGMENT">判断题</Option>

@ -50,7 +50,9 @@ class JudquestionEditor extends Component{
question_type: this.props.question_type || 0, question_type: this.props.question_type || 0,
question_score: this.props.question_score || this.props.init_question_score, question_score: this.props.question_score || this.props.init_question_score,
question_titles:this.props.question_titles||'', question_titles:this.props.question_titles||'',
zqda:null zqda:null,
item_banksedit:[],
mychoicess:[],
} }
} }
addOption = () => { addOption = () => {
@ -150,6 +152,74 @@ class JudquestionEditor extends Component{
this.props.getanswerMdRef(this); this.props.getanswerMdRef(this);
}catch (e) { }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,
})
if(this.props.item_banksedit){
if(this.props.item_banksedit.choices){
for(var ik=0;ik<this.props.item_banksedit.choices.length;ik++ ){
if( this.props.item_banksedit.choices[ik].choice_text==="正确"){
if( this.props.item_banksedit.choices[ik].is_answer===true){
this.setState({
zqda:"0"
})
}
}else{
if( this.props.item_banksedit.choices[ik].is_answer===true){
this.setState({
zqda:"1"
})
}
}
}
}
}
}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,
})
if(this.props.item_banksedit){
if(this.props.item_banksedit.choices){
for(var ik=0;ik<this.props.item_banksedit.choices.length;ik++ ){
if( this.props.item_banksedit.choices[ik].choice_text==="正确"){
if( this.props.item_banksedit.choices[ik].is_answer===true){
this.setState({
zqda:"0"
})
}
}else{
if( this.props.item_banksedit.choices[ik].is_answer===true){
this.setState({
zqda:"1"
})
}
}
}
}
}
} }
} }
onOptionClick = (index) => { onOptionClick = (index) => {
@ -201,7 +271,9 @@ class JudquestionEditor extends Component{
////console.log(value); ////console.log(value);
this.setState({ this.setState({
zqda:e.target.value, zqda:e.target.value,
}) })
} }
render() { render() {
let { question_title, question_score, question_type, question_choices, standard_answers,question_titles} = this.state; let { question_title, question_score, question_type, question_choices, standard_answers,question_titles} = this.state;
@ -225,7 +297,7 @@ class JudquestionEditor extends Component{
// ////console.log("xuanzheshijuan"); // ////console.log("xuanzheshijuan");
// ////console.log(answerTagArray); // ////console.log(answerTagArray);
// ////console.log(!exerciseIsPublish); // ////console.log(!exerciseIsPublish);
const params= this.props&&this.props.match&&this.props.match.params;
return( return(
<div className="padding20-30 bor-bottom-greyE signleEditor danxuano" id={qNumber}> <div className="padding20-30 bor-bottom-greyE signleEditor danxuano" id={qNumber}>
<style>{` <style>{`
@ -267,7 +339,7 @@ class JudquestionEditor extends Component{
<div className="mb10 sortinxdirection"> <div className="mb10 sortinxdirection">
<Radio.Group buttonStyle="solid" onChange={this.handleFormLayoutChange}> <Radio.Group buttonStyle="solid" value={this.state.zqda} onChange={this.handleFormLayoutChange}>
<Radio.Button value="0">正确</Radio.Button> <Radio.Button value="0">正确</Radio.Button>
<Radio.Button value="1">错误</Radio.Button> <Radio.Button value="1">错误</Radio.Button>

@ -50,6 +50,7 @@ class SingleEditor extends Component{
question_type: this.props.question_type || 0, question_type: this.props.question_type || 0,
question_score: this.props.question_score || this.props.init_question_score, question_score: this.props.question_score || this.props.init_question_score,
question_titles:this.props.question_titles||'', question_titles:this.props.question_titles||'',
item_banksedit:[],
} }
} }
addOption = () => { addOption = () => {
@ -154,6 +155,37 @@ class SingleEditor extends Component{
}catch (e) { }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) => { onOptionClick = (index) => {

Loading…
Cancel
Save