@coorpacademy/app-review 0.1.13 → 0.1.15
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-slide.d.ts +3 -3
- package/es/actions/api/fetch-slide.js +22 -2
- package/es/actions/api/post-progression.js +1 -2
- package/es/actions/index.d.ts +1 -10
- package/es/actions/ui/is-fetching.js +0 -2
- package/es/actions/ui/slides.d.ts +26 -0
- package/es/actions/ui/slides.js +9 -0
- package/es/common/index.d.ts +3 -1
- package/es/common/index.js +3 -1
- package/es/fixtures/qcm-slide.d.ts +2 -2
- package/es/fixtures/temp-fixture.d.ts +2 -2
- package/es/helpers/map-api-slide-to-ui.d.ts +4 -1
- package/es/helpers/map-api-slide-to-ui.js +33 -15
- package/es/helpers/test/fixtures/free-text.d.ts +2 -3
- package/es/helpers/test/fixtures/free-text.js +10 -4
- package/es/helpers/test/fixtures/qcm-drag.d.ts +2 -3
- package/es/helpers/test/fixtures/qcm-drag.js +38 -32
- package/es/helpers/test/fixtures/qcm-graphic.d.ts +2 -3
- package/es/helpers/test/fixtures/qcm-graphic.js +20 -14
- package/es/helpers/test/fixtures/qcm.d.ts +2 -3
- package/es/helpers/test/fixtures/qcm.js +32 -26
- package/es/helpers/test/fixtures/select-template.d.ts +2 -3
- package/es/helpers/test/fixtures/select-template.js +38 -32
- package/es/helpers/test/fixtures/slider.d.ts +2 -3
- package/es/helpers/test/fixtures/slider.js +13 -7
- package/es/helpers/test/fixtures/text-template.d.ts +2 -3
- package/es/helpers/test/fixtures/text-template.js +16 -10
- package/es/index.js +14 -78
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +3 -16
- package/es/reducers/data/progression.js +3 -22
- package/es/reducers/data/slides.d.ts +5 -6
- package/es/reducers/data/slides.js +4 -107
- package/es/reducers/index.d.ts +3 -4
- package/es/reducers/ui/current-slide-ref.d.ts +4 -0
- package/es/reducers/ui/{review-status.js → current-slide-ref.js} +4 -4
- package/es/reducers/ui/index.d.ts +7 -10
- package/es/reducers/ui/index.js +4 -6
- package/es/reducers/ui/slides.d.ts +9 -0
- package/es/reducers/ui/slides.js +42 -0
- package/es/services/test/post-progression.test.js +6 -4
- package/es/test/util/services.mock.js +17 -5
- package/es/types/common.d.ts +40 -23
- package/es/types/common.js +0 -5
- package/es/types/slides.d.ts +0 -4
- package/es/types/views/slides.d.ts +41 -27
- package/es/types/views/slides.js +5 -0
- package/{lib/types/views/skills.d.ts → es/views/skills/index.d.ts} +2 -0
- package/es/views/skills/index.js +25 -0
- package/es/views/slides/index.d.ts +3 -0
- package/es/views/slides/index.js +85 -0
- package/lib/actions/api/fetch-slide.d.ts +3 -3
- package/lib/actions/api/fetch-slide.js +20 -2
- package/lib/actions/api/post-progression.js +1 -2
- package/lib/actions/index.d.ts +1 -10
- package/lib/actions/ui/is-fetching.js +0 -2
- package/lib/actions/ui/slides.d.ts +26 -0
- package/lib/actions/ui/slides.js +9 -0
- package/lib/common/index.d.ts +3 -1
- package/lib/common/index.js +3 -1
- package/lib/fixtures/qcm-slide.d.ts +2 -2
- package/lib/fixtures/temp-fixture.d.ts +2 -2
- package/lib/helpers/map-api-slide-to-ui.d.ts +4 -1
- package/lib/helpers/map-api-slide-to-ui.js +34 -14
- package/lib/helpers/test/fixtures/free-text.d.ts +2 -3
- package/lib/helpers/test/fixtures/free-text.js +10 -4
- package/lib/helpers/test/fixtures/qcm-drag.d.ts +2 -3
- package/lib/helpers/test/fixtures/qcm-drag.js +38 -32
- package/lib/helpers/test/fixtures/qcm-graphic.d.ts +2 -3
- package/lib/helpers/test/fixtures/qcm-graphic.js +20 -14
- package/lib/helpers/test/fixtures/qcm.d.ts +2 -3
- package/lib/helpers/test/fixtures/qcm.js +32 -26
- package/lib/helpers/test/fixtures/select-template.d.ts +2 -3
- package/lib/helpers/test/fixtures/select-template.js +38 -32
- package/lib/helpers/test/fixtures/slider.d.ts +2 -3
- package/lib/helpers/test/fixtures/slider.js +13 -7
- package/lib/helpers/test/fixtures/text-template.d.ts +2 -3
- package/lib/helpers/test/fixtures/text-template.js +16 -10
- package/lib/index.js +14 -78
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +3 -16
- package/lib/reducers/data/progression.js +3 -22
- package/lib/reducers/data/slides.d.ts +5 -6
- package/lib/reducers/data/slides.js +4 -113
- package/lib/reducers/index.d.ts +3 -4
- package/lib/reducers/ui/current-slide-ref.d.ts +4 -0
- package/lib/reducers/ui/{review-status.js → current-slide-ref.js} +4 -4
- package/lib/reducers/ui/index.d.ts +7 -10
- package/lib/reducers/ui/index.js +4 -6
- package/lib/reducers/ui/slides.d.ts +9 -0
- package/lib/reducers/ui/slides.js +43 -0
- package/lib/services/test/post-progression.test.js +6 -4
- package/lib/test/util/services.mock.js +17 -5
- package/lib/types/common.d.ts +40 -23
- package/lib/types/common.js +0 -5
- package/lib/types/slides.d.ts +0 -4
- package/lib/types/views/slides.d.ts +41 -27
- package/lib/types/views/slides.js +5 -0
- package/{es/types/views/skills.d.ts → lib/views/skills/index.d.ts} +2 -0
- package/lib/views/skills/index.js +25 -0
- package/lib/views/slides/index.d.ts +3 -0
- package/lib/views/slides/index.js +89 -0
- package/package.json +3 -3
- package/src/actions/api/fetch-slide.ts +26 -5
- package/src/actions/api/post-progression.ts +1 -2
- package/src/actions/index.ts +1 -10
- package/src/actions/ui/is-fetching.ts +0 -6
- package/src/actions/ui/slides.ts +35 -0
- package/src/common/index.ts +7 -1
- package/src/fixtures/qcm-slide.ts +2 -2
- package/src/fixtures/temp-fixture.ts +2 -2
- package/src/helpers/map-api-slide-to-ui.ts +43 -17
- package/src/helpers/test/fixtures/free-text.ts +12 -7
- package/src/helpers/test/fixtures/qcm-drag.ts +40 -35
- package/src/helpers/test/fixtures/qcm-graphic.ts +22 -17
- package/src/helpers/test/fixtures/qcm.ts +38 -32
- package/src/helpers/test/fixtures/select-template.ts +40 -35
- package/src/helpers/test/fixtures/slider.ts +15 -10
- package/src/helpers/test/fixtures/text-template.ts +18 -13
- package/src/helpers/test/map-api-slide-to-ui.test.ts +2 -11
- package/src/index.tsx +15 -84
- package/src/reducers/data/progression.ts +5 -40
- package/src/reducers/data/slides.ts +9 -126
- package/src/reducers/ui/current-slide-ref.ts +19 -0
- package/src/reducers/ui/index.ts +6 -9
- package/src/reducers/ui/slides.ts +58 -0
- package/src/services/test/post-progression.test.ts +6 -4
- package/src/test/util/services.mock.ts +17 -5
- package/src/types/common.ts +44 -27
- package/src/types/slides.ts +0 -5
- package/src/types/views/slides.ts +52 -27
- package/src/views/skills/index.ts +56 -0
- package/src/views/slides/index.ts +92 -0
- package/es/actions/data/slides.d.ts +0 -37
- package/es/actions/data/slides.js +0 -16
- package/es/actions/ui/finished-slides.d.ts +0 -10
- package/es/actions/ui/finished-slides.js +0 -8
- package/es/actions/ui/review-status.d.ts +0 -7
- package/es/actions/ui/review-status.js +0 -7
- package/es/actions/ui/step-items.d.ts +0 -24
- package/es/actions/ui/step-items.js +0 -11
- package/es/reducers/ui/finished-slides.d.ts +0 -7
- package/es/reducers/ui/finished-slides.js +0 -33
- package/es/reducers/ui/review-status.d.ts +0 -4
- package/es/reducers/ui/step-items.d.ts +0 -14
- package/es/reducers/ui/step-items.js +0 -74
- package/es/types/ui-progression.d.ts +0 -10
- package/es/types/ui-progression.js +0 -1
- package/es/types/views/skills.js +0 -1
- package/lib/actions/data/slides.d.ts +0 -37
- package/lib/actions/data/slides.js +0 -16
- package/lib/actions/ui/finished-slides.d.ts +0 -10
- package/lib/actions/ui/finished-slides.js +0 -8
- package/lib/actions/ui/review-status.d.ts +0 -7
- package/lib/actions/ui/review-status.js +0 -7
- package/lib/actions/ui/step-items.d.ts +0 -24
- package/lib/actions/ui/step-items.js +0 -11
- package/lib/reducers/ui/finished-slides.d.ts +0 -7
- package/lib/reducers/ui/finished-slides.js +0 -45
- package/lib/reducers/ui/review-status.d.ts +0 -4
- package/lib/reducers/ui/step-items.d.ts +0 -14
- package/lib/reducers/ui/step-items.js +0 -86
- package/lib/types/ui-progression.d.ts +0 -10
- package/lib/types/ui-progression.js +0 -1
- package/lib/types/views/skills.js +0 -1
- package/src/actions/data/slides.ts +0 -65
- package/src/actions/ui/finished-slides.ts +0 -21
- package/src/actions/ui/review-status.ts +0 -19
- package/src/actions/ui/step-items.ts +0 -45
- package/src/reducers/ui/finished-slides.ts +0 -52
- package/src/reducers/ui/review-status.ts +0 -19
- package/src/reducers/ui/step-items.ts +0 -116
- package/src/types/ui-progression.ts +0 -25
- package/src/types/views/skills.ts +0 -27
package/es/types/common.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SlideIndexes } from '../common';
|
|
2
|
+
import { AnswerUI } from './slides';
|
|
2
3
|
declare type TemplateContextValues = {
|
|
3
4
|
brandTheme?: unknown;
|
|
4
5
|
theme?: unknown;
|
|
@@ -68,21 +69,33 @@ export declare type SlideFromAPI = {
|
|
|
68
69
|
tips?: string;
|
|
69
70
|
clue?: string;
|
|
70
71
|
hasClue?: boolean;
|
|
71
|
-
id
|
|
72
|
+
id: string;
|
|
73
|
+
};
|
|
74
|
+
declare type ProgressionAnswerItem = {
|
|
75
|
+
isCorrect: boolean;
|
|
76
|
+
slideRef: string;
|
|
77
|
+
answer: string[];
|
|
78
|
+
};
|
|
79
|
+
export declare type ProgressionState = {
|
|
80
|
+
allAnswers: ProgressionAnswerItem[];
|
|
81
|
+
content?: {
|
|
82
|
+
ref: string;
|
|
83
|
+
type: string;
|
|
84
|
+
};
|
|
85
|
+
isCorrect: boolean;
|
|
86
|
+
nextContent: {
|
|
87
|
+
type: 'success' | 'slide';
|
|
88
|
+
ref: 'successExitNode' | string;
|
|
89
|
+
};
|
|
90
|
+
pendingSlides: string[];
|
|
91
|
+
slides: string[];
|
|
92
|
+
step: {
|
|
93
|
+
current: number;
|
|
94
|
+
};
|
|
72
95
|
};
|
|
73
96
|
export declare type ProgressionFromAPI = {
|
|
74
97
|
_id: string;
|
|
75
|
-
state:
|
|
76
|
-
isCorrect: boolean;
|
|
77
|
-
step: {
|
|
78
|
-
current: number;
|
|
79
|
-
};
|
|
80
|
-
nextContent: {
|
|
81
|
-
type: 'success' | 'slide';
|
|
82
|
-
ref: 'successExitNode' | string;
|
|
83
|
-
};
|
|
84
|
-
pendingSlides: [];
|
|
85
|
-
};
|
|
98
|
+
state: ProgressionState;
|
|
86
99
|
};
|
|
87
100
|
export declare type Skill = {
|
|
88
101
|
skillRef: string;
|
|
@@ -116,23 +129,27 @@ export declare type JWT = {
|
|
|
116
129
|
host: string;
|
|
117
130
|
};
|
|
118
131
|
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
119
|
-
export declare type
|
|
132
|
+
export declare type NextUISlide = {
|
|
133
|
+
questionText?: string;
|
|
134
|
+
answerUI?: AnswerUI;
|
|
120
135
|
hidden?: boolean;
|
|
121
|
-
position
|
|
136
|
+
position?: number;
|
|
122
137
|
animationType?: SlideUIAnimations;
|
|
123
138
|
isCorrect?: boolean;
|
|
124
139
|
endReview?: boolean;
|
|
125
|
-
nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
|
|
126
140
|
};
|
|
127
|
-
declare
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
141
|
+
export declare type UISlide = {
|
|
142
|
+
questionText?: string;
|
|
143
|
+
answerUI?: AnswerUI;
|
|
144
|
+
hidden?: boolean;
|
|
145
|
+
position: number;
|
|
146
|
+
animationType?: SlideUIAnimations;
|
|
147
|
+
isCorrect?: boolean;
|
|
148
|
+
endReview?: boolean;
|
|
149
|
+
nextContent?: NextUISlide;
|
|
131
150
|
};
|
|
132
|
-
export declare type IconValue = keyof typeof ICON_VALUES;
|
|
133
151
|
export declare type FinishedSlides = {
|
|
134
|
-
|
|
135
|
-
[key: number]: true;
|
|
152
|
+
[key in SlideIndexes]?: true;
|
|
136
153
|
};
|
|
137
154
|
export declare type WithRequired<T, K extends keyof T> = T & {
|
|
138
155
|
[P in K]-?: T[P];
|
package/es/types/common.js
CHANGED
package/es/types/slides.d.ts
CHANGED
|
@@ -1,20 +1,53 @@
|
|
|
1
1
|
import type { StoreState } from '../../reducers';
|
|
2
2
|
import { Dispatchers } from '../../actions';
|
|
3
|
+
declare const ICON_VALUES: {
|
|
4
|
+
readonly right: "right";
|
|
5
|
+
readonly wrong: "wrong";
|
|
6
|
+
readonly 'no-answer': "no-answer";
|
|
7
|
+
};
|
|
8
|
+
declare type IconValue = keyof typeof ICON_VALUES;
|
|
9
|
+
declare type StepItem = {
|
|
10
|
+
current: boolean;
|
|
11
|
+
icon: IconValue;
|
|
12
|
+
value: string;
|
|
13
|
+
};
|
|
14
|
+
declare type CorrectionPopinProps = {
|
|
15
|
+
klf: {
|
|
16
|
+
label: string;
|
|
17
|
+
onClick: Function;
|
|
18
|
+
tooltip: string;
|
|
19
|
+
};
|
|
20
|
+
information: {
|
|
21
|
+
label: string;
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
next: {
|
|
25
|
+
label: string;
|
|
26
|
+
ariaLabel: string;
|
|
27
|
+
};
|
|
28
|
+
successLabel: string;
|
|
29
|
+
failureLabel: string;
|
|
30
|
+
};
|
|
3
31
|
declare type SlidesViewStaticProps = {
|
|
4
|
-
|
|
5
|
-
headerProps: {
|
|
32
|
+
header: {
|
|
6
33
|
mode: string;
|
|
7
34
|
skillName: string;
|
|
8
35
|
onQuitClick: Function;
|
|
9
36
|
'aria-label'?: string;
|
|
10
37
|
closeButtonAriaLabel: string;
|
|
38
|
+
steps: StepItem[];
|
|
11
39
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
40
|
+
stack: {
|
|
41
|
+
slides: StoreState['ui']['slides'];
|
|
42
|
+
validateButton: {
|
|
43
|
+
label: string;
|
|
44
|
+
disabled: boolean;
|
|
45
|
+
onClick: Function;
|
|
46
|
+
};
|
|
47
|
+
correctionPopinProps?: CorrectionPopinProps;
|
|
48
|
+
endReview: boolean;
|
|
17
49
|
};
|
|
50
|
+
reviewBackgroundAriaLabel?: string;
|
|
18
51
|
congratsProps?: {
|
|
19
52
|
'aria-label'?: string;
|
|
20
53
|
'data-name'?: string;
|
|
@@ -35,26 +68,7 @@ declare type SlidesViewStaticProps = {
|
|
|
35
68
|
type: string;
|
|
36
69
|
};
|
|
37
70
|
};
|
|
38
|
-
correctionPopinProps?: {
|
|
39
|
-
klf: {
|
|
40
|
-
label: string;
|
|
41
|
-
onClick: Function;
|
|
42
|
-
tooltip: string;
|
|
43
|
-
};
|
|
44
|
-
information: {
|
|
45
|
-
label: string;
|
|
46
|
-
message: string;
|
|
47
|
-
};
|
|
48
|
-
next: {
|
|
49
|
-
label: string;
|
|
50
|
-
ariaLabel: string;
|
|
51
|
-
};
|
|
52
|
-
successLabel: string;
|
|
53
|
-
failureLabel: string;
|
|
54
|
-
};
|
|
55
|
-
reviewBackgroundAriaLabel?: string;
|
|
56
|
-
progression: StoreState['data']['progression'];
|
|
57
71
|
};
|
|
58
72
|
declare type SlidesViewDispatcherProps = Omit<Dispatchers, 'navigateTo' | 'navigateBack'>;
|
|
59
73
|
declare type SlidesViewProps = SlidesViewStaticProps & SlidesViewDispatcherProps;
|
|
60
|
-
export { SlidesViewStaticProps, SlidesViewDispatcherProps, SlidesViewProps };
|
|
74
|
+
export { CorrectionPopinProps, IconValue, SlidesViewStaticProps, SlidesViewDispatcherProps, SlidesViewProps, StepItem };
|
package/es/types/views/slides.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StoreState } from '../../reducers';
|
|
1
2
|
declare type SkillCard = {
|
|
2
3
|
'aria-label': string;
|
|
3
4
|
skillTitle: string;
|
|
@@ -22,3 +23,4 @@ declare type SkillsProps = NoSkillsProps & {
|
|
|
22
23
|
listSkills: SkillCard[];
|
|
23
24
|
};
|
|
24
25
|
export { SkillsProps };
|
|
26
|
+
export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const mapStateToSkillsProps = (state) => {
|
|
2
|
+
if (!state.data.skills) {
|
|
3
|
+
return null;
|
|
4
|
+
}
|
|
5
|
+
return {
|
|
6
|
+
title: '@todo title',
|
|
7
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
8
|
+
textNoSkills: '@todo textNoSkills',
|
|
9
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
10
|
+
isLoading: false,
|
|
11
|
+
isLoadingAriaLabel: '@todo loading',
|
|
12
|
+
listSkills: state.data.skills.map(skill => ({
|
|
13
|
+
'aria-label': '',
|
|
14
|
+
isCustom: skill.custom,
|
|
15
|
+
skillTitle: skill.name,
|
|
16
|
+
skillAriaLabel: '@todo skill aria label',
|
|
17
|
+
buttonLabel: '@todo button',
|
|
18
|
+
buttonAriaLabel: '@todo button aria label',
|
|
19
|
+
reviseLabel: '@todo revise',
|
|
20
|
+
reviseAriaLabel: '@todo revise aria label',
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
onClick: () => console.log('@todo plug dispatcher select skill')
|
|
23
|
+
}))
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import isEmpty from 'lodash/fp/isEmpty';
|
|
2
|
+
const buildStepItemps = (state) => {
|
|
3
|
+
const { progression } = state.data;
|
|
4
|
+
const { currentSlideRef } = state.ui;
|
|
5
|
+
if (!progression)
|
|
6
|
+
return [];
|
|
7
|
+
const defaultProps = [
|
|
8
|
+
{
|
|
9
|
+
icon: 'no-answer',
|
|
10
|
+
current: true,
|
|
11
|
+
value: '1'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
icon: 'no-answer',
|
|
15
|
+
current: false,
|
|
16
|
+
value: '2'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
icon: 'no-answer',
|
|
20
|
+
current: false,
|
|
21
|
+
value: '3'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
icon: 'no-answer',
|
|
25
|
+
current: false,
|
|
26
|
+
value: '4'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
icon: 'no-answer',
|
|
30
|
+
current: false,
|
|
31
|
+
value: '5'
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
const allAnswers = progression.state.allAnswers;
|
|
35
|
+
const step = progression.state.step;
|
|
36
|
+
if (isEmpty(allAnswers))
|
|
37
|
+
return defaultProps;
|
|
38
|
+
const steps = defaultProps.map((stepItem, index) => {
|
|
39
|
+
const givenAnswer = allAnswers[index];
|
|
40
|
+
if (!givenAnswer) {
|
|
41
|
+
return {
|
|
42
|
+
...stepItem,
|
|
43
|
+
current: step.current === index + 1
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
...stepItem,
|
|
48
|
+
icon: givenAnswer.isCorrect ? 'right' : 'wrong',
|
|
49
|
+
current: givenAnswer.slideRef === currentSlideRef
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
return steps;
|
|
53
|
+
};
|
|
54
|
+
export const mapStateToSlidesProps = (state) => {
|
|
55
|
+
if (!state.data.slides) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
header: {
|
|
60
|
+
mode: '__revision_mode',
|
|
61
|
+
skillName: '__agility',
|
|
62
|
+
onQuitClick: () => {
|
|
63
|
+
// eslint-disable-next-line no-console
|
|
64
|
+
console.log('onQuitClick');
|
|
65
|
+
},
|
|
66
|
+
'aria-label': 'aria-header-wrapper',
|
|
67
|
+
closeButtonAriaLabel: 'aria-close-button',
|
|
68
|
+
steps: buildStepItemps(state)
|
|
69
|
+
},
|
|
70
|
+
stack: {
|
|
71
|
+
slides: state.ui.slides,
|
|
72
|
+
validateButton: {
|
|
73
|
+
label: '__validate',
|
|
74
|
+
disabled: true,
|
|
75
|
+
onClick: () => {
|
|
76
|
+
// eslint-disable-next-line no-console
|
|
77
|
+
console.log('TODO: validate question');
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
correctionPopinProps: undefined,
|
|
81
|
+
endReview: false
|
|
82
|
+
},
|
|
83
|
+
congratsProps: undefined
|
|
84
|
+
};
|
|
85
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnyAction } from 'redux';
|
|
2
2
|
import type { ThunkAction } from 'redux-thunk';
|
|
3
3
|
import type { StoreState } from '../../reducers';
|
|
4
|
-
import { Options, SlideFromAPI } from '../../types/common';
|
|
4
|
+
import type { Options, ProgressionFromAPI, SlideFromAPI } from '../../types/common';
|
|
5
5
|
export declare const SLIDE_FETCH_REQUEST: "@@slides/FETCH_REQUEST";
|
|
6
6
|
export declare const SLIDE_FETCH_SUCCESS: "@@slides/FETCH_SUCCESS";
|
|
7
7
|
export declare const SLIDE_FETCH_FAILURE: "@@slides/FETCH_FAILURE";
|
|
@@ -9,5 +9,5 @@ export interface ReceivedSlide extends AnyAction {
|
|
|
9
9
|
type: typeof SLIDE_FETCH_SUCCESS;
|
|
10
10
|
payload: SlideFromAPI;
|
|
11
11
|
}
|
|
12
|
-
export declare type FetchSlideAction = ThunkAction<Promise<
|
|
13
|
-
export declare const fetchSlide: (
|
|
12
|
+
export declare type FetchSlideAction = ThunkAction<Promise<SlideFromAPI>, StoreState, Options, AnyAction>;
|
|
13
|
+
export declare const fetchSlide: (progressionFromAPI: ProgressionFromAPI, token: string) => FetchSlideAction;
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
import buildTask from '@coorpacademy/redux-task';
|
|
2
|
+
import get from 'lodash/fp/get';
|
|
3
|
+
import has from 'lodash/fp/has';
|
|
4
|
+
import isEmpty from 'lodash/fp/isEmpty';
|
|
5
|
+
import { setCurrentSlide } from '../ui/slides';
|
|
2
6
|
export var SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST';
|
|
3
7
|
export var SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS';
|
|
4
8
|
export var SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE';
|
|
5
|
-
export var fetchSlide = function (
|
|
9
|
+
export var fetchSlide = function (progressionFromAPI, token) {
|
|
6
10
|
return buildTask({
|
|
7
11
|
types: [SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS, SLIDE_FETCH_FAILURE],
|
|
12
|
+
bailout: function (state) {
|
|
13
|
+
var slideRef = get('state.nextContent', progressionFromAPI).ref;
|
|
14
|
+
return has("data.slide.".concat(slideRef), state);
|
|
15
|
+
},
|
|
8
16
|
task: function (dispatch, getState, _a) {
|
|
9
17
|
var services = _a.services;
|
|
10
|
-
|
|
18
|
+
var slideRef = get('state.nextContent', progressionFromAPI).ref;
|
|
19
|
+
return services.fetchSlide(slideRef, token).then(function (slideFromAPI) {
|
|
20
|
+
if (!slideFromAPI)
|
|
21
|
+
throw new Error('Slide not found');
|
|
22
|
+
var state = getState();
|
|
23
|
+
var slides = get('data.progression.state.slides', state);
|
|
24
|
+
if (isEmpty(slides)) {
|
|
25
|
+
dispatch(setCurrentSlide(slideFromAPI));
|
|
26
|
+
}
|
|
27
|
+
return slideFromAPI;
|
|
28
|
+
});
|
|
11
29
|
}
|
|
12
30
|
});
|
|
13
31
|
};
|
|
@@ -9,8 +9,7 @@ export var postProgression = function (skillRef, token) {
|
|
|
9
9
|
task: function (dispatch, getState, _a) {
|
|
10
10
|
var services = _a.services;
|
|
11
11
|
return services.postProgression(skillRef, token).then(function (progression) {
|
|
12
|
-
|
|
13
|
-
dispatch(fetchSlide(ref, token));
|
|
12
|
+
dispatch(fetchSlide(progression, token));
|
|
14
13
|
return progression;
|
|
15
14
|
});
|
|
16
15
|
}
|
package/lib/actions/index.d.ts
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import { updateSlidesOnValidation, updateSlidesOnNext, validateSlide } from './data/slides';
|
|
2
1
|
import { StoreToken } from './data/token';
|
|
3
|
-
import { updateFinishedSlides } from './ui/finished-slides';
|
|
4
2
|
import { navigateBack, navigateTo, NavigateBack, NavigateTo, StartApp } from './ui/navigation';
|
|
5
|
-
import { updateReviewStatus } from './ui/review-status';
|
|
6
|
-
import { updateStepItemsOnValidation, updateStepItemsOnNext } from './ui/step-items';
|
|
7
3
|
import { ReceivedSlide } from './api/fetch-slide';
|
|
8
4
|
import { ReceiveProgression } from './api/post-progression';
|
|
9
5
|
import { ReceivedSkills } from './api/fetch-skills';
|
|
6
|
+
import { validateSlide } from './ui/slides';
|
|
10
7
|
export declare type Action = NavigateBack | NavigateTo | ReceivedSkills | StartApp | ReceivedSlide | StoreToken | ReceiveProgression;
|
|
11
8
|
export declare type Dispatchers = {
|
|
12
9
|
navigateTo: typeof navigateTo;
|
|
13
10
|
navigateBack: typeof navigateBack;
|
|
14
11
|
validateSlide: typeof validateSlide;
|
|
15
|
-
updateSlidesOnValidation: typeof updateSlidesOnValidation;
|
|
16
|
-
updateSlidesOnNext: typeof updateSlidesOnNext;
|
|
17
|
-
updateReviewStatus: typeof updateReviewStatus;
|
|
18
|
-
updateStepItemsOnValidation: typeof updateStepItemsOnValidation;
|
|
19
|
-
updateStepItemsOnNext: typeof updateStepItemsOnNext;
|
|
20
|
-
updateFinishedSlides: typeof updateFinishedSlides;
|
|
21
12
|
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
// -----------------------------------------------------------------------------
|
|
2
1
|
export var START_FETCHING = '@@ui/START_FETCHING';
|
|
3
2
|
export var STOP_FETCHING = '@@ui/STOP_FETCHING';
|
|
4
|
-
// -----------------------------------------------------------------------------
|
|
5
3
|
export var startFetching = function () { return ({ type: START_FETCHING }); };
|
|
6
4
|
export var stopFetching = function () { return ({ type: STOP_FETCHING }); };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SlideFromAPI } from '../../types/common';
|
|
2
|
+
import { AnswerUI } from '../../types/slides';
|
|
3
|
+
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
4
|
+
export declare type Slide = {
|
|
5
|
+
questionText?: string;
|
|
6
|
+
answerUI?: AnswerUI;
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
position: number;
|
|
9
|
+
animationType?: SlideUIAnimations;
|
|
10
|
+
isCorrect?: boolean;
|
|
11
|
+
endReview?: boolean;
|
|
12
|
+
nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
|
|
13
|
+
};
|
|
14
|
+
export declare const SET_CURRENT_SLIDE: "@@slide/SET_CURRENT_SLIDE";
|
|
15
|
+
export declare type SetCurrentSlide = {
|
|
16
|
+
type: typeof SET_CURRENT_SLIDE;
|
|
17
|
+
payload: SlideFromAPI;
|
|
18
|
+
};
|
|
19
|
+
export declare const setCurrentSlide: (payload: SlideFromAPI) => SetCurrentSlide;
|
|
20
|
+
export declare const VALIDATE_SLIDE = "@@slide/VALIDATE";
|
|
21
|
+
export declare type ValidateSlide = {
|
|
22
|
+
type: typeof VALIDATE_SLIDE;
|
|
23
|
+
};
|
|
24
|
+
export declare const validateSlide: () => ValidateSlide;
|
|
25
|
+
export declare type UISlidesAction = SetCurrentSlide;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var SET_CURRENT_SLIDE = '@@slide/SET_CURRENT_SLIDE';
|
|
2
|
+
export var setCurrentSlide = function (payload) { return ({
|
|
3
|
+
type: SET_CURRENT_SLIDE,
|
|
4
|
+
payload: payload
|
|
5
|
+
}); };
|
|
6
|
+
export var VALIDATE_SLIDE = '@@slide/VALIDATE';
|
|
7
|
+
export var validateSlide = function () { return ({
|
|
8
|
+
type: VALIDATE_SLIDE
|
|
9
|
+
}); };
|
package/lib/common/index.d.ts
CHANGED
|
@@ -5,4 +5,6 @@ export declare const VIEWS: {
|
|
|
5
5
|
readonly onboarding: 'onboarding';
|
|
6
6
|
readonly slides: 'slides';
|
|
7
7
|
};
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const slideIndexes: readonly ["0", "1", "2", "3", "4"];
|
|
9
|
+
export declare type SlideIndexes = typeof slideIndexes[number];
|
|
10
|
+
export declare const indexToString: (index: number) => SlideIndexes;
|
package/lib/common/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toString from 'lodash/fp/toString';
|
|
1
2
|
export var TOTAL_SLIDES_STACK = 5;
|
|
2
3
|
export var HIGHEST_INDEX = TOTAL_SLIDES_STACK - 1;
|
|
3
4
|
export var VIEWS = {
|
|
@@ -5,4 +6,5 @@ export var VIEWS = {
|
|
|
5
6
|
onboarding: 'onboarding',
|
|
6
7
|
slides: 'slides'
|
|
7
8
|
};
|
|
8
|
-
export var
|
|
9
|
+
export var slideIndexes = ['0', '1', '2', '3', '4'];
|
|
10
|
+
export var indexToString = function (index) { return _toString(index); };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UISlide } from '../types/
|
|
2
|
-
export declare const slide: UISlide
|
|
1
|
+
import { UISlide } from '../types/common';
|
|
2
|
+
export declare const slide: Pick<UISlide, 'questionText' | 'answerUI'>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SlidesViewProps } from '../types/views/slides';
|
|
2
|
-
export declare const correctionPopinProps:
|
|
1
|
+
import { SlidesViewProps, CorrectionPopinProps } from '../types/views/slides';
|
|
2
|
+
export declare const correctionPopinProps: CorrectionPopinProps;
|
|
3
3
|
export declare const congratsProps: SlidesViewProps['congratsProps'];
|
|
@@ -4,5 +4,8 @@ declare type UiUtils = {
|
|
|
4
4
|
translate: (text: string) => string;
|
|
5
5
|
};
|
|
6
6
|
export declare const getQuestionType: (slide: SlideFromAPI) => SlideFromAPI['question']['type'];
|
|
7
|
-
export declare const mapApiSlideToUi: (uiUtils: UiUtils) => (slide: SlideFromAPI) =>
|
|
7
|
+
export declare const mapApiSlideToUi: (uiUtils: UiUtils) => (slide: SlideFromAPI) => {
|
|
8
|
+
questionText: string;
|
|
9
|
+
answerUI: AnswerUI;
|
|
10
|
+
};
|
|
8
11
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { concat, divide, get, getOr, head, includes, indexOf, isEmpty, map,
|
|
1
|
+
import { concat, divide, get, getOr, head, includes, indexOf, isEmpty, map, pipe, rangeStep, size, toInteger } from 'lodash/fp';
|
|
2
2
|
var qcmProps = function (question) {
|
|
3
3
|
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
4
4
|
var answers = [];
|
|
@@ -8,7 +8,8 @@ var qcmProps = function (question) {
|
|
|
8
8
|
title: choice.label,
|
|
9
9
|
selected: includes(choice.label, answers),
|
|
10
10
|
// TODO: EDIT_CHOICES
|
|
11
|
-
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
12
|
+
onClick: function () { return console.log('TODO: on choice click'); },
|
|
12
13
|
ariaLabel: choice.label
|
|
13
14
|
}); },
|
|
14
15
|
// TODO: EDIT_CHOICES -> getChoices
|
|
@@ -16,7 +17,6 @@ var qcmProps = function (question) {
|
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
19
|
var qcmDragProps = function (question) {
|
|
19
|
-
// mock the answers
|
|
20
20
|
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
21
21
|
var answers = [];
|
|
22
22
|
return {
|
|
@@ -28,7 +28,8 @@ var qcmDragProps = function (question) {
|
|
|
28
28
|
selected: indexInAnswer !== -1,
|
|
29
29
|
order: indexInAnswer,
|
|
30
30
|
// TODO: EDIT_CHOICES
|
|
31
|
-
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
onClick: function () { return console.log('TODO: on choice click'); }
|
|
32
33
|
};
|
|
33
34
|
// TODO: EDIT_CHOICES -> getChoices
|
|
34
35
|
}, question.content.choices)
|
|
@@ -45,7 +46,8 @@ var qcmGraphicProps = function (question) {
|
|
|
45
46
|
image: get('media.src.0.url', choice),
|
|
46
47
|
selected: includes(choice.label, answers),
|
|
47
48
|
// TODO: EDIT_CHOICES
|
|
48
|
-
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
onClick: function () { return console.log('TODO: on choice click'); }
|
|
49
51
|
}); },
|
|
50
52
|
// TODO: EDIT_CHOICES -> getChoices
|
|
51
53
|
question.content.choices)
|
|
@@ -62,7 +64,8 @@ var templateTextProps = function (uiUtils) {
|
|
|
62
64
|
placeholder: translate('Type here'),
|
|
63
65
|
value: get(index, answers),
|
|
64
66
|
// TODO: EDIT_CHOICES
|
|
65
|
-
|
|
67
|
+
// eslint-disable-next-line no-console
|
|
68
|
+
onChange: function () { return console.log('TODO: on choice change'); }
|
|
66
69
|
};
|
|
67
70
|
};
|
|
68
71
|
};
|
|
@@ -92,7 +95,8 @@ var templateSelectProps = function (uiUtils) {
|
|
|
92
95
|
type: 'select',
|
|
93
96
|
name: getOr('', 'name', choice),
|
|
94
97
|
// TODO: EDIT_CHOICES
|
|
95
|
-
|
|
98
|
+
// eslint-disable-next-line no-console
|
|
99
|
+
onChange: function () { return console.log('TODO: on choice change'); },
|
|
96
100
|
options: isEmpty(answer) ? concat([temporaryOption], selectOptions) : selectOptions
|
|
97
101
|
};
|
|
98
102
|
};
|
|
@@ -124,13 +128,14 @@ var basicProps = function (uiUtils) {
|
|
|
124
128
|
placeholder: translate('Type here'),
|
|
125
129
|
value: head(answers),
|
|
126
130
|
// TODO: EDIT_CHOICES
|
|
127
|
-
|
|
131
|
+
// eslint-disable-next-line no-console
|
|
132
|
+
onChange: function () { return console.log('TODO: on choice change'); }
|
|
128
133
|
};
|
|
129
134
|
};
|
|
130
135
|
};
|
|
131
136
|
var sliderProps = function (question) {
|
|
132
137
|
var values = rangeStep(getOr(1, 'content.step', question), getOr(Number.NaN, 'content.min', question), getOr(Number.NaN, 'content.max', question) + 1
|
|
133
|
-
// Lodash doesn't
|
|
138
|
+
// Lodash doesn't infer the type very well here
|
|
134
139
|
);
|
|
135
140
|
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
136
141
|
var answers = [];
|
|
@@ -147,19 +152,23 @@ var sliderProps = function (question) {
|
|
|
147
152
|
title: "".concat(currentValue, " ").concat(question.content.unitLabel),
|
|
148
153
|
value: sliderPosition,
|
|
149
154
|
// TODO: EDIT_CHOICES
|
|
150
|
-
|
|
155
|
+
// eslint-disable-next-line no-console
|
|
156
|
+
onChange: function () { return console.log('TODO: on choice change'); }
|
|
151
157
|
};
|
|
152
158
|
};
|
|
153
159
|
export var getQuestionType = function (slide) {
|
|
154
160
|
return slide.question.type;
|
|
155
161
|
};
|
|
156
|
-
|
|
162
|
+
var getHelp = function (uiUtils) {
|
|
163
|
+
return function (slide) {
|
|
164
|
+
var translate = uiUtils.translate;
|
|
165
|
+
return get('question.explanation', slide) || translate('Select something below');
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
var getAnswerUIModel = function (uiUtils) {
|
|
157
169
|
var basicProps_ = basicProps(uiUtils);
|
|
158
170
|
var templateProps_ = templateProps(uiUtils);
|
|
159
171
|
return function (slide) {
|
|
160
|
-
if (!slide) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
172
|
var type = getQuestionType(slide);
|
|
164
173
|
switch (type) {
|
|
165
174
|
case 'qcm':
|
|
@@ -179,3 +188,14 @@ export var mapApiSlideToUi = function (uiUtils) {
|
|
|
179
188
|
}
|
|
180
189
|
};
|
|
181
190
|
};
|
|
191
|
+
export var mapApiSlideToUi = function (uiUtils) {
|
|
192
|
+
var getAnswerUIModel_ = getAnswerUIModel(uiUtils);
|
|
193
|
+
var getHelp_ = getHelp(uiUtils);
|
|
194
|
+
return function (slide) {
|
|
195
|
+
if (!slide) {
|
|
196
|
+
throw new Error('no slide was found');
|
|
197
|
+
}
|
|
198
|
+
var questionText = pipe(getOr('', 'question.header'), uiUtils.translate)(slide);
|
|
199
|
+
return { questionText: questionText, answerUI: { model: getAnswerUIModel_(slide), help: getHelp_(slide) } };
|
|
200
|
+
};
|
|
201
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SlideFromAPI } from '../../../types/common';
|
|
1
|
+
import { SlideFromAPI, UISlide } from '../../../types/common';
|
|
3
2
|
export declare const freeTextSlide: SlideFromAPI;
|
|
4
|
-
export declare const freeTextUISlide:
|
|
3
|
+
export declare const freeTextUISlide: Partial<UISlide>;
|
|
@@ -17,8 +17,14 @@ export var freeTextSlide = {
|
|
|
17
17
|
tips: 'sli_E1Pcl-XAYbi.tips'
|
|
18
18
|
};
|
|
19
19
|
export var freeTextUISlide = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
answerUI: {
|
|
21
|
+
help: 'sli_E1Pcl-XAYbi.explanation',
|
|
22
|
+
model: {
|
|
23
|
+
type: 'freeText',
|
|
24
|
+
placeholder: 'Type here',
|
|
25
|
+
value: undefined,
|
|
26
|
+
onChange: noop
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
questionText: 'sli_E1Pcl-XAYbi.header'
|
|
24
30
|
};
|