Skip to content

feat: attendance sheet import screen with prefilled template - #234

Merged
buzz-code merged 3 commits into
mainfrom
claude/project-thread-exk6ju
Oct 25, 2026
Merged

buzz-code merged 3 commits into
mainfrom
claude/project-thread-exk6ju

Conversation

@buzz-code

@buzz-code buzz-code commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Requested by הדסה · project thread

Fixes buzz-code/ops#8

Before: attendance kept in a shared per-class Excel workbook, with one column block per teacher, had no way into the system. The mail import only accepts the per-teacher file format.

After: users with the attendanceSheetImport permission get a new menu item, "קליטת קובץ נוכחות מגמה", under Data. On this screen they can download a prefilled workbook for a class and the lessons they pick. Uploading the filled workbook opens a preview dialog, like other Excel imports. The dialog shows the reports that would be created or updated plus any warnings, or lists every error by sheet and cell. Nothing is saved until the user clicks "ייבא", and then everything is saved in one transaction.

How

Server (att_report actions, gated by attendanceSheetImport or admin, scoped to the logged-in user's userId; an admin who is not impersonating a user is rejected)

  • src/utils/attendanceSheet.util.ts
    • parseAttendanceWorkbook: each sheet with the class-code label in E2 (or a value in F2) is one class; other sheets, such as instructions, are skipped.
    • A teacher block starts at any column with a teacher name, teacher tz or lesson key in rows 3–5, and runs until the next one. Merged slave cells count as empty, so block width is free and hand-added columns stay with their teacher.
    • Dates are accepted as Excel dates, serial numbers or dd/mm/yy(yy) text. A column with no date is skipped, a blank count means 1 lesson, and a blank student cell means absCount = 0.
    • importAttendanceWorkbook resolves klass and lesson for the current year, plus teacher and student, with one query per entity. It collects every error, warns (without blocking) when a student is not in the sheet's klass in StudentKlass, and saves all reports in one transaction.
    • On re-upload, existing reports are matched on student + teacher + lesson + date and updated. Entity listeners are skipped because reference ids are already resolved.
    • A duplicate student + teacher + lesson + date within one upload is reported as an error rather than silently overwritten.
    • extra.dryRun=true runs the same validation and returns the preview rows without saving.
  • src/reports/attendanceSheetTemplate.ts: builds the template with ExcelJS: the class's students, then for each selected lesson a block with the teacher name/tz and lesson key, and 10 date columns. Lessons with no teacher keep those cells empty and yellow. The sheet is RTL, has date and whole-number validation, and includes an instructions sheet.

Client

  • New src/components/AttendanceSheetImport.jsx (route in App.jsx, menu item in GeneralLayout.jsx, translations in domainTranslations.js, isAttendanceSheetImport in appPermissions.js, roadmap entry).
  • Upload flow: a dry run opens the preview dialog (summary per teacher, warnings, and the first 200 reports with new/update marked), then confirming sends the same file again to save it.
  • Lessons of the selected class are listed first in the lesson picker.
  • Student names go in column B only, because Student.name is a single field.

Tests

  • attendanceSheet.util.spec.ts (parser): several teachers, one teacher, a column added at the end of a merged block, a column with no date, several sheets plus an instructions sheet, each error type with sheet + cell, re-upload updating instead of duplicating, dry run returning rows without saving, the not-in-klass warning, and the userId filter.
  • attendanceSheetTemplate.spec.ts (template): layout, empty yellow teacher cells when a lesson has no teacher, and a round trip in which a downloaded file filled with no other changes imports with no errors.
  • att-report.service.spec.ts (endpoint): permission gate, admin-without-impersonation guard, action wiring, the dry-run flag, and rejection of a file that is not xlsx.
  • AttendanceSheetImport.test.jsx (screen): preview then confirmed import, and the error list with no import button.
  • Full suites: server 1184/1184, client 243/243, vite build passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UUoaKDcFVwbF3KPZg1Kmm3

Add a permission-gated screen (attendanceSheetImport) to download a
prefilled per-class attendance workbook and upload it back as att reports.

- Parser reads one class per sheet, teacher blocks of any width (block
  starts at teacher name/tz/lesson key, merged cells ignored), dates as
  Excel dates or dd/mm/yy(yy) text, blank cell = present.
- Import is all-or-nothing: every error is listed with sheet + cell;
  re-upload updates existing reports by student+teacher+lesson+date.
- Template: class code, class students, teacher and lesson per block,
  10 date columns per teacher, RTL, required cells highlighted, data
  validation and an instructions sheet.

Fixes buzz-code/ops#8

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UUoaKDcFVwbF3KPZg1Kmm3
@buzz-code buzz-code self-assigned this Oct 20, 2026
Upload now runs a dry run first: the server parses and validates the
file without saving and returns the reports it would create or update.
A preview dialog shows the summary, warnings and reports (or the error
list), and only "import" re-sends the file to save it in one transaction.

Fixes buzz-code/ops#8

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UUoaKDcFVwbF3KPZg1Kmm3

Copy link
Copy Markdown
Owner Author

Run browser E2E tests failed on e0e98e5. All 3 specs timed out at the same first step, waiting for input[name="username"] on /login, and the logs show no app or console error. The same suite passed on the previous head, cca6ce7, and the only difference between the two commits is the attendance-sheet preview dialog, which is not on the login route. I served this head's client locally and loaded /login in Chromium: the login form renders and there is no page error. That points to a slow or dead app start on the runner, not to this diff. I'm re-running the failed job once. If it fails again, I'll treat it as a real failure.


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UUoaKDcFVwbF3KPZg1Kmm3
@buzz-code
buzz-code marked this pull request as ready for review October 25, 2026 15:52
@buzz-code
buzz-code merged commit 094999c into main Oct 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants