From 9889da3462305831165d940791a851eac7bde677 Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Tue, 21 Jul 2026 16:53:46 -0400 Subject: [PATCH] Show course name and assignment content in planner print Week print: tasks grouped by day, each showing course name, type, and full assignment body text. Month print: course name in calendar cells + an Assignment Detail section below the calendar with body text. Co-Authored-By: Claude Sonnet 4.6 --- public/admin.js | 100 ++++++++++++++++++++++++++++++++++++++---------- server.js | 4 +- 2 files changed, 81 insertions(+), 23 deletions(-) diff --git a/public/admin.js b/public/admin.js index fee477a..65f9f53 100644 --- a/public/admin.js +++ b/public/admin.js @@ -880,11 +880,31 @@ function toggleAddTaskForm(date) { }); } +function renderPrintTaskBlock(t) { + const title = t.itemTitle || t.offlineTitle; + const course = t.courseName ? `${esc(t.courseName)}` : `Offline`; + const status = t.done ? `✓ done` : ''; + const typeTag = t.type ? `${TYPE_LABEL[t.type] || t.type}` : ''; + let body = ''; + if (t.body) body = `
${t.body.split(/\n\n+/).map((p) => `

${esc(p.trim())}

`).join('')}
`; + return `
+
${course} ${typeTag} ${esc(title)} ${status}
+ ${body} +
`; +} + async function printWeekReport(studentId, start) { const r = await api(`/api/week-report/${studentId}?start=${start}`); - const taskRows = r.tasks - .map((t) => `${t.date}${esc(t.itemTitle || t.offlineTitle)}${esc(t.courseName || 'Offline')}${t.done ? '✓ done' : '—'}`) - .join(''); + // Group tasks by date + const byDate = {}; + for (const t of r.tasks) { (byDate[t.date] = byDate[t.date] || []).push(t); } + const dayBlocks = Object.entries(byDate).map(([date, tasks]) => + `
+

${date}

+ ${tasks.map(renderPrintTaskBlock).join('')} +
` + ).join('') || '

Nothing scheduled this week.

'; + const gradedRows = r.graded .map((g) => `${esc(g.itemTitle)}${esc(g.courseName)}${g.score}/${g.points_possible}`) .join(''); @@ -892,22 +912,34 @@ async function printWeekReport(studentId, start) { .map((t) => `${esc(t.list)}${t.score}/${t.total}`) .join(''); const win = window.open('', '_blank'); - win.document.write(`Weekly Report + win.document.write(`Weekly Plan — ${esc(r.student)} -

Weekly Report — ${esc(r.student)}

+

Weekly Plan — ${esc(r.student)}

Week of ${r.start}

Schedule

- ${taskRows || ''}
DateTaskCourseStatus
Nothing scheduled
+ ${dayBlocks}

Graded work

- ${gradedRows || ''}
ItemCourseScore
Nothing graded this week
+ ${gradedRows ? `${gradedRows}
ItemCourseScore
` : '

Nothing graded this week.

'}

Spelling tests

- ${spellingRows || ''}
ListScore
No spelling tests this week
+ ${spellingRows ? `${spellingRows}
ListScore
` : '

No spelling tests this week.

'}