@coorpacademy/app-review 0.5.4 → 0.5.6-alpha.10
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/locales/en/review.json +14 -0
- package/es/sandbox/index.d.ts +9 -0
- package/es/sandbox/index.js +56 -0
- package/es/{index.js → src/index.js} +6 -5
- package/es/src/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
- package/es/src/services/fetch-slides-to-review-by-skill-ref.js +8 -0
- package/es/{services → src/services}/index.js +2 -0
- package/es/{test → src/test}/index.test.js +3 -1
- package/{lib → es/src}/test/util/services.mock.d.ts +1 -0
- package/es/{test → src/test}/util/services.mock.js +20 -1
- package/{lib → es/src}/types/common.d.ts +10 -2
- package/{lib → es/src}/views/slides/index.d.ts +2 -1
- package/es/{views → src/views}/slides/index.js +20 -18
- package/lib/locales/en/review.json +14 -0
- package/lib/sandbox/index.d.ts +9 -0
- package/lib/sandbox/index.js +67 -0
- package/lib/{index.js → src/index.js} +6 -6
- package/lib/src/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
- package/lib/src/services/fetch-slides-to-review-by-skill-ref.js +52 -0
- package/lib/{services → src/services}/index.js +2 -0
- package/lib/{test → src/test}/index.test.js +3 -1
- package/{es → lib/src}/test/util/services.mock.d.ts +1 -0
- package/lib/{test → src/test}/util/services.mock.js +20 -1
- package/{es → lib/src}/types/common.d.ts +10 -2
- package/{es → lib/src}/views/slides/index.d.ts +2 -1
- package/lib/{views → src/views}/slides/index.js +20 -18
- package/locales/en/review.json +14 -0
- package/package.json +9 -6
- package/src/index.tsx +7 -7
- package/src/services/fetch-slides-to-review-by-skill-ref.ts +18 -0
- package/src/services/index.ts +2 -0
- package/src/services/test/fetch-slides-to-review-by-skill-ref.test.ts +51 -0
- package/src/test/index.test.tsx +3 -1
- package/src/test/util/services.mock.ts +24 -2
- package/src/types/common.ts +16 -2
- package/src/types/globals.d.ts +1 -0
- package/src/views/slides/index.ts +43 -19
- package/src/views/slides/test/header.on-click.test.ts +10 -3
- package/src/views/slides/test/index.test.ts +58 -55
- package/src/views/slides/test/on-quit-popin.on-click.test.ts +12 -3
- package/src/views/slides/test/slide.free-text.on-change.test.ts +4 -2
- package/src/views/slides/test/slide.next-slide.on-click.test.ts +6 -3
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +3 -2
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +3 -2
- package/src/views/slides/test/slide.qcm.on-click.test.ts +3 -2
- package/src/views/slides/test/slide.slider.on-change.test.ts +3 -2
- package/src/views/slides/test/slide.slider.on-slider-change.test.ts +3 -2
- package/src/views/slides/test/slide.template.on-change.test.ts +5 -4
- /package/es/{actions → src/actions}/api/fetch-correction.d.ts +0 -0
- /package/es/{actions → src/actions}/api/fetch-correction.js +0 -0
- /package/es/{actions → src/actions}/api/fetch-rank.d.ts +0 -0
- /package/es/{actions → src/actions}/api/fetch-rank.js +0 -0
- /package/es/{actions → src/actions}/api/fetch-skills.d.ts +0 -0
- /package/es/{actions → src/actions}/api/fetch-skills.js +0 -0
- /package/es/{actions → src/actions}/api/fetch-slide.d.ts +0 -0
- /package/es/{actions → src/actions}/api/fetch-slide.js +0 -0
- /package/es/{actions → src/actions}/api/post-answer.d.ts +0 -0
- /package/es/{actions → src/actions}/api/post-answer.js +0 -0
- /package/es/{actions → src/actions}/api/post-progression.d.ts +0 -0
- /package/es/{actions → src/actions}/api/post-progression.js +0 -0
- /package/es/{actions → src/actions}/data/token.d.ts +0 -0
- /package/es/{actions → src/actions}/data/token.js +0 -0
- /package/es/{actions → src/actions}/index.d.ts +0 -0
- /package/es/{actions → src/actions}/index.js +0 -0
- /package/es/{actions → src/actions}/test/create-test-store.d.ts +0 -0
- /package/es/{actions → src/actions}/test/create-test-store.js +0 -0
- /package/es/{actions → src/actions}/ui/answers.d.ts +0 -0
- /package/es/{actions → src/actions}/ui/answers.js +0 -0
- /package/es/{actions → src/actions}/ui/navigation.d.ts +0 -0
- /package/es/{actions → src/actions}/ui/navigation.js +0 -0
- /package/es/{actions → src/actions}/ui/next-slide.d.ts +0 -0
- /package/es/{actions → src/actions}/ui/next-slide.js +0 -0
- /package/es/{actions → src/actions}/ui/quit-popin.d.ts +0 -0
- /package/es/{actions → src/actions}/ui/quit-popin.js +0 -0
- /package/es/{actions → src/actions}/ui/slides.d.ts +0 -0
- /package/es/{actions → src/actions}/ui/slides.js +0 -0
- /package/es/{common → src/common}/index.d.ts +0 -0
- /package/es/{common → src/common}/index.js +0 -0
- /package/es/{configure-store.d.ts → src/configure-store.d.ts} +0 -0
- /package/es/{configure-store.js → src/configure-store.js} +0 -0
- /package/es/{helpers → src/helpers}/css-register.d.ts +0 -0
- /package/es/{helpers → src/helpers}/css-register.js +0 -0
- /package/es/{index.d.ts → src/index.d.ts} +0 -0
- /package/es/{reducers → src/reducers}/data/corrections.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/corrections.js +0 -0
- /package/es/{reducers → src/reducers}/data/index.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/index.js +0 -0
- /package/es/{reducers → src/reducers}/data/progression.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/progression.js +0 -0
- /package/es/{reducers → src/reducers}/data/rank.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/rank.js +0 -0
- /package/es/{reducers → src/reducers}/data/skills.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/skills.js +0 -0
- /package/es/{reducers → src/reducers}/data/slides.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/slides.js +0 -0
- /package/es/{reducers → src/reducers}/data/token.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/token.js +0 -0
- /package/es/{reducers → src/reducers}/index.d.ts +0 -0
- /package/es/{reducers → src/reducers}/index.js +0 -0
- /package/es/{reducers → src/reducers}/ui/answers.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/answers.js +0 -0
- /package/es/{reducers → src/reducers}/ui/current-slide-ref.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/current-slide-ref.js +0 -0
- /package/es/{reducers → src/reducers}/ui/index.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/index.js +0 -0
- /package/es/{reducers → src/reducers}/ui/navigation.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/navigation.js +0 -0
- /package/es/{reducers → src/reducers}/ui/positions.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/positions.js +0 -0
- /package/es/{reducers → src/reducers}/ui/quit-popin.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/quit-popin.js +0 -0
- /package/es/{reducers → src/reducers}/ui/show-congrats.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/show-congrats.js +0 -0
- /package/es/{reducers → src/reducers}/ui/slide.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/slide.js +0 -0
- /package/es/{services → src/services}/fetch-correction.d.ts +0 -0
- /package/es/{services → src/services}/fetch-correction.js +0 -0
- /package/es/{services → src/services}/fetch-rank.d.ts +0 -0
- /package/es/{services → src/services}/fetch-rank.js +0 -0
- /package/es/{services → src/services}/fetch-skills.d.ts +0 -0
- /package/es/{services → src/services}/fetch-skills.js +0 -0
- /package/es/{services → src/services}/fetch-slide.d.ts +0 -0
- /package/es/{services → src/services}/fetch-slide.js +0 -0
- /package/es/{services → src/services}/index.d.ts +0 -0
- /package/es/{services → src/services}/post-answer.d.ts +0 -0
- /package/es/{services → src/services}/post-answer.js +0 -0
- /package/es/{services → src/services}/post-progression.d.ts +0 -0
- /package/es/{services → src/services}/post-progression.js +0 -0
- /package/es/{services → src/services}/tools/fetch-responses.d.ts +0 -0
- /package/es/{services → src/services}/tools/fetch-responses.js +0 -0
- /package/es/{services → src/services}/tools/sleep.d.ts +0 -0
- /package/es/{services → src/services}/tools/sleep.js +0 -0
- /package/es/{test → src/test}/index.test.d.ts +0 -0
- /package/es/{types → src/types}/common.js +0 -0
- /package/es/{types → src/types}/slides.d.ts +0 -0
- /package/es/{types → src/types}/slides.js +0 -0
- /package/es/{views → src/views}/skills/index.d.ts +0 -0
- /package/es/{views → src/views}/skills/index.js +0 -0
- /package/es/{views → src/views}/slides/map-api-slide-to-ui.d.ts +0 -0
- /package/es/{views → src/views}/slides/map-api-slide-to-ui.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/free-text.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/free-text.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm-drag.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm-drag.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm-graphic.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm-graphic.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/slider.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/slider.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/template.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/template.js +0 -0
- /package/lib/{actions → src/actions}/api/fetch-correction.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/fetch-correction.js +0 -0
- /package/lib/{actions → src/actions}/api/fetch-rank.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/fetch-rank.js +0 -0
- /package/lib/{actions → src/actions}/api/fetch-skills.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/fetch-skills.js +0 -0
- /package/lib/{actions → src/actions}/api/fetch-slide.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/fetch-slide.js +0 -0
- /package/lib/{actions → src/actions}/api/post-answer.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/post-answer.js +0 -0
- /package/lib/{actions → src/actions}/api/post-progression.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/post-progression.js +0 -0
- /package/lib/{actions → src/actions}/data/token.d.ts +0 -0
- /package/lib/{actions → src/actions}/data/token.js +0 -0
- /package/lib/{actions → src/actions}/index.d.ts +0 -0
- /package/lib/{actions → src/actions}/index.js +0 -0
- /package/lib/{actions → src/actions}/test/create-test-store.d.ts +0 -0
- /package/lib/{actions → src/actions}/test/create-test-store.js +0 -0
- /package/lib/{actions → src/actions}/ui/answers.d.ts +0 -0
- /package/lib/{actions → src/actions}/ui/answers.js +0 -0
- /package/lib/{actions → src/actions}/ui/navigation.d.ts +0 -0
- /package/lib/{actions → src/actions}/ui/navigation.js +0 -0
- /package/lib/{actions → src/actions}/ui/next-slide.d.ts +0 -0
- /package/lib/{actions → src/actions}/ui/next-slide.js +0 -0
- /package/lib/{actions → src/actions}/ui/quit-popin.d.ts +0 -0
- /package/lib/{actions → src/actions}/ui/quit-popin.js +0 -0
- /package/lib/{actions → src/actions}/ui/slides.d.ts +0 -0
- /package/lib/{actions → src/actions}/ui/slides.js +0 -0
- /package/lib/{common → src/common}/index.d.ts +0 -0
- /package/lib/{common → src/common}/index.js +0 -0
- /package/lib/{configure-store.d.ts → src/configure-store.d.ts} +0 -0
- /package/lib/{configure-store.js → src/configure-store.js} +0 -0
- /package/lib/{helpers → src/helpers}/css-register.d.ts +0 -0
- /package/lib/{helpers → src/helpers}/css-register.js +0 -0
- /package/lib/{index.d.ts → src/index.d.ts} +0 -0
- /package/lib/{reducers → src/reducers}/data/corrections.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/corrections.js +0 -0
- /package/lib/{reducers → src/reducers}/data/index.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/index.js +0 -0
- /package/lib/{reducers → src/reducers}/data/progression.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/progression.js +0 -0
- /package/lib/{reducers → src/reducers}/data/rank.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/rank.js +0 -0
- /package/lib/{reducers → src/reducers}/data/skills.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/skills.js +0 -0
- /package/lib/{reducers → src/reducers}/data/slides.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/slides.js +0 -0
- /package/lib/{reducers → src/reducers}/data/token.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/token.js +0 -0
- /package/lib/{reducers → src/reducers}/index.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/index.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/answers.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/answers.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/current-slide-ref.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/current-slide-ref.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/index.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/index.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/navigation.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/navigation.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/positions.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/positions.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/quit-popin.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/quit-popin.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/show-congrats.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/show-congrats.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/slide.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/slide.js +0 -0
- /package/lib/{services → src/services}/fetch-correction.d.ts +0 -0
- /package/lib/{services → src/services}/fetch-correction.js +0 -0
- /package/lib/{services → src/services}/fetch-rank.d.ts +0 -0
- /package/lib/{services → src/services}/fetch-rank.js +0 -0
- /package/lib/{services → src/services}/fetch-skills.d.ts +0 -0
- /package/lib/{services → src/services}/fetch-skills.js +0 -0
- /package/lib/{services → src/services}/fetch-slide.d.ts +0 -0
- /package/lib/{services → src/services}/fetch-slide.js +0 -0
- /package/lib/{services → src/services}/index.d.ts +0 -0
- /package/lib/{services → src/services}/post-answer.d.ts +0 -0
- /package/lib/{services → src/services}/post-answer.js +0 -0
- /package/lib/{services → src/services}/post-progression.d.ts +0 -0
- /package/lib/{services → src/services}/post-progression.js +0 -0
- /package/lib/{services → src/services}/tools/fetch-responses.d.ts +0 -0
- /package/lib/{services → src/services}/tools/fetch-responses.js +0 -0
- /package/lib/{services → src/services}/tools/sleep.d.ts +0 -0
- /package/lib/{services → src/services}/tools/sleep.js +0 -0
- /package/lib/{test → src/test}/index.test.d.ts +0 -0
- /package/lib/{types → src/types}/common.js +0 -0
- /package/lib/{types → src/types}/slides.d.ts +0 -0
- /package/lib/{types → src/types}/slides.js +0 -0
- /package/lib/{views → src/views}/skills/index.d.ts +0 -0
- /package/lib/{views → src/views}/skills/index.js +0 -0
- /package/lib/{views → src/views}/slides/map-api-slide-to-ui.d.ts +0 -0
- /package/lib/{views → src/views}/slides/map-api-slide-to-ui.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/free-text.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/free-text.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm-drag.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm-drag.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm-graphic.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm-graphic.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/slider.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/slider.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/template.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/template.js +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Review Title": "Review Mode",
|
|
3
|
+
"Content Parent Title": "From `{{contentTitle}}` `{{contentType}}`",
|
|
4
|
+
"Validate": "Validate",
|
|
5
|
+
"Next Question": "Next Question",
|
|
6
|
+
"KLF": "Key Learning Factor",
|
|
7
|
+
"Correct Answer": "Correct Answer",
|
|
8
|
+
"Wrong Answer": "Wrong Answer",
|
|
9
|
+
"You have won": "You have won",
|
|
10
|
+
"You are now": "You are now",
|
|
11
|
+
"Revise another skill": "Revise another skill",
|
|
12
|
+
"Continue reviewing": "Continue reviewing",
|
|
13
|
+
"Congratulations!": "Congratulations!"
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from 'react-dom';
|
|
3
|
+
import isNil from 'lodash/fp/isNil';
|
|
4
|
+
import get from 'lodash/fp/get';
|
|
5
|
+
import pipe from 'lodash/fp/pipe';
|
|
6
|
+
import createTranslate from '@coorpacademy/translate';
|
|
7
|
+
import { WebContext } from '@coorpacademy/components/es/atom/provider';
|
|
8
|
+
import localesComponents from '@coorpacademy/components/locales/en/global.json';
|
|
9
|
+
import localesAppReview from '../locales/en/review.json';
|
|
10
|
+
import AppReview from '../src';
|
|
11
|
+
import { services } from '../src/test/util/services.mock';
|
|
12
|
+
const translate = (key, data) => {
|
|
13
|
+
try {
|
|
14
|
+
return createTranslate({
|
|
15
|
+
...localesAppReview,
|
|
16
|
+
...localesComponents
|
|
17
|
+
})(key, data);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.error(err);
|
|
22
|
+
return createTranslate({ [key]: key })(key, data);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const isContainerAvailable = (options) => !pipe(get('container'), isNil)(options);
|
|
26
|
+
const createSandbox = (options) => {
|
|
27
|
+
if (!isContainerAvailable(options)) {
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.error('[AppReview sandbox] Requires a container.');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const container = document.getElementById(options.container);
|
|
33
|
+
// mode mobile/web
|
|
34
|
+
const appOptions = {
|
|
35
|
+
token: process.env.API_TEST_TOKEN || '',
|
|
36
|
+
skillRef: '123',
|
|
37
|
+
services,
|
|
38
|
+
translate,
|
|
39
|
+
onQuitClick: () => {
|
|
40
|
+
location.reload();
|
|
41
|
+
},
|
|
42
|
+
url: process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006'
|
|
43
|
+
};
|
|
44
|
+
const skin = {
|
|
45
|
+
common: {
|
|
46
|
+
primary: '#248e59'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
render(React.createElement(WebContext, { skin: skin, translate: translate },
|
|
50
|
+
React.createElement(AppReview, { options: appOptions })), container);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
if (window && !window.createSandbox) {
|
|
54
|
+
window.createSandbox = createSandbox;
|
|
55
|
+
}
|
|
56
|
+
createSandbox({ container: 'root' });
|
|
@@ -11,19 +11,20 @@ import { postProgression } from './actions/api/post-progression';
|
|
|
11
11
|
import { VIEWS } from './common';
|
|
12
12
|
import { mapStateToSlidesProps } from './views/slides';
|
|
13
13
|
import { mapStateToSkillsProps } from './views/skills';
|
|
14
|
-
const ConnectedApp = (
|
|
14
|
+
const ConnectedApp = (options) => {
|
|
15
15
|
const dispatch = useDispatch();
|
|
16
16
|
const props = {
|
|
17
17
|
viewName: useSelector((state) => state.ui.navigation[state.ui.navigation.length - 1]),
|
|
18
|
-
slides: useSelector((state) => mapStateToSlidesProps(state, dispatch,
|
|
19
|
-
skills: useSelector((state) => mapStateToSkillsProps(state))
|
|
18
|
+
slides: useSelector((state) => mapStateToSlidesProps(state, dispatch, options)),
|
|
19
|
+
skills: useSelector((state) => mapStateToSkillsProps(state)),
|
|
20
|
+
onboarding: {}
|
|
20
21
|
};
|
|
21
22
|
return React.createElement(AppReviewTemplate, { ...props });
|
|
22
23
|
};
|
|
23
24
|
const AppReview = ({ options }) => {
|
|
24
25
|
const [store, setStore] = useState(null);
|
|
25
26
|
const [isProgressionCreated, setIsProgressionCreated] = useState(false);
|
|
26
|
-
const onQuitClick = options
|
|
27
|
+
const { translate, onQuitClick } = options;
|
|
27
28
|
useEffect(() => {
|
|
28
29
|
if (store)
|
|
29
30
|
return;
|
|
@@ -67,6 +68,6 @@ const AppReview = ({ options }) => {
|
|
|
67
68
|
if (!store)
|
|
68
69
|
return null;
|
|
69
70
|
return (React.createElement(Provider, { store: store },
|
|
70
|
-
React.createElement(ConnectedApp, { onQuitClick: onQuitClick })));
|
|
71
|
+
React.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate })));
|
|
71
72
|
};
|
|
72
73
|
export default AppReview;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const fetchSlidesToReviewBySkillRef = async (url, token, skillRef) => {
|
|
5
|
+
const { user: userId } = decode(token);
|
|
6
|
+
const response = await crossFetch(`${url}/api/v1/review/users/${userId}/skills/${skillRef}/slide?limit=5&offset=0`);
|
|
7
|
+
return toJSON(response);
|
|
8
|
+
};
|
|
@@ -2,6 +2,7 @@ import { fetchCorrection } from './fetch-correction';
|
|
|
2
2
|
import { fetchRank } from './fetch-rank';
|
|
3
3
|
import { fetchSkills } from './fetch-skills';
|
|
4
4
|
import { fetchSlide } from './fetch-slide';
|
|
5
|
+
import { fetchSlidesToReviewBySkillRef } from './fetch-slides-to-review-by-skill-ref';
|
|
5
6
|
import { postAnswer } from './post-answer';
|
|
6
7
|
import { postProgression } from './post-progression';
|
|
7
8
|
export const getServices = () => ({
|
|
@@ -9,6 +10,7 @@ export const getServices = () => ({
|
|
|
9
10
|
fetchRank,
|
|
10
11
|
fetchSkills,
|
|
11
12
|
fetchSlide,
|
|
13
|
+
fetchSlidesToReviewBySkillRef,
|
|
12
14
|
postAnswer,
|
|
13
15
|
postProgression
|
|
14
16
|
});
|
|
@@ -39,7 +39,9 @@ const appOptions = {
|
|
|
39
39
|
token: process.env.API_TEST_TOKEN || '',
|
|
40
40
|
skillRef: 'skill_NJC0jFKoH',
|
|
41
41
|
services,
|
|
42
|
-
onQuitClick: identity
|
|
42
|
+
onQuitClick: identity,
|
|
43
|
+
translate: key => key,
|
|
44
|
+
url: process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006'
|
|
43
45
|
};
|
|
44
46
|
test('should show the loader while the app is fetching the data', async (t) => {
|
|
45
47
|
t.plan(2);
|
|
@@ -5,3 +5,4 @@ export declare const incorrectFreeTextPostAnswerResponse: ProgressionFromAPI;
|
|
|
5
5
|
export declare const progressionSlideWithPendingSlide: ProgressionFromAPI;
|
|
6
6
|
export declare const getChoicesCorrection: (ref: string, wrongChoice?: boolean) => CorrectionFromAPI;
|
|
7
7
|
export declare const services: Services;
|
|
8
|
+
export declare const translate: (key: string) => string;
|
|
@@ -413,6 +413,23 @@ export const getChoicesCorrection = (ref, wrongChoice = false) => {
|
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
};
|
|
416
|
+
const fetchSlidesToReviewBySkillRefResponse = [
|
|
417
|
+
{
|
|
418
|
+
slideId: freeTextSlide._id
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
slideId: templateSlide._id
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
slideId: qcmDragSlide._id
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
slideId: qcmGraphicSlide._id
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
slideId: qcmSlide._id
|
|
431
|
+
}
|
|
432
|
+
];
|
|
416
433
|
export const services = {
|
|
417
434
|
fetchSkills: () => Promise.resolve(fetchSkillsResponse),
|
|
418
435
|
fetchSlide: ref => Promise.resolve({ ...getSlideFixture(ref), universalRef: ref, _id: ref }),
|
|
@@ -422,5 +439,7 @@ export const services = {
|
|
|
422
439
|
return Promise.resolve(get(currentSlide, postAnswerResponses));
|
|
423
440
|
},
|
|
424
441
|
fetchCorrection: ref => Promise.resolve(getChoicesCorrection(ref)),
|
|
425
|
-
fetchRank: () => Promise.resolve(fetchRankResponse)
|
|
442
|
+
fetchRank: () => Promise.resolve(fetchRankResponse),
|
|
443
|
+
fetchSlidesToReviewBySkillRef: () => Promise.resolve(fetchSlidesToReviewBySkillRefResponse)
|
|
426
444
|
};
|
|
445
|
+
export const translate = (key) => `___${key}`;
|
|
@@ -69,6 +69,9 @@ export declare type SlideFromAPI = {
|
|
|
69
69
|
type: 'chapter' | 'course';
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
+
export declare type SlideIdFromAPI = {
|
|
73
|
+
slideId: string;
|
|
74
|
+
};
|
|
72
75
|
export declare type Rank = {
|
|
73
76
|
rank: number;
|
|
74
77
|
};
|
|
@@ -131,15 +134,20 @@ export declare type Services = {
|
|
|
131
134
|
postAnswer(progression: ProgressionFromAPI, token: string, answer: string[]): Promise<ProgressionFromAPI>;
|
|
132
135
|
fetchCorrection(slideRef: string, token: string, progressionId: string, answer: string[]): Promise<CorrectionFromAPI | void>;
|
|
133
136
|
fetchRank(token: string): Promise<Rank>;
|
|
137
|
+
fetchSlidesToReviewBySkillRef(url: string, token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
|
|
134
138
|
};
|
|
135
139
|
export declare type Options = {
|
|
136
140
|
services: Services;
|
|
137
141
|
};
|
|
138
|
-
export declare type
|
|
142
|
+
export declare type ConnectedOptions = {
|
|
143
|
+
translate: (key: string, data?: unknown) => string;
|
|
144
|
+
onQuitClick: Function;
|
|
145
|
+
};
|
|
146
|
+
export declare type AppOptions = ConnectedOptions & {
|
|
139
147
|
token: string;
|
|
140
148
|
skillRef?: string;
|
|
141
149
|
services: Services;
|
|
142
|
-
|
|
150
|
+
url: string;
|
|
143
151
|
};
|
|
144
152
|
export declare type JWT = {
|
|
145
153
|
exp: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
+
import type { ConnectedOptions } from '../../types/common';
|
|
2
3
|
import { type SlideIndexes } from '../../common';
|
|
3
4
|
import type { StoreState } from '../../reducers';
|
|
4
5
|
import type { AnswerUI } from '../../types/slides';
|
|
@@ -138,5 +139,5 @@ export declare type CongratsProps = {
|
|
|
138
139
|
};
|
|
139
140
|
export declare const initialState: SlidesStack;
|
|
140
141
|
export declare const buildStepItems: (state: StoreState) => StepItem[];
|
|
141
|
-
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch,
|
|
142
|
+
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, options: ConnectedOptions) => SlidesViewProps;
|
|
142
143
|
export {};
|
|
@@ -166,22 +166,22 @@ export const buildStepItems = (state) => {
|
|
|
166
166
|
});
|
|
167
167
|
return steps;
|
|
168
168
|
};
|
|
169
|
-
const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf) => {
|
|
169
|
+
const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, translate) => {
|
|
170
170
|
return {
|
|
171
171
|
klf: isCorrect
|
|
172
172
|
? undefined
|
|
173
173
|
: {
|
|
174
|
-
label: '
|
|
174
|
+
label: translate('KLF'),
|
|
175
175
|
tooltip: klf
|
|
176
176
|
},
|
|
177
|
-
resultLabel: isCorrect ? '
|
|
177
|
+
resultLabel: isCorrect ? translate('Correct Answer') : translate('Wrong Answer'),
|
|
178
178
|
information: {
|
|
179
|
-
label: isCorrect ? '
|
|
179
|
+
label: isCorrect ? translate('KLF') : translate('Correct Answer'),
|
|
180
180
|
message: isCorrect ? klf : join(',', correctAnswer)
|
|
181
181
|
},
|
|
182
182
|
next: {
|
|
183
|
-
ariaLabel: '
|
|
184
|
-
label: '
|
|
183
|
+
ariaLabel: translate('Next Question'),
|
|
184
|
+
label: translate('Next Question'),
|
|
185
185
|
onClick: () => {
|
|
186
186
|
dispatch(nextSlide);
|
|
187
187
|
}
|
|
@@ -214,7 +214,7 @@ const buildQuitPopinProps = (dispatch) => (onQuitClick) => {
|
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
216
|
};
|
|
217
|
-
const buildRankCard = (rank) => {
|
|
217
|
+
const buildRankCard = (rank, translate) => {
|
|
218
218
|
return {
|
|
219
219
|
'aria-label': 'Review Card Congrats Container',
|
|
220
220
|
'data-name': 'card-rank',
|
|
@@ -229,13 +229,13 @@ const buildRankCard = (rank) => {
|
|
|
229
229
|
cardType: 'card-rank',
|
|
230
230
|
iconAriaLabel: 'Image without information',
|
|
231
231
|
className: undefined,
|
|
232
|
-
reviewCardTitle: 'You are now',
|
|
232
|
+
reviewCardTitle: translate('You are now'),
|
|
233
233
|
reviewCardValue: `${rank}`,
|
|
234
234
|
rankSuffix: 'th',
|
|
235
235
|
timerAnimation: 200
|
|
236
236
|
};
|
|
237
237
|
};
|
|
238
|
-
const buildCongratsProps = (state) => {
|
|
238
|
+
const buildCongratsProps = (state, translate) => {
|
|
239
239
|
if (!state.ui.showCongrats)
|
|
240
240
|
return;
|
|
241
241
|
const progression = state.data.progression;
|
|
@@ -258,18 +258,18 @@ const buildCongratsProps = (state) => {
|
|
|
258
258
|
iconAriaLabel: 'Image without information',
|
|
259
259
|
className: undefined,
|
|
260
260
|
cardType: 'card-star',
|
|
261
|
-
reviewCardTitle: 'You have won',
|
|
261
|
+
reviewCardTitle: translate('You have won'),
|
|
262
262
|
reviewCardValue: `${stars}`,
|
|
263
263
|
timerAnimation: 200
|
|
264
264
|
};
|
|
265
265
|
const { start, end } = state.data.rank;
|
|
266
266
|
const newRank = start - end;
|
|
267
|
-
const cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end) : undefined;
|
|
267
|
+
const cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end, translate) : undefined;
|
|
268
268
|
return {
|
|
269
269
|
'aria-label': 'Review Congratulations',
|
|
270
270
|
'data-name': 'review-congrats',
|
|
271
271
|
animationLottie: confettiAnimation,
|
|
272
|
-
title: 'Congratulations!',
|
|
272
|
+
title: translate('Congratulations!'),
|
|
273
273
|
cardCongratsStar,
|
|
274
274
|
cardCongratsRank,
|
|
275
275
|
buttonRevising: undefined,
|
|
@@ -281,7 +281,8 @@ const isEndOfProgression = (progression) => {
|
|
|
281
281
|
return false;
|
|
282
282
|
return progression.state.nextContent.ref === 'successExitNode';
|
|
283
283
|
};
|
|
284
|
-
export const mapStateToSlidesProps = (state, dispatch,
|
|
284
|
+
export const mapStateToSlidesProps = (state, dispatch, options) => {
|
|
285
|
+
const { translate, onQuitClick } = options;
|
|
285
286
|
const currentSlideRef = getCurrentSlideRef(state);
|
|
286
287
|
const endReview = isEndOfProgression(state.data.progression);
|
|
287
288
|
const correction = get(['data', 'corrections', currentSlideRef], state);
|
|
@@ -290,8 +291,8 @@ export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
|
|
|
290
291
|
const showQuitPopin = get(['ui', 'showQuitPopin'], state);
|
|
291
292
|
return {
|
|
292
293
|
header: {
|
|
293
|
-
mode: '
|
|
294
|
-
skillName: '
|
|
294
|
+
mode: translate('Review Title'),
|
|
295
|
+
skillName: translate('Content Parent Title'),
|
|
295
296
|
onQuitClick: () => dispatch(openQuitPopin),
|
|
296
297
|
'aria-label': 'aria-header-wrapper',
|
|
297
298
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -300,16 +301,17 @@ export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
|
|
|
300
301
|
stack: {
|
|
301
302
|
slides: buildStackSlides(state, dispatch),
|
|
302
303
|
validateButton: {
|
|
303
|
-
label: '
|
|
304
|
+
label: translate('Validate'),
|
|
304
305
|
disabled: !get(['ui', 'slide', currentSlideRef, 'validateButton'], state),
|
|
305
306
|
onClick: () => {
|
|
306
307
|
dispatch(postAnswer);
|
|
307
308
|
}
|
|
308
309
|
},
|
|
309
|
-
correctionPopinProps: correction &&
|
|
310
|
+
correctionPopinProps: correction &&
|
|
311
|
+
getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf, options.translate),
|
|
310
312
|
endReview: endReview && state.ui.showCongrats
|
|
311
313
|
},
|
|
312
|
-
congrats: buildCongratsProps(state),
|
|
314
|
+
congrats: buildCongratsProps(state, options.translate),
|
|
313
315
|
quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
|
|
314
316
|
};
|
|
315
317
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Review Title": "Review Mode",
|
|
3
|
+
"Content Parent Title": "From `{{contentTitle}}` `{{contentType}}`",
|
|
4
|
+
"Validate": "Validate",
|
|
5
|
+
"Next Question": "Next Question",
|
|
6
|
+
"KLF": "Key Learning Factor",
|
|
7
|
+
"Correct Answer": "Correct Answer",
|
|
8
|
+
"Wrong Answer": "Wrong Answer",
|
|
9
|
+
"You have won": "You have won",
|
|
10
|
+
"You are now": "You are now",
|
|
11
|
+
"Revise another skill": "Revise another skill",
|
|
12
|
+
"Continue reviewing": "Continue reviewing",
|
|
13
|
+
"Congratulations!": "Congratulations!"
|
|
14
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { render } from 'react-dom';
|
|
14
|
+
import isNil from 'lodash/fp/isNil';
|
|
15
|
+
import get from 'lodash/fp/get';
|
|
16
|
+
import pipe from 'lodash/fp/pipe';
|
|
17
|
+
import createTranslate from '@coorpacademy/translate';
|
|
18
|
+
import { WebContext } from '@coorpacademy/components/es/atom/provider';
|
|
19
|
+
import localesComponents from '@coorpacademy/components/locales/en/global.json';
|
|
20
|
+
import localesAppReview from '../locales/en/review.json';
|
|
21
|
+
import AppReview from '../src';
|
|
22
|
+
import { services } from '../src/test/util/services.mock';
|
|
23
|
+
var translate = function (key, data) {
|
|
24
|
+
var _a;
|
|
25
|
+
try {
|
|
26
|
+
return createTranslate(__assign(__assign({}, localesAppReview), localesComponents))(key, data);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
// eslint-disable-next-line no-console
|
|
30
|
+
console.error(err);
|
|
31
|
+
return createTranslate((_a = {}, _a[key] = key, _a))(key, data);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var isContainerAvailable = function (options) {
|
|
35
|
+
return !pipe(get('container'), isNil)(options);
|
|
36
|
+
};
|
|
37
|
+
var createSandbox = function (options) {
|
|
38
|
+
if (!isContainerAvailable(options)) {
|
|
39
|
+
// eslint-disable-next-line no-console
|
|
40
|
+
console.error('[AppReview sandbox] Requires a container.');
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
var container = document.getElementById(options.container);
|
|
44
|
+
// mode mobile/web
|
|
45
|
+
var appOptions = {
|
|
46
|
+
token: process.env.API_TEST_TOKEN || '',
|
|
47
|
+
skillRef: '123',
|
|
48
|
+
services: services,
|
|
49
|
+
translate: translate,
|
|
50
|
+
onQuitClick: function () {
|
|
51
|
+
location.reload();
|
|
52
|
+
},
|
|
53
|
+
url: process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006'
|
|
54
|
+
};
|
|
55
|
+
var skin = {
|
|
56
|
+
common: {
|
|
57
|
+
primary: '#248e59'
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
render(React.createElement(WebContext, { skin: skin, translate: translate },
|
|
61
|
+
React.createElement(AppReview, { options: appOptions })), container);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
if (window && !window.createSandbox) {
|
|
65
|
+
window.createSandbox = createSandbox;
|
|
66
|
+
}
|
|
67
|
+
createSandbox({ container: 'root' });
|
|
@@ -22,13 +22,13 @@ import { postProgression } from './actions/api/post-progression';
|
|
|
22
22
|
import { VIEWS } from './common';
|
|
23
23
|
import { mapStateToSlidesProps } from './views/slides';
|
|
24
24
|
import { mapStateToSkillsProps } from './views/skills';
|
|
25
|
-
var ConnectedApp = function (
|
|
26
|
-
var onQuitClick = _a.onQuitClick;
|
|
25
|
+
var ConnectedApp = function (options) {
|
|
27
26
|
var dispatch = useDispatch();
|
|
28
27
|
var props = {
|
|
29
28
|
viewName: useSelector(function (state) { return state.ui.navigation[state.ui.navigation.length - 1]; }),
|
|
30
|
-
slides: useSelector(function (state) { return mapStateToSlidesProps(state, dispatch,
|
|
31
|
-
skills: useSelector(function (state) { return mapStateToSkillsProps(state); })
|
|
29
|
+
slides: useSelector(function (state) { return mapStateToSlidesProps(state, dispatch, options); }),
|
|
30
|
+
skills: useSelector(function (state) { return mapStateToSkillsProps(state); }),
|
|
31
|
+
onboarding: {}
|
|
32
32
|
};
|
|
33
33
|
return React.createElement(AppReviewTemplate, __assign({}, props));
|
|
34
34
|
};
|
|
@@ -36,7 +36,7 @@ var AppReview = function (_a) {
|
|
|
36
36
|
var options = _a.options;
|
|
37
37
|
var _b = useState(null), store = _b[0], setStore = _b[1];
|
|
38
38
|
var _c = useState(false), isProgressionCreated = _c[0], setIsProgressionCreated = _c[1];
|
|
39
|
-
var onQuitClick = options.onQuitClick;
|
|
39
|
+
var translate = options.translate, onQuitClick = options.onQuitClick;
|
|
40
40
|
useEffect(function () {
|
|
41
41
|
if (store)
|
|
42
42
|
return;
|
|
@@ -80,6 +80,6 @@ var AppReview = function (_a) {
|
|
|
80
80
|
if (!store)
|
|
81
81
|
return null;
|
|
82
82
|
return (React.createElement(Provider, { store: store },
|
|
83
|
-
React.createElement(ConnectedApp, { onQuitClick: onQuitClick })));
|
|
83
|
+
React.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate })));
|
|
84
84
|
};
|
|
85
85
|
export default AppReview;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import crossFetch from 'cross-fetch';
|
|
38
|
+
import decode from 'jwt-decode';
|
|
39
|
+
import { toJSON } from './tools/fetch-responses';
|
|
40
|
+
export var fetchSlidesToReviewBySkillRef = function (url, token, skillRef) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var userId, response;
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
switch (_a.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
userId = decode(token).user;
|
|
46
|
+
return [4 /*yield*/, crossFetch("".concat(url, "/api/v1/review/users/").concat(userId, "/skills/").concat(skillRef, "/slide?limit=5&offset=0"))];
|
|
47
|
+
case 1:
|
|
48
|
+
response = _a.sent();
|
|
49
|
+
return [2 /*return*/, toJSON(response)];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}); };
|
|
@@ -2,6 +2,7 @@ import { fetchCorrection } from './fetch-correction';
|
|
|
2
2
|
import { fetchRank } from './fetch-rank';
|
|
3
3
|
import { fetchSkills } from './fetch-skills';
|
|
4
4
|
import { fetchSlide } from './fetch-slide';
|
|
5
|
+
import { fetchSlidesToReviewBySkillRef } from './fetch-slides-to-review-by-skill-ref';
|
|
5
6
|
import { postAnswer } from './post-answer';
|
|
6
7
|
import { postProgression } from './post-progression';
|
|
7
8
|
export var getServices = function () { return ({
|
|
@@ -9,6 +10,7 @@ export var getServices = function () { return ({
|
|
|
9
10
|
fetchRank: fetchRank,
|
|
10
11
|
fetchSkills: fetchSkills,
|
|
11
12
|
fetchSlide: fetchSlide,
|
|
13
|
+
fetchSlidesToReviewBySkillRef: fetchSlidesToReviewBySkillRef,
|
|
12
14
|
postAnswer: postAnswer,
|
|
13
15
|
postProgression: postProgression
|
|
14
16
|
}); };
|
|
@@ -134,7 +134,9 @@ var appOptions = {
|
|
|
134
134
|
token: process.env.API_TEST_TOKEN || '',
|
|
135
135
|
skillRef: 'skill_NJC0jFKoH',
|
|
136
136
|
services: services,
|
|
137
|
-
onQuitClick: identity
|
|
137
|
+
onQuitClick: identity,
|
|
138
|
+
translate: function (key) { return key; },
|
|
139
|
+
url: process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006'
|
|
138
140
|
};
|
|
139
141
|
test('should show the loader while the app is fetching the data', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
140
142
|
var container, loader;
|
|
@@ -5,3 +5,4 @@ export declare const incorrectFreeTextPostAnswerResponse: ProgressionFromAPI;
|
|
|
5
5
|
export declare const progressionSlideWithPendingSlide: ProgressionFromAPI;
|
|
6
6
|
export declare const getChoicesCorrection: (ref: string, wrongChoice?: boolean) => CorrectionFromAPI;
|
|
7
7
|
export declare const services: Services;
|
|
8
|
+
export declare const translate: (key: string) => string;
|
|
@@ -417,6 +417,23 @@ export var getChoicesCorrection = function (ref, wrongChoice) {
|
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
};
|
|
420
|
+
var fetchSlidesToReviewBySkillRefResponse = [
|
|
421
|
+
{
|
|
422
|
+
slideId: freeTextSlide._id
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
slideId: templateSlide._id
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
slideId: qcmDragSlide._id
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
slideId: qcmGraphicSlide._id
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
slideId: qcmSlide._id
|
|
435
|
+
}
|
|
436
|
+
];
|
|
420
437
|
export var services = {
|
|
421
438
|
fetchSkills: function () { return Promise.resolve(fetchSkillsResponse); },
|
|
422
439
|
fetchSlide: function (ref) { return Promise.resolve(__assign(__assign({}, getSlideFixture(ref)), { universalRef: ref, _id: ref })); },
|
|
@@ -426,5 +443,7 @@ export var services = {
|
|
|
426
443
|
return Promise.resolve(get(currentSlide, postAnswerResponses));
|
|
427
444
|
},
|
|
428
445
|
fetchCorrection: function (ref) { return Promise.resolve(getChoicesCorrection(ref)); },
|
|
429
|
-
fetchRank: function () { return Promise.resolve(fetchRankResponse); }
|
|
446
|
+
fetchRank: function () { return Promise.resolve(fetchRankResponse); },
|
|
447
|
+
fetchSlidesToReviewBySkillRef: function () { return Promise.resolve(fetchSlidesToReviewBySkillRefResponse); }
|
|
430
448
|
};
|
|
449
|
+
export var translate = function (key) { return "___".concat(key); };
|
|
@@ -69,6 +69,9 @@ export declare type SlideFromAPI = {
|
|
|
69
69
|
type: 'chapter' | 'course';
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
+
export declare type SlideIdFromAPI = {
|
|
73
|
+
slideId: string;
|
|
74
|
+
};
|
|
72
75
|
export declare type Rank = {
|
|
73
76
|
rank: number;
|
|
74
77
|
};
|
|
@@ -131,15 +134,20 @@ export declare type Services = {
|
|
|
131
134
|
postAnswer(progression: ProgressionFromAPI, token: string, answer: string[]): Promise<ProgressionFromAPI>;
|
|
132
135
|
fetchCorrection(slideRef: string, token: string, progressionId: string, answer: string[]): Promise<CorrectionFromAPI | void>;
|
|
133
136
|
fetchRank(token: string): Promise<Rank>;
|
|
137
|
+
fetchSlidesToReviewBySkillRef(url: string, token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
|
|
134
138
|
};
|
|
135
139
|
export declare type Options = {
|
|
136
140
|
services: Services;
|
|
137
141
|
};
|
|
138
|
-
export declare type
|
|
142
|
+
export declare type ConnectedOptions = {
|
|
143
|
+
translate: (key: string, data?: unknown) => string;
|
|
144
|
+
onQuitClick: Function;
|
|
145
|
+
};
|
|
146
|
+
export declare type AppOptions = ConnectedOptions & {
|
|
139
147
|
token: string;
|
|
140
148
|
skillRef?: string;
|
|
141
149
|
services: Services;
|
|
142
|
-
|
|
150
|
+
url: string;
|
|
143
151
|
};
|
|
144
152
|
export declare type JWT = {
|
|
145
153
|
exp: number;
|