@cuemath/leap 3.5.30-gg4 → 3.5.30-j1
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/dist/assets/illustrations/illustrations.js +12 -0
- package/dist/assets/illustrations/illustrations.js.map +1 -1
- package/dist/assets/images/images.js +8 -0
- package/dist/assets/images/images.js.map +1 -1
- package/dist/assets/line-icons/icons/carat-right.js +26 -0
- package/dist/assets/line-icons/icons/carat-right.js.map +1 -0
- package/dist/features/chapters/chapters-list/chapter-item/chapter-circular-progress/chapter-circular-progress.js +3 -3
- package/dist/features/chapters/chapters-list/chapter-item/chapter-circular-progress/chapter-circular-progress.js.map +1 -1
- package/dist/features/circle-games/game-launcher/comps/carousel/carousel-styled.js +16 -32
- package/dist/features/circle-games/game-launcher/comps/carousel/carousel-styled.js.map +1 -1
- package/dist/features/circle-games/game-launcher/comps/carousel/carousel.js +88 -87
- package/dist/features/circle-games/game-launcher/comps/carousel/carousel.js.map +1 -1
- package/dist/features/circle-games/game-launcher/hooks/use-game-launcher-journey/use-game-launcher-journey.js +35 -35
- package/dist/features/circle-games/game-launcher/hooks/use-game-launcher-journey/use-game-launcher-journey.js.map +1 -1
- package/dist/features/stickers/hooks/use-handle-sticker-send/use-handle-sticker-send.js +0 -1
- package/dist/features/stickers/hooks/use-handle-sticker-send/use-handle-sticker-send.js.map +1 -1
- package/dist/features/timeline/daily-timeline-styled.js +13 -9
- package/dist/features/timeline/daily-timeline-styled.js.map +1 -1
- package/dist/features/timeline/daily-timeline-view.js +9 -10
- package/dist/features/timeline/daily-timeline-view.js.map +1 -1
- package/dist/features/timeline/monthly-report/api/use-monthly-report-get.js +13 -0
- package/dist/features/timeline/monthly-report/api/use-monthly-report-get.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/achievements/achievements.js +68 -0
- package/dist/features/timeline/monthly-report/comps/achievements/achievements.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/achievements/achievements.styled.js +15 -0
- package/dist/features/timeline/monthly-report/comps/achievements/achievements.styled.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/activities/activities-card/activities-card.js +128 -0
- package/dist/features/timeline/monthly-report/comps/activities/activities-card/activities-card.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/activities/activities-card/activities-card.styled.js +53 -0
- package/dist/features/timeline/monthly-report/comps/activities/activities-card/activities-card.styled.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/activities/activities-card-puzzles/activities-card-puzzles.js +121 -0
- package/dist/features/timeline/monthly-report/comps/activities/activities-card-puzzles/activities-card-puzzles.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/activities/activities-card-puzzles/activities-card-puzzles.styled.js +58 -0
- package/dist/features/timeline/monthly-report/comps/activities/activities-card-puzzles/activities-card-puzzles.styled.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/activities/activities.js +27 -0
- package/dist/features/timeline/monthly-report/comps/activities/activities.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/activities/constants.js +95 -0
- package/dist/features/timeline/monthly-report/comps/activities/constants.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/activities/utils.js +15 -0
- package/dist/features/timeline/monthly-report/comps/activities/utils.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/attendance/attendance-constants.js +29 -0
- package/dist/features/timeline/monthly-report/comps/attendance/attendance-constants.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/attendance/attendance-utils.js +92 -0
- package/dist/features/timeline/monthly-report/comps/attendance/attendance-utils.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/attendance/attendance.js +44 -0
- package/dist/features/timeline/monthly-report/comps/attendance/attendance.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/attendance/attendance.styled.js +39 -0
- package/dist/features/timeline/monthly-report/comps/attendance/attendance.styled.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/attendance/attendence-view.js +52 -0
- package/dist/features/timeline/monthly-report/comps/attendance/attendence-view.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/feedback/feedback-styled.js +9 -0
- package/dist/features/timeline/monthly-report/comps/feedback/feedback-styled.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/feedback/feedback.js +94 -0
- package/dist/features/timeline/monthly-report/comps/feedback/feedback.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/goals/goals-card/goal-chapter-card.js +48 -0
- package/dist/features/timeline/monthly-report/comps/goals/goals-card/goal-chapter-card.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/goals/goals-card/goals-card-styled.js +28 -0
- package/dist/features/timeline/monthly-report/comps/goals/goals-card/goals-card-styled.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/goals/goals-card/goals-card.js +113 -0
- package/dist/features/timeline/monthly-report/comps/goals/goals-card/goals-card.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/goals/goals-constants.js +30 -0
- package/dist/features/timeline/monthly-report/comps/goals/goals-constants.js.map +1 -0
- package/dist/features/timeline/monthly-report/comps/goals/goals.js +22 -0
- package/dist/features/timeline/monthly-report/comps/goals/goals.js.map +1 -0
- package/dist/features/timeline/monthly-report/monthly-report-styled.js +14 -0
- package/dist/features/timeline/monthly-report/monthly-report-styled.js.map +1 -0
- package/dist/features/timeline/monthly-report/monthly-report-types.js +5 -0
- package/dist/features/timeline/monthly-report/monthly-report-types.js.map +1 -0
- package/dist/features/timeline/monthly-report/monthly-report.js +69 -0
- package/dist/features/timeline/monthly-report/monthly-report.js.map +1 -0
- package/dist/features/timeline/monthly-timeline/api/use-monthly-timeline-get.js +10 -0
- package/dist/features/timeline/monthly-timeline/api/use-monthly-timeline-get.js.map +1 -0
- package/dist/features/timeline/monthly-timeline/comps/monthly-card/monthly-card.js +87 -0
- package/dist/features/timeline/monthly-timeline/comps/monthly-card/monthly-card.js.map +1 -0
- package/dist/features/timeline/monthly-timeline/comps/monthly-card/monthly-card.styled.js +9 -0
- package/dist/features/timeline/monthly-timeline/comps/monthly-card/monthly-card.styled.js.map +1 -0
- package/dist/features/timeline/monthly-timeline/constants.js +41 -0
- package/dist/features/timeline/monthly-timeline/constants.js.map +1 -0
- package/dist/features/timeline/monthly-timeline/monthly-timeline-styled.js +13 -0
- package/dist/features/timeline/monthly-timeline/monthly-timeline-styled.js.map +1 -0
- package/dist/features/timeline/monthly-timeline/monthly-timeline-types.js +6 -0
- package/dist/features/timeline/monthly-timeline/monthly-timeline-types.js.map +1 -0
- package/dist/features/timeline/monthly-timeline/monthly-timeline-view.js +28 -0
- package/dist/features/timeline/monthly-timeline/monthly-timeline-view.js.map +1 -0
- package/dist/features/timeline/monthly-timeline/monthly-timeline.js +62 -0
- package/dist/features/timeline/monthly-timeline/monthly-timeline.js.map +1 -0
- package/dist/features/timeline/ptm-report/api/use-ptm-report-get.js +9 -0
- package/dist/features/timeline/ptm-report/api/use-ptm-report-get.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/key-need/key-need-styled.js +9 -0
- package/dist/features/timeline/ptm-report/comps/key-need/key-need-styled.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/key-need/key-need.js +35 -0
- package/dist/features/timeline/ptm-report/comps/key-need/key-need.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/parent-support/parent-support.js +53 -0
- package/dist/features/timeline/ptm-report/comps/parent-support/parent-support.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/real-world-projects/real-world-projects-styled.js +19 -0
- package/dist/features/timeline/ptm-report/comps/real-world-projects/real-world-projects-styled.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/real-world-projects/real-world-projects.js +50 -0
- package/dist/features/timeline/ptm-report/comps/real-world-projects/real-world-projects.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/report-card/report-card-styled.js +9 -0
- package/dist/features/timeline/ptm-report/comps/report-card/report-card-styled.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/report-card/report-card.js +22 -0
- package/dist/features/timeline/ptm-report/comps/report-card/report-card.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/school-support/school-support-styled.js +9 -0
- package/dist/features/timeline/ptm-report/comps/school-support/school-support-styled.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/school-support/school-support.js +84 -0
- package/dist/features/timeline/ptm-report/comps/school-support/school-support.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/strategies/strategies-constant.js +11 -0
- package/dist/features/timeline/ptm-report/comps/strategies/strategies-constant.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/strategies/strategies.js +36 -0
- package/dist/features/timeline/ptm-report/comps/strategies/strategies.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/strategy-card/strategy-card-styled.js +55 -0
- package/dist/features/timeline/ptm-report/comps/strategy-card/strategy-card-styled.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/strategy-card/strategy-card.js +35 -0
- package/dist/features/timeline/ptm-report/comps/strategy-card/strategy-card.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/student-info/student-info-styled.js +21 -0
- package/dist/features/timeline/ptm-report/comps/student-info/student-info-styled.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/student-info/student-info.js +21 -0
- package/dist/features/timeline/ptm-report/comps/student-info/student-info.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/support-card/support-card-styled.js +9 -0
- package/dist/features/timeline/ptm-report/comps/support-card/support-card-styled.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/support-card/support-card.js +30 -0
- package/dist/features/timeline/ptm-report/comps/support-card/support-card.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/teacher-observations/teacher-observations-constant.js +9 -0
- package/dist/features/timeline/ptm-report/comps/teacher-observations/teacher-observations-constant.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/teacher-observations/teacher-observations.js +56 -0
- package/dist/features/timeline/ptm-report/comps/teacher-observations/teacher-observations.js.map +1 -0
- package/dist/features/timeline/ptm-report/comps/upcoming-chapters/upcoming-chapters.js +15 -0
- package/dist/features/timeline/ptm-report/comps/upcoming-chapters/upcoming-chapters.js.map +1 -0
- package/dist/features/timeline/ptm-report/ptm-report-constants.js +16 -0
- package/dist/features/timeline/ptm-report/ptm-report-constants.js.map +1 -0
- package/dist/features/timeline/ptm-report/ptm-report-helpers.js +8 -0
- package/dist/features/timeline/ptm-report/ptm-report-helpers.js.map +1 -0
- package/dist/features/timeline/ptm-report/ptm-report-styled.js +11 -0
- package/dist/features/timeline/ptm-report/ptm-report-styled.js.map +1 -0
- package/dist/features/timeline/ptm-report/ptm-report-types.js +5 -0
- package/dist/features/timeline/ptm-report/ptm-report-types.js.map +1 -0
- package/dist/features/timeline/ptm-report/ptm-report.js +113 -0
- package/dist/features/timeline/ptm-report/ptm-report.js.map +1 -0
- package/dist/features/timeline/timeline-tabs/timeline-tabs-types.js +5 -0
- package/dist/features/timeline/timeline-tabs/timeline-tabs-types.js.map +1 -0
- package/dist/features/timeline/timeline-tabs/timeline-tabs.js +42 -0
- package/dist/features/timeline/timeline-tabs/timeline-tabs.js.map +1 -0
- package/dist/features/timeline/timeline-tabs/timeline-tabs.styled.js +37 -0
- package/dist/features/timeline/timeline-tabs/timeline-tabs.styled.js.map +1 -0
- package/dist/features/ui/arrow-tooltip/comps/tooltip-body-styled.js.map +1 -1
- package/dist/features/ui/arrow-tooltip/comps/tooltip-body.js +11 -11
- package/dist/features/ui/arrow-tooltip/comps/tooltip-body.js.map +1 -1
- package/dist/features/ui/swipable-carousel/swipable-carousel-styled.js +57 -0
- package/dist/features/ui/swipable-carousel/swipable-carousel-styled.js.map +1 -0
- package/dist/features/ui/swipable-carousel/swipable-carousel.js +132 -0
- package/dist/features/ui/swipable-carousel/swipable-carousel.js.map +1 -0
- package/dist/features/ui/swipeable-component/swipeable-component-styled.js.map +1 -0
- package/dist/features/ui/swipeable-component/swipeable-component.js +27 -0
- package/dist/features/ui/swipeable-component/swipeable-component.js.map +1 -0
- package/dist/features/worksheet/user-pointer-pin/hooks/use-user-location.js +20 -21
- package/dist/features/worksheet/user-pointer-pin/hooks/use-user-location.js.map +1 -1
- package/dist/features/worksheet/user-pointer-pin/user-pin.js +35 -37
- package/dist/features/worksheet/user-pointer-pin/user-pin.js.map +1 -1
- package/dist/features/worksheet/worksheet/hooks/use-create-imperative-handle.js +132 -132
- package/dist/features/worksheet/worksheet/hooks/use-create-imperative-handle.js.map +1 -1
- package/dist/features/worksheet/worksheet/hooks/use-get-active-question-id.js +62 -0
- package/dist/features/worksheet/worksheet/hooks/use-get-active-question-id.js.map +1 -0
- package/dist/features/worksheet/worksheet/hooks/use-time-on-questions.js +19 -24
- package/dist/features/worksheet/worksheet/hooks/use-time-on-questions.js.map +1 -1
- package/dist/features/worksheet/worksheet/question-tips.js +47 -48
- package/dist/features/worksheet/worksheet/question-tips.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-action-bar/worksheet-action-bar.js +132 -88
- package/dist/features/worksheet/worksheet/worksheet-action-bar/worksheet-action-bar.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-blocker/worksheet-blocker.js +55 -44
- package/dist/features/worksheet/worksheet/worksheet-blocker/worksheet-blocker.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-container.js +87 -0
- package/dist/features/worksheet/worksheet/worksheet-container.js.map +1 -0
- package/dist/features/worksheet/worksheet/worksheet-helpers.js +112 -109
- package/dist/features/worksheet/worksheet/worksheet-helpers.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-navigation/worksheet-item-navigation/worksheet-item-navigation.js +27 -25
- package/dist/features/worksheet/worksheet/worksheet-navigation/worksheet-item-navigation/worksheet-item-navigation.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-navigation/worksheet-item-number/worksheet-item-number.js +47 -47
- package/dist/features/worksheet/worksheet/worksheet-navigation/worksheet-item-number/worksheet-item-number.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-navigation/worksheet-navigation.js +64 -66
- package/dist/features/worksheet/worksheet/worksheet-navigation/worksheet-navigation.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-navigation/worksheet-section-navigation/worksheet-section-navigation.js +40 -38
- package/dist/features/worksheet/worksheet/worksheet-navigation/worksheet-section-navigation/worksheet-section-navigation.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-permissions/error.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-question/header/header.js +71 -73
- package/dist/features/worksheet/worksheet/worksheet-question/header/header.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-question/learnosity-question.js +59 -61
- package/dist/features/worksheet/worksheet/worksheet-question/learnosity-question.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-question/subjective-review.js +18 -21
- package/dist/features/worksheet/worksheet/worksheet-question/subjective-review.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-question/worksheet-question.js +272 -269
- package/dist/features/worksheet/worksheet/worksheet-question/worksheet-question.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-questions-controller/scribble-switch.js +31 -32
- package/dist/features/worksheet/worksheet/worksheet-questions-controller/scribble-switch.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-questions-controller/use-handler-callbacks.js +149 -147
- package/dist/features/worksheet/worksheet/worksheet-questions-controller/use-handler-callbacks.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-questions-controller/worksheet-questions-controller.js +223 -212
- package/dist/features/worksheet/worksheet/worksheet-questions-controller/worksheet-questions-controller.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-questions-summary/worksheet-questions-summary.js +20 -22
- package/dist/features/worksheet/worksheet/worksheet-questions-summary/worksheet-questions-summary.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-sidebar/question-guide.js +55 -57
- package/dist/features/worksheet/worksheet/worksheet-sidebar/question-guide.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-sidebar/sidebar.js +42 -47
- package/dist/features/worksheet/worksheet/worksheet-sidebar/sidebar.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-styled.js +34 -24
- package/dist/features/worksheet/worksheet/worksheet-styled.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-summary/worksheet-summary.js +12 -16
- package/dist/features/worksheet/worksheet/worksheet-summary/worksheet-summary.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-summary-controller/worksheet-summary-controller.js +7 -8
- package/dist/features/worksheet/worksheet/worksheet-summary-controller/worksheet-summary-controller.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-types.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet.js +441 -203
- package/dist/features/worksheet/worksheet/worksheet.js.map +1 -1
- package/dist/features/worksheet/worksheet-preview/hooks/use-worksheet-layout.js.map +1 -1
- package/dist/features/worksheet/worksheet-preview/worksheet-preview-view.js +1 -1
- package/dist/features/worksheet/worksheet-preview/worksheet-preview-view.js.map +1 -1
- package/dist/index.d.ts +276 -31
- package/dist/index.js +465 -451
- package/dist/index.js.map +1 -1
- package/dist/static/2021.0683b580.png +0 -0
- package/dist/static/2022.d34ad7a5.png +0 -0
- package/dist/static/2023.fce87149.png +0 -0
- package/dist/static/2024.a275ee85.png +0 -0
- package/dist/static/2025.677cc187.png +0 -0
- package/dist/static/2026.63763214.png +0 -0
- package/dist/static/2027.b82dc039.png +0 -0
- package/dist/static/2028.580b8cc0.png +0 -0
- package/dist/static/coding-report-icon.91a1e900.svg +1 -0
- package/dist/static/elp-icon.d45b457d.svg +1 -0
- package/dist/static/empty-reports.fe92faad.svg +1 -0
- package/dist/static/english-icon.50c2e005.svg +1 -0
- package/dist/static/full-report.00112c74.svg +1 -0
- package/dist/static/math-fit-grey.c32f37b3.svg +1 -0
- package/dist/static/no-report.4158fad3.svg +1 -0
- package/dist/static/ptm-report-icon.5089218f.svg +1 -0
- package/dist/static/sat-report-icon.4331be86.svg +1 -0
- package/dist/static/science-report-icon.a0014c40.svg +1 -0
- package/dist/static/thumps-down.a1192a62.svg +1 -0
- package/dist/static/thumps-up.caa35a98.svg +1 -0
- package/package.json +3 -4
- package/dist/features/circle-games/game-launcher/comps/swipable-component/swipeable-component-styled.js.map +0 -1
- package/dist/features/circle-games/game-launcher/comps/swipable-component/swipeable-component.js +0 -26
- package/dist/features/circle-games/game-launcher/comps/swipable-component/swipeable-component.js.map +0 -1
- package/dist/features/worksheet/worksheet/hooks/use-active-question-observer.js +0 -59
- package/dist/features/worksheet/worksheet/hooks/use-active-question-observer.js.map +0 -1
- package/dist/features/worksheet/worksheet/hooks/use-worksheet-store.js +0 -13
- package/dist/features/worksheet/worksheet/hooks/use-worksheet-store.js.map +0 -1
- package/dist/features/worksheet/worksheet/worksheet-blocker/worksheet-blocker-view.js +0 -68
- package/dist/features/worksheet/worksheet/worksheet-blocker/worksheet-blocker-view.js.map +0 -1
- package/dist/features/worksheet/worksheet/worksheet-calculator/worksheet-calculator.js +0 -17
- package/dist/features/worksheet/worksheet/worksheet-calculator/worksheet-calculator.js.map +0 -1
- package/dist/features/worksheet/worksheet/worksheet-nudge-banner/worksheet-nudge-banner-styled.js +0 -20
- package/dist/features/worksheet/worksheet/worksheet-nudge-banner/worksheet-nudge-banner-styled.js.map +0 -1
- package/dist/features/worksheet/worksheet/worksheet-nudge-banner/worksheet-nudge-banner.js +0 -49
- package/dist/features/worksheet/worksheet/worksheet-nudge-banner/worksheet-nudge-banner.js.map +0 -1
- package/dist/features/worksheet/worksheet/worksheet-provider.js +0 -21
- package/dist/features/worksheet/worksheet/worksheet-provider.js.map +0 -1
- package/dist/features/worksheet/worksheet/worksheet-questions/worksheet-questions-styled.js +0 -16
- package/dist/features/worksheet/worksheet/worksheet-questions/worksheet-questions-styled.js.map +0 -1
- package/dist/features/worksheet/worksheet/worksheet-questions/worksheet-questions.js +0 -73
- package/dist/features/worksheet/worksheet/worksheet-questions/worksheet-questions.js.map +0 -1
- package/dist/features/worksheet/worksheet/worksheet-store.js +0 -301
- package/dist/features/worksheet/worksheet/worksheet-store.js.map +0 -1
- package/dist/features/worksheet/worksheet/worksheet-view.js +0 -141
- package/dist/features/worksheet/worksheet/worksheet-view.js.map +0 -1
- package/dist/node_modules/zustand/esm/middleware.js +0 -22
- package/dist/node_modules/zustand/esm/middleware.js.map +0 -1
- package/dist/node_modules/zustand/esm/react/shallow.js +0 -13
- package/dist/node_modules/zustand/esm/react/shallow.js.map +0 -1
- package/dist/node_modules/zustand/esm/vanilla/shallow.js +0 -31
- package/dist/node_modules/zustand/esm/vanilla/shallow.js.map +0 -1
- /package/dist/features/{circle-games/game-launcher/comps/swipable-component → ui/swipeable-component}/swipeable-component-styled.js +0 -0
|
@@ -1,184 +1,184 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
import
|
|
3
|
-
import { TEACHER_VALIDATION_AUDIO_LIST as
|
|
4
|
-
import { getQuestionMetadata as
|
|
5
|
-
import { QUESTIONS_RATING as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
var
|
|
20
|
-
const
|
|
21
|
-
...
|
|
22
|
-
...
|
|
1
|
+
import { useCallback as D, useImperativeHandle as K } from "react";
|
|
2
|
+
import X from "../../../hooks/use-audio-player.js";
|
|
3
|
+
import { TEACHER_VALIDATION_AUDIO_LIST as Y } from "../constants.js";
|
|
4
|
+
import { getQuestionMetadata as Q, isConceptIntroWidget as Z } from "../worksheet-helpers.js";
|
|
5
|
+
import { QUESTIONS_RATING as v, QUESTION_TAGS as x } from "../worksheet-types.js";
|
|
6
|
+
const h = (F, {
|
|
7
|
+
behavior: J,
|
|
8
|
+
questions: r,
|
|
9
|
+
setResponses: S,
|
|
10
|
+
onResponseChange: L,
|
|
11
|
+
onBulkResponsesChange: d,
|
|
12
|
+
getTimeSpentOnQuestion: W
|
|
13
|
+
}) => {
|
|
14
|
+
const { navigationMode: w } = J, M = X(Y), H = D(
|
|
15
|
+
(_, a, T) => {
|
|
16
|
+
M("VALIDATE");
|
|
17
|
+
const c = W(_);
|
|
18
|
+
S((t) => {
|
|
19
|
+
var $, j;
|
|
20
|
+
const m = r.findIndex((E) => E.response_id === _), i = r[m], f = {
|
|
21
|
+
...Q(r, _),
|
|
22
|
+
...t[_],
|
|
23
23
|
validatedByTeacher: !0,
|
|
24
|
-
rating:
|
|
25
|
-
timeSpent:
|
|
24
|
+
rating: a ? v[a] : void 0,
|
|
25
|
+
timeSpent: c
|
|
26
26
|
};
|
|
27
|
-
if (
|
|
28
|
-
if ((
|
|
29
|
-
return
|
|
30
|
-
const
|
|
31
|
-
[
|
|
32
|
-
...
|
|
33
|
-
(
|
|
34
|
-
...
|
|
35
|
-
...
|
|
27
|
+
if (w === "ADAPTIVE") {
|
|
28
|
+
if (($ = t[_]) != null && $.validatedByTeacher)
|
|
29
|
+
return t;
|
|
30
|
+
const E = i.item_tags_map[x.TRIAL_TOPIC], O = i.item_tags_map[x.QUESTION_CODE], y = O && O.length < 3 ? `${O}${a}` : "Q", I = r.findIndex((A, U) => U <= m ? !1 : y !== "Q" ? A.item_tags_map[x.TRIAL_TOPIC] === E && A.item_tags_map[x.QUESTION_CODE] === y : A.item_tags_map[x.TRIAL_TOPIC] !== E), N = {
|
|
31
|
+
[_]: f,
|
|
32
|
+
...r.reduce(
|
|
33
|
+
(A, U, z) => (z <= m || I > -1 && z >= I || (A[U.response_id] = {
|
|
34
|
+
...Q(r, U.response_id),
|
|
35
|
+
...t[U.response_id],
|
|
36
36
|
assignStatus: "skipped"
|
|
37
|
-
}),
|
|
37
|
+
}), A),
|
|
38
38
|
{}
|
|
39
39
|
)
|
|
40
|
-
},
|
|
41
|
-
return
|
|
42
|
-
...
|
|
43
|
-
[
|
|
44
|
-
...
|
|
45
|
-
...
|
|
40
|
+
}, P = (j = r[I]) == null ? void 0 : j.response_id;
|
|
41
|
+
return P ? d == null || d({
|
|
42
|
+
...N,
|
|
43
|
+
[P]: {
|
|
44
|
+
...t[P],
|
|
45
|
+
...Q(r, P),
|
|
46
46
|
assignStatus: void 0
|
|
47
47
|
}
|
|
48
|
-
}) :
|
|
49
|
-
...
|
|
50
|
-
...
|
|
48
|
+
}) : d == null || d(N), {
|
|
49
|
+
...t,
|
|
50
|
+
...N
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
if (
|
|
54
|
-
const { item_reference:
|
|
55
|
-
[
|
|
56
|
-
...
|
|
57
|
-
(
|
|
58
|
-
var
|
|
59
|
-
return
|
|
60
|
-
...
|
|
61
|
-
...
|
|
53
|
+
if (T) {
|
|
54
|
+
const { item_reference: E } = i, O = {
|
|
55
|
+
[_]: f,
|
|
56
|
+
...r.reduce(
|
|
57
|
+
(y, I) => {
|
|
58
|
+
var N;
|
|
59
|
+
return I.response_id !== i.response_id && I.item_reference === E && !((N = t[I.response_id]) != null && N.validatedByTeacher) && (y[I.response_id] = {
|
|
60
|
+
...Q(r, I.response_id),
|
|
61
|
+
...t[I.response_id],
|
|
62
62
|
assignStatus: "skipped"
|
|
63
|
-
}),
|
|
63
|
+
}), y;
|
|
64
64
|
},
|
|
65
65
|
{}
|
|
66
66
|
)
|
|
67
67
|
};
|
|
68
|
-
return
|
|
69
|
-
...
|
|
70
|
-
...
|
|
68
|
+
return d == null || d({
|
|
69
|
+
...t,
|
|
70
|
+
...O
|
|
71
71
|
}), {
|
|
72
|
-
...
|
|
73
|
-
...
|
|
72
|
+
...t,
|
|
73
|
+
...O
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
return
|
|
77
|
-
...
|
|
78
|
-
[
|
|
79
|
-
}) :
|
|
80
|
-
responseId:
|
|
81
|
-
response:
|
|
76
|
+
return w === "CURRENT" && i.item_number === 0 ? d == null || d({
|
|
77
|
+
...t,
|
|
78
|
+
[_]: f
|
|
79
|
+
}) : L == null || L({
|
|
80
|
+
responseId: _,
|
|
81
|
+
response: f,
|
|
82
82
|
question: i,
|
|
83
83
|
isNewAttempt: !1
|
|
84
84
|
}), {
|
|
85
|
-
...
|
|
86
|
-
[
|
|
85
|
+
...t,
|
|
86
|
+
[_]: f
|
|
87
87
|
};
|
|
88
88
|
});
|
|
89
89
|
},
|
|
90
90
|
[
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
W,
|
|
92
|
+
w,
|
|
93
|
+
d,
|
|
94
|
+
L,
|
|
95
|
+
M,
|
|
96
|
+
r,
|
|
97
|
+
S
|
|
98
98
|
]
|
|
99
|
-
),
|
|
100
|
-
(
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
(
|
|
104
|
-
var
|
|
105
|
-
return
|
|
99
|
+
), V = D(
|
|
100
|
+
(_) => {
|
|
101
|
+
S((a) => {
|
|
102
|
+
const T = r.filter(
|
|
103
|
+
(t) => {
|
|
104
|
+
var m;
|
|
105
|
+
return _.startsWith("advanced-") ? (m = t.item_type) == null ? void 0 : m.startsWith("advanced-") : t.item_type === _;
|
|
106
106
|
}
|
|
107
|
-
),
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
...
|
|
111
|
-
...
|
|
107
|
+
), c = {};
|
|
108
|
+
return T.length > 0 ? (T.forEach((t) => {
|
|
109
|
+
c[t.response_id] = {
|
|
110
|
+
...Q(r, t.response_id),
|
|
111
|
+
...a[t.response_id],
|
|
112
112
|
assignStatus: "assigned"
|
|
113
113
|
};
|
|
114
|
-
}),
|
|
115
|
-
...
|
|
116
|
-
...
|
|
117
|
-
}) :
|
|
114
|
+
}), d == null || d(c), {
|
|
115
|
+
...a,
|
|
116
|
+
...c
|
|
117
|
+
}) : a;
|
|
118
118
|
});
|
|
119
119
|
},
|
|
120
|
-
[
|
|
121
|
-
),
|
|
122
|
-
(
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
(
|
|
120
|
+
[d, r, S]
|
|
121
|
+
), b = D(
|
|
122
|
+
(_) => {
|
|
123
|
+
S((a) => {
|
|
124
|
+
const T = r.filter(
|
|
125
|
+
(m) => {
|
|
126
126
|
var i;
|
|
127
|
-
return
|
|
127
|
+
return _.startsWith("advanced-") ? (i = m.item_type) == null ? void 0 : i.startsWith("advanced-") : m.item_type === _;
|
|
128
128
|
}
|
|
129
|
-
),
|
|
130
|
-
return
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
...
|
|
134
|
-
...
|
|
129
|
+
), c = {}, t = [];
|
|
130
|
+
return T.length > 0 ? (T.forEach((i) => {
|
|
131
|
+
const f = a[i.response_id];
|
|
132
|
+
f != null && f.validatedByTeacher ? t.push(i) : c[i.response_id] = {
|
|
133
|
+
...Q(r, i.response_id),
|
|
134
|
+
...f,
|
|
135
135
|
assignStatus: "skipped"
|
|
136
136
|
};
|
|
137
|
-
}),
|
|
138
|
-
({ instructor_stimulus: i }) => !(i === "SystemIntro" ||
|
|
139
|
-
) ||
|
|
140
|
-
|
|
141
|
-
...
|
|
142
|
-
...
|
|
137
|
+
}), t.some(
|
|
138
|
+
({ instructor_stimulus: i }) => !(i === "SystemIntro" || Z(i))
|
|
139
|
+
) || t.forEach((i) => {
|
|
140
|
+
c[i.response_id] = {
|
|
141
|
+
...Q(r, i.response_id),
|
|
142
|
+
...a[i.response_id],
|
|
143
143
|
assignStatus: "skipped"
|
|
144
144
|
};
|
|
145
|
-
}),
|
|
146
|
-
...
|
|
147
|
-
...
|
|
148
|
-
}) :
|
|
145
|
+
}), d == null || d(c), {
|
|
146
|
+
...a,
|
|
147
|
+
...c
|
|
148
|
+
}) : a;
|
|
149
149
|
});
|
|
150
150
|
},
|
|
151
|
-
[
|
|
152
|
-
),
|
|
153
|
-
(
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
if (!
|
|
151
|
+
[d, r, S]
|
|
152
|
+
), G = D(
|
|
153
|
+
(_, a, T) => {
|
|
154
|
+
const c = a === "SIMULATION" ? "simState" : void 0;
|
|
155
|
+
c && S((t) => {
|
|
156
|
+
if (!r.find((f) => f.response_id === _)) return t;
|
|
157
157
|
const i = {
|
|
158
|
-
...
|
|
159
|
-
...
|
|
160
|
-
[
|
|
158
|
+
...Q(r, _),
|
|
159
|
+
...t[_],
|
|
160
|
+
[c]: T
|
|
161
161
|
};
|
|
162
162
|
return {
|
|
163
|
-
...
|
|
164
|
-
[
|
|
163
|
+
...t,
|
|
164
|
+
[_]: i
|
|
165
165
|
};
|
|
166
166
|
});
|
|
167
167
|
},
|
|
168
|
-
[
|
|
168
|
+
[r, S]
|
|
169
169
|
);
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
K(
|
|
171
|
+
F,
|
|
172
172
|
() => ({
|
|
173
|
-
validateQuestion:
|
|
174
|
-
assignOptionalItems:
|
|
175
|
-
skipOptionalItems:
|
|
176
|
-
updateMediaState:
|
|
173
|
+
validateQuestion: H,
|
|
174
|
+
assignOptionalItems: V,
|
|
175
|
+
skipOptionalItems: b,
|
|
176
|
+
updateMediaState: G
|
|
177
177
|
}),
|
|
178
|
-
[
|
|
178
|
+
[V, b, G, H]
|
|
179
179
|
);
|
|
180
180
|
};
|
|
181
181
|
export {
|
|
182
|
-
|
|
182
|
+
h as default
|
|
183
183
|
};
|
|
184
184
|
//# sourceMappingURL=use-create-imperative-handle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-create-imperative-handle.js","sources":["../../../../../src/features/worksheet/worksheet/hooks/use-create-imperative-handle.ts"],"sourcesContent":["import { useCallback, useImperativeHandle, type ForwardedRef } from 'react';\n\nimport useAudioPlayer from '../../../hooks/use-audio-player';\nimport { TEACHER_VALIDATION_AUDIO_LIST } from '../constants';\nimport { getQuestionMetadata, isConceptIntroWidget } from '../worksheet-helpers';\nimport {\n QUESTION_TAGS,\n QUESTIONS_RATING,\n type IWorksheetQuestion,\n type IWorksheetRef,\n type IWorksheetResponse,\n} from '../worksheet-types';\nimport { useWorksheetStore } from './use-worksheet-store';\n\ninterface IUseCreateImperativeHandle {\n (\n ref: ForwardedRef<IWorksheetRef>,\n options: {\n getTimeSpentOnQuestion: (questionId: string) => number;\n },\n ): void;\n}\n\nconst useCreateImperativeHandle: IUseCreateImperativeHandle = (ref, { getTimeSpentOnQuestion }) => {\n const { onResponseChange, onBulkResponsesChange, behavior, questions, setResponses } =\n useWorksheetStore(store => ({\n onResponseChange: store.onResponseChange,\n onBulkResponsesChange: store.onBulkResponsesChange,\n behavior: store.behavior,\n questions: store.questions,\n setResponses: store.setResponses,\n }));\n const { navigationMode } = behavior;\n const playNotifSound = useAudioPlayer(TEACHER_VALIDATION_AUDIO_LIST);\n const validateQuestion = useCallback<IWorksheetRef['validateQuestion']>(\n (questionId, rating, skipRemainingQuestions) => {\n playNotifSound('VALIDATE');\n const timeSpentOnQuestion = getTimeSpentOnQuestion(questionId);\n\n setResponses(prevResponses => {\n const questionIndex = questions.findIndex(q => q.response_id === questionId);\n const question = questions[questionIndex]!;\n\n const newResponse = {\n ...getQuestionMetadata(questions, questionId),\n ...prevResponses[questionId],\n validatedByTeacher: true,\n rating: rating ? QUESTIONS_RATING[rating] : undefined,\n timeSpent: timeSpentOnQuestion,\n };\n\n if (navigationMode === 'ADAPTIVE') {\n if (prevResponses[questionId]?.validatedByTeacher) {\n return prevResponses;\n }\n\n const topicName = question.item_tags_map[QUESTION_TAGS.TRIAL_TOPIC];\n const questionCode = question.item_tags_map[QUESTION_TAGS.QUESTION_CODE];\n const nextQuestionCode =\n questionCode && questionCode.length < 3 ? `${questionCode}${rating}` : 'Q';\n const nextQuestionIndex = questions.findIndex((q, qIndex) => {\n if (qIndex <= questionIndex) return false;\n\n if (nextQuestionCode !== 'Q') {\n return (\n q.item_tags_map[QUESTION_TAGS.TRIAL_TOPIC] === topicName &&\n q.item_tags_map[QUESTION_TAGS.QUESTION_CODE] === nextQuestionCode\n );\n }\n\n return q.item_tags_map[QUESTION_TAGS.TRIAL_TOPIC] !== topicName;\n });\n\n const newResponses = {\n [questionId]: newResponse,\n ...questions.reduce(\n (acc, q, qIndex) => {\n if (qIndex <= questionIndex) return acc;\n\n if (nextQuestionIndex > -1 && qIndex >= nextQuestionIndex) return acc;\n\n acc[q.response_id] = {\n ...getQuestionMetadata(questions, q.response_id),\n ...prevResponses[q.response_id],\n assignStatus: 'skipped',\n };\n\n return acc;\n },\n {} as Record<string, IWorksheetResponse>,\n ),\n };\n const nextQuestionResponseId = questions[nextQuestionIndex]?.response_id;\n\n if (nextQuestionResponseId) {\n onBulkResponsesChange?.({\n ...newResponses,\n [nextQuestionResponseId]: {\n ...prevResponses[nextQuestionResponseId],\n ...getQuestionMetadata(questions, nextQuestionResponseId),\n assignStatus: undefined,\n },\n });\n } else {\n onBulkResponsesChange?.(newResponses);\n }\n\n return {\n ...prevResponses,\n ...newResponses,\n };\n }\n\n if (skipRemainingQuestions) {\n const { item_reference } = question;\n const newResponses = {\n [questionId]: newResponse,\n ...questions.reduce(\n (acc, q) => {\n if (\n q.response_id !== question.response_id &&\n q.item_reference === item_reference &&\n !prevResponses[q.response_id]?.validatedByTeacher\n ) {\n acc[q.response_id] = {\n ...getQuestionMetadata(questions, q.response_id),\n ...prevResponses[q.response_id],\n assignStatus: 'skipped',\n };\n }\n\n return acc;\n },\n {} as Record<string, IWorksheetResponse>,\n ),\n };\n\n onBulkResponsesChange?.({\n ...prevResponses,\n ...newResponses,\n });\n\n return {\n ...prevResponses,\n ...newResponses,\n };\n }\n\n if (navigationMode === 'CURRENT' && question.item_number === 0) {\n onBulkResponsesChange?.({\n ...prevResponses,\n [questionId]: newResponse,\n });\n } else {\n onResponseChange?.({\n responseId: questionId,\n response: newResponse,\n question,\n isNewAttempt: false,\n });\n }\n\n return {\n ...prevResponses,\n [questionId]: newResponse,\n };\n });\n },\n [\n getTimeSpentOnQuestion,\n navigationMode,\n onBulkResponsesChange,\n onResponseChange,\n playNotifSound,\n questions,\n setResponses,\n ],\n );\n\n const assignOptionalItems = useCallback<IWorksheetRef['assignOptionalItems']>(\n itemType => {\n setResponses(prevResponses => {\n const optionalQuestions = questions.filter(q =>\n itemType.startsWith('advanced-')\n ? q.item_type?.startsWith('advanced-')\n : q.item_type === itemType,\n );\n const assignedResponses: Record<string, IWorksheetResponse> = {};\n\n if (optionalQuestions.length > 0) {\n optionalQuestions.forEach(question => {\n assignedResponses[question.response_id] = {\n ...getQuestionMetadata(questions, question.response_id),\n ...prevResponses[question.response_id],\n assignStatus: 'assigned',\n };\n });\n\n onBulkResponsesChange?.(assignedResponses);\n\n return {\n ...prevResponses,\n ...assignedResponses,\n };\n }\n\n return prevResponses;\n });\n },\n [onBulkResponsesChange, questions, setResponses],\n );\n\n const skipOptionalItems = useCallback<IWorksheetRef['skipOptionalItems']>(\n itemType => {\n setResponses(prevResponses => {\n const optionalQuestions = questions.filter(q =>\n itemType.startsWith('advanced-')\n ? q.item_type?.startsWith('advanced-')\n : q.item_type === itemType,\n );\n const skippedResponses: Record<string, IWorksheetResponse> = {};\n const unskippedQuestions: IWorksheetQuestion[] = [];\n\n if (optionalQuestions.length > 0) {\n optionalQuestions.forEach(question => {\n const prevResponse = prevResponses[question.response_id];\n\n if (!prevResponse?.validatedByTeacher) {\n skippedResponses[question.response_id] = {\n ...getQuestionMetadata(questions, question.response_id),\n ...prevResponse,\n assignStatus: 'skipped',\n };\n } else {\n unskippedQuestions.push(question);\n }\n });\n\n const nonIntroUnskippedQuestionsPresent = unskippedQuestions.some(\n ({ instructor_stimulus }) =>\n !(instructor_stimulus === 'SystemIntro' || isConceptIntroWidget(instructor_stimulus)),\n );\n\n if (!nonIntroUnskippedQuestionsPresent) {\n unskippedQuestions.forEach(question => {\n skippedResponses[question.response_id] = {\n ...getQuestionMetadata(questions, question.response_id),\n ...prevResponses[question.response_id],\n assignStatus: 'skipped',\n };\n });\n }\n\n onBulkResponsesChange?.(skippedResponses);\n\n return {\n ...prevResponses,\n ...skippedResponses,\n };\n }\n\n return prevResponses;\n });\n },\n [onBulkResponsesChange, questions, setResponses],\n );\n\n const updateMediaState = useCallback<IWorksheetRef['updateMediaState']>(\n (responseId, mediaType, mediaState) => {\n const key = mediaType === 'SIMULATION' ? 'simState' : undefined;\n\n if (!key) return;\n\n setResponses(prevResponses => {\n const question = questions.find(q => q.response_id === responseId);\n\n if (!question) return prevResponses;\n\n const newResponse = {\n ...getQuestionMetadata(questions, responseId),\n ...prevResponses[responseId],\n [key]: mediaState,\n };\n\n return {\n ...prevResponses,\n [responseId]: newResponse,\n };\n });\n },\n [questions, setResponses],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n validateQuestion,\n assignOptionalItems,\n skipOptionalItems,\n updateMediaState,\n }),\n [assignOptionalItems, skipOptionalItems, updateMediaState, validateQuestion],\n );\n};\n\nexport default useCreateImperativeHandle;\n"],"names":["useCreateImperativeHandle","ref","getTimeSpentOnQuestion","onResponseChange","onBulkResponsesChange","behavior","questions","setResponses","useWorksheetStore","store","navigationMode","playNotifSound","useAudioPlayer","TEACHER_VALIDATION_AUDIO_LIST","validateQuestion","useCallback","questionId","rating","skipRemainingQuestions","timeSpentOnQuestion","prevResponses","questionIndex","q","question","newResponse","getQuestionMetadata","QUESTIONS_RATING","_a","topicName","QUESTION_TAGS","questionCode","nextQuestionCode","nextQuestionIndex","qIndex","newResponses","acc","nextQuestionResponseId","_b","item_reference","assignOptionalItems","itemType","optionalQuestions","assignedResponses","skipOptionalItems","skippedResponses","unskippedQuestions","prevResponse","instructor_stimulus","isConceptIntroWidget","updateMediaState","responseId","mediaType","mediaState","key","useImperativeHandle"],"mappings":";;;;;;AAuBA,MAAMA,IAAwD,CAACC,GAAK,EAAE,wBAAAC,QAA6B;AAC3F,QAAA,EAAE,kBAAAC,GAAkB,uBAAAC,GAAuB,UAAAC,GAAU,WAAAC,GAAW,cAAAC,EAAa,IACjFC,EAAkB,CAAUC,OAAA;AAAA,IAC1B,kBAAkBA,EAAM;AAAA,IACxB,uBAAuBA,EAAM;AAAA,IAC7B,UAAUA,EAAM;AAAA,IAChB,WAAWA,EAAM;AAAA,IACjB,cAAcA,EAAM;AAAA,EACpB,EAAA,GACE,EAAE,gBAAAC,EAAmB,IAA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CAAU;AAAA,UAC5C,GAAG9B,EAAc8B,CAAU;AAAA,UAC3B,CAACG,CAAG,GAAGD;AAAA,QAAA;AAGF,eAAA;AAAA,UACL,GAAGhC;AAAA,UACH,CAAC8B,CAAU,GAAG1B;AAAA,QAAA;AAAA,MAChB,CACD;AAAA,IACH;AAAA,IACA,CAAClB,GAAWC,CAAY;AAAA,EAAA;AAG1B,EAAA+C;AAAA,IACErD;AAAA,IACA,OAAO;AAAA,MACL,kBAAAa;AAAA,MACA,qBAAAyB;AAAA,MACA,mBAAAI;AAAA,MACA,kBAAAM;AAAA,IAAA;AAAA,IAEF,CAACV,GAAqBI,GAAmBM,GAAkBnC,CAAgB;AAAA,EAAA;AAE/E;"}
|
|
1
|
+
{"version":3,"file":"use-create-imperative-handle.js","sources":["../../../../../src/features/worksheet/worksheet/hooks/use-create-imperative-handle.ts"],"sourcesContent":["import {\n useCallback,\n useImperativeHandle,\n type Dispatch,\n type ForwardedRef,\n type SetStateAction,\n} from 'react';\n\nimport useAudioPlayer from '../../../hooks/use-audio-player';\nimport { TEACHER_VALIDATION_AUDIO_LIST } from '../constants';\nimport { getQuestionMetadata, isConceptIntroWidget } from '../worksheet-helpers';\nimport {\n QUESTION_TAGS,\n QUESTIONS_RATING,\n type IWorksheetBehavior,\n type IWorksheetProps,\n type IWorksheetQuestion,\n type IWorksheetRef,\n type IWorksheetResponse,\n} from '../worksheet-types';\n\ninterface IUseCreateImperativeHandle {\n (\n ref: ForwardedRef<IWorksheetRef>,\n options: {\n behavior: IWorksheetBehavior;\n questions: IWorksheetQuestion[];\n setResponses: Dispatch<SetStateAction<Record<string, IWorksheetResponse>>>;\n onResponseChange: IWorksheetProps['onResponseChange'];\n onBulkResponsesChange: IWorksheetProps['onBulkResponsesChange'];\n getTimeSpentOnQuestion: (questionId: string) => number;\n },\n ): void;\n}\n\nconst useCreateImperativeHandle: IUseCreateImperativeHandle = (\n ref,\n {\n behavior,\n questions,\n setResponses,\n onResponseChange,\n onBulkResponsesChange,\n getTimeSpentOnQuestion,\n },\n) => {\n const { navigationMode } = behavior;\n const playNotifSound = useAudioPlayer(TEACHER_VALIDATION_AUDIO_LIST);\n const validateQuestion = useCallback<IWorksheetRef['validateQuestion']>(\n (questionId, rating, skipRemainingQuestions) => {\n playNotifSound('VALIDATE');\n const timeSpentOnQuestion = getTimeSpentOnQuestion(questionId);\n\n setResponses(prevResponses => {\n const questionIndex = questions.findIndex(q => q.response_id === questionId);\n const question = questions[questionIndex]!;\n\n const newResponse = {\n ...getQuestionMetadata(questions, questionId),\n ...prevResponses[questionId],\n validatedByTeacher: true,\n rating: rating ? QUESTIONS_RATING[rating] : undefined,\n timeSpent: timeSpentOnQuestion,\n };\n\n if (navigationMode === 'ADAPTIVE') {\n if (prevResponses[questionId]?.validatedByTeacher) {\n return prevResponses;\n }\n\n const topicName = question.item_tags_map[QUESTION_TAGS.TRIAL_TOPIC];\n const questionCode = question.item_tags_map[QUESTION_TAGS.QUESTION_CODE];\n const nextQuestionCode =\n questionCode && questionCode.length < 3 ? `${questionCode}${rating}` : 'Q';\n const nextQuestionIndex = questions.findIndex((q, qIndex) => {\n if (qIndex <= questionIndex) return false;\n\n if (nextQuestionCode !== 'Q') {\n return (\n q.item_tags_map[QUESTION_TAGS.TRIAL_TOPIC] === topicName &&\n q.item_tags_map[QUESTION_TAGS.QUESTION_CODE] === nextQuestionCode\n );\n }\n\n return q.item_tags_map[QUESTION_TAGS.TRIAL_TOPIC] !== topicName;\n });\n\n const newResponses = {\n [questionId]: newResponse,\n ...questions.reduce(\n (acc, q, qIndex) => {\n if (qIndex <= questionIndex) return acc;\n\n if (nextQuestionIndex > -1 && qIndex >= nextQuestionIndex) return acc;\n\n acc[q.response_id] = {\n ...getQuestionMetadata(questions, q.response_id),\n ...prevResponses[q.response_id],\n assignStatus: 'skipped',\n };\n\n return acc;\n },\n {} as Record<string, IWorksheetResponse>,\n ),\n };\n const nextQuestionResponseId = questions[nextQuestionIndex]?.response_id;\n\n if (nextQuestionResponseId) {\n onBulkResponsesChange?.({\n ...newResponses,\n [nextQuestionResponseId]: {\n ...prevResponses[nextQuestionResponseId],\n ...getQuestionMetadata(questions, nextQuestionResponseId),\n assignStatus: undefined,\n },\n });\n } else {\n onBulkResponsesChange?.(newResponses);\n }\n\n return {\n ...prevResponses,\n ...newResponses,\n };\n }\n\n if (skipRemainingQuestions) {\n const { item_reference } = question;\n const newResponses = {\n [questionId]: newResponse,\n ...questions.reduce(\n (acc, q) => {\n if (\n q.response_id !== question.response_id &&\n q.item_reference === item_reference &&\n !prevResponses[q.response_id]?.validatedByTeacher\n ) {\n acc[q.response_id] = {\n ...getQuestionMetadata(questions, q.response_id),\n ...prevResponses[q.response_id],\n assignStatus: 'skipped',\n };\n }\n\n return acc;\n },\n {} as Record<string, IWorksheetResponse>,\n ),\n };\n\n onBulkResponsesChange?.({\n ...prevResponses,\n ...newResponses,\n });\n\n return {\n ...prevResponses,\n ...newResponses,\n };\n }\n\n if (navigationMode === 'CURRENT' && question.item_number === 0) {\n onBulkResponsesChange?.({\n ...prevResponses,\n [questionId]: newResponse,\n });\n } else {\n onResponseChange?.({\n responseId: questionId,\n response: newResponse,\n question,\n isNewAttempt: false,\n });\n }\n\n return {\n ...prevResponses,\n [questionId]: newResponse,\n };\n });\n },\n [\n getTimeSpentOnQuestion,\n navigationMode,\n onBulkResponsesChange,\n onResponseChange,\n playNotifSound,\n questions,\n setResponses,\n ],\n );\n\n const assignOptionalItems = useCallback<IWorksheetRef['assignOptionalItems']>(\n itemType => {\n setResponses(prevResponses => {\n const optionalQuestions = questions.filter(q =>\n itemType.startsWith('advanced-')\n ? q.item_type?.startsWith('advanced-')\n : q.item_type === itemType,\n );\n const assignedResponses: Record<string, IWorksheetResponse> = {};\n\n if (optionalQuestions.length > 0) {\n optionalQuestions.forEach(question => {\n assignedResponses[question.response_id] = {\n ...getQuestionMetadata(questions, question.response_id),\n ...prevResponses[question.response_id],\n assignStatus: 'assigned',\n };\n });\n\n onBulkResponsesChange?.(assignedResponses);\n\n return {\n ...prevResponses,\n ...assignedResponses,\n };\n }\n\n return prevResponses;\n });\n },\n [onBulkResponsesChange, questions, setResponses],\n );\n\n const skipOptionalItems = useCallback<IWorksheetRef['skipOptionalItems']>(\n itemType => {\n setResponses(prevResponses => {\n const optionalQuestions = questions.filter(q =>\n itemType.startsWith('advanced-')\n ? q.item_type?.startsWith('advanced-')\n : q.item_type === itemType,\n );\n const skippedResponses: Record<string, IWorksheetResponse> = {};\n const unskippedQuestions: IWorksheetQuestion[] = [];\n\n if (optionalQuestions.length > 0) {\n optionalQuestions.forEach(question => {\n const prevResponse = prevResponses[question.response_id];\n\n if (!prevResponse?.validatedByTeacher) {\n skippedResponses[question.response_id] = {\n ...getQuestionMetadata(questions, question.response_id),\n ...prevResponse,\n assignStatus: 'skipped',\n };\n } else {\n unskippedQuestions.push(question);\n }\n });\n\n const nonIntroUnskippedQuestionsPresent = unskippedQuestions.some(\n ({ instructor_stimulus }) =>\n !(instructor_stimulus === 'SystemIntro' || isConceptIntroWidget(instructor_stimulus)),\n );\n\n if (!nonIntroUnskippedQuestionsPresent) {\n unskippedQuestions.forEach(question => {\n skippedResponses[question.response_id] = {\n ...getQuestionMetadata(questions, question.response_id),\n ...prevResponses[question.response_id],\n assignStatus: 'skipped',\n };\n });\n }\n\n onBulkResponsesChange?.(skippedResponses);\n\n return {\n ...prevResponses,\n ...skippedResponses,\n };\n }\n\n return prevResponses;\n });\n },\n [onBulkResponsesChange, questions, setResponses],\n );\n\n const updateMediaState = useCallback<IWorksheetRef['updateMediaState']>(\n (responseId, mediaType, mediaState) => {\n const key = mediaType === 'SIMULATION' ? 'simState' : undefined;\n\n if (!key) return;\n\n setResponses(prevResponses => {\n const question = questions.find(q => q.response_id === responseId);\n\n if (!question) return prevResponses;\n\n const newResponse = {\n ...getQuestionMetadata(questions, responseId),\n ...prevResponses[responseId],\n [key]: mediaState,\n };\n\n return {\n ...prevResponses,\n [responseId]: newResponse,\n };\n });\n },\n [questions, setResponses],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n validateQuestion,\n assignOptionalItems,\n skipOptionalItems,\n updateMediaState,\n }),\n [assignOptionalItems, skipOptionalItems, updateMediaState, validateQuestion],\n );\n};\n\nexport default useCreateImperativeHandle;\n"],"names":["useCreateImperativeHandle","ref","behavior","questions","setResponses","onResponseChange","onBulkResponsesChange","getTimeSpentOnQuestion","navigationMode","playNotifSound","useAudioPlayer","TEACHER_VALIDATION_AUDIO_LIST","validateQuestion","useCallback","questionId","rating","skipRemainingQuestions","timeSpentOnQuestion","prevResponses","questionIndex","q","question","newResponse","getQuestionMetadata","QUESTIONS_RATING","_a","topicName","QUESTION_TAGS","questionCode","nextQuestionCode","nextQuestionIndex","qIndex","newResponses","acc","nextQuestionResponseId","_b","item_reference","assignOptionalItems","itemType","optionalQuestions","assignedResponses","skipOptionalItems","skippedResponses","unskippedQuestions","prevResponse","instructor_stimulus","isConceptIntroWidget","updateMediaState","responseId","mediaType","mediaState","key","useImperativeHandle"],"mappings":";;;;;AAmCM,MAAAA,IAAwD,CAC5DC,GACA;AAAA,EACE,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,wBAAAC;AACF,MACG;AACG,QAAA,EAAE,gBAAAC,EAAmB,IAAAN,GACrBO,IAAiBC,EAAeC,CAA6B,GAC7DC,IAAmBC;AAAA,IACvB,CAACC,GAAYC,GAAQC,MAA2B;AAC9C,MAAAP,EAAe,UAAU;AACnB,YAAAQ,IAAsBV,EAAuBO,CAAU;AAE7D,MAAAV,EAAa,CAAiBc,MAAA;;AAC5B,cAAMC,IAAgBhB,EAAU,UAAU,CAAKiB,MAAAA,EAAE,gBAAgBN,CAAU,GACrEO,IAAWlB,EAAUgB,CAAa,GAElCG,IAAc;AAAA,UAClB,GAAGC,EAAoBpB,GAAWW,CAAU;AAAA,UAC5C,GAAGI,EAAcJ,CAAU;AAAA,UAC3B,oBAAoB;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C,CAAgB;AAAA,EAAA;AAE/E;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import O from "../../../../node_modules/lodash.debounce/index.js";
|
|
2
|
+
import { useState as m, useMemo as f, useRef as A, useEffect as H } from "react";
|
|
3
|
+
import { INTERSECTION_OBSERVER_THROTTLE_TIME as _, TOP_NAVIGATION_HEIGHT as g, ACTION_BAR_HEIGHT as v, INTERSECTION_OBSERVER_THRESHOLD_POINTS as h } from "../constants.js";
|
|
4
|
+
const N = () => {
|
|
5
|
+
const o = [];
|
|
6
|
+
for (let i = 0; i <= h; i++)
|
|
7
|
+
o.push(i / h);
|
|
8
|
+
return o;
|
|
9
|
+
}, S = N(), Q = (o) => {
|
|
10
|
+
const [i, d] = m(o), s = f(
|
|
11
|
+
() => O(d, _, {
|
|
12
|
+
trailing: !0
|
|
13
|
+
}),
|
|
14
|
+
[]
|
|
15
|
+
), t = A(void 0), u = f(
|
|
16
|
+
() => new IntersectionObserver(
|
|
17
|
+
(a) => {
|
|
18
|
+
const l = a.reduce((e, { isIntersecting: c, target: n }) => Math.max(e, c ? n.clientHeight : e), 0), [r, E, p] = a.reduce(
|
|
19
|
+
(e, { isIntersecting: c, target: n, intersectionRatio: I }) => {
|
|
20
|
+
var R;
|
|
21
|
+
if (n.getAttribute("data-response-id") === ((R = t.current) == null ? void 0 : R.questionEl.getAttribute("data-response-id")) && (t.current = void 0), c) {
|
|
22
|
+
const T = n.clientHeight / l * I;
|
|
23
|
+
if (T >= e[2])
|
|
24
|
+
return [n, I, T];
|
|
25
|
+
}
|
|
26
|
+
return e;
|
|
27
|
+
},
|
|
28
|
+
[null, 0, 0]
|
|
29
|
+
);
|
|
30
|
+
if (r)
|
|
31
|
+
if (!t.current)
|
|
32
|
+
t.current = {
|
|
33
|
+
questionEl: r,
|
|
34
|
+
intersectionRatio: E
|
|
35
|
+
}, s(r.getAttribute("data-response-id") ?? "");
|
|
36
|
+
else {
|
|
37
|
+
const e = t.current.questionEl.clientHeight / l * t.current.intersectionRatio;
|
|
38
|
+
p >= e && (t.current = {
|
|
39
|
+
questionEl: r,
|
|
40
|
+
intersectionRatio: E
|
|
41
|
+
}, s(r.getAttribute("data-response-id") ?? ""));
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
rootMargin: `-${g}px 0px -${v}px 0px`,
|
|
46
|
+
threshold: S
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
[s]
|
|
50
|
+
);
|
|
51
|
+
return H(() => () => {
|
|
52
|
+
u.disconnect();
|
|
53
|
+
}, [u]), {
|
|
54
|
+
intersectionObserver: u,
|
|
55
|
+
activeQuestionId: i,
|
|
56
|
+
setActiveQuestionId: d
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
Q as default
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=use-get-active-question-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-get-active-question-id.js","sources":["../../../../../src/features/worksheet/worksheet/hooks/use-get-active-question-id.ts"],"sourcesContent":["import debounce from 'lodash.debounce';\nimport { useEffect, useMemo, useRef, useState } from 'react';\n\nimport {\n ACTION_BAR_HEIGHT,\n INTERSECTION_OBSERVER_THRESHOLD_POINTS,\n INTERSECTION_OBSERVER_THROTTLE_TIME,\n TOP_NAVIGATION_HEIGHT,\n} from '../constants';\n\ninterface IUseGetActiveQuestionId {\n (initialQuestionId: string): {\n activeQuestionId?: string;\n setActiveQuestionId: (activeQuestionId: string) => void;\n intersectionObserver: IntersectionObserver;\n };\n}\n\nconst getThresholds = () => {\n const thresholds = [];\n\n for (let i = 0; i <= INTERSECTION_OBSERVER_THRESHOLD_POINTS; i++) {\n thresholds.push(i / INTERSECTION_OBSERVER_THRESHOLD_POINTS);\n }\n\n return thresholds;\n};\n\nconst thresholds = getThresholds();\n\n/**\n * Returns the question's response id which is currently in view with the highest intersection ratio\n * @returns activeQuestionId\n */\nconst useGetActiveQuestionId: IUseGetActiveQuestionId = initialQuestionId => {\n const [activeQuestionId, setActiveQuestionId] = useState<string>(initialQuestionId);\n const throttledSetActiveQuestionId = useMemo(\n () =>\n debounce(setActiveQuestionId, INTERSECTION_OBSERVER_THROTTLE_TIME, {\n trailing: true,\n }),\n [],\n );\n const activeQuestionRef = useRef<{\n questionEl: Element;\n intersectionRatio: number;\n }>(undefined);\n const intersectionObserver = useMemo(\n () =>\n new IntersectionObserver(\n entries => {\n const maxHeight = entries.reduce((acc, { isIntersecting, target }) => {\n return Math.max(acc, isIntersecting ? target.clientHeight : acc);\n }, 0);\n const [questionEl, questionIntersectionRatio, questionNormalisedRatio] = entries.reduce(\n (acc, { isIntersecting, target, intersectionRatio }) => {\n if (\n target.getAttribute('data-response-id') ===\n activeQuestionRef.current?.questionEl.getAttribute('data-response-id')\n ) {\n activeQuestionRef.current = undefined;\n }\n\n if (isIntersecting) {\n const normalisedRatio = (target.clientHeight / maxHeight) * intersectionRatio;\n\n if (normalisedRatio >= acc[2]) {\n return [target, intersectionRatio, normalisedRatio];\n }\n }\n\n return acc;\n },\n [null, 0, 0] as [Element | null, number, number],\n );\n\n if (questionEl) {\n if (!activeQuestionRef.current) {\n activeQuestionRef.current = {\n questionEl,\n intersectionRatio: questionIntersectionRatio,\n };\n throttledSetActiveQuestionId(questionEl.getAttribute('data-response-id') ?? '');\n } else {\n const nRatio =\n (activeQuestionRef.current.questionEl.clientHeight / maxHeight) *\n activeQuestionRef.current.intersectionRatio;\n\n if (questionNormalisedRatio >= nRatio) {\n activeQuestionRef.current = {\n questionEl,\n intersectionRatio: questionIntersectionRatio,\n };\n throttledSetActiveQuestionId(questionEl.getAttribute('data-response-id') ?? '');\n }\n }\n }\n },\n {\n rootMargin: `-${TOP_NAVIGATION_HEIGHT}px 0px -${ACTION_BAR_HEIGHT}px 0px`,\n threshold: thresholds,\n },\n ),\n [throttledSetActiveQuestionId],\n );\n\n useEffect(() => {\n return () => {\n intersectionObserver.disconnect();\n };\n }, [intersectionObserver]);\n\n return {\n intersectionObserver,\n activeQuestionId,\n setActiveQuestionId,\n };\n};\n\nexport default useGetActiveQuestionId;\n"],"names":["getThresholds","thresholds","INTERSECTION_OBSERVER_THRESHOLD_POINTS","useGetActiveQuestionId","initialQuestionId","activeQuestionId","setActiveQuestionId","useState","throttledSetActiveQuestionId","useMemo","debounce","INTERSECTION_OBSERVER_THROTTLE_TIME","activeQuestionRef","useRef","intersectionObserver","entries","maxHeight","acc","isIntersecting","target","questionEl","questionIntersectionRatio","questionNormalisedRatio","intersectionRatio","_a","normalisedRatio","nRatio","TOP_NAVIGATION_HEIGHT","ACTION_BAR_HEIGHT","useEffect"],"mappings":";;;AAkBA,MAAMA,IAAgB,MAAM;AAC1B,QAAMC,IAAa,CAAA;AAEnB,WAAS,IAAI,GAAG,KAAKC,GAAwC;AAC3DD,IAAAA,EAAW,KAAK,IAAIC,CAAsC;AAGrDD,SAAAA;AACT,GAEMA,IAAaD,EAAc,GAM3BG,IAAkD,CAAqBC,MAAA;AAC3E,QAAM,CAACC,GAAkBC,CAAmB,IAAIC,EAAiBH,CAAiB,GAC5EI,IAA+BC;AAAA,IACnC,MACEC,EAASJ,GAAqBK,GAAqC;AAAA,MACjE,UAAU;AAAA,IAAA,CACX;AAAA,IACH,CAAC;AAAA,EAAA,GAEGC,IAAoBC,EAGvB,MAAS,GACNC,IAAuBL;AAAA,IAC3B,MACE,IAAI;AAAA,MACF,CAAWM,MAAA;AACH,cAAAC,IAAYD,EAAQ,OAAO,CAACE,GAAK,EAAE,gBAAAC,GAAgB,QAAAC,QAChD,KAAK,IAAIF,GAAKC,IAAiBC,EAAO,eAAeF,CAAG,GAC9D,CAAC,GACE,CAACG,GAAYC,GAA2BC,CAAuB,IAAIP,EAAQ;AAAA,UAC/E,CAACE,GAAK,EAAE,gBAAAC,GAAgB,QAAAC,GAAQ,mBAAAI,QAAwB;;AAQtD,gBANEJ,EAAO,aAAa,kBAAkB,QACtCK,IAAAZ,EAAkB,YAAlB,gBAAAY,EAA2B,WAAW,aAAa,yBAEnDZ,EAAkB,UAAU,SAG1BM,GAAgB;AACZ,oBAAAO,IAAmBN,EAAO,eAAeH,IAAaO;AAExD,kBAAAE,KAAmBR,EAAI,CAAC;AACnB,uBAAA,CAACE,GAAQI,GAAmBE,CAAe;AAAA,YAEtD;AAEO,mBAAAR;AAAA,UACT;AAAA,UACA,CAAC,MAAM,GAAG,CAAC;AAAA,QAAA;AAGb,YAAIG;AACE,cAAA,CAACR,EAAkB;AACrB,YAAAA,EAAkB,UAAU;AAAA,cAC1B,YAAAQ;AAAA,cACA,mBAAmBC;AAAA,YAAA,GAErBb,EAA6BY,EAAW,aAAa,kBAAkB,KAAK,EAAE;AAAA,eACzE;AACL,kBAAMM,IACHd,EAAkB,QAAQ,WAAW,eAAeI,IACrDJ,EAAkB,QAAQ;AAE5B,YAAIU,KAA2BI,MAC7Bd,EAAkB,UAAU;AAAA,cAC1B,YAAAQ;AAAA,cACA,mBAAmBC;AAAA,YAAA,GAErBb,EAA6BY,EAAW,aAAa,kBAAkB,KAAK,EAAE;AAAA,UAElF;AAAA,MAEJ;AAAA,MACA;AAAA,QACE,YAAY,IAAIO,CAAqB,WAAWC,CAAiB;AAAA,QACjE,WAAW3B;AAAA,MACb;AAAA,IACF;AAAA,IACF,CAACO,CAA4B;AAAA,EAAA;AAG/B,SAAAqB,EAAU,MACD,MAAM;AACX,IAAAf,EAAqB,WAAW;AAAA,EAAA,GAEjC,CAACA,CAAoB,CAAC,GAElB;AAAA,IACL,sBAAAA;AAAA,IACA,kBAAAT;AAAA,IACA,qBAAAC;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,42 +1,37 @@
|
|
|
1
|
-
import { useRef as m, useCallback as
|
|
1
|
+
import { useRef as m, useCallback as l, useEffect as f } from "react";
|
|
2
2
|
import b from "../../../hooks/use-previous.js";
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
questionId: e.activeQuestionId
|
|
9
|
-
})), r = m(
|
|
10
|
-
Object.entries(l).reduce((e, [c, a]) => (e[c] = (a == null ? void 0 : a.timeSpent) ?? 0, e), {})
|
|
11
|
-
), u = m(n), t = m(Date.now()), o = b(n), { canAttempt: i } = v, d = p(
|
|
12
|
-
(e) => e !== u.current ? r.current[e] ?? 0 : e && t.current && i ? (r.current[e] ?? 0) + (Date.now() - t.current) : r.current[e] ?? 0,
|
|
3
|
+
const h = (p, v, n) => {
|
|
4
|
+
const r = m(
|
|
5
|
+
Object.entries(v).reduce((e, [s, a]) => (e[s] = (a == null ? void 0 : a.timeSpent) ?? 0, e), {})
|
|
6
|
+
), c = m(n), t = m(Date.now()), u = b(n), { canAttempt: i } = p, S = l(
|
|
7
|
+
(e) => e !== c.current ? r.current[e] ?? 0 : e && t.current && i ? (r.current[e] ?? 0) + (Date.now() - t.current) : r.current[e] ?? 0,
|
|
13
8
|
[i]
|
|
14
9
|
);
|
|
15
10
|
f(() => {
|
|
16
|
-
|
|
11
|
+
c.current = n;
|
|
17
12
|
}, [n]);
|
|
18
|
-
const
|
|
19
|
-
if (document.visibilityState === "hidden" && t.current &&
|
|
13
|
+
const o = l(() => {
|
|
14
|
+
if (document.visibilityState === "hidden" && t.current && c.current) {
|
|
20
15
|
const e = Date.now() - t.current;
|
|
21
|
-
r.current[
|
|
16
|
+
r.current[c.current] = (r.current[c.current] ?? 0) + e, t.current = null;
|
|
22
17
|
} else document.visibilityState === "visible" && !t.current && (t.current = Date.now());
|
|
23
18
|
}, []);
|
|
24
19
|
return f(() => {
|
|
25
20
|
if (i)
|
|
26
|
-
return document.addEventListener("visibilitychange",
|
|
27
|
-
document.removeEventListener("visibilitychange",
|
|
21
|
+
return document.addEventListener("visibilitychange", o), () => {
|
|
22
|
+
document.removeEventListener("visibilitychange", o);
|
|
28
23
|
};
|
|
29
|
-
}, [i,
|
|
30
|
-
if (!(!n || !i) &&
|
|
31
|
-
if (t.current &&
|
|
32
|
-
const e = r.current[
|
|
33
|
-
r.current[
|
|
24
|
+
}, [i, o]), f(() => {
|
|
25
|
+
if (!(!n || !i) && u !== n) {
|
|
26
|
+
if (t.current && u) {
|
|
27
|
+
const e = r.current[u] ?? 0, s = Date.now() - t.current;
|
|
28
|
+
r.current[u] = e + s;
|
|
34
29
|
}
|
|
35
30
|
t.current = Date.now();
|
|
36
31
|
}
|
|
37
|
-
}, [i,
|
|
32
|
+
}, [i, u, n]), S;
|
|
38
33
|
};
|
|
39
34
|
export {
|
|
40
|
-
|
|
35
|
+
h as default
|
|
41
36
|
};
|
|
42
37
|
//# sourceMappingURL=use-time-on-questions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-time-on-questions.js","sources":["../../../../../src/features/worksheet/worksheet/hooks/use-time-on-questions.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"use-time-on-questions.js","sources":["../../../../../src/features/worksheet/worksheet/hooks/use-time-on-questions.ts"],"sourcesContent":["import { useEffect, useRef, useCallback } from 'react';\n\nimport usePrevious from '../../../hooks/use-previous';\nimport type { IWorksheetBehavior, IWorksheetResponse } from '../worksheet-types';\n\nconst useTimeSpentOnQuestions = (\n behavior: IWorksheetBehavior,\n responses: Record<string, IWorksheetResponse>,\n questionId?: string,\n) => {\n const timeSpentRef = useRef<Record<string, number>>(\n Object.entries(responses).reduce((acc: Record<string, number>, [qId, res]) => {\n acc[qId] = res?.timeSpent ?? 0;\n\n return acc;\n }, {}),\n );\n const currentQuestionIdRef = useRef<string | undefined>(questionId);\n\n const startTimeRef = useRef<number | null>(Date.now());\n const previousQuestionId = usePrevious(questionId);\n\n const { canAttempt } = behavior;\n\n const getTimeSpentOnQuestion = useCallback(\n (qId: string) => {\n if (qId !== currentQuestionIdRef.current) {\n return timeSpentRef.current[qId] ?? 0;\n }\n\n if (qId && startTimeRef.current && canAttempt) {\n return (timeSpentRef.current[qId] ?? 0) + (Date.now() - startTimeRef.current);\n }\n\n return timeSpentRef.current[qId] ?? 0;\n },\n [canAttempt],\n );\n\n useEffect(() => {\n currentQuestionIdRef.current = questionId;\n }, [questionId]);\n\n const handleVisibilityChange = useCallback(() => {\n if (\n document.visibilityState === 'hidden' &&\n startTimeRef.current &&\n currentQuestionIdRef.current\n ) {\n const timeSpentInMs = Date.now() - startTimeRef.current;\n\n timeSpentRef.current[currentQuestionIdRef.current] =\n (timeSpentRef.current[currentQuestionIdRef.current] ?? 0) + timeSpentInMs;\n startTimeRef.current = null;\n } else if (document.visibilityState === 'visible' && !startTimeRef.current) {\n startTimeRef.current = Date.now();\n }\n }, []);\n\n useEffect(() => {\n if (!canAttempt) return;\n document.addEventListener('visibilitychange', handleVisibilityChange);\n\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange);\n };\n }, [canAttempt, handleVisibilityChange]);\n\n useEffect(() => {\n if (!questionId || !canAttempt) return;\n\n if (previousQuestionId !== questionId) {\n if (startTimeRef.current && previousQuestionId) {\n const prevTimeSpent = timeSpentRef.current[previousQuestionId] ?? 0;\n const timeSpentInMs = Date.now() - startTimeRef.current;\n\n timeSpentRef.current[previousQuestionId] = prevTimeSpent + timeSpentInMs;\n }\n startTimeRef.current = Date.now();\n }\n }, [canAttempt, previousQuestionId, questionId]);\n\n return getTimeSpentOnQuestion;\n};\n\nexport default useTimeSpentOnQuestions;\n"],"names":["useTimeSpentOnQuestions","behavior","responses","questionId","timeSpentRef","useRef","acc","qId","res","currentQuestionIdRef","startTimeRef","previousQuestionId","usePrevious","canAttempt","getTimeSpentOnQuestion","useCallback","useEffect","handleVisibilityChange","timeSpentInMs","prevTimeSpent"],"mappings":";;AAKA,MAAMA,IAA0B,CAC9BC,GACAC,GACAC,MACG;AACH,QAAMC,IAAeC;AAAA,IACnB,OAAO,QAAQH,CAAS,EAAE,OAAO,CAACI,GAA6B,CAACC,GAAKC,CAAG,OAClEF,EAAAC,CAAG,KAAIC,KAAA,gBAAAA,EAAK,cAAa,GAEtBF,IACN,EAAE;AAAA,EAAA,GAEDG,IAA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