@coorpacademy/app-review 0.14.4-alpha.7 → 0.14.4
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/index.js +2 -2
- package/es/types/common.d.ts +0 -7
- package/es/types/slides.d.ts +0 -6
- package/es/views/slides/index.js +1 -1
- package/es/views/slides/map-api-slide-to-ui.d.ts +2 -2
- package/es/views/slides/map-api-slide-to-ui.js +1 -20
- package/lib/index.js +2 -2
- package/lib/types/common.d.ts +0 -7
- package/lib/types/slides.d.ts +0 -6
- package/lib/views/slides/index.js +1 -1
- package/lib/views/slides/map-api-slide-to-ui.d.ts +2 -2
- package/lib/views/slides/map-api-slide-to-ui.js +1 -20
- package/package.json +3 -3
package/es/index.js
CHANGED
|
@@ -31,7 +31,7 @@ const storeTokenAndCreateProgression = async (store, options) => {
|
|
|
31
31
|
};
|
|
32
32
|
const AppReview = ({ options }) => {
|
|
33
33
|
const [store, setStore] = useState(null);
|
|
34
|
-
const { translate, onQuitClick, skin
|
|
34
|
+
const { translate, onQuitClick, skin } = options;
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
const newStore = configureStore(options);
|
|
37
37
|
setStore(newStore);
|
|
@@ -42,6 +42,6 @@ const AppReview = ({ options }) => {
|
|
|
42
42
|
if (!store)
|
|
43
43
|
return null;
|
|
44
44
|
return (React.createElement(Provider, { store: store },
|
|
45
|
-
React.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate, skin: skin
|
|
45
|
+
React.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate, skin: skin })));
|
|
46
46
|
};
|
|
47
47
|
export default AppReview;
|
package/es/types/common.d.ts
CHANGED
|
@@ -11,17 +11,10 @@ export declare type Skin = {
|
|
|
11
11
|
primary: string;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare type ApiMediaVideo = {
|
|
15
|
-
mimeType: string;
|
|
16
|
-
videoId: string;
|
|
17
|
-
mediaRef: string;
|
|
18
|
-
id: string;
|
|
19
|
-
};
|
|
20
14
|
export declare type ConnectedOptions = {
|
|
21
15
|
translate: Translate;
|
|
22
16
|
onQuitClick: () => void;
|
|
23
17
|
skin: Skin;
|
|
24
|
-
appendVideoOptions: (video: ApiMediaVideo) => unknown;
|
|
25
18
|
};
|
|
26
19
|
export declare type AppOptions = ConnectedOptions & {
|
|
27
20
|
token: string;
|
package/es/types/slides.d.ts
CHANGED
|
@@ -71,14 +71,8 @@ export declare type Template = {
|
|
|
71
71
|
template: string;
|
|
72
72
|
answers: (TextTemplate | SelectionTemplate)[];
|
|
73
73
|
};
|
|
74
|
-
export declare type VideoMedia = unknown;
|
|
75
|
-
export declare type Media = VideoMedia | {
|
|
76
|
-
url: string;
|
|
77
|
-
type: string;
|
|
78
|
-
};
|
|
79
74
|
export declare type AnswerUI = {
|
|
80
75
|
model: QcmDrag | Qcm | QcmGraphic | FreeText | DropDown | QuestionRange | Template;
|
|
81
76
|
help: string;
|
|
82
|
-
media?: Media;
|
|
83
77
|
};
|
|
84
78
|
export declare type SlideUIAnimations = 'unstack' | 'restack';
|
package/es/views/slides/index.js
CHANGED
|
@@ -84,7 +84,7 @@ const buildStackSlides = (state, dispatch, options) => {
|
|
|
84
84
|
if (!slideFromAPI)
|
|
85
85
|
return set(index, { ...uiSlide, position }, acc);
|
|
86
86
|
const answers = getOr([], ['ui', 'answers', slideRef], state);
|
|
87
|
-
const { questionText, answerUI } = mapApiSlideToUi(dispatch, translate
|
|
87
|
+
const { questionText, answerUI } = mapApiSlideToUi(dispatch, translate)(slideFromAPI, answers);
|
|
88
88
|
const { title: parentContentTitle, type: parentContentType } = slideFromAPI.parentContentTitle;
|
|
89
89
|
const isCurrentSlideRef = currentSlideRef === slideRef;
|
|
90
90
|
const slideUI = get(['ui', 'slide', slideRef], state);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
2
|
import type { Question, SlideFromAPI } from '@coorpacademy/review-services';
|
|
3
3
|
import { AnswerUI } from '../../types/slides';
|
|
4
|
-
import {
|
|
4
|
+
import { Translate } from '../../types/common';
|
|
5
5
|
export declare const getQuestionType: (question: Question) => Question['type'];
|
|
6
|
-
export declare const mapApiSlideToUi: (dispatch: Dispatch, translate: Translate
|
|
6
|
+
export declare const mapApiSlideToUi: (dispatch: Dispatch, translate: Translate) => (slide: SlideFromAPI, answers: string[]) => {
|
|
7
7
|
questionText: string;
|
|
8
8
|
answerUI: AnswerUI;
|
|
9
9
|
};
|
|
@@ -163,31 +163,12 @@ const getAnswerUIModel = (question, answers, dispatch, translate) => {
|
|
|
163
163
|
throw new Error(`${type} is not an handled question.type`);
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
const
|
|
167
|
-
const type = get('type', media);
|
|
168
|
-
const resource = get('src.0', media);
|
|
169
|
-
switch (type) {
|
|
170
|
-
case 'img':
|
|
171
|
-
case 'audio':
|
|
172
|
-
return {
|
|
173
|
-
...resource,
|
|
174
|
-
type,
|
|
175
|
-
url: get('url', resource)
|
|
176
|
-
};
|
|
177
|
-
case 'video': {
|
|
178
|
-
return appendVideoOptions(resource);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
export const mapApiSlideToUi = (dispatch, translate, options) => (slide, answers) => {
|
|
166
|
+
export const mapApiSlideToUi = (dispatch, translate) => (slide, answers) => {
|
|
183
167
|
const questionText = getOr('', 'question.header', slide);
|
|
184
|
-
const media = get('question.medias.0', slide);
|
|
185
|
-
const { appendVideoOptions } = options;
|
|
186
168
|
return {
|
|
187
169
|
questionText,
|
|
188
170
|
answerUI: {
|
|
189
171
|
model: getAnswerUIModel(slide.question, answers, dispatch, translate),
|
|
190
|
-
media: buildMedia(media, appendVideoOptions),
|
|
191
172
|
help: getHelp(slide)
|
|
192
173
|
}
|
|
193
174
|
};
|
package/lib/index.js
CHANGED
|
@@ -59,7 +59,7 @@ const storeTokenAndCreateProgression = async (store, options) => {
|
|
|
59
59
|
};
|
|
60
60
|
const AppReview = ({ options }) => {
|
|
61
61
|
const [store, setStore] = (0, react_1.useState)(null);
|
|
62
|
-
const { translate, onQuitClick, skin
|
|
62
|
+
const { translate, onQuitClick, skin } = options;
|
|
63
63
|
(0, react_1.useEffect)(() => {
|
|
64
64
|
const newStore = (0, configure_store_1.default)(options);
|
|
65
65
|
setStore(newStore);
|
|
@@ -70,6 +70,6 @@ const AppReview = ({ options }) => {
|
|
|
70
70
|
if (!store)
|
|
71
71
|
return null;
|
|
72
72
|
return (react_1.default.createElement(react_redux_1.Provider, { store: store },
|
|
73
|
-
react_1.default.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate, skin: skin
|
|
73
|
+
react_1.default.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate, skin: skin })));
|
|
74
74
|
};
|
|
75
75
|
exports.default = AppReview;
|
package/lib/types/common.d.ts
CHANGED
|
@@ -11,17 +11,10 @@ export declare type Skin = {
|
|
|
11
11
|
primary: string;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare type ApiMediaVideo = {
|
|
15
|
-
mimeType: string;
|
|
16
|
-
videoId: string;
|
|
17
|
-
mediaRef: string;
|
|
18
|
-
id: string;
|
|
19
|
-
};
|
|
20
14
|
export declare type ConnectedOptions = {
|
|
21
15
|
translate: Translate;
|
|
22
16
|
onQuitClick: () => void;
|
|
23
17
|
skin: Skin;
|
|
24
|
-
appendVideoOptions: (video: ApiMediaVideo) => unknown;
|
|
25
18
|
};
|
|
26
19
|
export declare type AppOptions = ConnectedOptions & {
|
|
27
20
|
token: string;
|
package/lib/types/slides.d.ts
CHANGED
|
@@ -71,14 +71,8 @@ export declare type Template = {
|
|
|
71
71
|
template: string;
|
|
72
72
|
answers: (TextTemplate | SelectionTemplate)[];
|
|
73
73
|
};
|
|
74
|
-
export declare type VideoMedia = unknown;
|
|
75
|
-
export declare type Media = VideoMedia | {
|
|
76
|
-
url: string;
|
|
77
|
-
type: string;
|
|
78
|
-
};
|
|
79
74
|
export declare type AnswerUI = {
|
|
80
75
|
model: QcmDrag | Qcm | QcmGraphic | FreeText | DropDown | QuestionRange | Template;
|
|
81
76
|
help: string;
|
|
82
|
-
media?: Media;
|
|
83
77
|
};
|
|
84
78
|
export declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
@@ -90,7 +90,7 @@ const buildStackSlides = (state, dispatch, options) => {
|
|
|
90
90
|
if (!slideFromAPI)
|
|
91
91
|
return (0, set_1.default)(index, { ...uiSlide, position }, acc);
|
|
92
92
|
const answers = (0, getOr_1.default)([], ['ui', 'answers', slideRef], state);
|
|
93
|
-
const { questionText, answerUI } = (0, map_api_slide_to_ui_1.mapApiSlideToUi)(dispatch, translate
|
|
93
|
+
const { questionText, answerUI } = (0, map_api_slide_to_ui_1.mapApiSlideToUi)(dispatch, translate)(slideFromAPI, answers);
|
|
94
94
|
const { title: parentContentTitle, type: parentContentType } = slideFromAPI.parentContentTitle;
|
|
95
95
|
const isCurrentSlideRef = currentSlideRef === slideRef;
|
|
96
96
|
const slideUI = (0, get_1.default)(['ui', 'slide', slideRef], state);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
2
|
import type { Question, SlideFromAPI } from '@coorpacademy/review-services';
|
|
3
3
|
import { AnswerUI } from '../../types/slides';
|
|
4
|
-
import {
|
|
4
|
+
import { Translate } from '../../types/common';
|
|
5
5
|
export declare const getQuestionType: (question: Question) => Question['type'];
|
|
6
|
-
export declare const mapApiSlideToUi: (dispatch: Dispatch, translate: Translate
|
|
6
|
+
export declare const mapApiSlideToUi: (dispatch: Dispatch, translate: Translate) => (slide: SlideFromAPI, answers: string[]) => {
|
|
7
7
|
questionText: string;
|
|
8
8
|
answerUI: AnswerUI;
|
|
9
9
|
};
|
|
@@ -167,31 +167,12 @@ const getAnswerUIModel = (question, answers, dispatch, translate) => {
|
|
|
167
167
|
throw new Error(`${type} is not an handled question.type`);
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
|
-
const
|
|
171
|
-
const type = (0, fp_1.get)('type', media);
|
|
172
|
-
const resource = (0, fp_1.get)('src.0', media);
|
|
173
|
-
switch (type) {
|
|
174
|
-
case 'img':
|
|
175
|
-
case 'audio':
|
|
176
|
-
return {
|
|
177
|
-
...resource,
|
|
178
|
-
type,
|
|
179
|
-
url: (0, fp_1.get)('url', resource)
|
|
180
|
-
};
|
|
181
|
-
case 'video': {
|
|
182
|
-
return appendVideoOptions(resource);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
const mapApiSlideToUi = (dispatch, translate, options) => (slide, answers) => {
|
|
170
|
+
const mapApiSlideToUi = (dispatch, translate) => (slide, answers) => {
|
|
187
171
|
const questionText = (0, fp_1.getOr)('', 'question.header', slide);
|
|
188
|
-
const media = (0, fp_1.get)('question.medias.0', slide);
|
|
189
|
-
const { appendVideoOptions } = options;
|
|
190
172
|
return {
|
|
191
173
|
questionText,
|
|
192
174
|
answerUI: {
|
|
193
175
|
model: getAnswerUIModel(slide.question, answers, dispatch, translate),
|
|
194
|
-
media: buildMedia(media, appendVideoOptions),
|
|
195
176
|
help: getHelp(slide)
|
|
196
177
|
}
|
|
197
178
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.14.4
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"main": "lib/index.js",
|
|
36
36
|
"module": "es/index.js",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@coorpacademy/components": "11.4.
|
|
38
|
+
"@coorpacademy/components": "11.4.2",
|
|
39
39
|
"@coorpacademy/progression-engine": "11.5.3",
|
|
40
40
|
"@coorpacademy/redux-task": "1.1.6",
|
|
41
41
|
"@coorpacademy/review-services": "1.1.0",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"webpack-cli": "^4.10.0",
|
|
75
75
|
"webpack-dev-server": "^4.11.1"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "9d748ee6196fddfbfffb22378a95754537ec933b"
|
|
78
78
|
}
|