@capytale/meta-player 0.8.2 → 0.8.3

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.
Files changed (105) hide show
  1. package/.prettierrc.json +4 -4
  2. package/LICENSE +674 -674
  3. package/README.md +12 -12
  4. package/eslint.config.js +28 -28
  5. package/index.html +15 -15
  6. package/package.json +60 -60
  7. package/public/themes/lara-dark-blue/theme.css +7015 -7015
  8. package/public/themes/lara-light-blue/theme.css +7005 -7005
  9. package/src/App.tsx +139 -139
  10. package/src/AppRedux.css +39 -39
  11. package/src/MetaPlayer.tsx +170 -170
  12. package/src/activityJs.ts +7 -7
  13. package/src/app/createAppSlice.ts +6 -6
  14. package/src/app/hooks.ts +12 -12
  15. package/src/app/store.ts +52 -52
  16. package/src/app.module.scss +80 -80
  17. package/src/demo.tsx +87 -87
  18. package/src/external/prime.ts +5 -5
  19. package/src/features/activityData/ExitWarning.ts +28 -28
  20. package/src/features/activityData/IsAntiCheatExitDetectionDisabledSetter.tsx +19 -19
  21. package/src/features/activityData/IsDirtySetter.tsx +17 -17
  22. package/src/features/activityData/MetaPlayerOptionsSetter.tsx +41 -41
  23. package/src/features/activityData/activityDataSlice.ts +256 -256
  24. package/src/features/activityData/activityJsData.ts +82 -82
  25. package/src/features/activityData/hooks.ts +34 -34
  26. package/src/features/activityData/metaPlayerOptions.ts +23 -23
  27. package/src/features/activityData/uiState.ts +20 -20
  28. package/src/features/activityJS/ActivityJSProvider.tsx +339 -339
  29. package/src/features/activityJS/AfterResetAction.tsx +23 -23
  30. package/src/features/activityJS/AfterSaveAction.tsx +23 -23
  31. package/src/features/activityJS/BeforeResetAction.tsx +23 -23
  32. package/src/features/activityJS/BeforeSaveAction.tsx +23 -23
  33. package/src/features/activityJS/Saver.tsx +167 -167
  34. package/src/features/activityJS/hooks.ts +85 -85
  35. package/src/features/activityJS/internal-hooks.ts +96 -96
  36. package/src/features/activityJS/saverSlice.ts +96 -96
  37. package/src/features/activitySettings/ActivitySettingsSetter.tsx +21 -21
  38. package/src/features/activitySettings/hooks.ts +12 -12
  39. package/src/features/activitySettings/index.tsx +43 -43
  40. package/src/features/activitySettings/store.ts +108 -108
  41. package/src/features/activitySettings/style.module.scss +8 -8
  42. package/src/features/activitySettings/types.ts +140 -140
  43. package/src/features/activitySettings/ui.tsx +299 -299
  44. package/src/features/functionalities/AttachedFilesFunctionality.ts +23 -23
  45. package/src/features/functionalities/PreviewDialog.tsx +83 -83
  46. package/src/features/functionalities/functionalitiesSlice.ts +98 -98
  47. package/src/features/functionalities/hooks.ts +70 -70
  48. package/src/features/layout/hooks.ts +7 -7
  49. package/src/features/layout/layoutSlice.ts +90 -90
  50. package/src/features/navbar/activity-info/index.tsx +54 -54
  51. package/src/features/navbar/activity-info/style.module.scss +38 -38
  52. package/src/features/navbar/activity-menu/ActivityQuickActions.tsx +57 -57
  53. package/src/features/navbar/activity-menu/index.tsx +154 -153
  54. package/src/features/navbar/activity-menu/style.module.scss +7 -7
  55. package/src/features/navbar/capytale-menu/CloneDialog.tsx +75 -75
  56. package/src/features/navbar/capytale-menu/Countdown.tsx +312 -312
  57. package/src/features/navbar/capytale-menu/CountdownAndSaveButton.tsx +115 -115
  58. package/src/features/navbar/capytale-menu/index.tsx +260 -260
  59. package/src/features/navbar/capytale-menu/style.module.scss +8 -8
  60. package/src/features/navbar/index.tsx +39 -39
  61. package/src/features/navbar/navbarSlice.ts +79 -79
  62. package/src/features/navbar/review-navbar/GradingNav.tsx +128 -128
  63. package/src/features/navbar/review-navbar/index.tsx +18 -18
  64. package/src/features/navbar/review-navbar/style.module.scss +22 -22
  65. package/src/features/navbar/sidebars/ActivitySidebarActions.tsx +57 -57
  66. package/src/features/navbar/sidebars/AttachedFilesSidebarContent.module.scss +43 -43
  67. package/src/features/navbar/sidebars/AttachedFilesSidebarContent.tsx +181 -181
  68. package/src/features/navbar/sidebars/SettingsSidebarContent.tsx +192 -192
  69. package/src/features/navbar/sidebars/style.module.scss +15 -15
  70. package/src/features/navbar/student-utils.ts +11 -11
  71. package/src/features/navbar/style.module.scss +65 -65
  72. package/src/features/pedago/InstructionsEditor.tsx +102 -102
  73. package/src/features/pedago/PdfEditor.tsx +91 -91
  74. package/src/features/pedago/PedagoCommands.tsx +353 -353
  75. package/src/features/pedago/SharedNotesEditor.tsx +144 -144
  76. package/src/features/pedago/index.tsx +207 -204
  77. package/src/features/pedago/style.module.scss +233 -233
  78. package/src/features/theming/ThemeSwitcher.tsx +51 -51
  79. package/src/features/theming/hooks.ts +6 -6
  80. package/src/features/theming/themingSlice.ts +93 -93
  81. package/src/features/toast.tsx +38 -38
  82. package/src/hooks/index.ts +16 -16
  83. package/src/index.css +132 -132
  84. package/src/index.ts +90 -90
  85. package/src/logo.svg +1 -1
  86. package/src/my_json_data.js +4146 -4146
  87. package/src/settings.ts +6 -6
  88. package/src/types.ts +9 -9
  89. package/src/utils/ButtonDoubleIcon.tsx +35 -35
  90. package/src/utils/CardSelector.tsx +41 -41
  91. package/src/utils/ErrorBoundary.tsx +41 -41
  92. package/src/utils/PopupButton.tsx +134 -134
  93. package/src/utils/activity.ts +8 -8
  94. package/src/utils/breakpoints.ts +4 -4
  95. package/src/utils/capytale.ts +10 -10
  96. package/src/utils/clipboard.ts +11 -11
  97. package/src/utils/download.ts +7 -7
  98. package/src/utils/equality.ts +32 -32
  99. package/src/utils/server-clock.ts +42 -42
  100. package/src/utils/style.module.scss +45 -45
  101. package/src/utils/useFullscreen.ts +65 -65
  102. package/src/vite-env.d.ts +1 -1
  103. package/tsconfig.json +28 -28
  104. package/tsconfig.node.json +9 -9
  105. package/vite.config.ts +11 -11
