@capytale/meta-player 0.8.3 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.json +4 -4
- package/LICENSE +674 -674
- package/README.md +12 -12
- package/eslint.config.js +28 -28
- package/index.html +15 -15
- package/package.json +60 -60
- package/public/themes/lara-dark-blue/theme.css +7015 -7015
- package/public/themes/lara-light-blue/theme.css +7005 -7005
- package/src/App.tsx +140 -139
- package/src/AppRedux.css +39 -39
- package/src/MetaPlayer.tsx +168 -170
- package/src/activityJs.ts +7 -7
- package/src/app/createAppSlice.ts +6 -6
- package/src/app/hooks.ts +12 -12
- package/src/app/store.ts +52 -52
- package/src/app.module.scss +80 -80
- package/src/demo.tsx +87 -87
- package/src/external/prime.ts +5 -5
- package/src/features/activityData/ExitWarning.ts +28 -28
- package/src/features/activityData/IsAntiCheatExitDetectionDisabledSetter.tsx +19 -19
- package/src/features/activityData/IsDirtySetter.tsx +17 -17
- package/src/features/activityData/MetaPlayerOptionsSetter.tsx +41 -41
- package/src/features/activityData/activityDataSlice.ts +252 -256
- package/src/features/activityData/activityJsData.ts +82 -82
- package/src/features/activityData/hooks.ts +34 -34
- package/src/features/activityData/metaPlayerOptions.ts +23 -23
- package/src/features/activityData/uiState.ts +20 -20
- package/src/features/activityJS/ActivityJSProvider.tsx +339 -339
- package/src/features/activityJS/AfterResetAction.tsx +23 -23
- package/src/features/activityJS/AfterSaveAction.tsx +23 -23
- package/src/features/activityJS/BeforeResetAction.tsx +23 -23
- package/src/features/activityJS/BeforeSaveAction.tsx +23 -23
- package/src/features/activityJS/Saver.tsx +167 -167
- package/src/features/activityJS/hooks.ts +85 -85
- package/src/features/activityJS/internal-hooks.ts +96 -96
- package/src/features/activityJS/saverSlice.ts +96 -96
- package/src/features/activitySettings/ActivitySettingsSetter.tsx +21 -21
- package/src/features/activitySettings/hooks.ts +12 -12
- package/src/features/activitySettings/index.tsx +43 -43
- package/src/features/activitySettings/store.ts +108 -108
- package/src/features/activitySettings/style.module.scss +8 -8
- package/src/features/activitySettings/types.ts +140 -140
- package/src/features/activitySettings/ui.tsx +299 -299
- package/src/features/functionalities/AttachedFilesFunctionality.ts +23 -23
- package/src/features/functionalities/PreviewDialog.tsx +83 -83
- package/src/features/functionalities/functionalitiesSlice.ts +98 -98
- package/src/features/functionalities/hooks.ts +70 -70
- package/src/features/layout/hooks.ts +7 -7
- package/src/features/layout/layoutSlice.ts +93 -90
- package/src/features/navbar/activity-info/index.tsx +54 -54
- package/src/features/navbar/activity-info/style.module.scss +38 -38
- package/src/features/navbar/activity-menu/ActivityQuickActions.tsx +57 -57
- package/src/features/navbar/activity-menu/index.tsx +154 -154
- package/src/features/navbar/activity-menu/style.module.scss +7 -7
- package/src/features/navbar/capytale-menu/CloneDialog.tsx +75 -75
- package/src/features/navbar/capytale-menu/Countdown.tsx +312 -312
- package/src/features/navbar/capytale-menu/CountdownAndSaveButton.tsx +115 -115
- package/src/features/navbar/capytale-menu/index.tsx +260 -260
- package/src/features/navbar/capytale-menu/style.module.scss +8 -8
- package/src/features/navbar/index.tsx +39 -39
- package/src/features/navbar/navbarSlice.ts +79 -79
- package/src/features/navbar/review-navbar/GradingNav.tsx +128 -128
- package/src/features/navbar/review-navbar/index.tsx +18 -18
- package/src/features/navbar/review-navbar/style.module.scss +22 -22
- package/src/features/navbar/sidebars/ActivitySidebarActions.tsx +57 -57
- package/src/features/navbar/sidebars/AttachedFilesSidebarContent.module.scss +43 -43
- package/src/features/navbar/sidebars/AttachedFilesSidebarContent.tsx +181 -181
- package/src/features/navbar/sidebars/SettingsSidebarContent.tsx +192 -192
- package/src/features/navbar/sidebars/style.module.scss +15 -15
- package/src/features/navbar/student-utils.ts +11 -11
- package/src/features/navbar/style.module.scss +65 -65
- package/src/features/pedago/InstructionsEditor.tsx +102 -102
- package/src/features/pedago/PdfEditor.tsx +91 -91
- package/src/features/pedago/PedagoCommands.tsx +353 -353
- package/src/features/pedago/SharedNotesEditor.tsx +144 -144
- package/src/features/pedago/hooks.ts +99 -0
- package/src/features/pedago/index.tsx +197 -207
- package/src/features/pedago/style.module.scss +233 -233
- package/src/features/theming/ThemeSwitcher.tsx +51 -51
- package/src/features/theming/hooks.ts +6 -6
- package/src/features/theming/themingSlice.ts +93 -93
- package/src/features/toast.tsx +38 -38
- package/src/hooks/index.ts +16 -16
- package/src/index.css +132 -132
- package/src/index.ts +90 -90
- package/src/logo.svg +1 -1
- package/src/my_json_data.js +4146 -4146
- package/src/settings.ts +6 -6
- package/src/types.ts +8 -9
- package/src/utils/ButtonDoubleIcon.tsx +35 -35
- package/src/utils/CardSelector.tsx +41 -41
- package/src/utils/ErrorBoundary.tsx +41 -41
- package/src/utils/PopupButton.tsx +134 -134
- package/src/utils/activity.ts +8 -8
- package/src/utils/breakpoints.ts +4 -4
- package/src/utils/capytale.ts +10 -10
- package/src/utils/clipboard.ts +11 -11
- package/src/utils/download.ts +7 -7
- package/src/utils/equality.ts +32 -32
- package/src/utils/server-clock.ts +42 -42
- package/src/utils/style.module.scss +45 -45
- package/src/utils/useFullscreen.ts +65 -65
- package/src/vite-env.d.ts +1 -1
- package/tsconfig.json +28 -28
- package/tsconfig.node.json +9 -9
- package/vite.config.ts +11 -11
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
import { useCapytaleRichTextEditor } from "@capytale/capytale-rich-text-editor";
|
|
2
|
-
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
|
3
|
-
import {
|
|
4
|
-
selectSharedNotesContent,
|
|
5
|
-
selectMode,
|
|
6
|
-
setCanSaveSharedNotes,
|
|
7
|
-
setIsMPDirty,
|
|
8
|
-
setLexicalSharedNotesState,
|
|
9
|
-
selectWorkflow,
|
|
10
|
-
selectSharedNotesType,
|
|
11
|
-
setSharedNotesType,
|
|
12
|
-
} from "../activityData/activityDataSlice";
|
|
13
|
-
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
14
|
-
import settings from "../../settings";
|
|
15
|
-
import { Button } from "primereact/button";
|
|
16
|
-
import { Dialog } from "primereact/dialog";
|
|
17
|
-
import { useToast } from "../toast";
|
|
18
|
-
|
|
19
|
-
const SharedNotesEditor: React.FC = forwardRef((_props, ref) => {
|
|
20
|
-
const [Editor, getState, _canSave] = useCapytaleRichTextEditor();
|
|
21
|
-
const dispatch = useAppDispatch();
|
|
22
|
-
const toast = useToast();
|
|
23
|
-
const mode = useAppSelector(selectMode);
|
|
24
|
-
const workflow = useAppSelector(selectWorkflow);
|
|
25
|
-
const isEditable =
|
|
26
|
-
mode === "create" ||
|
|
27
|
-
(mode === "assignment" && workflow === "current") ||
|
|
28
|
-
mode === "review";
|
|
29
|
-
const initialEditorState = useAppSelector(selectSharedNotesContent);
|
|
30
|
-
const initialStateOnChangeDone = useRef<boolean>(false);
|
|
31
|
-
const sharedNotesType = useAppSelector(selectSharedNotesType);
|
|
32
|
-
|
|
33
|
-
const [helpDialogVisible, setHelpDialogVisible] = useState(false);
|
|
34
|
-
|
|
35
|
-
useImperativeHandle(ref, () => {
|
|
36
|
-
return {
|
|
37
|
-
save: async () => {
|
|
38
|
-
const state = await getState();
|
|
39
|
-
dispatch(setLexicalSharedNotesState(state.json));
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<>
|
|
46
|
-
{sharedNotesType === "none" && (
|
|
47
|
-
<>
|
|
48
|
-
<p>Pas de notes partagées.</p>
|
|
49
|
-
{mode === "create" && (
|
|
50
|
-
<Button
|
|
51
|
-
label="Créer des notes partagées"
|
|
52
|
-
onClick={() => dispatch(setSharedNotesType("rich"))}
|
|
53
|
-
/>
|
|
54
|
-
)}
|
|
55
|
-
<div style={{ textAlign: "start", padding: "16px" }}>
|
|
56
|
-
<h3>Que sont les notes partagées ?</h3>
|
|
57
|
-
<p>
|
|
58
|
-
Les notes partagées permettent aux élèves de communiquer avec leur
|
|
59
|
-
enseignant. L'enseignant donne le contenu initial des notes
|
|
60
|
-
partagées, et les élèves peuvent le modifier, notamment pour
|
|
61
|
-
répondre à des questions, expliciter une démarche ou faire des
|
|
62
|
-
remarques sur leur travail. L'enseignant peut également modifier
|
|
63
|
-
les notes partagées pour répondre aux élèves.
|
|
64
|
-
</p>
|
|
65
|
-
<p>
|
|
66
|
-
Les notes partagées peuvent contenir du texte, des images, des
|
|
67
|
-
liens, etc., tout comme les consignes. La différence principale
|
|
68
|
-
avec les consignes est que les élèves peuvent modifier le contenu
|
|
69
|
-
des notes partagées. Elles sont un outil de communication
|
|
70
|
-
supplémentaire entre l'enseignant et les élèves.
|
|
71
|
-
</p>
|
|
72
|
-
</div>
|
|
73
|
-
<Button
|
|
74
|
-
severity="secondary"
|
|
75
|
-
size="small"
|
|
76
|
-
icon={"pi pi-question-circle"}
|
|
77
|
-
onClick={() => {
|
|
78
|
-
setHelpDialogVisible(true);
|
|
79
|
-
}}
|
|
80
|
-
outlined
|
|
81
|
-
label="En savoir plus"
|
|
82
|
-
style={{ marginBottom: "16px" }}
|
|
83
|
-
/>
|
|
84
|
-
<Dialog
|
|
85
|
-
id="metaPlayerHelpDialog"
|
|
86
|
-
header="Documentation"
|
|
87
|
-
visible={helpDialogVisible}
|
|
88
|
-
onHide={() => setHelpDialogVisible(false)}
|
|
89
|
-
maximizable={true}
|
|
90
|
-
>
|
|
91
|
-
<iframe
|
|
92
|
-
src={
|
|
93
|
-
"https://capytale2.ac-paris.fr/wiki/doku.php?id=notes_partagees"
|
|
94
|
-
}
|
|
95
|
-
style={{ width: "100%", height: "100%" }}
|
|
96
|
-
title="Documentation"
|
|
97
|
-
/>
|
|
98
|
-
</Dialog>
|
|
99
|
-
</>
|
|
100
|
-
)}
|
|
101
|
-
{sharedNotesType === "rich" && (
|
|
102
|
-
<Editor
|
|
103
|
-
placeholderText={
|
|
104
|
-
mode === "create"
|
|
105
|
-
? "Écrivez le contenu initial des notes partagées ici..."
|
|
106
|
-
: "Les notes partagées sont vides, vous pouvez les remplir ici..."
|
|
107
|
-
}
|
|
108
|
-
htmlInitialContent={initialEditorState ? undefined : ""}
|
|
109
|
-
initialEditorState={initialEditorState || undefined}
|
|
110
|
-
jsonSizeLimit={settings.STATEMENT_MAX_SIZE}
|
|
111
|
-
onChange={(editorState) => {
|
|
112
|
-
dispatch(setLexicalSharedNotesState(editorState));
|
|
113
|
-
if (initialStateOnChangeDone.current) {
|
|
114
|
-
dispatch(setIsMPDirty(true));
|
|
115
|
-
} else {
|
|
116
|
-
initialStateOnChangeDone.current = true;
|
|
117
|
-
}
|
|
118
|
-
}}
|
|
119
|
-
onJsonSizeLimitExceeded={() => {
|
|
120
|
-
dispatch(setCanSaveSharedNotes(false));
|
|
121
|
-
toast.show({
|
|
122
|
-
summary: "Erreur",
|
|
123
|
-
detail: `Le contenu des notes partagées est trop volumineux. Veuillez le réduire avant de l'enregistrer.\nPeut-être avez-vous inséré une image trop volumineuse ?`,
|
|
124
|
-
severity: "error",
|
|
125
|
-
life: 10000,
|
|
126
|
-
});
|
|
127
|
-
}}
|
|
128
|
-
onJsonSizeLimitMet={() => {
|
|
129
|
-
dispatch(setCanSaveSharedNotes(true));
|
|
130
|
-
toast.show({
|
|
131
|
-
summary: "Succès",
|
|
132
|
-
detail: `Le contenu des notes partagées ne dépasse plus la taille limite.`,
|
|
133
|
-
severity: "success",
|
|
134
|
-
life: 4000,
|
|
135
|
-
});
|
|
136
|
-
}}
|
|
137
|
-
isEditable={isEditable}
|
|
138
|
-
/>
|
|
139
|
-
)}
|
|
140
|
-
</>
|
|
141
|
-
);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
export default SharedNotesEditor;
|
|
1
|
+
import { useCapytaleRichTextEditor } from "@capytale/capytale-rich-text-editor";
|
|
2
|
+
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
|
3
|
+
import {
|
|
4
|
+
selectSharedNotesContent,
|
|
5
|
+
selectMode,
|
|
6
|
+
setCanSaveSharedNotes,
|
|
7
|
+
setIsMPDirty,
|
|
8
|
+
setLexicalSharedNotesState,
|
|
9
|
+
selectWorkflow,
|
|
10
|
+
selectSharedNotesType,
|
|
11
|
+
setSharedNotesType,
|
|
12
|
+
} from "../activityData/activityDataSlice";
|
|
13
|
+
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
14
|
+
import settings from "../../settings";
|
|
15
|
+
import { Button } from "primereact/button";
|
|
16
|
+
import { Dialog } from "primereact/dialog";
|
|
17
|
+
import { useToast } from "../toast";
|
|
18
|
+
|
|
19
|
+
const SharedNotesEditor: React.FC = forwardRef((_props, ref) => {
|
|
20
|
+
const [Editor, getState, _canSave] = useCapytaleRichTextEditor();
|
|
21
|
+
const dispatch = useAppDispatch();
|
|
22
|
+
const toast = useToast();
|
|
23
|
+
const mode = useAppSelector(selectMode);
|
|
24
|
+
const workflow = useAppSelector(selectWorkflow);
|
|
25
|
+
const isEditable =
|
|
26
|
+
mode === "create" ||
|
|
27
|
+
(mode === "assignment" && workflow === "current") ||
|
|
28
|
+
mode === "review";
|
|
29
|
+
const initialEditorState = useAppSelector(selectSharedNotesContent);
|
|
30
|
+
const initialStateOnChangeDone = useRef<boolean>(false);
|
|
31
|
+
const sharedNotesType = useAppSelector(selectSharedNotesType);
|
|
32
|
+
|
|
33
|
+
const [helpDialogVisible, setHelpDialogVisible] = useState(false);
|
|
34
|
+
|
|
35
|
+
useImperativeHandle(ref, () => {
|
|
36
|
+
return {
|
|
37
|
+
save: async () => {
|
|
38
|
+
const state = await getState();
|
|
39
|
+
dispatch(setLexicalSharedNotesState(state.json));
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
{sharedNotesType === "none" && (
|
|
47
|
+
<>
|
|
48
|
+
<p>Pas de notes partagées.</p>
|
|
49
|
+
{mode === "create" && (
|
|
50
|
+
<Button
|
|
51
|
+
label="Créer des notes partagées"
|
|
52
|
+
onClick={() => dispatch(setSharedNotesType("rich"))}
|
|
53
|
+
/>
|
|
54
|
+
)}
|
|
55
|
+
<div style={{ textAlign: "start", padding: "16px" }}>
|
|
56
|
+
<h3>Que sont les notes partagées ?</h3>
|
|
57
|
+
<p>
|
|
58
|
+
Les notes partagées permettent aux élèves de communiquer avec leur
|
|
59
|
+
enseignant. L'enseignant donne le contenu initial des notes
|
|
60
|
+
partagées, et les élèves peuvent le modifier, notamment pour
|
|
61
|
+
répondre à des questions, expliciter une démarche ou faire des
|
|
62
|
+
remarques sur leur travail. L'enseignant peut également modifier
|
|
63
|
+
les notes partagées pour répondre aux élèves.
|
|
64
|
+
</p>
|
|
65
|
+
<p>
|
|
66
|
+
Les notes partagées peuvent contenir du texte, des images, des
|
|
67
|
+
liens, etc., tout comme les consignes. La différence principale
|
|
68
|
+
avec les consignes est que les élèves peuvent modifier le contenu
|
|
69
|
+
des notes partagées. Elles sont un outil de communication
|
|
70
|
+
supplémentaire entre l'enseignant et les élèves.
|
|
71
|
+
</p>
|
|
72
|
+
</div>
|
|
73
|
+
<Button
|
|
74
|
+
severity="secondary"
|
|
75
|
+
size="small"
|
|
76
|
+
icon={"pi pi-question-circle"}
|
|
77
|
+
onClick={() => {
|
|
78
|
+
setHelpDialogVisible(true);
|
|
79
|
+
}}
|
|
80
|
+
outlined
|
|
81
|
+
label="En savoir plus"
|
|
82
|
+
style={{ marginBottom: "16px" }}
|
|
83
|
+
/>
|
|
84
|
+
<Dialog
|
|
85
|
+
id="metaPlayerHelpDialog"
|
|
86
|
+
header="Documentation"
|
|
87
|
+
visible={helpDialogVisible}
|
|
88
|
+
onHide={() => setHelpDialogVisible(false)}
|
|
89
|
+
maximizable={true}
|
|
90
|
+
>
|
|
91
|
+
<iframe
|
|
92
|
+
src={
|
|
93
|
+
"https://capytale2.ac-paris.fr/wiki/doku.php?id=notes_partagees"
|
|
94
|
+
}
|
|
95
|
+
style={{ width: "100%", height: "100%" }}
|
|
96
|
+
title="Documentation"
|
|
97
|
+
/>
|
|
98
|
+
</Dialog>
|
|
99
|
+
</>
|
|
100
|
+
)}
|
|
101
|
+
{sharedNotesType === "rich" && (
|
|
102
|
+
<Editor
|
|
103
|
+
placeholderText={
|
|
104
|
+
mode === "create"
|
|
105
|
+
? "Écrivez le contenu initial des notes partagées ici..."
|
|
106
|
+
: "Les notes partagées sont vides, vous pouvez les remplir ici..."
|
|
107
|
+
}
|
|
108
|
+
htmlInitialContent={initialEditorState ? undefined : ""}
|
|
109
|
+
initialEditorState={initialEditorState || undefined}
|
|
110
|
+
jsonSizeLimit={settings.STATEMENT_MAX_SIZE}
|
|
111
|
+
onChange={(editorState) => {
|
|
112
|
+
dispatch(setLexicalSharedNotesState(editorState));
|
|
113
|
+
if (initialStateOnChangeDone.current) {
|
|
114
|
+
dispatch(setIsMPDirty(true));
|
|
115
|
+
} else {
|
|
116
|
+
initialStateOnChangeDone.current = true;
|
|
117
|
+
}
|
|
118
|
+
}}
|
|
119
|
+
onJsonSizeLimitExceeded={() => {
|
|
120
|
+
dispatch(setCanSaveSharedNotes(false));
|
|
121
|
+
toast.show({
|
|
122
|
+
summary: "Erreur",
|
|
123
|
+
detail: `Le contenu des notes partagées est trop volumineux. Veuillez le réduire avant de l'enregistrer.\nPeut-être avez-vous inséré une image trop volumineuse ?`,
|
|
124
|
+
severity: "error",
|
|
125
|
+
life: 10000,
|
|
126
|
+
});
|
|
127
|
+
}}
|
|
128
|
+
onJsonSizeLimitMet={() => {
|
|
129
|
+
dispatch(setCanSaveSharedNotes(true));
|
|
130
|
+
toast.show({
|
|
131
|
+
summary: "Succès",
|
|
132
|
+
detail: `Le contenu des notes partagées ne dépasse plus la taille limite.`,
|
|
133
|
+
severity: "success",
|
|
134
|
+
life: 4000,
|
|
135
|
+
});
|
|
136
|
+
}}
|
|
137
|
+
isEditable={isEditable}
|
|
138
|
+
/>
|
|
139
|
+
)}
|
|
140
|
+
</>
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export default SharedNotesEditor;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useAppSelector } from "../../app/hooks";
|
|
3
|
+
import {
|
|
4
|
+
selectHasGradingOrComments,
|
|
5
|
+
selectShowPedagoByDefault,
|
|
6
|
+
selectInstructions,
|
|
7
|
+
selectInstructionsType,
|
|
8
|
+
selectMode,
|
|
9
|
+
} from "../activityData/activityDataSlice";
|
|
10
|
+
import {
|
|
11
|
+
selectIsGradingVisible,
|
|
12
|
+
selectIsPedagoVisible,
|
|
13
|
+
selectOrientation,
|
|
14
|
+
} from "../layout/layoutSlice";
|
|
15
|
+
|
|
16
|
+
export const usePedagoOptions = () => {
|
|
17
|
+
const mode = useAppSelector(selectMode);
|
|
18
|
+
const isHorizontal = useAppSelector(selectOrientation) === "horizontal";
|
|
19
|
+
const isPedagoVisible = useAppSelector(selectIsPedagoVisible);
|
|
20
|
+
const isGradingVisible = useAppSelector(selectIsGradingVisible);
|
|
21
|
+
const showPedagoByDefault = useAppSelector(selectShowPedagoByDefault);
|
|
22
|
+
const hasGradingOrComments = useAppSelector(selectHasGradingOrComments);
|
|
23
|
+
const instructionsType = useAppSelector(selectInstructionsType);
|
|
24
|
+
const instructions = useAppSelector(selectInstructions);
|
|
25
|
+
const hasNonEmptyInstructions = useMemo(() => {
|
|
26
|
+
if (instructionsType === "none" || !instructions) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
if (instructions.format === "html") {
|
|
30
|
+
if (typeof instructions.value !== "string") {
|
|
31
|
+
console.warn("HTML instructions value is not a string");
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return (
|
|
35
|
+
instructions.value.trim() !== "" &&
|
|
36
|
+
instructions.value.trim() !== "<p></p>"
|
|
37
|
+
);
|
|
38
|
+
} else if (instructions.format === "markdown") {
|
|
39
|
+
if (typeof instructions.value !== "string") {
|
|
40
|
+
console.warn("Markdown instructions value is not a string");
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return instructions.value.trim() !== "";
|
|
44
|
+
} else if (instructions.format === "lexical") {
|
|
45
|
+
if (typeof instructions.value !== "string") {
|
|
46
|
+
console.warn("Lexical instructions value is not a string");
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const parsedInstructions = JSON.parse(instructions.value);
|
|
51
|
+
if (
|
|
52
|
+
!parsedInstructions.root ||
|
|
53
|
+
!parsedInstructions.root.children ||
|
|
54
|
+
parsedInstructions.root.children.length === 0
|
|
55
|
+
) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
if (parsedInstructions.root.children.length > 1) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
const singleNode = parsedInstructions.root.children[0];
|
|
62
|
+
if (singleNode.type !== "paragraph") {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return singleNode.children && singleNode.children.length > 0;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.warn("Lexical instructions value is not valid JSON");
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}, [instructionsType, instructions]);
|
|
73
|
+
|
|
74
|
+
const hasPedago =
|
|
75
|
+
mode === "review"
|
|
76
|
+
? true
|
|
77
|
+
: mode === "detached"
|
|
78
|
+
? false
|
|
79
|
+
: mode === "create"
|
|
80
|
+
? true
|
|
81
|
+
: hasNonEmptyInstructions || hasGradingOrComments;
|
|
82
|
+
|
|
83
|
+
const showPedago =
|
|
84
|
+
isPedagoVisible ?? (mode === "create" ? showPedagoByDefault : hasPedago);
|
|
85
|
+
|
|
86
|
+
const showInstructions = mode === "create" ? true : hasNonEmptyInstructions;
|
|
87
|
+
const hasGrading = mode === "review" || hasGradingOrComments;
|
|
88
|
+
const showGrading = hasGrading && isGradingVisible;
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
hasPedago,
|
|
92
|
+
showPedago,
|
|
93
|
+
isHorizontal,
|
|
94
|
+
hasNonEmptyInstructions,
|
|
95
|
+
showInstructions,
|
|
96
|
+
hasGrading,
|
|
97
|
+
showGrading,
|
|
98
|
+
};
|
|
99
|
+
};
|