diff --git a/public/react/src/modules/courses/exercise/new/JudgeEditor.js b/public/react/src/modules/courses/exercise/new/JudgeEditor.js
index f43312f5e..280faa2e3 100644
--- a/public/react/src/modules/courses/exercise/new/JudgeEditor.js
+++ b/public/react/src/modules/courses/exercise/new/JudgeEditor.js
@@ -55,7 +55,9 @@ class SingleEditor extends Component{
// TODO check
const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1);
if(!question_title) {
+ this.refs['titleEditor'].showError()
this.props.showNotification('题目不能为空'); return;
+
}
const intScore = parseFloat(question_score)
if(!question_score || intScore == NaN) {
@@ -69,7 +71,9 @@ class SingleEditor extends Component{
this.props.showNotification('请先点击本题的正确选项'); return;
}
if(!question_title) {
+ this.refs['titleEditor'].showError()
this.props.showNotification('题目不能为空'); return;
+
}
/**
@@ -185,6 +189,7 @@ class SingleEditor extends Component{
this.setState({ question_title: val})}
+ ref="titleEditor"
>
diff --git a/public/react/src/modules/courses/exercise/new/MainEditor.js b/public/react/src/modules/courses/exercise/new/MainEditor.js
index 52d3e24bc..9f6e643df 100644
--- a/public/react/src/modules/courses/exercise/new/MainEditor.js
+++ b/public/react/src/modules/courses/exercise/new/MainEditor.js
@@ -45,7 +45,10 @@ class MainEditor extends Component{
// TODO check
const answerArray = standard_answers
if(!question_title) {
+ this.refs['titleEditor'].showError()
this.props.showNotification('题目不能为空'); return;
+
+
}
const intScore = parseFloat(question_score)
if(!question_score || intScore == NaN) {
@@ -151,7 +154,7 @@ class MainEditor extends Component{
this.setState({ question_title: val})}
- noStorage={true}
+ noStorage={true} ref="titleEditor"
>
diff --git a/public/react/src/modules/courses/exercise/new/NullChildEditor.js b/public/react/src/modules/courses/exercise/new/NullChildEditor.js
index 434211f1d..9e50e2ad3 100644
--- a/public/react/src/modules/courses/exercise/new/NullChildEditor.js
+++ b/public/react/src/modules/courses/exercise/new/NullChildEditor.js
@@ -35,6 +35,10 @@ class NullChildEditor extends Component{
// this.mdReactObject = that;
// }
+ showError = (itemIndex) => {
+ this.refs[`nullChildDMDEditor${itemIndex}`].showError()
+ }
+
render() {
let { question_title, question_score, question_type, question_choices, standard_answers } = this.state;
let { question_id, index, onAnswerChange, addChildAnswer, toMDMode, exerciseIsPublish,
@@ -49,6 +53,7 @@ class NullChildEditor extends Component{
return
{ return item == true ? index+1 : -1 }).filter(item => item != -1);
let answerArray = []
if(!question_title) {
+ this.refs['titleEditor'].showError()
this.props.showNotification('题目不能为空'); return;
+
}
const intScore = parseFloat(question_score)
if(!question_score || intScore == NaN) {
@@ -88,6 +90,7 @@ class NullEditor extends Component{
answers.forEach((item, itemIndex) => {
answerArray[index].answer_text.push(item)
if(!item) {
+ this.refs[`nullChildEditor${index}`].showError(itemIndex)
this.props.showNotification(`请先输入第${index+1}个填空的第${itemIndex+1}参考答案。`);
isEmpty = true;
}
@@ -97,7 +100,9 @@ class NullEditor extends Component{
return;
}
if(!question_title) {
+ this.refs['titleEditor'].showError()
this.props.showNotification('题目不能为空'); return;
+
}
/**
@@ -294,13 +299,16 @@ class NullEditor extends Component{
this.setState({ question_title: val})}
onPlaceholderChange={this.onPlaceholderChange} showNullButton={exerciseIsPublish ? false : true}
+ ref="titleEditor"
>
{
standard_answers.map((answers, index) => {
- return
{
+ this.refs['nullMDEditor'].showError()
+ }
render() {
let {
@@ -94,6 +96,7 @@ export default class NullMDEditor extends Component {
return (
)
diff --git a/public/react/src/modules/courses/exercise/new/SingleEditor.js b/public/react/src/modules/courses/exercise/new/SingleEditor.js
index ee8d3c204..a9e8aa3f5 100644
--- a/public/react/src/modules/courses/exercise/new/SingleEditor.js
+++ b/public/react/src/modules/courses/exercise/new/SingleEditor.js
@@ -87,7 +87,10 @@ class SingleEditor extends Component{
// TODO check
const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1);
if(!question_title) {
+ this.refs['titleEditor'].showError()
this.props.showNotification('题目不能为空'); return;
+
+
}
const intScore = parseFloat(question_score)
if(!question_score || intScore == NaN) {
@@ -101,11 +104,15 @@ class SingleEditor extends Component{
this.props.showNotification('请先点击选择本选择题的正确选项'); return;
}
if(!question_title) {
+ this.refs['titleEditor'].showError()
this.props.showNotification('题目不能为空'); return;
+
+
}
for(let i = 0; i < question_choices.length; i++) {
if (!question_choices[i]) {
+ this.refs[`optionEditor${i}`].showError()
this.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`); return;
}
}
@@ -237,6 +244,8 @@ class SingleEditor extends Component{
this.setState({ question_title: val})}
+ ref="titleEditor"
+
>
{question_choices.map( (item, index) => {
@@ -254,6 +263,7 @@ class SingleEditor extends Component{
{/* */}
this.onOptionContentChange(value, index)}
diff --git a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js
index 223065864..46f3a4128 100644
--- a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js
+++ b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js
@@ -239,7 +239,9 @@ export default class TPMMDEditor extends Component {
}
__editorName.cm.on("change", (_cm, changeObj) => {
that.contentChanged = true;
-
+ if (that.state.showError) {
+ that.setState({showError: false})
+ }
that.onEditorChange()
})
that.props.onCMBlur && __editorName.cm.on('blur', () => {
@@ -256,6 +258,9 @@ export default class TPMMDEditor extends Component {
}, this);
}
+ showError = () => {
+ this.setState({showError: true})
+ }
onEditorChange = () => {
if (!this.answers_editormd) return;
const val = this.answers_editormd.getValue();
@@ -297,14 +302,18 @@ export default class TPMMDEditor extends Component {
render() {
let {
- choice_url,
+ showError
} = this.state;
let { mdID, className, noStorage } = this.props;
+ let _style = {}
+ if (showError) {
+ _style.border = '1px solid red'
+ }
return (
-
+
{/* padding10-20 */}
-
+
From 14a638c34ecd7648aa2b2b7a943ddc8d6be6fac9 Mon Sep 17 00:00:00 2001
From: hjm <63528605@qq.com>
Date: Sat, 29 Jun 2019 15:23:39 +0800
Subject: [PATCH 6/6] =?UTF-8?q?=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/exercise/new/JudgeEditor.js | 10 +++++-----
.../src/modules/courses/exercise/new/MainEditor.js | 6 +++---
.../src/modules/courses/exercise/new/NullEditor.js | 11 ++++++-----
.../src/modules/courses/exercise/new/ShixunEditor.js | 2 +-
.../src/modules/courses/exercise/new/SingleEditor.js | 4 ++--
5 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/public/react/src/modules/courses/exercise/new/JudgeEditor.js b/public/react/src/modules/courses/exercise/new/JudgeEditor.js
index 280faa2e3..586d77ed0 100644
--- a/public/react/src/modules/courses/exercise/new/JudgeEditor.js
+++ b/public/react/src/modules/courses/exercise/new/JudgeEditor.js
@@ -56,23 +56,23 @@ class SingleEditor extends Component{
const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1);
if(!question_title) {
this.refs['titleEditor'].showError()
- this.props.showNotification('题目不能为空'); return;
+ this.props.showNotification('题目:不能为空'); return;
}
const intScore = parseFloat(question_score)
if(!question_score || intScore == NaN) {
- this.props.showNotification('分值不能为空'); return;
+ this.props.showNotification('分值:不能为空'); return;
} else {
if (intScore == 0) {
- this.props.showNotification('分值必须大于0'); return;
+ this.props.showNotification('分值:必须大于0'); return;
}
}
if(!answerArray || answerArray.length == 0) {
- this.props.showNotification('请先点击本题的正确选项'); return;
+ this.props.showNotification('必须设置标准答案'); return;
}
if(!question_title) {
this.refs['titleEditor'].showError()
- this.props.showNotification('题目不能为空'); return;
+ this.props.showNotification('题目:不能为空'); return;
}
diff --git a/public/react/src/modules/courses/exercise/new/MainEditor.js b/public/react/src/modules/courses/exercise/new/MainEditor.js
index 9f6e643df..e9dd3b105 100644
--- a/public/react/src/modules/courses/exercise/new/MainEditor.js
+++ b/public/react/src/modules/courses/exercise/new/MainEditor.js
@@ -46,16 +46,16 @@ class MainEditor extends Component{
const answerArray = standard_answers
if(!question_title) {
this.refs['titleEditor'].showError()
- this.props.showNotification('题目不能为空'); return;
+ this.props.showNotification('题目:不能为空'); return;
}
const intScore = parseFloat(question_score)
if(!question_score || intScore == NaN) {
- this.props.showNotification('分值不能为空'); return;
+ this.props.showNotification('分值:不能为空'); return;
} else {
if (intScore == 0) {
- this.props.showNotification('分值必须大于0'); return;
+ this.props.showNotification('分值:必须大于0'); return;
}
}
// if(!answerArray || answerArray.length == 0 || !answerArray[0]) {
diff --git a/public/react/src/modules/courses/exercise/new/NullEditor.js b/public/react/src/modules/courses/exercise/new/NullEditor.js
index dddadcf0a..299daf904 100644
--- a/public/react/src/modules/courses/exercise/new/NullEditor.js
+++ b/public/react/src/modules/courses/exercise/new/NullEditor.js
@@ -70,15 +70,15 @@ class NullEditor extends Component{
let answerArray = []
if(!question_title) {
this.refs['titleEditor'].showError()
- this.props.showNotification('题目不能为空'); return;
+ this.props.showNotification('题目:不能为空'); return;
}
const intScore = parseFloat(question_score)
if(!question_score || intScore == NaN) {
- this.props.showNotification('分值不能为空'); return;
+ this.props.showNotification('分值:不能为空'); return;
} else {
if (intScore == 0) {
- this.props.showNotification('分值必须大于0'); return;
+ this.props.showNotification('分值:必须大于0'); return;
}
}
let isEmpty = false;
@@ -91,7 +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(`请先输入第${index+1}个填空的第${itemIndex+1}参考答案。`);
+ this.props.showNotification(`答案:不能为空`);
isEmpty = true;
}
})
@@ -101,7 +102,7 @@ class NullEditor extends Component{
}
if(!question_title) {
this.refs['titleEditor'].showError()
- this.props.showNotification('题目不能为空'); return;
+ this.props.showNotification('题目:不能为空'); return;
}
diff --git a/public/react/src/modules/courses/exercise/new/ShixunEditor.js b/public/react/src/modules/courses/exercise/new/ShixunEditor.js
index 581467257..e4835ee10 100644
--- a/public/react/src/modules/courses/exercise/new/ShixunEditor.js
+++ b/public/react/src/modules/courses/exercise/new/ShixunEditor.js
@@ -98,7 +98,7 @@ class ShixunEditor extends Component{
// }
for(let _i = 0; _i < question_scores.length; _i++) {
if (!question_scores[_i] || question_scores[_i] == '0') {
- this.props.showNotification(`第${_i+1}题的分值必须大于0`); return;
+ this.props.showNotification(`第${_i+1}题的分值:必须大于0`); return;
}
}
diff --git a/public/react/src/modules/courses/exercise/new/SingleEditor.js b/public/react/src/modules/courses/exercise/new/SingleEditor.js
index a9e8aa3f5..8e68a593c 100644
--- a/public/react/src/modules/courses/exercise/new/SingleEditor.js
+++ b/public/react/src/modules/courses/exercise/new/SingleEditor.js
@@ -88,7 +88,7 @@ class SingleEditor extends Component{
const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1);
if(!question_title) {
this.refs['titleEditor'].showError()
- this.props.showNotification('题目不能为空'); return;
+ this.props.showNotification('题目:不能为空'); return;
}
@@ -105,7 +105,7 @@ class SingleEditor extends Component{
}
if(!question_title) {
this.refs['titleEditor'].showError()
- this.props.showNotification('题目不能为空'); return;
+ this.props.showNotification('题目:不能为空'); return;
}