@coorpacademy/app-review 0.1.17 → 0.1.18
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/post-answer.d.ts +5 -1
- package/es/actions/ui/answers.d.ts +1 -1
- package/es/actions/ui/answers.js +6 -4
- package/es/actions/ui/test/answers.test.js +15 -5
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +2 -1
- package/es/reducers/data/progression.js +2 -0
- package/es/reducers/data/test/progression.test.js +11 -26
- package/es/reducers/index.d.ts +1 -1
- package/es/reducers/ui/index.d.ts +1 -1
- package/es/reducers/ui/test/answers.test.js +4 -0
- package/es/test/util/services.mock.d.ts +1 -0
- package/es/test/util/services.mock.js +4 -1
- package/es/views/slides/index.js +1 -1
- package/es/views/slides/map-api-slide-to-ui.js +26 -22
- package/es/views/slides/test/fixtures/template.d.ts +4 -0
- package/es/views/slides/test/fixtures/{select-template.js → template.js} +82 -4
- package/es/views/slides/test/index.test.js +239 -0
- package/es/views/slides/test/map-api-slide-to-ui.test.js +4 -10
- package/es/views/slides/test/slide.template.on-change.test.d.ts +1 -0
- package/es/views/slides/test/slide.template.on-change.test.js +79 -0
- package/lib/actions/api/post-answer.d.ts +5 -1
- package/lib/actions/ui/answers.d.ts +1 -1
- package/lib/actions/ui/answers.js +6 -4
- package/lib/actions/ui/test/answers.test.js +24 -5
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +2 -1
- package/lib/reducers/data/progression.js +2 -0
- package/lib/reducers/data/test/progression.test.js +11 -26
- package/lib/reducers/index.d.ts +1 -1
- package/lib/reducers/ui/index.d.ts +1 -1
- package/lib/reducers/ui/test/answers.test.js +4 -0
- package/lib/test/util/services.mock.d.ts +1 -0
- package/lib/test/util/services.mock.js +4 -1
- package/lib/views/slides/index.js +1 -1
- package/lib/views/slides/map-api-slide-to-ui.js +34 -28
- package/lib/views/slides/test/fixtures/template.d.ts +4 -0
- package/lib/views/slides/test/fixtures/{select-template.js → template.js} +82 -4
- package/lib/views/slides/test/index.test.js +239 -0
- package/lib/views/slides/test/map-api-slide-to-ui.test.js +4 -10
- package/lib/views/slides/test/slide.template.on-change.test.d.ts +1 -0
- package/lib/views/slides/test/slide.template.on-change.test.js +82 -0
- package/package.json +3 -3
- package/src/actions/api/post-answer.ts +6 -1
- package/src/actions/ui/answers.ts +8 -6
- package/src/actions/ui/test/answers.test.ts +17 -5
- package/src/reducers/data/progression.ts +3 -1
- package/src/reducers/data/test/progression.test.ts +12 -28
- package/src/reducers/ui/test/answers.test.ts +5 -0
- package/src/test/util/services.mock.ts +4 -1
- package/src/views/slides/index.ts +1 -1
- package/src/views/slides/map-api-slide-to-ui.ts +63 -30
- package/src/views/slides/test/fixtures/{select-template.ts → template.ts} +82 -4
- package/src/views/slides/test/index.test.ts +253 -0
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +4 -10
- package/src/views/slides/test/slide.template.on-change.test.ts +92 -0
- package/es/views/slides/test/fixtures/select-template.d.ts +0 -4
- package/es/views/slides/test/fixtures/text-template.d.ts +0 -4
- package/es/views/slides/test/fixtures/text-template.js +0 -58
- package/lib/views/slides/test/fixtures/select-template.d.ts +0 -4
- package/lib/views/slides/test/fixtures/text-template.d.ts +0 -4
- package/lib/views/slides/test/fixtures/text-template.js +0 -58
- package/src/views/slides/test/fixtures/text-template.ts +0 -62
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { Options } from '../../types/common';
|
|
2
|
+
import type { Options, ProgressionFromAPI } from '../../types/common';
|
|
3
3
|
import type { StoreState } from '../../reducers';
|
|
4
4
|
export declare const POST_ANSWER_REQUEST: "@@answer/POST_REQUEST";
|
|
5
5
|
export declare const POST_ANSWER_SUCCESS: "@@answer/POST_SUCCESS";
|
|
@@ -7,4 +7,8 @@ export declare const POST_ANSWER_FAILURE: "@@answer/POST_FAILURE";
|
|
|
7
7
|
export declare type PostAnswerRequestAction = {
|
|
8
8
|
type: typeof POST_ANSWER_REQUEST;
|
|
9
9
|
};
|
|
10
|
+
export declare type PostAnswerSuccessAction = {
|
|
11
|
+
type: typeof POST_ANSWER_SUCCESS;
|
|
12
|
+
payload: ProgressionFromAPI;
|
|
13
|
+
};
|
|
10
14
|
export declare const postAnswer: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|
|
@@ -18,4 +18,4 @@ export declare type EditAnswerAction = {
|
|
|
18
18
|
type: typeof EDIT_QCM | typeof EDIT_QCM_GRAPHIC | typeof EDIT_QCM_DRAG | typeof EDIT_TEMPLATE | typeof EDIT_BASIC | typeof EDIT_SLIDER;
|
|
19
19
|
payload: string[];
|
|
20
20
|
};
|
|
21
|
-
export declare const editAnswer: (answer: string) => (dispatch: Dispatch, getState: () => StoreState) => EditAnswerAction;
|
|
21
|
+
export declare const editAnswer: (answer: string[]) => (dispatch: Dispatch, getState: () => StoreState) => EditAnswerAction;
|
package/es/actions/ui/answers.js
CHANGED
|
@@ -18,13 +18,15 @@ const buildAnswer = (userAnswers, questionType, newValue) => {
|
|
|
18
18
|
case 'qcm':
|
|
19
19
|
case 'qcmGraphic':
|
|
20
20
|
case 'qcmDrag': {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const firstValue = newValue[0];
|
|
22
|
+
return includes(firstValue, userAnswers)
|
|
23
|
+
? pull(firstValue, userAnswers)
|
|
24
|
+
: flatten([...userAnswers, firstValue]);
|
|
24
25
|
}
|
|
25
26
|
case 'basic':
|
|
26
27
|
case 'slider':
|
|
27
|
-
|
|
28
|
+
case 'template':
|
|
29
|
+
return newValue;
|
|
28
30
|
default:
|
|
29
31
|
return [];
|
|
30
32
|
}
|
|
@@ -8,6 +8,7 @@ import { qcmDragSlide } from '../../../views/slides/test/fixtures/qcm-drag';
|
|
|
8
8
|
import { qcmSlide } from '../../../views/slides/test/fixtures/qcm';
|
|
9
9
|
import { qcmGraphicSlide } from '../../../views/slides/test/fixtures/qcm-graphic';
|
|
10
10
|
import { sliderSlide } from '../../../views/slides/test/fixtures/slider';
|
|
11
|
+
import { templateSlide } from '../../../views/slides/test/fixtures/template';
|
|
11
12
|
import { editAnswer, ANSWER_EDIT } from '../answers';
|
|
12
13
|
const initialState = {
|
|
13
14
|
data: {
|
|
@@ -55,14 +56,14 @@ test('should dispatch EDIT_BASIC action when editAnswer is called', async (t) =>
|
|
|
55
56
|
const state = buildInitialState(initialState, freeTextSlide);
|
|
56
57
|
const expectedActions = [{ type: ANSWER_EDIT.basic, payload: ['My Answer'] }];
|
|
57
58
|
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
58
|
-
await dispatch(editAnswer('My Answer'));
|
|
59
|
+
await dispatch(editAnswer(['My Answer']));
|
|
59
60
|
});
|
|
60
61
|
test('should dispatch EDIT_QCM action when editAnswer is called', async (t) => {
|
|
61
62
|
let state = buildInitialState(initialState, qcmSlide);
|
|
62
63
|
state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer'], state);
|
|
63
64
|
const expectedActions = [{ type: ANSWER_EDIT.qcm, payload: ['My First Answer'] }];
|
|
64
65
|
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
65
|
-
await dispatch(editAnswer('My Second Answer'));
|
|
66
|
+
await dispatch(editAnswer(['My Second Answer']));
|
|
66
67
|
});
|
|
67
68
|
test('should dispatch EDIT_QCM_GRAPHIC action when editAnswer is called', async (t) => {
|
|
68
69
|
let state = buildInitialState(initialState, qcmGraphicSlide);
|
|
@@ -71,7 +72,7 @@ test('should dispatch EDIT_QCM_GRAPHIC action when editAnswer is called', async
|
|
|
71
72
|
{ type: ANSWER_EDIT.qcmGraphic, payload: ['My First Answer', 'My Third Answer'] }
|
|
72
73
|
];
|
|
73
74
|
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
74
|
-
await dispatch(editAnswer('My Second Answer'));
|
|
75
|
+
await dispatch(editAnswer(['My Second Answer']));
|
|
75
76
|
});
|
|
76
77
|
test('should dispatch EDIT_QCM_DRAG action when editAnswer is called', async (t) => {
|
|
77
78
|
let state = buildInitialState(initialState, qcmDragSlide);
|
|
@@ -80,11 +81,20 @@ test('should dispatch EDIT_QCM_DRAG action when editAnswer is called', async (t)
|
|
|
80
81
|
{ type: ANSWER_EDIT.qcmDrag, payload: ['My First Answer', 'My Second Answer', 'My Third Answer'] }
|
|
81
82
|
];
|
|
82
83
|
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
83
|
-
await dispatch(editAnswer('My Third Answer'));
|
|
84
|
+
await dispatch(editAnswer(['My Third Answer']));
|
|
84
85
|
});
|
|
85
86
|
test('should dispatch EDIT_SLIDER action when editAnswer is called', async (t) => {
|
|
86
87
|
const state = buildInitialState(initialState, sliderSlide);
|
|
87
88
|
const expectedActions = [{ type: ANSWER_EDIT.slider, payload: ['5'] }];
|
|
88
89
|
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
89
|
-
await dispatch(editAnswer('5'));
|
|
90
|
+
await dispatch(editAnswer(['5']));
|
|
91
|
+
});
|
|
92
|
+
test('should dispatch EDIT_TEMPLATE action when editAnswer is called', async (t) => {
|
|
93
|
+
let state = buildInitialState(initialState, templateSlide);
|
|
94
|
+
state = set(['ui', 'answers'], ['Catalogue', '', 'étoiles'], state);
|
|
95
|
+
const expectedActions = [
|
|
96
|
+
{ type: ANSWER_EDIT.template, payload: ['Catalogue', 'My Answer', 'étoiles'] }
|
|
97
|
+
];
|
|
98
|
+
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
99
|
+
await dispatch(editAnswer(['Catalogue', 'My Answer', 'étoiles']));
|
|
90
100
|
});
|
|
@@ -14,5 +14,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
14
14
|
skills: SkillsState;
|
|
15
15
|
slides: SlidesState;
|
|
16
16
|
token: TokenState;
|
|
17
|
-
}>, import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
|
|
17
|
+
}>, import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
|
|
18
18
|
export default _default;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { PostAnswerSuccessAction } from '../../actions/api/post-answer';
|
|
1
2
|
import { ReceivedProgression } from '../../actions/api/post-progression';
|
|
2
3
|
import { ProgressionFromAPI } from '../../types/common';
|
|
3
4
|
export declare type ProgressionState = ProgressionFromAPI | null;
|
|
4
|
-
declare const reducer: (state: ProgressionState | undefined, action: ReceivedProgression) => ProgressionState;
|
|
5
|
+
declare const reducer: (state: ProgressionState | undefined, action: ReceivedProgression | PostAnswerSuccessAction) => ProgressionState;
|
|
5
6
|
export default reducer;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { POST_ANSWER_SUCCESS } from '../../actions/api/post-answer';
|
|
1
2
|
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
2
3
|
const reducer = (
|
|
3
4
|
// eslint-disable-next-line default-param-last
|
|
4
5
|
state = null, action) => {
|
|
5
6
|
switch (action.type) {
|
|
7
|
+
case POST_ANSWER_SUCCESS:
|
|
6
8
|
case POST_PROGRESSION_SUCCESS: {
|
|
7
9
|
const progression = action.payload;
|
|
8
10
|
return progression;
|
|
@@ -1,38 +1,23 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import reducer from '../progression';
|
|
3
3
|
import { POST_PROGRESSION_SUCCESS } from '../../../actions/api/post-progression';
|
|
4
|
+
import { POST_ANSWER_SUCCESS } from '../../../actions/api/post-answer';
|
|
5
|
+
import { postAnswerResponse, postProgressionResponse } from '../../../test/util/services.mock';
|
|
4
6
|
test('should have initial value', t => {
|
|
5
7
|
const state = reducer(undefined, {});
|
|
6
8
|
t.is(state, null);
|
|
7
9
|
});
|
|
8
10
|
test('should set the value of POST_PROGRESSION_SUCCESS action', t => {
|
|
9
|
-
const progression = {
|
|
10
|
-
_id: '62b1d1087aa12f00253f40ee',
|
|
11
|
-
content: {
|
|
12
|
-
ref: '_skill-ref',
|
|
13
|
-
type: 'skill'
|
|
14
|
-
},
|
|
15
|
-
engine: {
|
|
16
|
-
ref: 'review'
|
|
17
|
-
},
|
|
18
|
-
state: {
|
|
19
|
-
allAnswers: [],
|
|
20
|
-
isCorrect: true,
|
|
21
|
-
nextContent: {
|
|
22
|
-
ref: 'sli_N1XACJobn',
|
|
23
|
-
type: 'slide'
|
|
24
|
-
},
|
|
25
|
-
pendingSlides: [],
|
|
26
|
-
slides: [],
|
|
27
|
-
step: {
|
|
28
|
-
current: 1
|
|
29
|
-
},
|
|
30
|
-
stars: 0
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
11
|
const state = reducer(null, {
|
|
34
12
|
type: POST_PROGRESSION_SUCCESS,
|
|
35
|
-
payload:
|
|
13
|
+
payload: postProgressionResponse
|
|
36
14
|
});
|
|
37
|
-
t.deepEqual(state,
|
|
15
|
+
t.deepEqual(state, postProgressionResponse);
|
|
16
|
+
});
|
|
17
|
+
test('should set the value of POST_ANSWER_SUCCESS action', t => {
|
|
18
|
+
const state = reducer(null, {
|
|
19
|
+
type: POST_ANSWER_SUCCESS,
|
|
20
|
+
payload: postAnswerResponse
|
|
21
|
+
});
|
|
22
|
+
t.deepEqual(state, postAnswerResponse);
|
|
38
23
|
});
|
package/es/reducers/index.d.ts
CHANGED
|
@@ -17,5 +17,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
17
17
|
answers: import("./ui/answers").AnswerState;
|
|
18
18
|
slide: import("./ui/slide").UISlideState;
|
|
19
19
|
}>;
|
|
20
|
-
}>, import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction
|
|
20
|
+
}>, import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
|
|
21
21
|
export default _default;
|
|
@@ -13,5 +13,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
13
13
|
navigation: NavigationState;
|
|
14
14
|
answers: AnswerState;
|
|
15
15
|
slide: UISlideState;
|
|
16
|
-
}>, import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/
|
|
16
|
+
}>, import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction>;
|
|
17
17
|
export default _default;
|
|
@@ -25,3 +25,7 @@ test('should set the value of EDIT_SLIDER action', t => {
|
|
|
25
25
|
const state = reducer([], { type: ANSWER_EDIT.slider, payload: ['5'] });
|
|
26
26
|
t.deepEqual(state, ['5']);
|
|
27
27
|
});
|
|
28
|
+
test('should set the value of EDIT_TEMPLATE action', t => {
|
|
29
|
+
const state = reducer([], { type: ANSWER_EDIT.template, payload: ['value1', 'value2'] });
|
|
30
|
+
t.deepEqual(state, ['value1', 'value2']);
|
|
31
|
+
});
|
|
@@ -2,6 +2,7 @@ import { qcmSlide } from '../../views/slides/test/fixtures/qcm';
|
|
|
2
2
|
import { qcmGraphicSlide } from '../../views/slides/test/fixtures/qcm-graphic';
|
|
3
3
|
import { freeTextSlide } from '../../views/slides/test/fixtures/free-text';
|
|
4
4
|
import { sliderSlide } from '../../views/slides/test/fixtures/slider';
|
|
5
|
+
import { templateSlide } from '../../views/slides/test/fixtures/template';
|
|
5
6
|
const getSlideFixture = (ref) => {
|
|
6
7
|
switch (ref) {
|
|
7
8
|
case qcmSlide.universalRef:
|
|
@@ -10,6 +11,8 @@ const getSlideFixture = (ref) => {
|
|
|
10
11
|
return qcmGraphicSlide;
|
|
11
12
|
case freeTextSlide.universalRef:
|
|
12
13
|
return freeTextSlide;
|
|
14
|
+
case templateSlide.universalRef:
|
|
15
|
+
return templateSlide;
|
|
13
16
|
default:
|
|
14
17
|
return sliderSlide;
|
|
15
18
|
}
|
|
@@ -28,7 +31,7 @@ const fetchSkillsResponse = [
|
|
|
28
31
|
custom: true
|
|
29
32
|
}
|
|
30
33
|
];
|
|
31
|
-
const postProgressionResponse = {
|
|
34
|
+
export const postProgressionResponse = {
|
|
32
35
|
_id: '62b1d1087aa12f00253f40ee',
|
|
33
36
|
content: {
|
|
34
37
|
ref: '_skill-ref',
|
package/es/views/slides/index.js
CHANGED
|
@@ -44,7 +44,7 @@ export const initialState = {
|
|
|
44
44
|
const getProgressionSlidesRefs = (progression) => {
|
|
45
45
|
if (progression.state.step.current < 5) {
|
|
46
46
|
const slideRef = progression.state.nextContent.ref;
|
|
47
|
-
return concat(
|
|
47
|
+
return concat(progression.state.slides, [slideRef]);
|
|
48
48
|
}
|
|
49
49
|
return slice(0, 5, progression.state.slides);
|
|
50
50
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { concat, divide, get, getOr, head, includes, indexOf, isEmpty, map, multiply, pipe, rangeStep, round, size, toInteger, toString as _toString, __ } from 'lodash/fp';
|
|
1
|
+
import { concat, constant, divide, get, getOr, head, includes, indexOf, isEmpty, isNil, map, multiply, pipe, rangeStep, round, set, size, times, toInteger, toString as _toString, __ } from 'lodash/fp';
|
|
2
2
|
import { editAnswer } from '../../actions/ui/answers';
|
|
3
3
|
const qcmProps = (dispatch) => (answers, question) => {
|
|
4
4
|
return {
|
|
@@ -9,7 +9,7 @@ const qcmProps = (dispatch) => (answers, question) => {
|
|
|
9
9
|
title: label,
|
|
10
10
|
selected: includes(label, answers),
|
|
11
11
|
onClick: () => {
|
|
12
|
-
dispatch(editAnswer(label));
|
|
12
|
+
dispatch(editAnswer([label]));
|
|
13
13
|
},
|
|
14
14
|
ariaLabel: choice.label
|
|
15
15
|
};
|
|
@@ -27,7 +27,7 @@ const qcmDragProps = (dispatch) => (answers, question) => {
|
|
|
27
27
|
selected: includes(label, answers),
|
|
28
28
|
order: indexInAnswer,
|
|
29
29
|
onClick: () => {
|
|
30
|
-
dispatch(editAnswer(label));
|
|
30
|
+
dispatch(editAnswer([label]));
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
}, question.content.choices)
|
|
@@ -43,28 +43,29 @@ const qcmGraphicProps = (dispatch) => (answers, question) => {
|
|
|
43
43
|
image: get('media.src.0.url', choice),
|
|
44
44
|
selected: includes(label, answers),
|
|
45
45
|
onClick: () => {
|
|
46
|
-
dispatch(editAnswer(label));
|
|
46
|
+
dispatch(editAnswer([label]));
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
}, question.content.choices)
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const updateTemplateAnswer = (text, _answers, index, max) => {
|
|
53
|
+
const answers = isEmpty(_answers) ? times(constant(undefined), max) : _answers;
|
|
54
|
+
return map(a => (isNil(a) ? '' : a), set(index, text, answers));
|
|
55
|
+
};
|
|
56
|
+
const templateTextProps = (dispatch, answers, choice, index, maxLength) => {
|
|
55
57
|
return {
|
|
56
58
|
type: 'text',
|
|
57
59
|
name: getOr('', 'name', choice),
|
|
58
60
|
placeholder: 'Type here',
|
|
59
61
|
value: get(index, answers),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
onChange: (text) => {
|
|
63
|
+
const newAnswers = updateTemplateAnswer(text, answers, index, maxLength);
|
|
64
|
+
dispatch(editAnswer(newAnswers));
|
|
65
|
+
}
|
|
63
66
|
};
|
|
64
67
|
};
|
|
65
|
-
const templateSelectProps = (choice, index) => {
|
|
66
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
67
|
-
const answers = [];
|
|
68
|
+
const templateSelectProps = (dispatch, answers, choice, index, maxLength) => {
|
|
68
69
|
const answer = get(index, answers);
|
|
69
70
|
const temporaryOption = {
|
|
70
71
|
name: 'Select an answer',
|
|
@@ -84,19 +85,22 @@ const templateSelectProps = (choice, index) => {
|
|
|
84
85
|
return {
|
|
85
86
|
type: 'select',
|
|
86
87
|
name: getOr('', 'name', choice),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
onChange: (text) => {
|
|
89
|
+
const newAnswers = updateTemplateAnswer(text, answers, index, maxLength);
|
|
90
|
+
dispatch(editAnswer(newAnswers));
|
|
91
|
+
},
|
|
90
92
|
options: isEmpty(answer) ? concat([temporaryOption], selectOptions) : selectOptions
|
|
91
93
|
};
|
|
92
94
|
};
|
|
93
|
-
const templateProps = (question) => {
|
|
94
|
-
// TODO: EDIT_CHOICES -> getChoices
|
|
95
|
+
const templateProps = (dispatch) => (answers, question) => {
|
|
95
96
|
const choices = question.content.choices;
|
|
97
|
+
const maxLength = size(choices);
|
|
96
98
|
return {
|
|
97
99
|
type: 'template',
|
|
98
100
|
template: get('content.template', question),
|
|
99
|
-
answers: choices.map((choice, index) => choice.type === 'text'
|
|
101
|
+
answers: choices.map((choice, index) => choice.type === 'text'
|
|
102
|
+
? templateTextProps(dispatch, answers, choice, index, maxLength)
|
|
103
|
+
: templateSelectProps(dispatch, answers, choice, index, maxLength))
|
|
100
104
|
};
|
|
101
105
|
};
|
|
102
106
|
const basicProps = (dispatch) => (answers, question) => {
|
|
@@ -105,7 +109,7 @@ const basicProps = (dispatch) => (answers, question) => {
|
|
|
105
109
|
placeholder: question.content.placeholder || '',
|
|
106
110
|
value: answers[0] || '',
|
|
107
111
|
onChange: (text) => {
|
|
108
|
-
dispatch(editAnswer(text));
|
|
112
|
+
dispatch(editAnswer([text]));
|
|
109
113
|
}
|
|
110
114
|
};
|
|
111
115
|
};
|
|
@@ -128,7 +132,7 @@ const sliderProps = (dispatch) => (answers, question) => {
|
|
|
128
132
|
value: sliderPosition,
|
|
129
133
|
onChange: (position) => {
|
|
130
134
|
const newValue = pipe(multiply(maxValue), round, get(__, values), _toString)(position);
|
|
131
|
-
dispatch(editAnswer(newValue));
|
|
135
|
+
dispatch(editAnswer([newValue]));
|
|
132
136
|
}
|
|
133
137
|
};
|
|
134
138
|
};
|
|
@@ -146,7 +150,7 @@ const getAnswerUIModel = (question, answers, dispatch) => {
|
|
|
146
150
|
case 'basic':
|
|
147
151
|
return basicProps(dispatch)(answers, question);
|
|
148
152
|
case 'template':
|
|
149
|
-
return templateProps(question);
|
|
153
|
+
return templateProps(dispatch)(answers, question);
|
|
150
154
|
case 'slider':
|
|
151
155
|
return sliderProps(dispatch)(answers, question);
|
|
152
156
|
default:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import noop from 'lodash/fp/noop';
|
|
2
|
-
export const
|
|
2
|
+
export const templateSlide = {
|
|
3
3
|
question: {
|
|
4
4
|
content: {
|
|
5
|
-
template: 'La vue {{sel80495}} présente la liste des
|
|
5
|
+
template: 'La vue {{sel80495}} présente la liste des {{inp58402}} ayant le plus grand nombre d’{{sel80496}} cumulées.',
|
|
6
6
|
choices: [
|
|
7
7
|
{
|
|
8
8
|
items: [
|
|
@@ -30,6 +30,45 @@ export const selectTemplateSlide = {
|
|
|
30
30
|
_id: '5b57464e3b594d002e8829f3',
|
|
31
31
|
name: 'sel80495',
|
|
32
32
|
type: 'select'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
media: {
|
|
36
|
+
src: [],
|
|
37
|
+
posters: [],
|
|
38
|
+
subtitles: []
|
|
39
|
+
},
|
|
40
|
+
items: [],
|
|
41
|
+
_id: '62433c2c58920f02c4950de0',
|
|
42
|
+
type: 'text',
|
|
43
|
+
name: 'inp58402',
|
|
44
|
+
id: '62433c2c58920f02c4950de0'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
items: [
|
|
48
|
+
{
|
|
49
|
+
_id: '5b57464e3b594d002e8829f7',
|
|
50
|
+
value: 'sli_N13-hG3kX.choice_NJgC3aznJm',
|
|
51
|
+
text: 'étoiles'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
_id: '5b57464e3b594d002e8829f6',
|
|
55
|
+
value: 'sli_N13-hG3kX.choice_EJZ02aMny7',
|
|
56
|
+
text: 'idées'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
_id: '5b57464e3b594d002e8829f5',
|
|
60
|
+
value: 'sli_N13-hG3kX.choice_4keCaf21Q',
|
|
61
|
+
text: 'envies'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
_id: '5b57464e3b594d002e8829f4',
|
|
65
|
+
value: 'sli_N13-hG3kX.choice_NkbJAMn17',
|
|
66
|
+
text: 'images'
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
_id: '5b57464e3b594d002e8829f3',
|
|
70
|
+
name: 'sel80496',
|
|
71
|
+
type: 'select'
|
|
33
72
|
}
|
|
34
73
|
]
|
|
35
74
|
},
|
|
@@ -46,13 +85,13 @@ export const selectTemplateSlide = {
|
|
|
46
85
|
type: 'course'
|
|
47
86
|
}
|
|
48
87
|
};
|
|
49
|
-
export const
|
|
88
|
+
export const templateUISlide = {
|
|
50
89
|
questionText: 'Complétez la phrase ci-dessous.',
|
|
51
90
|
answerUI: {
|
|
52
91
|
help: 'Saisissez votre réponse ou sélectionnez la bonne réponse dans le(s) menu(s) déroulant(s).',
|
|
53
92
|
model: {
|
|
54
93
|
type: 'template',
|
|
55
|
-
template: 'La vue {{sel80495}} présente la liste des
|
|
94
|
+
template: 'La vue {{sel80495}} présente la liste des {{inp58402}} ayant le plus grand nombre d’{{sel80496}} cumulées.',
|
|
56
95
|
answers: [
|
|
57
96
|
{
|
|
58
97
|
type: 'select',
|
|
@@ -85,6 +124,45 @@ export const selectTemplateUISlide = {
|
|
|
85
124
|
selected: false
|
|
86
125
|
}
|
|
87
126
|
]
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
type: 'text',
|
|
130
|
+
name: 'inp58402',
|
|
131
|
+
placeholder: 'Type here',
|
|
132
|
+
value: undefined,
|
|
133
|
+
onChange: noop
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
type: 'select',
|
|
137
|
+
name: 'sel80496',
|
|
138
|
+
onChange: noop,
|
|
139
|
+
options: [
|
|
140
|
+
{ name: 'Select an answer', value: '', validOption: false, selected: true },
|
|
141
|
+
{
|
|
142
|
+
name: 'étoiles',
|
|
143
|
+
value: 'étoiles',
|
|
144
|
+
validOption: true,
|
|
145
|
+
selected: false
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'idées',
|
|
149
|
+
value: 'idées',
|
|
150
|
+
validOption: true,
|
|
151
|
+
selected: false
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'envies',
|
|
155
|
+
value: 'envies',
|
|
156
|
+
validOption: true,
|
|
157
|
+
selected: false
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: 'images',
|
|
161
|
+
value: 'images',
|
|
162
|
+
validOption: true,
|
|
163
|
+
selected: false
|
|
164
|
+
}
|
|
165
|
+
]
|
|
88
166
|
}
|
|
89
167
|
]
|
|
90
168
|
}
|