@coorpacademy/app-review 0.1.16 → 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 +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 +10 -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 +39 -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 +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 +1 -3
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +2 -3
- package/es/reducers/data/progression.js +0 -5
- package/es/reducers/data/slides.d.ts +2 -3
- package/es/reducers/data/test/progression.test.js +1 -1
- 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 +19 -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 +2 -1
- package/es/test/util/services.mock.js +86 -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 +18 -14
- package/es/views/slides/map-api-slide-to-ui.js +44 -51
- 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/select-template.d.ts +2 -1
- package/es/views/slides/test/fixtures/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/text-template.d.ts +2 -1
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +234 -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 +10 -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 +48 -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 +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 +1 -3
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +2 -3
- package/lib/reducers/data/progression.js +0 -5
- package/lib/reducers/data/slides.d.ts +2 -3
- package/lib/reducers/data/test/progression.test.js +1 -1
- 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 +19 -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 +2 -1
- package/lib/test/util/services.mock.js +86 -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 +18 -14
- package/lib/views/slides/map-api-slide-to-ui.js +77 -76
- 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/select-template.d.ts +2 -1
- package/lib/views/slides/test/fixtures/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/text-template.d.ts +2 -1
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +234 -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 +39 -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 +52 -5
- 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 +1 -3
- package/src/reducers/data/progression.ts +2 -7
- package/src/reducers/data/slides.ts +2 -3
- package/src/reducers/data/test/progression.test.ts +3 -3
- 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 +24 -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 +91 -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 +37 -22
- package/src/views/slides/map-api-slide-to-ui.ts +89 -89
- 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/select-template.ts +2 -1
- package/src/views/slides/test/fixtures/slider.ts +2 -1
- package/src/views/slides/test/fixtures/text-template.ts +2 -1
- package/src/views/slides/test/index.test.ts +240 -0
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +2 -1
- 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/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/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
|
@@ -9,83 +9,97 @@ 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
|
+
var getSlideFixture = function (ref) {
|
|
17
|
+
switch (ref) {
|
|
18
|
+
case qcmSlide.universalRef:
|
|
19
|
+
return qcmSlide;
|
|
20
|
+
case qcmGraphicSlide.universalRef:
|
|
21
|
+
return qcmGraphicSlide;
|
|
22
|
+
case freeTextSlide.universalRef:
|
|
23
|
+
return freeTextSlide;
|
|
24
|
+
default:
|
|
25
|
+
return sliderSlide;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var fetchSkillsResponse = [
|
|
29
|
+
{
|
|
30
|
+
skillRef: '_skill-ref',
|
|
31
|
+
slidesToReview: 2,
|
|
32
|
+
name: 'skill-test',
|
|
33
|
+
custom: false
|
|
29
34
|
},
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
{
|
|
36
|
+
skillRef: '_skill-ref-2',
|
|
37
|
+
slidesToReview: 2,
|
|
38
|
+
name: 'skill-test-2',
|
|
39
|
+
custom: true
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
var postProgressionResponse = {
|
|
43
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
44
|
+
content: {
|
|
45
|
+
ref: '_skill-ref',
|
|
46
|
+
type: 'skill'
|
|
32
47
|
},
|
|
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
|
-
});
|
|
48
|
+
engine: {
|
|
49
|
+
ref: 'review'
|
|
50
|
+
},
|
|
51
|
+
state: {
|
|
52
|
+
allAnswers: [],
|
|
53
|
+
isCorrect: true,
|
|
54
|
+
nextContent: {
|
|
55
|
+
ref: 'sli_VJYjJnJhg',
|
|
56
|
+
type: 'slide'
|
|
57
|
+
},
|
|
58
|
+
pendingSlides: [],
|
|
59
|
+
slides: [],
|
|
60
|
+
step: {
|
|
61
|
+
current: 1
|
|
62
|
+
},
|
|
63
|
+
stars: 0
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
export var postAnswerResponse = {
|
|
67
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
68
|
+
content: {
|
|
69
|
+
ref: '_skill-ref',
|
|
70
|
+
type: 'skill'
|
|
58
71
|
},
|
|
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
|
-
],
|
|
72
|
+
engine: {
|
|
73
|
+
ref: 'review'
|
|
74
|
+
},
|
|
75
|
+
state: {
|
|
76
|
+
allAnswers: [
|
|
77
|
+
{
|
|
78
|
+
slideRef: 'sli_VJYjJnJhg',
|
|
77
79
|
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
|
|
80
|
+
answer: ['Benchmark']
|
|
88
81
|
}
|
|
89
|
-
|
|
82
|
+
],
|
|
83
|
+
isCorrect: true,
|
|
84
|
+
nextContent: {
|
|
85
|
+
ref: 'sli_VkSQroQnx',
|
|
86
|
+
type: 'slide'
|
|
87
|
+
},
|
|
88
|
+
content: {
|
|
89
|
+
ref: 'sli_VJYjJnJhg',
|
|
90
|
+
type: 'slide'
|
|
91
|
+
},
|
|
92
|
+
pendingSlides: [],
|
|
93
|
+
slides: ['sli_VJYjJnJhg'],
|
|
94
|
+
step: {
|
|
95
|
+
current: 2
|
|
96
|
+
},
|
|
97
|
+
stars: 4
|
|
90
98
|
}
|
|
91
99
|
};
|
|
100
|
+
export var services = {
|
|
101
|
+
fetchSkills: function () { return Promise.resolve(fetchSkillsResponse); },
|
|
102
|
+
fetchSlide: function (ref) { return Promise.resolve(__assign(__assign({}, getSlideFixture(ref)), { universalRef: ref, id: ref })); },
|
|
103
|
+
postProgression: function () { return Promise.resolve(postProgressionResponse); },
|
|
104
|
+
postAnswer: function () { return Promise.resolve(postAnswerResponse); }
|
|
105
|
+
};
|
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,26 +28,31 @@ 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
58
|
return concat([slideRef], progression.state.slides);
|
|
@@ -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,
|
|
@@ -1,57 +1,58 @@
|
|
|
1
|
-
import { concat, divide, get, getOr, head, includes, indexOf, isEmpty, map, rangeStep, size, toInteger } from 'lodash/fp';
|
|
1
|
+
import { concat, divide, get, getOr, head, includes, indexOf, isEmpty, map, multiply, pipe, rangeStep, round, size, toInteger, toString as _toString, __ } from 'lodash/fp';
|
|
2
2
|
import { editAnswer } from '../../actions/ui/answers';
|
|
3
|
-
var qcmProps = function (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
var qcmProps = function (dispatch) {
|
|
4
|
+
return function (answers, question) {
|
|
5
|
+
return {
|
|
6
|
+
type: 'qcm',
|
|
7
|
+
answers: map(function (choice) {
|
|
8
|
+
var label = choice.label || '';
|
|
9
|
+
return {
|
|
10
|
+
title: label,
|
|
11
|
+
selected: includes(label, answers),
|
|
12
|
+
onClick: function () {
|
|
13
|
+
dispatch(editAnswer(label));
|
|
14
|
+
},
|
|
15
|
+
ariaLabel: choice.label
|
|
16
|
+
};
|
|
17
|
+
}, question.content.choices)
|
|
18
|
+
};
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
|
-
var qcmDragProps = function (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
21
|
+
var qcmDragProps = function (dispatch) {
|
|
22
|
+
return function (answers, question) {
|
|
23
|
+
return {
|
|
24
|
+
type: 'qcmDrag',
|
|
25
|
+
answers: map(function (choice) {
|
|
26
|
+
var label = choice.label || '';
|
|
27
|
+
var indexInAnswer = indexOf(label, answers);
|
|
28
|
+
return {
|
|
29
|
+
title: label,
|
|
30
|
+
selected: includes(label, answers),
|
|
31
|
+
order: indexInAnswer,
|
|
32
|
+
onClick: function () {
|
|
33
|
+
dispatch(editAnswer(label));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, question.content.choices)
|
|
37
|
+
};
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
|
-
var qcmGraphicProps = function (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
var qcmGraphicProps = function (dispatch) {
|
|
41
|
+
return function (answers, question) {
|
|
42
|
+
return {
|
|
43
|
+
type: 'qcmGraphic',
|
|
44
|
+
answers: map(function (choice) {
|
|
45
|
+
var label = choice.label || '';
|
|
46
|
+
return {
|
|
47
|
+
title: label,
|
|
48
|
+
image: get('media.src.0.url', choice),
|
|
49
|
+
selected: includes(label, answers),
|
|
50
|
+
onClick: function () {
|
|
51
|
+
dispatch(editAnswer(label));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, question.content.choices)
|
|
55
|
+
};
|
|
55
56
|
};
|
|
56
57
|
};
|
|
57
58
|
var templateTextProps = function (choice, index) {
|
|
@@ -113,34 +114,34 @@ var basicProps = function (dispatch) {
|
|
|
113
114
|
placeholder: question.content.placeholder || '',
|
|
114
115
|
value: answers[0] || '',
|
|
115
116
|
onChange: function (text) {
|
|
116
|
-
// eslint-disable-next-line no-console
|
|
117
|
-
console.log(text);
|
|
118
117
|
dispatch(editAnswer(text));
|
|
119
118
|
}
|
|
120
119
|
};
|
|
121
120
|
};
|
|
122
121
|
};
|
|
123
|
-
var sliderProps = function (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
122
|
+
var sliderProps = function (dispatch) {
|
|
123
|
+
return function (answers, question) {
|
|
124
|
+
var values = rangeStep(getOr(1, 'content.step', question), get('content.min', question), get('content.max', question) + 1
|
|
125
|
+
// Lodash doesn't infer the type very well here
|
|
126
|
+
);
|
|
127
|
+
var stateValue = head(answers) || question.content.min;
|
|
128
|
+
var currentValue = toInteger(stateValue);
|
|
129
|
+
var indexValue = indexOf(currentValue, values);
|
|
130
|
+
var maxValue = size(values) - 1;
|
|
131
|
+
var sliderPosition = divide(indexValue, maxValue);
|
|
132
|
+
var unitLabel = get('content.unitLabel', question);
|
|
133
|
+
return {
|
|
134
|
+
type: 'slider',
|
|
135
|
+
placeholder: question.explanation,
|
|
136
|
+
minLabel: "".concat(question.content.min, " ").concat(unitLabel),
|
|
137
|
+
maxLabel: "".concat(question.content.max, " ").concat(unitLabel),
|
|
138
|
+
title: "".concat(currentValue, " ").concat(question.content.unitLabel),
|
|
139
|
+
value: sliderPosition,
|
|
140
|
+
onChange: function (position) {
|
|
141
|
+
var newValue = pipe(multiply(maxValue), round, get(__, values), _toString)(position);
|
|
142
|
+
dispatch(editAnswer(newValue));
|
|
143
|
+
}
|
|
144
|
+
};
|
|
144
145
|
};
|
|
145
146
|
};
|
|
146
147
|
export var getQuestionType = function (question) { return question.type; };
|
|
@@ -149,17 +150,17 @@ var getAnswerUIModel = function (question, answers, dispatch) {
|
|
|
149
150
|
var type = getQuestionType(question);
|
|
150
151
|
switch (type) {
|
|
151
152
|
case 'qcm':
|
|
152
|
-
return qcmProps(question);
|
|
153
|
+
return qcmProps(dispatch)(answers, question);
|
|
153
154
|
case 'qcmGraphic':
|
|
154
|
-
return qcmGraphicProps(question);
|
|
155
|
+
return qcmGraphicProps(dispatch)(answers, question);
|
|
155
156
|
case 'qcmDrag':
|
|
156
|
-
return qcmDragProps(question);
|
|
157
|
+
return qcmDragProps(dispatch)(answers, question);
|
|
157
158
|
case 'basic':
|
|
158
159
|
return basicProps(dispatch)(answers, question);
|
|
159
160
|
case 'template':
|
|
160
161
|
return templateProps(question);
|
|
161
162
|
case 'slider':
|
|
162
|
-
return sliderProps(question);
|
|
163
|
+
return sliderProps(dispatch)(answers, question);
|
|
163
164
|
default:
|
|
164
165
|
throw new Error("".concat(type, " is not an handled question.type"));
|
|
165
166
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UISlide } from '../..';
|
|
2
|
+
import { SlideFromAPI } from '../../../../types/common';
|
|
2
3
|
export declare const qcmGraphicSlide: SlideFromAPI;
|
|
3
4
|
export declare const qcmGraphicUISlide: Partial<UISlide>;
|