Skip to content

Phone-per-class Yemot flow: class phone, teacher code - #158

Merged
buzz-code merged 3 commits into
mainfrom
claude/phone-classes-requirements-7u7bi7
Aug 24, 2026
Merged

buzz-code merged 3 commits into
mainfrom
claude/phone-classes-requirements-7u7bi7

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

Summary

Classes now get their own fixed phone number instead of being identified by teacher caller ID:

  • Klass.phone (new, nullable) — the classroom's fixed phone number
  • Teacher.number (new, nullable) — short code teachers key in on the call, instead of ID
  • Seminar attendance call resolves the class from the caller's number, then asks for the teacher code instead of matching caller ID to a teacher's own phone
  • Star (*) during the teacher-code prompt falls back to manual class selection (existing klass-key flow)
  • lessonReferenceId is now filled from a matching LessonSchedule only when it belongs to the resolved class (previously the schedule chose the class directly)

Not included

The auto-number-students bulk action (assign sequential student numbers per class) is a separate follow-up, not part of this PR.

Testing

Rewrote server/src/yemot-handler.service.test.ts's seminar-attendance scenarios for the new flow (class-by-phone happy path, star-escape to manual class, invalid teacher code retry, schedule-matches-wrong-class guard, plus the existing happy-path/edge-case coverage). Could not run yarn test in this sandbox (no node_modules/submodules installed) — please run the suite in CI/locally before merging.


Generated by Claude Code

Classes now get their own fixed phone number instead of being identified
by teacher caller ID:
- Klass.phone (new, nullable) - the classroom's fixed phone number
- Teacher.number (new, nullable) - short code teachers key in on the call
- Seminar attendance call resolves the class from the caller's number,
  then asks for the teacher code instead of matching caller ID to a
  teacher's own phone
- Star (*) during the teacher-code prompt falls back to manual class
  selection (existing klass-key flow)
- lessonReferenceId is now filled from a matching LessonSchedule only
  when it belongs to the resolved class (previously the schedule chose
  the class directly)

Excludes the auto-number-students bulk action (separate follow-up).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXGT749AjJ6BDgDqvQXQX2
Copilot AI lite review requested due to automatic review settings August 24, 2026 19:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Missing uniqueness enforcement for new lookup keys (Klass.phone, Teacher.number) can make Yemot resolution nondeterministic in real data.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Shift Yemot seminar-attendance identification from teacher caller-ID to klass fixed phone + teacher keyed code, plus schema/UI support for new fields.

Changes:

  • Add Klass.phone and Teacher.number columns, expose in admin UI + translations.
  • Update Yemot seminar flow: resolve klass by caller phone, prompt teacher code, allow * escape to manual klass select.
  • Update Yemot seminar test scenarios and add Yemot texts migration for new prompts.
File summaries
File Description
server/src/yemot-handler.service.ts Switch seminar flow to klass-by-phone + teacher-code prompt; guard schedule lessonReferenceId by klass match
server/src/yemot-handler.service.test.ts Rewrite seminar scenarios for new phone-per-class + teacher-code flow
server/src/migrations/1787300000000-AddKlassPhoneAndTeacherNumber.ts Add DB columns + indexes for klass phone and teacher number
server/src/migrations/1787300000001-UpdateYemotTextsTeacherCode.ts Seed new Yemot text keys for teacher-code prompt + invalid-code message
server/src/entity-modules/teacher.config.ts Add teacher number field to config list
server/src/db/entities/Teacher.entity.ts Add number column + index metadata
server/src/db/entities/Klass.entity.ts Add phone column + index metadata
client/src/entities/teacher.jsx Show/edit/import teacher number in React-Admin
client/src/entities/klass.jsx Show/edit/import klass phone in React-Admin
client/src/domainTranslations.js Add field translations for klass phone + teacher number
Review details

Suppressed comments (1)

server/src/migrations/1787300000000-AddKlassPhoneAndTeacherNumber.ts:22

  • teachers_user_id_number_idx index is non-unique, but Yemot flow authenticates teacher by Teacher.number using findOneBy. Duplicate number values under same user will resolve to arbitrary teacher, breaking attendance reporting. Add unique constraint (and align entity decorator/validation) so teacher-code lookup is deterministic.
        await queryRunner.query(`
            ALTER TABLE \`teachers\`
            ADD INDEX \`teachers_user_id_number_idx\` (\`user_id\`, \`number\`)
        `);
  • Files reviewed: 10/10 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread server/src/db/entities/Klass.entity.ts Resolved
Comment thread client/src/entities/klass.jsx Resolved
Comment thread server/src/yemot-handler.service.ts Resolved
Per Copilot review: Yemot resolution looked up both fields with no
DB or app-level uniqueness guarantee, so a duplicate would resolve to
an arbitrary row.

- Klass.phone: unique per (userId, phone, year), matching the year
  scope getKlassByPhone() already queries with
- Teacher.number: unique per (userId, number), matching the existing
  (year-agnostic) teacher lookup convention
- Added matching @IsUniqueCombination validators for a Hebrew
  duplicate-value error in the admin UI, and unique() on the klass
  phone input (teacher number already had it)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXGT749AjJ6BDgDqvQXQX2

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Nullable unique fields (Teacher.number, Klass.phone) can be saved as empty string from UI/import, causing duplicate-key failures and blocking creation of multiple rows with “blank” values.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 6
  • Review effort level: Lite

Comment thread server/src/db/entities/Klass.entity.ts Resolved
Comment thread client/src/entities/teacher.jsx Resolved
Comment thread client/src/entities/klass.jsx Resolved
Per Copilot review: a blank React-Admin TextInput submits '', and
MySQL's unique index treats '' as a real (colliding) value unlike
NULL - so a second klass/teacher left without a phone/number would
hit a raw DB unique-constraint error instead of just saving fine.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXGT749AjJ6BDgDqvQXQX2

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Core attendance call flow + schema migrations changed; need human verification plus CI test run before merge.

Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@buzz-code
buzz-code merged commit e4c4aec into main Aug 24, 2026
5 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.

3 participants