@@ -1,153 +1,154 @@
1
- import { useMemo, useState } from "react";
2
- import styles from "./style.module.scss";
3
-
4
- import { Button } from "primereact/button";
5
- import { Sidebar } from "primereact/sidebar";
6
- import SettingsSidebarContent from "../sidebars/SettingsSidebarContent";
7
- import settings from "../../../settings";
8
- import ActivityQuickActions from "./ActivityQuickActions";
9
- import useFullscreen from "../../../utils/useFullscreen";
10
- import { useActivityJS } from "../../activityJS/ActivityJSProvider";
11
- import { Dialog } from "primereact/dialog";
12
- import capytaleUI from "@capytale/activity.js/backend/capytale/ui";
13
- import { useAppSelector } from "../../../app/hooks";
14
- import { selectHasAntiCheat } from "../../activityData/activityDataSlice";
15
- import AttachedFilesSidebarContent from "../sidebars/AttachedFilesSidebarContent";
16
- import { Badge } from "primereact/badge";
17
- import { useAttachedFiles } from "../../functionalities/hooks";
18
- import {
19
- selectAttachedFilesEnabled,
20
- selectAttachedFilesOptions,
21
- } from "../../functionalities/functionalitiesSlice";
22
-
23
- const ActivityMenu: React.FC = () => {
24
- const [settingsSidebarVisible, setSettingsSidebarVisible] = useState(false);
25
- const [attachedFilesSidebarVisible, setAttachedFilesSidebarVisible] =
26
- useState(false);
27
- const [wantFullscreen, setWantFullscreen] = useState(false);
28
- const isFullscreen = useFullscreen(wantFullscreen, () =>
29
- setWantFullscreen(false),
30
- );
31
- const isInIframe = useMemo(() => capytaleUI.isInCapytaletIframe(), []);
32
- const [helpDialogVisible, setHelpDialogVisible] = useState(false);
33
- const activityJS = useActivityJS();
34
- const hasAntiCheat = useAppSelector(selectHasAntiCheat);
35
- const attachedFiles = useAttachedFiles(); // causes a bug for now - TODO: debug
36
- const attachedFilesEnabled = useAppSelector(selectAttachedFilesEnabled);
37
- const attachedFilesOptions = useAppSelector(selectAttachedFilesOptions);
38
- return (
39
- <div className={styles.activityMenu}>
40
- <ActivityQuickActions />
41
- {attachedFilesEnabled && (
42
- <Button
43
- aria-label="Afficher les fichiers joints"
44
- severity="secondary"
45
- size="small"
46
- icon={
47
- <i className="pi pi-paperclip p-overlay-badge">
48
- {attachedFiles.length > 0 && (
49
- <Badge value={attachedFiles.length}></Badge>
50
- )}
51
- </i>
52
- }
53
- outlined
54
- tooltip="Fichiers joints"
55
- tooltipOptions={{
56
- position: "left",
57
- showDelay: settings.TOOLTIP_SHOW_DELAY,
58
- }}
59
- className="p-overlay-badge"
60
- onClick={() => {
61
- attachedFilesOptions.onViewFiles?.();
62
- setAttachedFilesSidebarVisible(true);
63
- }}
64
- />
65
- )}
66
- <Button
67
- aria-label="Afficher les paramètres"
68
- severity="secondary"
69
- size="small"
70
- icon="pi pi-cog" // pi-ellipsis-v
71
- outlined
72
- tooltip="Paramètres"
73
- tooltipOptions={{
74
- position: "left",
75
- showDelay: settings.TOOLTIP_SHOW_DELAY,
76
- }}
77
- onClick={() => setSettingsSidebarVisible(true)}
78
- />
79
- {!hasAntiCheat && (
80
- <Button
81
- aria-label="Mettre en plein écran"
82
- severity="secondary"
83
- size="small"
84
- icon={isFullscreen ? "pi pi-expand" : "pi pi-expand"}
85
- text
86
- tooltip="Plein écran"
87
- tooltipOptions={{
88
- position: "left",
89
- showDelay: settings.TOOLTIP_SHOW_DELAY,
90
- }}
91
- onClick={() => setWantFullscreen((prev) => !prev)}
92
- />
93
- )}
94
- {isInIframe && (
95
- <Button
96
- aria-label="Retour à la liste des activités (droite)"
97
- severity="secondary"
98
- size="small"
99
- icon={"pi pi-times"}
100
- text
101
- tooltip="Retour à la liste des activités"
102
- tooltipOptions={{
103
- position: "left",
104
- showDelay: settings.TOOLTIP_SHOW_DELAY,
105
- }}
106
- onClick={() => capytaleUI.closeCapytaleIframe()}
107
- />
108
- )}
109
- <Sidebar
110
- header="Paramètres"
111
- visible={settingsSidebarVisible}
112
- position="right"
113
- onHide={() => setSettingsSidebarVisible(false)}
114
- >
115
- <SettingsSidebarContent
116
- showHelp={
117
- activityJS.activitySession?.type.helpUrl
118
- ? () => {
119
- setHelpDialogVisible(true);
120
- setSettingsSidebarVisible(false);
121
- }
122
- : undefined
123
- }
124
- />
125
- </Sidebar>
126
- <Sidebar
127
- header="Fichiers joints"
128
- visible={attachedFilesSidebarVisible}
129
- position="right"
130
- onHide={() => setAttachedFilesSidebarVisible(false)}
131
- >
132
- <AttachedFilesSidebarContent />
133
- </Sidebar>
134
- {activityJS.activitySession?.type.helpUrl && (
135
- <Dialog
136
- id="metaPlayerHelpDialog"
137
- header="Documentation"
138
- visible={helpDialogVisible}
139
- onHide={() => setHelpDialogVisible(false)}
140
- maximizable={true}
141
- >
142
- <iframe
143
- src={activityJS.activitySession?.type.helpUrl}
144
- style={{ width: "100%", height: "100%" }}
145
- title="Documentation"
146
- />
147
- </Dialog>
148
- )}
149
- </div>
150
- );
151
- };
152
-
153
- export default ActivityMenu;
1
+ import { useMemo, useState } from "react";
2
+ import styles from "./style.module.scss";
3
+
4
+ import { Button } from "primereact/button";
5
+ import { Sidebar } from "primereact/sidebar";
6
+ import SettingsSidebarContent from "../sidebars/SettingsSidebarContent";
7
+ import settings from "../../../settings";
8
+ import ActivityQuickActions from "./ActivityQuickActions";
9
+ import useFullscreen from "../../../utils/useFullscreen";
10
+ import { useActivityJS } from "../../activityJS/ActivityJSProvider";
11
+ import { Dialog } from "primereact/dialog";
12
+ import capytaleUI from "@capytale/activity.js/backend/capytale/ui";
13
+ import { useAppSelector } from "../../../app/hooks";
14
+ import { selectHasAntiCheat } from "../../activityData/activityDataSlice";
15
+ import AttachedFilesSidebarContent from "../sidebars/AttachedFilesSidebarContent";
16
+ import { Badge } from "primereact/badge";
17
+ import { useAttachedFiles } from "../../functionalities/hooks";
18
+ import {
19
+ selectAttachedFilesEnabled,
20
+ selectAttachedFilesOptions,
21
+ } from "../../functionalities/functionalitiesSlice";
22
+
23
+ const ActivityMenu: React.FC = () => {
24
+ const [settingsSidebarVisible, setSettingsSidebarVisible] = useState(false);
25
+ const [attachedFilesSidebarVisible, setAttachedFilesSidebarVisible] =
26
+ useState(false);
27
+ const [wantFullscreen, setWantFullscreen] = useState(false);
28
+ const isFullscreen = useFullscreen(wantFullscreen, () =>
29
+ setWantFullscreen(false),
30
+ );
31
+ const isInIframe = useMemo(() => capytaleUI.isInCapytaletIframe(), []);
32
+ const [helpDialogVisible, setHelpDialogVisible] = useState(false);
33
+ const activityJS = useActivityJS();
34
+ const hasAntiCheat = useAppSelector(selectHasAntiCheat);
35
+ const attachedFiles = useAttachedFiles(); // causes a bug for now - TODO: debug
36
+ const attachedFilesEnabled = useAppSelector(selectAttachedFilesEnabled);
37
+ const attachedFilesOptions = useAppSelector(selectAttachedFilesOptions);
38
+ return (
39
+ <div className={styles.activityMenu}>
40
+ <ActivityQuickActions />
41
+ {attachedFilesEnabled && (
42
+ <Button
43
+ aria-label="Afficher les fichiers joints"
44
+ severity="secondary"
45
+ size="small"
46
+ icon={
47
+ <i className="pi pi-paperclip p-overlay-badge">
48
+ {attachedFiles.length > 0 && (
49
+ <Badge value={attachedFiles.length}></Badge>
50
+ )}
51
+ </i>
52
+ }
53
+ outlined
54
+ tooltip="Fichiers joints"
55
+ tooltipOptions={{
56
+ position: "left",
57
+ showDelay: settings.TOOLTIP_SHOW_DELAY,
58
+ }}
59
+ className="p-overlay-badge"
60
+ onClick={() => {
61
+ attachedFilesOptions.onViewFiles?.();
62
+ setAttachedFilesSidebarVisible(true);
63
+ }}
64
+ />
65
+ )}
66
+ <Button
67
+ aria-label="Afficher les paramètres"
68
+ severity="secondary"
69
+ size="small"
70
+ icon="pi pi-cog" // pi-ellipsis-v
71
+ outlined
72
+ tooltip="Paramètres"
73
+ tooltipOptions={{
74
+ position: "left",
75
+ showDelay: settings.TOOLTIP_SHOW_DELAY,
76
+ }}
77
+ onClick={() => setSettingsSidebarVisible(true)}
78
+ />
79
+ {!hasAntiCheat && (
80
+ <Button
81
+ aria-label="Mettre en plein écran"
82
+ severity="secondary"
83
+ size="small"
84
+ icon={isFullscreen ? "pi pi-expand" : "pi pi-expand"}
85
+ text
86
+ tooltip="Plein écran"
87
+ tooltipOptions={{
88
+ position: "left",
89
+ showDelay: settings.TOOLTIP_SHOW_DELAY,
90
+ }}
91
+ onClick={() => setWantFullscreen((prev) => !prev)}
92
+ />
93
+ )}
94
+ {isInIframe && (
95
+ <Button
96
+ aria-label="Retour à la liste des activités (droite)"
97
+ severity="secondary"
98
+ size="small"
99
+ icon={"pi pi-times"}
100
+ text
101
+ tooltip="Retour à la liste des activités"
102
+ tooltipOptions={{
103
+ position: "left",
104
+ showDelay: settings.TOOLTIP_SHOW_DELAY,
105
+ }}
106
+ onClick={() => capytaleUI.closeCapytaleIframe()}
107
+ />
108
+ )}
109
+ <Sidebar
110
+ header="Paramètres"
111
+ visible={settingsSidebarVisible}
112
+ position="right"
113
+ onHide={() => setSettingsSidebarVisible(false)}
114
+ style={{ width: "24rem", maxWidth: "100%" }}
115
+ >
116
+ <SettingsSidebarContent
117
+ showHelp={
118
+ activityJS.activitySession?.type.helpUrl
119
+ ? () => {
120
+ setHelpDialogVisible(true);
121
+ setSettingsSidebarVisible(false);
122
+ }
123
+ : undefined
124
+ }
125
+ />
126
+ </Sidebar>
127
+ <Sidebar
128
+ header="Fichiers joints"
129
+ visible={attachedFilesSidebarVisible}
130
+ position="right"
131
+ onHide={() => setAttachedFilesSidebarVisible(false)}
132
+ >
133
+ <AttachedFilesSidebarContent />
134
+ </Sidebar>
135
+ {activityJS.activitySession?.type.helpUrl && (
136
+ <Dialog
137
+ id="metaPlayerHelpDialog"
138
+ header="Documentation"
139
+ visible={helpDialogVisible}
140
+ onHide={() => setHelpDialogVisible(false)}
141
+ maximizable={true}
142
+ >
143
+ <iframe
144
+ src={activityJS.activitySession?.type.helpUrl}
145
+ style={{ width: "100%", height: "100%" }}
146
+ title="Documentation"
147
+ />
148
+ </Dialog>
149
+ )}
150
+ </div>
151
+ );
152
+ };
153
+
154
+ export default ActivityMenu;
@@ -1,7 +1,7 @@
1
- .activityMenu {
2
- padding-right: 16px;
3
- display: flex;
4
- gap: 8px;
5
- justify-content: center;
6
- align-items: center;
7
- }
1
+ .activityMenu {
2
+ padding-right: 16px;
3
+ display: flex;
4
+ gap: 8px;
5
+ justify-content: center;
6
+ align-items: center;
7
+ }
@@ -1,75 +1,75 @@
1
- import { FC, useCallback, useEffect, useState } from "react";
2
- import { useAppSelector } from "../../../app/hooks";
3
- import { Dialog } from "primereact/dialog";
4
- import { selectActivityInfo } from "../../activityData/activityDataSlice";
5
- import { Button } from "primereact/button";
6
- import { apiCloneActivity } from "../../../utils/capytale";
7
- import { useActivityJsEssentials } from "../../activityJS/ActivityJSProvider";
8
- import { InputText } from "primereact/inputtext";
9
-
10
- const CloneDialog: FC<{ visible: boolean; onHide: () => any }> = ({
11
- visible,
12
- onHide,
13
- }) => {
14
- const { nid } = useActivityJsEssentials();
15
- const activityTitle = useAppSelector(selectActivityInfo).title;
16
- const [newTitle, setNewTitle] = useState<string>(activityTitle);
17
- const clone = useCallback(async () => {
18
- const clone = await apiCloneActivity(nid, newTitle);
19
- const newNid = clone.nid;
20
- const url = `/web/c-act/n/${newNid}/play/create`;
21
- // redirect to the new activity in a new tab
22
- window.open(url, "_blank");
23
- onHide();
24
- }, [nid, newTitle, onHide]);
25
-
26
- useEffect(() => {
27
- setNewTitle(activityTitle);
28
- }, [activityTitle, visible]);
29
-
30
- return (
31
- <Dialog
32
- visible={visible}
33
- header={"Choisissez le titre du clone"}
34
- onHide={onHide}
35
- style={{ width: "750px", maxWidth: "100%" }}
36
- >
37
- <div
38
- style={{
39
- display: "flex",
40
- flexDirection: "column",
41
- gap: "0.5rem",
42
- marginBottom: "1rem",
43
- }}
44
- >
45
- <label htmlFor="title-input">Titre</label>
46
- <InputText
47
- id="title-input"
48
- value={newTitle}
49
- onChange={(e) => setNewTitle(e.target.value)}
50
- />
51
- <div
52
- style={{
53
- display: "flex",
54
- justifyContent: "flex-end",
55
- gap: "0.5rem",
56
- }}
57
- >
58
- <Button
59
- aria-label="Annuler le clonage"
60
- label="Annuler"
61
- onClick={onHide}
62
- severity="secondary"
63
- />
64
- <Button
65
- aria-label="Confirmer le clonage"
66
- label="Cloner"
67
- onClick={clone}
68
- />
69
- </div>
70
- </div>
71
- </Dialog>
72
- );
73
- };
74
-
75
- export default CloneDialog;
1
+ import { FC, useCallback, useEffect, useState } from "react";
2
+ import { useAppSelector } from "../../../app/hooks";
3
+ import { Dialog } from "primereact/dialog";
4
+ import { selectActivityInfo } from "../../activityData/activityDataSlice";
5
+ import { Button } from "primereact/button";
6
+ import { apiCloneActivity } from "../../../utils/capytale";
7
+ import { useActivityJsEssentials } from "../../activityJS/ActivityJSProvider";
8
+ import { InputText } from "primereact/inputtext";
9
+
10
+ const CloneDialog: FC<{ visible: boolean; onHide: () => any }> = ({
11
+ visible,
12
+ onHide,
13
+ }) => {
14
+ const { nid } = useActivityJsEssentials();
15
+ const activityTitle = useAppSelector(selectActivityInfo).title;
16
+ const [newTitle, setNewTitle] = useState<string>(activityTitle);
17
+ const clone = useCallback(async () => {
18
+ const clone = await apiCloneActivity(nid, newTitle);
19
+ const newNid = clone.nid;
20
+ const url = `/web/c-act/n/${newNid}/play/create`;
21
+ // redirect to the new activity in a new tab
22
+ window.open(url, "_blank");
23
+ onHide();
24
+ }, [nid, newTitle, onHide]);
25
+
26
+ useEffect(() => {
27
+ setNewTitle(activityTitle);
28
+ }, [activityTitle, visible]);
29
+
30
+ return (
31
+ <Dialog
32
+ visible={visible}
33
+ header={"Choisissez le titre du clone"}
34
+ onHide={onHide}
35
+ style={{ width: "750px", maxWidth: "100%" }}
36
+ >
37
+ <div
38
+ style={{
39
+ display: "flex",
40
+ flexDirection: "column",
41
+ gap: "0.5rem",
42
+ marginBottom: "1rem",
43
+ }}
44
+ >
45
+ <label htmlFor="title-input">Titre</label>
46
+ <InputText
47
+ id="title-input"
48
+ value={newTitle}
49
+ onChange={(e) => setNewTitle(e.target.value)}
50
+ />
51
+ <div
52
+ style={{
53
+ display: "flex",
54
+ justifyContent: "flex-end",
55
+ gap: "0.5rem",
56
+ }}
57
+ >
58
+ <Button
59
+ aria-label="Annuler le clonage"
60
+ label="Annuler"
61
+ onClick={onHide}
62
+ severity="secondary"
63
+ />
64
+ <Button
65
+ aria-label="Confirmer le clonage"
66
+ label="Cloner"
67
+ onClick={clone}
68
+ />
69
+ </div>
70
+ </div>
71
+ </Dialog>
72
+ );
73
+ };
74
+
75
+ export default CloneDialog;