feat(assessment): keep real attempts in fullscreen and protect the task text
This commit is contained in:
1 parent
56dcf32f8c
commit
efa41d5967
46 files changed
+1940
-72
No files matched your search
@@ -69,12 +69,16 @@ The attempt screen focuses on the item: a strip above it names the attempt and s
|
||||
|
||||
The `Idempotency-Key` of the express start is kept in the tab's sessionStorage per account until the run is finished or expired, and for 24 hours at most. When a new start gets 409 `state_conflict`, the page repeats the start with the key of the active run, and the server returns the stored 201 with that attempt: an unfinished demonstration continues after a reload. The key of a start with an unknown outcome (no response, 5xx) is kept and repeated as well. Without a key (another browser, a closed tab, blocked storage), the screen explains that the demonstration ends by itself within 5 minutes of its start.
|
||||
|
||||
Before a real attempt starts, the screen shows a dialog that lists the signals. The browser records tab or window switches, copy, paste and cut, and fullscreen exits; the server measures the answer time per item, a change of network address during the attempt, parallel sessions, and the match of answer digests with other candidates' answers. The dialog states that image, sound, and clipboard contents are not collected, that addresses and session tokens are not stored (only one-way keyed digests), and that browser events are stored only while the C3 consent is current. The attempt cannot start without confirmation: closing the dialog or pressing Escape starts nothing. The confirmation is stored on the server (`/me/assessment-signal-notice`) for the text version, so a reload or a new browser does not ask again; the same dialog opens when an older attempt that was created without the confirmation is resumed. It is a record of being informed, not a consent: C3 stays separate.
|
||||
Before a real attempt starts, the screen shows a dialog that lists the signals. The browser records tab or window switches, copy, paste and cut, and fullscreen exits; the server measures the answer time per item, a change of network address during the attempt, parallel sessions, and the match of answer digests with other candidates' answers. The dialog states that image, sound, and clipboard contents are not collected, that addresses and session tokens are not stored (only one-way keyed digests), and that browser events are stored only while the C3 consent is current. The attempt cannot start without confirmation: closing the dialog or pressing Escape starts nothing. The dialog also lists the measures the page applies during the attempt (fullscreen, covering the task when the candidate leaves, blocks on copying, selecting, and printing the task text, the paste rule, and a watermark that is announced as planned and not used yet). This is notice text version 2; an acknowledgement of version 1 does not count for it. The confirmation is stored on the server (`/me/assessment-signal-notice`) for the text version, so a reload or a new browser does not ask again; the same dialog opens when an older attempt that was created without the confirmation is resumed. It is a record of being informed, not a consent: C3 stays separate.
|
||||
|
||||
During a real attempt, `features/assessment-signals` collects the disclosed signals: focus loss with its duration, copy, paste and cut with a size only, and fullscreen exit. The listeners are passive, block nothing, and show nothing. Events go in batches (every 10 seconds, when the tab is hidden, or at 20 queued events), and each batch keeps one `Idempotency-Key` across retries. When the page is closed (`pagehide`) or the collector unmounts, what remains is sent in one last request with `keepalive`, so closing the tab does not lose the last seconds of events; the result of that request is not awaited and not retried. A network failure never affects answer submission: a failed batch is sent again with the same key and body after a growing pause and is dropped after the attempt limit. A server refusal (no C3, finished attempt) stops collection. The demonstration run collects no signals.
|
||||
During a real attempt, `features/assessment-signals` collects the disclosed signals: focus loss with its duration, copy, paste and cut with a size only, and fullscreen exit. The collector's listeners are passive, block nothing, and show nothing (the measures of the next paragraph are a separate feature and do not depend on it). Events go in batches (every 10 seconds, when the tab is hidden, or at 20 queued events), and each batch keeps one `Idempotency-Key` across retries. When the page is closed (`pagehide`) or the collector unmounts, what remains is sent in one last request with `keepalive`, so closing the tab does not lose the last seconds of events; the result of that request is not awaited and not retried. A network failure never affects answer submission: a failed batch is sent again with the same key and body after a growing pause and is dropped after the attempt limit. A server refusal (no C3, finished attempt) stops collection. The demonstration run collects no signals.
|
||||
|
||||
Clipboard contents and typed text are never read into a signal or sent. The paste size comes from the `paste` event: file sizes (`File.size`) plus the UTF-8 length of the plain-text item of `clipboardData`; the string lives in one local variable during the count and is not kept. The Clipboard API (`navigator.clipboard`) is not used. The copy and cut size is the selection length in UTF-16 code units taken from the field offsets without reading its value; when the active field has no numeric offsets the size is zero and the page selection is not read. It is an approximate size, not an exact byte count. The answer time per item is measured by the server and not sent by the client. Event timestamps are moved to server time: the client remembers the difference between the device clock and the `Date` header of API responses, because the server rejects a whole batch when a timestamp is more than five minutes from its own clock. Durations use the device clock and do not depend on that difference. Browser signals are easy to forge and false positives are possible, so they are only a hint for a review.
|
||||
|
||||
`features/assessment-lockdown` keeps a real attempt in fullscreen and hides the task when the candidate leaves it. The click on "Start or continue" requests fullscreen: the request has to be made inside the click, before the asynchronous notice check, because the browser accepts it only with a user gesture; closing the notice without confirming leaves fullscreen again. While the work runs, the task is covered when fullscreen is exited, the tab is hidden, or the window loses focus (`fullscreenchange`, `visibilitychange`, `focus` and `blur`). The cover replaces the task instead of blurring it: the prompt, the options, and the answer controls are not rendered, so they are not in the DOM, in a screenshot of the page, or in the accessibility tree. The answer form stays mounted and renders nothing, so the draft survives (and the sessionStorage copy of the draft is still kept). The timer stays the server's and stays on screen. After leaving fullscreen the candidate continues with a button, which is the user gesture the browser needs to enter fullscreen again; leaving only the tab or the window needs no click. These exits are recorded by the collector above (`fullscreen_exit`, `focus_loss`); the cover records nothing itself. A browser without element fullscreen (iPhone Safari) or one that refuses the request gets an information notice and takes the test with the tab watch alone (`fallback` `unsupported` or `denied`), so the screen is never a dead end. The express run and a finished attempt are not protected, and leaving the page or finishing the attempt leaves fullscreen.
|
||||
|
||||
The same panel (`ProtectedRegion`) keeps the task text of a real attempt from being taken out. The text cannot be selected (`user-select`, with the `-webkit-` form that Safari still needs, and a cancelled `selectstart`), the context menu and drag are cancelled on it, copy and cut are cancelled when the target or the selection reaches into the panel (the clipboard text is set to an empty string), and `@media print` hides the panel with the task, the options, and the answer fields. Fields are exempt: a text field keeps selection, its own context menu, and copy and cut of the candidate's own text. Paste into answer fields is refused (the `paste` event, and `beforeinput` of the paste kind), the screen says so with a short status that goes away on the next input, and dropping text into a field is refused everywhere. The code editor of a practice item carries `data-paste="allowed"`: pasting works there and its size goes out as the existing `paste` signal. The collector sees every paste, copy, and cut, including the refused ones, because the guard cancels the default action and never stops propagation, so a refused paste is still a signal with a size. The text stays in the page for screen readers (no canvas, no image text), typing and the focus order are untouched, and the express run is not restricted. These measures stop the casual route only: a screenshot, a second device, or a browser extension still takes the task out, and a paste by an on-screen keyboard that inserts text as typing is not visible to the page.
|
||||
|
||||
## Candidate results
|
||||
|
||||
`/candidate/results` lists the completed real assessments of the current candidate (`GET /me/assessment-results`, 20 records per page; the cursor comes only from the server response and is never built on the client). `/candidate/results/:attemptId` opens one record by a direct URL. Both screens read data only for a confirmed candidate session: query keys include the account identifier and the session token, data does not outlive the screen (`gcTime: 0`) and is removed when the session changes or ends. A 401, 403, or 404 response shows an "unavailable" screen without data and does not reveal whether another candidate's result exists; the assessment cache is cleared only on 401, while a network or 5xx failure offers a retry and is not treated as lost access. A failed background refresh keeps the data that was already loaded and says so. Dates are shown in the browser time zone with its name. "Show more" moves the focus to the first new row and announces how many were loaded. Loading, empty history, and error states with retry exist. A failed attempt after a successful one, adaptive estimate values, retry dates, and missing-field cases are covered by unit contract fixtures because the stand cannot produce them; the e2e test checks the shape of the flow (a real result, the express run, ownership, sign-out; the session ends through the API, not through the account menu, because the menu reloads the page). By contract, express tests are not part of the history; their result opens from the attempt screen or by a direct URL and is captioned "Экспресс-тест без грейда" (express test without a grade).
|
||||
|
||||
Reference in new issue
Block a user