@coorpacademy/app-review 0.10.1-alpha.0 → 0.10.1
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-correction.d.ts +1 -2
- package/es/actions/api/fetch-rank.d.ts +1 -2
- package/es/actions/api/fetch-skill.d.ts +1 -2
- package/es/actions/api/fetch-skills.d.ts +1 -2
- package/es/actions/api/fetch-slide.d.ts +1 -2
- package/es/actions/api/fetch-slides-to-review-by-skill-ref.d.ts +1 -2
- package/es/actions/api/post-answer.d.ts +1 -2
- package/es/actions/api/post-progression.d.ts +1 -2
- package/es/actions/ui/navigation.d.ts +1 -1
- package/es/actions/ui/slides.d.ts +1 -1
- package/es/common/index.d.ts +1 -1
- package/es/configure-store.d.ts +1 -1
- package/es/configure-store.js +1 -1
- package/es/reducers/data/corrections.d.ts +1 -1
- package/es/reducers/data/current-skill.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +1 -1
- package/es/reducers/data/skills.d.ts +1 -1
- package/es/reducers/data/slides.d.ts +1 -1
- package/es/reducers/ui/slide.d.ts +1 -0
- package/es/reducers/ui/slide.js +3 -2
- package/es/services/fetch-correction.d.ts +2 -0
- package/es/services/fetch-correction.js +14 -0
- package/es/services/fetch-rank.d.ts +2 -0
- package/es/services/fetch-rank.js +10 -0
- package/es/services/fetch-skill.d.ts +2 -0
- package/es/services/fetch-skill.js +11 -0
- package/es/services/fetch-skills.d.ts +2 -0
- package/es/services/fetch-skills.js +10 -0
- package/es/services/fetch-slide.d.ts +2 -0
- package/es/services/fetch-slide.js +10 -0
- package/es/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
- package/es/services/fetch-slides-to-review-by-skill-ref.js +10 -0
- package/es/services/index.d.ts +2 -0
- package/es/services/index.js +18 -0
- package/es/services/post-answer.d.ts +2 -0
- package/es/services/post-answer.js +20 -0
- package/es/services/post-progression.d.ts +2 -0
- package/es/services/post-progression.js +21 -0
- package/es/services/tools/fetch-responses.d.ts +7 -0
- package/es/services/tools/fetch-responses.js +33 -0
- package/es/services/tools/sleep.d.ts +1 -0
- package/es/services/tools/sleep.js +3 -0
- package/es/types/common.d.ts +186 -10
- package/es/views/skills/index.d.ts +1 -1
- package/es/views/slides/index.d.ts +1 -1
- package/es/views/slides/index.js +2 -0
- package/es/views/slides/map-api-slide-to-ui.d.ts +1 -2
- package/lib/actions/api/fetch-correction.d.ts +1 -2
- package/lib/actions/api/fetch-rank.d.ts +1 -2
- package/lib/actions/api/fetch-skill.d.ts +1 -2
- package/lib/actions/api/fetch-skills.d.ts +1 -2
- package/lib/actions/api/fetch-slide.d.ts +1 -2
- package/lib/actions/api/fetch-slides-to-review-by-skill-ref.d.ts +1 -2
- package/lib/actions/api/post-answer.d.ts +1 -2
- package/lib/actions/api/post-progression.d.ts +1 -2
- package/lib/actions/ui/navigation.d.ts +1 -1
- package/lib/actions/ui/slides.d.ts +1 -1
- package/lib/common/index.d.ts +1 -1
- package/lib/configure-store.d.ts +1 -1
- package/lib/configure-store.js +2 -2
- package/lib/reducers/data/corrections.d.ts +1 -1
- package/lib/reducers/data/current-skill.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +1 -1
- package/lib/reducers/data/skills.d.ts +1 -1
- package/lib/reducers/data/slides.d.ts +1 -1
- package/lib/reducers/ui/slide.d.ts +1 -0
- package/lib/reducers/ui/slide.js +3 -2
- package/lib/services/fetch-correction.d.ts +2 -0
- package/lib/services/fetch-correction.js +21 -0
- package/lib/services/fetch-rank.d.ts +2 -0
- package/lib/services/fetch-rank.js +17 -0
- package/lib/services/fetch-skill.d.ts +2 -0
- package/lib/services/fetch-skill.js +18 -0
- package/lib/services/fetch-skills.d.ts +2 -0
- package/lib/services/fetch-skills.js +17 -0
- package/lib/services/fetch-slide.d.ts +2 -0
- package/lib/services/fetch-slide.js +17 -0
- package/lib/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
- package/lib/services/fetch-slides-to-review-by-skill-ref.js +17 -0
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.js +22 -0
- package/lib/services/post-answer.d.ts +2 -0
- package/lib/services/post-answer.js +27 -0
- package/lib/services/post-progression.d.ts +2 -0
- package/lib/services/post-progression.js +28 -0
- package/lib/services/tools/fetch-responses.d.ts +7 -0
- package/lib/services/tools/fetch-responses.js +40 -0
- package/lib/services/tools/sleep.d.ts +1 -0
- package/lib/services/tools/sleep.js +7 -0
- package/lib/types/common.d.ts +186 -10
- package/lib/views/skills/index.d.ts +1 -1
- package/lib/views/slides/index.d.ts +1 -1
- package/lib/views/slides/index.js +2 -0
- package/lib/views/slides/map-api-slide-to-ui.d.ts +1 -2
- package/locales/bs/review.json +4 -1
- package/locales/cs/review.json +6 -6
- package/locales/de/review.json +7 -7
- package/locales/es/review.json +7 -7
- package/locales/hr/review.json +1 -1
- package/locales/hu/review.json +7 -7
- package/locales/hy/review.json +4 -1
- package/locales/id/review.json +3 -3
- package/locales/it/review.json +6 -6
- package/locales/ja/review.json +5 -5
- package/locales/ko/review.json +7 -7
- package/locales/nl/review.json +6 -6
- package/locales/pl/review.json +6 -6
- package/locales/pt/review.json +7 -7
- package/locales/ro/review.json +6 -6
- package/locales/sk/review.json +3 -3
- package/locales/th/review.json +5 -5
- package/locales/tl/review.json +7 -7
- package/locales/tr/review.json +2 -2
- package/locales/uk/review.json +7 -7
- package/locales/vi/review.json +3 -3
- package/locales/zh/review.json +4 -4
- package/locales/zh_TW/review.json +6 -6
- package/package.json +3 -4
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { CorrectionFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
|
-
import type { ThunkOptions } from '../../types/common';
|
|
4
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import type { CorrectionFromAPI, ThunkOptions } from '../../types/common';
|
|
5
4
|
export declare const CORRECTION_FETCH_REQUEST: "@@correction/FETCH_REQUEST";
|
|
6
5
|
export declare const CORRECTION_FETCH_SUCCESS: "@@correction/FETCH_SUCCESS";
|
|
7
6
|
export declare const CORRECTION_FETCH_FAILURE: "@@correction/FETCH_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { Rank, Services } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
|
-
import type { ThunkOptions } from '../../types/common';
|
|
4
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import type { Rank, Services, ThunkOptions } from '../../types/common';
|
|
5
4
|
export declare const RANK_FETCH_START_REQUEST: "@@rank/FETCH_START_REQUEST";
|
|
6
5
|
export declare const RANK_FETCH_START_SUCCESS: "@@rank/FETCH_START_SUCCESS";
|
|
7
6
|
export declare const RANK_FETCH_START_FAILURE: "@@rank/FETCH_START_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
|
-
import type { Skill } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
|
-
import type { ThunkOptions } from '../../types/common';
|
|
4
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import type { Skill, ThunkOptions } from '../../types/common';
|
|
5
4
|
export declare const SKILL_FETCH_REQUEST: "@@skill/FETCH_REQUEST";
|
|
6
5
|
export declare const SKILL_FETCH_SUCCESS: "@@skill/FETCH_SUCCESS";
|
|
7
6
|
export declare const SKILL_FETCH_FAILURE: "@@skill/FETCH_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { SkillToReview } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
2
|
import type { StoreState } from '../../reducers';
|
|
4
|
-
import type { ThunkOptions } from '../../types/common';
|
|
3
|
+
import type { ThunkOptions, SkillToReview } from '../../types/common';
|
|
5
4
|
export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
|
|
6
5
|
export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
|
|
7
6
|
export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { SlideFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
|
-
import type { ThunkOptions } from '../../types/common';
|
|
4
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import type { ThunkOptions, SlideFromAPI } from '../../types/common';
|
|
5
4
|
export declare const SLIDE_FETCH_REQUEST: "@@slides/FETCH_REQUEST";
|
|
6
5
|
export declare const SLIDE_FETCH_SUCCESS: "@@slides/FETCH_SUCCESS";
|
|
7
6
|
export declare const SLIDE_FETCH_FAILURE: "@@slides/FETCH_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { SlideIdFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
|
-
import { Options } from '../../types/common';
|
|
4
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import type { Options, SlideIdFromAPI } from '../../types/common';
|
|
5
4
|
export declare const SLIDES_TO_REVIEW_FETCH_REQUEST: "@@slidesToReview/FETCH_REQUEST";
|
|
6
5
|
export declare const SLIDES_TO_REVIEW_FETCH_SUCCESS: "@@slidesToReview/FETCH_SUCCESS";
|
|
7
6
|
export declare const SLIDES_TO_REVIEW_FETCH_FAILURE: "@@slidesToReview/FETCH_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { ProgressionFromAPI } from '
|
|
2
|
+
import type { ThunkOptions, ProgressionFromAPI } from '../../types/common';
|
|
3
3
|
import type { StoreState } from '../../reducers';
|
|
4
|
-
import type { ThunkOptions } from '../../types/common';
|
|
5
4
|
export declare const POST_ANSWER_REQUEST: "@@answer/POST_REQUEST";
|
|
6
5
|
export declare const POST_ANSWER_SUCCESS: "@@answer/POST_SUCCESS";
|
|
7
6
|
export declare const POST_ANSWER_FAILURE: "@@answer/POST_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { ProgressionFromAPI } from '
|
|
2
|
+
import type { ThunkOptions, ProgressionFromAPI } from '../../types/common';
|
|
3
3
|
import type { StoreState } from '../../reducers';
|
|
4
|
-
import type { ThunkOptions } from '../../types/common';
|
|
5
4
|
export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
|
|
6
5
|
export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
|
|
7
6
|
export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
|
-
import { ThunkOptions, AppOptions, ViewName } from '../../types/common';
|
|
3
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import { ThunkOptions, AppOptions, ViewName } from '../../types/common';
|
|
4
4
|
export declare type NavigateToAction = {
|
|
5
5
|
type: '@@navigation/NAVIGATE_TO';
|
|
6
6
|
payload: ViewName;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SlideFromAPI } from '
|
|
1
|
+
import { SlideFromAPI } from '../../types/common';
|
|
2
2
|
import { AnswerUI } from '../../types/slides';
|
|
3
3
|
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
4
4
|
export declare type Slide = {
|
package/es/common/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProgressionFromAPI } from '
|
|
1
|
+
import type { ProgressionFromAPI } from '../types/common';
|
|
2
2
|
export declare const slideIndexes: readonly ["0", "1", "2", "3", "4"];
|
|
3
3
|
export declare type SlideIndexes = typeof slideIndexes[number];
|
|
4
4
|
export declare const getProgressionSlidesRefs: (progression: ProgressionFromAPI) => string[];
|
package/es/configure-store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AnyAction, Store } from 'redux';
|
|
2
2
|
import { StoreState } from './reducers';
|
|
3
|
-
import
|
|
3
|
+
import { AppOptions } from './types/common';
|
|
4
4
|
export default function configureStore(options: AppOptions): Store<StoreState, AnyAction>;
|
package/es/configure-store.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { applyMiddleware, compose, createStore } from 'redux';
|
|
2
2
|
import thunk from 'redux-thunk';
|
|
3
|
-
import { getServices } from '@coorpacademy/review-services';
|
|
4
3
|
import rootReducer from './reducers';
|
|
4
|
+
import { getServices } from './services';
|
|
5
5
|
export default function configureStore(options) {
|
|
6
6
|
const _compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
7
7
|
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CorrectionFromAPI } from '
|
|
1
|
+
import type { CorrectionFromAPI } from '../../types/common';
|
|
2
2
|
import { ReceivedCorrection, FetchCorrection } from '../../actions/api/fetch-correction';
|
|
3
3
|
import { FetchProgression } from '../../actions/api/post-progression';
|
|
4
4
|
export declare type CorrectionsState = Record<string, CorrectionFromAPI>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Skill } from '@coorpacademy/review-services/es/types/services-types';
|
|
2
1
|
import { ReceivedSkill } from '../../actions/api/fetch-skill';
|
|
2
|
+
import { Skill } from '../../types/common';
|
|
3
3
|
export declare type CurrentSkillState = Skill | null;
|
|
4
4
|
declare const reducer: (state: CurrentSkillState | undefined, action: ReceivedSkill) => CurrentSkillState;
|
|
5
5
|
export default reducer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ProgressionFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
2
1
|
import { PostAnswerSuccessAction } from '../../actions/api/post-answer';
|
|
3
2
|
import { FetchProgression, ReceivedProgression } from '../../actions/api/post-progression';
|
|
3
|
+
import { ProgressionFromAPI } from '../../types/common';
|
|
4
4
|
export declare type ProgressionState = ProgressionFromAPI | null;
|
|
5
5
|
declare const reducer: (state: ProgressionState | undefined, action: ReceivedProgression | PostAnswerSuccessAction | FetchProgression) => ProgressionState;
|
|
6
6
|
export default reducer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SkillToReview } from '
|
|
1
|
+
import { SkillToReview } from '../../types/common';
|
|
2
2
|
import { ReceivedSkills } from '../../actions/api/fetch-skills';
|
|
3
3
|
export declare type SkillsState = SkillToReview[];
|
|
4
4
|
declare const reducer: (state: SkillsState | undefined, action: ReceivedSkills) => SkillsState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SlideFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
2
1
|
import { ReceivedSlide, FetchSlide } from '../../actions/api/fetch-slide';
|
|
3
2
|
import { FetchProgression } from '../../actions/api/post-progression';
|
|
3
|
+
import { SlideFromAPI } from '../../types/common';
|
|
4
4
|
export declare type SlidesAction = FetchSlide | ReceivedSlide;
|
|
5
5
|
export declare type SlidesState = Record<string, SlideFromAPI | null>;
|
|
6
6
|
export declare const initialState: SlidesState;
|
|
@@ -10,6 +10,7 @@ export declare type UISlide = {
|
|
|
10
10
|
animateCorrectionPopin: boolean;
|
|
11
11
|
showCorrectionPopin: boolean;
|
|
12
12
|
animationType?: SlideUIAnimations;
|
|
13
|
+
pendingAnswerRequest: boolean;
|
|
13
14
|
};
|
|
14
15
|
export declare type UISlideState = Record<string, UISlide>;
|
|
15
16
|
export declare const initialState: UISlideState;
|
package/es/reducers/ui/slide.js
CHANGED
|
@@ -18,7 +18,8 @@ state = initialState, action) => {
|
|
|
18
18
|
return pipe(unset([action.meta.slideRef, 'animationType']), set([action.meta.slideRef], {
|
|
19
19
|
validateButton: false,
|
|
20
20
|
animateCorrectionPopin: false,
|
|
21
|
-
showCorrectionPopin: false
|
|
21
|
+
showCorrectionPopin: false,
|
|
22
|
+
pendingAnswerRequest: false
|
|
22
23
|
}))(state);
|
|
23
24
|
}
|
|
24
25
|
case EDIT_QCM:
|
|
@@ -30,7 +31,7 @@ state = initialState, action) => {
|
|
|
30
31
|
return set([action.meta.slideRef, 'validateButton'], !pipe(compact, isEmpty)(action.payload), state);
|
|
31
32
|
}
|
|
32
33
|
case POST_ANSWER_REQUEST: {
|
|
33
|
-
return set([action.meta.slideRef, 'validateButton'], false, state);
|
|
34
|
+
return pipe(set([action.meta.slideRef, 'validateButton'], false), set([action.meta.slideRef, 'pendingAnswerRequest'], true))(state);
|
|
34
35
|
}
|
|
35
36
|
case CORRECTION_FETCH_SUCCESS: {
|
|
36
37
|
return pipe(set([action.meta.slideRef, 'animateCorrectionPopin'], true), set([action.meta.slideRef, 'showCorrectionPopin'], true))(state);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const fetchCorrection = async (slideRef, token, progressionId, answer) => {
|
|
5
|
+
const { host } = decode(token);
|
|
6
|
+
const response = await crossFetch(`${host}/api/v2/progressions/${progressionId}/answers/${slideRef}`, {
|
|
7
|
+
method: 'post',
|
|
8
|
+
headers: { authorization: token },
|
|
9
|
+
body: JSON.stringify({
|
|
10
|
+
answer
|
|
11
|
+
})
|
|
12
|
+
});
|
|
13
|
+
return toJSON(response);
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const fetchRank = async (token) => {
|
|
5
|
+
const { user: userId, host } = decode(token);
|
|
6
|
+
const response = await crossFetch(`${host}/api/v1/leaderboard/rank/${userId}?group=ALL`, {
|
|
7
|
+
headers: { authorization: token }
|
|
8
|
+
});
|
|
9
|
+
return toJSON(response);
|
|
10
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const fetchSkill = async (skillRef, token) => {
|
|
5
|
+
const { host } = decode(token);
|
|
6
|
+
const response = await crossFetch(`${host}/api/v2/skills?conditions={"ref":"${skillRef}"}`, {
|
|
7
|
+
headers: { authorization: token }
|
|
8
|
+
});
|
|
9
|
+
const skills = await toJSON(response);
|
|
10
|
+
return skills[0];
|
|
11
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const fetchSkills = async (token) => {
|
|
5
|
+
const { user: userId, host } = decode(token);
|
|
6
|
+
const response = await crossFetch(`${host}/api/v2/skills/review/user/${userId}`, {
|
|
7
|
+
headers: { authorization: token }
|
|
8
|
+
});
|
|
9
|
+
return toJSON(response);
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const fetchSlide = async (slideRef, token) => {
|
|
5
|
+
const { host } = decode(token);
|
|
6
|
+
const response = await crossFetch(`${host}/api/v1/slides/${slideRef}/parentContentTitle`, {
|
|
7
|
+
headers: { authorization: token }
|
|
8
|
+
});
|
|
9
|
+
return toJSON(response);
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const fetchSlidesToReviewBySkillRef = async (token, skillRef) => {
|
|
5
|
+
const { user: userId, host } = decode(token);
|
|
6
|
+
const response = await crossFetch(`${host}/api/v2/skills/${skillRef}/review/user/${userId}/slide`, {
|
|
7
|
+
headers: { authorization: token }
|
|
8
|
+
});
|
|
9
|
+
return toJSON(response);
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { fetchCorrection } from './fetch-correction';
|
|
2
|
+
import { fetchRank } from './fetch-rank';
|
|
3
|
+
import { fetchSkills } from './fetch-skills';
|
|
4
|
+
import { fetchSlide } from './fetch-slide';
|
|
5
|
+
import { fetchSlidesToReviewBySkillRef } from './fetch-slides-to-review-by-skill-ref';
|
|
6
|
+
import { postAnswer } from './post-answer';
|
|
7
|
+
import { postProgression } from './post-progression';
|
|
8
|
+
import { fetchSkill } from './fetch-skill';
|
|
9
|
+
export const getServices = () => ({
|
|
10
|
+
fetchCorrection,
|
|
11
|
+
fetchRank,
|
|
12
|
+
fetchSkill,
|
|
13
|
+
fetchSkills,
|
|
14
|
+
fetchSlide,
|
|
15
|
+
fetchSlidesToReviewBySkillRef,
|
|
16
|
+
postAnswer,
|
|
17
|
+
postProgression
|
|
18
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const postAnswer = async (progression, token, answer) => {
|
|
5
|
+
const progressionId = progression._id;
|
|
6
|
+
const slideRef = progression.state.nextContent.ref;
|
|
7
|
+
const { host } = decode(token);
|
|
8
|
+
const response = await crossFetch(`${host}/api/v2/progressions/${progressionId}/answers`, {
|
|
9
|
+
method: 'post',
|
|
10
|
+
headers: { authorization: token, 'content-type': 'application/json' },
|
|
11
|
+
body: JSON.stringify({
|
|
12
|
+
content: {
|
|
13
|
+
ref: slideRef,
|
|
14
|
+
type: 'slide'
|
|
15
|
+
},
|
|
16
|
+
answer
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
return toJSON(response);
|
|
20
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const postProgression = async (skillRef, token) => {
|
|
5
|
+
const { host } = decode(token);
|
|
6
|
+
const response = await crossFetch(`${host}/api/v2/progressions`, {
|
|
7
|
+
method: 'post',
|
|
8
|
+
headers: { authorization: token, 'content-type': 'application/json' },
|
|
9
|
+
body: JSON.stringify({
|
|
10
|
+
content: {
|
|
11
|
+
ref: skillRef,
|
|
12
|
+
type: 'skill'
|
|
13
|
+
},
|
|
14
|
+
engine: {
|
|
15
|
+
ref: 'review',
|
|
16
|
+
version: '1'
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
return toJSON(response);
|
|
21
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class ResponseError extends Error {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
constructor(statusCode: number, statusText: string, body?: string);
|
|
4
|
+
}
|
|
5
|
+
export declare const toJSON: <T = unknown>(response: Response) => Promise<T>;
|
|
6
|
+
export declare const toText: (response: Response) => Promise<string>;
|
|
7
|
+
export declare const toVoid: (response: Response) => Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export class ResponseError extends Error {
|
|
2
|
+
constructor(statusCode, statusText, body = '') {
|
|
3
|
+
super(`${statusText} ${body}`.trim());
|
|
4
|
+
this.name = 'ResponseError';
|
|
5
|
+
this.statusCode = statusCode;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export const toJSON = async (response) => {
|
|
9
|
+
if (!response.ok) {
|
|
10
|
+
const body = await response.text();
|
|
11
|
+
throw new ResponseError(response.status, response.statusText, body);
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
return await response.json();
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
throw new ResponseError(response.status, response.statusText);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export const toText = async (response) => {
|
|
21
|
+
const body = await response.text();
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
throw new ResponseError(response.status, response.statusText, body);
|
|
24
|
+
}
|
|
25
|
+
return body;
|
|
26
|
+
};
|
|
27
|
+
export const toVoid = async (response) => {
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
const body = await response.text();
|
|
30
|
+
throw new ResponseError(response.status, response.statusText, body);
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sleep: (msToSleep: number) => Promise<void>;
|
package/es/types/common.d.ts
CHANGED
|
@@ -1,16 +1,164 @@
|
|
|
1
|
-
|
|
2
|
-
export declare type WithRequired<T, K extends keyof T> = T & {
|
|
3
|
-
[P in K]-?: T[P];
|
|
4
|
-
};
|
|
1
|
+
export declare type ViewName = 'skills' | 'onboarding' | 'slides' | 'loader';
|
|
5
2
|
export interface Translate {
|
|
6
3
|
(key: string, data?: Record<string, string>): string;
|
|
7
4
|
}
|
|
8
|
-
export declare type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
export declare type ChoiceFromAPI = {
|
|
6
|
+
_id: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
type?: 'text' | 'select';
|
|
11
|
+
label?: string;
|
|
12
|
+
items: {
|
|
13
|
+
text: string;
|
|
14
|
+
value: string;
|
|
15
|
+
_id: string;
|
|
16
|
+
}[];
|
|
17
|
+
media?: unknown;
|
|
18
|
+
};
|
|
19
|
+
declare type BaseContent = {
|
|
20
|
+
media?: unknown;
|
|
21
|
+
choices: ChoiceFromAPI[];
|
|
22
|
+
answers: string[][];
|
|
23
|
+
};
|
|
24
|
+
declare type BaseQuestion = {
|
|
25
|
+
header?: string;
|
|
26
|
+
content: BaseContent;
|
|
27
|
+
explanation?: string;
|
|
28
|
+
};
|
|
29
|
+
export declare type QcmQuestion = BaseQuestion & {
|
|
30
|
+
type: 'qcm';
|
|
31
|
+
};
|
|
32
|
+
export declare type QcmGraphicQuestion = BaseQuestion & {
|
|
33
|
+
type: 'qcmGraphic';
|
|
34
|
+
};
|
|
35
|
+
export declare type QcmDragQuestion = BaseQuestion & {
|
|
36
|
+
type: 'qcmDrag';
|
|
37
|
+
};
|
|
38
|
+
export declare type BasicQuestion = Omit<BaseQuestion, 'content'> & {
|
|
39
|
+
type: 'basic';
|
|
40
|
+
content: {
|
|
41
|
+
media?: unknown;
|
|
42
|
+
label?: string;
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
id: string;
|
|
45
|
+
answers: string[][];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export declare type SliderQuestion = Omit<BaseQuestion, 'content'> & {
|
|
49
|
+
content: {
|
|
50
|
+
media?: unknown;
|
|
51
|
+
unitLabel: string;
|
|
52
|
+
min: number;
|
|
53
|
+
max: number;
|
|
54
|
+
step?: number;
|
|
55
|
+
answers: string[][];
|
|
56
|
+
};
|
|
57
|
+
type: 'slider';
|
|
58
|
+
};
|
|
59
|
+
export declare type TemplateQuestion = Omit<BaseQuestion, 'content'> & {
|
|
60
|
+
content: BaseContent & {
|
|
61
|
+
template: string;
|
|
62
|
+
answers: string[][];
|
|
63
|
+
};
|
|
64
|
+
type: 'template';
|
|
65
|
+
};
|
|
66
|
+
export declare type Question = QcmQuestion | QcmGraphicQuestion | QcmDragQuestion | BasicQuestion | SliderQuestion | TemplateQuestion;
|
|
67
|
+
export declare type SlideFromAPI = {
|
|
68
|
+
_id: string;
|
|
69
|
+
question: Question;
|
|
70
|
+
klf: string;
|
|
71
|
+
universalRef: string;
|
|
72
|
+
tips?: string;
|
|
73
|
+
clue?: string;
|
|
74
|
+
hasClue?: boolean;
|
|
75
|
+
parentContentTitle: {
|
|
76
|
+
title: string;
|
|
77
|
+
type: 'chapter' | 'course';
|
|
12
78
|
};
|
|
13
79
|
};
|
|
80
|
+
export declare type SlideIdFromAPI = {
|
|
81
|
+
slideId: string;
|
|
82
|
+
};
|
|
83
|
+
export declare type Rank = {
|
|
84
|
+
rank: number;
|
|
85
|
+
};
|
|
86
|
+
export declare type ProgressionAnswerItem = {
|
|
87
|
+
isCorrect: boolean;
|
|
88
|
+
slideRef: string;
|
|
89
|
+
answer: string[];
|
|
90
|
+
};
|
|
91
|
+
export declare type SlideContent = {
|
|
92
|
+
type: 'slide';
|
|
93
|
+
ref: string;
|
|
94
|
+
};
|
|
95
|
+
export declare type SuccessNodeContent = {
|
|
96
|
+
type: 'success';
|
|
97
|
+
ref: 'successExitNode';
|
|
98
|
+
};
|
|
99
|
+
export declare type ProgressionState = {
|
|
100
|
+
allAnswers: ProgressionAnswerItem[];
|
|
101
|
+
content?: SlideContent;
|
|
102
|
+
isCorrect: boolean;
|
|
103
|
+
lives?: number;
|
|
104
|
+
livesDisabled?: boolean;
|
|
105
|
+
hasViewedAResourceAtThisStep?: boolean;
|
|
106
|
+
nextContent: SlideContent | SuccessNodeContent;
|
|
107
|
+
pendingSlides: string[];
|
|
108
|
+
remainingLifeRequests?: number;
|
|
109
|
+
requestedClues?: [];
|
|
110
|
+
variables?: {};
|
|
111
|
+
viewedResources?: [];
|
|
112
|
+
slides: string[];
|
|
113
|
+
step: {
|
|
114
|
+
current: number;
|
|
115
|
+
};
|
|
116
|
+
stars: number;
|
|
117
|
+
};
|
|
118
|
+
export declare type ReviewContent = {
|
|
119
|
+
type: 'skill';
|
|
120
|
+
ref: string;
|
|
121
|
+
};
|
|
122
|
+
export declare type ReviewEngine = {
|
|
123
|
+
ref: 'review';
|
|
124
|
+
};
|
|
125
|
+
export declare type ProgressionFromAPI = {
|
|
126
|
+
_id: string;
|
|
127
|
+
content: ReviewContent;
|
|
128
|
+
engine: ReviewEngine;
|
|
129
|
+
state: ProgressionState;
|
|
130
|
+
};
|
|
131
|
+
export declare type CorrectedChoice = {
|
|
132
|
+
answer: string;
|
|
133
|
+
isCorrect: boolean;
|
|
134
|
+
};
|
|
135
|
+
export declare type CorrectionFromAPI = {
|
|
136
|
+
correctAnswer: string[];
|
|
137
|
+
corrections: CorrectedChoice[];
|
|
138
|
+
};
|
|
139
|
+
export declare type SkillToReview = {
|
|
140
|
+
skillRef: string;
|
|
141
|
+
slidesToReview: number;
|
|
142
|
+
custom: boolean;
|
|
143
|
+
name: string;
|
|
144
|
+
};
|
|
145
|
+
export declare type Skill = {
|
|
146
|
+
name: string;
|
|
147
|
+
ref: string;
|
|
148
|
+
};
|
|
149
|
+
export declare type Services = {
|
|
150
|
+
fetchSkill(skillRef: string, token: string): Promise<Skill>;
|
|
151
|
+
fetchSkills(token: string): Promise<SkillToReview[]>;
|
|
152
|
+
fetchSlide(slideRef: string, token: string): Promise<SlideFromAPI | void>;
|
|
153
|
+
postProgression(skillRef: string, token: string): Promise<ProgressionFromAPI>;
|
|
154
|
+
postAnswer(progression: ProgressionFromAPI, token: string, answer: string[]): Promise<ProgressionFromAPI>;
|
|
155
|
+
fetchCorrection(slideRef: string, token: string, progressionId: string, answer: string[]): Promise<CorrectionFromAPI | void>;
|
|
156
|
+
fetchRank(token: string): Promise<Rank>;
|
|
157
|
+
fetchSlidesToReviewBySkillRef(token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
|
|
158
|
+
};
|
|
159
|
+
export declare type Options = {
|
|
160
|
+
services: Services;
|
|
161
|
+
};
|
|
14
162
|
export declare type ConnectedOptions = {
|
|
15
163
|
translate: Translate;
|
|
16
164
|
onQuitClick: () => void;
|
|
@@ -26,6 +174,34 @@ export declare type ThunkOptions = {
|
|
|
26
174
|
callbackOnViewChanged?: AppOptions['callbackOnViewChanged'];
|
|
27
175
|
services: Services;
|
|
28
176
|
};
|
|
29
|
-
export declare type
|
|
30
|
-
|
|
177
|
+
export declare type JWT = {
|
|
178
|
+
exp: number;
|
|
179
|
+
iat: number;
|
|
180
|
+
grants: unknown;
|
|
181
|
+
iss: string;
|
|
182
|
+
user: string;
|
|
183
|
+
usage: string;
|
|
184
|
+
host: string;
|
|
185
|
+
};
|
|
186
|
+
export declare type WithRequired<T, K extends keyof T> = T & {
|
|
187
|
+
[P in K]-?: T[P];
|
|
188
|
+
};
|
|
189
|
+
export declare type Skin = {
|
|
190
|
+
common: {
|
|
191
|
+
primary: string;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
export declare type Config = {
|
|
195
|
+
version: string;
|
|
196
|
+
livesDisabled: boolean;
|
|
197
|
+
lives: number;
|
|
198
|
+
maxTypos: number;
|
|
199
|
+
slidesToComplete: number;
|
|
200
|
+
shuffleChoices?: boolean;
|
|
201
|
+
answerBoundaryLimit: number;
|
|
202
|
+
starsPerAskingClue: number;
|
|
203
|
+
starsPerCorrectAnswer: number;
|
|
204
|
+
starsPerResourceViewed: number;
|
|
205
|
+
remainingLifeRequests: number;
|
|
31
206
|
};
|
|
207
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ReviewSkillsProps } from '@coorpacademy/components/es/template/app-review/skills/prop-types';
|
|
2
|
-
import type { ConnectedOptions } from '../../types/common';
|
|
3
2
|
import { StoreState } from '../../reducers';
|
|
3
|
+
import type { ConnectedOptions } from '../../types/common';
|
|
4
4
|
export declare const mapStateToSkillsProps: (state: StoreState, options: ConnectedOptions) => ReviewSkillsProps;
|