@coorpacademy/app-review 0.1.15 → 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 +22 -19
- package/es/actions/api/post-progression.d.ts +4 -6
- package/es/actions/api/post-progression.js +13 -8
- 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.d.ts +1 -0
- package/es/actions/api/test/post-progression.test.js +102 -0
- package/es/actions/ui/answers.d.ts +7 -0
- package/es/actions/ui/answers.js +7 -0
- package/es/fixtures/temp-fixture.d.ts +1 -1
- package/es/index.js +10 -16
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/slides.d.ts +2 -2
- package/es/reducers/data/slides.js +5 -1
- package/es/reducers/data/test/progression.test.d.ts +1 -0
- package/es/reducers/data/test/progression.test.js +38 -0
- package/es/reducers/data/test/skills.test.d.ts +1 -0
- package/es/reducers/data/test/skills.test.js +12 -0
- package/es/reducers/data/test/slides.test.d.ts +1 -0
- package/es/reducers/data/test/slides.test.js +20 -0
- package/es/reducers/data/test/token.test.d.ts +1 -0
- package/es/reducers/data/test/token.test.js +11 -0
- package/es/reducers/index.d.ts +2 -2
- package/es/reducers/ui/answers.d.ts +4 -0
- package/es/reducers/ui/answers.js +13 -0
- package/es/reducers/ui/index.d.ts +4 -4
- package/es/reducers/ui/index.js +2 -2
- package/es/reducers/ui/test/answers.test.d.ts +1 -0
- 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 +9 -1
- package/es/test/util/services.mock.js +37 -7
- package/es/types/common.d.ts +22 -8
- package/es/views/slides/index.d.ts +78 -2
- package/es/views/slides/index.js +70 -4
- 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/{lib/helpers → es/views/slides}/test/fixtures/free-text.d.ts +1 -1
- package/es/views/slides/test/fixtures/free-text.js +38 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +1 -1
- package/es/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +1 -1
- package/es/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm.d.ts +1 -1
- package/es/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
- package/es/{helpers → views/slides}/test/fixtures/select-template.d.ts +1 -1
- package/es/views/slides/test/fixtures/select-template.js +92 -0
- package/es/{helpers → views/slides}/test/fixtures/slider.d.ts +1 -1
- package/es/views/slides/test/fixtures/slider.js +36 -0
- package/es/{helpers → views/slides}/test/fixtures/text-template.d.ts +1 -1
- package/es/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
- 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 +70 -20
- package/lib/actions/api/post-progression.d.ts +4 -6
- package/lib/actions/api/post-progression.js +63 -9
- 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/ui/answers.d.ts +7 -0
- package/lib/actions/ui/answers.js +9 -0
- package/lib/fixtures/temp-fixture.d.ts +1 -1
- package/lib/index.js +21 -18
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/slides.d.ts +2 -2
- package/lib/reducers/data/slides.js +5 -1
- 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 +2 -2
- package/lib/reducers/ui/answers.d.ts +4 -0
- package/lib/reducers/ui/answers.js +14 -0
- package/lib/reducers/ui/index.d.ts +4 -4
- package/lib/reducers/ui/index.js +2 -2
- 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 +9 -1
- package/lib/test/util/services.mock.js +37 -7
- package/lib/types/common.d.ts +22 -8
- package/lib/views/slides/index.d.ts +78 -2
- package/lib/views/slides/index.js +70 -4
- 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/{es/helpers → lib/views/slides}/test/fixtures/free-text.d.ts +1 -1
- package/lib/views/slides/test/fixtures/free-text.js +38 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +1 -1
- package/lib/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +1 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm.d.ts +1 -1
- package/lib/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
- package/lib/{helpers → views/slides}/test/fixtures/select-template.d.ts +1 -1
- package/lib/views/slides/test/fixtures/select-template.js +92 -0
- package/lib/{helpers → views/slides}/test/fixtures/slider.d.ts +1 -1
- package/lib/views/slides/test/fixtures/slider.js +36 -0
- package/lib/{helpers → views/slides}/test/fixtures/text-template.d.ts +1 -1
- package/lib/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
- 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 +3 -3
- package/src/actions/api/fetch-skills.ts +12 -12
- package/src/actions/api/fetch-slide.ts +33 -29
- package/src/actions/api/post-progression.ts +18 -21
- 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/ui/answers.ts +16 -0
- package/src/fixtures/temp-fixture.ts +1 -1
- package/src/index.tsx +14 -29
- package/src/reducers/data/index.ts +1 -1
- package/src/reducers/data/slides.ts +11 -2
- 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/index.ts +3 -3
- 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 +9 -1
- package/src/test/util/services.mock.ts +37 -7
- package/src/types/common.ts +34 -14
- package/src/views/slides/index.ts +164 -5
- 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 +6 -2
- 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 +6 -2
- package/src/{helpers → views/slides}/test/map-api-slide-to-ui.test.ts +21 -10
- package/es/helpers/map-api-slide-to-ui.d.ts +0 -11
- package/es/helpers/map-api-slide-to-ui.js +0 -193
- package/es/helpers/test/fixtures/free-text.js +0 -30
- package/es/helpers/test/fixtures/qcm-drag.js +0 -112
- package/es/helpers/test/fixtures/qcm-graphic.js +0 -76
- package/es/helpers/test/fixtures/select-template.js +0 -94
- package/es/helpers/test/fixtures/slider.js +0 -33
- package/es/reducers/ui/slides.d.ts +0 -9
- package/es/reducers/ui/slides.js +0 -42
- package/es/types/views/slides.d.ts +0 -74
- package/es/types/views/slides.js +0 -6
- package/lib/helpers/map-api-slide-to-ui.d.ts +0 -11
- package/lib/helpers/map-api-slide-to-ui.js +0 -201
- package/lib/helpers/test/fixtures/free-text.js +0 -30
- package/lib/helpers/test/fixtures/qcm-drag.js +0 -112
- package/lib/helpers/test/fixtures/qcm-graphic.js +0 -76
- package/lib/helpers/test/fixtures/select-template.js +0 -94
- package/lib/helpers/test/fixtures/slider.js +0 -33
- package/lib/reducers/ui/slides.d.ts +0 -9
- package/lib/reducers/ui/slides.js +0 -43
- package/lib/types/views/slides.d.ts +0 -74
- package/lib/types/views/slides.js +0 -6
- package/src/helpers/map-api-slide-to-ui.ts +0 -279
- package/src/helpers/test/fixtures/free-text.ts +0 -33
- package/src/helpers/test/fixtures/qcm-drag.ts +0 -115
- package/src/helpers/test/fixtures/qcm-graphic.ts +0 -79
- package/src/helpers/test/fixtures/select-template.ts +0 -97
- package/src/helpers/test/fixtures/slider.ts +0 -36
- package/src/reducers/ui/slides.ts +0 -58
- package/src/types/views/slides.ts +0 -90
- /package/es/{helpers/test/map-api-slide-to-ui.test.d.ts → actions/api/test/fetch-skills.test.d.ts} +0 -0
- /package/{lib/helpers/test/map-api-slide-to-ui.test.d.ts → es/actions/api/test/fetch-slide.test.d.ts} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { CurrentSlideRefState } from './current-slide-ref';
|
|
2
2
|
import { NavigationState } from './navigation';
|
|
3
|
-
import {
|
|
3
|
+
import { AnswerState } from './answers';
|
|
4
4
|
export declare type UIState = {
|
|
5
5
|
currentSlideRef: CurrentSlideRefState;
|
|
6
6
|
navigation: NavigationState;
|
|
7
|
-
|
|
7
|
+
answers: AnswerState;
|
|
8
8
|
};
|
|
9
9
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
10
10
|
currentSlideRef: string;
|
|
11
11
|
navigation: NavigationState;
|
|
12
|
-
|
|
13
|
-
}>, import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack>;
|
|
12
|
+
answers: AnswerState;
|
|
13
|
+
}>, import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditBasicAction>;
|
|
14
14
|
export default _default;
|
package/es/reducers/ui/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { combineReducers } from 'redux';
|
|
2
2
|
import currentSlideRef from './current-slide-ref';
|
|
3
3
|
import navigation from './navigation';
|
|
4
|
-
import
|
|
4
|
+
import answers from './answers';
|
|
5
5
|
export default combineReducers({
|
|
6
6
|
currentSlideRef,
|
|
7
7
|
navigation,
|
|
8
|
-
|
|
8
|
+
answers
|
|
9
9
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../answers';
|
|
3
|
+
import { EDIT_BASIC } from '../../../actions/ui/answers';
|
|
4
|
+
test('should have inital value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.deepEqual(state, []);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of EDIT_BASIC action', t => {
|
|
9
|
+
const state = reducer([], { type: EDIT_BASIC, payload: ['value'] });
|
|
10
|
+
t.deepEqual(state, ['value']);
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../current-slide-ref';
|
|
3
|
+
import { SET_CURRENT_SLIDE } from '../../../actions/ui/slides';
|
|
4
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
5
|
+
test('should have inital value', t => {
|
|
6
|
+
const state = reducer(undefined, {});
|
|
7
|
+
t.is(state, '');
|
|
8
|
+
});
|
|
9
|
+
test('should set the value of SET_CURRENT_SLIDE action', t => {
|
|
10
|
+
const state = reducer('', { type: SET_CURRENT_SLIDE, payload: freeTextSlide });
|
|
11
|
+
t.is(state, 'sli_VJYjJnJhg');
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../navigation';
|
|
3
|
+
import { NAVIGATE_TO, NAVIGATE_BACK } from '../../../actions/ui/navigation';
|
|
4
|
+
test('should have inital value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.deepEqual(state, []);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of NAVIGATE_TO and NAVIGATE_BACK action', t => {
|
|
9
|
+
const state = reducer([], { type: NAVIGATE_TO, payload: 'loader' });
|
|
10
|
+
t.deepEqual(state, ['loader']);
|
|
11
|
+
const updatedState = reducer(state, { type: NAVIGATE_TO, payload: 'skills' });
|
|
12
|
+
t.deepEqual(updatedState, ['loader', 'skills']);
|
|
13
|
+
const _updatedState = reducer(updatedState, { type: NAVIGATE_BACK });
|
|
14
|
+
t.deepEqual(_updatedState, ['loader']);
|
|
15
|
+
});
|
|
@@ -3,7 +3,7 @@ import decode from 'jwt-decode';
|
|
|
3
3
|
import { toJSON } from './tools/fetch-responses';
|
|
4
4
|
export const fetchSlide = async (slideRef, token) => {
|
|
5
5
|
const { host } = decode(token);
|
|
6
|
-
const response = await crossFetch(`${host}/api/v2/slide/${slideRef}`, {
|
|
6
|
+
const response = await crossFetch(`${host}/api/v2/slide/${slideRef}/parentContentTitle`, {
|
|
7
7
|
headers: { authorization: token }
|
|
8
8
|
});
|
|
9
9
|
const slide = (await toJSON(response));
|
package/es/services/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { fetchSkills } from './fetch-skills';
|
|
2
2
|
import { postProgression } from './post-progression';
|
|
3
3
|
import { fetchSlide } from './fetch-slide';
|
|
4
|
+
import { postAnswer } from './post-answer';
|
|
4
5
|
export const getServices = () => ({
|
|
5
6
|
fetchSkills,
|
|
6
7
|
fetchSlide,
|
|
7
|
-
postProgression
|
|
8
|
+
postProgression,
|
|
9
|
+
postAnswer
|
|
8
10
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const postAnswer = async (skillRef, token, progressionId, answer) => {
|
|
5
|
+
const { host } = decode(token);
|
|
6
|
+
const response = await crossFetch(`${host}/api/v2/progressions/${progressionId}/answers`, {
|
|
7
|
+
method: 'post',
|
|
8
|
+
headers: { authorization: token },
|
|
9
|
+
body: JSON.stringify({
|
|
10
|
+
content: {
|
|
11
|
+
ref: skillRef,
|
|
12
|
+
type: 'slide'
|
|
13
|
+
},
|
|
14
|
+
answer
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
return toJSON(response);
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
test.before(() => {
|
|
6
|
+
nock('http://localhost:3000')
|
|
7
|
+
.get('/api/v2/slide/sli_123546/parentContentTitle')
|
|
8
|
+
.reply(200, qcmDragSlide);
|
|
9
|
+
});
|
|
10
|
+
test.after(() => {
|
|
11
|
+
nock.cleanAll();
|
|
12
|
+
});
|
|
13
|
+
test('should fetch a slide with the parentTitleContent info successfully', async (t) => {
|
|
14
|
+
const token = process.env.API_TEST_TOKEN || '';
|
|
15
|
+
const slide = await fetchSlide('sli_123546', token);
|
|
16
|
+
t.deepEqual(qcmDragSlide, slide);
|
|
17
|
+
});
|
|
18
|
+
test('should reject if a bad token is passed', async (t) => {
|
|
19
|
+
const badToken = 'token is not a jwt';
|
|
20
|
+
const error = await t.throwsAsync(() => fetchSlide('sli_123546', badToken));
|
|
21
|
+
t.is(error?.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import nock from 'nock';
|
|
3
|
+
import { postAnswer } from '../post-answer';
|
|
4
|
+
const progressionId = '123456789123';
|
|
5
|
+
const skillRef = '_skill-ref';
|
|
6
|
+
const answer = ['Lister vos tâches pour vous libérer l’esprit', 'Vous isoler dans un lieu calme'];
|
|
7
|
+
const result = {
|
|
8
|
+
content: {
|
|
9
|
+
type: 'skill',
|
|
10
|
+
ref: skillRef
|
|
11
|
+
},
|
|
12
|
+
engine: {
|
|
13
|
+
ref: 'review'
|
|
14
|
+
},
|
|
15
|
+
_id: '123456123456',
|
|
16
|
+
state: {
|
|
17
|
+
allAnswers: [
|
|
18
|
+
{
|
|
19
|
+
slideRef: 'sli_NkvrWPFF2',
|
|
20
|
+
isCorrect: true,
|
|
21
|
+
answer
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
isCorrect: true,
|
|
25
|
+
nextContent: {
|
|
26
|
+
type: 'slide',
|
|
27
|
+
ref: 'sli_NJ3m5KtWh'
|
|
28
|
+
},
|
|
29
|
+
pendingSlides: [],
|
|
30
|
+
slides: ['sli_NkvrWPFF2'],
|
|
31
|
+
content: {
|
|
32
|
+
ref: 'sli_NkvrWPFF2',
|
|
33
|
+
type: 'slide'
|
|
34
|
+
},
|
|
35
|
+
step: {
|
|
36
|
+
current: 2
|
|
37
|
+
},
|
|
38
|
+
stars: 4
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
test.before(() => {
|
|
42
|
+
const moocApi = nock('http://localhost:3000');
|
|
43
|
+
moocApi.post(`/api/v2/progressions/${progressionId}/answers`).reply(200, result);
|
|
44
|
+
});
|
|
45
|
+
test.after(() => {
|
|
46
|
+
nock.cleanAll();
|
|
47
|
+
});
|
|
48
|
+
test('should post the answers successfully', async (t) => {
|
|
49
|
+
const token = process.env.API_TEST_TOKEN || '';
|
|
50
|
+
const progression = await postAnswer(skillRef, token, progressionId, answer);
|
|
51
|
+
t.deepEqual(result, progression);
|
|
52
|
+
});
|
|
53
|
+
test('should reject bad token', async (t) => {
|
|
54
|
+
const badToken = 'token is not a jwt';
|
|
55
|
+
const error = await t.throwsAsync(() => postAnswer(skillRef, badToken, progressionId, answer));
|
|
56
|
+
t.is(error?.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|
|
57
|
+
});
|
|
@@ -4,6 +4,13 @@ import { postProgression } from '../post-progression';
|
|
|
4
4
|
const skillRef = '_skill-ref';
|
|
5
5
|
const result = {
|
|
6
6
|
_id: '123456123456',
|
|
7
|
+
content: {
|
|
8
|
+
ref: '_skill-ref',
|
|
9
|
+
type: 'skill'
|
|
10
|
+
},
|
|
11
|
+
engine: {
|
|
12
|
+
ref: 'review'
|
|
13
|
+
},
|
|
7
14
|
state: {
|
|
8
15
|
allAnswers: [],
|
|
9
16
|
isCorrect: true,
|
|
@@ -15,7 +22,8 @@ const result = {
|
|
|
15
22
|
slides: [],
|
|
16
23
|
step: {
|
|
17
24
|
current: 1
|
|
18
|
-
}
|
|
25
|
+
},
|
|
26
|
+
stars: 0
|
|
19
27
|
}
|
|
20
28
|
};
|
|
21
29
|
test.before(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { freeTextSlide } from '../../views/slides/test/fixtures/free-text';
|
|
2
2
|
export const services = {
|
|
3
3
|
fetchSkills: () => {
|
|
4
4
|
return Promise.resolve([
|
|
@@ -7,20 +7,17 @@ export const services = {
|
|
|
7
7
|
slidesToReview: 2,
|
|
8
8
|
name: 'skill-test',
|
|
9
9
|
custom: false
|
|
10
|
-
// TODO parentContentTitle
|
|
11
10
|
},
|
|
12
11
|
{
|
|
13
12
|
skillRef: '_skill-ref-2',
|
|
14
13
|
slidesToReview: 2,
|
|
15
14
|
name: 'skill-test-2',
|
|
16
|
-
custom: true
|
|
17
|
-
parentContentTitle: 'parentContentTitle 2'
|
|
18
|
-
// TODO parentContentTitle
|
|
15
|
+
custom: true
|
|
19
16
|
}
|
|
20
17
|
]);
|
|
21
18
|
},
|
|
22
19
|
fetchSlide: ref => {
|
|
23
|
-
return Promise.resolve({ ...
|
|
20
|
+
return Promise.resolve({ ...freeTextSlide, universalRef: ref, id: ref });
|
|
24
21
|
},
|
|
25
22
|
postProgression: () => {
|
|
26
23
|
return Promise.resolve({
|
|
@@ -43,7 +40,40 @@ export const services = {
|
|
|
43
40
|
slides: [],
|
|
44
41
|
step: {
|
|
45
42
|
current: 1
|
|
46
|
-
}
|
|
43
|
+
},
|
|
44
|
+
stars: 0
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
postAnswer: () => {
|
|
49
|
+
return Promise.resolve({
|
|
50
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
51
|
+
content: {
|
|
52
|
+
ref: '_skill-ref',
|
|
53
|
+
type: 'skill'
|
|
54
|
+
},
|
|
55
|
+
engine: {
|
|
56
|
+
ref: 'review'
|
|
57
|
+
},
|
|
58
|
+
state: {
|
|
59
|
+
allAnswers: [
|
|
60
|
+
{
|
|
61
|
+
slideRef: 'sli_N1XACJobn',
|
|
62
|
+
isCorrect: true,
|
|
63
|
+
answer: ['Le créateur peut fixer un pourcentage pour chaque transaction future']
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
isCorrect: true,
|
|
67
|
+
nextContent: {
|
|
68
|
+
ref: 'sli_VkSQroQnx',
|
|
69
|
+
type: 'slide'
|
|
70
|
+
},
|
|
71
|
+
pendingSlides: [],
|
|
72
|
+
slides: ['sli_N1XACJobn'],
|
|
73
|
+
step: {
|
|
74
|
+
current: 2
|
|
75
|
+
},
|
|
76
|
+
stars: 4
|
|
47
77
|
}
|
|
48
78
|
});
|
|
49
79
|
}
|
package/es/types/common.d.ts
CHANGED
|
@@ -23,21 +23,21 @@ declare type BaseContent = {
|
|
|
23
23
|
media?: unknown;
|
|
24
24
|
choices: ChoiceFromAPI[];
|
|
25
25
|
};
|
|
26
|
-
declare type
|
|
26
|
+
declare type BaseQuestion = {
|
|
27
27
|
header?: string;
|
|
28
28
|
content: BaseContent;
|
|
29
29
|
explanation?: string;
|
|
30
30
|
};
|
|
31
|
-
export declare type QcmQuestion =
|
|
31
|
+
export declare type QcmQuestion = BaseQuestion & {
|
|
32
32
|
type: 'qcm';
|
|
33
33
|
};
|
|
34
|
-
export declare type QcmGraphicQuestion =
|
|
34
|
+
export declare type QcmGraphicQuestion = BaseQuestion & {
|
|
35
35
|
type: 'qcmGraphic';
|
|
36
36
|
};
|
|
37
|
-
export declare type QcmDragQuestion =
|
|
37
|
+
export declare type QcmDragQuestion = BaseQuestion & {
|
|
38
38
|
type: 'qcmDrag';
|
|
39
39
|
};
|
|
40
|
-
export declare type BasicQuestion = Omit<
|
|
40
|
+
export declare type BasicQuestion = Omit<BaseQuestion, 'content'> & {
|
|
41
41
|
type: 'basic';
|
|
42
42
|
content: {
|
|
43
43
|
media?: unknown;
|
|
@@ -46,7 +46,7 @@ export declare type BasicQuestion = Omit<Question, 'content'> & {
|
|
|
46
46
|
id: string;
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
-
export declare type SliderQuestion = Omit<
|
|
49
|
+
export declare type SliderQuestion = Omit<BaseQuestion, 'content'> & {
|
|
50
50
|
content: {
|
|
51
51
|
media?: unknown;
|
|
52
52
|
unitLabel: string;
|
|
@@ -56,20 +56,25 @@ export declare type SliderQuestion = Omit<Question, 'content'> & {
|
|
|
56
56
|
};
|
|
57
57
|
type: 'slider';
|
|
58
58
|
};
|
|
59
|
-
export declare type TemplateQuestion = Omit<
|
|
59
|
+
export declare type TemplateQuestion = Omit<BaseQuestion, 'content'> & {
|
|
60
60
|
content: BaseContent & {
|
|
61
61
|
template: string;
|
|
62
62
|
};
|
|
63
63
|
type: 'template';
|
|
64
64
|
};
|
|
65
|
+
export declare type Question = QcmQuestion | QcmGraphicQuestion | QcmDragQuestion | BasicQuestion | SliderQuestion | TemplateQuestion;
|
|
65
66
|
export declare type SlideFromAPI = {
|
|
66
|
-
question:
|
|
67
|
+
question: Question;
|
|
67
68
|
klf: string;
|
|
68
69
|
universalRef: string;
|
|
69
70
|
tips?: string;
|
|
70
71
|
clue?: string;
|
|
71
72
|
hasClue?: boolean;
|
|
72
73
|
id: string;
|
|
74
|
+
parentContentTitle: {
|
|
75
|
+
title: string;
|
|
76
|
+
type: 'chapter' | 'course';
|
|
77
|
+
};
|
|
73
78
|
};
|
|
74
79
|
declare type ProgressionAnswerItem = {
|
|
75
80
|
isCorrect: boolean;
|
|
@@ -92,9 +97,17 @@ export declare type ProgressionState = {
|
|
|
92
97
|
step: {
|
|
93
98
|
current: number;
|
|
94
99
|
};
|
|
100
|
+
stars: number;
|
|
95
101
|
};
|
|
96
102
|
export declare type ProgressionFromAPI = {
|
|
97
103
|
_id: string;
|
|
104
|
+
content: {
|
|
105
|
+
type: 'skill';
|
|
106
|
+
ref: string;
|
|
107
|
+
};
|
|
108
|
+
engine: {
|
|
109
|
+
ref: 'review';
|
|
110
|
+
};
|
|
98
111
|
state: ProgressionState;
|
|
99
112
|
};
|
|
100
113
|
export declare type Skill = {
|
|
@@ -107,6 +120,7 @@ export declare type Services = {
|
|
|
107
120
|
fetchSkills(token: string): Promise<Skill[]>;
|
|
108
121
|
fetchSlide(slideRef: string, token: string): Promise<SlideFromAPI | void>;
|
|
109
122
|
postProgression(skillRef: string, token: string): Promise<ProgressionFromAPI>;
|
|
123
|
+
postAnswer(skillRef: string, token: string, progressionId: string, answer: string[]): Promise<ProgressionFromAPI>;
|
|
110
124
|
};
|
|
111
125
|
export declare type Options = {
|
|
112
126
|
services: Services;
|
|
@@ -1,3 +1,79 @@
|
|
|
1
|
+
import { Dispatch } from 'redux';
|
|
2
|
+
import { UISlide } from '../../types/common';
|
|
3
|
+
import { SlideIndexes } from '../../common';
|
|
1
4
|
import { StoreState } from '../../reducers';
|
|
2
|
-
|
|
3
|
-
|
|
5
|
+
declare const ICON_VALUES: {
|
|
6
|
+
readonly right: "right";
|
|
7
|
+
readonly wrong: "wrong";
|
|
8
|
+
readonly 'no-answer': "no-answer";
|
|
9
|
+
};
|
|
10
|
+
declare type IconValue = keyof typeof ICON_VALUES;
|
|
11
|
+
declare type StepItem = {
|
|
12
|
+
current: boolean;
|
|
13
|
+
icon: IconValue;
|
|
14
|
+
value: string;
|
|
15
|
+
};
|
|
16
|
+
declare type SlidesStack = {
|
|
17
|
+
[key in SlideIndexes]: UISlide;
|
|
18
|
+
};
|
|
19
|
+
export declare type CorrectionPopinProps = {
|
|
20
|
+
klf: {
|
|
21
|
+
label: string;
|
|
22
|
+
onClick: Function;
|
|
23
|
+
tooltip: string;
|
|
24
|
+
};
|
|
25
|
+
information: {
|
|
26
|
+
label: string;
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
next: {
|
|
30
|
+
label: string;
|
|
31
|
+
ariaLabel: string;
|
|
32
|
+
};
|
|
33
|
+
successLabel: string;
|
|
34
|
+
failureLabel: string;
|
|
35
|
+
};
|
|
36
|
+
export declare type SlidesViewProps = {
|
|
37
|
+
header: {
|
|
38
|
+
mode: string;
|
|
39
|
+
skillName: string;
|
|
40
|
+
onQuitClick: Function;
|
|
41
|
+
'aria-label'?: string;
|
|
42
|
+
closeButtonAriaLabel: string;
|
|
43
|
+
steps: StepItem[];
|
|
44
|
+
};
|
|
45
|
+
stack: {
|
|
46
|
+
slides: SlidesStack;
|
|
47
|
+
validateButton: {
|
|
48
|
+
label: string;
|
|
49
|
+
disabled: boolean;
|
|
50
|
+
onClick: Function;
|
|
51
|
+
};
|
|
52
|
+
correctionPopinProps?: CorrectionPopinProps;
|
|
53
|
+
endReview: boolean;
|
|
54
|
+
};
|
|
55
|
+
reviewBackgroundAriaLabel?: string;
|
|
56
|
+
congratsProps?: {
|
|
57
|
+
'aria-label'?: string;
|
|
58
|
+
'data-name'?: string;
|
|
59
|
+
animationLottie: unknown;
|
|
60
|
+
title: string;
|
|
61
|
+
cardCongratsStar: unknown;
|
|
62
|
+
cardCongratsRank: unknown;
|
|
63
|
+
buttonRevising: {
|
|
64
|
+
'aria-label'?: string;
|
|
65
|
+
label: string;
|
|
66
|
+
onClick: Function;
|
|
67
|
+
type: string;
|
|
68
|
+
};
|
|
69
|
+
buttonRevisingSkill: {
|
|
70
|
+
'aria-label'?: string;
|
|
71
|
+
label: string;
|
|
72
|
+
onClick: Function;
|
|
73
|
+
type: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export declare const initialState: SlidesStack;
|
|
78
|
+
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch) => SlidesViewProps | null;
|
|
79
|
+
export {};
|
package/es/views/slides/index.js
CHANGED
|
@@ -1,5 +1,71 @@
|
|
|
1
|
+
import concat from 'lodash/fp/concat';
|
|
2
|
+
import get from 'lodash/fp/get';
|
|
3
|
+
import getOr from 'lodash/fp/getOr';
|
|
1
4
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
2
|
-
|
|
5
|
+
import pipe from 'lodash/fp/pipe';
|
|
6
|
+
import reduce from 'lodash/fp/reduce';
|
|
7
|
+
import set from 'lodash/fp/set';
|
|
8
|
+
import slice from 'lodash/fp/slice';
|
|
9
|
+
import toInteger from 'lodash/fp/toInteger';
|
|
10
|
+
import { mapApiSlideToUi } from './map-api-slide-to-ui';
|
|
11
|
+
const ICON_VALUES = {
|
|
12
|
+
right: 'right',
|
|
13
|
+
wrong: 'wrong',
|
|
14
|
+
'no-answer': 'no-answer'
|
|
15
|
+
};
|
|
16
|
+
export const initialState = {
|
|
17
|
+
'0': {
|
|
18
|
+
hidden: false,
|
|
19
|
+
position: 0
|
|
20
|
+
},
|
|
21
|
+
'1': {
|
|
22
|
+
hidden: false,
|
|
23
|
+
position: 1
|
|
24
|
+
},
|
|
25
|
+
'2': {
|
|
26
|
+
hidden: false,
|
|
27
|
+
position: 2
|
|
28
|
+
},
|
|
29
|
+
'3': {
|
|
30
|
+
hidden: false,
|
|
31
|
+
position: 3
|
|
32
|
+
},
|
|
33
|
+
'4': {
|
|
34
|
+
hidden: false,
|
|
35
|
+
position: 4
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const getProgressionSlidesRef = (progression) => {
|
|
39
|
+
if (progression.state.step.current < 5) {
|
|
40
|
+
const slideRef = progression.state.nextContent.ref;
|
|
41
|
+
return concat([slideRef], progression.state.slides);
|
|
42
|
+
}
|
|
43
|
+
return slice(0, 5, progression.state.slides);
|
|
44
|
+
};
|
|
45
|
+
const buildStackSlides = (state, dispatch) => {
|
|
46
|
+
const currentSlideRef = state.ui.currentSlideRef;
|
|
47
|
+
const progression = state.data.progression;
|
|
48
|
+
if (!currentSlideRef || !progression)
|
|
49
|
+
return initialState;
|
|
50
|
+
const slideRefs = getProgressionSlidesRef(progression);
|
|
51
|
+
// @ts-expect-error typescript does not support capped versions of lodash functions
|
|
52
|
+
const stack = reduce.convert({ cap: false })((acc, uiSlide, index) => {
|
|
53
|
+
const slideRef = slideRefs[toInteger(index)];
|
|
54
|
+
if (!slideRef)
|
|
55
|
+
return set(index, uiSlide, acc);
|
|
56
|
+
const slideFromAPI = get(slideRef, state.data.slides);
|
|
57
|
+
const answers = state.ui.answers;
|
|
58
|
+
const { questionText, answerUI } = mapApiSlideToUi(dispatch)(slideFromAPI, answers);
|
|
59
|
+
const parentContentTitle = getOr('', 'parentContentTitle.title', slideFromAPI);
|
|
60
|
+
const parentContentType = getOr('', 'parentContentTitle.type', slideFromAPI);
|
|
61
|
+
const updatedUiSlide = pipe(set(['questionText'], questionText), set(['answerUI'], answerUI), set(['parentContentTitle'], `From "${parentContentTitle}" ${parentContentType}`) // TODO translate: -From- .... -Course/chapter-
|
|
62
|
+
// TODO: Set position according to currentSlideRef et slideRefs (or maybe a value on the state ui.slidePositions !!)
|
|
63
|
+
)(uiSlide);
|
|
64
|
+
return set(index, updatedUiSlide, acc);
|
|
65
|
+
}, initialState, initialState);
|
|
66
|
+
return stack;
|
|
67
|
+
};
|
|
68
|
+
const buildStepItems = (state) => {
|
|
3
69
|
const { progression } = state.data;
|
|
4
70
|
const { currentSlideRef } = state.ui;
|
|
5
71
|
if (!progression)
|
|
@@ -51,7 +117,7 @@ const buildStepItemps = (state) => {
|
|
|
51
117
|
});
|
|
52
118
|
return steps;
|
|
53
119
|
};
|
|
54
|
-
export const mapStateToSlidesProps = (state) => {
|
|
120
|
+
export const mapStateToSlidesProps = (state, dispatch) => {
|
|
55
121
|
if (!state.data.slides) {
|
|
56
122
|
return null;
|
|
57
123
|
}
|
|
@@ -65,10 +131,10 @@ export const mapStateToSlidesProps = (state) => {
|
|
|
65
131
|
},
|
|
66
132
|
'aria-label': 'aria-header-wrapper',
|
|
67
133
|
closeButtonAriaLabel: 'aria-close-button',
|
|
68
|
-
steps:
|
|
134
|
+
steps: buildStepItems(state)
|
|
69
135
|
},
|
|
70
136
|
stack: {
|
|
71
|
-
slides: state
|
|
137
|
+
slides: buildStackSlides(state, dispatch),
|
|
72
138
|
validateButton: {
|
|
73
139
|
label: '__validate',
|
|
74
140
|
disabled: true,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Dispatch } from 'redux';
|
|
2
|
+
import { AnswerUI } from '../../types/slides';
|
|
3
|
+
import { Question, SlideFromAPI } from '../../types/common';
|
|
4
|
+
export declare const getQuestionType: (question: Question) => Question['type'];
|
|
5
|
+
export declare const mapApiSlideToUi: (dispatch: Dispatch) => (slide: SlideFromAPI, answers: string[]) => {
|
|
6
|
+
questionText: string;
|
|
7
|
+
answerUI: AnswerUI;
|
|
8
|
+
};
|