lesson-topic: автозаполнение темы модуля на главной по отчёту о занятии

This commit is contained in:
dev
2026-11-24 12:30:27 +03:00
parent 36baa45cd8
commit d7f4a4b457
7 changed files with 466 additions and 2 deletions
+19 -1
View File
@@ -63,7 +63,7 @@ const {
sweepBackupStorage,
} = require('./lib/backup-tickets');
const { normalizeStudentStatus, ensureStudentsTable } = require('./lib/students');
const { lessonReportWriteBlocked } = require('./lib/lesson-reports');
const { lessonReportWriteBlocked, findCurrentLessonTopic } = require('./lib/lesson-reports');
const { groupOwnedBy } = require('./lib/groups');
const { ensureProjectFileSizeColumn, backfillProjectFileSizes } = require('./lib/file-sizes');
const { resolveImgbbEndpoint, friendlyApiError } = require('./lib/feedback-imgbb');
@@ -8621,6 +8621,24 @@ app.get('/api/groups/active', apiLimiter, async (_, res) => {
res.json(rows);
});
app.get('/api/public/lesson-topic', apiLimiter, async (req, res) => {
let groupId;
try {
groupId = reqInt(req.query.group_id);
if (groupId <= 0) throw new Error('Invalid group_id');
} catch (e) {
res.status(400).json({ error: 'Некорректный group_id' });
return;
}
try {
const topic = await findCurrentLessonTopic(pool, { groupId, timezone: await appTimezone() });
res.json({ topic });
} catch (e) {
console.error('Public lesson topic failed:', e.message);
res.status(500).json({ error: 'Не удалось получить тему занятия' });
}
});
app.put('/api/groups/:id', requireAuth, async (req, res) => {
const { name, day_of_week, time_start, time_end, branch_id, tutor_id } = req.body;
if (!(await groupBelongsToBranches(req.user, req.params.id))) {