feat(assessment): add the review band of attempt signals and the disclosed collector

This commit is contained in:
shira committed 2026-10-08 23:04:57 +03:00
1 parent 68286af8b7
commit b3c6dc870b
124 files changed
+13522 -633

No files matched your search

@@ -32,6 +32,7 @@ import type {
AssessmentQualifiedResult,
AssessmentResult,
AssessmentSessions,
AssessmentSignalNotice,
AssessmentSignalReceipt,
AssessmentUncertainty,
BasicScore,
@@ -48,6 +49,10 @@ import type {
export const getGetMyAssessmentAvailabilityResponseMock = (overrideResponse: Partial<Extract<AssessmentAvailability, object>> = {}): AssessmentAvailability => ({specializations: Array.from({ length: faker.number.int({min: 1, max: 2}) }, (_, i) => i + 1).map(() => ({specialization: faker.helpers.arrayElement(['backend','frontend','mobile','network_engineer','devops_sre','data_analyst','ds_ml','information_security','qa'] as const), confirmed_grade: faker.helpers.arrayElement([faker.helpers.arrayElement(['intern','junior','middle','senior'] as const),null,]), active_attempt_id: faker.helpers.arrayElement([faker.string.uuid(), null]), grades: Array.from({ length: faker.number.int({min: 1, max: 10}) }, (_, i) => i + 1).map(() => ({grade: faker.helpers.arrayElement(['intern','junior','middle','senior'] as const), status: faker.helpers.arrayElement(['available','active_attempt','cooldown','insufficient_bank'] as const), mode: faker.helpers.arrayElement([faker.helpers.arrayElement(['demo_basic','adaptive'] as const),null,]), available_at: faker.helpers.arrayElement([faker.date.past().toISOString().slice(0, 19) + 'Z',null,]), time_limit_seconds: faker.helpers.arrayElement([faker.number.int({min: 1}), null]), max_sessions: faker.helpers.arrayElement([faker.number.int({min: 1, max: 10}), null]), max_items: faker.helpers.arrayElement([faker.number.int({min: 1, max: 100}), null]), practice_required: faker.helpers.arrayElement([faker.datatype.boolean(), null])}))})), ...overrideResponse})
export const getGetMyAssessmentSignalNoticeResponseMock = (overrideResponse: Partial<Extract<AssessmentSignalNotice, object>> = {}): AssessmentSignalNotice => ({notice_version: faker.number.int({min: 1, max: 2147483647}), acknowledged: faker.datatype.boolean(), acknowledged_at: faker.helpers.arrayElement([faker.date.past().toISOString().slice(0, 19) + 'Z',null,]), ...overrideResponse})
export const getAcknowledgeMyAssessmentSignalNoticeResponseMock = (overrideResponse: Partial<Extract<AssessmentSignalNotice, object>> = {}): AssessmentSignalNotice => ({notice_version: faker.number.int({min: 1, max: 2147483647}), acknowledged: faker.datatype.boolean(), acknowledged_at: faker.helpers.arrayElement([faker.date.past().toISOString().slice(0, 19) + 'Z',null,]), ...overrideResponse})
export const getCreateMyAssessmentAttemptResponseAssessmentSessionsMock = (overrideResponse: Partial<AssessmentSessions> = {}): AssessmentSessions => ({...{used: faker.number.int({min: 1, max: 10}), max: faker.number.int({min: 1, max: 10}), idle_timeout_seconds: faker.number.int({min: 60, max: 86400})}, ...overrideResponse});
export const getCreateMyAssessmentAttemptResponseChoiceItemContentMock = (overrideResponse: Partial<ChoiceItemContent> = {}): ChoiceItemContent => ({...{format: faker.helpers.arrayElement(['choice'] as const), options: Array.from({ length: faker.number.int({min: 2, max: 10}) }, (_, i) => i + 1).map(() => ({id: fakeFromPattern("^[A-Za-z0-9_-]+$", {minLength: 1, maxLength: 32}), text: faker.string.alpha({length: {min: 1, max: 2000}})})), multiple: faker.datatype.boolean()}, ...overrideResponse});
@@ -215,6 +220,30 @@ export const getGetMyAssessmentAvailabilityMockHandler = (overrideResponse?: Ass
}, options)
}
export const getGetMyAssessmentSignalNoticeMockHandler = (overrideResponse?: AssessmentSignalNotice | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<AssessmentSignalNotice> | AssessmentSignalNotice), options?: RequestHandlerOptions) => {
return http.get('*/api/v1/me/assessment-signal-notice', async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
return HttpResponse.json(overrideResponse !== undefined
? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse)
: getGetMyAssessmentSignalNoticeResponseMock(),
{ status: 200
})
}, options)
}
export const getAcknowledgeMyAssessmentSignalNoticeMockHandler = (overrideResponse?: AssessmentSignalNotice | ((info: Parameters<Parameters<typeof http.put>[1]>[0]) => Promise<AssessmentSignalNotice> | AssessmentSignalNotice), options?: RequestHandlerOptions) => {
return http.put('*/api/v1/me/assessment-signal-notice', async (info: Parameters<Parameters<typeof http.put>[1]>[0]) => {
return HttpResponse.json(overrideResponse !== undefined
? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse)
: getAcknowledgeMyAssessmentSignalNoticeResponseMock(),
{ status: 200
})
}, options)
}
export const getCreateMyAssessmentAttemptMockHandler = (overrideResponse?: AssessmentAttempt | ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Promise<AssessmentAttempt> | AssessmentAttempt), options?: RequestHandlerOptions) => {
return http.post('*/api/v1/me/assessment-attempts', async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
@@ -300,6 +329,8 @@ export const getGetMyAssessmentResultMockHandler = (overrideResponse?: Assessmen
}
export const getAssessmentMock = () => [
getGetMyAssessmentAvailabilityMockHandler(),
getGetMyAssessmentSignalNoticeMockHandler(),
getAcknowledgeMyAssessmentSignalNoticeMockHandler(),
getCreateMyAssessmentAttemptMockHandler(),
getGetMyAssessmentAttemptMockHandler(),
getStartMyAssessmentAttemptSessionMockHandler(),
@@ -33,6 +33,8 @@ import type {
AssessmentFinalizeConflictProblem,
AssessmentResult,
AssessmentSignalBatch,
AssessmentSignalNotice,
AssessmentSignalNoticeAcknowledgement,
AssessmentSignalReceipt,
CreateMyAssessmentAttemptHeaders,
FinalizeMyAssessmentAttemptHeaders,
@@ -170,7 +172,206 @@ export function useGetMyAssessmentAvailability<TData = Awaited<ReturnType<typeof
export const getCreateMyAssessmentAttemptUrl = () => {
export const getGetMyAssessmentSignalNoticeUrl = () => {
return `/api/v1/me/assessment-signal-notice`
}
/**
* Requires the session cookie of a candidate account with a confirmed email; the candidate comes from the session. Returns the notice version that the server requires now and whether this candidate acknowledged it. The notice lists the signals that are collected during a real assessment attempt and states that images, sound, and clipboard contents are not collected. Client signals are the time away from the tab or window, copy, paste and cut with a size only, and exits from fullscreen mode. Server signals are the response time of each item measured by the server, a change of network address during the attempt, parallel sessions, and the comparison of answers to variants of the same task by candidates. The server stores for these only one-way keyed digests: it stores no network address, no session token, and no answer text. Client signals are stored only while the C3 consent is current. The client shows it before a real attempt starts and does not start the attempt until the notice is acknowledged.
*
* The acknowledgement is stored on the server per account and notice version, so it survives a reload and a new browser. It is not a consent and never changes C3: the signal operation still requires a current C3 consent, and an unacknowledged notice does not make that operation fail. The demo_express training mode collects no signals and needs no acknowledgement.
*
* A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account or an unconfirmed email answers 403 forbidden.
* @summary Read whether the current candidate acknowledged the signal notice.
*/
export const getMyAssessmentSignalNotice = async ( options?: Parameters<typeof apiRequest>[1]): Promise<AssessmentSignalNotice> => {
return apiRequest<AssessmentSignalNotice>(getGetMyAssessmentSignalNoticeUrl(),
{
...options,
method: 'GET'
}
);}
export const getGetMyAssessmentSignalNoticeQueryKey = () => {
return [
`/api/v1/me/assessment-signal-notice`
] as const;
}
export const getGetMyAssessmentSignalNoticeQueryOptions = <TData = Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>, TError = ErrorType<Problem>>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
) => {
const {query: queryOptions, request: requestOptions} = options ?? {};
const queryKey = queryOptions?.queryKey ?? getGetMyAssessmentSignalNoticeQueryKey();
const queryFn: QueryFunction<Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>> = ({ signal }) => getMyAssessmentSignalNotice({ signal, ...requestOptions });
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}
export type GetMyAssessmentSignalNoticeQueryResult = NonNullable<Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>>
export type GetMyAssessmentSignalNoticeQueryError = ErrorType<Problem>
export function useGetMyAssessmentSignalNotice<TData = Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>, TError = ErrorType<Problem>>(
options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>, TError, TData>> & Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>,
TError,
Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetMyAssessmentSignalNotice<TData = Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>, TError = ErrorType<Problem>>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>, TError, TData>> & Pick<
UndefinedInitialDataOptions<
Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>,
TError,
Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetMyAssessmentSignalNotice<TData = Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>, TError = ErrorType<Problem>>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
* @summary Read whether the current candidate acknowledged the signal notice.
*/
export function useGetMyAssessmentSignalNotice<TData = Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>, TError = ErrorType<Problem>>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyAssessmentSignalNotice>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
const queryOptions = getGetMyAssessmentSignalNoticeQueryOptions(options)
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
return withQueryKey(query, queryOptions.queryKey);
}
export const getAcknowledgeMyAssessmentSignalNoticeUrl = () => {
return `/api/v1/me/assessment-signal-notice`
}
/**
* Requires the session cookie of a candidate account with a confirmed email, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. The body carries the notice version the candidate was shown. The server stores the acknowledgement for the account and that version; the response carries the server time of the first acknowledgement.
*
* The operation needs no Idempotency-Key: it is idempotent. Repeating it for an acknowledged version changes nothing, keeps the first time, and answers 200, so a retry after a lost response succeeds. A version other than the one the server requires answers 409 state_conflict and stores nothing; the client reads the notice again.
*
* The acknowledgement is not a consent. It does not grant, replace, or hide C3, and it does not affect the signal operation or any score, category, or quota. The body carries no signal, answer, or clipboard data.
*
* Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account (403 forbidden), then the version (409).
* @summary Record that the current candidate read the signal notice.
*/
export const acknowledgeMyAssessmentSignalNotice = async (assessmentSignalNoticeAcknowledgement: AssessmentSignalNoticeAcknowledgement, options?: Parameters<typeof apiRequest>[1]): Promise<AssessmentSignalNotice> => {
const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {
if (!h) return {};
if (h instanceof Headers) return Object.fromEntries(h.entries());
if (Symbol.iterator in h) {
return Object.fromEntries(
Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),
);
}
const headers: Record<string, string | readonly string[]> = {};
for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {
if (value !== undefined) headers[name] = value;
}
return headers;
};
return apiRequest<AssessmentSignalNotice>(getAcknowledgeMyAssessmentSignalNoticeUrl(),
{
...options,
method: 'PUT',
headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },
body: JSON.stringify(assessmentSignalNoticeAcknowledgement)
}
);}
export const getAcknowledgeMyAssessmentSignalNoticeMutationKey = () => ['acknowledgeMyAssessmentSignalNotice'] as const;
export const getAcknowledgeMyAssessmentSignalNoticeMutationOptions = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof acknowledgeMyAssessmentSignalNotice>>, TError,AcknowledgeMyAssessmentSignalNoticeMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
): UseMutationOptions<Awaited<ReturnType<typeof acknowledgeMyAssessmentSignalNotice>>, TError,AcknowledgeMyAssessmentSignalNoticeMutationVariables, TContext> => {
const mutationKey = getAcknowledgeMyAssessmentSignalNoticeMutationKey();
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
const mutationFn: MutationFunction<Awaited<ReturnType<typeof acknowledgeMyAssessmentSignalNotice>>, AcknowledgeMyAssessmentSignalNoticeMutationVariables> = (props) => {
const {data} = props ?? {};
return acknowledgeMyAssessmentSignalNotice(data,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type AcknowledgeMyAssessmentSignalNoticeMutationResult = NonNullable<Awaited<ReturnType<typeof acknowledgeMyAssessmentSignalNotice>>>
export type AcknowledgeMyAssessmentSignalNoticeMutationBody = AssessmentSignalNoticeAcknowledgement
export type AcknowledgeMyAssessmentSignalNoticeMutationError = ErrorType<Problem>
export type AcknowledgeMyAssessmentSignalNoticeMutationVariables = {data: AssessmentSignalNoticeAcknowledgement}
/**
* @summary Record that the current candidate read the signal notice.
*/
export const useAcknowledgeMyAssessmentSignalNotice = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof acknowledgeMyAssessmentSignalNotice>>, TError,AcknowledgeMyAssessmentSignalNoticeMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof acknowledgeMyAssessmentSignalNotice>>,
TError,
AcknowledgeMyAssessmentSignalNoticeMutationVariables,
TContext
> => {
return useMutation(getAcknowledgeMyAssessmentSignalNoticeMutationOptions(options), queryClient);
}
export const getCreateMyAssessmentAttemptUrl = () => {