Add group-class enrolment deadline with instructor late-enrolment override
CI / Tests (PHP 8.1) (pull_request) Successful in 48s
CI / Tests (PHP 8.2) (pull_request) Successful in 47s
CI / No Debug Code (pull_request) Successful in 3s
CI / PHPStan (pull_request) Successful in 2m51s
CI / Coding Standards (pull_request) Successful in 3m2s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m37s
CI / Build Plugin Zip (pull_request) Skipped

Group classes gain an instructor-set enrolment deadline (new
us_offerings.enrollment_deadline column) that defaults to the first day of
the class (term_start). Past the deadline students can no longer self-enrol:
the enrolment endpoint rejects it (403 enrollment_closed) and the front-end
class list shows "Enrolment has closed." in place of the Enrol button.

Instructors keep a manual path: the "Add students directly" control on each
class's details page now renders for public classes too (not just
invite-only) and deliberately bypasses the deadline and capacity, so a
student can be added as a late enrolment after the class has closed. Past
the deadline the details page labels these as late enrolments.

Bumps USC_VERSION to 1.1.3 for the schema change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
2026-07-24 10:19:38 -03:00
co-authored by Claude Opus 4.8
parent 991ed2f5ad
commit bf29162587
18 changed files with 338 additions and 54 deletions
+44
View File
@@ -277,4 +277,48 @@ class OfferingTest extends TestCase
self::assertContains(Offering::BILLING_ONE_TIME, Offering::VALID_BILLING_MODES);
self::assertContains(Offering::BILLING_FULL_TERM, Offering::VALID_BILLING_MODES);
}
public function testEffectiveEnrollmentDeadlineDefaultsToTermStart(): void
{
$offering = new Offering(1, Offering::KIND_GROUP_CLASS, 'Choir', termStart: '2026-09-08');
self::assertSame('2026-09-08', $offering->effectiveEnrollmentDeadline());
}
public function testEffectiveEnrollmentDeadlineUsesExplicitValueWhenSet(): void
{
$offering = new Offering(1, Offering::KIND_GROUP_CLASS, 'Choir', termStart: '2026-09-08', enrollmentDeadline: '2026-08-31');
self::assertSame('2026-08-31', $offering->effectiveEnrollmentDeadline());
}
public function testEffectiveEnrollmentDeadlineIsNullWithoutDates(): void
{
$offering = new Offering(1, Offering::KIND_GROUP_CLASS, 'Choir');
self::assertNull($offering->effectiveEnrollmentDeadline());
}
public function testIsEnrollmentOpenOnAndBeforeTheDeadlineDay(): void
{
$offering = new Offering(1, Offering::KIND_GROUP_CLASS, 'Choir', termStart: '2026-09-08', enrollmentDeadline: '2026-08-31');
self::assertTrue($offering->isEnrollmentOpen('2026-08-30'));
self::assertTrue($offering->isEnrollmentOpen('2026-08-31'));
self::assertFalse($offering->isEnrollmentOpen('2026-09-01'));
}
public function testIsEnrollmentOpenAlwaysTrueWithoutADeadline(): void
{
$offering = new Offering(1, Offering::KIND_GROUP_CLASS, 'Choir');
self::assertTrue($offering->isEnrollmentOpen('2099-01-01'));
}
public function testToArrayIncludesEnrollmentDeadline(): void
{
$offering = new Offering(1, Offering::KIND_GROUP_CLASS, 'Choir', enrollmentDeadline: '2026-08-31', id: 10);
self::assertSame('2026-08-31', $offering->toArray()['enrollment_deadline']);
}
}