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
9413e388
Commit
9413e388
authored
Mar 18, 2021
by
sunbingqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 编辑问题
parent
670804b8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
101 additions
and
32 deletions
+101
-32
src/domains/basic-domain/constants.ts
+3
-3
src/modules/teach-tool/components/NewQuestionTab.jsx
+39
-19
src/modules/teach-tool/components/QuestionEditor.jsx
+53
-4
src/modules/teach-tool/components/model.js
+5
-5
src/modules/teach-tool/modal/QuestionPreviewModal.jsx
+1
-1
No files found.
src/domains/basic-domain/constants.ts
View file @
9413e388
/*
/*
* @Author: 陈剑宇
* @Author: 陈剑宇
* @Date: 2020-05-07 14:43:01
* @Date: 2020-05-07 14:43:01
* @LastEditTime: 2021-03-1
1 11:43:59
* @LastEditTime: 2021-03-1
8 16:53:23
* @LastEditors:
yuanant
ing
* @LastEditors:
sunbingq
ing
* @Description:
* @Description:
* @FilePath: /wheat-web-demo/src/domains/basic-domain/constants.ts
* @FilePath: /wheat-web-demo/src/domains/basic-domain/constants.ts
*/
*/
import
{
MapInterface
}
from
'@/domains/basic-domain/interface'
import
{
MapInterface
}
from
'@/domains/basic-domain/interface'
// 默认是 dev 环境
// 默认是 dev 环境
const
ENV
:
string
=
process
.
env
.
DEPLOY_ENV
||
'dev
1
'
;
const
ENV
:
string
=
process
.
env
.
DEPLOY_ENV
||
'dev'
;
console
.
log
(
"process.env.DEPLOY_ENV"
,
process
)
console
.
log
(
"process.env.DEPLOY_ENV"
,
process
)
const
BASIC_HOST_MAP
:
MapInterface
=
{
const
BASIC_HOST_MAP
:
MapInterface
=
{
dev
:
'https://dev-heimdall.xiaomai5.com/'
,
dev
:
'https://dev-heimdall.xiaomai5.com/'
,
...
...
src/modules/teach-tool/components/NewQuestionTab.jsx
View file @
9413e388
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: yuananting
* @Author: yuananting
* @Date: 2021-02-25 14:34:29
* @Date: 2021-02-25 14:34:29
* @LastEditors: sunbingqing
* @LastEditors: sunbingqing
* @LastEditTime: 2021-03-18 1
4:55:15
* @LastEditTime: 2021-03-18 1
8:44:09
* @Description: 助学工具-题库-题目管理-新建题目Tab
* @Description: 助学工具-题库-题目管理-新建题目Tab
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
*/
...
@@ -530,9 +530,24 @@ class NewQuestionTab extends Component {
...
@@ -530,9 +530,24 @@ class NewQuestionTab extends Component {
});
});
}
}
changeBlankCount
=
(
data
)
=>
{
changeBlankCount
=
(
data
,
idx
)
=>
{
console
.
log
(
"data:"
,
data
);
console
.
log
(
"data:"
,
data
);
data
&&
data
.
length
>
0
&&
data
.
forEach
((
item
)
=>
{
const
{
gapFillingAnswer
}
=
this
.
state
;
let
_gap
=
[...
gapFillingAnswer
];
console
.
log
(
9
,
_gap
)
data
&&
data
.
length
>
0
&&
data
.
forEach
((
item
,
index
)
=>
{
if
(
index
===
idx
)
{
if
(
_gap
.
length
<
data
.
length
)
{
_gap
.
splice
(
idx
,
0
,
{
correctAnswerList
:
[]})
}
else
if
(
_gap
.
length
>
data
.
length
){
_gap
.
splice
(
idx
,
1
)
}
else
{
_gap
.
splice
(
idx
,
1
,
{
correctAnswerList
:
[]})
}
}
if
(
!
item
.
correctAnswerList
)
{
if
(
!
item
.
correctAnswerList
)
{
item
.
correctAnswerList
=
[];
item
.
correctAnswerList
=
[];
}
}
...
@@ -541,8 +556,16 @@ class NewQuestionTab extends Component {
...
@@ -541,8 +556,16 @@ class NewQuestionTab extends Component {
item
.
editInput
=
false
;
item
.
editInput
=
false
;
return
item
;
return
item
;
});
});
this
.
setState
({
blanksList
:
data
});
};
console
.
log
(
'idx'
,
idx
)
console
.
log
(
'****'
,
_gap
)
this
.
setState
({
blanksList
:
data
,
gapFillingAnswer
:
_gap
});
};
addAnswerTag
=
(
optionItem
)
=>
{
addAnswerTag
=
(
optionItem
)
=>
{
const
_blanksList
=
this
.
state
.
blanksList
;
const
_blanksList
=
this
.
state
.
blanksList
;
...
@@ -554,26 +577,27 @@ class NewQuestionTab extends Component {
...
@@ -554,26 +577,27 @@ class NewQuestionTab extends Component {
this
.
setState
({
blanksList
:
_blanksList
});
this
.
setState
({
blanksList
:
_blanksList
});
};
};
// 填空选项
handleInputConfirm
=
(
optionItem
,
val
)
=>
{
handleInputConfirm
=
(
optionItem
,
val
)
=>
{
const
_blanksList
=
this
.
state
.
blanksList
;
const
_blanksList
=
this
.
state
.
blanksList
;
// const { gapFillingAnswer } = this.state;
const
{
gapFillingAnswer
}
=
this
.
state
;
let
_gapFillingAnswer
=
[];
console
.
log
(
0.2
,
val
)
console
.
log
(
0.3
,
optionItem
)
let
_gapFillingAnswer
=
[...
gapFillingAnswer
];
console
.
log
(
0.4
,
_gapFillingAnswer
)
_blanksList
.
forEach
((
item
,
index
)
=>
{
_blanksList
.
forEach
((
item
,
index
)
=>
{
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
.
correctAnswerList
.
push
(
val
);
_gapFillingAnswer
[
index
]
.
correctAnswerList
.
push
(
val
);
optionItem
.
inputVisible
=
false
;
optionItem
.
inputVisible
=
false
;
}
else
{
}
else
{
optionItem
.
errorHold
=
true
;
optionItem
.
errorHold
=
true
;
}
}
}
}
});
})
console
.
log
(
8888
,
_gapFillingAnswer
)
console
.
log
(
8888
,
_gapFillingAnswer
)
this
.
setState
({
gapFillingAnswer
:
_gapFillingAnswer
},
()
=>
this
.
_onSetState
());
this
.
setState
({
gapFillingAnswer
:
_gapFillingAnswer
},
()
=>
this
.
_onSetState
());
this
.
setState
({
blanksList
:
_blanksList
});
this
.
setState
({
blanksList
:
_blanksList
});
...
@@ -1147,10 +1171,6 @@ class NewQuestionTab extends Component {
...
@@ -1147,10 +1171,6 @@ 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"
;
<
<<<<<<
HEAD
=======
>
>>>>>>
acb5ccd546aa59474df75f3b0397b7308f9d5b12
const
isGapFilling
=
this
.
props
.
questionTypeKey
===
"GAP_FILLING"
;
const
isGapFilling
=
this
.
props
.
questionTypeKey
===
"GAP_FILLING"
;
const
placehold
=
isGapFilling
?
(
const
placehold
=
isGapFilling
?
(
<
span
>
<
span
>
...
...
src/modules/teach-tool/components/QuestionEditor.jsx
View file @
9413e388
...
@@ -40,7 +40,6 @@ class QuestionEditor extends Component {
...
@@ -40,7 +40,6 @@ class QuestionEditor extends Component {
isGapFilling
:
props
.
isGapFilling
,
isGapFilling
:
props
.
isGapFilling
,
contentType
:
props
.
contentType
,
contentType
:
props
.
contentType
,
detailInfo
:
props
.
detailInfo
||
{},
detailInfo
:
props
.
detailInfo
||
{},
gapFillingAnswer
:
props
.
gapFillingAnswer
||
[],
blanksList
:
props
.
blanksList
||
[],
blanksList
:
props
.
blanksList
||
[],
};
};
}
}
...
@@ -138,7 +137,18 @@ class QuestionEditor extends Component {
...
@@ -138,7 +137,18 @@ class QuestionEditor extends Component {
return
str
;
return
str
;
};
};
let
prevList
=
[]
const
isEdit
=
getParameterByName
(
'id'
);
if
(
isEdit
)
{
const
stemDom
=
document
.
getElementsByClassName
(
"add-fill-line"
);
prevList
=
[...
stemDom
].
map
(
item
=>
item
.
id
)
console
.
log
(
'!!!!!!!!!'
,
prevList
)
localStorage
.
setItem
(
'gap_ques_prevList'
,
JSON
.
stringify
(
prevList
));
}
let
counter
=
0
editorRoot
.
customConfig
.
onchange
=
(
html
)
=>
{
editorRoot
.
customConfig
.
onchange
=
(
html
)
=>
{
counter
++
;
const
{
focusFlag
}
=
this
.
state
;
const
{
focusFlag
}
=
this
.
state
;
const
textLength
=
editorRoot
.
txt
.
text
().
replace
(
/
\&
nbsp
\;
/gi
,
" "
)
const
textLength
=
editorRoot
.
txt
.
text
().
replace
(
/
\&
nbsp
\;
/gi
,
" "
)
.
length
;
.
length
;
...
@@ -153,9 +163,33 @@ class QuestionEditor extends Component {
...
@@ -153,9 +163,33 @@ class QuestionEditor extends Component {
}
else
{
}
else
{
this
.
setState
({
isShowSingleInput
:
true
});
this
.
setState
({
isShowSingleInput
:
true
});
}
}
if
(
this
.
state
.
isGapFilling
)
{
if
(
this
.
state
.
isGapFilling
&&
this
.
state
.
contentType
===
"QUESTION_STEM"
)
{
console
.
log
(
9999
,
this
.
state
.
isGapFilling
)
const
stemHtml
=
this
.
transferStemDocument
(
html
);
this
.
props
.
changeBlankCount
(
this
.
state
.
blanksList
);
var
_blanksList
=
stemHtml
.
getElementsByClassName
(
"add-fill-line"
)
const
ids
=
[...
_blanksList
].
map
(
item
=>
item
.
id
);
const
isEdit
=
getParameterByName
(
'id'
);
if
(
isEdit
&&
counter
===
1
)
{
const
prev
=
localStorage
.
getItem
(
'gap_ques_prevList'
);
prevList
=
prev
&&
JSON
.
parse
(
prev
);
}
console
.
log
(
prevList
,
'++++++++++++++++'
,
ids
)
let
idx
=
0
;
if
(
prevList
&&
ids
)
{
idx
=
this
.
getNewArr
(
prevList
,
ids
);
const
oldLen
=
prevList
.
length
;
console
.
log
(
555
,
idx
,
oldLen
)
idx
=
idx
>=
oldLen
?
idx
-
oldLen
:
idx
}
prevList
=
[...
ids
];
this
.
setState
({
blanksList
:
_blanksList
},
()
=>
this
.
props
.
changeBlankCount
(
_blanksList
,
idx
))
}
}
this
.
setState
(
this
.
setState
(
{
contentLength
,
visiblePlacehold
:
contentLength
===
0
&&
!
focusFlag
},
{
contentLength
,
visiblePlacehold
:
contentLength
===
0
&&
!
focusFlag
},
...
@@ -210,6 +244,21 @@ class QuestionEditor extends Component {
...
@@ -210,6 +244,21 @@ class QuestionEditor extends Component {
bindChangeContent
&&
bindChangeContent
(
this
.
handleChangeContent
);
bindChangeContent
&&
bindChangeContent
(
this
.
handleChangeContent
);
}
}
getNewArr
(
a
,
b
)
{
const
arr
=
[...
a
,
...
b
];
const
idx
=
arr
.
findIndex
(
item
=>
{
return
!
(
a
.
includes
(
item
)
&&
b
.
includes
(
item
));
});
return
idx
;
}
transferStemDocument
=
(
txt
)
=>
{
const
template
=
`<div class='option-content'>
${
txt
}
</div>`
;
let
doc
=
new
DOMParser
().
parseFromString
(
template
,
"text/html"
);
let
div
=
doc
.
querySelector
(
".option-content"
);
return
div
;
};
insertBlank
=
(
blanks
)
=>
{
insertBlank
=
(
blanks
)
=>
{
var
blanks
=
`<input class="add-fill-line" disabled correctAnswerList="[]" id=
${
window
.
random_string
(
var
blanks
=
`<input class="add-fill-line" disabled correctAnswerList="[]" id=
${
window
.
random_string
(
16
16
...
...
src/modules/teach-tool/components/model.js
View file @
9413e388
/*
/*
* @Author: chenjianyu
* @Author: chenjianyu
* @Date: 2020-09-12 17:00:44
* @Date: 2020-09-12 17:00:44
* @LastEditTime: 2021-03-18
09:33:26
* @LastEditTime: 2021-03-18
17:23:09
* @LastEditors:
yuanant
ing
* @LastEditors:
sunbingq
ing
* @Description: 答题模式模板
* @Description: 答题模式模板
* @Copyright © 2020 杭州杰竞科技有限公司 版权所有
* @Copyright © 2020 杭州杰竞科技有限公司 版权所有
*/
*/
...
@@ -56,9 +56,9 @@ export function defineQuestionInfo(questionType) {
...
@@ -56,9 +56,9 @@ export function defineQuestionInfo(questionType) {
],
// 题干
],
// 题干
optionList
:
questionType
===
"JUDGE"
?
[]
:
[],
// 非填空题选项
optionList
:
questionType
===
"JUDGE"
?
[]
:
[],
// 非填空题选项
gapFillingAnswerList
:
[
gapFillingAnswerList
:
[
{
//
{
correctAnswerList
:
[]
//
correctAnswerList: []
}
//
}
],
//填空题填空项
],
//填空题填空项
questionAnswerDescList
:
[
questionAnswerDescList
:
[
{
{
...
...
src/modules/teach-tool/modal/QuestionPreviewModal.jsx
View file @
9413e388
...
@@ -124,7 +124,7 @@ class QuestionPreviewModal extends Component {
...
@@ -124,7 +124,7 @@ class QuestionPreviewModal extends Component {
`<input
`<input
class="add-fill-line"
class="add-fill-line"
disabled
disabled
answerTag
List=""
correctAnswer
List=""
id=${window.random_string(16)}
id=${window.random_string(16)}
value="填空"
value="填空"
/>`
/>`
...
...
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