feat(post-lesson): подсказка при несчитанных коротких сообщениях (ошибка даты/автора)

This commit is contained in:
dev
2026-11-03 12:06:24 +03:00
parent c2ef292237
commit 6685800cf4
5 changed files with 48 additions and 3 deletions
+2
View File
@@ -17,6 +17,8 @@
.post-task-step { display:inline-flex; align-items:center; gap:4px; padding:3px 8px; border-radius:999px; font-size:12px; background:rgba(0,0,0,.05); }
.post-task-step.done { color:#16a34a; text-decoration:line-through; opacity:.7; }
.post-task-step.next { animation:postTaskBlink 1.1s ease-in-out infinite; font-weight:600; background:rgba(245,158,11,.18); color:#b45309; }
.post-task-step.warn { background:rgba(239,68,68,.15); color:#b91c1c; font-weight:600; }
.post-task-hint { margin-top:6px; padding:6px 10px; border-radius:6px; background:rgba(239,68,68,.08); border:1px solid rgba(239,68,68,.3); color:#b91c1c; font-size:12px; line-height:1.4; }
.post-task-actions { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }
.post-task-actions .btn-xs { padding:4px 10px; font-size:12px; }
</style>
+8 -1
View File
@@ -187,8 +187,15 @@ function renderPostLessonTasks(rows) {
<span class="top-count">${completed}/${steps.length}</span>
</div>
<div class="post-task-steps">
${steps.map((s, i) => `<span class="post-task-step ${s.done ? 'done' : ''} ${i === nextIdx ? 'next' : ''}" data-task-key="${esc(t.key)}" data-step-key="${esc(s.key)}" style="cursor:pointer" title="Нажмите, чтобы переключить статус">${s.done ? '✓' : '○'} ${esc(s.label)}</span>`).join('')}
${steps.map((s, i) => {
const related = (s.key === 'shorts' && Array.isArray(s.related) && s.related.length) ? s.related : [];
const title = related.length
? 'Короткие сообщения найдены, но не засчитаны: ' + related.map(r => r.resident + ' (' + r.lesson_date + (r.reason === 'date' ? ', другая дата' : ', другой автор') + ')').join('; ')
: 'Нажмите, чтобы переключить статус';
return `<span class="post-task-step ${s.done ? 'done' : ''} ${i === nextIdx ? 'next' : ''} ${(!s.done && related.length) ? 'warn' : ''}" data-task-key="${esc(t.key)}" data-step-key="${esc(s.key)}" style="cursor:pointer" title="${esc(title)}">${s.done ? '✓' : (related.length ? '⚠' : '○')} ${esc(s.label)}${related.length ? ' (' + related.length + ')' : ''}</span>`;
}).join('')}
</div>
${t.shorts_related && t.shorts_related.length ? `<div class="post-task-hint">⚠ Короткие сообщения найдены (${t.shorts_related.length}), но не засчитаны: ${t.shorts_related.map(r => esc(r.resident) + ' — ' + esc(r.lesson_date) + (r.reason === 'date' ? ' (другая дата)' : ' (другой автор)')).join(', ')}. Проверьте дату и автора.</div>` : ''}
<div class="post-task-actions">
<button type="button" class="btn-xs post-task-close" data-close-task="${esc(t.key)}" title="Закрыть задачу">Закрыть</button>
</div>
+9 -1
View File
@@ -121,8 +121,16 @@ function renderPostLessonTasks() {
<span class="top-count">${completed}/${steps2.length}</span>
</div>
<div class="post-task-steps">
${steps2.map((s, i) => `<span class="post-task-step ${s.done ? 'done' : ''} ${i === nextIdx ? 'next' : ''} ${s.manual ? 'manual' : ''}" data-task-key="${esc(t.key)}" data-step-key="${esc(s.key)}" title="Нажмите, чтобы переключить статус">${s.done ? '✓' : '○'} ${esc(s.label)}</span>`).join('')}
${steps2.map((s, i) => {
const related = (s.key === 'shorts' && Array.isArray(s.related) && s.related.length) ? s.related : [];
const warn = (!s.done && related.length) ? 'warn' : '';
const title = related.length
? 'Короткие сообщения найдены, но не засчитаны: ' + related.map(r => r.resident + ' (' + r.lesson_date + (r.reason === 'date' ? ', другая дата' : ', другой автор') + ')').join('; ')
: 'Нажмите, чтобы переключить статус';
return `<span class="post-task-step ${s.done ? 'done' : ''} ${i === nextIdx ? 'next' : ''} ${s.manual ? 'manual' : ''} ${warn}" data-task-key="${esc(t.key)}" data-step-key="${esc(s.key)}" title="${esc(title)}">${s.done ? '✓' : (related.length ? '⚠' : '○')} ${esc(s.label)}${related.length ? ' (' + related.length + ')' : ''}</span>`;
}).join('')}
</div>
${t.shorts_related && t.shorts_related.length && !(overrides[t.key] && overrides[t.key].shorts) ? `<div class="post-task-hint">⚠ Короткие сообщения найдены (${t.shorts_related.length}), но не засчитаны: ${t.shorts_related.map(r => esc(r.resident) + ' — ' + esc(r.lesson_date) + (r.reason === 'date' ? ' (другая дата)' : ' (другой автор)')).join(', ')}. Проверьте дату и автора.</div>` : ''}
<div class="post-task-actions">
${isDismissed
? `<button type="button" class="btn-xs post-task-restore" data-restore-task="${esc(t.key)}" title="Вернуть задачу">Вернуть</button>`
+2
View File
@@ -19,6 +19,8 @@
.post-task-step.done { color:#16a34a; text-decoration:line-through; opacity:.7; }
.post-task-step.next { animation:postTaskBlink 1.1s ease-in-out infinite; font-weight:600; background:rgba(245,158,11,.18); color:#b45309; }
.post-task-step.manual::after { content:' (вручную)'; font-size:10px; opacity:.7; }
.post-task-step.warn { background:rgba(239,68,68,.15); color:#b91c1c; font-weight:600; }
.post-task-hint { margin-top:6px; padding:6px 10px; border-radius:6px; background:rgba(239,68,68,.08); border:1px solid rgba(239,68,68,.3); color:#b91c1c; font-size:12px; line-height:1.4; }
.post-task-actions { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }
.post-task-actions .btn-xs { padding:4px 10px; font-size:12px; }
.post-task-basis-wrap { margin-top:6px; font-size:12px; opacity:.85; }
+27 -1
View File
@@ -12018,6 +12018,11 @@ async function buildPostLessonTasks(user, days) {
}
}
}
const { rows: allShortRows } = await pool.query(
`SELECT sm.id, sm.lesson_date::text AS d, sm.resident, sm.author_id, sm.created_at, u.name AS author_name, u.username AS author_username
FROM short_messages sm LEFT JOIN users u ON u.id = sm.author_id
WHERE sm.deleted_at IS NULL`
);
const tutorIds = [...new Set(groups.map(g => g.tutor_id).filter(Boolean))];
const tutorMap = new Map();
if (tutorIds.length) {
@@ -12032,9 +12037,29 @@ async function buildPostLessonTasks(user, days) {
const reportBasis = reportMap.get(key) || [];
const shortsBasis = shortsMap.get(key) || [];
const feedbackBasis = feedbackMap.get(key) || [];
const countedShortIds = new Set(shortsBasis.map(x => x.id));
const shortsRelated = allShortRows
.filter(sm => {
const gids = groupsByStudentName.get(String(sm.resident || '').trim().toLowerCase());
if (!gids || !gids.has(g.id)) return false;
if (countedShortIds.has(sm.id)) return false;
const diffDays = Math.abs(new Date(sm.d + 'T00:00:00Z').getTime() - new Date(date + 'T00:00:00Z').getTime()) / (1000 * 60 * 60 * 24);
if (diffDays > 1) return false;
// отработка в другой группе: если дата совпадает с расписанием другой группы — не подсвечивать
const smDow = new Date(sm.d + 'T00:00:00Z').getUTCDay();
if (groups.some(og => og.id !== g.id && og.day_of_week === smDow)) return false;
return true;
})
.map(sm => ({
id: sm.id,
resident: sm.resident || '',
lesson_date: sm.d,
author: sm.author_name || sm.author_username || '',
reason: sm.d !== date ? 'date' : 'author',
}));
const steps = [
{ key: 'report', label: 'Отчёт о занятии', done: reportDone, link: '/lessons.html', basis: reportBasis },
{ key: 'shorts', label: 'Короткие сообщения', done: shortsDone, link: '/shorts.html', basis: shortsBasis },
{ key: 'shorts', label: 'Короткие сообщения', done: shortsDone, link: '/shorts.html', basis: shortsBasis, related: shortsRelated },
{ key: 'feedback', label: 'Обратная связь', done: feedbackDone, link: '/feedback.html', basis: feedbackBasis },
];
const completed = steps.filter(x => x.done).length;
@@ -12051,6 +12076,7 @@ async function buildPostLessonTasks(user, days) {
total: 3,
overdue: date < today,
all_done: completed === 3,
shorts_related: shortsRelated,
};
});
tasks.sort((a, b) => {