Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
2e7ee804
Commit
2e7ee804
authored
Mar 18, 2021
by
sunbingqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 编辑赋值
parent
0e1a2057
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
27 deletions
+51
-27
src/modules/teach-tool/components/NewQuestionTab.jsx
+41
-24
src/modules/teach-tool/components/QuestionEditor.jsx
+10
-3
No files found.
src/modules/teach-tool/components/NewQuestionTab.jsx
View file @
2e7ee804
/*
/*
* @Author: yuananting
* @Author: yuananting
* @Date: 2021-02-25 14:34:29
* @Date: 2021-02-25 14:34:29
* @LastEditors:
yuanant
ing
* @LastEditors:
sunbingq
ing
* @LastEditTime: 2021-03-18
09:33:34
* @LastEditTime: 2021-03-18
14:49:27
* @Description: 助学工具-题库-题目管理-新建题目Tab
* @Description: 助学工具-题库-题目管理-新建题目Tab
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
*/
...
@@ -99,6 +99,12 @@ class NewQuestionTab extends Component {
...
@@ -99,6 +99,12 @@ class NewQuestionTab extends Component {
shouldComponentUpdate
(
nextProps
,
nextState
)
{
shouldComponentUpdate
(
nextProps
,
nextState
)
{
const
{
questionInfo
}
=
nextProps
;
const
{
questionInfo
}
=
nextProps
;
if
(
this
.
props
.
questionInfo
!==
questionInfo
)
{
if
(
this
.
props
.
questionInfo
!==
questionInfo
)
{
if
(
questionInfo
.
gapFillingAnswerList
!==
this
.
state
.
gapFillingAnswer
)
{
console
.
log
(
999
,
questionInfo
.
gapFillingAnswerList
)
this
.
setState
({
gapFillingAnswer
:
questionInfo
.
gapFillingAnswerList
})
}
this
.
setState
(
this
.
setState
(
{
{
stemContent
:
JSON
.
parse
(
stemContent
:
JSON
.
parse
(
...
@@ -106,12 +112,13 @@ class NewQuestionTab extends Component {
...
@@ -106,12 +112,13 @@ class NewQuestionTab extends Component {
),
),
},
},
()
=>
{
()
=>
{
const
editorHtml
=
this
.
transferStemDocument
(
const
con
=
questionInfo
.
questionStemList
[
0
].
content
;
questionInfo
.
questionStemList
[
0
].
content
const
input
=
con
.
match
(
/<input
([^
<>
]
*
)
>/g
)
);
const
_blanksList
=
input
.
map
(
item
=>
{
const
_blanksList
=
editorHtml
.
getElementsByClassName
(
"fill-line"
);
return
this
.
transferStemDocument
(
item
).
firstChild
// this.setState({blanksList:_blanksList})
})
console
.
log
(
"转:"
,
editorHtml
.
getElementsByClassName
(
"fill-line"
));
console
.
log
(
"-----"
,
_blanksList
)
this
.
setState
({
blanksList
:
_blanksList
})
}
}
);
// 题干内容
);
// 题干内容
this
.
setState
({
this
.
setState
({
...
@@ -197,7 +204,7 @@ class NewQuestionTab extends Component {
...
@@ -197,7 +204,7 @@ class NewQuestionTab extends Component {
const
{
chooseOptions
}
=
this
.
state
;
const
{
chooseOptions
}
=
this
.
state
;
if
(
this
.
props
.
questionTypeKey
===
"GAP_FILLING"
)
{
if
(
this
.
props
.
questionTypeKey
===
"GAP_FILLING"
)
{
this
.
state
.
blanksList
.
forEach
((
item
,
index
)
=>
{
this
.
state
.
blanksList
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
answerTag
List
.
length
===
0
)
{
if
(
item
.
correctAnswer
List
.
length
===
0
)
{
this
.
setState
({
[
`optionsValidate_
${
index
}
`
]:
"error"
});
this
.
setState
({
[
`optionsValidate_
${
index
}
`
]:
"error"
});
this
.
setState
({
[
`optionsText_
${
index
}
`
]:
"请输入答案"
});
this
.
setState
({
[
`optionsText_
${
index
}
`
]:
"请输入答案"
});
validateError
++
;
validateError
++
;
...
@@ -525,9 +532,9 @@ class NewQuestionTab extends Component {
...
@@ -525,9 +532,9 @@ class NewQuestionTab extends Component {
changeBlankCount
=
(
data
)
=>
{
changeBlankCount
=
(
data
)
=>
{
console
.
log
(
"data:"
,
data
);
console
.
log
(
"data:"
,
data
);
data
.
forEach
((
item
)
=>
{
data
&&
data
.
length
>
0
&&
data
.
forEach
((
item
)
=>
{
if
(
!
item
.
answerTag
List
)
{
if
(
!
item
.
correctAnswer
List
)
{
item
.
answerTag
List
=
[];
item
.
correctAnswer
List
=
[];
}
}
item
.
inputVisible
=
false
;
item
.
inputVisible
=
false
;
item
.
errorHold
=
false
;
item
.
errorHold
=
false
;
...
@@ -536,7 +543,7 @@ class NewQuestionTab extends Component {
...
@@ -536,7 +543,7 @@ class NewQuestionTab extends Component {
});
});
this
.
setState
({
blanksList
:
data
});
this
.
setState
({
blanksList
:
data
});
};
};
addAnswerTag
=
(
optionItem
)
=>
{
addAnswerTag
=
(
optionItem
)
=>
{
const
_blanksList
=
this
.
state
.
blanksList
;
const
_blanksList
=
this
.
state
.
blanksList
;
_blanksList
.
forEach
((
item
)
=>
{
_blanksList
.
forEach
((
item
)
=>
{
...
@@ -549,19 +556,26 @@ class NewQuestionTab extends Component {
...
@@ -549,19 +556,26 @@ class NewQuestionTab extends Component {
handleInputConfirm
=
(
optionItem
,
val
)
=>
{
handleInputConfirm
=
(
optionItem
,
val
)
=>
{
const
_blanksList
=
this
.
state
.
blanksList
;
const
_blanksList
=
this
.
state
.
blanksList
;
var
gapFillingAnswer
=
[];
// const { gapFillingAnswer } = this.state;
_blanksList
.
forEach
((
item
)
=>
{
let
_gapFillingAnswer
=
[];
_blanksList
.
forEach
((
item
,
index
)
=>
{
gapFillingAnswer
.
push
({
correctAnswerList
:
item
.
answerTagList
});
gapFillingAnswer
.
push
({
correctAnswerList
:
item
.
answerTagList
});
// if (gapFillingAnswer[index] && gapFillingAnswer[index].correctAnswerList) {
// _gapFillingAnswer[index] = gapFillingAnswer[index]
// } else {
// _gapFillingAnswer.push({ correctAnswerList: item.correctAnswerList });
// }
if
(
item
.
id
===
optionItem
.
id
)
{
if
(
item
.
id
===
optionItem
.
id
)
{
if
(
val
)
{
if
(
val
)
{
optionItem
.
answerTag
List
.
push
(
val
);
optionItem
.
correctAnswer
List
.
push
(
val
);
optionItem
.
inputVisible
=
false
;
optionItem
.
inputVisible
=
false
;
}
else
{
}
else
{
optionItem
.
errorHold
=
true
;
optionItem
.
errorHold
=
true
;
}
}
}
}
});
});
this
.
setState
({
gapFillingAnswer
},
()
=>
this
.
_onSetState
());
console
.
log
(
8888
,
_gapFillingAnswer
)
this
.
setState
({
gapFillingAnswer
:
_gapFillingAnswer
},
()
=>
this
.
_onSetState
());
this
.
setState
({
blanksList
:
_blanksList
});
this
.
setState
({
blanksList
:
_blanksList
});
};
};
...
@@ -569,7 +583,7 @@ class NewQuestionTab extends Component {
...
@@ -569,7 +583,7 @@ class NewQuestionTab extends Component {
const
_blanksList
=
this
.
state
.
blanksList
;
const
_blanksList
=
this
.
state
.
blanksList
;
_blanksList
.
forEach
((
item
)
=>
{
_blanksList
.
forEach
((
item
)
=>
{
if
(
item
.
id
===
optionItem
.
id
)
{
if
(
item
.
id
===
optionItem
.
id
)
{
optionItem
=
optionItem
.
answerTag
List
.
filter
(
optionItem
=
optionItem
.
correctAnswer
List
.
filter
(
(
tag
)
=>
tag
!==
removedTag
(
tag
)
=>
tag
!==
removedTag
);
);
}
}
...
@@ -581,13 +595,17 @@ class NewQuestionTab extends Component {
...
@@ -581,13 +595,17 @@ class NewQuestionTab extends Component {
const
_blanksList
=
this
.
state
.
blanksList
;
const
_blanksList
=
this
.
state
.
blanksList
;
_blanksList
.
forEach
((
item
)
=>
{
_blanksList
.
forEach
((
item
)
=>
{
if
(
item
.
id
===
optionItem
.
id
)
{
if
(
item
.
id
===
optionItem
.
id
)
{
item
.
answerTag
List
.
map
();
item
.
correctAnswer
List
.
map
();
}
}
});
});
this
.
setState
({
blanksList
:
_blanksList
});
this
.
setState
({
blanksList
:
_blanksList
});
};
};
renderGapFillingAnswer
=
(
optionItem
,
optionIndex
)
=>
{
renderGapFillingAnswer
=
(
optionItem
,
optionIndex
)
=>
{
console
.
log
(
11111
,
optionItem
)
const
{
gapFillingAnswer
}
=
this
.
state
;
console
.
log
(
222
,
gapFillingAnswer
)
const
list
=
gapFillingAnswer
[
optionIndex
]
&&
gapFillingAnswer
[
optionIndex
].
correctAnswerList
;
return
(
return
(
<
div
className=
"gap-answer-box"
key=
{
optionIndex
}
>
<
div
className=
"gap-answer-box"
key=
{
optionIndex
}
>
<
span
className=
"gap-answer-label"
>
<
span
className=
"gap-answer-label"
>
...
@@ -595,7 +613,7 @@ class NewQuestionTab extends Component {
...
@@ -595,7 +613,7 @@ class NewQuestionTab extends Component {
{
optionIndex
+
1
}
.
{
optionIndex
+
1
}
.
</
span
>
</
span
>
<
div
className=
"gap-answer-content"
>
<
div
className=
"gap-answer-content"
>
{
optionItem
.
answerTagL
ist
.
map
((
tag
,
index
)
=>
{
{
list
&&
l
ist
.
map
((
tag
,
index
)
=>
{
return
optionItem
.
editInput
?
(
return
optionItem
.
editInput
?
(
<
Input
<
Input
placeholder=
{
optionItem
.
errorHold
?
"请输入"
:
""
}
placeholder=
{
optionItem
.
errorHold
?
"请输入"
:
""
}
...
@@ -672,6 +690,7 @@ class NewQuestionTab extends Component {
...
@@ -672,6 +690,7 @@ class NewQuestionTab extends Component {
contentType
,
contentType
,
validateStatus
validateStatus
)
=>
{
)
=>
{
const
{
blanksList
}
=
this
.
state
;
const
isGapFilling
=
this
.
props
.
questionTypeKey
===
"GAP_FILLING"
;
const
isGapFilling
=
this
.
props
.
questionTypeKey
===
"GAP_FILLING"
;
const
editorContent
=
_
.
find
(
const
editorContent
=
_
.
find
(
contentList
,
contentList
,
...
@@ -701,6 +720,7 @@ class NewQuestionTab extends Component {
...
@@ -701,6 +720,7 @@ class NewQuestionTab extends Component {
isGapFilling=
{
isGapFilling
}
isGapFilling=
{
isGapFilling
}
contentType=
{
contentType
}
contentType=
{
contentType
}
mediaBtn=
{
mediaBtn
}
mediaBtn=
{
mediaBtn
}
blanksList=
{
blanksList
}
changeBlankCount=
{
this
.
changeBlankCount
.
bind
(
this
)
}
changeBlankCount=
{
this
.
changeBlankCount
.
bind
(
this
)
}
bindChangeContent=
{
(
cb
,
textElemId
)
=>
{
bindChangeContent=
{
(
cb
,
textElemId
)
=>
{
this
.
setState
({
textElemId
});
this
.
setState
({
textElemId
});
...
@@ -1031,7 +1051,6 @@ class NewQuestionTab extends Component {
...
@@ -1031,7 +1051,6 @@ class NewQuestionTab extends Component {
* @memberof QuestionInputItem
* @memberof QuestionInputItem
*/
*/
handleReupload
=
(
uploadItem
)
=>
{
handleReupload
=
(
uploadItem
)
=>
{
console
.
log
(
"uploadItem:"
,
uploadItem
);
uploadItem
.
status
=
"init"
;
uploadItem
.
status
=
"init"
;
Upload
.
uploadToOSSEvent
(
Upload
.
uploadToOSSEvent
(
uploadItem
.
mediaFile
,
uploadItem
.
mediaFile
,
...
@@ -1128,8 +1147,7 @@ class NewQuestionTab extends Component {
...
@@ -1128,8 +1147,7 @@ class NewQuestionTab extends Component {
}
=
this
.
state
;
}
=
this
.
state
;
const
{
stemValidate
,
stemText
,
radioValidate
,
radioText
}
=
this
.
state
;
const
{
stemValidate
,
stemText
,
radioValidate
,
radioText
}
=
this
.
state
;
const
isJudge
=
this
.
props
.
questionTypeKey
===
"JUDGE"
;
const
isJudge
=
this
.
props
.
questionTypeKey
===
"JUDGE"
;
console
.
log
(
"this.props.questionTypeKey:"
,
this
.
props
.
questionTypeKey
)
console
.
log
(
"判断:"
,
isJudge
)
const
isGapFilling
=
this
.
props
.
questionTypeKey
===
"GAP_FILLING"
;
const
isGapFilling
=
this
.
props
.
questionTypeKey
===
"GAP_FILLING"
;
const
placehold
=
isGapFilling
?
(
const
placehold
=
isGapFilling
?
(
<
span
>
<
span
>
...
@@ -1228,7 +1246,6 @@ class NewQuestionTab extends Component {
...
@@ -1228,7 +1246,6 @@ class NewQuestionTab extends Component {
questionOptionContentList
,
questionOptionContentList
,
isCorrectAnswer
,
isCorrectAnswer
,
}
=
optionItem
;
}
=
optionItem
;
console
.
log
(
"questionOptionContentList:"
,
questionOptionContentList
)
optionItem
.
optionSort
=
optionIndex
;
optionItem
.
optionSort
=
optionIndex
;
const
mediaBtn
=
[
"VOICE"
,
"RECORD"
,
"PICTURE"
];
const
mediaBtn
=
[
"VOICE"
,
"RECORD"
,
"PICTURE"
];
const
placeHold
=
const
placeHold
=
...
...
src/modules/teach-tool/components/QuestionEditor.jsx
View file @
2e7ee804
...
@@ -56,12 +56,18 @@ class QuestionEditor extends Component {
...
@@ -56,12 +56,18 @@ class QuestionEditor extends Component {
}
}
shouldComponentUpdate
(
nextProps
,
nextState
)
{
shouldComponentUpdate
(
nextProps
,
nextState
)
{
const
{
detailInfo
}
=
nextProps
;
const
{
detailInfo
,
blanksList
}
=
nextProps
;
if
(
this
.
state
.
detailInfo
!==
detailInfo
)
{
if
(
this
.
state
.
detailInfo
!==
detailInfo
)
{
this
.
setState
({
detailInfo
:
nextProps
.
detailInfo
},
()
=>
{
this
.
setState
({
detailInfo
:
nextProps
.
detailInfo
},
()
=>
{
this
.
renderEditor
();
this
.
renderEditor
();
});
});
}
}
if
(
blanksList
!==
this
.
state
.
blanksList
)
{
console
.
log
(
"+++++++"
,
blanksList
)
this
.
setState
({
blanksList
})
}
return
true
;
return
true
;
}
}
...
@@ -148,6 +154,7 @@ class QuestionEditor extends Component {
...
@@ -148,6 +154,7 @@ class QuestionEditor extends Component {
this
.
setState
({
isShowSingleInput
:
true
});
this
.
setState
({
isShowSingleInput
:
true
});
}
}
if
(
this
.
state
.
isGapFilling
)
{
if
(
this
.
state
.
isGapFilling
)
{
console
.
log
(
9999
,
this
.
state
.
isGapFilling
)
this
.
props
.
changeBlankCount
(
this
.
state
.
blanksList
);
this
.
props
.
changeBlankCount
(
this
.
state
.
blanksList
);
}
}
this
.
setState
(
this
.
setState
(
...
@@ -204,7 +211,7 @@ class QuestionEditor extends Component {
...
@@ -204,7 +211,7 @@ class QuestionEditor extends Component {
}
}
insertBlank
=
(
blanks
)
=>
{
insertBlank
=
(
blanks
)
=>
{
var
blanks
=
`<input class="add-fill-line" disabled
answerTagList="
" id=
${
window
.
random_string
(
var
blanks
=
`<input class="add-fill-line" disabled
correctAnswerList="[]
" id=
${
window
.
random_string
(
16
16
)}
value="填空"/>`
;
)}
value="填空"/>`
;
this
.
editorRoot
.
cmd
.
do
(
"insertHTML"
,
blanks
);
this
.
editorRoot
.
cmd
.
do
(
"insertHTML"
,
blanks
);
...
@@ -215,7 +222,7 @@ class QuestionEditor extends Component {
...
@@ -215,7 +222,7 @@ class QuestionEditor extends Component {
this
.
setState
({
this
.
setState
({
visiblePlacehold
:
false
,
visiblePlacehold
:
false
,
});
});
//
this.props.changeBlankCount(_blanksList);
this
.
props
.
changeBlankCount
(
_blanksList
);
};
};
render
()
{
render
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment