feat(assessment): add the review band of attempt signals and the disclosed collector
This commit is contained in:
1 parent
68286af8b7
commit
b3c6dc870b
124 files changed
+13522
-633
No files matched your search
@@ -46,6 +46,12 @@ import {
|
||||
submitPendingAnswerCommand,
|
||||
} from "../../../features/answer-assessment";
|
||||
import type { AnswerDraft, PendingAnswerCommand } from "../../../features/answer-assessment";
|
||||
import {
|
||||
SignalNoticeDialog,
|
||||
shouldCollectSignals,
|
||||
useAssessmentSignals,
|
||||
useSignalNoticeGate,
|
||||
} from "../../../features/assessment-signals";
|
||||
import attemptStyles from "./assessment-attempt-page.module.css";
|
||||
|
||||
type PendingFinalize = { key: string; body: AssessmentFinalization };
|
||||
@@ -107,6 +113,28 @@ function AssessmentAttemptContent({ attemptId }: { attemptId: string }) {
|
||||
queryClient,
|
||||
});
|
||||
const [workReady, setWorkReady] = useState(false);
|
||||
const collectsSignals = Boolean(attempt && attempt.kind !== "demo_express");
|
||||
const signalNotice = useSignalNoticeGate({
|
||||
actor,
|
||||
queryClient,
|
||||
enabled: actorReady && collectsSignals,
|
||||
});
|
||||
// Signals are collected only while a real attempt is being worked on. The hook
|
||||
// renders nothing and never waits for the network.
|
||||
useAssessmentSignals({
|
||||
attemptId,
|
||||
itemId: attempt?.current_item?.id ?? null,
|
||||
csrfToken: actor?.csrf_token ?? "",
|
||||
enabled: Boolean(
|
||||
attempt &&
|
||||
shouldCollectSignals({
|
||||
ready: actorReady,
|
||||
kind: attempt.kind,
|
||||
workReady,
|
||||
terminal: isTerminal(attempt),
|
||||
}),
|
||||
),
|
||||
});
|
||||
const [resumeBusy, setResumeBusy] = useState(false);
|
||||
const [pendingResume, setPendingResume] = useState<{ key: string; version: number } | null>(null);
|
||||
const [pendingAnswer, setPendingAnswer] = useState<PendingAnswerCommand | null>(null);
|
||||
@@ -529,7 +557,19 @@ function AssessmentAttemptContent({ attemptId }: { attemptId: string }) {
|
||||
Продолжение сверит актуальную версию с сервером. При перезагрузке задания не
|
||||
меняются, а ответ не отправляется повторно автоматически.
|
||||
</p>
|
||||
<Button isBusy={resumeBusy} onClick={() => void resumeWork()}>
|
||||
{signalNotice.checkError ? (
|
||||
<p className={attemptStyles.error} role="alert">
|
||||
{signalNotice.checkError}
|
||||
</p>
|
||||
) : null}
|
||||
<Button
|
||||
isBusy={resumeBusy}
|
||||
onClick={() =>
|
||||
void (collectsSignals
|
||||
? signalNotice.guard(() => void resumeWork())
|
||||
: resumeWork())
|
||||
}
|
||||
>
|
||||
{resumeBusy
|
||||
? "Проверяем попытку..."
|
||||
: pendingResume
|
||||
@@ -630,6 +670,7 @@ function AssessmentAttemptContent({ attemptId }: { attemptId: string }) {
|
||||
</ButtonLink>
|
||||
</div>
|
||||
</div>
|
||||
<SignalNoticeDialog {...signalNotice.dialog} />
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user