Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GeekLearnMathWeapp
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
frontend
GeekLearnMathWeapp
Commits
631e2ec4
Commit
631e2ec4
authored
Jun 20, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 竖式加减法错题
parent
593eb9e7
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
281 additions
and
2 deletions
+281
-2
math-symbol.module.scss
src/pages/game/play/components/math-symbol.module.scss
+5
-0
question-vertical-add-minus.module.scss
...mponents/question/question-vertical-add-minus.module.scss
+0
-1
index.tsx
src/pages/game/wrong/components/question/index.tsx
+7
-1
question-vertical-add-minus.module.scss
...mponents/question/question-vertical-add-minus.module.scss
+70
-0
question-vertical-add-minus.tsx
...wrong/components/question/question-vertical-add-minus.tsx
+199
-0
No files found.
src/pages/game/play/components/math-symbol.module.scss
View file @
631e2ec4
...
@@ -21,5 +21,10 @@
...
@@ -21,5 +21,10 @@
&
.is_dot
{
&
.is_dot
{
width
:
24px
;
width
:
24px
;
height
:
112px
;
height
:
112px
;
&
.is_small
{
height
:
80px
;
width
:
17px
;
}
}
}
}
}
src/pages/game/play/components/question/question-vertical-add-minus.module.scss
View file @
631e2ec4
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
align-items
:
center
;
align-items
:
center
;
padding-right
:
60px
;
min-height
:
100%
;
min-height
:
100%
;
}
}
...
...
src/pages/game/wrong/components/question/index.tsx
View file @
631e2ec4
...
@@ -8,9 +8,11 @@ import {
...
@@ -8,9 +8,11 @@ import {
isBlankQuestion
,
isBlankQuestion
,
isSelectionQuestion
,
isSelectionQuestion
,
isVerticalDivisionQuestion
,
isVerticalDivisionQuestion
,
isFractionAddMinusQuestion
isFractionAddMinusQuestion
,
isVerticalAddMinusQuestion
}
from
'../../../play/types'
}
from
'../../../play/types'
import
QuestionFractionAddMinus
from
'./question-fraction-add-minus'
import
QuestionFractionAddMinus
from
'./question-fraction-add-minus'
import
QuestionVerticalAddMinus
from
'./question-vertical-add-minus'
type
QuestionProps
=
{
type
QuestionProps
=
{
question
:
QuestionType
question
:
QuestionType
...
@@ -43,6 +45,10 @@ const Question = (props: QuestionProps) => {
...
@@ -43,6 +45,10 @@ const Question = (props: QuestionProps) => {
)
)
}
}
if
(
isVerticalAddMinusQuestion
(
question
))
{
return
<
QuestionVerticalAddMinus
question=
{
question
}
/>
}
return
(
return
(
<
View
>
not supported question type
</
View
>
<
View
>
not supported question type
</
View
>
)
)
...
...
src/pages/game/wrong/components/question/question-vertical-add-minus.module.scss
0 → 100644
View file @
631e2ec4
.content
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
min-height
:
100%
;
}
.gap
{
flex
:
2
;
}
.gap_2
{
flex
:
3
;
}
.question_content
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.item_cell
{
min-width
:
96px
;
height
:
80px
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
font-size
:
50px
;
font-weight
:
500
;
color
:
#465164
;
line-height
:
80px
;
margin
:
0
-8px
;
}
.sign_cell
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
height
:
80px
;
min-width
:
96px
;
margin
:
0
-8px
;
}
.left
{
display
:
flex
;
justify-content
:
flex-end
;
gap
:
10px
;
}
.right
{
display
:
flex
;
justify-content
:
flex-start
;
gap
:
10px
;
}
.split
{
height
:
8px
;
background
:
rgba
(
23
,
134
,
247
,
0
.9
);
margin
:
6px
0
;
}
.column_wrap
{
display
:
flex
;
flex-direction
:
column
;
gap
:
10px
;
}
.place_holder
{
width
:
24px
;
height
:
80px
;
}
src/pages/game/wrong/components/question/question-vertical-add-minus.tsx
0 → 100644
View file @
631e2ec4
/** 填空题 */
import
{
View
}
from
'@tarojs/components'
import
{
useMemo
}
from
'react'
import
classNames
from
'classnames'
import
htmlParser
,
{
Node
}
from
'html-parse-stringify'
import
type
{
VerticalAddMinusQuestion
}
from
'../../../play/types'
import
styles
from
'./question-vertical-add-minus.module.scss'
import
{
renderRichText
}
from
'./render-tichtext'
import
MathSymbol
from
'../../../play/components/math-symbol'
type
QuestionVerticalAddMinusProps
=
{
question
:
VerticalAddMinusQuestion
}
const
genNewNode
=
(
src
:
string
):
Node
[]
=>
{
const
tree
=
htmlParser
.
parse
(
src
)
return
tree
.
reduce
<
Node
[]
>
((
ret
,
item
)
=>
{
if
(
item
.
type
===
'text'
)
{
const
sub
:
Node
[]
=
item
.
content
.
split
(
''
).
filter
(
Boolean
).
map
(
text
=>
({
content
:
text
,
type
:
'text'
}))
ret
=
[...
ret
,
...
sub
]
}
else
{
ret
.
push
(
item
)
}
return
ret
},
[])
}
const
isDotTextNode
=
(
node
:
Node
)
=>
node
.
type
===
'text'
&&
node
.
content
===
'.'
function
computeFinalData
(
top
:
Node
[],
center
:
Node
[],
bottom
:
Node
[])
{
const
topDotIndex
=
top
.
findIndex
(
isDotTextNode
)
const
centerDotIndex
=
center
.
findIndex
(
isDotTextNode
)
const
bottomDotIndex
=
bottom
.
findIndex
(
isDotTextNode
)
const
hasTopDot
=
topDotIndex
!==
-
1
const
hasCenterDot
=
centerDotIndex
!==
-
1
const
hasBottomDot
=
bottomDotIndex
!==
-
1
return
{
left
:
[
{
key
:
1
,
nodes
:
hasTopDot
?
top
.
slice
(
0
,
topDotIndex
)
:
top
},
{
key
:
2
,
nodes
:
hasCenterDot
?
center
.
slice
(
0
,
centerDotIndex
)
:
center
,
hasSign
:
true
},
{
key
:
3
,
nodes
:
[],
isSplit
:
true
},
{
key
:
4
,
nodes
:
hasBottomDot
?
bottom
.
slice
(
0
,
bottomDotIndex
)
:
bottom
},
],
center
:
[
{
key
:
1
,
hasDot
:
hasTopDot
},
{
key
:
2
,
hasDot
:
hasCenterDot
},
{
key
:
3
,
hasDot
:
false
,
isSplit
:
true
},
{
key
:
4
,
hasDot
:
hasBottomDot
},
],
right
:
[
{
key
:
1
,
nodes
:
hasTopDot
?
top
.
slice
(
topDotIndex
+
1
,
top
.
length
)
:
[]
},
{
key
:
2
,
nodes
:
hasCenterDot
?
center
.
slice
(
centerDotIndex
+
1
,
center
.
length
)
:
[]
},
{
key
:
3
,
nodes
:
[],
isSplit
:
true
},
{
key
:
4
,
nodes
:
hasBottomDot
?
bottom
.
slice
(
bottomDotIndex
+
1
,
bottom
.
length
)
:
[]
},
]
}
}
type
FormatContentRet
=
{
sign
:
'ADD'
|
'SUB'
,
top
:
Node
[];
center
:
Node
[];
bottom
:
Node
[];
}
const
formatContent
=
(
str
:
string
):
FormatContentRet
=>
{
if
(
!
str
)
{
return
{
sign
:
'ADD'
,
top
:
[],
center
:
[],
bottom
:
[]
}
}
const
list
=
genNewNode
(
str
)
let
signIndex
=
list
.
findIndex
(
c
=>
c
.
type
===
'text'
&&
c
.
content
===
'+'
)
let
signal
:
FormatContentRet
[
'sign'
]
=
'ADD'
if
(
signIndex
===
-
1
)
{
signIndex
=
list
.
findIndex
(
c
=>
c
.
type
===
'text'
&&
c
.
content
===
'-'
)
signal
=
'SUB'
}
if
(
signIndex
===
-
1
)
{
return
{
sign
:
signal
,
top
:
[],
center
:
[],
bottom
:
[]
}
}
const
top
=
list
.
slice
(
0
,
signIndex
)
const
rightAndCenter
=
list
.
slice
(
signIndex
+
1
,
list
.
length
)
const
equalIndex
=
rightAndCenter
.
findIndex
(
c
=>
c
.
type
===
'text'
&&
c
.
content
===
'='
)
if
(
equalIndex
===
-
1
)
{
return
{
sign
:
signal
,
top
:
[],
center
:
[],
bottom
:
[]
}
}
const
center
=
rightAndCenter
.
slice
(
0
,
equalIndex
)
const
bottom
=
rightAndCenter
.
slice
(
equalIndex
+
1
,
rightAndCenter
.
length
)
return
{
sign
:
signal
,
top
,
center
,
bottom
}
}
const
QuestionVerticalAddMinus
=
(
props
:
QuestionVerticalAddMinusProps
)
=>
{
const
{
question
}
=
props
const
preGen
=
useMemo
(()
=>
{
return
formatContent
(
question
.
contentText
)
},
[
question
.
contentText
])
const
contentTreeInfo
=
useMemo
(()
=>
{
return
computeFinalData
(
preGen
.
top
,
preGen
.
center
,
preGen
.
bottom
)
},
[
preGen
])
return
(
<
View
className=
{
classNames
(
styles
.
content
)
}
>
<
View
className=
{
styles
.
gap
}
></
View
>
<
View
className=
{
styles
.
question_content
}
>
<
View
className=
{
styles
.
column_wrap
}
>
{
contentTreeInfo
.
left
.
map
(
item
=>
{
if
(
item
.
isSplit
)
{
return
(
<
View
key=
{
item
.
key
}
className=
{
styles
.
split
}
></
View
>
)
}
return
(
<
View
key=
{
item
.
key
}
className=
{
styles
.
left
}
>
{
item
.
hasSign
&&
(
<
View
className=
{
styles
.
sign_cell
}
>
<
MathSymbol
value=
{
preGen
.
sign
}
></
MathSymbol
>
</
View
>
)
}
{
item
.
nodes
.
map
((
node
,
index
)
=>
(
<
View
key=
{
index
}
className=
{
styles
.
item_cell
}
>
{
renderRichText
(
node
,
question
)
}
</
View
>
))
}
</
View
>
)
})
}
</
View
>
<
View
className=
{
styles
.
column_wrap
}
>
{
contentTreeInfo
.
center
.
map
(
item
=>
{
if
(
item
.
isSplit
)
{
return
(
<
View
key=
{
item
.
key
}
className=
{
styles
.
split
}
></
View
>
)
}
if
(
item
.
hasDot
)
{
return
(
<
MathSymbol
value=
"."
key=
{
item
.
key
}
size=
"small"
></
MathSymbol
>
)
}
return
(
<
View
className=
{
styles
.
place_holder
}
key=
{
item
.
key
}
></
View
>
)
})
}
</
View
>
<
View
className=
{
styles
.
column_wrap
}
>
{
contentTreeInfo
.
right
.
map
(
item
=>
{
if
(
item
.
isSplit
)
{
return
(
<
View
key=
{
item
.
key
}
className=
{
styles
.
split
}
></
View
>
)
}
return
(
<
View
key=
{
item
.
key
}
className=
{
styles
.
right
}
>
{
item
.
nodes
.
map
((
node
,
index
)
=>
(
<
View
key=
{
index
}
className=
{
styles
.
item_cell
}
>
{
renderRichText
(
node
,
question
)
}
</
View
>
))
}
</
View
>
)
})
}
</
View
>
</
View
>
<
View
className=
{
styles
.
gap_2
}
></
View
>
</
View
>
)
}
export
default
QuestionVerticalAddMinus
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