feat(trainer): P4 — авторинг задач учителем + раздача классу
- POST /api/practice/author: учитель пишет story/lhs/rhs/answer → та же проверка подстановкой (validateAndVerify) → пул; не сходится → 422 - POST /api/practice/assign: выдать тему классу → durable pushNotif каждому ученику (ссылка /trainer); владелец/админ, чужой → 403 - клиент: LS.practiceAuthor/Assign; в теме «Текстовые задачи» учителю кнопки «Своя задача» (модалка-форма) и «Выдать классу» (пикер классов) - тесты: author (валид→пул, неверный→422, ученик→403), assign (владелец уведомляет, чужой→403) — practice 19/19 + practice-gen 16/16 - смоук страницы 27/27; план P4 → DONE (lean: ручной авторинг + раздача, без полного DSL-конструктора) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -106,6 +106,27 @@ describe('/api/practice pool endpoints', () => {
|
||||
assert.equal(res.status, 400, `got ${res.status}`);
|
||||
});
|
||||
|
||||
it('POST /author учителем (валидная) → в пул', async () => {
|
||||
const res = await inject('POST', '/api/practice/author',
|
||||
{ topic: 'word-linear', story: 'Задача от учителя', lhs: '2*x + 1', rhs: '7', answer: 3 }, teacher);
|
||||
assert.equal(res.status, 200, `got ${res.status}`);
|
||||
assert.equal(res.body.ok, true);
|
||||
assert.equal(res.body.problem.answer, 3);
|
||||
assert.equal(res.body.problem.kind, 'word');
|
||||
});
|
||||
|
||||
it('POST /author с неверным корнем → 422 (в пул не попадёт)', async () => {
|
||||
const res = await inject('POST', '/api/practice/author',
|
||||
{ topic: 'word-linear', story: 'X', lhs: '2*x + 1', rhs: '7', answer: 5 }, teacher);
|
||||
assert.equal(res.status, 422, `got ${res.status}`);
|
||||
});
|
||||
|
||||
it('POST /author ученику запрещён (403)', async () => {
|
||||
const res = await inject('POST', '/api/practice/author',
|
||||
{ topic: 'word-linear', story: 'X', lhs: '2*x + 1', rhs: '7', answer: 3 }, student);
|
||||
assert.equal(res.status, 403, `got ${res.status}`);
|
||||
});
|
||||
|
||||
it('GET /pool отдаёт одобренные задачи', async () => {
|
||||
db.prepare(`INSERT INTO practice_problems (topic, skill, difficulty, story, lhs, rhs, answer_var, answer, solution_json, status)
|
||||
VALUES ('word-linear','word-linear',1,'Условие','3*x + 4','19','x',5,'[]','approved')`).run();
|
||||
|
||||
Reference in New Issue
Block a user