Add lesson booking registration flow (offering, questions, policies)
CI / Coding Standards (pull_request) Successful in 1m51s
CI / PHPStan (pull_request) Successful in 2m17s
CI / Tests (PHP 8.1) (pull_request) Successful in 2m24s
CI / No Debug Code (pull_request) Successful in 2s
CI / Tests (PHP 8.2) (pull_request) Successful in 42s
CI / Tests (PHP 8.3) (pull_request) Successful in 47s
CI / Build Plugin Zip (pull_request) Has been skipped

Implements #3: students register for a private lesson by picking a slot,
answering the offering's intake questions, and accepting booking-scoped
policies. Payment is a clean seam for #7 (lessons land pending; payment_id
null; instructor confirms via PATCH /bookings/{id}/status).

- Schema: us_lessons += offering_id, recurrence, series_id, payment_id.
- Lesson: new fields + recurrence constants.
- BookingRepository::insertSeries() builds a weekly series sharing a
  series_id; AvailabilityRepository::findUnbookedInGroup() reserves a group.
- RegistrationGate (src/Registration/): validate + record intake answers and
  booking-scoped policy acceptances. Reused by group enrolment (#4).
- BookingEndpoint::book(): offering_id, recurrence, answers,
  accepted_policy_version_ids; single or weekly; records answers/acceptances
  (type lesson).
- GET /policies?scope=booking filter.
- Front-end booking.js: slot -> questions + policies -> submit.
- Wiring: RegistrationGate built in Plugin, passed via RestRegistrar.
- Test-only WP_Error stub in tests/bootstrap.php for gate testing.

Refs #3

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 11:25:30 -03:00
parent d0dddd9075
commit 6d163e5d0e
15 changed files with 649 additions and 68 deletions
+51 -1
View File
@@ -16,18 +16,68 @@ class BookingRepository {
$this->table,
[
'slot_id' => $lesson->slotId,
'offering_id' => $lesson->offeringId,
'student_id' => $lesson->studentId,
'instructor_id' => $lesson->instructorId,
'recurrence' => $lesson->recurrence,
'series_id' => $lesson->seriesId,
'status' => $lesson->status,
'payment_id' => $lesson->paymentId,
'notes' => $lesson->notes,
'created_at' => current_time( 'mysql' ),
],
[ '%d', '%d', '%d', '%s', '%s', '%s' ]
[ '%d', '%d', '%d', '%d', '%s', '%d', '%s', '%d', '%s', '%s' ]
);
return $this->db->insert_id;
}
/**
* Create a weekly lesson series — one lesson per slot, all sharing a
* `series_id` (the id of the first lesson row).
*
* @param list<int> $slotIds Availability slot IDs to reserve, in order.
* @return list<int> Inserted lesson IDs.
*/
public function insertSeries( Lesson $template, array $slotIds ): array {
$ids = [];
$seriesId = 0;
foreach ( $slotIds as $slotId ) {
$id = $this->insert(
new Lesson(
slotId: $slotId,
studentId: $template->studentId,
instructorId: $template->instructorId,
offeringId: $template->offeringId,
recurrence: Lesson::RECURRENCE_WEEKLY,
seriesId: $seriesId > 0 ? $seriesId : null,
status: $template->status,
notes: $template->notes,
)
);
if ( 0 === $seriesId ) {
$seriesId = $id;
$this->setSeriesId( $id, $seriesId );
}
$ids[] = $id;
}
return $ids;
}
private function setSeriesId( int $id, int $seriesId ): void {
$this->db->update(
$this->table,
[ 'series_id' => $seriesId ],
[ 'id' => $id ],
[ '%d' ],
[ '%d' ]
);
}
public function findById( int $id ): ?Lesson {
$row = $this->db->get_row(
$this->db->prepare( "SELECT * FROM {$this->table} WHERE id = %d", $id )