Commit 5955f8dd authored by hewenhao's avatar hewenhao

feat: fix skynet error

parent 94fd1b39
...@@ -46,6 +46,7 @@ function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserG ...@@ -46,6 +46,7 @@ function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserG
createSelectorQuery() createSelectorQuery()
.select(`#${domRef.current.uid}`) .select(`#${domRef.current.uid}`)
.boundingClientRect().exec(([_rect]) => { .boundingClientRect().exec(([_rect]) => {
if (!_rect) return
setRect({ ..._rect, top: _rect.top + scrollRef.current }) setRect({ ..._rect, top: _rect.top + scrollRef.current })
setIsActive(true) setIsActive(true)
}) })
......
...@@ -102,7 +102,7 @@ function convert (inQuestion: QuestionType): CompleteQuestion { ...@@ -102,7 +102,7 @@ function convert (inQuestion: QuestionType): CompleteQuestion {
if (isSelectionQuestion(inQuestion)) { if (isSelectionQuestion(inQuestion)) {
return { return {
...inQuestion, ...inQuestion,
userAnswers: inQuestion.options.filter(c => c.userAnswer).map(c => c.index) userAnswers: inQuestion.options.filter(c => c?.userAnswer).map(c => c?.index)
} }
} }
...@@ -114,7 +114,7 @@ function convert (inQuestion: QuestionType): CompleteQuestion { ...@@ -114,7 +114,7 @@ function convert (inQuestion: QuestionType): CompleteQuestion {
) { ) {
return { return {
...inQuestion, ...inQuestion,
userAnswers: inQuestion.answers.map(c => c.userAnswer!), userAnswers: inQuestion.answers.map(c => c?.userAnswer!),
} }
} }
...@@ -124,7 +124,7 @@ function convert (inQuestion: QuestionType): CompleteQuestion { ...@@ -124,7 +124,7 @@ function convert (inQuestion: QuestionType): CompleteQuestion {
/** 已答题目 */ /** 已答题目 */
export function answeredQuestion (question: QuestionType) { export function answeredQuestion (question: QuestionType) {
if (isSelectionQuestion(question)) { if (isSelectionQuestion(question)) {
return question.options.some(c => c.userAnswer) return question.options.some(c => c?.userAnswer)
} }
if ( if (
...@@ -133,7 +133,7 @@ export function answeredQuestion (question: QuestionType) { ...@@ -133,7 +133,7 @@ export function answeredQuestion (question: QuestionType) {
isFractionAddMinusQuestion(question) || isFractionAddMinusQuestion(question) ||
isVerticalAddMinusQuestion(question) isVerticalAddMinusQuestion(question)
) { ) {
return question.answers.every(c => c.userAnswer) return question.answers.every(c => c?.userAnswer)
} }
throw new Error('question type not supported') throw new Error('question type not supported')
...@@ -142,7 +142,7 @@ export function answeredQuestion (question: QuestionType) { ...@@ -142,7 +142,7 @@ export function answeredQuestion (question: QuestionType) {
/** 判题 */ /** 判题 */
export function determinQuestion (question: QuestionType) { export function determinQuestion (question: QuestionType) {
if (isSelectionQuestion(question)) { if (isSelectionQuestion(question)) {
return question.options.every(c => c.answer === c.userAnswer) return question.options.every(c => c.answer === c?.userAnswer)
} }
if ( if (
...@@ -151,7 +151,7 @@ export function determinQuestion (question: QuestionType) { ...@@ -151,7 +151,7 @@ export function determinQuestion (question: QuestionType) {
isFractionAddMinusQuestion(question) || isFractionAddMinusQuestion(question) ||
isVerticalAddMinusQuestion(question) isVerticalAddMinusQuestion(question)
) { ) {
return question.answers.every(c => c.userAnswer === c.contentText) return question.answers.every(c => c?.userAnswer === c.contentText)
} }
throw new Error('question type not supported') throw new Error('question type not supported')
......
...@@ -30,7 +30,7 @@ const AnswerBlank = (props: AnswerBlankProps) => { ...@@ -30,7 +30,7 @@ const AnswerBlank = (props: AnswerBlankProps) => {
}, [question]) }, [question])
const isWrong = useMemo(() => { const isWrong = useMemo(() => {
return currentInputOption?.contentText !== currentInputOption.userAnswer || !currentInput return currentInputOption?.contentText !== currentInputOption?.userAnswer || !currentInput
}, [currentInputOption, currentInput]) }, [currentInputOption, currentInput])
return ( return (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment