@ -38,7 +38,7 @@ class NullEditor extends Component{
answers . answer _text . forEach ( ( item , itemIndex ) => {
answers . answer _text . forEach ( ( item , itemIndex ) => {
_standard _answers [ index ] . push ( item )
_standard _answers [ index ] . push ( item )
} )
} )
} )
} )
}
}
this . state = {
this . state = {
@ -53,7 +53,7 @@ class NullEditor extends Component{
this . setState ( { is _ordered : e . target . checked } )
this . setState ( { is _ordered : e . target . checked } )
}
}
onSave = ( ) => {
onSave = ( ) => {
const { question _title , question _score , question _type , question _choices , standard _answers , is _ordered } = this . state ;
const { question _title , question _score , question _type , question _choices , standard _answers , is _ordered } = this . state ;
const { question _id _to _insert _after , question _id } = this . props
const { question _id _to _insert _after , question _id } = this . props
@ -78,8 +78,8 @@ class NullEditor extends Component{
this . props . showNotification ( '分值: 必须大于0' ) ; return ;
this . props . showNotification ( '分值: 必须大于0' ) ; return ;
} else if ( ! question _score || intScore == NaN ) {
} else if ( ! question _score || intScore == NaN ) {
this . props . showNotification ( '分值:不能为空' ) ; return ;
this . props . showNotification ( '分值:不能为空' ) ; return ;
}
}
let isEmpty = false ;
let isEmpty = false ;
standard _answers . forEach ( ( answers , index ) => {
standard _answers . forEach ( ( answers , index ) => {
@ -91,8 +91,8 @@ class NullEditor extends Component{
answerArray [ index ] . answer _text . push ( item )
answerArray [ index ] . answer _text . push ( item )
if ( ! item ) {
if ( ! item ) {
this . refs [ ` nullChildEditor ${ index } ` ] . showError ( itemIndex )
this . refs [ ` nullChildEditor ${ index } ` ] . showError ( itemIndex )
// this.props.showNotification(`请先输入第${index+1}个填空的第${itemIndex+1}参考答案。`);
// this.props.showNotification(`请先输入第${index+1}个填空的第${itemIndex+1}参考答案。`);
this . props . showNotification ( ` 答案:不能为空 ` ) ;
this . props . showNotification ( ` 答案:不能为空 ` ) ;
isEmpty = true ;
isEmpty = true ;
}
}
} )
} )
@ -122,7 +122,7 @@ class NullEditor extends Component{
"is_ordered" : true
"is_ordered" : true
}
}
} * /
} * /
const Id = this . props . match . params . Id
const Id = this . props . match . params . Id
if ( question _id ) {
if ( question _id ) {
const editUrl = this . props . getEditQuestionUrl ( question _id ) ;
const editUrl = this . props . getEditQuestionUrl ( question _id ) ;
axios . put ( editUrl , {
axios . put ( editUrl , {
@ -146,7 +146,7 @@ class NullEditor extends Component{
} ) ;
} ) ;
} else {
} else {
const url = this . props . getAddQuestionUrl ( ) ;
const url = this . props . getAddQuestionUrl ( ) ;
axios . post ( url , {
axios . post ( url , {
exercise _bank _id : Id ,
exercise _bank _id : Id ,
question _title ,
question _title ,
@ -165,13 +165,13 @@ class NullEditor extends Component{
. catch ( function ( error ) {
. catch ( function ( error ) {
console . log ( error ) ;
console . log ( error ) ;
} ) ;
} ) ;
}
}
}
}
onCancel = ( ) => {
onCancel = ( ) => {
this . props . onEditorCancel ( )
this . props . onEditorCancel ( )
}
}
componentDidMount = ( ) => {
componentDidMount = ( ) => {
}
}
on _question _score _change = ( e ) => {
on _question _score _change = ( e ) => {
this . setState ( { question _score : e } )
this . setState ( { question _score : e } )
@ -195,13 +195,13 @@ class NullEditor extends Component{
this . mdReactObject . toShowMode ( )
this . mdReactObject . toShowMode ( )
}
}
} )
} )
}
}
onAnswerChange = ( index , itemIndex , val ) => {
onAnswerChange = ( index , itemIndex , val ) => {
if ( this . state . standard _answers [ index ] ) {
if ( this . state . standard _answers [ index ] ) {
this . setState (
this . setState (
( prevState ) => ( {
( prevState ) => ( {
standard _answers : update ( prevState . standard _answers
standard _answers : update ( prevState . standard _answers
, { [ index ] : { $splice : [ [ itemIndex , 1 , val ] ] } } ) ,
, { [ index ] : { $splice : [ [ itemIndex , 1 , val ] ] } } ) ,
} )
} )
@ -217,6 +217,21 @@ class NullEditor extends Component{
)
)
}
}
deleteChildAnswermain = ( index , childIndex ) => {
let newstandard _answers = this . state . standard _answers
this . props . confirm ( {
content : ` 确认要删除这个参考答案吗? ` ,
onOk : ( ) => {
newstandard _answers . splice ( index , 1 )
this . setState ( {
standard _answers : newstandard _answers
} )
}
} )
}
deleteChildAnswer = ( index , childIndex ) => {
deleteChildAnswer = ( index , childIndex ) => {
if ( ! this . state . standard _answers [ index ] [ childIndex ] ) {
if ( ! this . state . standard _answers [ index ] [ childIndex ] ) {
this . setState (
this . setState (
@ -258,16 +273,16 @@ class NullEditor extends Component{
}
}
this . mdReactObject = that ;
this . mdReactObject = that ;
}
}
render ( ) {
render ( ) {
let { question _title , question _score , question _type , question _choices , standard _answers
let { question _title , question _score , question _type , question _choices , standard _answers
, is _ordered } = this . state ;
, is _ordered } = this . state ;
let { question _id , index , exerciseIsPublish ,
let { question _id , index , exerciseIsPublish ,
// question_title,
// question_title,
// question_type,
// question_type,
// question_score,
// question_score,
isNew } = this . props ;
isNew } = this . props ;
// const { getFieldDecorator } = this.props.form;
// const { getFieldDecorator } = this.props.form;
const isAdmin = this . props . isAdmin ( )
const isAdmin = this . props . isAdmin ( )
@ -302,17 +317,17 @@ class NullEditor extends Component{
< span className = "color-grey-9 font-12 fl" > ( 客观题 , 由系统自动评分 , 允许手动调分 , 请设置标准答案 ; 支持最多5个空 , 每空得分按照本题的总分平均计算 ) < / s p a n >
< span className = "color-grey-9 font-12 fl" > ( 客观题 , 由系统自动评分 , 允许手动调分 , 请设置标准答案 ; 支持最多5个空 , 每空得分按照本题的总分平均计算 ) < / s p a n >
< / p >
< / p >
< NullMDEditor { ... this . props } mdID = { ` question_ ${ question _id } ` } placeholder = "请您输入题目" height = { 155 }
< NullMDEditor { ... this . props } mdID = { ` question_ ${ question _id } ` } placeholder = "请您输入题目" height = { 155 }
initValue = { question _title } onChange = { ( val ) => this . setState ( { question _title : val } ) }
initValue = { question _title } onChange = { ( val ) => this . setState ( { question _title : val } ) }
onPlaceholderChange = { this . onPlaceholderChange } showNullButton = { exerciseIsPublish ? false : true }
onPlaceholderChange = { this . onPlaceholderChange } showNullButton = { exerciseIsPublish ? false : true }
ref = "titleEditor"
ref = "titleEditor"
> < / N u l l M D E d i t o r >
> < / N u l l M D E d i t o r >
< div className = "clearfix" >
< div className = "clearfix" >
{
{
standard _answers . map ( ( answers , index ) => {
standard _answers . map ( ( answers , index ) => {
return < NullChildEditor
return < NullChildEditor
ref = { ` nullChildEditor ${ index } ` }
ref = { ` nullChildEditor ${ index } ` }
{ ... this . props }
{ ... this . props }
toMDMode = { this . toMDMode }
toMDMode = { this . toMDMode }
@ -321,6 +336,7 @@ class NullEditor extends Component{
onAnswerChange = { this . onAnswerChange }
onAnswerChange = { this . onAnswerChange }
addChildAnswer = { this . addChildAnswer }
addChildAnswer = { this . addChildAnswer }
deleteChildAnswer = { this . deleteChildAnswer }
deleteChildAnswer = { this . deleteChildAnswer }
deleteChildAnswermain = { this . deleteChildAnswermain }
> < / N u l l C h i l d E d i t o r >
> < / N u l l C h i l d E d i t o r >
// answer.map((item, itemIndex) => {
// answer.map((item, itemIndex) => {
// return <DMDEditor
// return <DMDEditor
@ -331,7 +347,7 @@ class NullEditor extends Component{
// })
// })
} )
} )
}
}
< / d i v >
< / d i v >
< div className = "clearfix " >
< div className = "clearfix " >
@ -346,16 +362,16 @@ class NullEditor extends Component{
< InputNumber step = { 0.1 } precision = { 1 } min = { 0 } max = { 100 } style = { { width : 100 } } value = { question _score } onChange = { this . on _question _score _change }
< InputNumber step = { 0.1 } precision = { 1 } min = { 0 } max = { 100 } style = { { width : 100 } } value = { question _score } onChange = { this . on _question _score _change }
disabled = { exerciseIsPublish } placeholder = "请填写分数"
disabled = { exerciseIsPublish } placeholder = "请填写分数"
> < / I n p u t N u m b e r > 分
> < / I n p u t N u m b e r > 分
< span className = "fr" >
< span className = "fr" >
< ActionBtn style = "greyBack" className = "middle mr20" onClick = { this . onCancel }
< ActionBtn style = "greyBack" className = "middle mr20" onClick = { this . onCancel }
> 取消 < / A c t i o n B t n >
> 取消 < / A c t i o n B t n >
< ActionBtn style = "blue" className = "middle" onClick = { this . onSave } > 保存 < / A c t i o n B t n >
< ActionBtn style = "blue" className = "middle" onClick = { this . onSave } > 保存 < / A c t i o n B t n >
< / s p a n >
< / s p a n >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
)
)
}
}