@capytale/meta-player 0.9.10 → 0.10.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.
Files changed (110) 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 +145 -140
  10. package/src/AppRedux.css +39 -39
  11. package/src/MetaPlayer.tsx +168 -168
  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 +255 -255
  24. package/src/features/activityData/activityJsData.ts +90 -90
  25. package/src/features/activityData/hooks.ts +39 -39
  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 +362 -350
  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 +93 -93
  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 +89 -57
  53. package/src/features/navbar/activity-menu/index.tsx +154 -154
  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 +313 -313
  57. package/src/features/navbar/capytale-menu/CountdownAndSaveButton.tsx +129 -125
  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/capytale-menu/useRemainingTimeMs.tsx +32 -32
  61. package/src/features/navbar/index.tsx +39 -39
  62. package/src/features/navbar/navbarSlice.ts +79 -79
  63. package/src/features/navbar/preview-navbar/index.tsx +18 -0
  64. package/src/features/navbar/preview-navbar/style.module.scss +17 -0
  65. package/src/features/navbar/review-navbar/GradingNav.tsx +128 -128
  66. package/src/features/navbar/review-navbar/index.tsx +18 -18
  67. package/src/features/navbar/review-navbar/style.module.scss +22 -22
  68. package/src/features/navbar/sidebars/ActivitySidebarActions.tsx +57 -57
  69. package/src/features/navbar/sidebars/AttachedFilesSidebarContent.module.scss +43 -43
  70. package/src/features/navbar/sidebars/AttachedFilesSidebarContent.tsx +181 -181
  71. package/src/features/navbar/sidebars/SettingsSidebarContent.tsx +192 -192
  72. package/src/features/navbar/sidebars/style.module.scss +15 -15
  73. package/src/features/navbar/student-utils.ts +11 -11
  74. package/src/features/navbar/style.module.scss +65 -65
  75. package/src/features/pedago/InstructionsEditor.tsx +104 -102
  76. package/src/features/pedago/PdfEditor.tsx +91 -91
  77. package/src/features/pedago/PedagoCommands.tsx +378 -378
  78. package/src/features/pedago/SharedNotesEditor.tsx +144 -144
  79. package/src/features/pedago/hooks.ts +108 -108
  80. package/src/features/pedago/index.tsx +205 -205
  81. package/src/features/pedago/style.module.scss +233 -233
  82. package/src/features/theming/ThemeSwitcher.tsx +51 -51
  83. package/src/features/theming/hooks.ts +6 -6
  84. package/src/features/theming/themingSlice.ts +93 -93
  85. package/src/features/toast.tsx +38 -38
  86. package/src/hooks/index.ts +55 -16
  87. package/src/index.css +132 -132
  88. package/src/index.ts +93 -92
  89. package/src/logo.svg +1 -1
  90. package/src/my_json_data.js +4146 -4146
  91. package/src/settings.ts +6 -6
  92. package/src/types.ts +8 -8
  93. package/src/utils/ButtonDoubleIcon.tsx +35 -35
  94. package/src/utils/CardSelector.tsx +41 -41
  95. package/src/utils/ErrorBoundary.tsx +41 -41
  96. package/src/utils/PopupButton.tsx +134 -134
  97. package/src/utils/activity.ts +8 -8
  98. package/src/utils/breakpoints.ts +4 -4
  99. package/src/utils/capytale.ts +10 -10
  100. package/src/utils/clipboard.ts +11 -11
  101. package/src/utils/download.ts +7 -7
  102. package/src/utils/equality.ts +32 -32
  103. package/src/utils/server-clock.ts +42 -42
  104. package/src/utils/style.module.scss +45 -45
  105. package/src/utils/useFullscreen.ts +65 -65
  106. package/src/vite-env.d.ts +1 -1
  107. package/src/zustandStore.ts +66 -0
  108. package/tsconfig.json +28 -28
  109. package/tsconfig.node.json +9 -9
  110. package/vite.config.ts +11 -11
