@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
package/es/views/slides/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import reduce from 'lodash/fp/reduce';
|
|
|
7
7
|
import set from 'lodash/fp/set';
|
|
8
8
|
import slice from 'lodash/fp/slice';
|
|
9
9
|
import toInteger from 'lodash/fp/toInteger';
|
|
10
|
+
import { postAnswer } from '../../actions/api/post-answer';
|
|
10
11
|
import { mapApiSlideToUi } from './map-api-slide-to-ui';
|
|
11
12
|
const ICON_VALUES = {
|
|
12
13
|
right: 'right',
|
|
@@ -16,26 +17,31 @@ const ICON_VALUES = {
|
|
|
16
17
|
export const initialState = {
|
|
17
18
|
'0': {
|
|
18
19
|
hidden: false,
|
|
19
|
-
position: 0
|
|
20
|
+
position: 0,
|
|
21
|
+
loading: true
|
|
20
22
|
},
|
|
21
23
|
'1': {
|
|
22
24
|
hidden: false,
|
|
23
|
-
position: 1
|
|
25
|
+
position: 1,
|
|
26
|
+
loading: true
|
|
24
27
|
},
|
|
25
28
|
'2': {
|
|
26
29
|
hidden: false,
|
|
27
|
-
position: 2
|
|
30
|
+
position: 2,
|
|
31
|
+
loading: true
|
|
28
32
|
},
|
|
29
33
|
'3': {
|
|
30
34
|
hidden: false,
|
|
31
|
-
position: 3
|
|
35
|
+
position: 3,
|
|
36
|
+
loading: true
|
|
32
37
|
},
|
|
33
38
|
'4': {
|
|
34
39
|
hidden: false,
|
|
35
|
-
position: 4
|
|
40
|
+
position: 4,
|
|
41
|
+
loading: true
|
|
36
42
|
}
|
|
37
43
|
};
|
|
38
|
-
const
|
|
44
|
+
const getProgressionSlidesRefs = (progression) => {
|
|
39
45
|
if (progression.state.step.current < 5) {
|
|
40
46
|
const slideRef = progression.state.nextContent.ref;
|
|
41
47
|
return concat([slideRef], progression.state.slides);
|
|
@@ -47,18 +53,20 @@ const buildStackSlides = (state, dispatch) => {
|
|
|
47
53
|
const progression = state.data.progression;
|
|
48
54
|
if (!currentSlideRef || !progression)
|
|
49
55
|
return initialState;
|
|
50
|
-
const slideRefs =
|
|
56
|
+
const slideRefs = getProgressionSlidesRefs(progression);
|
|
51
57
|
// @ts-expect-error typescript does not support capped versions of lodash functions
|
|
52
58
|
const stack = reduce.convert({ cap: false })((acc, uiSlide, index) => {
|
|
53
59
|
const slideRef = slideRefs[toInteger(index)];
|
|
54
60
|
if (!slideRef)
|
|
55
61
|
return set(index, uiSlide, acc);
|
|
56
62
|
const slideFromAPI = get(slideRef, state.data.slides);
|
|
63
|
+
if (!slideFromAPI)
|
|
64
|
+
return set(index, uiSlide, acc);
|
|
57
65
|
const answers = state.ui.answers;
|
|
58
66
|
const { questionText, answerUI } = mapApiSlideToUi(dispatch)(slideFromAPI, answers);
|
|
59
67
|
const parentContentTitle = getOr('', 'parentContentTitle.title', slideFromAPI);
|
|
60
68
|
const parentContentType = getOr('', 'parentContentTitle.type', slideFromAPI);
|
|
61
|
-
const updatedUiSlide = pipe(set(
|
|
69
|
+
const updatedUiSlide = pipe(set('loading', false), set('questionText', questionText), set('answerUI', answerUI), set('parentContentTitle', `From "${parentContentTitle}" ${parentContentType}`) // TODO translate: -From- .... -Course/chapter-
|
|
62
70
|
// TODO: Set position according to currentSlideRef et slideRefs (or maybe a value on the state ui.slidePositions !!)
|
|
63
71
|
)(uiSlide);
|
|
64
72
|
return set(index, updatedUiSlide, acc);
|
|
@@ -118,9 +126,6 @@ const buildStepItems = (state) => {
|
|
|
118
126
|
return steps;
|
|
119
127
|
};
|
|
120
128
|
export const mapStateToSlidesProps = (state, dispatch) => {
|
|
121
|
-
if (!state.data.slides) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
129
|
return {
|
|
125
130
|
header: {
|
|
126
131
|
mode: '__revision_mode',
|
|
@@ -137,10 +142,9 @@ export const mapStateToSlidesProps = (state, dispatch) => {
|
|
|
137
142
|
slides: buildStackSlides(state, dispatch),
|
|
138
143
|
validateButton: {
|
|
139
144
|
label: '__validate',
|
|
140
|
-
disabled:
|
|
145
|
+
disabled: !get('ui.slide.validateButton', state),
|
|
141
146
|
onClick: () => {
|
|
142
|
-
|
|
143
|
-
console.log('TODO: validate question');
|
|
147
|
+
dispatch(postAnswer);
|
|
144
148
|
}
|
|
145
149
|
},
|
|
146
150
|
correctionPopinProps: undefined,
|
|
@@ -1,57 +1,52 @@
|
|
|
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
|
-
const qcmProps = (question) => {
|
|
4
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
5
|
-
const answers = [];
|
|
3
|
+
const qcmProps = (dispatch) => (answers, question) => {
|
|
6
4
|
return {
|
|
7
5
|
type: 'qcm',
|
|
8
|
-
answers: map(choice =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
answers: map(choice => {
|
|
7
|
+
const label = choice.label || '';
|
|
8
|
+
return {
|
|
9
|
+
title: label,
|
|
10
|
+
selected: includes(label, answers),
|
|
11
|
+
onClick: () => {
|
|
12
|
+
dispatch(editAnswer(label));
|
|
13
|
+
},
|
|
14
|
+
ariaLabel: choice.label
|
|
15
|
+
};
|
|
16
|
+
}, question.content.choices)
|
|
18
17
|
};
|
|
19
18
|
};
|
|
20
|
-
const qcmDragProps = (question) => {
|
|
21
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
22
|
-
const answers = [];
|
|
19
|
+
const qcmDragProps = (dispatch) => (answers, question) => {
|
|
23
20
|
return {
|
|
24
21
|
type: 'qcmDrag',
|
|
25
22
|
answers: map(choice => {
|
|
26
|
-
const
|
|
23
|
+
const label = choice.label || '';
|
|
24
|
+
const indexInAnswer = indexOf(label, answers);
|
|
27
25
|
return {
|
|
28
|
-
title:
|
|
29
|
-
selected: includes(
|
|
26
|
+
title: label,
|
|
27
|
+
selected: includes(label, answers),
|
|
30
28
|
order: indexInAnswer,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
onClick: () => {
|
|
30
|
+
dispatch(editAnswer(label));
|
|
31
|
+
}
|
|
34
32
|
};
|
|
35
|
-
// TODO: EDIT_CHOICES -> getChoices
|
|
36
33
|
}, question.content.choices)
|
|
37
34
|
};
|
|
38
35
|
};
|
|
39
|
-
const qcmGraphicProps = (question) => {
|
|
40
|
-
// mock the answers
|
|
41
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
42
|
-
const answers = [];
|
|
36
|
+
const qcmGraphicProps = (dispatch) => (answers, question) => {
|
|
43
37
|
return {
|
|
44
38
|
type: 'qcmGraphic',
|
|
45
|
-
answers: map(choice =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
answers: map(choice => {
|
|
40
|
+
const label = choice.label || '';
|
|
41
|
+
return {
|
|
42
|
+
title: label,
|
|
43
|
+
image: get('media.src.0.url', choice),
|
|
44
|
+
selected: includes(label, answers),
|
|
45
|
+
onClick: () => {
|
|
46
|
+
dispatch(editAnswer(label));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}, question.content.choices)
|
|
55
50
|
};
|
|
56
51
|
};
|
|
57
52
|
const templateTextProps = (choice, index) => {
|
|
@@ -110,22 +105,19 @@ const basicProps = (dispatch) => (answers, question) => {
|
|
|
110
105
|
placeholder: question.content.placeholder || '',
|
|
111
106
|
value: answers[0] || '',
|
|
112
107
|
onChange: (text) => {
|
|
113
|
-
// eslint-disable-next-line no-console
|
|
114
|
-
console.log(text);
|
|
115
108
|
dispatch(editAnswer(text));
|
|
116
109
|
}
|
|
117
110
|
};
|
|
118
111
|
};
|
|
119
|
-
const sliderProps = (question) => {
|
|
112
|
+
const sliderProps = (dispatch) => (answers, question) => {
|
|
120
113
|
const values = rangeStep(getOr(1, 'content.step', question), get('content.min', question), get('content.max', question) + 1
|
|
121
114
|
// Lodash doesn't infer the type very well here
|
|
122
115
|
);
|
|
123
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
124
|
-
const answers = [];
|
|
125
116
|
const stateValue = head(answers) || question.content.min;
|
|
126
117
|
const currentValue = toInteger(stateValue);
|
|
127
118
|
const indexValue = indexOf(currentValue, values);
|
|
128
|
-
const
|
|
119
|
+
const maxValue = size(values) - 1;
|
|
120
|
+
const sliderPosition = divide(indexValue, maxValue);
|
|
129
121
|
const unitLabel = get('content.unitLabel', question);
|
|
130
122
|
return {
|
|
131
123
|
type: 'slider',
|
|
@@ -134,9 +126,10 @@ const sliderProps = (question) => {
|
|
|
134
126
|
maxLabel: `${question.content.max} ${unitLabel}`,
|
|
135
127
|
title: `${currentValue} ${question.content.unitLabel}`,
|
|
136
128
|
value: sliderPosition,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
129
|
+
onChange: (position) => {
|
|
130
|
+
const newValue = pipe(multiply(maxValue), round, get(__, values), _toString)(position);
|
|
131
|
+
dispatch(editAnswer(newValue));
|
|
132
|
+
}
|
|
140
133
|
};
|
|
141
134
|
};
|
|
142
135
|
export const getQuestionType = (question) => question.type;
|
|
@@ -145,17 +138,17 @@ const getAnswerUIModel = (question, answers, dispatch) => {
|
|
|
145
138
|
const type = getQuestionType(question);
|
|
146
139
|
switch (type) {
|
|
147
140
|
case 'qcm':
|
|
148
|
-
return qcmProps(question);
|
|
141
|
+
return qcmProps(dispatch)(answers, question);
|
|
149
142
|
case 'qcmGraphic':
|
|
150
|
-
return qcmGraphicProps(question);
|
|
143
|
+
return qcmGraphicProps(dispatch)(answers, question);
|
|
151
144
|
case 'qcmDrag':
|
|
152
|
-
return qcmDragProps(question);
|
|
145
|
+
return qcmDragProps(dispatch)(answers, question);
|
|
153
146
|
case 'basic':
|
|
154
147
|
return basicProps(dispatch)(answers, question);
|
|
155
148
|
case 'template':
|
|
156
149
|
return templateProps(question);
|
|
157
150
|
case 'slider':
|
|
158
|
-
return sliderProps(question);
|
|
151
|
+
return sliderProps(dispatch)(answers, question);
|
|
159
152
|
default:
|
|
160
153
|
throw new Error(`${type} is not an handled question.type`);
|
|
161
154
|
}
|
|
@@ -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>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UISlide } from '../..';
|
|
2
|
+
import { SlideFromAPI } from '../../../../types/common';
|
|
2
3
|
export declare const selectTemplateSlide: SlideFromAPI;
|
|
3
4
|
export declare const selectTemplateUISlide: Partial<UISlide>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UISlide } from '../..';
|
|
2
|
+
import { SlideFromAPI } from '../../../../types/common';
|
|
2
3
|
export declare const textTemplateSlide: SlideFromAPI;
|
|
3
4
|
export declare const textTemplateUISlide: Partial<UISlide>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import identity from 'lodash/fp/identity';
|
|
3
|
+
import omit from 'lodash/fp/omit';
|
|
4
|
+
import { mapStateToSlidesProps } from '..';
|
|
5
|
+
import { freeTextSlide } from './fixtures/free-text';
|
|
6
|
+
test('should create initial props when fetched slide is still not received', t => {
|
|
7
|
+
const state = {
|
|
8
|
+
data: {
|
|
9
|
+
progression: {
|
|
10
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
11
|
+
content: {
|
|
12
|
+
ref: '_skillref',
|
|
13
|
+
type: 'skill'
|
|
14
|
+
},
|
|
15
|
+
engine: {
|
|
16
|
+
ref: 'review'
|
|
17
|
+
},
|
|
18
|
+
state: {
|
|
19
|
+
allAnswers: [],
|
|
20
|
+
isCorrect: true,
|
|
21
|
+
nextContent: {
|
|
22
|
+
ref: 'sli_N1XACJobn',
|
|
23
|
+
type: 'slide'
|
|
24
|
+
},
|
|
25
|
+
pendingSlides: [],
|
|
26
|
+
slides: [],
|
|
27
|
+
step: {
|
|
28
|
+
current: 1
|
|
29
|
+
},
|
|
30
|
+
stars: 0
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
skills: [],
|
|
34
|
+
slides: {
|
|
35
|
+
sli_N1XACJobn: null
|
|
36
|
+
},
|
|
37
|
+
token: '1234'
|
|
38
|
+
},
|
|
39
|
+
ui: {
|
|
40
|
+
currentSlideRef: '',
|
|
41
|
+
navigation: ['loader', 'slides'],
|
|
42
|
+
answers: [],
|
|
43
|
+
slide: {
|
|
44
|
+
validateButton: false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const props = mapStateToSlidesProps(state, identity);
|
|
49
|
+
t.is(props.congratsProps, undefined);
|
|
50
|
+
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
51
|
+
'aria-label': 'aria-header-wrapper',
|
|
52
|
+
closeButtonAriaLabel: 'aria-close-button',
|
|
53
|
+
mode: '__revision_mode',
|
|
54
|
+
skillName: '__agility',
|
|
55
|
+
steps: [
|
|
56
|
+
{
|
|
57
|
+
current: true,
|
|
58
|
+
icon: 'no-answer',
|
|
59
|
+
value: '1'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
current: false,
|
|
63
|
+
icon: 'no-answer',
|
|
64
|
+
value: '2'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
current: false,
|
|
68
|
+
icon: 'no-answer',
|
|
69
|
+
value: '3'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
current: false,
|
|
73
|
+
icon: 'no-answer',
|
|
74
|
+
value: '4'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
current: false,
|
|
78
|
+
icon: 'no-answer',
|
|
79
|
+
value: '5'
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
t.deepEqual(omit(['validateButton'], props.stack), {
|
|
84
|
+
correctionPopinProps: undefined,
|
|
85
|
+
endReview: false,
|
|
86
|
+
slides: {
|
|
87
|
+
'0': {
|
|
88
|
+
hidden: false,
|
|
89
|
+
position: 0,
|
|
90
|
+
loading: true
|
|
91
|
+
},
|
|
92
|
+
'1': {
|
|
93
|
+
hidden: false,
|
|
94
|
+
position: 1,
|
|
95
|
+
loading: true
|
|
96
|
+
},
|
|
97
|
+
'2': {
|
|
98
|
+
hidden: false,
|
|
99
|
+
position: 2,
|
|
100
|
+
loading: true
|
|
101
|
+
},
|
|
102
|
+
'3': {
|
|
103
|
+
hidden: false,
|
|
104
|
+
position: 3,
|
|
105
|
+
loading: true
|
|
106
|
+
},
|
|
107
|
+
'4': {
|
|
108
|
+
hidden: false,
|
|
109
|
+
position: 4,
|
|
110
|
+
loading: true
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
test('should create initial props when the slide is on the state', t => {
|
|
116
|
+
const state = {
|
|
117
|
+
data: {
|
|
118
|
+
progression: {
|
|
119
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
120
|
+
content: {
|
|
121
|
+
ref: '_skillref',
|
|
122
|
+
type: 'skill'
|
|
123
|
+
},
|
|
124
|
+
engine: {
|
|
125
|
+
ref: 'review'
|
|
126
|
+
},
|
|
127
|
+
state: {
|
|
128
|
+
allAnswers: [],
|
|
129
|
+
isCorrect: true,
|
|
130
|
+
nextContent: {
|
|
131
|
+
ref: 'sli_N1XACJobn',
|
|
132
|
+
type: 'slide'
|
|
133
|
+
},
|
|
134
|
+
pendingSlides: [],
|
|
135
|
+
slides: [],
|
|
136
|
+
step: {
|
|
137
|
+
current: 1
|
|
138
|
+
},
|
|
139
|
+
stars: 0
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
skills: [],
|
|
143
|
+
slides: {
|
|
144
|
+
sli_N1XACJobn: freeTextSlide
|
|
145
|
+
},
|
|
146
|
+
token: '1234'
|
|
147
|
+
},
|
|
148
|
+
ui: {
|
|
149
|
+
currentSlideRef: 'sli_N1XACJobn',
|
|
150
|
+
navigation: ['loader', 'slides'],
|
|
151
|
+
answers: ['My value'],
|
|
152
|
+
slide: {
|
|
153
|
+
validateButton: true
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const props = mapStateToSlidesProps(state, identity);
|
|
158
|
+
t.is(props.congratsProps, undefined);
|
|
159
|
+
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
160
|
+
'aria-label': 'aria-header-wrapper',
|
|
161
|
+
closeButtonAriaLabel: 'aria-close-button',
|
|
162
|
+
mode: '__revision_mode',
|
|
163
|
+
skillName: '__agility',
|
|
164
|
+
steps: [
|
|
165
|
+
{
|
|
166
|
+
current: true,
|
|
167
|
+
icon: 'no-answer',
|
|
168
|
+
value: '1'
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
current: false,
|
|
172
|
+
icon: 'no-answer',
|
|
173
|
+
value: '2'
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
current: false,
|
|
177
|
+
icon: 'no-answer',
|
|
178
|
+
value: '3'
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
current: false,
|
|
182
|
+
icon: 'no-answer',
|
|
183
|
+
value: '4'
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
current: false,
|
|
187
|
+
icon: 'no-answer',
|
|
188
|
+
value: '5'
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
});
|
|
192
|
+
t.deepEqual(omit(['validateButton', 'slides'], props.stack), {
|
|
193
|
+
correctionPopinProps: undefined,
|
|
194
|
+
endReview: false
|
|
195
|
+
});
|
|
196
|
+
t.false(props.stack.validateButton.disabled);
|
|
197
|
+
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
198
|
+
hidden: false,
|
|
199
|
+
position: 0,
|
|
200
|
+
loading: false,
|
|
201
|
+
parentContentTitle: 'From "Developing the review app" course',
|
|
202
|
+
questionText: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
|
|
203
|
+
});
|
|
204
|
+
t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
|
|
205
|
+
help: 'Type your answer.',
|
|
206
|
+
model: {
|
|
207
|
+
placeholder: 'Type here',
|
|
208
|
+
type: 'freeText',
|
|
209
|
+
value: 'My value'
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
t.deepEqual(omit(['0'], props.stack.slides), {
|
|
213
|
+
'1': {
|
|
214
|
+
hidden: false,
|
|
215
|
+
position: 1,
|
|
216
|
+
loading: true
|
|
217
|
+
},
|
|
218
|
+
'2': {
|
|
219
|
+
hidden: false,
|
|
220
|
+
position: 2,
|
|
221
|
+
loading: true
|
|
222
|
+
},
|
|
223
|
+
'3': {
|
|
224
|
+
hidden: false,
|
|
225
|
+
position: 3,
|
|
226
|
+
loading: true
|
|
227
|
+
},
|
|
228
|
+
'4': {
|
|
229
|
+
hidden: false,
|
|
230
|
+
position: 4,
|
|
231
|
+
loading: true
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Dispatch } from 'redux';
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
2
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
-
import { Options, Skill } from '../../types/common';
|
|
3
|
+
import type { Options, Skill } from '../../types/common';
|
|
4
4
|
export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
|
|
5
5
|
export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
|
|
6
6
|
export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
|
|
@@ -8,4 +8,4 @@ export declare type ReceivedSkills = {
|
|
|
8
8
|
type: '@@skills/FETCH_SUCCESS';
|
|
9
9
|
payload: Skill[];
|
|
10
10
|
};
|
|
11
|
-
export declare const fetchSkills: (
|
|
11
|
+
export declare const fetchSkills: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|
|
@@ -35,27 +35,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import buildTask from '@coorpacademy/redux-task';
|
|
38
|
+
import get from 'lodash/fp/get';
|
|
38
39
|
export var SKILLS_FETCH_REQUEST = '@@skills/FETCH_REQUEST';
|
|
39
40
|
export var SKILLS_FETCH_SUCCESS = '@@skills/FETCH_SUCCESS';
|
|
40
41
|
export var SKILLS_FETCH_FAILURE = '@@skills/FETCH_FAILURE';
|
|
41
|
-
export var fetchSkills = function (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
export var fetchSkills = function (dispatch, getState, _a) {
|
|
43
|
+
var services = _a.services;
|
|
44
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
+
var action;
|
|
46
|
+
return __generator(this, function (_b) {
|
|
47
|
+
switch (_b.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
action = buildTask({
|
|
50
|
+
types: [SKILLS_FETCH_REQUEST, SKILLS_FETCH_SUCCESS, SKILLS_FETCH_FAILURE],
|
|
51
|
+
task: function () {
|
|
52
|
+
var state = getState();
|
|
53
|
+
var token = get('data.token', state);
|
|
54
|
+
return services.fetchSkills(token);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return [4 /*yield*/, dispatch(action)];
|
|
58
|
+
case 1:
|
|
59
|
+
_b.sent();
|
|
60
|
+
return [2 /*return*/];
|
|
61
|
+
}
|
|
59
62
|
});
|
|
60
|
-
};
|
|
63
|
+
});
|
|
61
64
|
};
|
|
@@ -17,4 +17,4 @@ export declare type ReceivedSlide = {
|
|
|
17
17
|
slideRef: string;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
export declare const fetchSlide: (slideRef: string
|
|
20
|
+
export declare const fetchSlide: (slideRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|
|
@@ -42,7 +42,7 @@ import { setCurrentSlide } from '../ui/slides';
|
|
|
42
42
|
export var SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST';
|
|
43
43
|
export var SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS';
|
|
44
44
|
export var SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE';
|
|
45
|
-
export var fetchSlide = function (slideRef
|
|
45
|
+
export var fetchSlide = function (slideRef) {
|
|
46
46
|
return function (dispatch, getState, _a) {
|
|
47
47
|
var services = _a.services;
|
|
48
48
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -56,6 +56,8 @@ export var fetchSlide = function (slideRef, token) {
|
|
|
56
56
|
return has("data.slide.".concat(slideRef), state);
|
|
57
57
|
},
|
|
58
58
|
task: function () {
|
|
59
|
+
var state = getState();
|
|
60
|
+
var token = get('data.token', state);
|
|
59
61
|
return services.fetchSlide(slideRef, token);
|
|
60
62
|
},
|
|
61
63
|
meta: { slideRef: slideRef }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
2
|
+
import type { Options } from '../../types/common';
|
|
3
|
+
import type { StoreState } from '../../reducers';
|
|
4
|
+
export declare const POST_ANSWER_REQUEST: "@@answer/POST_REQUEST";
|
|
5
|
+
export declare const POST_ANSWER_SUCCESS: "@@answer/POST_SUCCESS";
|
|
6
|
+
export declare const POST_ANSWER_FAILURE: "@@answer/POST_FAILURE";
|
|
7
|
+
export declare type PostAnswerRequestAction = {
|
|
8
|
+
type: typeof POST_ANSWER_REQUEST;
|
|
9
|
+
};
|
|
10
|
+
export declare const postAnswer: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|