diff --git a/public/dashboard.html b/public/dashboard.html index 9eadd30..a604ad6 100644 --- a/public/dashboard.html +++ b/public/dashboard.html @@ -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; } diff --git a/public/js/dashboard.js b/public/js/dashboard.js index 51323ba..6b333b4 100644 --- a/public/js/dashboard.js +++ b/public/js/dashboard.js @@ -187,8 +187,15 @@ function renderPostLessonTasks(rows) { ${completed}/${steps.length}
- ${steps.map((s, i) => `${s.done ? '✓' : '○'} ${esc(s.label)}`).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 `${s.done ? '✓' : (related.length ? '⚠' : '○')} ${esc(s.label)}${related.length ? ' (' + related.length + ')' : ''}`; + }).join('')}
+ ${t.shorts_related && t.shorts_related.length ? `
⚠ Короткие сообщения найдены (${t.shorts_related.length}), но не засчитаны: ${t.shorts_related.map(r => esc(r.resident) + ' — ' + esc(r.lesson_date) + (r.reason === 'date' ? ' (другая дата)' : ' (другой автор)')).join(', ')}. Проверьте дату и автора.
` : ''}
diff --git a/public/js/postlesson.js b/public/js/postlesson.js index 0a6444e..e42aa9f 100644 --- a/public/js/postlesson.js +++ b/public/js/postlesson.js @@ -121,8 +121,16 @@ function renderPostLessonTasks() { ${completed}/${steps2.length}
- ${steps2.map((s, i) => `${s.done ? '✓' : '○'} ${esc(s.label)}`).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 `${s.done ? '✓' : (related.length ? '⚠' : '○')} ${esc(s.label)}${related.length ? ' (' + related.length + ')' : ''}`; + }).join('')}
+ ${t.shorts_related && t.shorts_related.length && !(overrides[t.key] && overrides[t.key].shorts) ? `
⚠ Короткие сообщения найдены (${t.shorts_related.length}), но не засчитаны: ${t.shorts_related.map(r => esc(r.resident) + ' — ' + esc(r.lesson_date) + (r.reason === 'date' ? ' (другая дата)' : ' (другой автор)')).join(', ')}. Проверьте дату и автора.
` : ''}
${isDismissed ? `` diff --git a/public/postlesson.html b/public/postlesson.html index 0f060ef..90dd97d 100644 --- a/public/postlesson.html +++ b/public/postlesson.html @@ -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; } diff --git a/server.js b/server.js index 097dd12..5aef99b 100644 --- a/server.js +++ b/server.js @@ -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) => {