@coorpacademy/app-review 0.1.16 → 0.1.18
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 +3 -3
- package/es/actions/api/fetch-skills.js +7 -2
- package/es/actions/api/fetch-slide.d.ts +1 -1
- package/es/actions/api/fetch-slide.js +3 -1
- package/es/actions/api/post-answer.d.ts +14 -0
- package/es/actions/api/post-answer.js +25 -0
- package/es/actions/api/post-progression.d.ts +3 -3
- package/es/actions/api/post-progression.js +5 -2
- package/es/actions/api/test/fetch-skills.test.js +7 -4
- package/es/actions/api/test/fetch-slide.test.js +7 -4
- 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.js +7 -4
- 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/{api/test → test}/create-test-store.d.ts +2 -2
- package/es/actions/{api/test → test}/create-test-store.js +1 -1
- package/es/actions/ui/answers.d.ts +17 -3
- package/es/actions/ui/answers.js +41 -3
- 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 +100 -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 +1 -3
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +3 -3
- package/es/reducers/data/progression.js +2 -5
- package/es/reducers/data/slides.d.ts +2 -3
- package/es/reducers/data/test/progression.test.js +12 -27
- package/es/reducers/index.d.ts +2 -1
- package/es/reducers/ui/answers.d.ts +2 -2
- package/es/reducers/ui/answers.js +4 -8
- package/es/reducers/ui/index.d.ts +4 -1
- package/es/reducers/ui/index.js +3 -1
- package/es/reducers/ui/slide.d.ts +8 -0
- package/es/reducers/ui/slide.js +26 -0
- package/es/reducers/ui/test/answers.test.js +23 -3
- package/es/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/es/reducers/ui/test/navigation.test.js +5 -5
- package/es/reducers/ui/test/slide.test.d.ts +1 -0
- package/es/reducers/ui/test/slide.test.js +12 -0
- package/es/test/util/services.mock.d.ts +3 -1
- package/es/test/util/services.mock.js +89 -72
- package/es/types/common.d.ts +0 -25
- 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 +13 -2
- package/es/views/slides/index.js +19 -15
- package/es/views/slides/map-api-slide-to-ui.js +65 -68
- package/es/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/es/views/slides/test/fixtures/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/template.d.ts +4 -0
- package/{lib/views/slides/test/fixtures/select-template.js → es/views/slides/test/fixtures/template.js} +82 -4
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +473 -0
- package/es/views/slides/test/map-api-slide-to-ui.test.js +4 -10
- package/es/views/slides/test/slide.template.on-change.test.d.ts +1 -0
- package/es/views/slides/test/slide.template.on-change.test.js +79 -0
- package/lib/actions/api/fetch-skills.d.ts +3 -3
- package/lib/actions/api/fetch-skills.js +22 -19
- package/lib/actions/api/fetch-slide.d.ts +1 -1
- package/lib/actions/api/fetch-slide.js +3 -1
- package/lib/actions/api/post-answer.d.ts +14 -0
- package/lib/actions/api/post-answer.js +75 -0
- package/lib/actions/api/post-progression.d.ts +3 -3
- package/lib/actions/api/post-progression.js +6 -3
- package/lib/actions/api/test/fetch-skills.test.js +7 -4
- package/lib/actions/api/test/fetch-slide.test.js +7 -4
- 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.js +7 -4
- 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/{api/test → test}/create-test-store.d.ts +2 -2
- package/lib/actions/{api/test → test}/create-test-store.js +1 -1
- package/lib/actions/ui/answers.d.ts +17 -3
- package/lib/actions/ui/answers.js +50 -3
- 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 +190 -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 +1 -3
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +3 -3
- package/lib/reducers/data/progression.js +2 -5
- package/lib/reducers/data/slides.d.ts +2 -3
- package/lib/reducers/data/test/progression.test.js +12 -27
- package/lib/reducers/index.d.ts +2 -1
- package/lib/reducers/ui/answers.d.ts +2 -2
- package/lib/reducers/ui/answers.js +4 -8
- package/lib/reducers/ui/index.d.ts +4 -1
- package/lib/reducers/ui/index.js +3 -1
- package/lib/reducers/ui/slide.d.ts +8 -0
- package/lib/reducers/ui/slide.js +27 -0
- package/lib/reducers/ui/test/answers.test.js +23 -3
- package/lib/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/lib/reducers/ui/test/navigation.test.js +5 -5
- package/lib/reducers/ui/test/slide.test.d.ts +1 -0
- package/lib/reducers/ui/test/slide.test.js +12 -0
- package/lib/test/util/services.mock.d.ts +3 -1
- package/lib/test/util/services.mock.js +89 -72
- package/lib/types/common.d.ts +0 -25
- 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 +13 -2
- package/lib/views/slides/index.js +19 -15
- package/lib/views/slides/map-api-slide-to-ui.js +106 -99
- package/lib/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/lib/views/slides/test/fixtures/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/template.d.ts +4 -0
- package/{es/views/slides/test/fixtures/select-template.js → lib/views/slides/test/fixtures/template.js} +82 -4
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +473 -0
- package/lib/views/slides/test/map-api-slide-to-ui.test.js +4 -10
- package/lib/views/slides/test/slide.template.on-change.test.d.ts +1 -0
- package/lib/views/slides/test/slide.template.on-change.test.js +82 -0
- package/package.json +6 -5
- package/src/actions/api/fetch-skills.ts +18 -11
- package/src/actions/api/fetch-slide.ts +3 -1
- package/src/actions/api/post-answer.ts +44 -0
- package/src/actions/api/post-progression.ts +7 -4
- package/src/actions/api/test/fetch-skills.test.ts +9 -6
- package/src/actions/api/test/fetch-slide.test.ts +9 -6
- package/src/actions/api/test/post-answer.test.ts +101 -0
- package/src/actions/api/test/post-progression.test.ts +9 -6
- package/src/actions/data/test/token.test.ts +29 -0
- package/src/actions/index.ts +1 -17
- package/src/actions/{api/test → test}/create-test-store.ts +2 -2
- package/src/actions/ui/answers.ts +55 -6
- package/src/actions/ui/slides.ts +1 -8
- package/src/actions/ui/test/answers.test.ts +115 -0
- package/src/actions/ui/test/slides.test.ts +30 -0
- package/src/common/index.ts +0 -7
- package/src/index.tsx +1 -3
- package/src/reducers/data/progression.ts +4 -7
- package/src/reducers/data/slides.ts +2 -3
- package/src/reducers/data/test/progression.test.ts +15 -31
- package/src/reducers/ui/answers.ts +5 -9
- package/src/reducers/ui/index.ts +4 -1
- package/src/reducers/ui/slide.ts +43 -0
- package/src/reducers/ui/test/answers.test.ts +29 -4
- package/src/reducers/ui/test/current-slide-ref.test.ts +1 -1
- package/src/reducers/ui/test/navigation.test.ts +5 -5
- package/src/reducers/ui/test/slide.test.ts +15 -0
- package/src/test/util/services.mock.ts +94 -73
- package/src/types/common.ts +0 -30
- package/src/views/skills/index.ts +1 -5
- package/src/views/skills/test/skills.test.ts +101 -0
- package/src/views/slides/index.ts +38 -23
- package/src/views/slides/map-api-slide-to-ui.ts +146 -113
- package/src/views/slides/test/fixtures/free-text.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-drag.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-graphic.ts +2 -1
- package/src/views/slides/test/fixtures/qcm.ts +2 -1
- package/src/views/slides/test/fixtures/slider.ts +2 -1
- package/src/views/slides/test/fixtures/{select-template.ts → template.ts} +84 -5
- package/src/views/slides/test/index.test.ts +493 -0
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +6 -11
- package/src/views/slides/test/slide.template.on-change.test.ts +92 -0
- 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/views/slides/test/fixtures/select-template.d.ts +0 -3
- package/es/views/slides/test/fixtures/text-template.d.ts +0 -3
- package/es/views/slides/test/fixtures/text-template.js +0 -58
- 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/views/slides/test/fixtures/select-template.d.ts +0 -3
- package/lib/views/slides/test/fixtures/text-template.d.ts +0 -3
- package/lib/views/slides/test/fixtures/text-template.js +0 -58
- package/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
- package/src/views/slides/test/fixtures/text-template.ts +0 -61
|
@@ -9,83 +9,100 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
import { qcmSlide } from '../../views/slides/test/fixtures/qcm';
|
|
13
|
+
import { qcmGraphicSlide } from '../../views/slides/test/fixtures/qcm-graphic';
|
|
12
14
|
import { freeTextSlide } from '../../views/slides/test/fixtures/free-text';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
import { sliderSlide } from '../../views/slides/test/fixtures/slider';
|
|
16
|
+
import { templateSlide } from '../../views/slides/test/fixtures/template';
|
|
17
|
+
var getSlideFixture = function (ref) {
|
|
18
|
+
switch (ref) {
|
|
19
|
+
case qcmSlide.universalRef:
|
|
20
|
+
return qcmSlide;
|
|
21
|
+
case qcmGraphicSlide.universalRef:
|
|
22
|
+
return qcmGraphicSlide;
|
|
23
|
+
case freeTextSlide.universalRef:
|
|
24
|
+
return freeTextSlide;
|
|
25
|
+
case templateSlide.universalRef:
|
|
26
|
+
return templateSlide;
|
|
27
|
+
default:
|
|
28
|
+
return sliderSlide;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var fetchSkillsResponse = [
|
|
32
|
+
{
|
|
33
|
+
skillRef: '_skill-ref',
|
|
34
|
+
slidesToReview: 2,
|
|
35
|
+
name: 'skill-test',
|
|
36
|
+
custom: false
|
|
29
37
|
},
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
{
|
|
39
|
+
skillRef: '_skill-ref-2',
|
|
40
|
+
slidesToReview: 2,
|
|
41
|
+
name: 'skill-test-2',
|
|
42
|
+
custom: true
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
export var postProgressionResponse = {
|
|
46
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
47
|
+
content: {
|
|
48
|
+
ref: '_skill-ref',
|
|
49
|
+
type: 'skill'
|
|
32
50
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
});
|
|
51
|
+
engine: {
|
|
52
|
+
ref: 'review'
|
|
53
|
+
},
|
|
54
|
+
state: {
|
|
55
|
+
allAnswers: [],
|
|
56
|
+
isCorrect: true,
|
|
57
|
+
nextContent: {
|
|
58
|
+
ref: 'sli_VJYjJnJhg',
|
|
59
|
+
type: 'slide'
|
|
60
|
+
},
|
|
61
|
+
pendingSlides: [],
|
|
62
|
+
slides: [],
|
|
63
|
+
step: {
|
|
64
|
+
current: 1
|
|
65
|
+
},
|
|
66
|
+
stars: 0
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export var postAnswerResponse = {
|
|
70
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
71
|
+
content: {
|
|
72
|
+
ref: '_skill-ref',
|
|
73
|
+
type: 'skill'
|
|
58
74
|
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
engine: {
|
|
67
|
-
ref: 'review'
|
|
68
|
-
},
|
|
69
|
-
state: {
|
|
70
|
-
allAnswers: [
|
|
71
|
-
{
|
|
72
|
-
slideRef: 'sli_N1XACJobn',
|
|
73
|
-
isCorrect: true,
|
|
74
|
-
answer: ['Le créateur peut fixer un pourcentage pour chaque transaction future']
|
|
75
|
-
}
|
|
76
|
-
],
|
|
75
|
+
engine: {
|
|
76
|
+
ref: 'review'
|
|
77
|
+
},
|
|
78
|
+
state: {
|
|
79
|
+
allAnswers: [
|
|
80
|
+
{
|
|
81
|
+
slideRef: 'sli_VJYjJnJhg',
|
|
77
82
|
isCorrect: true,
|
|
78
|
-
|
|
79
|
-
ref: 'sli_VkSQroQnx',
|
|
80
|
-
type: 'slide'
|
|
81
|
-
},
|
|
82
|
-
pendingSlides: [],
|
|
83
|
-
slides: ['sli_N1XACJobn'],
|
|
84
|
-
step: {
|
|
85
|
-
current: 2
|
|
86
|
-
},
|
|
87
|
-
stars: 4
|
|
83
|
+
answer: ['Benchmark']
|
|
88
84
|
}
|
|
89
|
-
|
|
85
|
+
],
|
|
86
|
+
isCorrect: true,
|
|
87
|
+
nextContent: {
|
|
88
|
+
ref: 'sli_VkSQroQnx',
|
|
89
|
+
type: 'slide'
|
|
90
|
+
},
|
|
91
|
+
content: {
|
|
92
|
+
ref: 'sli_VJYjJnJhg',
|
|
93
|
+
type: 'slide'
|
|
94
|
+
},
|
|
95
|
+
pendingSlides: [],
|
|
96
|
+
slides: ['sli_VJYjJnJhg'],
|
|
97
|
+
step: {
|
|
98
|
+
current: 2
|
|
99
|
+
},
|
|
100
|
+
stars: 4
|
|
90
101
|
}
|
|
91
102
|
};
|
|
103
|
+
export var services = {
|
|
104
|
+
fetchSkills: function () { return Promise.resolve(fetchSkillsResponse); },
|
|
105
|
+
fetchSlide: function (ref) { return Promise.resolve(__assign(__assign({}, getSlideFixture(ref)), { universalRef: ref, id: ref })); },
|
|
106
|
+
postProgression: function () { return Promise.resolve(postProgressionResponse); },
|
|
107
|
+
postAnswer: function () { return Promise.resolve(postAnswerResponse); }
|
|
108
|
+
};
|
package/lib/types/common.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { SlideIndexes } from '../common';
|
|
2
|
-
import { AnswerUI } from './slides';
|
|
3
1
|
declare type TemplateContextValues = {
|
|
4
2
|
brandTheme?: unknown;
|
|
5
3
|
theme?: unknown;
|
|
@@ -142,29 +140,6 @@ export declare type JWT = {
|
|
|
142
140
|
usage: string;
|
|
143
141
|
host: string;
|
|
144
142
|
};
|
|
145
|
-
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
146
|
-
export declare type NextUISlide = {
|
|
147
|
-
questionText?: string;
|
|
148
|
-
answerUI?: AnswerUI;
|
|
149
|
-
hidden?: boolean;
|
|
150
|
-
position?: number;
|
|
151
|
-
animationType?: SlideUIAnimations;
|
|
152
|
-
isCorrect?: boolean;
|
|
153
|
-
endReview?: boolean;
|
|
154
|
-
};
|
|
155
|
-
export declare type UISlide = {
|
|
156
|
-
questionText?: string;
|
|
157
|
-
answerUI?: AnswerUI;
|
|
158
|
-
hidden?: boolean;
|
|
159
|
-
position: number;
|
|
160
|
-
animationType?: SlideUIAnimations;
|
|
161
|
-
isCorrect?: boolean;
|
|
162
|
-
endReview?: boolean;
|
|
163
|
-
nextContent?: NextUISlide;
|
|
164
|
-
};
|
|
165
|
-
export declare type FinishedSlides = {
|
|
166
|
-
[key in SlideIndexes]?: true;
|
|
167
|
-
};
|
|
168
143
|
export declare type WithRequired<T, K extends keyof T> = T & {
|
|
169
144
|
[P in K]-?: T[P];
|
|
170
145
|
};
|
|
@@ -23,4 +23,4 @@ declare type SkillsProps = NoSkillsProps & {
|
|
|
23
23
|
listSkills: SkillCard[];
|
|
24
24
|
};
|
|
25
25
|
export { SkillsProps };
|
|
26
|
-
export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps
|
|
26
|
+
export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import map from 'lodash/fp/map';
|
|
3
|
+
import omit from 'lodash/fp/omit';
|
|
4
|
+
import { mapStateToSkillsProps } from '..';
|
|
5
|
+
test('should create initial props when there are no skills on the state', function (t) {
|
|
6
|
+
var state = {
|
|
7
|
+
data: {
|
|
8
|
+
progression: null,
|
|
9
|
+
skills: [],
|
|
10
|
+
slides: {},
|
|
11
|
+
token: '1234'
|
|
12
|
+
},
|
|
13
|
+
ui: {
|
|
14
|
+
currentSlideRef: '',
|
|
15
|
+
navigation: ['loader', 'skills'],
|
|
16
|
+
answers: [],
|
|
17
|
+
slide: {
|
|
18
|
+
validateButton: false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var props = mapStateToSkillsProps(state);
|
|
23
|
+
t.deepEqual(props, {
|
|
24
|
+
title: '@todo title',
|
|
25
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
26
|
+
textNoSkills: '@todo textNoSkills',
|
|
27
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
28
|
+
isLoading: false,
|
|
29
|
+
isLoadingAriaLabel: '@todo loading',
|
|
30
|
+
listSkills: []
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
test('should create initial props when skills on the state', function (t) {
|
|
34
|
+
var state = {
|
|
35
|
+
data: {
|
|
36
|
+
progression: null,
|
|
37
|
+
skills: [
|
|
38
|
+
{
|
|
39
|
+
skillRef: '_skill-ref',
|
|
40
|
+
slidesToReview: 2,
|
|
41
|
+
name: 'skill-test',
|
|
42
|
+
custom: false
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
skillRef: '_skill-ref-2',
|
|
46
|
+
slidesToReview: 5,
|
|
47
|
+
name: 'skill-test-2',
|
|
48
|
+
custom: true
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
slides: {},
|
|
52
|
+
token: '1234'
|
|
53
|
+
},
|
|
54
|
+
ui: {
|
|
55
|
+
currentSlideRef: '',
|
|
56
|
+
navigation: ['loader', 'skills'],
|
|
57
|
+
answers: [],
|
|
58
|
+
slide: {
|
|
59
|
+
validateButton: false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var props = mapStateToSkillsProps(state);
|
|
64
|
+
t.deepEqual(omit('listSkills', props), {
|
|
65
|
+
title: '@todo title',
|
|
66
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
67
|
+
textNoSkills: '@todo textNoSkills',
|
|
68
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
69
|
+
isLoading: false,
|
|
70
|
+
isLoadingAriaLabel: '@todo loading'
|
|
71
|
+
});
|
|
72
|
+
t.deepEqual(map(omit('onClick'), props.listSkills), [
|
|
73
|
+
{
|
|
74
|
+
'aria-label': '',
|
|
75
|
+
isCustom: false,
|
|
76
|
+
skillTitle: 'skill-test',
|
|
77
|
+
skillAriaLabel: '@todo skill aria label',
|
|
78
|
+
buttonLabel: '@todo button',
|
|
79
|
+
buttonAriaLabel: '@todo button aria label',
|
|
80
|
+
reviseLabel: '@todo revise',
|
|
81
|
+
reviseAriaLabel: '@todo revise aria label'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
'aria-label': '',
|
|
85
|
+
isCustom: true,
|
|
86
|
+
skillTitle: 'skill-test-2',
|
|
87
|
+
skillAriaLabel: '@todo skill aria label',
|
|
88
|
+
buttonLabel: '@todo button',
|
|
89
|
+
buttonAriaLabel: '@todo button aria label',
|
|
90
|
+
reviseLabel: '@todo revise',
|
|
91
|
+
reviseAriaLabel: '@todo revise aria label'
|
|
92
|
+
}
|
|
93
|
+
]);
|
|
94
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
|
-
import { UISlide } from '../../types/common';
|
|
3
2
|
import { SlideIndexes } from '../../common';
|
|
4
3
|
import { StoreState } from '../../reducers';
|
|
4
|
+
import { AnswerUI } from '../../types/slides';
|
|
5
5
|
declare const ICON_VALUES: {
|
|
6
6
|
readonly right: "right";
|
|
7
7
|
readonly wrong: "wrong";
|
|
@@ -13,6 +13,17 @@ declare type StepItem = {
|
|
|
13
13
|
icon: IconValue;
|
|
14
14
|
value: string;
|
|
15
15
|
};
|
|
16
|
+
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
17
|
+
export declare type UISlide = {
|
|
18
|
+
questionText?: string;
|
|
19
|
+
answerUI?: AnswerUI;
|
|
20
|
+
hidden?: boolean;
|
|
21
|
+
position: number;
|
|
22
|
+
animationType?: SlideUIAnimations;
|
|
23
|
+
isCorrect?: boolean;
|
|
24
|
+
endReview?: boolean;
|
|
25
|
+
loading: boolean;
|
|
26
|
+
};
|
|
16
27
|
declare type SlidesStack = {
|
|
17
28
|
[key in SlideIndexes]: UISlide;
|
|
18
29
|
};
|
|
@@ -75,5 +86,5 @@ export declare type SlidesViewProps = {
|
|
|
75
86
|
};
|
|
76
87
|
};
|
|
77
88
|
export declare const initialState: SlidesStack;
|
|
78
|
-
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch) => SlidesViewProps
|
|
89
|
+
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch) => SlidesViewProps;
|
|
79
90
|
export {};
|
|
@@ -18,6 +18,7 @@ import reduce from 'lodash/fp/reduce';
|
|
|
18
18
|
import set from 'lodash/fp/set';
|
|
19
19
|
import slice from 'lodash/fp/slice';
|
|
20
20
|
import toInteger from 'lodash/fp/toInteger';
|
|
21
|
+
import { postAnswer } from '../../actions/api/post-answer';
|
|
21
22
|
import { mapApiSlideToUi } from './map-api-slide-to-ui';
|
|
22
23
|
var ICON_VALUES = {
|
|
23
24
|
right: 'right',
|
|
@@ -27,29 +28,34 @@ var ICON_VALUES = {
|
|
|
27
28
|
export var initialState = {
|
|
28
29
|
'0': {
|
|
29
30
|
hidden: false,
|
|
30
|
-
position: 0
|
|
31
|
+
position: 0,
|
|
32
|
+
loading: true
|
|
31
33
|
},
|
|
32
34
|
'1': {
|
|
33
35
|
hidden: false,
|
|
34
|
-
position: 1
|
|
36
|
+
position: 1,
|
|
37
|
+
loading: true
|
|
35
38
|
},
|
|
36
39
|
'2': {
|
|
37
40
|
hidden: false,
|
|
38
|
-
position: 2
|
|
41
|
+
position: 2,
|
|
42
|
+
loading: true
|
|
39
43
|
},
|
|
40
44
|
'3': {
|
|
41
45
|
hidden: false,
|
|
42
|
-
position: 3
|
|
46
|
+
position: 3,
|
|
47
|
+
loading: true
|
|
43
48
|
},
|
|
44
49
|
'4': {
|
|
45
50
|
hidden: false,
|
|
46
|
-
position: 4
|
|
51
|
+
position: 4,
|
|
52
|
+
loading: true
|
|
47
53
|
}
|
|
48
54
|
};
|
|
49
|
-
var
|
|
55
|
+
var getProgressionSlidesRefs = function (progression) {
|
|
50
56
|
if (progression.state.step.current < 5) {
|
|
51
57
|
var slideRef = progression.state.nextContent.ref;
|
|
52
|
-
return concat(
|
|
58
|
+
return concat(progression.state.slides, [slideRef]);
|
|
53
59
|
}
|
|
54
60
|
return slice(0, 5, progression.state.slides);
|
|
55
61
|
};
|
|
@@ -58,18 +64,20 @@ var buildStackSlides = function (state, dispatch) {
|
|
|
58
64
|
var progression = state.data.progression;
|
|
59
65
|
if (!currentSlideRef || !progression)
|
|
60
66
|
return initialState;
|
|
61
|
-
var slideRefs =
|
|
67
|
+
var slideRefs = getProgressionSlidesRefs(progression);
|
|
62
68
|
// @ts-expect-error typescript does not support capped versions of lodash functions
|
|
63
69
|
var stack = reduce.convert({ cap: false })(function (acc, uiSlide, index) {
|
|
64
70
|
var slideRef = slideRefs[toInteger(index)];
|
|
65
71
|
if (!slideRef)
|
|
66
72
|
return set(index, uiSlide, acc);
|
|
67
73
|
var slideFromAPI = get(slideRef, state.data.slides);
|
|
74
|
+
if (!slideFromAPI)
|
|
75
|
+
return set(index, uiSlide, acc);
|
|
68
76
|
var answers = state.ui.answers;
|
|
69
77
|
var _a = mapApiSlideToUi(dispatch)(slideFromAPI, answers), questionText = _a.questionText, answerUI = _a.answerUI;
|
|
70
78
|
var parentContentTitle = getOr('', 'parentContentTitle.title', slideFromAPI);
|
|
71
79
|
var parentContentType = getOr('', 'parentContentTitle.type', slideFromAPI);
|
|
72
|
-
var updatedUiSlide = pipe(set(
|
|
80
|
+
var updatedUiSlide = pipe(set('loading', false), set('questionText', questionText), set('answerUI', answerUI), set('parentContentTitle', "From \"".concat(parentContentTitle, "\" ").concat(parentContentType)) // TODO translate: -From- .... -Course/chapter-
|
|
73
81
|
// TODO: Set position according to currentSlideRef et slideRefs (or maybe a value on the state ui.slidePositions !!)
|
|
74
82
|
)(uiSlide);
|
|
75
83
|
return set(index, updatedUiSlide, acc);
|
|
@@ -122,9 +130,6 @@ var buildStepItems = function (state) {
|
|
|
122
130
|
return steps;
|
|
123
131
|
};
|
|
124
132
|
export var mapStateToSlidesProps = function (state, dispatch) {
|
|
125
|
-
if (!state.data.slides) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
133
|
return {
|
|
129
134
|
header: {
|
|
130
135
|
mode: '__revision_mode',
|
|
@@ -141,10 +146,9 @@ export var mapStateToSlidesProps = function (state, dispatch) {
|
|
|
141
146
|
slides: buildStackSlides(state, dispatch),
|
|
142
147
|
validateButton: {
|
|
143
148
|
label: '__validate',
|
|
144
|
-
disabled:
|
|
149
|
+
disabled: !get('ui.slide.validateButton', state),
|
|
145
150
|
onClick: function () {
|
|
146
|
-
|
|
147
|
-
console.log('TODO: validate question');
|
|
151
|
+
dispatch(postAnswer);
|
|
148
152
|
}
|
|
149
153
|
},
|
|
150
154
|
correctionPopinProps: undefined,
|