@magmamath/students-features 1.3.10-rc.1 → 1.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/typescript/commonjs/features/uiMode/__tests__/getUIMode.test.d.ts +2 -0
- package/dist/typescript/commonjs/features/uiMode/__tests__/getUIMode.test.d.ts.map +1 -0
- package/dist/typescript/module/features/uiMode/__tests__/getUIMode.test.d.ts +2 -0
- package/dist/typescript/module/features/uiMode/__tests__/getUIMode.test.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/features/uiMode/__tests__/SPEC.md +114 -0
- package/src/features/uiMode/__tests__/getUIMode.test.ts +364 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUIMode.test.d.ts","sourceRoot":"","sources":["../../../../../../src/features/uiMode/__tests__/getUIMode.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUIMode.test.d.ts","sourceRoot":"","sources":["../../../../../../src/features/uiMode/__tests__/getUIMode.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magmamath/students-features",
|
|
3
|
-
"version": "1.3.10
|
|
3
|
+
"version": "1.3.10",
|
|
4
4
|
"description": "Magmamath features library",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@magmamath/frontend-config": "1.1.3",
|
|
44
|
-
"@magmamath/react-native-draw-board": "1.8.2
|
|
44
|
+
"@magmamath/react-native-draw-board": "1.8.2",
|
|
45
45
|
"@magmamath/react-native-ui": "0.4.83",
|
|
46
46
|
"@matteappen/skills-utils": "^3.7.1",
|
|
47
47
|
"@react-native-masked-view/masked-view": "^0.3.2",
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# UIMode Specification
|
|
2
|
+
|
|
3
|
+
## Inputs
|
|
4
|
+
|
|
5
|
+
| Input | Type | Description |
|
|
6
|
+
|----------------------|-------------------|---------------------------------------------------|
|
|
7
|
+
| `user.grade` | `number \| null` | User's grade level. Invalid when `null` or `-1` |
|
|
8
|
+
| `practice.isEnabled` | `boolean` | Whether this is a practice exercise |
|
|
9
|
+
| `practice.grade` | `number \| null` | Grade of the practice problem |
|
|
10
|
+
| `assignment.grade` | `number \| null` | From `assignment.classes[0].grade` |
|
|
11
|
+
| `locale` | `Locale` | e.g. `US`, `CA`, `SE` |
|
|
12
|
+
| `problem.answerType` | `AnswerType` | Current problem's answer type |
|
|
13
|
+
| `problem.characterType` | `number` | Current problem's character type |
|
|
14
|
+
| `problem.hasAnswerVariants` | `boolean` | Whether the current problem has answer variants |
|
|
15
|
+
|
|
16
|
+
## Output
|
|
17
|
+
|
|
18
|
+
| Field | Type | Values |
|
|
19
|
+
|--------------|------------------|---------------------------------|
|
|
20
|
+
| `general` | `UIMode` | `SIMPLE` or `REGULAR` |
|
|
21
|
+
| `toolbar` | `ToolBarVariants` | `SIMPLE`, `COMMON`, `ADVANCED` |
|
|
22
|
+
| `answerArea` | `UIMode` | `SIMPLE` or `REGULAR` |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Step 1: Determine `isSimpleMode`
|
|
27
|
+
|
|
28
|
+
A grade is "simple" when it is **not null** and is **between 0 and 2 inclusive**.
|
|
29
|
+
|
|
30
|
+
| Condition | Grade used |
|
|
31
|
+
|------------------------------------|----------------------|
|
|
32
|
+
| `practice.isEnabled` is `true` | `practice.grade` |
|
|
33
|
+
| `user.grade` is valid (not null/-1)| `user.grade` |
|
|
34
|
+
| `user.grade` is null or -1 | `assignment.grade` |
|
|
35
|
+
|
|
36
|
+
### Test cases
|
|
37
|
+
|
|
38
|
+
| # | practice.isEnabled | practice.grade | user.grade | assignment.grade | isSimpleMode |
|
|
39
|
+
|----|--------------------|----------------|------------|------------------|--------------|
|
|
40
|
+
| 1 | true | 0 | - | - | true |
|
|
41
|
+
| 2 | true | 2 | - | - | true |
|
|
42
|
+
| 3 | true | 3 | - | - | false |
|
|
43
|
+
| 4 | true | null | - | - | false |
|
|
44
|
+
| 5 | false | - | 1 | - | true |
|
|
45
|
+
| 6 | false | - | 5 | - | false |
|
|
46
|
+
| 7 | false | - | null | 2 | true |
|
|
47
|
+
| 8 | false | - | -1 | 2 | true |
|
|
48
|
+
| 9 | false | - | null | 5 | false |
|
|
49
|
+
| 10 | false | - | null | null | false |
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Step 2: `general`
|
|
54
|
+
|
|
55
|
+
| isSimpleMode | general |
|
|
56
|
+
|--------------|-----------|
|
|
57
|
+
| true | `SIMPLE` |
|
|
58
|
+
| false | `REGULAR` |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Step 3: `toolbar`
|
|
63
|
+
|
|
64
|
+
Effective grade = `assignment.grade ?? practice.grade`
|
|
65
|
+
|
|
66
|
+
| # | assignment.grade | practice.grade | locale | isSimpleMode | toolbar |
|
|
67
|
+
|----|------------------|----------------|--------|--------------|------------|
|
|
68
|
+
| 11 | 7 | - | SE | any | `ADVANCED` |
|
|
69
|
+
| 12 | 8 | - | US | any | `ADVANCED` |
|
|
70
|
+
| 13 | 6 | - | US | any | `ADVANCED` |
|
|
71
|
+
| 14 | 6 | - | CA | any | `ADVANCED` |
|
|
72
|
+
| 15 | 6 | - | SE | true | `SIMPLE` |
|
|
73
|
+
| 16 | 6 | - | SE | false | `COMMON` |
|
|
74
|
+
| 17 | 3 | - | US | true | `SIMPLE` |
|
|
75
|
+
| 18 | 3 | - | US | false | `COMMON` |
|
|
76
|
+
| 19 | null | 8 | US | any | `ADVANCED` |
|
|
77
|
+
| 20 | null | null | - | true | `SIMPLE` |
|
|
78
|
+
| 21 | null | null | - | false | `COMMON` |
|
|
79
|
+
|
|
80
|
+
**Advanced threshold:**
|
|
81
|
+
|
|
82
|
+
| Locale | Grade >= | Result |
|
|
83
|
+
|----------|----------|------------|
|
|
84
|
+
| US or CA | 6 | `ADVANCED` |
|
|
85
|
+
| Other | 7 | `ADVANCED` |
|
|
86
|
+
|
|
87
|
+
**Priority:** `ADVANCED` > `SIMPLE` > `COMMON`
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Step 4: `answerArea`
|
|
92
|
+
|
|
93
|
+
| # | isSimpleMode | practice.isEnabled | hasAnswerVariants | answerType | characterType | answerArea |
|
|
94
|
+
|----|--------------|--------------------|-------------------|--------------|---------------|------------|
|
|
95
|
+
| 22 | false | any | any | any | any | `REGULAR` |
|
|
96
|
+
| 23 | true | true | any | any | any | `SIMPLE` |
|
|
97
|
+
| 24 | true | false | true | any | any | `SIMPLE` |
|
|
98
|
+
| 25 | true | false | false | HANDWRITING | 10 | `SIMPLE` |
|
|
99
|
+
| 26 | true | false | false | HANDWRITING | 5 | `REGULAR` |
|
|
100
|
+
| 27 | true | false | false | MULTI_CHOICE | 10 | `REGULAR` |
|
|
101
|
+
| 28 | true | false | false | other | any | `REGULAR` |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Full combined scenarios
|
|
106
|
+
|
|
107
|
+
| # | Mode | user.grade | assignment.grade | practice.grade | locale | hasVariants | answerType | charType | general | toolbar | answerArea |
|
|
108
|
+
|----|----------|------------|------------------|----------------|--------|-------------|-------------|----------|-----------|------------|------------|
|
|
109
|
+
| 29 | practice | - | - | 1 | US | true | - | - | `SIMPLE` | `SIMPLE` | `SIMPLE` |
|
|
110
|
+
| 30 | practice | - | - | 8 | US | false | - | - | `REGULAR` | `ADVANCED` | `REGULAR` |
|
|
111
|
+
| 31 | regular | 2 | 7 | - | SE | true | - | - | `SIMPLE` | `ADVANCED` | `SIMPLE` |
|
|
112
|
+
| 32 | regular | 5 | 3 | - | US | false | SINGLE | - | `REGULAR` | `COMMON` | `REGULAR` |
|
|
113
|
+
| 33 | regular | null | 1 | - | SE | false | HANDWRITING | 10 | `SIMPLE` | `SIMPLE` | `SIMPLE` |
|
|
114
|
+
| 34 | regular | null | null | null | SE | - | - | - | `REGULAR` | `COMMON` | `REGULAR` |
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
jest.mock('@magmamath/react-native-draw-board', () => ({
|
|
2
|
+
ToolBarVariants: {
|
|
3
|
+
COMMON: 'COMMON',
|
|
4
|
+
SIMPLE: 'SIMPLE',
|
|
5
|
+
ADVANCED: 'ADVANCED',
|
|
6
|
+
REPLAY: 'REPLAY',
|
|
7
|
+
NO_CONTROLLER: 'NO_CONTROLLER',
|
|
8
|
+
},
|
|
9
|
+
}))
|
|
10
|
+
|
|
11
|
+
jest.mock('@magmamath/frontend-config', () => ({
|
|
12
|
+
Locale: {
|
|
13
|
+
US: 'en-SE',
|
|
14
|
+
SE: 'sv-SE',
|
|
15
|
+
CA: 'en-CA',
|
|
16
|
+
GB: 'en-GB',
|
|
17
|
+
SCT: 'en-SCT',
|
|
18
|
+
DE: 'de-DE',
|
|
19
|
+
},
|
|
20
|
+
}))
|
|
21
|
+
|
|
22
|
+
import { getUIMode } from '../getUIMode'
|
|
23
|
+
import { UIMode } from '../uiMode.constants'
|
|
24
|
+
import { AnswerType } from '../../../types/answerTypes'
|
|
25
|
+
import { MyScriptMathCharacterTypes } from '../../../types/characterTypes'
|
|
26
|
+
import { ToolBarVariants } from '@magmamath/react-native-draw-board'
|
|
27
|
+
import { Locale } from '@magmamath/frontend-config'
|
|
28
|
+
import { GetUIModeProps } from '../uiMode.types'
|
|
29
|
+
|
|
30
|
+
const defaults: GetUIModeProps = {
|
|
31
|
+
user: { grade: null },
|
|
32
|
+
practice: { isEnabled: false, grade: null },
|
|
33
|
+
assignment: { grade: null },
|
|
34
|
+
locale: Locale.US,
|
|
35
|
+
problem: {
|
|
36
|
+
answerType: AnswerType.HANDWRITING,
|
|
37
|
+
characterType: MyScriptMathCharacterTypes.DEFAULT,
|
|
38
|
+
hasAnswerVariants: false,
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const getUIModeWithDefaults = (overrides: Partial<GetUIModeProps>) =>
|
|
43
|
+
getUIMode({ ...defaults, ...overrides })
|
|
44
|
+
|
|
45
|
+
describe('practice mode uses practice grade to determine simple mode (grades 0-2 are simple)', () => {
|
|
46
|
+
it('grade 0 → simple', () => {
|
|
47
|
+
const result = getUIModeWithDefaults({ practice: { isEnabled: true, grade: 0 } })
|
|
48
|
+
expect(result.general).toBe(UIMode.SIMPLE)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('grade 2 → simple', () => {
|
|
52
|
+
const result = getUIModeWithDefaults({ practice: { isEnabled: true, grade: 2 } })
|
|
53
|
+
expect(result.general).toBe(UIMode.SIMPLE)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('grade 3 → regular', () => {
|
|
57
|
+
const result = getUIModeWithDefaults({ practice: { isEnabled: true, grade: 3 } })
|
|
58
|
+
expect(result.general).toBe(UIMode.REGULAR)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('null grade → regular', () => {
|
|
62
|
+
const result = getUIModeWithDefaults({ practice: { isEnabled: true, grade: null } })
|
|
63
|
+
expect(result.general).toBe(UIMode.REGULAR)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('young student practicing with answer variants gets full simple experience', () => {
|
|
67
|
+
const result = getUIModeWithDefaults({
|
|
68
|
+
practice: { isEnabled: true, grade: 1 },
|
|
69
|
+
locale: Locale.US,
|
|
70
|
+
problem: {
|
|
71
|
+
answerType: AnswerType.HANDWRITING,
|
|
72
|
+
characterType: MyScriptMathCharacterTypes.DEFAULT,
|
|
73
|
+
hasAnswerVariants: true,
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
expect(result).toEqual({
|
|
77
|
+
general: UIMode.SIMPLE,
|
|
78
|
+
toolbar: ToolBarVariants.SIMPLE,
|
|
79
|
+
answerArea: UIMode.SIMPLE,
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('older student practicing gets advanced toolbar with regular UI', () => {
|
|
84
|
+
const result = getUIModeWithDefaults({
|
|
85
|
+
practice: { isEnabled: true, grade: 8 },
|
|
86
|
+
locale: Locale.US,
|
|
87
|
+
problem: {
|
|
88
|
+
answerType: AnswerType.HANDWRITING,
|
|
89
|
+
characterType: MyScriptMathCharacterTypes.DEFAULT,
|
|
90
|
+
hasAnswerVariants: false,
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
expect(result).toEqual({
|
|
94
|
+
general: UIMode.REGULAR,
|
|
95
|
+
toolbar: ToolBarVariants.ADVANCED,
|
|
96
|
+
answerArea: UIMode.REGULAR,
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
describe('regular mode uses user grade, falls back to assignment grade when user grade is null, undefined, or -1', () => {
|
|
102
|
+
it('user grade 1 → simple', () => {
|
|
103
|
+
const result = getUIModeWithDefaults({ user: { grade: 1 } })
|
|
104
|
+
expect(result.general).toBe(UIMode.SIMPLE)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('user grade 5 → regular', () => {
|
|
108
|
+
const result = getUIModeWithDefaults({ user: { grade: 5 } })
|
|
109
|
+
expect(result.general).toBe(UIMode.REGULAR)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('user grade null falls back to assignment grade 2 → simple', () => {
|
|
113
|
+
const result = getUIModeWithDefaults({ user: { grade: null }, assignment: { grade: 2 } })
|
|
114
|
+
expect(result.general).toBe(UIMode.SIMPLE)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('user grade undefined falls back to assignment grade 2 → simple', () => {
|
|
118
|
+
const result = getUIModeWithDefaults({ user: { grade: undefined }, assignment: { grade: 2 } })
|
|
119
|
+
expect(result.general).toBe(UIMode.SIMPLE)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('user grade -1 (invalid) falls back to assignment grade 2 → simple', () => {
|
|
123
|
+
const result = getUIModeWithDefaults({ user: { grade: -1 }, assignment: { grade: 2 } })
|
|
124
|
+
expect(result.general).toBe(UIMode.SIMPLE)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it('user grade null falls back to assignment grade 5 → regular', () => {
|
|
128
|
+
const result = getUIModeWithDefaults({ user: { grade: null }, assignment: { grade: 5 } })
|
|
129
|
+
expect(result.general).toBe(UIMode.REGULAR)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('user grade undefined falls back to assignment grade 5 → regular', () => {
|
|
133
|
+
const result = getUIModeWithDefaults({ user: { grade: undefined }, assignment: { grade: 5 } })
|
|
134
|
+
expect(result.general).toBe(UIMode.REGULAR)
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('both user and assignment grade null → regular', () => {
|
|
138
|
+
const result = getUIModeWithDefaults({ user: { grade: null }, assignment: { grade: null } })
|
|
139
|
+
expect(result.general).toBe(UIMode.REGULAR)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it('user grade 2 in grade 7 SE assignment gets simple mode but advanced toolbar', () => {
|
|
143
|
+
const result = getUIModeWithDefaults({
|
|
144
|
+
user: { grade: 2 },
|
|
145
|
+
assignment: { grade: 7 },
|
|
146
|
+
locale: Locale.SE,
|
|
147
|
+
problem: {
|
|
148
|
+
answerType: AnswerType.HANDWRITING,
|
|
149
|
+
characterType: MyScriptMathCharacterTypes.DEFAULT,
|
|
150
|
+
hasAnswerVariants: true,
|
|
151
|
+
},
|
|
152
|
+
})
|
|
153
|
+
expect(result).toEqual({
|
|
154
|
+
general: UIMode.SIMPLE,
|
|
155
|
+
toolbar: ToolBarVariants.ADVANCED,
|
|
156
|
+
answerArea: UIMode.SIMPLE,
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
it('user grade 5 in grade 3 US assignment gets fully regular experience', () => {
|
|
161
|
+
const result = getUIModeWithDefaults({
|
|
162
|
+
user: { grade: 5 },
|
|
163
|
+
assignment: { grade: 3 },
|
|
164
|
+
locale: Locale.US,
|
|
165
|
+
problem: {
|
|
166
|
+
answerType: AnswerType.SINGLE_CHOICE,
|
|
167
|
+
characterType: MyScriptMathCharacterTypes.DEFAULT,
|
|
168
|
+
hasAnswerVariants: false,
|
|
169
|
+
},
|
|
170
|
+
})
|
|
171
|
+
expect(result).toEqual({
|
|
172
|
+
general: UIMode.REGULAR,
|
|
173
|
+
toolbar: ToolBarVariants.COMMON,
|
|
174
|
+
answerArea: UIMode.REGULAR,
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
it('unknown user falls back to assignment grade 1 in SE with handwriting whole numbers', () => {
|
|
179
|
+
const result = getUIModeWithDefaults({
|
|
180
|
+
user: { grade: null },
|
|
181
|
+
assignment: { grade: 1 },
|
|
182
|
+
locale: Locale.SE,
|
|
183
|
+
problem: {
|
|
184
|
+
answerType: AnswerType.HANDWRITING,
|
|
185
|
+
characterType: MyScriptMathCharacterTypes.NUMBERS_WHOLE,
|
|
186
|
+
hasAnswerVariants: false,
|
|
187
|
+
},
|
|
188
|
+
})
|
|
189
|
+
expect(result).toEqual({
|
|
190
|
+
general: UIMode.SIMPLE,
|
|
191
|
+
toolbar: ToolBarVariants.SIMPLE,
|
|
192
|
+
answerArea: UIMode.SIMPLE,
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
it('all grades unknown defaults to fully regular experience', () => {
|
|
197
|
+
const result = getUIModeWithDefaults({
|
|
198
|
+
user: { grade: null },
|
|
199
|
+
assignment: { grade: null },
|
|
200
|
+
practice: { isEnabled: false, grade: null },
|
|
201
|
+
locale: Locale.SE,
|
|
202
|
+
})
|
|
203
|
+
expect(result).toEqual({
|
|
204
|
+
general: UIMode.REGULAR,
|
|
205
|
+
toolbar: ToolBarVariants.COMMON,
|
|
206
|
+
answerArea: UIMode.REGULAR,
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
describe('toolbar is ADVANCED for high grades (>=6 US/CA, >=7 elsewhere), SIMPLE for young students, COMMON otherwise', () => {
|
|
212
|
+
it('grade 7 in SE → ADVANCED', () => {
|
|
213
|
+
const result = getUIModeWithDefaults({ assignment: { grade: 7 }, locale: Locale.SE, user: { grade: 7 } })
|
|
214
|
+
expect(result.toolbar).toBe(ToolBarVariants.ADVANCED)
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
it('grade 8 in US → ADVANCED', () => {
|
|
218
|
+
const result = getUIModeWithDefaults({ assignment: { grade: 8 }, locale: Locale.US, user: { grade: 8 } })
|
|
219
|
+
expect(result.toolbar).toBe(ToolBarVariants.ADVANCED)
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
it('grade 6 in US → ADVANCED', () => {
|
|
223
|
+
const result = getUIModeWithDefaults({ assignment: { grade: 6 }, locale: Locale.US, user: { grade: 6 } })
|
|
224
|
+
expect(result.toolbar).toBe(ToolBarVariants.ADVANCED)
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
it('grade 6 in CA → ADVANCED', () => {
|
|
228
|
+
const result = getUIModeWithDefaults({ assignment: { grade: 6 }, locale: Locale.CA, user: { grade: 6 } })
|
|
229
|
+
expect(result.toolbar).toBe(ToolBarVariants.ADVANCED)
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
it('grade 6 in SE with simple mode student → SIMPLE (not advanced in SE until grade 7)', () => {
|
|
233
|
+
const result = getUIModeWithDefaults({ assignment: { grade: 6 }, locale: Locale.SE, user: { grade: 1 } })
|
|
234
|
+
expect(result.toolbar).toBe(ToolBarVariants.SIMPLE)
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
it('grade 6 in SE with regular mode student → COMMON', () => {
|
|
238
|
+
const result = getUIModeWithDefaults({ assignment: { grade: 6 }, locale: Locale.SE, user: { grade: 6 } })
|
|
239
|
+
expect(result.toolbar).toBe(ToolBarVariants.COMMON)
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
it('grade 3 in US with simple mode student → SIMPLE', () => {
|
|
243
|
+
const result = getUIModeWithDefaults({ assignment: { grade: 3 }, locale: Locale.US, user: { grade: 1 } })
|
|
244
|
+
expect(result.toolbar).toBe(ToolBarVariants.SIMPLE)
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
it('grade 3 in US with regular mode student → COMMON', () => {
|
|
248
|
+
const result = getUIModeWithDefaults({ assignment: { grade: 3 }, locale: Locale.US, user: { grade: 3 } })
|
|
249
|
+
expect(result.toolbar).toBe(ToolBarVariants.COMMON)
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
it('no assignment grade falls back to practice grade 8 → ADVANCED', () => {
|
|
253
|
+
const result = getUIModeWithDefaults({
|
|
254
|
+
assignment: { grade: null },
|
|
255
|
+
practice: { isEnabled: true, grade: 8 },
|
|
256
|
+
locale: Locale.US,
|
|
257
|
+
})
|
|
258
|
+
expect(result.toolbar).toBe(ToolBarVariants.ADVANCED)
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
it('no grades at all with simple mode → SIMPLE', () => {
|
|
262
|
+
const result = getUIModeWithDefaults({
|
|
263
|
+
assignment: { grade: null },
|
|
264
|
+
practice: { isEnabled: true, grade: 1 },
|
|
265
|
+
})
|
|
266
|
+
expect(result.toolbar).toBe(ToolBarVariants.SIMPLE)
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
it('no grades at all with regular mode → COMMON', () => {
|
|
270
|
+
const result = getUIModeWithDefaults({
|
|
271
|
+
assignment: { grade: null },
|
|
272
|
+
practice: { isEnabled: false, grade: null },
|
|
273
|
+
user: { grade: 5 },
|
|
274
|
+
})
|
|
275
|
+
expect(result.toolbar).toBe(ToolBarVariants.COMMON)
|
|
276
|
+
})
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
describe('answer area is SIMPLE only in simple mode when practicing, has variants, or handwriting whole numbers', () => {
|
|
280
|
+
it('regular mode → always REGULAR regardless of other inputs', () => {
|
|
281
|
+
const result = getUIModeWithDefaults({
|
|
282
|
+
user: { grade: 5 },
|
|
283
|
+
practice: { isEnabled: true, grade: 5 },
|
|
284
|
+
problem: {
|
|
285
|
+
answerType: AnswerType.HANDWRITING,
|
|
286
|
+
characterType: MyScriptMathCharacterTypes.NUMBERS_WHOLE,
|
|
287
|
+
hasAnswerVariants: true,
|
|
288
|
+
},
|
|
289
|
+
})
|
|
290
|
+
expect(result.answerArea).toBe(UIMode.REGULAR)
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
it('simple mode + practice exercise → SIMPLE', () => {
|
|
294
|
+
const result = getUIModeWithDefaults({
|
|
295
|
+
practice: { isEnabled: true, grade: 1 },
|
|
296
|
+
problem: {
|
|
297
|
+
answerType: AnswerType.HANDWRITING,
|
|
298
|
+
characterType: MyScriptMathCharacterTypes.DEFAULT,
|
|
299
|
+
hasAnswerVariants: false,
|
|
300
|
+
},
|
|
301
|
+
})
|
|
302
|
+
expect(result.answerArea).toBe(UIMode.SIMPLE)
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
it('simple mode + answer variants → SIMPLE', () => {
|
|
306
|
+
const result = getUIModeWithDefaults({
|
|
307
|
+
user: { grade: 1 },
|
|
308
|
+
problem: {
|
|
309
|
+
answerType: AnswerType.HANDWRITING,
|
|
310
|
+
characterType: MyScriptMathCharacterTypes.DEFAULT,
|
|
311
|
+
hasAnswerVariants: true,
|
|
312
|
+
},
|
|
313
|
+
})
|
|
314
|
+
expect(result.answerArea).toBe(UIMode.SIMPLE)
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
it('simple mode + handwriting whole numbers → SIMPLE', () => {
|
|
318
|
+
const result = getUIModeWithDefaults({
|
|
319
|
+
user: { grade: 1 },
|
|
320
|
+
problem: {
|
|
321
|
+
answerType: AnswerType.HANDWRITING,
|
|
322
|
+
characterType: MyScriptMathCharacterTypes.NUMBERS_WHOLE,
|
|
323
|
+
hasAnswerVariants: false,
|
|
324
|
+
},
|
|
325
|
+
})
|
|
326
|
+
expect(result.answerArea).toBe(UIMode.SIMPLE)
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
it('simple mode + handwriting but not whole numbers → REGULAR', () => {
|
|
330
|
+
const result = getUIModeWithDefaults({
|
|
331
|
+
user: { grade: 1 },
|
|
332
|
+
problem: {
|
|
333
|
+
answerType: AnswerType.HANDWRITING,
|
|
334
|
+
characterType: MyScriptMathCharacterTypes.NUMBERS,
|
|
335
|
+
hasAnswerVariants: false,
|
|
336
|
+
},
|
|
337
|
+
})
|
|
338
|
+
expect(result.answerArea).toBe(UIMode.REGULAR)
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
it('simple mode + multiple choice even with whole numbers → REGULAR', () => {
|
|
342
|
+
const result = getUIModeWithDefaults({
|
|
343
|
+
user: { grade: 1 },
|
|
344
|
+
problem: {
|
|
345
|
+
answerType: AnswerType.MULTIPLE_CHOICE,
|
|
346
|
+
characterType: MyScriptMathCharacterTypes.NUMBERS_WHOLE,
|
|
347
|
+
hasAnswerVariants: false,
|
|
348
|
+
},
|
|
349
|
+
})
|
|
350
|
+
expect(result.answerArea).toBe(UIMode.REGULAR)
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
it('simple mode + no special conditions → REGULAR', () => {
|
|
354
|
+
const result = getUIModeWithDefaults({
|
|
355
|
+
user: { grade: 1 },
|
|
356
|
+
problem: {
|
|
357
|
+
answerType: AnswerType.SINGLE_CHOICE,
|
|
358
|
+
characterType: MyScriptMathCharacterTypes.DEFAULT,
|
|
359
|
+
hasAnswerVariants: false,
|
|
360
|
+
},
|
|
361
|
+
})
|
|
362
|
+
expect(result.answerArea).toBe(UIMode.REGULAR)
|
|
363
|
+
})
|
|
364
|
+
})
|