@@ -1,205 +1,205 @@
1
- import { Panel } from "primereact/panel";
2
- import styles from "./style.module.scss";
3
- import { useAppDispatch, useAppSelector } from "../../app/hooks";
4
- import { selectPedagoTab } from "../layout/layoutSlice";
5
-
6
- import "@capytale/capytale-rich-text-editor/style.css";
7
- import { Splitter, SplitterPanel } from "primereact/splitter";
8
- import { classNames } from "primereact/utils";
9
- import InstructionsEditor from "./InstructionsEditor";
10
- import {
11
- selectComments,
12
- selectGrading,
13
- selectMode,
14
- setComments,
15
- setGrading,
16
- setIsMPDirty,
17
- } from "../activityData/activityDataSlice";
18
- import { ChangeEventHandler, FC, useCallback } from "react";
19
- import { DivProps } from "react-html-props";
20
- import SharedNotesEditor from "./SharedNotesEditor";
21
- import { CloseOnlyPedagoCommands, PedagoCommands } from "./PedagoCommands";
22
- import { PdfEditor } from "./PdfEditor";
23
- import { usePedagoOptions } from "./hooks";
24
-
25
- const Pedago: React.FC<DivProps> = ({ className, ...props }) => {
26
- const pedagoTab = useAppSelector(selectPedagoTab);
27
- const { showInstructions, showGrading, isHorizontal } = usePedagoOptions();
28
-
29
- const mayReverse = useCallback(
30
- isHorizontal
31
- ? (tab: Array<any>) => {
32
- const reversed = [...tab];
33
- reversed.reverse();
34
- return reversed;
35
- }
36
- : (tab: Array<any>) => tab,
37
- [isHorizontal],
38
- );
39
-
40
- if (!showInstructions) {
41
- return (
42
- <div className={styles.onlyGradingPedago}>
43
- <CloseOnlyPedagoCommands />
44
- <div className={styles.gradingPanel}>
45
- <Grading />
46
- </div>
47
- </div>
48
- );
49
- }
50
-
51
- return (
52
- // @ts-ignore - Incompatibility for props in TS
53
- <div className={classNames(styles.pedago, className)} {...props}>
54
- <PedagoCommands />
55
- <div
56
- className={styles.pedagoContent}
57
- aria-label={
58
- pedagoTab === "instructions"
59
- ? "Consignes"
60
- : pedagoTab === "pdf"
61
- ? "PDF"
62
- : pedagoTab === "sharedNotes"
63
- ? "Notes partagées"
64
- : ""
65
- }
66
- data-grading-visible={showGrading}
67
- >
68
- {!showGrading && (
69
- <>
70
- {pedagoTab === "instructions" && <InstructionsEditor />}
71
- {pedagoTab === "sharedNotes" && <SharedNotesEditor />}
72
- {pedagoTab === "pdf" && <PdfEditor />}
73
- {pedagoTab === null && <div />}
74
- </>
75
- )}
76
- {showGrading && (
77
- <Splitter
78
- layout={isHorizontal ? "horizontal" : "vertical"}
79
- className={styles.pedagoSplitter}
80
- >
81
- {mayReverse([
82
- <SplitterPanel
83
- aria-label="Panneau de notation"
84
- key="gradingPanel"
85
- minSize={30}
86
- size={40}
87
- className={styles.gradingPanel}
88
- >
89
- <Grading />
90
- </SplitterPanel>,
91
- <SplitterPanel
92
- aria-label="Panneau de consignes"
93
- key="pedagoPanel"
94
- minSize={50}
95
- size={60}
96
- className={styles.pedagoPanel}
97
- >
98
- <Panel
99
- className={styles.fullSizePanel}
100
- aria-label={
101
- pedagoTab === "instructions"
102
- ? "Consignes"
103
- : pedagoTab === "pdf"
104
- ? "PDF"
105
- : pedagoTab === "sharedNotes"
106
- ? "Notes partagées"
107
- : ""
108
- }
109
- header={
110
- pedagoTab === "instructions"
111
- ? "Consignes"
112
- : pedagoTab === "pdf"
113
- ? "PDF"
114
- : pedagoTab === "sharedNotes"
115
- ? "Notes partagées"
116
- : ""
117
- }
118
- >
119
- {pedagoTab === "instructions" && <InstructionsEditor />}
120
- {pedagoTab === "sharedNotes" && <SharedNotesEditor />}
121
- {pedagoTab === "pdf" && <PdfEditor />}
122
- {pedagoTab === null && <div />}
123
- </Panel>
124
- </SplitterPanel>,
125
- ])}
126
- </Splitter>
127
- )}
128
- </div>
129
- </div>
130
- );
131
- };
132
-
133
- const Grading: FC = () => {
134
- const mode = useAppSelector(selectMode);
135
- const comments = useAppSelector(selectComments);
136
- const grading = useAppSelector(selectGrading);
137
- const dispatch = useAppDispatch();
138
-
139
- const handleCommentsChange: ChangeEventHandler<HTMLTextAreaElement> = (
140
- event,
141
- ) => {
142
- dispatch(setComments(event.target.value));
143
- dispatch(setIsMPDirty(true));
144
- };
145
-
146
- const handleGradingChange: ChangeEventHandler<HTMLTextAreaElement> = (
147
- event,
148
- ) => {
149
- dispatch(setGrading(event.target.value));
150
- dispatch(setIsMPDirty(true));
151
- };
152
-
153
- return (
154
- <>
155
- <Panel
156
- className={classNames(styles.fullSizePanel, styles.pedagoFeedbackPanel)}
157
- header="Appréciation"
158
- >
159
- <div className={styles.pedagoFeedback}>
160
- {(comments || mode !== "assignment") && (
161
- <textarea
162
- aria-label="Saisie de l'appréciation"
163
- value={comments || ""}
164
- placeholder={
165
- mode !== "review" ? "" : "Rédigez ici l'appréciation."
166
- }
167
- id="comments"
168
- name="comments"
169
- rows={2}
170
- readOnly={mode !== "review"}
171
- onChange={handleCommentsChange}
172
- className={styles.fullTextarea}
173
- />
174
- )}
175
- </div>
176
- </Panel>
177
- <Panel
178
- className={classNames(styles.fullSizePanel, styles.pedagoGradePanel)}
179
- header="Évaluation"
180
- >
181
- <div className={styles.pedagoGrade}>
182
- {(grading || mode !== "assignment") && (
183
- <textarea
184
- aria-label="Saisie de l'évaluation"
185
- value={grading || ""}
186
- placeholder={
187
- mode !== "review"
188
- ? ""
189
- : "Écrivez ici l'évaluation libre (chiffrée ou non)."
190
- }
191
- id="grading"
192
- name="grading"
193
- rows={1}
194
- readOnly={mode !== "review"}
195
- onChange={handleGradingChange}
196
- className={styles.fullTextarea}
197
- />
198
- )}
199
- </div>
200
- </Panel>
201
- </>
202
- );
203
- };
204
-
205
- export default Pedago;
1
+ import { Panel } from "primereact/panel";
2
+ import styles from "./style.module.scss";
3
+ import { useAppDispatch, useAppSelector } from "../../app/hooks";
4
+ import { selectPedagoTab } from "../layout/layoutSlice";
5
+
6
+ import "@capytale/capytale-rich-text-editor/style.css";
7
+ import { Splitter, SplitterPanel } from "primereact/splitter";
8
+ import { classNames } from "primereact/utils";
9
+ import InstructionsEditor from "./InstructionsEditor";
10
+ import {
11
+ selectComments,
12
+ selectGrading,
13
+ selectMode,
14
+ setComments,
15
+ setGrading,
16
+ setIsMPDirty,
17
+ } from "../activityData/activityDataSlice";
18
+ import { ChangeEventHandler, FC, useCallback } from "react";
19
+ import { DivProps } from "react-html-props";
20
+ import SharedNotesEditor from "./SharedNotesEditor";
21
+ import { CloseOnlyPedagoCommands, PedagoCommands } from "./PedagoCommands";
22
+ import { PdfEditor } from "./PdfEditor";
23
+ import { usePedagoOptions } from "./hooks";
24
+
25
+ const Pedago: React.FC<DivProps> = ({ className, ...props }) => {
26
+ const pedagoTab = useAppSelector(selectPedagoTab);
27
+ const { showInstructions, showGrading, isHorizontal } = usePedagoOptions();
28
+
29
+ const mayReverse = useCallback(
30
+ isHorizontal
31
+ ? (tab: Array<any>) => {
32
+ const reversed = [...tab];
33
+ reversed.reverse();
34
+ return reversed;
35
+ }
36
+ : (tab: Array<any>) => tab,
37
+ [isHorizontal],
38
+ );
39
+
40
+ if (!showInstructions) {
41
+ return (
42
+ <div className={styles.onlyGradingPedago}>
43
+ <CloseOnlyPedagoCommands />
44
+ <div className={styles.gradingPanel}>
45
+ <Grading />
46
+ </div>
47
+ </div>
48
+ );
49
+ }
50
+
51
+ return (
52
+ // @ts-ignore - Incompatibility for props in TS
53
+ <div className={classNames(styles.pedago, className)} {...props}>
54
+ <PedagoCommands />
55
+ <div
56
+ className={styles.pedagoContent}
57
+ aria-label={
58
+ pedagoTab === "instructions"
59
+ ? "Consignes"
60
+ : pedagoTab === "pdf"
61
+ ? "PDF"
62
+ : pedagoTab === "sharedNotes"
63
+ ? "Notes partagées"
64
+ : ""
65
+ }
66
+ data-grading-visible={showGrading}
67
+ >
68
+ {!showGrading && (
69
+ <>
70
+ {pedagoTab === "instructions" && <InstructionsEditor />}
71
+ {pedagoTab === "sharedNotes" && <SharedNotesEditor />}
72
+ {pedagoTab === "pdf" && <PdfEditor />}
73
+ {pedagoTab === null && <div />}
74
+ </>
75
+ )}
76
+ {showGrading && (
77
+ <Splitter
78
+ layout={isHorizontal ? "horizontal" : "vertical"}
79
+ className={styles.pedagoSplitter}
80
+ >
81
+ {mayReverse([
82
+ <SplitterPanel
83
+ aria-label="Panneau de notation"
84
+ key="gradingPanel"
85
+ minSize={30}
86
+ size={40}
87
+ className={styles.gradingPanel}
88
+ >
89
+ <Grading />
90
+ </SplitterPanel>,
91
+ <SplitterPanel
92
+ aria-label="Panneau de consignes"
93
+ key="pedagoPanel"
94
+ minSize={50}
95
+ size={60}
96
+ className={styles.pedagoPanel}
97
+ >
98
+ <Panel
99
+ className={styles.fullSizePanel}
100
+ aria-label={
101
+ pedagoTab === "instructions"
102
+ ? "Consignes"
103
+ : pedagoTab === "pdf"
104
+ ? "PDF"
105
+ : pedagoTab === "sharedNotes"
106
+ ? "Notes partagées"
107
+ : ""
108
+ }
109
+ header={
110
+ pedagoTab === "instructions"
111
+ ? "Consignes"
112
+ : pedagoTab === "pdf"
113
+ ? "PDF"
114
+ : pedagoTab === "sharedNotes"
115
+ ? "Notes partagées"
116
+ : ""
117
+ }
118
+ >
119
+ {pedagoTab === "instructions" && <InstructionsEditor />}
120
+ {pedagoTab === "sharedNotes" && <SharedNotesEditor />}
121
+ {pedagoTab === "pdf" && <PdfEditor />}
122
+ {pedagoTab === null && <div />}
123
+ </Panel>
124
+ </SplitterPanel>,
125
+ ])}
126
+ </Splitter>
127
+ )}
128
+ </div>
129
+ </div>
130
+ );
131
+ };
132
+
133
+ const Grading: FC = () => {
134
+ const mode = useAppSelector(selectMode);
135
+ const comments = useAppSelector(selectComments);
136
+ const grading = useAppSelector(selectGrading);
137
+ const dispatch = useAppDispatch();
138
+
139
+ const handleCommentsChange: ChangeEventHandler<HTMLTextAreaElement> = (
140
+ event,
141
+ ) => {
142
+ dispatch(setComments(event.target.value));
143
+ dispatch(setIsMPDirty(true));
144
+ };
145
+
146
+ const handleGradingChange: ChangeEventHandler<HTMLTextAreaElement> = (
147
+ event,
148
+ ) => {
149
+ dispatch(setGrading(event.target.value));
150
+ dispatch(setIsMPDirty(true));
151
+ };
152
+
153
+ return (
154
+ <>
155
+ <Panel
156
+ className={classNames(styles.fullSizePanel, styles.pedagoFeedbackPanel)}
157
+ header="Appréciation"
158
+ >
159
+ <div className={styles.pedagoFeedback}>
160
+ {(comments || mode !== "assignment") && (
161
+ <textarea
162
+ aria-label="Saisie de l'appréciation"
163
+ value={comments || ""}
164
+ placeholder={
165
+ mode !== "review" ? "" : "Rédigez ici l'appréciation."
166
+ }
167
+ id="comments"
168
+ name="comments"
169
+ rows={2}
170
+ readOnly={mode !== "review"}
171
+ onChange={handleCommentsChange}
172
+ className={styles.fullTextarea}
173
+ />
174
+ )}
175
+ </div>
176
+ </Panel>
177
+ <Panel
178
+ className={classNames(styles.fullSizePanel, styles.pedagoGradePanel)}
179
+ header="Évaluation"
180
+ >
181
+ <div className={styles.pedagoGrade}>
182
+ {(grading || mode !== "assignment") && (
183
+ <textarea
184
+ aria-label="Saisie de l'évaluation"
185
+ value={grading || ""}
186
+ placeholder={
187
+ mode !== "review"
188
+ ? ""
189
+ : "Écrivez ici l'évaluation libre (chiffrée ou non)."
190
+ }
191
+ id="grading"
192
+ name="grading"
193
+ rows={1}
194
+ readOnly={mode !== "review"}
195
+ onChange={handleGradingChange}
196
+ className={styles.fullTextarea}
197
+ />
198
+ )}
199
+ </div>
200
+ </Panel>
201
+ </>
202
+ );
203
+ };
204
+
205
+ export default Pedago;