feat: add assessment, privacy and support flows

This commit is contained in:
TakuyaYagam1 committed 2026-10-08 08:08:25 +03:00
1 parent ee3738ee73
commit e4f24fa202
339 files changed
+56454 -1126

No files matched your search

@@ -0,0 +1,5 @@
export { AnswerForm } from "./ui/answer-form";
export { buildAnswerSubmission, emptyAnswerDraft, newIdempotencyKey } from "./model/answer-draft";
export { submitPendingAnswerCommand } from "./model/answer-command";
export type { AnswerDraft, AnswerBuildResult } from "./model/answer-draft";
export type { AnswerCommandOutcome, PendingAnswerCommand } from "./model/answer-command";
@@ -0,0 +1,156 @@
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest";
import { http, HttpResponse } from "msw";
import { setupServer } from "msw/node";
import { ApiRequestError, invalidResponseCode } from "../../../shared/api";
import { AssessmentAttempt } from "../../../shared/api/schemas";
import { submitPendingAnswerCommand, type PendingAnswerCommand } from "./answer-command";
const attemptId = "01928f7a-4a10-7b2c-9d3e-5f6a7b8c9d01";
const server = setupServer();
beforeAll(() => server.listen());
afterEach(() => {
vi.unstubAllGlobals();
server.resetHandlers();
});
afterAll(() => server.close());
const validAttempt: AssessmentAttempt = {
id: attemptId,
version: 2,
kind: "root",
specialization: "backend",
target_grade: "junior",
task_language: "python",
root_attempt_id: null,
chain_deadline: null,
mode: "demo_basic",
state: "in_progress",
versions: { policy_version: 1, bank_version: "bank.1", algorithm_version: "algo.1" },
started_at: "2026-10-08T10:00:00Z",
expires_at: "2026-10-08T11:00:00Z",
sessions: { used: 1, max: 2, idle_timeout_seconds: 1800 },
finished_at: null,
progress: { answered_items: 1, max_items: 2 },
current_item: {
id: "01928f7a-4a10-7b2c-9d3e-5f6a7b8c9d02",
sequence: 2,
prompt: "Сколько?",
content: { format: "number", unit: null },
},
practices: [],
};
describe("assessment answer response validation", () => {
it.each([{}, { id: attemptId, version: 2 }])(
"keeps the exact command retryable when a successful response is incomplete",
async (body) => {
const interceptedFetch = globalThis.fetch;
vi.stubGlobal("fetch", (input: string, init?: RequestInit) =>
interceptedFetch(new URL(input, "http://localhost"), init),
);
const requests: Array<{ body: string | null; key: string | null; csrf: string | null }> = [];
server.use(
http.post(
`http://localhost/api/v1/me/assessment-attempts/${attemptId}/answers`,
async ({ request }) => {
requests.push({
body: await request.text(),
key: request.headers.get("Idempotency-Key"),
csrf: request.headers.get("X-CSRF-Token"),
});
return HttpResponse.json(body, { status: 200 });
},
),
);
const command: PendingAnswerCommand = {
key: "answer-command-key",
body: '{"expected_version":1,"item_id":"item-1","answer":{"format":"number","number":1}}',
itemId: "item-1",
};
const outcome = await submitPendingAnswerCommand(command, attemptId, "csrf-token");
expect(outcome.kind).toBe("retry");
if (outcome.kind !== "retry") return;
expect(outcome.command).toBe(command);
expect(outcome.command).toEqual({
key: "answer-command-key",
body: '{"expected_version":1,"item_id":"item-1","answer":{"format":"number","number":1}}',
itemId: "item-1",
});
expect(outcome.error).toMatchObject({
status: 200,
code: invalidResponseCode,
} satisfies Partial<ApiRequestError>);
expect(requests).toEqual([
{
body: command.body,
key: command.key,
csrf: "csrf-token",
},
]);
},
);
it("accepts a complete server attempt response", async () => {
const interceptedFetch = globalThis.fetch;
vi.stubGlobal("fetch", (input: string, init?: RequestInit) =>
interceptedFetch(new URL(input, "http://localhost"), init),
);
server.use(
http.post(`http://localhost/api/v1/me/assessment-attempts/${attemptId}/answers`, () =>
HttpResponse.json(validAttempt, { status: 200 }),
),
);
const outcome = await submitPendingAnswerCommand(
{
key: "answer-command-key",
body: '{"expected_version":1,"item_id":"item-1","answer":{"format":"number","number":1}}',
itemId: "item-1",
},
attemptId,
"csrf-token",
);
expect(outcome).toEqual({ kind: "accepted", attempt: validAttempt });
});
it("replays the original key and body after a malformed success response", async () => {
const interceptedFetch = globalThis.fetch;
vi.stubGlobal("fetch", (input: string, init?: RequestInit) =>
interceptedFetch(new URL(input, "http://localhost"), init),
);
const requests: Array<{ body: string; key: string | null }> = [];
let responseCount = 0;
server.use(
http.post(
`http://localhost/api/v1/me/assessment-attempts/${attemptId}/answers`,
async ({ request }) => {
requests.push({
body: await request.text(),
key: request.headers.get("Idempotency-Key"),
});
responseCount += 1;
return HttpResponse.json(responseCount === 1 ? {} : validAttempt, { status: 200 });
},
),
);
const original: PendingAnswerCommand = {
key: "same-answer-key",
body: '{"expected_version":1,"item_id":"item-1","answer":{"format":"number","number":1}}',
itemId: "item-1",
};
const first = await submitPendingAnswerCommand(original, attemptId, "csrf-token");
expect(first.kind).toBe("retry");
if (first.kind !== "retry") return;
const second = await submitPendingAnswerCommand(first.command, attemptId, "csrf-token");
expect(second).toEqual({ kind: "accepted", attempt: validAttempt });
expect(requests).toEqual([
{ body: original.body, key: original.key },
{ body: original.body, key: original.key },
]);
});
});
@@ -0,0 +1,41 @@
import { apiRequest } from "../../../shared/api";
import { isOutcomeAmbiguous } from "../../../entities/assessment";
import { getSubmitMyAssessmentAnswerUrl } from "../../../shared/api/endpoints/assessment/assessment";
import {
AssessmentAttempt as assessmentAttemptSchema,
type AssessmentAttempt,
} from "../../../shared/api/schemas";
export type PendingAnswerCommand = { key: string; body: string; itemId: string };
export type AnswerCommandOutcome =
| { kind: "accepted"; attempt: AssessmentAttempt }
| { kind: "retry"; command: PendingAnswerCommand; error: unknown }
| { kind: "rejected"; error: unknown };
export async function submitPendingAnswerCommand(
command: PendingAnswerCommand,
attemptId: string,
csrfToken: string,
): Promise<AnswerCommandOutcome> {
try {
const attempt = await apiRequest<AssessmentAttempt>(
getSubmitMyAssessmentAnswerUrl(attemptId),
{
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": command.key,
"X-CSRF-Token": csrfToken,
},
body: command.body,
},
assessmentAttemptSchema,
);
return { kind: "accepted", attempt };
} catch (error: unknown) {
return isOutcomeAmbiguous(error)
? { kind: "retry", command, error }
: { kind: "rejected", error };
}
}
@@ -0,0 +1,78 @@
import { describe, expect, it } from "vitest";
import type { AssessmentAttempt, AssessmentItem } from "../../../shared/api/schemas";
import { buildAnswerSubmission, emptyAnswerDraft } from "./answer-draft";
const attempt = {
id: "01928f7a-4a10-7b2c-9d3e-5f6a7b8c9d01",
version: 4,
kind: "root",
specialization: "backend",
target_grade: "junior",
task_language: "go",
root_attempt_id: null,
chain_deadline: null,
mode: "demo_basic",
state: "in_progress",
versions: { policy_version: 1, bank_version: "bank.1", algorithm_version: "algo.1" },
started_at: "2026-10-07T10:00:00Z",
expires_at: "2026-10-07T11:00:00Z",
sessions: { used: 1, max: 2, idle_timeout_seconds: 1800 },
finished_at: null,
progress: { answered_items: 0, max_items: 10 },
current_item: null,
practices: [],
} satisfies AssessmentAttempt;
const numberItem = {
id: "01928f7a-4a10-7b2c-9d3e-5f6a7b8c9d02",
sequence: 1,
prompt: "Сколько?",
content: { format: "number", unit: null },
} satisfies AssessmentItem;
describe("assessment answer submission", () => {
it("preserves a decimal JSON token without converting it through JavaScript number", () => {
const token = "254.00000000000000000000000000000000000001";
const result = buildAnswerSubmission(attempt, numberItem, { format: "number", value: token });
expect(result.ok).toBe(true);
if (!result.ok) return;
expect(result.submission).toBeNull();
expect(result.body).toContain(`"number":${token}`);
expect(JSON.parse(result.body)).toMatchObject({
expected_version: attempt.version,
item_id: numberItem.id,
});
});
it.each([" 2", "2,5", "+2", "01", "Infinity", "2 "])(
"rejects a number token that is not valid JSON: %s",
(value) => {
const result = buildAnswerSubmission(attempt, numberItem, { format: "number", value });
expect(result).toMatchObject({ ok: false });
},
);
it("keeps the initial order as a draft and requires a complete permutation", () => {
const item = {
id: numberItem.id,
sequence: 1,
prompt: "Упорядочите",
content: {
format: "order",
elements: [
{ id: "one", text: "Первый" },
{ id: "two", text: "Второй" },
],
},
} satisfies AssessmentItem;
const draft = emptyAnswerDraft(item);
expect(draft).toEqual({ format: "order", elementIds: ["one", "two"] });
expect(buildAnswerSubmission(attempt, item, draft).ok).toBe(true);
expect(
buildAnswerSubmission(attempt, item, { format: "order", elementIds: ["one", "one"] }),
).toMatchObject({ ok: false });
});
});
@@ -0,0 +1,145 @@
import { AssessmentAnswerSubmission } from "../../../shared/api/schemas";
import type {
AssessmentAttempt,
AssessmentItem,
AssessmentAnswerSubmission as AnswerSubmission,
} from "../../../shared/api/schemas";
export type AnswerDraft =
| { format: "choice"; optionIds: string[] }
| { format: "number"; value: string }
| { format: "string"; value: string }
| { format: "order"; elementIds: string[] }
| { format: "find_error"; lineNumbers: number[] }
| { format: "configuration"; value: string }
| { format: "practice"; language: "python" | "go" | null; sourceCode: string };
export type AnswerBuildResult =
{ ok: true; body: string; submission: AnswerSubmission | null } | { ok: false; message: string };
const jsonNumberToken = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
const maxNumberTokenLength = 64;
export function emptyAnswerDraft(item: AssessmentItem): AnswerDraft {
switch (item.content.format) {
case "choice":
return { format: "choice", optionIds: [] };
case "number":
return { format: "number", value: "" };
case "string":
return { format: "string", value: "" };
case "order":
return { format: "order", elementIds: item.content.elements.map(({ id }) => id) };
case "find_error":
return { format: "find_error", lineNumbers: [] };
case "configuration":
return { format: "configuration", value: item.content.initial_config };
case "practice":
return { format: "practice", language: item.content.languages[0] ?? null, sourceCode: "" };
}
}
export function buildAnswerSubmission(
attempt: AssessmentAttempt,
item: AssessmentItem,
draft: AnswerDraft,
): AnswerBuildResult {
if (draft.format !== item.content.format) {
return { ok: false, message: "Формат ответа не совпадает с заданием. Перезагрузите попытку." };
}
if (draft.format === "number" && item.content.format === "number") {
const token = draft.value;
if (token.length === 0) return { ok: false, message: "Введите числовой ответ." };
if (token.length > maxNumberTokenLength || !jsonNumberToken.test(token)) {
return {
ok: false,
message: "Введите число без пробелов и разделителей тысяч. Десятичный разделитель - точка.",
};
}
const body = `{"expected_version":${attempt.version},"item_id":${JSON.stringify(item.id)},"answer":{"format":"number","number":${token}}}`;
return { ok: true, body, submission: null };
}
let answer: AnswerSubmission["answer"] | null = null;
switch (draft.format) {
case "choice":
if (draft.optionIds.length === 0) {
return { ok: false, message: "Выберите ответ." };
}
if (
item.content.format === "choice" &&
!item.content.multiple &&
draft.optionIds.length !== 1
) {
return { ok: false, message: "Выберите один вариант." };
}
answer = { format: "choice", option_ids: [...draft.optionIds] };
break;
case "string":
if (draft.value.length === 0) return { ok: false, message: "Введите ответ." };
if (item.content.format !== "string" || draft.value.length > item.content.max_length) {
return { ok: false, message: "Проверьте длину ответа." };
}
answer = { format: "string", text: draft.value };
break;
case "order":
if (
item.content.format !== "order" ||
draft.elementIds.length !== item.content.elements.length ||
new Set(draft.elementIds).size !== item.content.elements.length ||
item.content.elements.some(({ id }) => !draft.elementIds.includes(id))
) {
return { ok: false, message: "Расположите все элементы в нужном порядке." };
}
answer = { format: "order", element_ids: [...draft.elementIds] };
break;
case "find_error":
if (
item.content.format !== "find_error" ||
draft.lineNumbers.length === 0 ||
draft.lineNumbers.length > item.content.max_selections
) {
return { ok: false, message: "Выберите строки с ошибкой в пределах лимита." };
}
answer = { format: "find_error", line_numbers: [...draft.lineNumbers] };
break;
case "configuration":
if (
item.content.format !== "configuration" ||
draft.value.length === 0 ||
draft.value.length > item.content.max_length
) {
return { ok: false, message: "Введите конфигурацию в пределах указанного лимита." };
}
answer = { format: "configuration", config: draft.value };
break;
case "practice":
if (
item.content.format !== "practice" ||
draft.sourceCode.length === 0 ||
draft.sourceCode.length > item.content.max_source_length ||
(draft.language !== null && !item.content.languages.includes(draft.language))
) {
return { ok: false, message: "Добавьте решение в разрешенном формате." };
}
answer = { format: "practice", language: draft.language, source_code: draft.sourceCode };
break;
}
if (!answer) return { ok: false, message: "Проверьте ответ и повторите отправку." };
const parsed = AssessmentAnswerSubmission.safeParse({
expected_version: attempt.version,
item_id: item.id,
answer,
});
if (!parsed.success) {
return { ok: false, message: "Проверьте ответ и повторите отправку." };
}
return { ok: true, body: JSON.stringify(parsed.data), submission: parsed.data };
}
export function newIdempotencyKey(): string {
return crypto.randomUUID();
}
@@ -0,0 +1,181 @@
.form {
display: grid;
gap: var(--space-4);
min-width: 0;
}
.fields,
.code-lines {
display: grid;
gap: var(--space-3);
min-width: 0;
margin: 0;
padding: var(--space-4);
border: var(--line-thin) solid var(--color-divider);
border-radius: var(--radius-m);
}
.legend,
.code-lines legend {
padding: 0 var(--space-2);
font-weight: var(--font-weight-bold);
}
.options,
.practice {
display: grid;
gap: var(--space-3);
min-width: 0;
}
.option,
.code-line {
display: flex;
align-items: flex-start;
gap: var(--space-3);
min-width: 0;
padding: var(--space-3);
border: var(--line-thin) solid var(--color-border-strong);
border-radius: var(--radius-s);
cursor: pointer;
}
.option input,
.code-line input {
flex: 0 0 auto;
width: 1.2rem;
height: 1.2rem;
margin-block-start: 0.15rem;
accent-color: var(--color-accent);
}
.field {
display: grid;
gap: var(--space-2);
min-width: 0;
font-weight: var(--font-weight-bold);
}
.field input,
.field select,
.field textarea {
width: 100%;
min-width: 0;
padding: var(--space-3);
border: var(--line-thin) solid var(--color-border-strong);
border-radius: var(--radius-s);
color: var(--color-text);
background: var(--color-surface);
font: inherit;
font-weight: var(--font-weight-regular);
}
.field textarea {
resize: vertical;
font-family: var(--font-mono);
line-height: var(--line-height-body);
overflow-wrap: anywhere;
}
.field :is(input, select, textarea):focus-visible,
.option input:focus-visible,
.code-line input:focus-visible {
outline: var(--line-strong) solid var(--color-accent);
outline-offset: 2px;
}
.hint {
margin: 0;
color: var(--color-text-secondary);
font-size: var(--font-size-s);
font-weight: var(--font-weight-regular);
}
.order {
display: grid;
gap: var(--space-3);
margin: 0;
padding: 0;
list-style: none;
}
.order-item {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
gap: var(--space-3);
min-width: 0;
padding: var(--space-3);
border: var(--line-thin) solid var(--color-border-strong);
border-radius: var(--radius-s);
}
.order-actions,
.actions {
display: flex;
flex-wrap: wrap;
gap: var(--space-2);
align-items: center;
}
.code-lines {
padding-inline: var(--space-3);
}
.code-line {
align-items: baseline;
font-family: var(--font-mono);
overflow-wrap: anywhere;
}
.line-number {
flex: 0 0 2.5rem;
color: var(--color-text-secondary);
text-align: end;
user-select: none;
}
.code-line code {
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.examples {
display: grid;
gap: var(--space-2);
min-width: 0;
padding: var(--space-3);
background: var(--color-canvas);
border-radius: var(--radius-s);
}
.examples h3,
.examples p {
margin: 0;
}
.examples pre {
max-width: 100%;
margin: var(--space-1) 0 var(--space-3);
padding: var(--space-2);
overflow-x: auto;
background: var(--color-surface);
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.error {
margin: 0;
color: var(--color-danger);
}
@media (width < 42rem) {
.fields {
padding: var(--space-3);
}
.order-item {
align-items: flex-start;
}
}
@@ -0,0 +1,281 @@
import { useState, type FormEvent } from "react";
import type { AssessmentItem } from "../../../shared/api/schemas";
import { Button } from "../../../shared/ui";
import { emptyAnswerDraft, type AnswerDraft } from "../model/answer-draft";
import styles from "./answer-form.module.css";
type AnswerFormProps = {
item: AssessmentItem;
isSaving: boolean;
retryable: boolean;
errorMessage: string | null;
onSubmit: (draft: AnswerDraft) => void;
onRetry: () => void;
};
export function AnswerForm({
item,
isSaving,
retryable,
errorMessage,
onSubmit,
onRetry,
}: AnswerFormProps) {
const [draft, setDraft] = useState<AnswerDraft>(() => emptyAnswerDraft(item));
const frozen = isSaving || retryable;
function submit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
if (frozen) return;
onSubmit(draft);
}
return (
<form className={styles.form} onSubmit={submit}>
<fieldset className={styles.fields} disabled={frozen}>
<legend className={styles.legend}>Ваш ответ</legend>
<AnswerFields item={item} draft={draft} setDraft={setDraft} />
</fieldset>
{errorMessage ? (
<p className={styles.error} role="alert">
{errorMessage}
</p>
) : null}
<div className={styles.actions}>
{retryable ? (
<Button isBusy={isSaving} onClick={onRetry}>
Повторить отправку того же ответа
</Button>
) : (
<Button type="submit" isBusy={isSaving}>
{isSaving ? "Сохраняем ответ..." : "Отправить ответ"}
</Button>
)}
</div>
</form>
);
}
type AnswerFieldsProps = {
item: AssessmentItem;
draft: AnswerDraft;
setDraft: (draft: AnswerDraft) => void;
};
function AnswerFields({ item, draft, setDraft }: AnswerFieldsProps) {
const content = item.content;
switch (content.format) {
case "choice": {
const selected = draft.format === "choice" ? draft.optionIds : [];
return (
<div className={styles.options}>
{content.options.map((option) => {
const checked = selected.includes(option.id);
return (
<label className={styles.option} key={option.id}>
<input
type={content.multiple ? "checkbox" : "radio"}
name={`answer-${item.id}`}
value={option.id}
checked={checked}
onChange={() => {
const optionIds = content.multiple
? checked
? selected.filter((id) => id !== option.id)
: [...selected, option.id]
: [option.id];
setDraft({ format: "choice", optionIds });
}}
/>
<span>{option.text}</span>
</label>
);
})}
</div>
);
}
case "number":
return (
<label className={styles.field}>
<span>Числовой ответ{content.unit ? `, ${content.unit}` : ""}</span>
<input
autoComplete="off"
inputMode="decimal"
maxLength={64}
name="number-answer"
type="text"
value={draft.format === "number" ? draft.value : ""}
onChange={(event) => setDraft({ format: "number", value: event.currentTarget.value })}
/>
<span className={styles.hint}>
Десятичный разделитель - точка. Введенное число отправляется без округления.
</span>
</label>
);
case "string":
return (
<label className={styles.field}>
<span>Краткий ответ</span>
<input
autoComplete="off"
maxLength={content.max_length}
name="text-answer"
type="text"
value={draft.format === "string" ? draft.value : ""}
onChange={(event) => setDraft({ format: "string", value: event.currentTarget.value })}
/>
<span className={styles.hint}>Не более {content.max_length} символов.</span>
</label>
);
case "order": {
const ids =
draft.format === "order" ? draft.elementIds : content.elements.map(({ id }) => id);
const options = new Map(content.elements.map((element) => [element.id, element.text]));
function move(index: number, offset: -1 | 1) {
const nextIndex = index + offset;
if (nextIndex < 0 || nextIndex >= ids.length) return;
const next = [...ids];
[next[index], next[nextIndex]] = [next[nextIndex] as string, next[index] as string];
setDraft({ format: "order", elementIds: next });
}
return (
<ol className={styles.order} aria-label="Порядок элементов">
{ids.map((id, index) => (
<li className={styles["order-item"]} key={id}>
<span>{options.get(id)}</span>
<div className={styles["order-actions"]}>
<Button
variant="secondary"
disabled={index === 0}
aria-label={`Переместить ${options.get(id)} выше`}
onClick={() => move(index, -1)}
>
Выше
</Button>
<Button
variant="secondary"
disabled={index === ids.length - 1}
aria-label={`Переместить ${options.get(id)} ниже`}
onClick={() => move(index, 1)}
>
Ниже
</Button>
</div>
</li>
))}
</ol>
);
}
case "find_error": {
const selected = draft.format === "find_error" ? draft.lineNumbers : [];
return (
<fieldset className={styles["code-lines"]}>
<legend>Отметьте строки с ошибкой</legend>
{content.lines.map((line) => (
<label className={styles["code-line"]} key={line.number}>
<input
type="checkbox"
checked={selected.includes(line.number)}
onChange={(event) => {
const lineNumbers = event.currentTarget.checked
? [...selected, line.number]
: selected.filter((number) => number !== line.number);
setDraft({ format: "find_error", lineNumbers });
}}
/>
<span className={styles["line-number"]}>{line.number}</span>
<code>{line.text}</code>
</label>
))}
<p className={styles.hint}>Можно отметить не более {content.max_selections} строк.</p>
</fieldset>
);
}
case "configuration":
return (
<label className={styles.field}>
<span>Конфигурация ({content.syntax})</span>
<textarea
autoComplete="off"
maxLength={content.max_length}
name="configuration-answer"
rows={12}
spellCheck={false}
value={draft.format === "configuration" ? draft.value : content.initial_config}
onChange={(event) =>
setDraft({ format: "configuration", value: event.currentTarget.value })
}
/>
<span className={styles.hint}>Не более {content.max_length} символов.</span>
</label>
);
case "practice":
return (
<div className={styles.practice}>
{content.languages.length > 1 ? (
<label className={styles.field}>
<span>Язык решения</span>
<select
value={draft.format === "practice" ? (draft.language ?? "") : ""}
onChange={(event) =>
setDraft({
format: "practice",
language:
event.currentTarget.value === ""
? null
: (event.currentTarget.value as "go" | "python"),
sourceCode: draft.format === "practice" ? draft.sourceCode : "",
})
}
>
<option value="">Выберите язык</option>
{content.languages.map((language) => (
<option key={language} value={language}>
{language === "go" ? "Go" : "Python"}
</option>
))}
</select>
</label>
) : content.languages[0] ? (
<p className={styles.hint}>
Язык решения: {content.languages[0] === "go" ? "Go" : "Python"}.
</p>
) : null}
{content.public_examples.length > 0 ? (
<div className={styles.examples}>
<h3>Примеры</h3>
{content.public_examples.map((example, index) => (
<div key={`${index}-${example.input}`}>
<p>Входные данные</p>
<pre>{example.input}</pre>
<p>Ожидаемый вывод</p>
<pre>{example.expected_output}</pre>
</div>
))}
</div>
) : null}
<label className={styles.field}>
<span>Код решения</span>
<textarea
autoComplete="off"
maxLength={content.max_source_length}
name="practice-answer"
rows={16}
spellCheck={false}
value={draft.format === "practice" ? draft.sourceCode : ""}
onChange={(event) =>
setDraft({
format: "practice",
language:
draft.format === "practice" ? draft.language : (content.languages[0] ?? null),
sourceCode: event.currentTarget.value,
})
}
/>
<span className={styles.hint}>Не более {content.max_source_length} символов.</span>
</label>
</div>
);
}
}