@capytale/meta-player 0.5.18 → 0.6.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/package.json
CHANGED
|
@@ -3,6 +3,8 @@ import { TimeRange } from "@capytale/activity.js/common/field";
|
|
|
3
3
|
import { InitialEditorStateType } from "@capytale/capytale-rich-text-editor";
|
|
4
4
|
import { wf } from "@capytale/activity.js/activity/field/workflow";
|
|
5
5
|
|
|
6
|
+
export type Workflow = wf;
|
|
7
|
+
|
|
6
8
|
export type StudentInfo = {
|
|
7
9
|
firstName: string;
|
|
8
10
|
lastName: string;
|
|
@@ -43,7 +45,7 @@ export type ActivityJSData = {
|
|
|
43
45
|
friendlyType: string;
|
|
44
46
|
comments: string | null;
|
|
45
47
|
grading: string | null;
|
|
46
|
-
workflow:
|
|
48
|
+
workflow: Workflow | null | undefined;
|
|
47
49
|
antiCheat?: null | {
|
|
48
50
|
passwordHash?: string | null;
|
|
49
51
|
startLocked: boolean;
|
|
@@ -22,7 +22,6 @@ import tracker from "@capytale/activity.js/backend/capytale/tracker";
|
|
|
22
22
|
|
|
23
23
|
const ActivityJSContext = createContext<ActivitySessionLoaderReturnValue>({
|
|
24
24
|
state: "loading",
|
|
25
|
-
activitySession: null,
|
|
26
25
|
});
|
|
27
26
|
|
|
28
27
|
type ActivityJSProviderProps = PropsWithChildren<{
|
|
@@ -128,16 +127,31 @@ export const ActivityJSProvider: FC<ActivityJSProviderProps> = (props) => {
|
|
|
128
127
|
};
|
|
129
128
|
|
|
130
129
|
export const useActivityJS = () => {
|
|
131
|
-
|
|
130
|
+
const activityJs = useContext(ActivityJSContext);
|
|
131
|
+
if (activityJs.state === "loading") {
|
|
132
|
+
throw new Error("ActivityJS data not loaded");
|
|
133
|
+
}
|
|
134
|
+
if (activityJs.state === "error") {
|
|
135
|
+
throw new Error("Error loading ActivityJS data: " + activityJs.error);
|
|
136
|
+
}
|
|
137
|
+
return activityJs;
|
|
132
138
|
};
|
|
133
139
|
|
|
134
|
-
export const
|
|
140
|
+
export const useActivitySession = () => {
|
|
135
141
|
const activityJs = useActivityJS();
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
142
|
+
return activityJs.activitySession;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export const useActivityBunch = () => {
|
|
146
|
+
const activitySession = useActivitySession();
|
|
147
|
+
const ab = activitySession.activityBunch;
|
|
148
|
+
return ab;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const useActivityJsEssentials = () => {
|
|
152
|
+
const activitySession = useActivitySession();
|
|
153
|
+
const mode = activitySession.mode;
|
|
154
|
+
const ab = activitySession.activityBunch;
|
|
141
155
|
const hasAssignment = !!ab.assignmentNode;
|
|
142
156
|
const getActivityContent = () => {
|
|
143
157
|
return ab.activityNode.content.value as string | null;
|
|
@@ -27,7 +27,7 @@ export const useReset = (props: UseResetProps) => {
|
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
29
|
return async (reload: boolean = true) => {
|
|
30
|
-
if (
|
|
30
|
+
if (activityJs.state !== "loaded") {
|
|
31
31
|
throw new Error("No activity session to reset");
|
|
32
32
|
}
|
|
33
33
|
for (const callback of Object.values(beforeReset)) {
|
|
@@ -9,9 +9,13 @@ import type { ActivityBunchOptions as LoadOptions } from "@capytale/activity.js/
|
|
|
9
9
|
export type { LoadOptions };
|
|
10
10
|
|
|
11
11
|
export type ActivitySessionLoaderReturnValue = {
|
|
12
|
-
state: "loading"
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
state: "loading";
|
|
13
|
+
} | {
|
|
14
|
+
state: "loaded";
|
|
15
|
+
activitySession: ActivitySession;
|
|
16
|
+
} | {
|
|
17
|
+
state: "error";
|
|
18
|
+
error: any;
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
/**
|
|
@@ -32,7 +36,6 @@ export function useActivitySessionLoader(
|
|
|
32
36
|
const callbackW = useHandlerWrapper(callback);
|
|
33
37
|
const [state, setState] = useState<ActivitySessionLoaderReturnValue>({
|
|
34
38
|
state: "loading",
|
|
35
|
-
activitySession: null,
|
|
36
39
|
});
|
|
37
40
|
useEffect(() => {
|
|
38
41
|
let cancelled = false;
|
|
@@ -50,7 +53,6 @@ export function useActivitySessionLoader(
|
|
|
50
53
|
if (cancelled) return;
|
|
51
54
|
setState({
|
|
52
55
|
state: "error",
|
|
53
|
-
activitySession: null,
|
|
54
56
|
error,
|
|
55
57
|
});
|
|
56
58
|
});
|
|
@@ -58,7 +60,6 @@ export function useActivitySessionLoader(
|
|
|
58
60
|
cancelled = true;
|
|
59
61
|
setState({
|
|
60
62
|
state: "loading",
|
|
61
|
-
activitySession: null,
|
|
62
63
|
});
|
|
63
64
|
};
|
|
64
65
|
}, [id, loadOptions?.binaryDataType, loadOptions?.readOnly]);
|
package/src/index.tsx
CHANGED
|
@@ -11,6 +11,8 @@ import { useMode, useWorkflow } from "./hooks";
|
|
|
11
11
|
import { useThemeType } from "./features/theming/hooks";
|
|
12
12
|
import {
|
|
13
13
|
useActivityJS,
|
|
14
|
+
useActivitySession,
|
|
15
|
+
useActivityBunch,
|
|
14
16
|
useActivityJsEssentials,
|
|
15
17
|
} from "./features/activityJS/ActivityJSProvider";
|
|
16
18
|
import {
|
|
@@ -38,6 +40,7 @@ import type {
|
|
|
38
40
|
} from "./features/functionalities/functionalitiesSlice";
|
|
39
41
|
|
|
40
42
|
import type { ActivityMode } from "@capytale/activity.js/activity/activitySession";
|
|
43
|
+
import type { Workflow } from "./features/activityData/activityJsData";
|
|
41
44
|
|
|
42
45
|
export {
|
|
43
46
|
MetaPlayer,
|
|
@@ -49,6 +52,8 @@ export {
|
|
|
49
52
|
useMode,
|
|
50
53
|
useWorkflow,
|
|
51
54
|
useActivityJS,
|
|
55
|
+
useActivitySession,
|
|
56
|
+
useActivityBunch,
|
|
52
57
|
useActivityJsEssentials,
|
|
53
58
|
useNotifyIsDirty,
|
|
54
59
|
useCanSave,
|
|
@@ -66,4 +71,10 @@ export {
|
|
|
66
71
|
useRefreshAttachedFiles,
|
|
67
72
|
Toast,
|
|
68
73
|
};
|
|
69
|
-
export type {
|
|
74
|
+
export type {
|
|
75
|
+
ActivityMode,
|
|
76
|
+
AttachedFileData,
|
|
77
|
+
UploadedFileInfo,
|
|
78
|
+
ToastMessage,
|
|
79
|
+
Workflow,
|
|
80
|
+
};
|