|
|
|
@ -38,7 +38,7 @@ class NullEditor extends Component{
|
|
|
|
|
answers.answer_text.forEach((item, itemIndex) => {
|
|
|
|
|
_standard_answers[index].push(item)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.state = {
|
|
|
|
@ -53,7 +53,7 @@ class NullEditor extends Component{
|
|
|
|
|
this.setState({ is_ordered: e.target.checked})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onSave = () => {
|
|
|
|
|
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
|
|
|
|
@ -78,8 +78,8 @@ class NullEditor extends Component{
|
|
|
|
|
this.props.showNotification('分值:必须大于0'); return;
|
|
|
|
|
} else if(!question_score || intScore == NaN) {
|
|
|
|
|
this.props.showNotification('分值:不能为空'); return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let isEmpty = false;
|
|
|
|
|
standard_answers.forEach((answers, index) => {
|
|
|
|
@ -91,8 +91,8 @@ class NullEditor extends Component{
|
|
|
|
|
answerArray[index].answer_text.push(item)
|
|
|
|
|
if(!item) {
|
|
|
|
|
this.refs[`nullChildEditor${index}`].showError(itemIndex)
|
|
|
|
|
// this.props.showNotification(`请先输入第${index+1}个填空的第${itemIndex+1}参考答案。`);
|
|
|
|
|
this.props.showNotification(`答案:不能为空`);
|
|
|
|
|
// this.props.showNotification(`请先输入第${index+1}个填空的第${itemIndex+1}参考答案。`);
|
|
|
|
|
this.props.showNotification(`答案:不能为空`);
|
|
|
|
|
isEmpty = true;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
@ -122,7 +122,7 @@ class NullEditor extends Component{
|
|
|
|
|
"is_ordered":true
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
const Id = this.props.match.params.Id
|
|
|
|
|
const Id = this.props.match.params.Id
|
|
|
|
|
if (question_id) {
|
|
|
|
|
const editUrl = this.props.getEditQuestionUrl(question_id);
|
|
|
|
|
axios.put(editUrl, {
|
|
|
|
@ -146,7 +146,7 @@ class NullEditor extends Component{
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
const url = this.props.getAddQuestionUrl();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
axios.post(url, {
|
|
|
|
|
exercise_bank_id: Id,
|
|
|
|
|
question_title,
|
|
|
|
@ -165,13 +165,13 @@ class NullEditor extends Component{
|
|
|
|
|
.catch(function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onCancel = () => {
|
|
|
|
|
this.props.onEditorCancel()
|
|
|
|
|
}
|
|
|
|
|
componentDidMount = () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
on_question_score_change = (e) => {
|
|
|
|
|
this.setState({ question_score: e })
|
|
|
|
@ -195,13 +195,13 @@ class NullEditor extends Component{
|
|
|
|
|
this.mdReactObject.toShowMode()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onAnswerChange = (index, itemIndex, val) => {
|
|
|
|
|
if (this.state.standard_answers[index]) {
|
|
|
|
|
this.setState(
|
|
|
|
|
(prevState) => ({
|
|
|
|
|
(prevState) => ({
|
|
|
|
|
standard_answers : update(prevState.standard_answers
|
|
|
|
|
, {[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) => {
|
|
|
|
|
if(!this.state.standard_answers[index][childIndex]) {
|
|
|
|
|
this.setState(
|
|
|
|
@ -258,16 +273,16 @@ class NullEditor extends Component{
|
|
|
|
|
}
|
|
|
|
|
this.mdReactObject = that;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
let { question_title, question_score, question_type, question_choices, standard_answers
|
|
|
|
|
, is_ordered } = this.state;
|
|
|
|
|
let { question_id, index, exerciseIsPublish,
|
|
|
|
|
// question_title,
|
|
|
|
|
// question_type,
|
|
|
|
|
// question_title,
|
|
|
|
|
// question_type,
|
|
|
|
|
// question_score,
|
|
|
|
|
isNew } = this.props;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const { getFieldDecorator } = this.props.form;
|
|
|
|
|
|
|
|
|
|
const isAdmin = this.props.isAdmin()
|
|
|
|
@ -302,17 +317,17 @@ class NullEditor extends Component{
|
|
|
|
|
<span className="color-grey-9 font-12 fl">(客观题,由系统自动评分,允许手动调分,请设置标准答案 ;支持最多5个空,每空得分按照本题的总分平均计算)</span>
|
|
|
|
|
</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})}
|
|
|
|
|
onPlaceholderChange={this.onPlaceholderChange} showNullButton={exerciseIsPublish ? false : true}
|
|
|
|
|
ref="titleEditor"
|
|
|
|
|
></NullMDEditor>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div className="clearfix">
|
|
|
|
|
{
|
|
|
|
|
standard_answers.map((answers, index) => {
|
|
|
|
|
|
|
|
|
|
return <NullChildEditor
|
|
|
|
|
return <NullChildEditor
|
|
|
|
|
ref={`nullChildEditor${index}`}
|
|
|
|
|
{...this.props}
|
|
|
|
|
toMDMode={this.toMDMode}
|
|
|
|
@ -321,6 +336,7 @@ class NullEditor extends Component{
|
|
|
|
|
onAnswerChange={this.onAnswerChange}
|
|
|
|
|
addChildAnswer={this.addChildAnswer}
|
|
|
|
|
deleteChildAnswer={this.deleteChildAnswer}
|
|
|
|
|
deleteChildAnswermain={this.deleteChildAnswermain}
|
|
|
|
|
></NullChildEditor>
|
|
|
|
|
// answer.map((item, itemIndex) => {
|
|
|
|
|
// return <DMDEditor
|
|
|
|
@ -331,7 +347,7 @@ class NullEditor extends Component{
|
|
|
|
|
// })
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<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}
|
|
|
|
|
disabled={exerciseIsPublish} placeholder="请填写分数"
|
|
|
|
|
></InputNumber > 分
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span className="fr">
|
|
|
|
|
<ActionBtn style="greyBack" className="middle mr20" onClick={this.onCancel}
|
|
|
|
|
>取消</ActionBtn>
|
|
|
|
|
<ActionBtn style="blue" className="middle" onClick={this.onSave}>保存</ActionBtn>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|