@coorpacademy/app-review 0.1.15 → 0.1.17
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/es/actions/api/fetch-skills.d.ts +5 -7
- package/es/actions/api/fetch-skills.js +12 -4
- package/es/actions/api/fetch-slide.d.ts +14 -7
- package/es/actions/api/fetch-slide.js +23 -18
- package/es/actions/api/post-answer.d.ts +10 -0
- package/es/actions/api/post-answer.js +25 -0
- package/es/actions/api/post-progression.d.ts +5 -7
- package/es/actions/api/post-progression.js +16 -8
- package/es/actions/api/test/fetch-skills.test.js +57 -0
- package/es/actions/api/test/fetch-slide.test.js +64 -0
- package/es/actions/api/test/post-answer.test.d.ts +1 -0
- package/es/actions/api/test/post-answer.test.js +82 -0
- package/es/actions/api/test/post-progression.test.d.ts +1 -0
- package/es/actions/api/test/post-progression.test.js +105 -0
- package/es/actions/data/test/token.test.d.ts +1 -0
- package/es/actions/data/test/token.test.js +25 -0
- package/es/actions/index.d.ts +1 -8
- package/es/actions/test/create-test-store.d.ts +5 -0
- package/es/actions/test/create-test-store.js +16 -0
- package/es/actions/ui/answers.d.ts +21 -0
- package/es/actions/ui/answers.js +43 -0
- package/es/actions/ui/slides.d.ts +0 -5
- package/es/actions/ui/slides.js +0 -4
- package/es/actions/ui/test/answers.test.d.ts +1 -0
- package/es/actions/ui/test/answers.test.js +90 -0
- package/es/actions/ui/test/slides.test.d.ts +1 -0
- package/es/actions/ui/test/slides.test.js +26 -0
- package/es/common/index.d.ts +0 -3
- package/es/common/index.js +0 -4
- package/es/index.js +11 -19
- package/es/reducers/data/index.d.ts +2 -2
- package/es/reducers/data/progression.d.ts +2 -3
- package/es/reducers/data/progression.js +0 -5
- package/es/reducers/data/slides.d.ts +3 -4
- package/es/reducers/data/slides.js +5 -1
- package/es/reducers/data/test/progression.test.d.ts +1 -0
- package/es/reducers/data/test/progression.test.js +38 -0
- package/es/reducers/data/test/skills.test.d.ts +1 -0
- package/es/reducers/data/test/skills.test.js +12 -0
- package/es/reducers/data/test/slides.test.d.ts +1 -0
- package/es/reducers/data/test/slides.test.js +20 -0
- package/es/reducers/data/test/token.test.d.ts +1 -0
- package/es/reducers/data/test/token.test.js +11 -0
- package/es/reducers/index.d.ts +3 -2
- package/es/reducers/ui/answers.d.ts +4 -0
- package/es/reducers/ui/answers.js +9 -0
- package/es/reducers/ui/index.d.ts +7 -4
- package/es/reducers/ui/index.js +4 -2
- package/es/reducers/ui/slide.d.ts +8 -0
- package/es/reducers/ui/slide.js +26 -0
- package/es/reducers/ui/test/answers.test.d.ts +1 -0
- package/es/reducers/ui/test/answers.test.js +27 -0
- package/es/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/es/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/es/reducers/ui/test/navigation.test.d.ts +1 -0
- package/es/reducers/ui/test/navigation.test.js +15 -0
- package/es/reducers/ui/test/slide.test.d.ts +1 -0
- package/es/reducers/ui/test/slide.test.js +12 -0
- package/es/services/fetch-slide.js +1 -1
- package/es/services/index.js +3 -1
- package/es/services/post-answer.d.ts +2 -0
- package/es/services/post-answer.js +18 -0
- package/es/services/test/fetch-slide.test.d.ts +1 -0
- package/es/services/test/fetch-slide.test.js +22 -0
- package/es/services/test/post-answer.test.d.ts +1 -0
- package/es/services/test/post-answer.test.js +57 -0
- package/es/services/test/post-progression.test.js +9 -1
- package/es/test/util/services.mock.d.ts +2 -1
- package/es/test/util/services.mock.js +88 -44
- package/es/types/common.d.ts +22 -33
- package/es/views/skills/index.d.ts +1 -1
- package/es/views/skills/index.js +0 -3
- package/es/views/skills/test/skills.test.d.ts +1 -0
- package/es/views/skills/test/skills.test.js +94 -0
- package/es/views/slides/index.d.ts +89 -2
- package/es/views/slides/index.js +80 -10
- package/es/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/es/views/slides/map-api-slide-to-ui.js +165 -0
- package/es/{helpers → views/slides}/test/fixtures/free-text.d.ts +2 -1
- package/es/views/slides/test/fixtures/free-text.js +38 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm.d.ts +2 -1
- package/es/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
- package/es/{helpers → views/slides}/test/fixtures/select-template.d.ts +2 -1
- package/es/views/slides/test/fixtures/select-template.js +92 -0
- package/es/{helpers → views/slides}/test/fixtures/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/slider.js +36 -0
- package/es/{helpers → views/slides}/test/fixtures/text-template.d.ts +2 -1
- package/es/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +234 -0
- package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/es/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/lib/actions/api/fetch-skills.d.ts +5 -7
- package/lib/actions/api/fetch-skills.js +58 -7
- package/lib/actions/api/fetch-slide.d.ts +14 -7
- package/lib/actions/api/fetch-slide.js +72 -20
- package/lib/actions/api/post-answer.d.ts +10 -0
- package/lib/actions/api/post-answer.js +75 -0
- package/lib/actions/api/post-progression.d.ts +5 -7
- package/lib/actions/api/post-progression.js +67 -10
- package/lib/actions/api/test/fetch-skills.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-skills.test.js +116 -0
- package/lib/actions/api/test/fetch-slide.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-slide.test.js +123 -0
- package/lib/actions/api/test/post-answer.test.d.ts +1 -0
- package/lib/actions/api/test/post-answer.test.js +145 -0
- package/lib/actions/api/test/post-progression.test.d.ts +1 -0
- package/lib/actions/api/test/post-progression.test.js +163 -0
- package/lib/actions/data/test/token.test.d.ts +1 -0
- package/lib/actions/data/test/token.test.js +70 -0
- package/lib/actions/index.d.ts +1 -8
- package/lib/actions/test/create-test-store.d.ts +5 -0
- package/lib/actions/test/create-test-store.js +18 -0
- package/lib/actions/ui/answers.d.ts +21 -0
- package/lib/actions/ui/answers.js +54 -0
- package/lib/actions/ui/slides.d.ts +0 -5
- package/lib/actions/ui/slides.js +0 -4
- package/lib/actions/ui/test/answers.test.d.ts +1 -0
- package/lib/actions/ui/test/answers.test.js +171 -0
- package/lib/actions/ui/test/slides.test.d.ts +1 -0
- package/lib/actions/ui/test/slides.test.js +71 -0
- package/lib/common/index.d.ts +0 -3
- package/lib/common/index.js +0 -4
- package/lib/index.js +22 -21
- package/lib/reducers/data/index.d.ts +2 -2
- package/lib/reducers/data/progression.d.ts +2 -3
- package/lib/reducers/data/progression.js +0 -5
- package/lib/reducers/data/slides.d.ts +3 -4
- package/lib/reducers/data/slides.js +5 -1
- package/lib/reducers/data/test/progression.test.d.ts +1 -0
- package/lib/reducers/data/test/progression.test.js +38 -0
- package/lib/reducers/data/test/skills.test.d.ts +1 -0
- package/lib/reducers/data/test/skills.test.js +12 -0
- package/lib/reducers/data/test/slides.test.d.ts +1 -0
- package/lib/reducers/data/test/slides.test.js +20 -0
- package/lib/reducers/data/test/token.test.d.ts +1 -0
- package/lib/reducers/data/test/token.test.js +11 -0
- package/lib/reducers/index.d.ts +3 -2
- package/lib/reducers/ui/answers.d.ts +4 -0
- package/lib/reducers/ui/answers.js +10 -0
- package/lib/reducers/ui/index.d.ts +7 -4
- package/lib/reducers/ui/index.js +4 -2
- package/lib/reducers/ui/slide.d.ts +8 -0
- package/lib/reducers/ui/slide.js +27 -0
- package/lib/reducers/ui/test/answers.test.d.ts +1 -0
- package/lib/reducers/ui/test/answers.test.js +27 -0
- package/lib/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/lib/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/lib/reducers/ui/test/navigation.test.d.ts +1 -0
- package/lib/reducers/ui/test/navigation.test.js +15 -0
- package/lib/reducers/ui/test/slide.test.d.ts +1 -0
- package/lib/reducers/ui/test/slide.test.js +12 -0
- package/lib/services/fetch-slide.js +1 -1
- package/lib/services/index.js +3 -1
- package/lib/services/post-answer.d.ts +2 -0
- package/lib/services/post-answer.js +62 -0
- package/lib/services/test/fetch-slide.test.d.ts +1 -0
- package/lib/services/test/fetch-slide.test.js +76 -0
- package/lib/services/test/post-answer.test.d.ts +1 -0
- package/lib/services/test/post-answer.test.js +111 -0
- package/lib/services/test/post-progression.test.js +9 -1
- package/lib/test/util/services.mock.d.ts +2 -1
- package/lib/test/util/services.mock.js +88 -44
- package/lib/types/common.d.ts +22 -33
- package/lib/views/skills/index.d.ts +1 -1
- package/lib/views/skills/index.js +0 -3
- package/lib/views/skills/test/skills.test.d.ts +1 -0
- package/lib/views/skills/test/skills.test.js +94 -0
- package/lib/views/slides/index.d.ts +89 -2
- package/lib/views/slides/index.js +80 -10
- package/lib/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/lib/views/slides/map-api-slide-to-ui.js +179 -0
- package/lib/{helpers → views/slides}/test/fixtures/free-text.d.ts +2 -1
- package/lib/views/slides/test/fixtures/free-text.js +38 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm.d.ts +2 -1
- package/lib/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
- package/lib/{helpers → views/slides}/test/fixtures/select-template.d.ts +2 -1
- package/lib/views/slides/test/fixtures/select-template.js +92 -0
- package/lib/{helpers → views/slides}/test/fixtures/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/slider.js +36 -0
- package/lib/{helpers → views/slides}/test/fixtures/text-template.d.ts +2 -1
- package/lib/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +234 -0
- package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/lib/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/package.json +6 -5
- package/src/actions/api/fetch-skills.ts +19 -12
- package/src/actions/api/fetch-slide.ts +35 -29
- package/src/actions/api/post-answer.ts +39 -0
- package/src/actions/api/post-progression.ts +22 -22
- package/src/actions/api/test/fetch-skills.test.ts +73 -0
- package/src/actions/api/test/fetch-slide.test.ts +80 -0
- package/src/actions/api/test/post-answer.test.ts +101 -0
- package/src/actions/api/test/post-progression.test.ts +122 -0
- package/src/actions/data/test/token.test.ts +29 -0
- package/src/actions/index.ts +1 -17
- package/src/actions/test/create-test-store.ts +25 -0
- package/src/actions/ui/answers.ts +63 -0
- package/src/actions/ui/slides.ts +1 -8
- package/src/actions/ui/test/answers.test.ts +103 -0
- package/src/actions/ui/test/slides.test.ts +30 -0
- package/src/common/index.ts +0 -7
- package/src/index.tsx +15 -32
- package/src/reducers/data/index.ts +1 -1
- package/src/reducers/data/progression.ts +2 -7
- package/src/reducers/data/slides.ts +12 -4
- package/src/reducers/data/test/progression.test.ts +42 -0
- package/src/reducers/data/test/skills.test.ts +14 -0
- package/src/reducers/data/test/slides.test.ts +26 -0
- package/src/reducers/data/test/token.test.ts +13 -0
- package/src/reducers/ui/answers.ts +15 -0
- package/src/reducers/ui/index.ts +6 -3
- package/src/reducers/ui/slide.ts +43 -0
- package/src/reducers/ui/test/answers.test.ts +33 -0
- package/src/reducers/ui/test/current-slide-ref.test.ts +14 -0
- package/src/reducers/ui/test/navigation.test.ts +19 -0
- package/src/reducers/ui/test/slide.test.ts +15 -0
- package/src/services/fetch-slide.ts +1 -1
- package/src/services/index.ts +3 -1
- package/src/services/post-answer.ts +27 -0
- package/src/services/test/fetch-slide.test.ts +30 -0
- package/src/services/test/post-answer.test.ts +68 -0
- package/src/services/test/post-progression.test.ts +9 -1
- package/src/test/util/services.mock.ts +93 -45
- package/src/types/common.ts +34 -44
- package/src/views/skills/index.ts +1 -5
- package/src/views/skills/test/skills.test.ts +101 -0
- package/src/views/slides/index.ts +186 -12
- package/src/views/slides/map-api-slide-to-ui.ts +251 -0
- package/src/views/slides/test/fixtures/free-text.ts +44 -0
- package/src/views/slides/test/fixtures/qcm-drag.ts +112 -0
- package/src/views/slides/test/fixtures/qcm-graphic.ts +95 -0
- package/src/{helpers → views/slides}/test/fixtures/qcm.ts +7 -2
- package/src/views/slides/test/fixtures/select-template.ts +99 -0
- package/src/views/slides/test/fixtures/slider.ts +42 -0
- package/src/{helpers → views/slides}/test/fixtures/text-template.ts +7 -2
- package/src/views/slides/test/index.test.ts +240 -0
- package/src/{helpers → views/slides}/test/map-api-slide-to-ui.test.ts +22 -10
- package/es/fixtures/qcm-slide.d.ts +0 -2
- package/es/fixtures/qcm-slide.js +0 -33
- package/es/fixtures/temp-fixture.d.ts +0 -3
- package/es/fixtures/temp-fixture.js +0 -84
- package/es/helpers/map-api-slide-to-ui.d.ts +0 -11
- package/es/helpers/map-api-slide-to-ui.js +0 -193
- package/es/helpers/test/fixtures/free-text.js +0 -30
- package/es/helpers/test/fixtures/qcm-drag.js +0 -112
- package/es/helpers/test/fixtures/qcm-graphic.js +0 -76
- package/es/helpers/test/fixtures/select-template.js +0 -94
- package/es/helpers/test/fixtures/slider.js +0 -33
- package/es/reducers/ui/slides.d.ts +0 -9
- package/es/reducers/ui/slides.js +0 -42
- package/es/types/views/slides.d.ts +0 -74
- package/es/types/views/slides.js +0 -6
- package/lib/fixtures/qcm-slide.d.ts +0 -2
- package/lib/fixtures/qcm-slide.js +0 -33
- package/lib/fixtures/temp-fixture.d.ts +0 -3
- package/lib/fixtures/temp-fixture.js +0 -84
- package/lib/helpers/map-api-slide-to-ui.d.ts +0 -11
- package/lib/helpers/map-api-slide-to-ui.js +0 -201
- package/lib/helpers/test/fixtures/free-text.js +0 -30
- package/lib/helpers/test/fixtures/qcm-drag.js +0 -112
- package/lib/helpers/test/fixtures/qcm-graphic.js +0 -76
- package/lib/helpers/test/fixtures/select-template.js +0 -94
- package/lib/helpers/test/fixtures/slider.js +0 -33
- package/lib/reducers/ui/slides.d.ts +0 -9
- package/lib/reducers/ui/slides.js +0 -43
- package/lib/types/views/slides.d.ts +0 -74
- package/lib/types/views/slides.js +0 -6
- package/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
- package/src/helpers/map-api-slide-to-ui.ts +0 -279
- package/src/helpers/test/fixtures/free-text.ts +0 -33
- package/src/helpers/test/fixtures/qcm-drag.ts +0 -115
- package/src/helpers/test/fixtures/qcm-graphic.ts +0 -79
- package/src/helpers/test/fixtures/select-template.ts +0 -97
- package/src/helpers/test/fixtures/slider.ts +0 -36
- package/src/reducers/ui/slides.ts +0 -58
- package/src/types/views/slides.ts +0 -90
- /package/es/{helpers/test/map-api-slide-to-ui.test.d.ts → actions/api/test/fetch-skills.test.d.ts} +0 -0
- /package/{lib/helpers/test/map-api-slide-to-ui.test.d.ts → es/actions/api/test/fetch-slide.test.d.ts} +0 -0
|
@@ -1,52 +1,100 @@
|
|
|
1
|
-
import {qcmSlide} from '../../
|
|
2
|
-
import {
|
|
1
|
+
import {qcmSlide} from '../../views/slides/test/fixtures/qcm';
|
|
2
|
+
import {qcmGraphicSlide} from '../../views/slides/test/fixtures/qcm-graphic';
|
|
3
|
+
import {freeTextSlide} from '../../views/slides/test/fixtures/free-text';
|
|
4
|
+
import {sliderSlide} from '../../views/slides/test/fixtures/slider';
|
|
5
|
+
import {ProgressionFromAPI, Services, SlideFromAPI} from '../../types/common';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
const getSlideFixture = (ref: string): SlideFromAPI => {
|
|
8
|
+
switch (ref) {
|
|
9
|
+
case qcmSlide.universalRef:
|
|
10
|
+
return qcmSlide;
|
|
11
|
+
case qcmGraphicSlide.universalRef:
|
|
12
|
+
return qcmGraphicSlide;
|
|
13
|
+
case freeTextSlide.universalRef:
|
|
14
|
+
return freeTextSlide;
|
|
15
|
+
default:
|
|
16
|
+
return sliderSlide;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const fetchSkillsResponse = [
|
|
21
|
+
{
|
|
22
|
+
skillRef: '_skill-ref',
|
|
23
|
+
slidesToReview: 2,
|
|
24
|
+
name: 'skill-test',
|
|
25
|
+
custom: false
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
skillRef: '_skill-ref-2',
|
|
29
|
+
slidesToReview: 2,
|
|
30
|
+
name: 'skill-test-2',
|
|
31
|
+
custom: true
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const postProgressionResponse: ProgressionFromAPI = {
|
|
36
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
37
|
+
content: {
|
|
38
|
+
ref: '_skill-ref',
|
|
39
|
+
type: 'skill'
|
|
23
40
|
},
|
|
24
|
-
|
|
25
|
-
|
|
41
|
+
engine: {
|
|
42
|
+
ref: 'review'
|
|
26
43
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
state: {
|
|
45
|
+
allAnswers: [],
|
|
46
|
+
isCorrect: true,
|
|
47
|
+
nextContent: {
|
|
48
|
+
ref: 'sli_VJYjJnJhg',
|
|
49
|
+
type: 'slide'
|
|
50
|
+
},
|
|
51
|
+
pendingSlides: [],
|
|
52
|
+
slides: [],
|
|
53
|
+
step: {
|
|
54
|
+
current: 1
|
|
55
|
+
},
|
|
56
|
+
stars: 0
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const postAnswerResponse: ProgressionFromAPI = {
|
|
61
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
62
|
+
content: {
|
|
63
|
+
ref: '_skill-ref',
|
|
64
|
+
type: 'skill'
|
|
65
|
+
},
|
|
66
|
+
engine: {
|
|
67
|
+
ref: 'review'
|
|
68
|
+
},
|
|
69
|
+
state: {
|
|
70
|
+
allAnswers: [
|
|
71
|
+
{
|
|
72
|
+
slideRef: 'sli_VJYjJnJhg',
|
|
39
73
|
isCorrect: true,
|
|
40
|
-
|
|
41
|
-
ref: 'sli_N1XACJobn',
|
|
42
|
-
type: 'slide'
|
|
43
|
-
},
|
|
44
|
-
pendingSlides: [],
|
|
45
|
-
slides: [],
|
|
46
|
-
step: {
|
|
47
|
-
current: 1
|
|
48
|
-
}
|
|
74
|
+
answer: ['Benchmark']
|
|
49
75
|
}
|
|
50
|
-
|
|
76
|
+
],
|
|
77
|
+
isCorrect: true,
|
|
78
|
+
nextContent: {
|
|
79
|
+
ref: 'sli_VkSQroQnx',
|
|
80
|
+
type: 'slide'
|
|
81
|
+
},
|
|
82
|
+
content: {
|
|
83
|
+
ref: 'sli_VJYjJnJhg',
|
|
84
|
+
type: 'slide'
|
|
85
|
+
},
|
|
86
|
+
pendingSlides: [],
|
|
87
|
+
slides: ['sli_VJYjJnJhg'],
|
|
88
|
+
step: {
|
|
89
|
+
current: 2
|
|
90
|
+
},
|
|
91
|
+
stars: 4
|
|
51
92
|
}
|
|
52
93
|
};
|
|
94
|
+
|
|
95
|
+
export const services: Services = {
|
|
96
|
+
fetchSkills: () => Promise.resolve(fetchSkillsResponse),
|
|
97
|
+
fetchSlide: ref => Promise.resolve({...getSlideFixture(ref), universalRef: ref, id: ref}),
|
|
98
|
+
postProgression: () => Promise.resolve(postProgressionResponse),
|
|
99
|
+
postAnswer: () => Promise.resolve(postAnswerResponse)
|
|
100
|
+
};
|
package/src/types/common.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {SlideIndexes} from '../common';
|
|
2
|
-
import {AnswerUI} from './slides';
|
|
3
|
-
|
|
4
1
|
// TODO use type from components
|
|
5
2
|
type TemplateContextValues = {
|
|
6
3
|
brandTheme?: unknown;
|
|
@@ -25,25 +22,25 @@ type BaseContent = {
|
|
|
25
22
|
choices: ChoiceFromAPI[];
|
|
26
23
|
};
|
|
27
24
|
|
|
28
|
-
type
|
|
25
|
+
type BaseQuestion = {
|
|
29
26
|
header?: string;
|
|
30
27
|
content: BaseContent;
|
|
31
28
|
explanation?: string;
|
|
32
29
|
};
|
|
33
30
|
|
|
34
|
-
export type QcmQuestion =
|
|
31
|
+
export type QcmQuestion = BaseQuestion & {
|
|
35
32
|
type: 'qcm';
|
|
36
33
|
};
|
|
37
34
|
|
|
38
|
-
export type QcmGraphicQuestion =
|
|
35
|
+
export type QcmGraphicQuestion = BaseQuestion & {
|
|
39
36
|
type: 'qcmGraphic';
|
|
40
37
|
};
|
|
41
38
|
|
|
42
|
-
export type QcmDragQuestion =
|
|
39
|
+
export type QcmDragQuestion = BaseQuestion & {
|
|
43
40
|
type: 'qcmDrag';
|
|
44
41
|
};
|
|
45
42
|
|
|
46
|
-
export type BasicQuestion = Omit<
|
|
43
|
+
export type BasicQuestion = Omit<BaseQuestion, 'content'> & {
|
|
47
44
|
type: 'basic';
|
|
48
45
|
content: {
|
|
49
46
|
media?: unknown;
|
|
@@ -53,7 +50,7 @@ export type BasicQuestion = Omit<Question, 'content'> & {
|
|
|
53
50
|
};
|
|
54
51
|
};
|
|
55
52
|
|
|
56
|
-
export type SliderQuestion = Omit<
|
|
53
|
+
export type SliderQuestion = Omit<BaseQuestion, 'content'> & {
|
|
57
54
|
content: {
|
|
58
55
|
media?: unknown;
|
|
59
56
|
unitLabel: string;
|
|
@@ -64,27 +61,33 @@ export type SliderQuestion = Omit<Question, 'content'> & {
|
|
|
64
61
|
type: 'slider';
|
|
65
62
|
};
|
|
66
63
|
|
|
67
|
-
export type TemplateQuestion = Omit<
|
|
64
|
+
export type TemplateQuestion = Omit<BaseQuestion, 'content'> & {
|
|
68
65
|
content: BaseContent & {
|
|
69
66
|
template: string;
|
|
70
67
|
};
|
|
71
68
|
type: 'template';
|
|
72
69
|
};
|
|
73
70
|
|
|
71
|
+
export type Question =
|
|
72
|
+
| QcmQuestion
|
|
73
|
+
| QcmGraphicQuestion
|
|
74
|
+
| QcmDragQuestion
|
|
75
|
+
| BasicQuestion
|
|
76
|
+
| SliderQuestion
|
|
77
|
+
| TemplateQuestion;
|
|
78
|
+
|
|
74
79
|
export type SlideFromAPI = {
|
|
75
|
-
question:
|
|
76
|
-
| QcmQuestion
|
|
77
|
-
| QcmGraphicQuestion
|
|
78
|
-
| QcmDragQuestion
|
|
79
|
-
| BasicQuestion
|
|
80
|
-
| SliderQuestion
|
|
81
|
-
| TemplateQuestion;
|
|
80
|
+
question: Question;
|
|
82
81
|
klf: string;
|
|
83
82
|
universalRef: string;
|
|
84
83
|
tips?: string;
|
|
85
84
|
clue?: string;
|
|
86
85
|
hasClue?: boolean;
|
|
87
86
|
id: string;
|
|
87
|
+
parentContentTitle: {
|
|
88
|
+
title: string;
|
|
89
|
+
type: 'chapter' | 'course';
|
|
90
|
+
};
|
|
88
91
|
};
|
|
89
92
|
|
|
90
93
|
type ProgressionAnswerItem = {
|
|
@@ -109,10 +112,18 @@ export type ProgressionState = {
|
|
|
109
112
|
step: {
|
|
110
113
|
current: number;
|
|
111
114
|
};
|
|
115
|
+
stars: number;
|
|
112
116
|
};
|
|
113
117
|
|
|
114
118
|
export type ProgressionFromAPI = {
|
|
115
119
|
_id: string;
|
|
120
|
+
content: {
|
|
121
|
+
type: 'skill';
|
|
122
|
+
ref: string;
|
|
123
|
+
};
|
|
124
|
+
engine: {
|
|
125
|
+
ref: 'review';
|
|
126
|
+
};
|
|
116
127
|
state: ProgressionState;
|
|
117
128
|
};
|
|
118
129
|
|
|
@@ -127,6 +138,12 @@ export type Services = {
|
|
|
127
138
|
fetchSkills(token: string): Promise<Skill[]>;
|
|
128
139
|
fetchSlide(slideRef: string, token: string): Promise<SlideFromAPI | void>;
|
|
129
140
|
postProgression(skillRef: string, token: string): Promise<ProgressionFromAPI>;
|
|
141
|
+
postAnswer(
|
|
142
|
+
skillRef: string,
|
|
143
|
+
token: string,
|
|
144
|
+
progressionId: string,
|
|
145
|
+
answer: string[]
|
|
146
|
+
): Promise<ProgressionFromAPI>;
|
|
130
147
|
};
|
|
131
148
|
|
|
132
149
|
export type Options = {
|
|
@@ -152,33 +169,6 @@ export type JWT = {
|
|
|
152
169
|
host: string;
|
|
153
170
|
};
|
|
154
171
|
|
|
155
|
-
type SlideUIAnimations = 'unstack' | 'restack';
|
|
156
|
-
|
|
157
|
-
export type NextUISlide = {
|
|
158
|
-
questionText?: string;
|
|
159
|
-
answerUI?: AnswerUI;
|
|
160
|
-
hidden?: boolean;
|
|
161
|
-
position?: number;
|
|
162
|
-
animationType?: SlideUIAnimations;
|
|
163
|
-
isCorrect?: boolean;
|
|
164
|
-
endReview?: boolean;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export type UISlide = {
|
|
168
|
-
questionText?: string;
|
|
169
|
-
answerUI?: AnswerUI;
|
|
170
|
-
hidden?: boolean;
|
|
171
|
-
position: number;
|
|
172
|
-
animationType?: SlideUIAnimations;
|
|
173
|
-
isCorrect?: boolean;
|
|
174
|
-
endReview?: boolean;
|
|
175
|
-
nextContent?: NextUISlide;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
export type FinishedSlides = {
|
|
179
|
-
[key in SlideIndexes]?: true;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
172
|
export type WithRequired<T, K extends keyof T> = T & {
|
|
183
173
|
// the "-" is a Mapping Modifier, removes optionality from a prop
|
|
184
174
|
[P in K]-?: T[P];
|
|
@@ -28,11 +28,7 @@ type SkillsProps = NoSkillsProps & {
|
|
|
28
28
|
|
|
29
29
|
export {SkillsProps};
|
|
30
30
|
|
|
31
|
-
export const mapStateToSkillsProps = (state: StoreState): SkillsProps
|
|
32
|
-
if (!state.data.skills) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
31
|
+
export const mapStateToSkillsProps = (state: StoreState): SkillsProps => {
|
|
36
32
|
return {
|
|
37
33
|
title: '@todo title',
|
|
38
34
|
titleNoSkills: '@todo titleNoSkills',
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import map from 'lodash/fp/map';
|
|
3
|
+
import omit from 'lodash/fp/omit';
|
|
4
|
+
import {StoreState} from '../../../reducers';
|
|
5
|
+
import {mapStateToSkillsProps} from '..';
|
|
6
|
+
|
|
7
|
+
test('should create initial props when there are no skills on the state', t => {
|
|
8
|
+
const state: StoreState = {
|
|
9
|
+
data: {
|
|
10
|
+
progression: null,
|
|
11
|
+
skills: [],
|
|
12
|
+
slides: {},
|
|
13
|
+
token: '1234'
|
|
14
|
+
},
|
|
15
|
+
ui: {
|
|
16
|
+
currentSlideRef: '',
|
|
17
|
+
navigation: ['loader', 'skills'],
|
|
18
|
+
answers: [],
|
|
19
|
+
slide: {
|
|
20
|
+
validateButton: false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const props = mapStateToSkillsProps(state);
|
|
26
|
+
|
|
27
|
+
t.deepEqual(props, {
|
|
28
|
+
title: '@todo title',
|
|
29
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
30
|
+
textNoSkills: '@todo textNoSkills',
|
|
31
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
32
|
+
isLoading: false,
|
|
33
|
+
isLoadingAriaLabel: '@todo loading',
|
|
34
|
+
listSkills: []
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('should create initial props when skills on the state', t => {
|
|
39
|
+
const state: StoreState = {
|
|
40
|
+
data: {
|
|
41
|
+
progression: null,
|
|
42
|
+
skills: [
|
|
43
|
+
{
|
|
44
|
+
skillRef: '_skill-ref',
|
|
45
|
+
slidesToReview: 2,
|
|
46
|
+
name: 'skill-test',
|
|
47
|
+
custom: false
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
skillRef: '_skill-ref-2',
|
|
51
|
+
slidesToReview: 5,
|
|
52
|
+
name: 'skill-test-2',
|
|
53
|
+
custom: true
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
slides: {},
|
|
57
|
+
token: '1234'
|
|
58
|
+
},
|
|
59
|
+
ui: {
|
|
60
|
+
currentSlideRef: '',
|
|
61
|
+
navigation: ['loader', 'skills'],
|
|
62
|
+
answers: [],
|
|
63
|
+
slide: {
|
|
64
|
+
validateButton: false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const props = mapStateToSkillsProps(state);
|
|
70
|
+
|
|
71
|
+
t.deepEqual(omit('listSkills', props), {
|
|
72
|
+
title: '@todo title',
|
|
73
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
74
|
+
textNoSkills: '@todo textNoSkills',
|
|
75
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
76
|
+
isLoading: false,
|
|
77
|
+
isLoadingAriaLabel: '@todo loading'
|
|
78
|
+
});
|
|
79
|
+
t.deepEqual(map(omit('onClick'), props.listSkills), [
|
|
80
|
+
{
|
|
81
|
+
'aria-label': '',
|
|
82
|
+
isCustom: false,
|
|
83
|
+
skillTitle: 'skill-test',
|
|
84
|
+
skillAriaLabel: '@todo skill aria label',
|
|
85
|
+
buttonLabel: '@todo button',
|
|
86
|
+
buttonAriaLabel: '@todo button aria label',
|
|
87
|
+
reviseLabel: '@todo revise',
|
|
88
|
+
reviseAriaLabel: '@todo revise aria label'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
'aria-label': '',
|
|
92
|
+
isCustom: true,
|
|
93
|
+
skillTitle: 'skill-test-2',
|
|
94
|
+
skillAriaLabel: '@todo skill aria label',
|
|
95
|
+
buttonLabel: '@todo button',
|
|
96
|
+
buttonAriaLabel: '@todo button aria label',
|
|
97
|
+
reviseLabel: '@todo revise',
|
|
98
|
+
reviseAriaLabel: '@todo revise aria label'
|
|
99
|
+
}
|
|
100
|
+
]);
|
|
101
|
+
});
|
|
@@ -1,8 +1,187 @@
|
|
|
1
|
+
import concat from 'lodash/fp/concat';
|
|
2
|
+
|
|
3
|
+
import get from 'lodash/fp/get';
|
|
4
|
+
import getOr from 'lodash/fp/getOr';
|
|
1
5
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
6
|
+
import pipe from 'lodash/fp/pipe';
|
|
7
|
+
import reduce from 'lodash/fp/reduce';
|
|
8
|
+
import set from 'lodash/fp/set';
|
|
9
|
+
import slice from 'lodash/fp/slice';
|
|
10
|
+
import toInteger from 'lodash/fp/toInteger';
|
|
11
|
+
import {Dispatch} from 'redux';
|
|
12
|
+
import {ProgressionFromAPI} from '../../types/common';
|
|
13
|
+
import {SlideIndexes} from '../../common';
|
|
2
14
|
import {StoreState} from '../../reducers';
|
|
3
|
-
import {
|
|
15
|
+
import {AnswerUI} from '../../types/slides';
|
|
16
|
+
import {postAnswer} from '../../actions/api/post-answer';
|
|
17
|
+
import {mapApiSlideToUi} from './map-api-slide-to-ui';
|
|
18
|
+
|
|
19
|
+
const ICON_VALUES = {
|
|
20
|
+
right: 'right',
|
|
21
|
+
wrong: 'wrong',
|
|
22
|
+
'no-answer': 'no-answer'
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
type IconValue = keyof typeof ICON_VALUES;
|
|
26
|
+
|
|
27
|
+
type StepItem = {
|
|
28
|
+
current: boolean;
|
|
29
|
+
icon: IconValue;
|
|
30
|
+
value: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type SlideUIAnimations = 'unstack' | 'restack';
|
|
4
34
|
|
|
5
|
-
|
|
35
|
+
export type UISlide = {
|
|
36
|
+
questionText?: string;
|
|
37
|
+
answerUI?: AnswerUI;
|
|
38
|
+
hidden?: boolean;
|
|
39
|
+
position: number;
|
|
40
|
+
animationType?: SlideUIAnimations;
|
|
41
|
+
isCorrect?: boolean;
|
|
42
|
+
endReview?: boolean;
|
|
43
|
+
loading: boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type SlidesStack = {
|
|
47
|
+
[key in SlideIndexes]: UISlide;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type CorrectionPopinProps = {
|
|
51
|
+
klf: {
|
|
52
|
+
label: string;
|
|
53
|
+
onClick: Function;
|
|
54
|
+
tooltip: string;
|
|
55
|
+
};
|
|
56
|
+
information: {
|
|
57
|
+
label: string;
|
|
58
|
+
message: string;
|
|
59
|
+
};
|
|
60
|
+
next: {
|
|
61
|
+
label: string;
|
|
62
|
+
ariaLabel: string;
|
|
63
|
+
};
|
|
64
|
+
successLabel: string;
|
|
65
|
+
failureLabel: string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type SlidesViewProps = {
|
|
69
|
+
header: {
|
|
70
|
+
mode: string;
|
|
71
|
+
skillName: string;
|
|
72
|
+
onQuitClick: Function;
|
|
73
|
+
'aria-label'?: string;
|
|
74
|
+
closeButtonAriaLabel: string;
|
|
75
|
+
steps: StepItem[];
|
|
76
|
+
};
|
|
77
|
+
stack: {
|
|
78
|
+
slides: SlidesStack;
|
|
79
|
+
validateButton: {
|
|
80
|
+
label: string;
|
|
81
|
+
disabled: boolean;
|
|
82
|
+
onClick: Function;
|
|
83
|
+
};
|
|
84
|
+
correctionPopinProps?: CorrectionPopinProps;
|
|
85
|
+
endReview: boolean;
|
|
86
|
+
};
|
|
87
|
+
reviewBackgroundAriaLabel?: string;
|
|
88
|
+
congratsProps?: {
|
|
89
|
+
'aria-label'?: string;
|
|
90
|
+
'data-name'?: string;
|
|
91
|
+
animationLottie: unknown;
|
|
92
|
+
title: string;
|
|
93
|
+
cardCongratsStar: unknown;
|
|
94
|
+
cardCongratsRank: unknown;
|
|
95
|
+
buttonRevising: {
|
|
96
|
+
'aria-label'?: string;
|
|
97
|
+
label: string;
|
|
98
|
+
onClick: Function;
|
|
99
|
+
type: string;
|
|
100
|
+
};
|
|
101
|
+
buttonRevisingSkill: {
|
|
102
|
+
'aria-label'?: string;
|
|
103
|
+
label: string;
|
|
104
|
+
onClick: Function;
|
|
105
|
+
type: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const initialState: SlidesStack = {
|
|
111
|
+
'0': {
|
|
112
|
+
hidden: false,
|
|
113
|
+
position: 0,
|
|
114
|
+
loading: true
|
|
115
|
+
},
|
|
116
|
+
'1': {
|
|
117
|
+
hidden: false,
|
|
118
|
+
position: 1,
|
|
119
|
+
loading: true
|
|
120
|
+
},
|
|
121
|
+
'2': {
|
|
122
|
+
hidden: false,
|
|
123
|
+
position: 2,
|
|
124
|
+
loading: true
|
|
125
|
+
},
|
|
126
|
+
'3': {
|
|
127
|
+
hidden: false,
|
|
128
|
+
position: 3,
|
|
129
|
+
loading: true
|
|
130
|
+
},
|
|
131
|
+
'4': {
|
|
132
|
+
hidden: false,
|
|
133
|
+
position: 4,
|
|
134
|
+
loading: true
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const getProgressionSlidesRefs = (progression: ProgressionFromAPI): string[] => {
|
|
139
|
+
if (progression.state.step.current < 5) {
|
|
140
|
+
const slideRef = progression.state.nextContent.ref;
|
|
141
|
+
return concat([slideRef], progression.state.slides);
|
|
142
|
+
}
|
|
143
|
+
return slice(0, 5, progression.state.slides);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const buildStackSlides = (state: StoreState, dispatch: Dispatch): SlidesStack => {
|
|
147
|
+
const currentSlideRef = state.ui.currentSlideRef;
|
|
148
|
+
const progression = state.data.progression;
|
|
149
|
+
|
|
150
|
+
if (!currentSlideRef || !progression) return initialState;
|
|
151
|
+
const slideRefs = getProgressionSlidesRefs(progression);
|
|
152
|
+
|
|
153
|
+
// @ts-expect-error typescript does not support capped versions of lodash functions
|
|
154
|
+
const stack = reduce.convert({cap: false})(
|
|
155
|
+
(acc: SlidesStack, uiSlide: UISlide, index: string) => {
|
|
156
|
+
const slideRef = slideRefs[toInteger(index)];
|
|
157
|
+
if (!slideRef) return set(index, uiSlide, acc);
|
|
158
|
+
|
|
159
|
+
const slideFromAPI = get(slideRef, state.data.slides);
|
|
160
|
+
if (!slideFromAPI) return set(index, uiSlide, acc);
|
|
161
|
+
|
|
162
|
+
const answers = state.ui.answers;
|
|
163
|
+
const {questionText, answerUI} = mapApiSlideToUi(dispatch)(slideFromAPI, answers);
|
|
164
|
+
const parentContentTitle = getOr('', 'parentContentTitle.title', slideFromAPI);
|
|
165
|
+
const parentContentType = getOr('', 'parentContentTitle.type', slideFromAPI);
|
|
166
|
+
|
|
167
|
+
const updatedUiSlide = pipe(
|
|
168
|
+
set('loading', false),
|
|
169
|
+
set('questionText', questionText),
|
|
170
|
+
set('answerUI', answerUI),
|
|
171
|
+
set('parentContentTitle', `From "${parentContentTitle}" ${parentContentType}`) // TODO translate: -From- .... -Course/chapter-
|
|
172
|
+
// TODO: Set position according to currentSlideRef et slideRefs (or maybe a value on the state ui.slidePositions !!)
|
|
173
|
+
)(uiSlide);
|
|
174
|
+
|
|
175
|
+
return set(index, updatedUiSlide, acc);
|
|
176
|
+
},
|
|
177
|
+
initialState,
|
|
178
|
+
initialState
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
return stack;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const buildStepItems = (state: StoreState): StepItem[] => {
|
|
6
185
|
const {progression} = state.data;
|
|
7
186
|
const {currentSlideRef} = state.ui;
|
|
8
187
|
if (!progression) return [];
|
|
@@ -57,11 +236,7 @@ const buildStepItemps = (state: StoreState): StepItem[] => {
|
|
|
57
236
|
return steps;
|
|
58
237
|
};
|
|
59
238
|
|
|
60
|
-
export const mapStateToSlidesProps = (state: StoreState):
|
|
61
|
-
if (!state.data.slides) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
239
|
+
export const mapStateToSlidesProps = (state: StoreState, dispatch: Dispatch): SlidesViewProps => {
|
|
65
240
|
return {
|
|
66
241
|
header: {
|
|
67
242
|
mode: '__revision_mode',
|
|
@@ -72,16 +247,15 @@ export const mapStateToSlidesProps = (state: StoreState): SlidesViewStaticProps
|
|
|
72
247
|
},
|
|
73
248
|
'aria-label': 'aria-header-wrapper',
|
|
74
249
|
closeButtonAriaLabel: 'aria-close-button',
|
|
75
|
-
steps:
|
|
250
|
+
steps: buildStepItems(state)
|
|
76
251
|
},
|
|
77
252
|
stack: {
|
|
78
|
-
slides: state
|
|
253
|
+
slides: buildStackSlides(state, dispatch),
|
|
79
254
|
validateButton: {
|
|
80
255
|
label: '__validate',
|
|
81
|
-
disabled:
|
|
256
|
+
disabled: !get('ui.slide.validateButton', state),
|
|
82
257
|
onClick: (): void => {
|
|
83
|
-
|
|
84
|
-
console.log('TODO: validate question');
|
|
258
|
+
dispatch(postAnswer);
|
|
85
259
|
}
|
|
86
260
|
},
|
|
87
261
|
correctionPopinProps: undefined,
|