@coorpacademy/app-review 0.6.0 → 0.6.1-alpha.0
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/lib/actions/api/fetch-correction.js +25 -0
- package/lib/actions/api/fetch-rank.js +43 -0
- package/lib/actions/api/fetch-skills.js +23 -0
- package/lib/actions/api/fetch-slide.js +38 -0
- package/lib/actions/api/post-answer.js +43 -0
- package/lib/actions/api/post-progression.js +27 -0
- package/lib/actions/data/token.js +9 -0
- package/lib/actions/ui/answers.js +61 -0
- package/lib/actions/ui/navigation.js +31 -0
- package/lib/actions/ui/next-slide.js +28 -0
- package/lib/actions/ui/quit-popin.js +11 -0
- package/lib/actions/ui/slides.js +9 -0
- package/lib/common/index.js +17 -0
- package/lib/configure-store.js +27 -0
- package/lib/helpers/css-register.js +7 -0
- package/lib/index.js +101 -0
- package/lib/reducers/data/corrections.js +26 -0
- package/lib/reducers/data/index.js +13 -0
- package/lib/reducers/data/progression.js +18 -0
- package/lib/reducers/data/rank.js +32 -0
- package/lib/reducers/data/skills.js +13 -0
- package/lib/reducers/data/slides.js +25 -0
- package/lib/reducers/data/token.js +13 -0
- package/lib/reducers/index.js +12 -0
- package/lib/reducers/ui/answers.js +27 -0
- package/lib/reducers/ui/current-slide-ref.js +18 -0
- package/lib/reducers/ui/index.js +22 -0
- package/lib/reducers/ui/navigation.js +20 -0
- package/lib/reducers/ui/positions.js +32 -0
- package/lib/reducers/ui/quit-popin.js +18 -0
- package/lib/reducers/ui/show-congrats.js +22 -0
- package/lib/reducers/ui/slide.js +53 -0
- package/lib/services/fetch-correction.js +21 -0
- package/lib/services/fetch-rank.js +17 -0
- package/lib/services/fetch-skills.js +17 -0
- package/lib/services/fetch-slide.js +17 -0
- package/lib/services/fetch-slides-to-review-by-skill-ref.js +15 -0
- package/lib/services/index.js +20 -0
- package/lib/services/post-answer.js +27 -0
- package/lib/services/post-progression.js +28 -0
- package/lib/services/tools/fetch-responses.js +40 -0
- package/lib/services/tools/sleep.js +7 -0
- package/lib/types/common.js +2 -0
- package/lib/types/slides.js +2 -0
- package/lib/{src/views → views}/skills/index.js +8 -4
- package/lib/views/slides/index.js +325 -0
- package/lib/views/slides/map-api-slide-to-ui.js +177 -0
- package/package.json +5 -13
- package/es/sandbox/index.d.ts +0 -9
- package/es/sandbox/index.js +0 -41
- package/es/src/actions/test/create-test-store.d.ts +0 -5
- package/es/src/actions/test/create-test-store.js +0 -16
- package/es/src/test/index.test.d.ts +0 -1
- package/es/src/test/index.test.js +0 -66
- package/es/src/test/util/services.mock.d.ts +0 -7
- package/es/src/test/util/services.mock.js +0 -444
- package/es/src/views/slides/test/fixtures/free-text.d.ts +0 -4
- package/es/src/views/slides/test/fixtures/free-text.js +0 -38
- package/es/src/views/slides/test/fixtures/qcm-drag.d.ts +0 -4
- package/es/src/views/slides/test/fixtures/qcm-drag.js +0 -108
- package/es/src/views/slides/test/fixtures/qcm-graphic.d.ts +0 -4
- package/es/src/views/slides/test/fixtures/qcm-graphic.js +0 -252
- package/es/src/views/slides/test/fixtures/qcm.d.ts +0 -4
- package/es/src/views/slides/test/fixtures/qcm.js +0 -109
- package/es/src/views/slides/test/fixtures/slider.d.ts +0 -4
- package/es/src/views/slides/test/fixtures/slider.js +0 -37
- package/es/src/views/slides/test/fixtures/template.d.ts +0 -4
- package/es/src/views/slides/test/fixtures/template.js +0 -170
- package/lib/sandbox/index.d.ts +0 -9
- package/lib/sandbox/index.js +0 -43
- package/lib/src/actions/api/fetch-correction.js +0 -19
- package/lib/src/actions/api/fetch-rank.js +0 -38
- package/lib/src/actions/api/fetch-skills.js +0 -17
- package/lib/src/actions/api/fetch-slide.js +0 -81
- package/lib/src/actions/api/post-answer.js +0 -92
- package/lib/src/actions/api/post-progression.js +0 -72
- package/lib/src/actions/data/token.js +0 -5
- package/lib/src/actions/test/create-test-store.d.ts +0 -5
- package/lib/src/actions/test/create-test-store.js +0 -18
- package/lib/src/actions/ui/answers.js +0 -65
- package/lib/src/actions/ui/navigation.js +0 -86
- package/lib/src/actions/ui/next-slide.js +0 -21
- package/lib/src/actions/ui/quit-popin.js +0 -8
- package/lib/src/actions/ui/slides.js +0 -5
- package/lib/src/common/index.js +0 -10
- package/lib/src/configure-store.js +0 -21
- package/lib/src/helpers/css-register.js +0 -2
- package/lib/src/index.js +0 -86
- package/lib/src/reducers/data/corrections.js +0 -22
- package/lib/src/reducers/data/index.js +0 -8
- package/lib/src/reducers/data/progression.js +0 -17
- package/lib/src/reducers/data/rank.js +0 -28
- package/lib/src/reducers/data/skills.js +0 -12
- package/lib/src/reducers/data/slides.js +0 -20
- package/lib/src/reducers/data/token.js +0 -12
- package/lib/src/reducers/index.js +0 -7
- package/lib/src/reducers/ui/answers.js +0 -25
- package/lib/src/reducers/ui/current-slide-ref.js +0 -17
- package/lib/src/reducers/ui/index.js +0 -17
- package/lib/src/reducers/ui/navigation.js +0 -28
- package/lib/src/reducers/ui/positions.js +0 -28
- package/lib/src/reducers/ui/quit-popin.js +0 -17
- package/lib/src/reducers/ui/show-congrats.js +0 -21
- package/lib/src/reducers/ui/slide.js +0 -48
- package/lib/src/services/fetch-correction.js +0 -58
- package/lib/src/services/fetch-rank.js +0 -54
- package/lib/src/services/fetch-skills.js +0 -54
- package/lib/src/services/fetch-slide.js +0 -54
- package/lib/src/services/fetch-slides-to-review-by-skill-ref.js +0 -52
- package/lib/src/services/index.js +0 -16
- package/lib/src/services/post-answer.js +0 -64
- package/lib/src/services/post-progression.js +0 -65
- package/lib/src/services/tools/fetch-responses.js +0 -112
- package/lib/src/services/tools/sleep.js +0 -5
- package/lib/src/test/index.test.d.ts +0 -1
- package/lib/src/test/index.test.js +0 -170
- package/lib/src/test/util/services.mock.d.ts +0 -7
- package/lib/src/test/util/services.mock.js +0 -448
- package/lib/src/types/common.js +0 -1
- package/lib/src/types/slides.js +0 -1
- package/lib/src/views/slides/index.js +0 -315
- package/lib/src/views/slides/map-api-slide-to-ui.js +0 -188
- package/lib/src/views/slides/test/fixtures/free-text.d.ts +0 -4
- package/lib/src/views/slides/test/fixtures/free-text.js +0 -38
- package/lib/src/views/slides/test/fixtures/qcm-drag.d.ts +0 -4
- package/lib/src/views/slides/test/fixtures/qcm-drag.js +0 -108
- package/lib/src/views/slides/test/fixtures/qcm-graphic.d.ts +0 -4
- package/lib/src/views/slides/test/fixtures/qcm-graphic.js +0 -252
- package/lib/src/views/slides/test/fixtures/qcm.d.ts +0 -4
- package/lib/src/views/slides/test/fixtures/qcm.js +0 -109
- package/lib/src/views/slides/test/fixtures/slider.d.ts +0 -4
- package/lib/src/views/slides/test/fixtures/slider.js +0 -37
- package/lib/src/views/slides/test/fixtures/template.d.ts +0 -4
- package/lib/src/views/slides/test/fixtures/template.js +0 -170
- package/src/actions/api/fetch-correction.ts +0 -39
- package/src/actions/api/fetch-rank.ts +0 -91
- package/src/actions/api/fetch-skills.ts +0 -31
- package/src/actions/api/fetch-slide.ts +0 -54
- package/src/actions/api/post-answer.ts +0 -55
- package/src/actions/api/post-progression.ts +0 -37
- package/src/actions/api/test/fetch-correction.test.ts +0 -119
- package/src/actions/api/test/fetch-rank.test.ts +0 -138
- package/src/actions/api/test/fetch-skills.test.ts +0 -78
- package/src/actions/api/test/fetch-slide.test.ts +0 -85
- package/src/actions/api/test/post-answer.test.ts +0 -266
- package/src/actions/api/test/post-progression.test.ts +0 -127
- package/src/actions/data/test/token.test.ts +0 -32
- package/src/actions/data/token.ts +0 -11
- package/src/actions/test/create-test-store.ts +0 -25
- package/src/actions/ui/answers.ts +0 -77
- package/src/actions/ui/navigation.ts +0 -62
- package/src/actions/ui/next-slide.ts +0 -44
- package/src/actions/ui/quit-popin.ts +0 -10
- package/src/actions/ui/slides.ts +0 -26
- package/src/actions/ui/test/answers.test.ts +0 -174
- package/src/actions/ui/test/navigation.test.ts +0 -95
- package/src/actions/ui/test/next-slide.test.ts +0 -87
- package/src/actions/ui/test/quit-popin.test.ts +0 -39
- package/src/actions/ui/test/slides.test.ts +0 -33
- package/src/common/index.ts +0 -15
- package/src/common/test/get-progression-slide-ref.test.ts +0 -35
- package/src/configure-store.ts +0 -28
- package/src/helpers/css-modules-require-hook.d.ts +0 -4
- package/src/helpers/css-register.ts +0 -3
- package/src/index.tsx +0 -107
- package/src/reducers/data/corrections.ts +0 -36
- package/src/reducers/data/index.ts +0 -19
- package/src/reducers/data/progression.ts +0 -23
- package/src/reducers/data/rank.ts +0 -44
- package/src/reducers/data/skills.ts +0 -16
- package/src/reducers/data/slides.ts +0 -31
- package/src/reducers/data/test/corrections.test.ts +0 -36
- package/src/reducers/data/test/progression.test.ts +0 -28
- package/src/reducers/data/test/rank.test.ts +0 -59
- package/src/reducers/data/test/skills.test.ts +0 -14
- package/src/reducers/data/test/slides.test.ts +0 -27
- package/src/reducers/data/test/token.test.ts +0 -13
- package/src/reducers/data/token.ts +0 -15
- package/src/reducers/index.ts +0 -14
- package/src/reducers/ui/answers.ts +0 -41
- package/src/reducers/ui/current-slide-ref.ts +0 -22
- package/src/reducers/ui/index.ts +0 -29
- package/src/reducers/ui/navigation.ts +0 -29
- package/src/reducers/ui/positions.ts +0 -34
- package/src/reducers/ui/quit-popin.ts +0 -22
- package/src/reducers/ui/show-congrats.ts +0 -26
- package/src/reducers/ui/slide.ts +0 -87
- package/src/reducers/ui/test/answers.test.ts +0 -105
- package/src/reducers/ui/test/current-slide-ref.test.ts +0 -14
- package/src/reducers/ui/test/navigation.test.ts +0 -19
- package/src/reducers/ui/test/positions.test.ts +0 -82
- package/src/reducers/ui/test/quit-popin.test.ts +0 -24
- package/src/reducers/ui/test/show-congrats.test.ts +0 -40
- package/src/reducers/ui/test/slide.test.ts +0 -110
- package/src/services/fetch-correction.ts +0 -26
- package/src/services/fetch-rank.ts +0 -14
- package/src/services/fetch-skills.ts +0 -14
- package/src/services/fetch-slide.ts +0 -14
- package/src/services/fetch-slides-to-review-by-skill-ref.ts +0 -18
- package/src/services/index.ts +0 -18
- package/src/services/post-answer.ts +0 -28
- package/src/services/post-progression.ts +0 -28
- package/src/services/test/fetch-correction.test.ts +0 -55
- package/src/services/test/fetch-rank.test.ts +0 -34
- package/src/services/test/fetch-skills.test.ts +0 -39
- package/src/services/test/fetch-slide.test.ts +0 -30
- package/src/services/test/fetch-slides-to-review-by-skill-ref.test.ts +0 -51
- package/src/services/test/post-answer.test.ts +0 -100
- package/src/services/test/post-progression.test.ts +0 -66
- package/src/services/tools/fetch-responses.ts +0 -40
- package/src/services/tools/sleep.ts +0 -4
- package/src/test/index.test.tsx +0 -99
- package/src/test/util/services.mock.ts +0 -465
- package/src/types/common.ts +0 -207
- package/src/types/globals.d.ts +0 -4
- package/src/types/slides.ts +0 -98
- package/src/views/skills/index.ts +0 -48
- package/src/views/skills/test/skills.test.ts +0 -104
- package/src/views/slides/index.ts +0 -398
- package/src/views/slides/map-api-slide-to-ui.ts +0 -287
- package/src/views/slides/test/fixtures/free-text.ts +0 -44
- package/src/views/slides/test/fixtures/qcm-drag.ts +0 -112
- package/src/views/slides/test/fixtures/qcm-graphic.ts +0 -264
- package/src/views/slides/test/fixtures/qcm.ts +0 -120
- package/src/views/slides/test/fixtures/slider.ts +0 -43
- package/src/views/slides/test/fixtures/template.ts +0 -177
- package/src/views/slides/test/header.on-click.test.ts +0 -46
- package/src/views/slides/test/index.test.ts +0 -1515
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +0 -52
- package/src/views/slides/test/on-quit-popin.on-click.test.ts +0 -66
- package/src/views/slides/test/slide.free-text.on-change.test.ts +0 -116
- package/src/views/slides/test/slide.next-slide.on-click.test.ts +0 -178
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +0 -90
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +0 -90
- package/src/views/slides/test/slide.qcm.on-click.test.ts +0 -92
- package/src/views/slides/test/slide.slider.on-change.test.ts +0 -92
- package/src/views/slides/test/slide.slider.on-slider-change.test.ts +0 -91
- package/src/views/slides/test/slide.template.on-change.test.ts +0 -126
- /package/es/{src/actions → actions}/api/fetch-correction.d.ts +0 -0
- /package/es/{src/actions → actions}/api/fetch-correction.js +0 -0
- /package/es/{src/actions → actions}/api/fetch-rank.d.ts +0 -0
- /package/es/{src/actions → actions}/api/fetch-rank.js +0 -0
- /package/es/{src/actions → actions}/api/fetch-skills.d.ts +0 -0
- /package/es/{src/actions → actions}/api/fetch-skills.js +0 -0
- /package/es/{src/actions → actions}/api/fetch-slide.d.ts +0 -0
- /package/es/{src/actions → actions}/api/fetch-slide.js +0 -0
- /package/es/{src/actions → actions}/api/post-answer.d.ts +0 -0
- /package/es/{src/actions → actions}/api/post-answer.js +0 -0
- /package/es/{src/actions → actions}/api/post-progression.d.ts +0 -0
- /package/es/{src/actions → actions}/api/post-progression.js +0 -0
- /package/es/{src/actions → actions}/data/token.d.ts +0 -0
- /package/es/{src/actions → actions}/data/token.js +0 -0
- /package/es/{src/actions → actions}/ui/answers.d.ts +0 -0
- /package/es/{src/actions → actions}/ui/answers.js +0 -0
- /package/es/{src/actions → actions}/ui/navigation.d.ts +0 -0
- /package/es/{src/actions → actions}/ui/navigation.js +0 -0
- /package/es/{src/actions → actions}/ui/next-slide.d.ts +0 -0
- /package/es/{src/actions → actions}/ui/next-slide.js +0 -0
- /package/es/{src/actions → actions}/ui/quit-popin.d.ts +0 -0
- /package/es/{src/actions → actions}/ui/quit-popin.js +0 -0
- /package/es/{src/actions → actions}/ui/slides.d.ts +0 -0
- /package/es/{src/actions → actions}/ui/slides.js +0 -0
- /package/es/{src/common → common}/index.d.ts +0 -0
- /package/es/{src/common → common}/index.js +0 -0
- /package/es/{src/configure-store.d.ts → configure-store.d.ts} +0 -0
- /package/es/{src/configure-store.js → configure-store.js} +0 -0
- /package/es/{src/helpers → helpers}/css-register.d.ts +0 -0
- /package/es/{src/helpers → helpers}/css-register.js +0 -0
- /package/es/{src/index.d.ts → index.d.ts} +0 -0
- /package/es/{src/index.js → index.js} +0 -0
- /package/es/{src/reducers → reducers}/data/corrections.d.ts +0 -0
- /package/es/{src/reducers → reducers}/data/corrections.js +0 -0
- /package/es/{src/reducers → reducers}/data/index.d.ts +0 -0
- /package/es/{src/reducers → reducers}/data/index.js +0 -0
- /package/es/{src/reducers → reducers}/data/progression.d.ts +0 -0
- /package/es/{src/reducers → reducers}/data/progression.js +0 -0
- /package/es/{src/reducers → reducers}/data/rank.d.ts +0 -0
- /package/es/{src/reducers → reducers}/data/rank.js +0 -0
- /package/es/{src/reducers → reducers}/data/skills.d.ts +0 -0
- /package/es/{src/reducers → reducers}/data/skills.js +0 -0
- /package/es/{src/reducers → reducers}/data/slides.d.ts +0 -0
- /package/es/{src/reducers → reducers}/data/slides.js +0 -0
- /package/es/{src/reducers → reducers}/data/token.d.ts +0 -0
- /package/es/{src/reducers → reducers}/data/token.js +0 -0
- /package/es/{src/reducers → reducers}/index.d.ts +0 -0
- /package/es/{src/reducers → reducers}/index.js +0 -0
- /package/es/{src/reducers → reducers}/ui/answers.d.ts +0 -0
- /package/es/{src/reducers → reducers}/ui/answers.js +0 -0
- /package/es/{src/reducers → reducers}/ui/current-slide-ref.d.ts +0 -0
- /package/es/{src/reducers → reducers}/ui/current-slide-ref.js +0 -0
- /package/es/{src/reducers → reducers}/ui/index.d.ts +0 -0
- /package/es/{src/reducers → reducers}/ui/index.js +0 -0
- /package/es/{src/reducers → reducers}/ui/navigation.d.ts +0 -0
- /package/es/{src/reducers → reducers}/ui/navigation.js +0 -0
- /package/es/{src/reducers → reducers}/ui/positions.d.ts +0 -0
- /package/es/{src/reducers → reducers}/ui/positions.js +0 -0
- /package/es/{src/reducers → reducers}/ui/quit-popin.d.ts +0 -0
- /package/es/{src/reducers → reducers}/ui/quit-popin.js +0 -0
- /package/es/{src/reducers → reducers}/ui/show-congrats.d.ts +0 -0
- /package/es/{src/reducers → reducers}/ui/show-congrats.js +0 -0
- /package/es/{src/reducers → reducers}/ui/slide.d.ts +0 -0
- /package/es/{src/reducers → reducers}/ui/slide.js +0 -0
- /package/es/{src/services → services}/fetch-correction.d.ts +0 -0
- /package/es/{src/services → services}/fetch-correction.js +0 -0
- /package/es/{src/services → services}/fetch-rank.d.ts +0 -0
- /package/es/{src/services → services}/fetch-rank.js +0 -0
- /package/es/{src/services → services}/fetch-skills.d.ts +0 -0
- /package/es/{src/services → services}/fetch-skills.js +0 -0
- /package/es/{src/services → services}/fetch-slide.d.ts +0 -0
- /package/es/{src/services → services}/fetch-slide.js +0 -0
- /package/es/{src/services → services}/fetch-slides-to-review-by-skill-ref.d.ts +0 -0
- /package/es/{src/services → services}/fetch-slides-to-review-by-skill-ref.js +0 -0
- /package/es/{src/services → services}/index.d.ts +0 -0
- /package/es/{src/services → services}/index.js +0 -0
- /package/es/{src/services → services}/post-answer.d.ts +0 -0
- /package/es/{src/services → services}/post-answer.js +0 -0
- /package/es/{src/services → services}/post-progression.d.ts +0 -0
- /package/es/{src/services → services}/post-progression.js +0 -0
- /package/es/{src/services → services}/tools/fetch-responses.d.ts +0 -0
- /package/es/{src/services → services}/tools/fetch-responses.js +0 -0
- /package/es/{src/services → services}/tools/sleep.d.ts +0 -0
- /package/es/{src/services → services}/tools/sleep.js +0 -0
- /package/es/{src/types → types}/common.d.ts +0 -0
- /package/es/{src/types → types}/common.js +0 -0
- /package/es/{src/types → types}/slides.d.ts +0 -0
- /package/es/{src/types → types}/slides.js +0 -0
- /package/es/{src/views → views}/skills/index.d.ts +0 -0
- /package/es/{src/views → views}/skills/index.js +0 -0
- /package/es/{src/views → views}/slides/index.d.ts +0 -0
- /package/es/{src/views → views}/slides/index.js +0 -0
- /package/es/{src/views → views}/slides/map-api-slide-to-ui.d.ts +0 -0
- /package/es/{src/views → views}/slides/map-api-slide-to-ui.js +0 -0
- /package/lib/{src/actions → actions}/api/fetch-correction.d.ts +0 -0
- /package/lib/{src/actions → actions}/api/fetch-rank.d.ts +0 -0
- /package/lib/{src/actions → actions}/api/fetch-skills.d.ts +0 -0
- /package/lib/{src/actions → actions}/api/fetch-slide.d.ts +0 -0
- /package/lib/{src/actions → actions}/api/post-answer.d.ts +0 -0
- /package/lib/{src/actions → actions}/api/post-progression.d.ts +0 -0
- /package/lib/{src/actions → actions}/data/token.d.ts +0 -0
- /package/lib/{src/actions → actions}/ui/answers.d.ts +0 -0
- /package/lib/{src/actions → actions}/ui/navigation.d.ts +0 -0
- /package/lib/{src/actions → actions}/ui/next-slide.d.ts +0 -0
- /package/lib/{src/actions → actions}/ui/quit-popin.d.ts +0 -0
- /package/lib/{src/actions → actions}/ui/slides.d.ts +0 -0
- /package/lib/{src/common → common}/index.d.ts +0 -0
- /package/lib/{src/configure-store.d.ts → configure-store.d.ts} +0 -0
- /package/lib/{src/helpers → helpers}/css-register.d.ts +0 -0
- /package/lib/{src/index.d.ts → index.d.ts} +0 -0
- /package/lib/{src/reducers → reducers}/data/corrections.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/data/index.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/data/progression.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/data/rank.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/data/skills.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/data/slides.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/data/token.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/index.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/ui/answers.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/ui/current-slide-ref.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/ui/index.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/ui/navigation.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/ui/positions.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/ui/quit-popin.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/ui/show-congrats.d.ts +0 -0
- /package/lib/{src/reducers → reducers}/ui/slide.d.ts +0 -0
- /package/lib/{src/services → services}/fetch-correction.d.ts +0 -0
- /package/lib/{src/services → services}/fetch-rank.d.ts +0 -0
- /package/lib/{src/services → services}/fetch-skills.d.ts +0 -0
- /package/lib/{src/services → services}/fetch-slide.d.ts +0 -0
- /package/lib/{src/services → services}/fetch-slides-to-review-by-skill-ref.d.ts +0 -0
- /package/lib/{src/services → services}/index.d.ts +0 -0
- /package/lib/{src/services → services}/post-answer.d.ts +0 -0
- /package/lib/{src/services → services}/post-progression.d.ts +0 -0
- /package/lib/{src/services → services}/tools/fetch-responses.d.ts +0 -0
- /package/lib/{src/services → services}/tools/sleep.d.ts +0 -0
- /package/lib/{src/types → types}/common.d.ts +0 -0
- /package/lib/{src/types → types}/slides.d.ts +0 -0
- /package/lib/{src/views → views}/skills/index.d.ts +0 -0
- /package/lib/{src/views → views}/slides/index.d.ts +0 -0
- /package/lib/{src/views → views}/slides/map-api-slide-to-ui.d.ts +0 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mapStateToSlidesProps = exports.buildStepItems = exports.initialState = void 0;
|
|
7
|
+
const findLast_1 = __importDefault(require("lodash/fp/findLast"));
|
|
8
|
+
const get_1 = __importDefault(require("lodash/fp/get"));
|
|
9
|
+
const getOr_1 = __importDefault(require("lodash/fp/getOr"));
|
|
10
|
+
const last_1 = __importDefault(require("lodash/fp/last"));
|
|
11
|
+
const reduce_1 = __importDefault(require("lodash/fp/reduce"));
|
|
12
|
+
const set_1 = __importDefault(require("lodash/fp/set"));
|
|
13
|
+
const toInteger_1 = __importDefault(require("lodash/fp/toInteger"));
|
|
14
|
+
const join_1 = __importDefault(require("lodash/fp/join"));
|
|
15
|
+
const quit_popin_1 = require("../../actions/ui/quit-popin");
|
|
16
|
+
const common_1 = require("../../common");
|
|
17
|
+
const post_answer_1 = require("../../actions/api/post-answer");
|
|
18
|
+
const next_slide_1 = require("../../actions/ui/next-slide");
|
|
19
|
+
const map_api_slide_to_ui_1 = require("./map-api-slide-to-ui");
|
|
20
|
+
const ICON_VALUES = {
|
|
21
|
+
right: 'right',
|
|
22
|
+
wrong: 'wrong',
|
|
23
|
+
'no-answer': 'no-answer'
|
|
24
|
+
};
|
|
25
|
+
const confettiAnimation = {
|
|
26
|
+
'aria-label': 'aria lottie',
|
|
27
|
+
'data-name': 'default-lottie',
|
|
28
|
+
className: undefined,
|
|
29
|
+
animationSrc: 'https://static-staging.coorpacademy.com/animations/review/confetti.json',
|
|
30
|
+
loop: undefined,
|
|
31
|
+
autoplay: true,
|
|
32
|
+
rendererSettings: {
|
|
33
|
+
hideOnTransparent: false
|
|
34
|
+
},
|
|
35
|
+
ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg'
|
|
36
|
+
};
|
|
37
|
+
exports.initialState = {
|
|
38
|
+
'0': {
|
|
39
|
+
position: 0,
|
|
40
|
+
loading: true
|
|
41
|
+
},
|
|
42
|
+
'1': {
|
|
43
|
+
position: 1,
|
|
44
|
+
loading: true
|
|
45
|
+
},
|
|
46
|
+
'2': {
|
|
47
|
+
position: 2,
|
|
48
|
+
loading: true
|
|
49
|
+
},
|
|
50
|
+
'3': {
|
|
51
|
+
position: 3,
|
|
52
|
+
loading: true
|
|
53
|
+
},
|
|
54
|
+
'4': {
|
|
55
|
+
position: 4,
|
|
56
|
+
loading: true
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const getCurrentSlideRef = (state) => {
|
|
60
|
+
const currentSlideRef = (0, get_1.default)(['ui', 'currentSlideRef'], state);
|
|
61
|
+
const endReview = currentSlideRef === 'successExitNode';
|
|
62
|
+
if (!endReview)
|
|
63
|
+
return currentSlideRef;
|
|
64
|
+
const progression = state.data.progression;
|
|
65
|
+
const content = progression.state.content;
|
|
66
|
+
return content.ref;
|
|
67
|
+
};
|
|
68
|
+
const buildStackSlides = (state, dispatch) => {
|
|
69
|
+
const currentSlideRef = getCurrentSlideRef(state);
|
|
70
|
+
const progression = state.data.progression;
|
|
71
|
+
if (!currentSlideRef || !progression)
|
|
72
|
+
return exports.initialState;
|
|
73
|
+
const slideRefs = (0, common_1.getProgressionSlidesRefs)(progression);
|
|
74
|
+
// @ts-expect-error typescript does not support capped versions of lodash functions
|
|
75
|
+
const stack = reduce_1.default.convert({ cap: false })((acc, uiSlide, _index) => {
|
|
76
|
+
const index = (0, toInteger_1.default)(_index);
|
|
77
|
+
const positions = state.ui.positions;
|
|
78
|
+
const position = positions[index];
|
|
79
|
+
const slideRef = slideRefs[index];
|
|
80
|
+
if (!slideRef)
|
|
81
|
+
return (0, set_1.default)(index, { ...uiSlide, position }, acc);
|
|
82
|
+
const slideFromAPI = (0, get_1.default)(slideRef, state.data.slides);
|
|
83
|
+
if (!slideFromAPI)
|
|
84
|
+
return (0, set_1.default)(index, { ...uiSlide, position }, acc);
|
|
85
|
+
const answers = (0, getOr_1.default)([], ['ui', 'answers', slideRef], state);
|
|
86
|
+
const { questionText, answerUI } = (0, map_api_slide_to_ui_1.mapApiSlideToUi)(dispatch)(slideFromAPI, answers);
|
|
87
|
+
const { title: parentContentTitle, type: parentContentType } = slideFromAPI.parentContentTitle;
|
|
88
|
+
const isCurrentSlideRef = currentSlideRef === slideRef;
|
|
89
|
+
const slideUI = (0, get_1.default)(['ui', 'slide', slideRef], state);
|
|
90
|
+
const animateCorrectionPopin = isCurrentSlideRef && slideUI.animateCorrectionPopin;
|
|
91
|
+
const showCorrectionPopin = isCurrentSlideRef && slideUI.showCorrectionPopin;
|
|
92
|
+
const animationType = slideUI.animationType;
|
|
93
|
+
const updatedUiSlide = {
|
|
94
|
+
...uiSlide,
|
|
95
|
+
position,
|
|
96
|
+
showCorrectionPopin,
|
|
97
|
+
animateCorrectionPopin,
|
|
98
|
+
loading: false,
|
|
99
|
+
questionText,
|
|
100
|
+
answerUI,
|
|
101
|
+
parentContentTitle: `From "${parentContentTitle}" ${parentContentType}`,
|
|
102
|
+
animationType
|
|
103
|
+
};
|
|
104
|
+
return (0, set_1.default)(index, updatedUiSlide, acc);
|
|
105
|
+
}, exports.initialState, exports.initialState);
|
|
106
|
+
return stack;
|
|
107
|
+
};
|
|
108
|
+
const getIconForCurrentStep = (slideRef, lastGivenAnswerForSlide, currentSlideRef, lastGivenAnswer) => {
|
|
109
|
+
if (slideRef !== currentSlideRef)
|
|
110
|
+
return lastGivenAnswerForSlide.isCorrect ? 'right' : 'wrong';
|
|
111
|
+
if (lastGivenAnswer.slideRef !== slideRef)
|
|
112
|
+
return 'no-answer';
|
|
113
|
+
return lastGivenAnswerForSlide.isCorrect ? 'right' : 'wrong';
|
|
114
|
+
};
|
|
115
|
+
const buildStepItems = (state) => {
|
|
116
|
+
const { progression } = state.data;
|
|
117
|
+
const { currentSlideRef } = state.ui;
|
|
118
|
+
if (!progression)
|
|
119
|
+
return [];
|
|
120
|
+
const defaultProps = [
|
|
121
|
+
{
|
|
122
|
+
icon: 'no-answer',
|
|
123
|
+
current: true,
|
|
124
|
+
value: '1'
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
icon: 'no-answer',
|
|
128
|
+
current: false,
|
|
129
|
+
value: '2'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
icon: 'no-answer',
|
|
133
|
+
current: false,
|
|
134
|
+
value: '3'
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
icon: 'no-answer',
|
|
138
|
+
current: false,
|
|
139
|
+
value: '4'
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
icon: 'no-answer',
|
|
143
|
+
current: false,
|
|
144
|
+
value: '5'
|
|
145
|
+
}
|
|
146
|
+
];
|
|
147
|
+
const slideRefs = (0, common_1.getProgressionSlidesRefs)(progression);
|
|
148
|
+
const allAnswers = progression.state.allAnswers;
|
|
149
|
+
const step = progression.state.step;
|
|
150
|
+
const nextContentRef = progression.state.nextContent.ref;
|
|
151
|
+
const lastGivenAnswer = (0, last_1.default)(allAnswers);
|
|
152
|
+
if (!lastGivenAnswer)
|
|
153
|
+
return defaultProps;
|
|
154
|
+
const steps = defaultProps.map((stepItem, index) => {
|
|
155
|
+
const slideRef = slideRefs[index];
|
|
156
|
+
if (!slideRef)
|
|
157
|
+
return stepItem; // non fecthed slide pour given index
|
|
158
|
+
const lastGivenAnswerForSlide = (0, findLast_1.default)(answer => answer.slideRef === slideRef, allAnswers);
|
|
159
|
+
// never answered slide
|
|
160
|
+
if (!lastGivenAnswerForSlide) {
|
|
161
|
+
return {
|
|
162
|
+
...stepItem,
|
|
163
|
+
current: nextContentRef === currentSlideRef && step.current === index + 1
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
// already answered slide, we computed based on the lastGivenAnswer
|
|
167
|
+
return {
|
|
168
|
+
...stepItem,
|
|
169
|
+
icon: getIconForCurrentStep(slideRef, lastGivenAnswerForSlide, currentSlideRef, lastGivenAnswer),
|
|
170
|
+
current: lastGivenAnswerForSlide.slideRef === currentSlideRef
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
return steps;
|
|
174
|
+
};
|
|
175
|
+
exports.buildStepItems = buildStepItems;
|
|
176
|
+
const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf) => {
|
|
177
|
+
return {
|
|
178
|
+
klf: isCorrect
|
|
179
|
+
? undefined
|
|
180
|
+
: {
|
|
181
|
+
label: '_klf',
|
|
182
|
+
tooltip: klf
|
|
183
|
+
},
|
|
184
|
+
resultLabel: isCorrect ? '_right' : '_wrong',
|
|
185
|
+
information: {
|
|
186
|
+
label: isCorrect ? '_klf' : '_correctAnswer',
|
|
187
|
+
message: isCorrect ? klf : (0, join_1.default)(',', correctAnswer)
|
|
188
|
+
},
|
|
189
|
+
next: {
|
|
190
|
+
'aria-label': '_correctionNextAriaLabel',
|
|
191
|
+
label: '_correctionNextLabel',
|
|
192
|
+
onClick: () => {
|
|
193
|
+
dispatch(next_slide_1.nextSlide);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
type: isCorrect ? 'right' : 'wrong'
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
const buildQuitPopinProps = (dispatch) => (onQuitClick) => {
|
|
200
|
+
return {
|
|
201
|
+
content: `Tu t'en vas déjà ?`,
|
|
202
|
+
icon: `MoonRocket`,
|
|
203
|
+
mode: 'alert',
|
|
204
|
+
descriptionText: `Tu vas t'en sortir ! Si tu arrêtes maintenant, tu vas perdre ta progression.`,
|
|
205
|
+
firstButton: {
|
|
206
|
+
label: 'Arrêter ma session',
|
|
207
|
+
type: 'tertiary',
|
|
208
|
+
customStyle: {
|
|
209
|
+
color: '#ED3436'
|
|
210
|
+
},
|
|
211
|
+
handleOnclick: onQuitClick,
|
|
212
|
+
'aria-label': 'Stop session'
|
|
213
|
+
},
|
|
214
|
+
secondButton: {
|
|
215
|
+
label: `Continuer d'apprendre`,
|
|
216
|
+
type: 'primary',
|
|
217
|
+
handleOnclick: () => {
|
|
218
|
+
dispatch(quit_popin_1.closeQuitPopin);
|
|
219
|
+
},
|
|
220
|
+
'aria-label': 'Continue review'
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
const buildRankCard = (rank) => {
|
|
225
|
+
return {
|
|
226
|
+
'aria-label': 'Review Card Congrats Container',
|
|
227
|
+
'data-name': 'card-rank',
|
|
228
|
+
animationLottie: {
|
|
229
|
+
'aria-label': 'aria lottie',
|
|
230
|
+
'data-name': 'default-lottie',
|
|
231
|
+
animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
|
|
232
|
+
loop: true,
|
|
233
|
+
autoplay: true,
|
|
234
|
+
ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg'
|
|
235
|
+
},
|
|
236
|
+
cardType: 'card-rank',
|
|
237
|
+
iconAriaLabel: 'Image without information',
|
|
238
|
+
className: undefined,
|
|
239
|
+
reviewCardTitle: 'You are now',
|
|
240
|
+
reviewCardValue: `${rank}`,
|
|
241
|
+
rankSuffix: 'th',
|
|
242
|
+
timerAnimation: 200
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
const buildCongratsProps = (state) => {
|
|
246
|
+
if (!state.ui.showCongrats)
|
|
247
|
+
return;
|
|
248
|
+
const progression = state.data.progression;
|
|
249
|
+
const stars = progression.state.stars;
|
|
250
|
+
const cardCongratsStar = {
|
|
251
|
+
'aria-label': 'Review Card Congrats Container',
|
|
252
|
+
'data-name': 'card-star',
|
|
253
|
+
animationLottie: {
|
|
254
|
+
'aria-label': 'aria lottie',
|
|
255
|
+
'data-name': 'default-lottie',
|
|
256
|
+
className: undefined,
|
|
257
|
+
animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',
|
|
258
|
+
loop: false,
|
|
259
|
+
autoplay: undefined,
|
|
260
|
+
rendererSettings: {
|
|
261
|
+
hideOnTransparent: false
|
|
262
|
+
},
|
|
263
|
+
ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg'
|
|
264
|
+
},
|
|
265
|
+
iconAriaLabel: 'Image without information',
|
|
266
|
+
className: undefined,
|
|
267
|
+
cardType: 'card-star',
|
|
268
|
+
reviewCardTitle: 'You have won',
|
|
269
|
+
reviewCardValue: `${stars}`,
|
|
270
|
+
timerAnimation: 200
|
|
271
|
+
};
|
|
272
|
+
const { start, end } = state.data.rank;
|
|
273
|
+
const newRank = start - end;
|
|
274
|
+
const cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end) : undefined;
|
|
275
|
+
return {
|
|
276
|
+
'aria-label': 'Review Congratulations',
|
|
277
|
+
'data-name': 'review-congrats',
|
|
278
|
+
animationLottie: confettiAnimation,
|
|
279
|
+
title: 'Congratulations!',
|
|
280
|
+
cardCongratsStar,
|
|
281
|
+
cardCongratsRank,
|
|
282
|
+
buttonRevising: undefined,
|
|
283
|
+
buttonRevisingSkill: undefined // TODO make boutons and actions
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
const isEndOfProgression = (progression) => {
|
|
287
|
+
if (!progression)
|
|
288
|
+
return false;
|
|
289
|
+
return progression.state.nextContent.ref === 'successExitNode';
|
|
290
|
+
};
|
|
291
|
+
const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
|
|
292
|
+
const currentSlideRef = getCurrentSlideRef(state);
|
|
293
|
+
const endReview = isEndOfProgression(state.data.progression);
|
|
294
|
+
const correction = (0, get_1.default)(['data', 'corrections', currentSlideRef], state);
|
|
295
|
+
const isCorrect = (0, get_1.default)(['data', 'progression', 'state', 'isCorrect'], state);
|
|
296
|
+
const klf = (0, getOr_1.default)('', ['data', 'slides', currentSlideRef, 'klf'], state);
|
|
297
|
+
const showQuitPopin = (0, get_1.default)(['ui', 'showQuitPopin'], state);
|
|
298
|
+
const showCongrats = (0, get_1.default)(['ui', 'showCongrats'], state);
|
|
299
|
+
return {
|
|
300
|
+
header: {
|
|
301
|
+
mode: '__revision_mode',
|
|
302
|
+
skillName: '__agility',
|
|
303
|
+
onQuitClick: () => dispatch(quit_popin_1.openQuitPopin),
|
|
304
|
+
'aria-label': 'aria-header-wrapper',
|
|
305
|
+
closeButtonAriaLabel: 'aria-close-button',
|
|
306
|
+
steps: (0, exports.buildStepItems)(state),
|
|
307
|
+
hiddenSteps: showCongrats
|
|
308
|
+
},
|
|
309
|
+
stack: {
|
|
310
|
+
slides: buildStackSlides(state, dispatch),
|
|
311
|
+
validateButton: {
|
|
312
|
+
label: '__validate',
|
|
313
|
+
disabled: !(0, get_1.default)(['ui', 'slide', currentSlideRef, 'validateButton'], state),
|
|
314
|
+
onClick: () => {
|
|
315
|
+
dispatch(post_answer_1.postAnswer);
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
correctionPopinProps: correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
|
|
319
|
+
endReview: endReview && state.ui.showCongrats
|
|
320
|
+
},
|
|
321
|
+
congrats: buildCongratsProps(state),
|
|
322
|
+
quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
exports.mapStateToSlidesProps = mapStateToSlidesProps;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapApiSlideToUi = exports.getQuestionType = void 0;
|
|
4
|
+
const fp_1 = require("lodash/fp");
|
|
5
|
+
const answers_1 = require("../../actions/ui/answers");
|
|
6
|
+
const qcmProps = (dispatch) => (answers, question) => {
|
|
7
|
+
return {
|
|
8
|
+
type: 'qcm',
|
|
9
|
+
answers: (0, fp_1.map)(choice => {
|
|
10
|
+
const label = (0, fp_1.getOr)('', 'label', choice);
|
|
11
|
+
return {
|
|
12
|
+
title: label,
|
|
13
|
+
selected: (0, fp_1.includes)(label, answers),
|
|
14
|
+
onClick: () => {
|
|
15
|
+
dispatch((0, answers_1.editAnswer)([label]));
|
|
16
|
+
},
|
|
17
|
+
'aria-label': label
|
|
18
|
+
};
|
|
19
|
+
}, question.content.choices)
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const qcmDragProps = (dispatch) => (answers, question) => {
|
|
23
|
+
return {
|
|
24
|
+
type: 'qcmDrag',
|
|
25
|
+
answers: (0, fp_1.map)(choice => {
|
|
26
|
+
const label = (0, fp_1.getOr)('', 'label', choice);
|
|
27
|
+
const indexInAnswer = (0, fp_1.indexOf)(label, answers);
|
|
28
|
+
return {
|
|
29
|
+
title: label,
|
|
30
|
+
selected: (0, fp_1.includes)(label, answers),
|
|
31
|
+
order: indexInAnswer,
|
|
32
|
+
onClick: () => {
|
|
33
|
+
dispatch((0, answers_1.editAnswer)([label]));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, question.content.choices)
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const qcmGraphicProps = (dispatch) => (answers, question) => {
|
|
40
|
+
return {
|
|
41
|
+
type: 'qcmGraphic',
|
|
42
|
+
answers: (0, fp_1.map)(choice => {
|
|
43
|
+
const label = (0, fp_1.getOr)('', 'label', choice);
|
|
44
|
+
return {
|
|
45
|
+
title: label,
|
|
46
|
+
image: (0, fp_1.get)('media.src.0.url', choice),
|
|
47
|
+
selected: (0, fp_1.includes)(label, answers),
|
|
48
|
+
onClick: () => {
|
|
49
|
+
dispatch((0, answers_1.editAnswer)([label]));
|
|
50
|
+
},
|
|
51
|
+
ariaLabel: label
|
|
52
|
+
};
|
|
53
|
+
}, question.content.choices)
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const updateTemplateAnswer = (text, _answers, index, max) => {
|
|
57
|
+
const answers = (0, fp_1.isEmpty)(_answers) ? (0, fp_1.times)((0, fp_1.constant)(undefined), max) : _answers;
|
|
58
|
+
return (0, fp_1.map)(a => ((0, fp_1.isNil)(a) ? '' : a), (0, fp_1.set)(index, text, answers));
|
|
59
|
+
};
|
|
60
|
+
const templateTextProps = (dispatch, answers, choice, index, maxLength) => {
|
|
61
|
+
return {
|
|
62
|
+
type: 'text',
|
|
63
|
+
name: (0, fp_1.getOr)('', 'name', choice),
|
|
64
|
+
placeholder: 'Type here',
|
|
65
|
+
value: (0, fp_1.get)(index, answers),
|
|
66
|
+
onChange: (text) => {
|
|
67
|
+
const newAnswers = updateTemplateAnswer(text, answers, index, maxLength);
|
|
68
|
+
dispatch((0, answers_1.editAnswer)(newAnswers));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const templateSelectProps = (dispatch, answers, choice, index, maxLength) => {
|
|
73
|
+
const answer = (0, fp_1.get)(index, answers);
|
|
74
|
+
const temporaryOption = {
|
|
75
|
+
name: 'Select an answer',
|
|
76
|
+
value: '',
|
|
77
|
+
validOption: false,
|
|
78
|
+
selected: true
|
|
79
|
+
};
|
|
80
|
+
const selectOptions = choice.items.map(item => {
|
|
81
|
+
const itemText = (0, fp_1.getOr)('', 'text', item);
|
|
82
|
+
return {
|
|
83
|
+
name: itemText,
|
|
84
|
+
value: itemText,
|
|
85
|
+
validOption: true,
|
|
86
|
+
selected: itemText === answer
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
type: 'select',
|
|
91
|
+
name: (0, fp_1.getOr)('', 'name', choice),
|
|
92
|
+
onChange: (text) => {
|
|
93
|
+
const newAnswers = updateTemplateAnswer(text, answers, index, maxLength);
|
|
94
|
+
dispatch((0, answers_1.editAnswer)(newAnswers));
|
|
95
|
+
},
|
|
96
|
+
options: (0, fp_1.isEmpty)(answer) ? (0, fp_1.concat)([temporaryOption], selectOptions) : selectOptions
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const templateProps = (dispatch) => (answers, question) => {
|
|
100
|
+
const choices = question.content.choices;
|
|
101
|
+
const maxLength = (0, fp_1.size)(choices);
|
|
102
|
+
return {
|
|
103
|
+
type: 'template',
|
|
104
|
+
template: (0, fp_1.get)('content.template', question),
|
|
105
|
+
answers: choices.map((choice, index) => choice.type === 'text'
|
|
106
|
+
? templateTextProps(dispatch, answers, choice, index, maxLength)
|
|
107
|
+
: templateSelectProps(dispatch, answers, choice, index, maxLength))
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
const basicProps = (dispatch) => (answers, question) => {
|
|
111
|
+
return {
|
|
112
|
+
type: 'freeText',
|
|
113
|
+
placeholder: (0, fp_1.getOr)('', 'content.placeholder', question),
|
|
114
|
+
value: (0, fp_1.getOr)('', '0', answers),
|
|
115
|
+
onChange: (text) => {
|
|
116
|
+
dispatch((0, answers_1.editAnswer)([text]));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
const sliderProps = (dispatch) => (answers, question) => {
|
|
121
|
+
const values = (0, fp_1.rangeStep)((0, fp_1.getOr)(1, 'content.step', question), (0, fp_1.get)('content.min', question), (0, fp_1.get)('content.max', question) + 1
|
|
122
|
+
// Lodash doesn't infer the type very well here
|
|
123
|
+
);
|
|
124
|
+
const stateValue = (0, fp_1.head)(answers) || question.content.min;
|
|
125
|
+
const currentValue = (0, fp_1.toInteger)(stateValue);
|
|
126
|
+
const indexValue = (0, fp_1.indexOf)(currentValue, values);
|
|
127
|
+
const maxValue = (0, fp_1.size)(values) - 1;
|
|
128
|
+
const sliderPosition = (0, fp_1.divide)(indexValue, maxValue);
|
|
129
|
+
const unitLabel = (0, fp_1.get)('content.unitLabel', question);
|
|
130
|
+
return {
|
|
131
|
+
type: 'slider',
|
|
132
|
+
placeholder: question.explanation,
|
|
133
|
+
minLabel: `${question.content.min} ${unitLabel}`,
|
|
134
|
+
maxLabel: `${question.content.max} ${unitLabel}`,
|
|
135
|
+
title: `${currentValue} ${question.content.unitLabel}`,
|
|
136
|
+
value: sliderPosition,
|
|
137
|
+
onChange: (position) => {
|
|
138
|
+
// atom/range handler
|
|
139
|
+
const newValue = (0, fp_1.pipe)((0, fp_1.multiply)(maxValue), fp_1.round, (0, fp_1.get)(fp_1.__, values), fp_1.toString)(position);
|
|
140
|
+
dispatch((0, answers_1.editAnswer)([newValue]));
|
|
141
|
+
},
|
|
142
|
+
onSliderChange: (newValue) => {
|
|
143
|
+
// mobile/slider handler
|
|
144
|
+
dispatch((0, answers_1.editAnswer)([`${newValue}`]));
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
const getQuestionType = (question) => question.type;
|
|
149
|
+
exports.getQuestionType = getQuestionType;
|
|
150
|
+
const getHelp = (slide) => (0, fp_1.get)('question.explanation', slide);
|
|
151
|
+
const getAnswerUIModel = (question, answers, dispatch) => {
|
|
152
|
+
const type = (0, exports.getQuestionType)(question);
|
|
153
|
+
switch (type) {
|
|
154
|
+
case 'qcm':
|
|
155
|
+
return qcmProps(dispatch)(answers, question);
|
|
156
|
+
case 'qcmGraphic':
|
|
157
|
+
return qcmGraphicProps(dispatch)(answers, question);
|
|
158
|
+
case 'qcmDrag':
|
|
159
|
+
return qcmDragProps(dispatch)(answers, question);
|
|
160
|
+
case 'basic':
|
|
161
|
+
return basicProps(dispatch)(answers, question);
|
|
162
|
+
case 'template':
|
|
163
|
+
return templateProps(dispatch)(answers, question);
|
|
164
|
+
case 'slider':
|
|
165
|
+
return sliderProps(dispatch)(answers, question);
|
|
166
|
+
default:
|
|
167
|
+
throw new Error(`${type} is not an handled question.type`);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const mapApiSlideToUi = (dispatch) => (slide, answers) => {
|
|
171
|
+
const questionText = (0, fp_1.getOr)('', 'question.header', slide);
|
|
172
|
+
return {
|
|
173
|
+
questionText,
|
|
174
|
+
answerUI: { model: getAnswerUIModel(slide.question, answers, dispatch), help: getHelp(slide) }
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
exports.mapApiSlideToUi = mapApiSlideToUi;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.6.0",
|
|
3
|
+
"version": "0.6.1-alpha.0+397b6bc37",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
@@ -29,20 +29,12 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"lib",
|
|
31
31
|
"es",
|
|
32
|
-
"src",
|
|
33
32
|
"readme.md"
|
|
34
33
|
],
|
|
35
|
-
"main": "
|
|
36
|
-
"
|
|
37
|
-
".": {
|
|
38
|
-
"import": "./es/index.js",
|
|
39
|
-
"commonjs": "./lib/index.js",
|
|
40
|
-
"types": "./es/index.d.ts"
|
|
41
|
-
},
|
|
42
|
-
"./package.json": "./package.json"
|
|
43
|
-
},
|
|
34
|
+
"main": "lib/index.js",
|
|
35
|
+
"module": "es/index.js",
|
|
44
36
|
"dependencies": {
|
|
45
|
-
"@coorpacademy/components": "10.25.0",
|
|
37
|
+
"@coorpacademy/components": "10.25.1-alpha.0+397b6bc37",
|
|
46
38
|
"@coorpacademy/redux-task": "1.1.6",
|
|
47
39
|
"cross-fetch": "^3.1.5",
|
|
48
40
|
"jwt-decode": "^3.1.2",
|
|
@@ -77,5 +69,5 @@
|
|
|
77
69
|
"webpack-cli": "^4.10.0",
|
|
78
70
|
"webpack-dev-server": "^4.11.1"
|
|
79
71
|
},
|
|
80
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "397b6bc37e3ee081c19b8f246647a87f0648e1e6"
|
|
81
73
|
}
|
package/es/sandbox/index.d.ts
DELETED
package/es/sandbox/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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 { WebContext } from '@coorpacademy/components/es/atom/provider';
|
|
7
|
-
import { identity } from 'lodash/fp';
|
|
8
|
-
import AppReview from '../src';
|
|
9
|
-
import { services } from '../src/test/util/services.mock';
|
|
10
|
-
const isContainerAvailable = (options) => !pipe(get('container'), isNil)(options);
|
|
11
|
-
const createSandbox = (options) => {
|
|
12
|
-
if (!isContainerAvailable(options)) {
|
|
13
|
-
// eslint-disable-next-line no-console
|
|
14
|
-
console.error('[AppReview sandbox] Requires a container.');
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
const container = document.getElementById(options.container);
|
|
18
|
-
// mode mobile/web
|
|
19
|
-
const appOptions = {
|
|
20
|
-
token: process.env.API_TEST_TOKEN || '',
|
|
21
|
-
skillRef: '123',
|
|
22
|
-
services,
|
|
23
|
-
onQuitClick: () => {
|
|
24
|
-
location.reload();
|
|
25
|
-
},
|
|
26
|
-
url: process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006'
|
|
27
|
-
};
|
|
28
|
-
const skin = {
|
|
29
|
-
common: {
|
|
30
|
-
primary: '#248e59'
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
render(React.createElement(WebContext, { skin: skin, translate: identity },
|
|
34
|
-
React.createElement(AppReview, { options: appOptions })), container);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
// -----------------------------------------------------------------------------
|
|
38
|
-
if (window && !window.createSandbox) {
|
|
39
|
-
window.createSandbox = createSandbox;
|
|
40
|
-
}
|
|
41
|
-
createSandbox({ container: 'root' });
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ExecutionContext } from 'ava';
|
|
2
|
-
import { AnyAction, Store } from 'redux';
|
|
3
|
-
import { ThunkOptions } from '../../types/common';
|
|
4
|
-
import { StoreState } from '../../reducers';
|
|
5
|
-
export declare const createTestStore: (t: ExecutionContext, initialState: StoreState, thunkOptions: ThunkOptions, actions: AnyAction[]) => Store<StoreState, AnyAction>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import constant from 'lodash/fp/constant';
|
|
2
|
-
import { applyMiddleware, compose, createStore } from 'redux';
|
|
3
|
-
import thunk from 'redux-thunk';
|
|
4
|
-
import rootReducer from '../../reducers';
|
|
5
|
-
const assertActionsMiddleware = (t, ACTIONS) => constant((next) => (action) => {
|
|
6
|
-
const expectedAction = ACTIONS.shift();
|
|
7
|
-
if (!expectedAction)
|
|
8
|
-
throw new Error(`Missing {type: "${action.type}"} action`);
|
|
9
|
-
t.deepEqual(action, expectedAction);
|
|
10
|
-
return next(action);
|
|
11
|
-
});
|
|
12
|
-
export const createTestStore = (t, initialState, thunkOptions, actions) => {
|
|
13
|
-
const thunkMiddleware = thunk.withExtraArgument(thunkOptions);
|
|
14
|
-
const enhancer = compose(applyMiddleware(thunkMiddleware, assertActionsMiddleware(t, actions)));
|
|
15
|
-
return createStore(rootReducer, initialState, enhancer);
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import browserEnv from 'browser-env';
|
|
2
|
-
import identity from 'lodash/fp/identity';
|
|
3
|
-
import test from 'ava';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { render, fireEvent, act } from '@testing-library/react';
|
|
6
|
-
import { sleep } from '../services/tools/sleep';
|
|
7
|
-
import AppReview from '..';
|
|
8
|
-
import { services } from './util/services.mock';
|
|
9
|
-
browserEnv({ pretendToBeVisual: true });
|
|
10
|
-
const elementExists = (foundElements) => foundElements && foundElements[0];
|
|
11
|
-
const waitForChanges = async (msToWait = 3000) => {
|
|
12
|
-
await act(async () => {
|
|
13
|
-
await sleep(msToWait); // wait *just* a little longer than the timeout in the component
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
const LIMIT = 5;
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
|
-
const clickAllSlides = async (t, container, accumulator = 0) => {
|
|
19
|
-
if (accumulator === LIMIT)
|
|
20
|
-
return;
|
|
21
|
-
// last one needs to wait for more calculations && components updates
|
|
22
|
-
if (accumulator === 4)
|
|
23
|
-
await act(async () => {
|
|
24
|
-
await sleep(1000);
|
|
25
|
-
});
|
|
26
|
-
const validateButton = container.querySelectorAll(`[data-name="slide-validate-button-${accumulator}"]`);
|
|
27
|
-
t.truthy(elementExists(validateButton));
|
|
28
|
-
await act(async () => {
|
|
29
|
-
await fireEvent.click(validateButton[0]);
|
|
30
|
-
});
|
|
31
|
-
const nextButton = container.querySelectorAll(`[data-name="next-question-button-${accumulator}"]`);
|
|
32
|
-
t.truthy(elementExists(nextButton));
|
|
33
|
-
await act(async () => {
|
|
34
|
-
await fireEvent.click(nextButton[0]);
|
|
35
|
-
});
|
|
36
|
-
await clickAllSlides(t, container, accumulator + 1);
|
|
37
|
-
};
|
|
38
|
-
const appOptions = {
|
|
39
|
-
token: process.env.API_TEST_TOKEN || '',
|
|
40
|
-
skillRef: 'skill_NJC0jFKoH',
|
|
41
|
-
services,
|
|
42
|
-
onQuitClick: identity,
|
|
43
|
-
url: process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006'
|
|
44
|
-
};
|
|
45
|
-
test('should show the loader while the app is fetching the data', async (t) => {
|
|
46
|
-
t.plan(2);
|
|
47
|
-
const { container } = render(React.createElement(AppReview, { options: appOptions }));
|
|
48
|
-
await waitForChanges(1000);
|
|
49
|
-
const loader = container.querySelector('[data-name="loader"]');
|
|
50
|
-
t.truthy(loader);
|
|
51
|
-
// await waitFor(async () => {
|
|
52
|
-
// // await sleep(500);
|
|
53
|
-
// const result = await t.try(tt => {
|
|
54
|
-
// // rerender(<AppReview options={appOptions} />);
|
|
55
|
-
// const slidesContainer = container.querySelector('[data-name="slides-revision-container"]');
|
|
56
|
-
// tt.truthy(slidesContainer);
|
|
57
|
-
// });
|
|
58
|
-
// if (result.passed) return result.commit();
|
|
59
|
-
// result.discard();
|
|
60
|
-
// throw result.errors;
|
|
61
|
-
// });
|
|
62
|
-
// const stackedSlidesContainer = container.querySelector('[data-name="stacked-slides-container"]');
|
|
63
|
-
// t.truthy(stackedSlidesContainer);
|
|
64
|
-
// await clickAllSlides(t, container);
|
|
65
|
-
t.pass();
|
|
66
|
-
});
|