@capytale/meta-player 0.3.11 → 0.3.13
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 +1 -1
- package/src/app.module.scss +1 -0
- package/src/features/activityJS/Saver.tsx +1 -2
- package/src/features/activityJS/hooks.ts +1 -2
- package/src/features/navbar/Countdown.tsx +5 -22
- package/src/features/pedago/InstructionsEditor.tsx +6 -4
- package/src/features/pedago/SharedNotesEditor.tsx +6 -4
- package/src/index.css +21 -0
- package/src/utils/server-clock.ts +42 -0
package/package.json
CHANGED
package/src/app.module.scss
CHANGED
|
@@ -51,8 +51,7 @@ export const useReset = (props: UseResetProps) => {
|
|
|
51
51
|
ab.assignmentNode.binaryData.value = null;
|
|
52
52
|
}
|
|
53
53
|
try {
|
|
54
|
-
|
|
55
|
-
console.log("Save return data", saveData);
|
|
54
|
+
await ab.save();
|
|
56
55
|
|
|
57
56
|
for (const callback of Object.values(afterReset)) {
|
|
58
57
|
try {
|
|
@@ -6,6 +6,7 @@ import { useAppSelector } from "../../app/hooks";
|
|
|
6
6
|
import { selectIsDirty, selectMode } from "../activityData/activityDataSlice";
|
|
7
7
|
import { Button } from "primereact/button";
|
|
8
8
|
import { useSave } from "../activityData/hooks";
|
|
9
|
+
import serverClock from "../../utils/server-clock";
|
|
9
10
|
|
|
10
11
|
// TODO use https://capytale2.ac-paris.fr/vanilla/time-s.php
|
|
11
12
|
// https://forge.apps.education.fr/capytale/activity-js/-/blob/main/src/backend/capytale/clock.ts?ref_type=heads
|
|
@@ -47,8 +48,7 @@ const Countdown: FC = () => {
|
|
|
47
48
|
}}
|
|
48
49
|
>
|
|
49
50
|
<Button
|
|
50
|
-
severity="
|
|
51
|
-
outlined
|
|
51
|
+
severity="danger"
|
|
52
52
|
onClick={() => {
|
|
53
53
|
shouldSaveAt30s.current = false;
|
|
54
54
|
toast.current?.clear();
|
|
@@ -56,7 +56,7 @@ const Countdown: FC = () => {
|
|
|
56
56
|
>
|
|
57
57
|
Ne pas sauvegarder (danger)
|
|
58
58
|
</Button>
|
|
59
|
-
<Button severity="
|
|
59
|
+
<Button severity="success" onClick={save}>
|
|
60
60
|
Sauvegarder maintenant
|
|
61
61
|
</Button>
|
|
62
62
|
</div>
|
|
@@ -116,25 +116,8 @@ const Countdown: FC = () => {
|
|
|
116
116
|
if (!deadline) {
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
const deadlineUTC =
|
|
120
|
-
|
|
121
|
-
deadline.getMonth(),
|
|
122
|
-
deadline.getDate(),
|
|
123
|
-
deadline.getHours(),
|
|
124
|
-
deadline.getMinutes(),
|
|
125
|
-
deadline.getSeconds(),
|
|
126
|
-
deadline.getMilliseconds(),
|
|
127
|
-
);
|
|
128
|
-
const now = new Date();
|
|
129
|
-
const nowUTC = Date.UTC(
|
|
130
|
-
now.getFullYear(),
|
|
131
|
-
now.getMonth(),
|
|
132
|
-
now.getDate(),
|
|
133
|
-
now.getHours(),
|
|
134
|
-
now.getMinutes(),
|
|
135
|
-
now.getSeconds(),
|
|
136
|
-
now.getMilliseconds(),
|
|
137
|
-
);
|
|
119
|
+
const deadlineUTC = deadline.getTime();
|
|
120
|
+
const nowUTC = serverClock.now();
|
|
138
121
|
const newDiffMs = deadlineUTC - nowUTC;
|
|
139
122
|
setDiffMs(newDiffMs);
|
|
140
123
|
if (mode !== "assignment") {
|
|
@@ -52,10 +52,12 @@ const InstructionsEditor: React.FC = forwardRef((_props, ref) => {
|
|
|
52
52
|
{instructionsType === "none" && (
|
|
53
53
|
<>
|
|
54
54
|
<p>Pas de consigne.</p>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
{mode === "create" && (
|
|
56
|
+
<Button
|
|
57
|
+
label="Créer une consigne"
|
|
58
|
+
onClick={() => dispatch(setInstructionsType("rich"))}
|
|
59
|
+
/>
|
|
60
|
+
)}
|
|
59
61
|
</>
|
|
60
62
|
)}
|
|
61
63
|
{instructionsType === "rich" && (
|
|
@@ -48,10 +48,12 @@ const SharedNotesEditor: React.FC = forwardRef((_props, ref) => {
|
|
|
48
48
|
{sharedNotesType === "none" && (
|
|
49
49
|
<>
|
|
50
50
|
<p>Pas de notes partagées.</p>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
{mode === "create" && (
|
|
52
|
+
<Button
|
|
53
|
+
label="Créer des notes partagées"
|
|
54
|
+
onClick={() => dispatch(setSharedNotesType("rich"))}
|
|
55
|
+
/>
|
|
56
|
+
)}
|
|
55
57
|
<div style={{ textAlign: "start", padding: "16px" }}>
|
|
56
58
|
<h3>Que sont les notes partagées ?</h3>
|
|
57
59
|
<p>
|
package/src/index.css
CHANGED
|
@@ -12,12 +12,32 @@ code {
|
|
|
12
12
|
monospace;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
html {
|
|
16
|
+
overscroll-behavior: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
html,
|
|
16
20
|
body,
|
|
17
21
|
#root {
|
|
18
22
|
height: 100%;
|
|
19
23
|
}
|
|
20
24
|
|
|
25
|
+
.p-splitter-horizontal > .p-splitter-gutter {
|
|
26
|
+
width: 6px !important;
|
|
27
|
+
}
|
|
28
|
+
.p-splitter-vertical > .p-splitter-gutter {
|
|
29
|
+
height: 6px !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@media (pointer: coarse) {
|
|
33
|
+
.p-splitter-horizontal > .p-splitter-gutter {
|
|
34
|
+
width: 12px !important;
|
|
35
|
+
}
|
|
36
|
+
.p-splitter-vertical > .p-splitter-gutter {
|
|
37
|
+
height: 12px !important;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
21
41
|
.p-splitter-gutter {
|
|
22
42
|
background-color: var(--surface-200);
|
|
23
43
|
}
|
|
@@ -94,6 +114,7 @@ body,
|
|
|
94
114
|
|
|
95
115
|
.anti-cheat-content {
|
|
96
116
|
height: 100vh;
|
|
117
|
+
height: 100dvh;
|
|
97
118
|
width: 100vw;
|
|
98
119
|
overflow: hidden;
|
|
99
120
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
async function getSeverTime() {
|
|
2
|
+
const res = await fetch("/vanilla/time-s.php");
|
|
3
|
+
return parseInt(await res.text()) * 1000;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
class SeverClock {
|
|
7
|
+
private offset: number;
|
|
8
|
+
private lastSync: number;
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
this.offset = 0;
|
|
12
|
+
this.lastSync = 0;
|
|
13
|
+
this.sync();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async sync() {
|
|
17
|
+
const offsets = [];
|
|
18
|
+
for (let i = 0; i < 3; i++) {
|
|
19
|
+
const serverTime = await getSeverTime();
|
|
20
|
+
const localTime = Date.now();
|
|
21
|
+
offsets.push(serverTime - localTime);
|
|
22
|
+
}
|
|
23
|
+
this.offset = Math.max(...offsets);
|
|
24
|
+
this.lastSync = Date.now();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
now() {
|
|
28
|
+
return Date.now() + this.offset;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get lastSyncTime() {
|
|
32
|
+
return this.lastSync;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get offsetTime() {
|
|
36
|
+
return this.offset;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const serverClock = new SeverClock();
|
|
41
|
+
|
|
42
|
+
export default serverClock;
|