feat(quizzes): тесты ученика на странице профиля
- GET /api/students/:id/overview отдаёт quizzes (история попыток ученика) - studentQuizResults(pool, studentId, user) в lib/quizzes.js - идентификация ученика через системный вопрос kind='student' - индекс idx_quiz_attempt_answers_answer в init/migration/ensureQuizTables - таб «Тесты» на public/student.html + рендер в public/js/student.js - обновление AGENTS.md (раздел 3n)
This commit is contained in:
@@ -102,6 +102,7 @@ const {
|
||||
lookupPublicQuizOptions,
|
||||
listAttempts: listQuizAttempts,
|
||||
getAttempt: getQuizAttempt,
|
||||
studentQuizResults,
|
||||
quizStats,
|
||||
purgeQuizzes,
|
||||
cleanupQuizAssets,
|
||||
@@ -10897,7 +10898,7 @@ app.get('/api/students/:id/overview', requireAuth, async (req, res) => {
|
||||
}
|
||||
const fWhere = fConds.join(' AND ');
|
||||
|
||||
const [groupRes, entriesTotalRes, entriesRes, fbTotalRes, fbRes, shortsTotalRes, shortsRes, photosRes, facesRes, achList] = await Promise.all([
|
||||
const [groupRes, entriesTotalRes, entriesRes, fbTotalRes, fbRes, shortsTotalRes, shortsRes, photosRes, facesRes, achList, quizResults] = await Promise.all([
|
||||
student.group_id ? pool.query('SELECT id, name FROM groups WHERE id = $1', [student.group_id]) : Promise.resolve({ rows: [] }),
|
||||
pool.query(`SELECT count(*)::int AS n FROM entries e JOIN groups g ON g.id = e.group_id WHERE ${eWhere}`, eParams),
|
||||
(() => {
|
||||
@@ -10942,6 +10943,10 @@ app.get('/api/students/:id/overview', requireAuth, async (req, res) => {
|
||||
[id, FACE_CANDIDATE_MIN]
|
||||
),
|
||||
achListForStudent(pool, id),
|
||||
studentQuizResults(pool, id, req.user).catch(e => {
|
||||
console.error('student quizzes:', e);
|
||||
return { items: [], total: 0 };
|
||||
}),
|
||||
]);
|
||||
|
||||
const entryIds = entriesRes.rows.map(r => r.id);
|
||||
@@ -10966,6 +10971,7 @@ app.get('/api/students/:id/overview', requireAuth, async (req, res) => {
|
||||
photos: { items: photosRes.rows, photo_path: student.photo_path || null },
|
||||
faces: { refs: faces.refs || 0, found: faces.found || 0, similar: faces.similar || 0 },
|
||||
achievements: achList || { items: [], total: 0 },
|
||||
quizzes: quizResults || { items: [], total: 0 },
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('student overview:', e);
|
||||
|
||||
Reference in New Issue
Block a user