@coorpacademy/app-review 0.1.14 → 0.1.16
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 +4 -6
- package/es/actions/api/fetch-skills.js +7 -4
- package/es/actions/api/fetch-slide.d.ts +14 -7
- package/es/actions/api/fetch-slide.js +27 -4
- package/es/actions/api/post-progression.d.ts +4 -6
- package/es/actions/api/post-progression.js +13 -9
- package/es/actions/api/test/create-test-store.d.ts +5 -0
- package/es/actions/api/test/create-test-store.js +16 -0
- package/es/actions/api/test/fetch-skills.test.js +54 -0
- package/es/actions/api/test/fetch-slide.test.js +61 -0
- package/es/actions/api/test/post-progression.test.js +102 -0
- package/es/actions/index.d.ts +1 -10
- package/es/actions/ui/answers.d.ts +7 -0
- package/es/actions/ui/answers.js +7 -0
- 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/index.js +22 -92
- package/es/reducers/data/index.d.ts +2 -2
- 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 +9 -108
- package/es/reducers/data/test/progression.test.js +38 -0
- package/es/reducers/data/test/skills.test.js +12 -0
- package/es/reducers/data/test/slides.test.js +20 -0
- package/es/reducers/data/test/token.test.js +11 -0
- package/es/reducers/index.d.ts +3 -4
- package/es/reducers/ui/answers.d.ts +4 -0
- package/es/reducers/ui/{review-status.js → answers.js} +3 -3
- package/es/reducers/ui/current-slide-ref.d.ts +4 -0
- package/es/reducers/ui/current-slide-ref.js +13 -0
- package/es/reducers/ui/index.d.ts +7 -10
- package/es/reducers/ui/index.js +4 -6
- package/es/reducers/ui/test/answers.test.js +11 -0
- package/es/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/es/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/es/reducers/ui/test/navigation.test.d.ts +1 -0
- package/es/reducers/ui/test/navigation.test.js +15 -0
- package/es/services/fetch-slide.js +1 -1
- package/es/services/index.js +3 -1
- package/es/services/post-answer.d.ts +2 -0
- package/es/services/post-answer.js +18 -0
- package/es/services/test/fetch-slide.test.d.ts +1 -0
- package/es/services/test/fetch-slide.test.js +22 -0
- package/es/services/test/post-answer.test.d.ts +1 -0
- package/es/services/test/post-answer.test.js +57 -0
- package/es/services/test/post-progression.test.js +14 -4
- package/es/test/util/services.mock.js +46 -4
- package/es/types/common.d.ts +61 -30
- package/es/types/common.js +0 -5
- package/es/types/slides.d.ts +0 -4
- 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 +79 -0
- package/es/views/slides/index.js +151 -0
- package/es/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/es/views/slides/map-api-slide-to-ui.js +172 -0
- package/es/views/slides/test/fixtures/free-text.d.ts +3 -0
- package/es/views/slides/test/fixtures/free-text.js +38 -0
- package/es/views/slides/test/fixtures/qcm-drag.d.ts +3 -0
- package/es/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/es/views/slides/test/fixtures/qcm-graphic.d.ts +3 -0
- package/es/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/es/views/slides/test/fixtures/qcm.d.ts +3 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm.js +37 -27
- package/es/views/slides/test/fixtures/select-template.d.ts +3 -0
- package/es/views/slides/test/fixtures/select-template.js +92 -0
- package/es/views/slides/test/fixtures/slider.d.ts +3 -0
- package/es/views/slides/test/fixtures/slider.js +36 -0
- package/es/views/slides/test/fixtures/text-template.d.ts +3 -0
- package/es/{helpers → views/slides}/test/fixtures/text-template.js +21 -11
- package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/es/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/lib/actions/api/fetch-skills.d.ts +4 -6
- package/lib/actions/api/fetch-skills.js +55 -7
- package/lib/actions/api/fetch-slide.d.ts +14 -7
- package/lib/actions/api/fetch-slide.js +75 -7
- package/lib/actions/api/post-progression.d.ts +4 -6
- package/lib/actions/api/post-progression.js +63 -10
- package/lib/actions/api/test/create-test-store.d.ts +5 -0
- package/lib/actions/api/test/create-test-store.js +18 -0
- package/lib/actions/api/test/fetch-skills.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-skills.test.js +113 -0
- package/lib/actions/api/test/fetch-slide.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-slide.test.js +120 -0
- package/lib/actions/api/test/post-progression.test.d.ts +1 -0
- package/lib/actions/api/test/post-progression.test.js +160 -0
- package/lib/actions/index.d.ts +1 -10
- package/lib/actions/ui/answers.d.ts +7 -0
- package/lib/actions/ui/answers.js +9 -0
- 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/index.js +33 -94
- package/lib/reducers/data/index.d.ts +2 -2
- 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 +9 -114
- package/lib/reducers/data/test/progression.test.d.ts +1 -0
- package/lib/reducers/data/test/progression.test.js +38 -0
- package/lib/reducers/data/test/skills.test.d.ts +1 -0
- package/lib/reducers/data/test/skills.test.js +12 -0
- package/lib/reducers/data/test/slides.test.d.ts +1 -0
- package/lib/reducers/data/test/slides.test.js +20 -0
- package/lib/reducers/data/test/token.test.d.ts +1 -0
- package/lib/reducers/data/test/token.test.js +11 -0
- package/lib/reducers/index.d.ts +3 -4
- package/lib/reducers/ui/answers.d.ts +4 -0
- package/lib/reducers/ui/{review-status.js → answers.js} +3 -3
- package/lib/reducers/ui/current-slide-ref.d.ts +4 -0
- package/lib/reducers/ui/current-slide-ref.js +14 -0
- package/lib/reducers/ui/index.d.ts +7 -10
- package/lib/reducers/ui/index.js +4 -6
- package/lib/reducers/ui/test/answers.test.d.ts +1 -0
- package/lib/reducers/ui/test/answers.test.js +11 -0
- package/lib/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/lib/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/lib/reducers/ui/test/navigation.test.d.ts +1 -0
- package/lib/reducers/ui/test/navigation.test.js +15 -0
- package/lib/services/fetch-slide.js +1 -1
- package/lib/services/index.js +3 -1
- package/lib/services/post-answer.d.ts +2 -0
- package/lib/services/post-answer.js +62 -0
- package/lib/services/test/fetch-slide.test.d.ts +1 -0
- package/lib/services/test/fetch-slide.test.js +76 -0
- package/lib/services/test/post-answer.test.d.ts +1 -0
- package/lib/services/test/post-answer.test.js +111 -0
- package/lib/services/test/post-progression.test.js +14 -4
- package/lib/test/util/services.mock.js +46 -4
- package/lib/types/common.d.ts +61 -30
- package/lib/types/common.js +0 -5
- package/lib/types/slides.d.ts +0 -4
- 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 +79 -0
- package/lib/views/slides/index.js +155 -0
- package/lib/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/lib/views/slides/map-api-slide-to-ui.js +178 -0
- package/lib/views/slides/test/fixtures/free-text.d.ts +3 -0
- package/lib/views/slides/test/fixtures/free-text.js +38 -0
- package/lib/views/slides/test/fixtures/qcm-drag.d.ts +3 -0
- package/lib/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +3 -0
- package/lib/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/lib/views/slides/test/fixtures/qcm.d.ts +3 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm.js +37 -27
- package/lib/views/slides/test/fixtures/select-template.d.ts +3 -0
- package/lib/views/slides/test/fixtures/select-template.js +92 -0
- package/lib/views/slides/test/fixtures/slider.d.ts +3 -0
- package/lib/views/slides/test/fixtures/slider.js +36 -0
- package/lib/views/slides/test/fixtures/text-template.d.ts +3 -0
- package/lib/{helpers → views/slides}/test/fixtures/text-template.js +21 -11
- package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/lib/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/package.json +4 -3
- package/src/actions/api/fetch-skills.ts +12 -12
- package/src/actions/api/fetch-slide.ts +38 -13
- package/src/actions/api/post-progression.ts +18 -22
- package/src/actions/api/test/create-test-store.ts +25 -0
- package/src/actions/api/test/fetch-skills.test.ts +70 -0
- package/src/actions/api/test/fetch-slide.test.ts +77 -0
- package/src/actions/api/test/post-progression.test.ts +119 -0
- package/src/actions/index.ts +1 -10
- package/src/actions/ui/answers.ts +16 -0
- 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/index.tsx +26 -110
- package/src/reducers/data/index.ts +1 -1
- package/src/reducers/data/progression.ts +5 -40
- package/src/reducers/data/slides.ts +17 -125
- package/src/reducers/data/test/progression.test.ts +42 -0
- package/src/reducers/data/test/skills.test.ts +14 -0
- package/src/reducers/data/test/slides.test.ts +26 -0
- package/src/reducers/data/test/token.test.ts +13 -0
- package/src/reducers/ui/answers.ts +19 -0
- package/src/reducers/ui/current-slide-ref.ts +19 -0
- package/src/reducers/ui/index.ts +6 -9
- package/src/reducers/ui/test/answers.test.ts +13 -0
- package/src/reducers/ui/test/current-slide-ref.test.ts +14 -0
- package/src/reducers/ui/test/navigation.test.ts +19 -0
- package/src/services/fetch-slide.ts +1 -1
- package/src/services/index.ts +3 -1
- package/src/services/post-answer.ts +27 -0
- package/src/services/test/fetch-slide.test.ts +30 -0
- package/src/services/test/post-answer.test.ts +68 -0
- package/src/services/test/post-progression.test.ts +14 -4
- package/src/test/util/services.mock.ts +46 -4
- package/src/types/common.ts +77 -40
- package/src/types/slides.ts +0 -5
- package/src/views/skills/index.ts +56 -0
- package/src/views/slides/index.ts +251 -0
- package/src/views/slides/map-api-slide-to-ui.ts +251 -0
- package/src/views/slides/test/fixtures/free-text.ts +43 -0
- package/src/views/slides/test/fixtures/qcm-drag.ts +111 -0
- package/src/views/slides/test/fixtures/qcm-graphic.ts +94 -0
- package/src/{helpers → views/slides}/test/fixtures/qcm.ts +43 -33
- package/src/views/slides/test/fixtures/select-template.ts +98 -0
- package/src/views/slides/test/fixtures/slider.ts +41 -0
- package/src/{helpers → views/slides}/test/fixtures/text-template.ts +23 -14
- package/src/{helpers → views/slides}/test/map-api-slide-to-ui.test.ts +22 -20
- 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/helpers/map-api-slide-to-ui.d.ts +0 -8
- package/es/helpers/map-api-slide-to-ui.js +0 -175
- package/es/helpers/test/fixtures/free-text.d.ts +0 -4
- package/es/helpers/test/fixtures/free-text.js +0 -24
- package/es/helpers/test/fixtures/qcm-drag.d.ts +0 -4
- package/es/helpers/test/fixtures/qcm-drag.js +0 -106
- package/es/helpers/test/fixtures/qcm-graphic.d.ts +0 -4
- package/es/helpers/test/fixtures/qcm-graphic.js +0 -70
- package/es/helpers/test/fixtures/qcm.d.ts +0 -4
- package/es/helpers/test/fixtures/select-template.d.ts +0 -4
- package/es/helpers/test/fixtures/select-template.js +0 -88
- package/es/helpers/test/fixtures/slider.d.ts +0 -4
- package/es/helpers/test/fixtures/slider.js +0 -27
- package/es/helpers/test/fixtures/text-template.d.ts +0 -4
- 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/views/slides.d.ts +0 -60
- 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/helpers/map-api-slide-to-ui.d.ts +0 -8
- package/lib/helpers/map-api-slide-to-ui.js +0 -181
- package/lib/helpers/test/fixtures/free-text.d.ts +0 -4
- package/lib/helpers/test/fixtures/free-text.js +0 -24
- package/lib/helpers/test/fixtures/qcm-drag.d.ts +0 -4
- package/lib/helpers/test/fixtures/qcm-drag.js +0 -106
- package/lib/helpers/test/fixtures/qcm-graphic.d.ts +0 -4
- package/lib/helpers/test/fixtures/qcm-graphic.js +0 -70
- package/lib/helpers/test/fixtures/qcm.d.ts +0 -4
- package/lib/helpers/test/fixtures/select-template.d.ts +0 -4
- package/lib/helpers/test/fixtures/select-template.js +0 -88
- package/lib/helpers/test/fixtures/slider.d.ts +0 -4
- package/lib/helpers/test/fixtures/slider.js +0 -27
- package/lib/helpers/test/fixtures/text-template.d.ts +0 -4
- 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/views/slides.d.ts +0 -60
- 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/helpers/map-api-slide-to-ui.ts +0 -253
- package/src/helpers/test/fixtures/free-text.ts +0 -28
- package/src/helpers/test/fixtures/qcm-drag.ts +0 -110
- package/src/helpers/test/fixtures/qcm-graphic.ts +0 -74
- package/src/helpers/test/fixtures/select-template.ts +0 -92
- package/src/helpers/test/fixtures/slider.ts +0 -31
- 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/src/types/views/slides.ts +0 -65
- /package/es/{helpers/test/map-api-slide-to-ui.test.d.ts → actions/api/test/fetch-skills.test.d.ts} +0 -0
- /package/es/{types/ui-progression.js → actions/api/test/fetch-slide.test.d.ts} +0 -0
- /package/es/{types/views/skills.js → actions/api/test/post-progression.test.d.ts} +0 -0
- /package/es/{types/views/slides.js → reducers/data/test/progression.test.d.ts} +0 -0
- /package/{lib/helpers/test/map-api-slide-to-ui.test.d.ts → es/reducers/data/test/skills.test.d.ts} +0 -0
- /package/{lib/types/ui-progression.js → es/reducers/data/test/slides.test.d.ts} +0 -0
- /package/{lib/types/views/skills.js → es/reducers/data/test/token.test.d.ts} +0 -0
- /package/{lib/types/views/slides.js → es/reducers/ui/test/answers.test.d.ts} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../navigation';
|
|
3
|
+
import {NavigateTo, NAVIGATE_TO, NAVIGATE_BACK} from '../../../actions/ui/navigation';
|
|
4
|
+
|
|
5
|
+
test('should have inital value', t => {
|
|
6
|
+
const state = reducer(undefined, {} as NavigateTo);
|
|
7
|
+
t.deepEqual(state, []);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('should set the value of NAVIGATE_TO and NAVIGATE_BACK action', t => {
|
|
11
|
+
const state = reducer([], {type: NAVIGATE_TO, payload: 'loader'});
|
|
12
|
+
t.deepEqual(state, ['loader']);
|
|
13
|
+
|
|
14
|
+
const updatedState = reducer(state, {type: NAVIGATE_TO, payload: 'skills'});
|
|
15
|
+
t.deepEqual(updatedState, ['loader', 'skills']);
|
|
16
|
+
|
|
17
|
+
const _updatedState = reducer(updatedState, {type: NAVIGATE_BACK});
|
|
18
|
+
t.deepEqual(_updatedState, ['loader']);
|
|
19
|
+
});
|
|
@@ -6,7 +6,7 @@ import {toJSON} from './tools/fetch-responses';
|
|
|
6
6
|
|
|
7
7
|
export const fetchSlide = async (slideRef: string, token: string): Promise<SlideFromAPI | void> => {
|
|
8
8
|
const {host}: JWT = decode(token);
|
|
9
|
-
const response = await crossFetch(`${host}/api/v2/slide/${slideRef}`, {
|
|
9
|
+
const response = await crossFetch(`${host}/api/v2/slide/${slideRef}/parentContentTitle`, {
|
|
10
10
|
headers: {authorization: token}
|
|
11
11
|
});
|
|
12
12
|
|
package/src/services/index.ts
CHANGED
|
@@ -2,9 +2,11 @@ import {Services} from '../types/common';
|
|
|
2
2
|
import {fetchSkills} from './fetch-skills';
|
|
3
3
|
import {postProgression} from './post-progression';
|
|
4
4
|
import {fetchSlide} from './fetch-slide';
|
|
5
|
+
import {postAnswer} from './post-answer';
|
|
5
6
|
|
|
6
7
|
export const getServices = (): Services => ({
|
|
7
8
|
fetchSkills,
|
|
8
9
|
fetchSlide,
|
|
9
|
-
postProgression
|
|
10
|
+
postProgression,
|
|
11
|
+
postAnswer
|
|
10
12
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
|
|
4
|
+
import {JWT, ProgressionFromAPI} from '../types/common';
|
|
5
|
+
import {toJSON} from './tools/fetch-responses';
|
|
6
|
+
|
|
7
|
+
export const postAnswer = async (
|
|
8
|
+
skillRef: string,
|
|
9
|
+
token: string,
|
|
10
|
+
progressionId: string,
|
|
11
|
+
answer: string[]
|
|
12
|
+
): Promise<ProgressionFromAPI> => {
|
|
13
|
+
const {host}: JWT = decode(token);
|
|
14
|
+
const response = await crossFetch(`${host}/api/v2/progressions/${progressionId}/answers`, {
|
|
15
|
+
method: 'post',
|
|
16
|
+
headers: {authorization: token},
|
|
17
|
+
body: JSON.stringify({
|
|
18
|
+
content: {
|
|
19
|
+
ref: skillRef,
|
|
20
|
+
type: 'slide'
|
|
21
|
+
},
|
|
22
|
+
answer
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return toJSON<ProgressionFromAPI>(response);
|
|
27
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import nock from 'nock';
|
|
3
|
+
import {qcmDragSlide} from '../../views/slides/test/fixtures/qcm-drag';
|
|
4
|
+
import {fetchSlide} from '../fetch-slide';
|
|
5
|
+
|
|
6
|
+
test.before(() => {
|
|
7
|
+
nock('http://localhost:3000')
|
|
8
|
+
.get('/api/v2/slide/sli_123546/parentContentTitle')
|
|
9
|
+
.reply(200, qcmDragSlide);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test.after(() => {
|
|
13
|
+
nock.cleanAll();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('should fetch a slide with the parentTitleContent info successfully', async t => {
|
|
17
|
+
const token = process.env.API_TEST_TOKEN || '';
|
|
18
|
+
const slide = await fetchSlide('sli_123546', token);
|
|
19
|
+
t.deepEqual(qcmDragSlide, slide);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('should reject if a bad token is passed', async t => {
|
|
23
|
+
const badToken = 'token is not a jwt';
|
|
24
|
+
const error = await t.throwsAsync(() => fetchSlide('sli_123546', badToken));
|
|
25
|
+
|
|
26
|
+
t.is(
|
|
27
|
+
error?.message,
|
|
28
|
+
"Invalid token specified: Cannot read properties of undefined (reading 'replace')"
|
|
29
|
+
);
|
|
30
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import nock from 'nock';
|
|
3
|
+
import type {ProgressionFromAPI} from '../../types/common';
|
|
4
|
+
import {postAnswer} from '../post-answer';
|
|
5
|
+
|
|
6
|
+
const progressionId = '123456789123';
|
|
7
|
+
const skillRef = '_skill-ref';
|
|
8
|
+
const answer = ['Lister vos tâches pour vous libérer l’esprit', 'Vous isoler dans un lieu calme'];
|
|
9
|
+
|
|
10
|
+
const result: ProgressionFromAPI = {
|
|
11
|
+
content: {
|
|
12
|
+
type: 'skill',
|
|
13
|
+
ref: skillRef
|
|
14
|
+
},
|
|
15
|
+
engine: {
|
|
16
|
+
ref: 'review'
|
|
17
|
+
},
|
|
18
|
+
_id: '123456123456',
|
|
19
|
+
state: {
|
|
20
|
+
allAnswers: [
|
|
21
|
+
{
|
|
22
|
+
slideRef: 'sli_NkvrWPFF2',
|
|
23
|
+
isCorrect: true,
|
|
24
|
+
answer
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
isCorrect: true,
|
|
28
|
+
nextContent: {
|
|
29
|
+
type: 'slide',
|
|
30
|
+
ref: 'sli_NJ3m5KtWh'
|
|
31
|
+
},
|
|
32
|
+
pendingSlides: [],
|
|
33
|
+
slides: ['sli_NkvrWPFF2'],
|
|
34
|
+
content: {
|
|
35
|
+
ref: 'sli_NkvrWPFF2',
|
|
36
|
+
type: 'slide'
|
|
37
|
+
},
|
|
38
|
+
step: {
|
|
39
|
+
current: 2
|
|
40
|
+
},
|
|
41
|
+
stars: 4
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
test.before(() => {
|
|
46
|
+
const moocApi = nock('http://localhost:3000');
|
|
47
|
+
moocApi.post(`/api/v2/progressions/${progressionId}/answers`).reply(200, result);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test.after(() => {
|
|
51
|
+
nock.cleanAll();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('should post the answers successfully', async t => {
|
|
55
|
+
const token = process.env.API_TEST_TOKEN || '';
|
|
56
|
+
const progression = await postAnswer(skillRef, token, progressionId, answer);
|
|
57
|
+
t.deepEqual(result, progression);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('should reject bad token', async t => {
|
|
61
|
+
const badToken = 'token is not a jwt';
|
|
62
|
+
const error = await t.throwsAsync(() => postAnswer(skillRef, badToken, progressionId, answer));
|
|
63
|
+
|
|
64
|
+
t.is(
|
|
65
|
+
error?.message,
|
|
66
|
+
"Invalid token specified: Cannot read properties of undefined (reading 'replace')"
|
|
67
|
+
);
|
|
68
|
+
});
|
|
@@ -6,16 +6,26 @@ import {postProgression} from '../post-progression';
|
|
|
6
6
|
const skillRef = '_skill-ref';
|
|
7
7
|
const result: ProgressionFromAPI = {
|
|
8
8
|
_id: '123456123456',
|
|
9
|
+
content: {
|
|
10
|
+
ref: '_skill-ref',
|
|
11
|
+
type: 'skill'
|
|
12
|
+
},
|
|
13
|
+
engine: {
|
|
14
|
+
ref: 'review'
|
|
15
|
+
},
|
|
9
16
|
state: {
|
|
17
|
+
allAnswers: [],
|
|
10
18
|
isCorrect: true,
|
|
11
|
-
step: {
|
|
12
|
-
current: 1
|
|
13
|
-
},
|
|
14
19
|
nextContent: {
|
|
15
20
|
type: 'slide',
|
|
16
21
|
ref: 'sli_NJ3m5KtWh'
|
|
17
22
|
},
|
|
18
|
-
pendingSlides: []
|
|
23
|
+
pendingSlides: [],
|
|
24
|
+
slides: [],
|
|
25
|
+
step: {
|
|
26
|
+
current: 1
|
|
27
|
+
},
|
|
28
|
+
stars: 0
|
|
19
29
|
}
|
|
20
30
|
};
|
|
21
31
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {freeTextSlide} from '../../views/slides/test/fixtures/free-text';
|
|
2
2
|
import {Services} from '../../types/common';
|
|
3
3
|
|
|
4
4
|
export const services: Services = {
|
|
@@ -19,21 +19,63 @@ export const services: Services = {
|
|
|
19
19
|
]);
|
|
20
20
|
},
|
|
21
21
|
fetchSlide: ref => {
|
|
22
|
-
return Promise.resolve({...
|
|
22
|
+
return Promise.resolve({...freeTextSlide, universalRef: ref, id: ref});
|
|
23
23
|
},
|
|
24
24
|
postProgression: () => {
|
|
25
25
|
return Promise.resolve({
|
|
26
26
|
_id: '62b1d1087aa12f00253f40ee',
|
|
27
|
+
content: {
|
|
28
|
+
ref: '_skill-ref',
|
|
29
|
+
type: 'skill'
|
|
30
|
+
},
|
|
31
|
+
engine: {
|
|
32
|
+
ref: 'review'
|
|
33
|
+
},
|
|
27
34
|
state: {
|
|
35
|
+
allAnswers: [],
|
|
36
|
+
isCorrect: true,
|
|
37
|
+
nextContent: {
|
|
38
|
+
ref: 'sli_N1XACJobn',
|
|
39
|
+
type: 'slide'
|
|
40
|
+
},
|
|
28
41
|
pendingSlides: [],
|
|
42
|
+
slides: [],
|
|
29
43
|
step: {
|
|
30
44
|
current: 1
|
|
31
45
|
},
|
|
46
|
+
stars: 0
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
postAnswer: () => {
|
|
51
|
+
return Promise.resolve({
|
|
52
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
53
|
+
content: {
|
|
54
|
+
ref: '_skill-ref',
|
|
55
|
+
type: 'skill'
|
|
56
|
+
},
|
|
57
|
+
engine: {
|
|
58
|
+
ref: 'review'
|
|
59
|
+
},
|
|
60
|
+
state: {
|
|
61
|
+
allAnswers: [
|
|
62
|
+
{
|
|
63
|
+
slideRef: 'sli_N1XACJobn',
|
|
64
|
+
isCorrect: true,
|
|
65
|
+
answer: ['Le créateur peut fixer un pourcentage pour chaque transaction future']
|
|
66
|
+
}
|
|
67
|
+
],
|
|
32
68
|
isCorrect: true,
|
|
33
69
|
nextContent: {
|
|
34
|
-
ref: '
|
|
70
|
+
ref: 'sli_VkSQroQnx',
|
|
35
71
|
type: 'slide'
|
|
36
|
-
}
|
|
72
|
+
},
|
|
73
|
+
pendingSlides: [],
|
|
74
|
+
slides: ['sli_N1XACJobn'],
|
|
75
|
+
step: {
|
|
76
|
+
current: 2
|
|
77
|
+
},
|
|
78
|
+
stars: 4
|
|
37
79
|
}
|
|
38
80
|
});
|
|
39
81
|
}
|
package/src/types/common.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {SlideIndexes} from '../common';
|
|
2
|
+
import {AnswerUI} from './slides';
|
|
2
3
|
|
|
3
4
|
// TODO use type from components
|
|
4
5
|
type TemplateContextValues = {
|
|
@@ -24,25 +25,25 @@ type BaseContent = {
|
|
|
24
25
|
choices: ChoiceFromAPI[];
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
type
|
|
28
|
+
type BaseQuestion = {
|
|
28
29
|
header?: string;
|
|
29
30
|
content: BaseContent;
|
|
30
31
|
explanation?: string;
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
export type QcmQuestion =
|
|
34
|
+
export type QcmQuestion = BaseQuestion & {
|
|
34
35
|
type: 'qcm';
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
export type QcmGraphicQuestion =
|
|
38
|
+
export type QcmGraphicQuestion = BaseQuestion & {
|
|
38
39
|
type: 'qcmGraphic';
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
export type QcmDragQuestion =
|
|
42
|
+
export type QcmDragQuestion = BaseQuestion & {
|
|
42
43
|
type: 'qcmDrag';
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
export type BasicQuestion = Omit<
|
|
46
|
+
export type BasicQuestion = Omit<BaseQuestion, 'content'> & {
|
|
46
47
|
type: 'basic';
|
|
47
48
|
content: {
|
|
48
49
|
media?: unknown;
|
|
@@ -52,7 +53,7 @@ export type BasicQuestion = Omit<Question, 'content'> & {
|
|
|
52
53
|
};
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
export type SliderQuestion = Omit<
|
|
56
|
+
export type SliderQuestion = Omit<BaseQuestion, 'content'> & {
|
|
56
57
|
content: {
|
|
57
58
|
media?: unknown;
|
|
58
59
|
unitLabel: string;
|
|
@@ -63,42 +64,70 @@ export type SliderQuestion = Omit<Question, 'content'> & {
|
|
|
63
64
|
type: 'slider';
|
|
64
65
|
};
|
|
65
66
|
|
|
66
|
-
export type TemplateQuestion = Omit<
|
|
67
|
+
export type TemplateQuestion = Omit<BaseQuestion, 'content'> & {
|
|
67
68
|
content: BaseContent & {
|
|
68
69
|
template: string;
|
|
69
70
|
};
|
|
70
71
|
type: 'template';
|
|
71
72
|
};
|
|
72
73
|
|
|
74
|
+
export type Question =
|
|
75
|
+
| QcmQuestion
|
|
76
|
+
| QcmGraphicQuestion
|
|
77
|
+
| QcmDragQuestion
|
|
78
|
+
| BasicQuestion
|
|
79
|
+
| SliderQuestion
|
|
80
|
+
| TemplateQuestion;
|
|
81
|
+
|
|
73
82
|
export type SlideFromAPI = {
|
|
74
|
-
question:
|
|
75
|
-
| QcmQuestion
|
|
76
|
-
| QcmGraphicQuestion
|
|
77
|
-
| QcmDragQuestion
|
|
78
|
-
| BasicQuestion
|
|
79
|
-
| SliderQuestion
|
|
80
|
-
| TemplateQuestion;
|
|
83
|
+
question: Question;
|
|
81
84
|
klf: string;
|
|
82
85
|
universalRef: string;
|
|
83
86
|
tips?: string;
|
|
84
87
|
clue?: string;
|
|
85
88
|
hasClue?: boolean;
|
|
86
|
-
id
|
|
89
|
+
id: string;
|
|
90
|
+
parentContentTitle: {
|
|
91
|
+
title: string;
|
|
92
|
+
type: 'chapter' | 'course';
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
type ProgressionAnswerItem = {
|
|
97
|
+
isCorrect: boolean;
|
|
98
|
+
slideRef: string;
|
|
99
|
+
answer: string[];
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type ProgressionState = {
|
|
103
|
+
allAnswers: ProgressionAnswerItem[];
|
|
104
|
+
content?: {
|
|
105
|
+
ref: string;
|
|
106
|
+
type: string;
|
|
107
|
+
};
|
|
108
|
+
isCorrect: boolean;
|
|
109
|
+
nextContent: {
|
|
110
|
+
type: 'success' | 'slide';
|
|
111
|
+
ref: 'successExitNode' | string;
|
|
112
|
+
};
|
|
113
|
+
pendingSlides: string[];
|
|
114
|
+
slides: string[];
|
|
115
|
+
step: {
|
|
116
|
+
current: number;
|
|
117
|
+
};
|
|
118
|
+
stars: number;
|
|
87
119
|
};
|
|
88
120
|
|
|
89
121
|
export type ProgressionFromAPI = {
|
|
90
122
|
_id: string;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
current: number;
|
|
95
|
-
};
|
|
96
|
-
nextContent: {
|
|
97
|
-
type: 'success' | 'slide';
|
|
98
|
-
ref: 'successExitNode' | string;
|
|
99
|
-
};
|
|
100
|
-
pendingSlides: [];
|
|
123
|
+
content: {
|
|
124
|
+
type: 'skill';
|
|
125
|
+
ref: string;
|
|
101
126
|
};
|
|
127
|
+
engine: {
|
|
128
|
+
ref: 'review';
|
|
129
|
+
};
|
|
130
|
+
state: ProgressionState;
|
|
102
131
|
};
|
|
103
132
|
|
|
104
133
|
export type Skill = {
|
|
@@ -112,6 +141,12 @@ export type Services = {
|
|
|
112
141
|
fetchSkills(token: string): Promise<Skill[]>;
|
|
113
142
|
fetchSlide(slideRef: string, token: string): Promise<SlideFromAPI | void>;
|
|
114
143
|
postProgression(skillRef: string, token: string): Promise<ProgressionFromAPI>;
|
|
144
|
+
postAnswer(
|
|
145
|
+
skillRef: string,
|
|
146
|
+
token: string,
|
|
147
|
+
progressionId: string,
|
|
148
|
+
answer: string[]
|
|
149
|
+
): Promise<ProgressionFromAPI>;
|
|
115
150
|
};
|
|
116
151
|
|
|
117
152
|
export type Options = {
|
|
@@ -137,31 +172,33 @@ export type JWT = {
|
|
|
137
172
|
host: string;
|
|
138
173
|
};
|
|
139
174
|
|
|
140
|
-
// -----------------------------------------------------------------------------
|
|
141
175
|
type SlideUIAnimations = 'unstack' | 'restack';
|
|
142
|
-
|
|
176
|
+
|
|
177
|
+
export type NextUISlide = {
|
|
178
|
+
questionText?: string;
|
|
179
|
+
answerUI?: AnswerUI;
|
|
143
180
|
hidden?: boolean;
|
|
144
|
-
position
|
|
181
|
+
position?: number;
|
|
145
182
|
animationType?: SlideUIAnimations;
|
|
146
183
|
isCorrect?: boolean;
|
|
147
184
|
endReview?: boolean;
|
|
148
|
-
nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
|
|
149
185
|
};
|
|
150
186
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
187
|
+
export type UISlide = {
|
|
188
|
+
questionText?: string;
|
|
189
|
+
answerUI?: AnswerUI;
|
|
190
|
+
hidden?: boolean;
|
|
191
|
+
position: number;
|
|
192
|
+
animationType?: SlideUIAnimations;
|
|
193
|
+
isCorrect?: boolean;
|
|
194
|
+
endReview?: boolean;
|
|
195
|
+
nextContent?: NextUISlide;
|
|
196
|
+
};
|
|
156
197
|
|
|
157
|
-
export type IconValue = keyof typeof ICON_VALUES;
|
|
158
198
|
export type FinishedSlides = {
|
|
159
|
-
|
|
160
|
-
[key: number]: true;
|
|
199
|
+
[key in SlideIndexes]?: true;
|
|
161
200
|
};
|
|
162
201
|
|
|
163
|
-
// -----------------------------------------------------------------------------
|
|
164
|
-
|
|
165
202
|
export type WithRequired<T, K extends keyof T> = T & {
|
|
166
203
|
// the "-" is a Mapping Modifier, removes optionality from a prop
|
|
167
204
|
[P in K]-?: T[P];
|
package/src/types/slides.ts
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {StoreState} from '../../reducers';
|
|
2
|
+
|
|
3
|
+
type SkillCard = {
|
|
4
|
+
'aria-label': string;
|
|
5
|
+
skillTitle: string;
|
|
6
|
+
skillAriaLabel: string;
|
|
7
|
+
buttonLabel: string;
|
|
8
|
+
buttonAriaLabel: string;
|
|
9
|
+
reviseLabel: string;
|
|
10
|
+
reviseAriaLabel: string;
|
|
11
|
+
isCustom: boolean;
|
|
12
|
+
onClick: Function;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type NoSkillsProps = {
|
|
16
|
+
titleNoSkills: string;
|
|
17
|
+
textNoSkills: string;
|
|
18
|
+
iconSkillAriaLabel: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type SkillsProps = NoSkillsProps & {
|
|
22
|
+
'aria-label'?: string;
|
|
23
|
+
title: string;
|
|
24
|
+
isLoading?: boolean;
|
|
25
|
+
isLoadingAriaLabel: string;
|
|
26
|
+
listSkills: SkillCard[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export {SkillsProps};
|
|
30
|
+
|
|
31
|
+
export const mapStateToSkillsProps = (state: StoreState): SkillsProps | null => {
|
|
32
|
+
if (!state.data.skills) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
title: '@todo title',
|
|
38
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
39
|
+
textNoSkills: '@todo textNoSkills',
|
|
40
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
41
|
+
isLoading: false,
|
|
42
|
+
isLoadingAriaLabel: '@todo loading',
|
|
43
|
+
listSkills: state.data.skills.map(skill => ({
|
|
44
|
+
'aria-label': '',
|
|
45
|
+
isCustom: skill.custom,
|
|
46
|
+
skillTitle: skill.name,
|
|
47
|
+
skillAriaLabel: '@todo skill aria label',
|
|
48
|
+
buttonLabel: '@todo button',
|
|
49
|
+
buttonAriaLabel: '@todo button aria label',
|
|
50
|
+
reviseLabel: '@todo revise',
|
|
51
|
+
reviseAriaLabel: '@todo revise aria label',
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
onClick: () => console.log('@todo plug dispatcher select skill')
|
|
54
|
+
}))
|
|
55
|
+
};
|
|
56
|
+
};
|