调整题库

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

@ -33,7 +33,9 @@ class Questionitem_banks extends Component {
this.Judquestio= React.createRef();
this.state = {
item_type:null,
item_banksedit:[]
item_banksedit:[],
myquestion_choicesco:[],
}
}
@ -80,9 +82,30 @@ class Questionitem_banks extends Component {
////console.log("item_banks");
console.log("Questionitem_banks");
console.log(response.data);
this.setState({
item_banksedit: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)
@ -124,7 +147,6 @@ class Questionitem_banks extends Component {
}
getJudquestio=(Ref)=>{
debugger
this.Judquestio=Ref;
}
@ -139,7 +161,20 @@ class Questionitem_banks extends Component {
////console.log(this.contentMdRef.Getdatas());
////console.log("preservation3333");
////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){
console.log(this.contentMdRef.Getdatas());
}
@ -185,16 +220,30 @@ class Questionitem_banks extends Component {
analysis:anserdata[3],
choices:choices,
};
if(boolnew===true){
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`新增单选题成功`);
}
}).catch((error) => {
console.log(error);
})
}else{
axios.put(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`编辑单选题成功`);
}
}).catch((error) => {
console.log(error);
})
}
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`新增单选题成功`);
}
}).catch((error) => {
console.log(error);
})
}
@ -230,15 +279,29 @@ class Questionitem_banks extends Component {
analysis:anserdata[3],
choices:choices,
}
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`新增多选题成功`);
if(boolnew===true) {
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`新增多选题成功`);
}
}).catch((error) => {
console.log(error);
})
}else{
axios.put(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`编辑多选题成功`);
}
}).catch((error) => {
console.log(error);
})
}
}
}).catch((error) => {
console.log(error);
})
@ -278,14 +341,28 @@ class Questionitem_banks extends Component {
analysis:anserdata[2],
choices:choices,
}
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`新增判断题成功`);
}
}).catch((error) => {
console.log(error);
})
if(boolnew===true) {
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`新增判断题成功`);
}
}).catch((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
{...this.state}
{...this.props}
question_choices={this.state.myquestion_choicesco}
getanswerMdRef={(ref)=>this.getanswerMdRef(ref)}
>
@ -385,6 +463,7 @@ class Questionitem_banks extends Component {
<JudquestionEditor
{...this.state}
{...this.props}
item_banksedit={this.state.item_banksedit}
getanswerMdRef={(ref)=>this.getJudquestio(ref)}
>

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

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

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

Loading…
Cancel
Save