Add student administration view (studio-admin)
CI / Tests (PHP 8.1) (pull_request) Successful in 43s
CI / Coding Standards (pull_request) Successful in 56s
CI / PHPStan (pull_request) Successful in 57s
CI / No Debug Code (pull_request) Successful in 2s
CI / Tests (PHP 8.2) (pull_request) Successful in 44s
CI / Tests (PHP 8.3) (pull_request) Successful in 48s
CI / Build Plugin Zip (pull_request) Has been skipped
CI / Tests (PHP 8.1) (pull_request) Successful in 43s
CI / Coding Standards (pull_request) Successful in 56s
CI / PHPStan (pull_request) Successful in 57s
CI / No Debug Code (pull_request) Successful in 2s
CI / Tests (PHP 8.2) (pull_request) Successful in 44s
CI / Tests (PHP 8.3) (pull_request) Successful in 48s
CI / Build Plugin Zip (pull_request) Has been skipped
Implements #22: a read-only Students area for studio admins. - StudentController (manage_students): a list of us_student users with upcoming-lesson and active-enrolment counts, each linking to a detail page showing account info, upcoming/past lessons (offering, instructor, status), and group-class enrolments. - StudentSchedule::partition() — pure, unit-tested upcoming/past split. - Repo counts: BookingRepository::countUpcomingForStudent and EnrollmentRepository::countActiveForStudent (single-query, tested). - Templates: templates/admin/students.php, student-detail.php. - Students admin menu wired in AdminMenu (no Plugin change — the repos were already available there). - Docs: README status flipped to implemented; feature spec updated. Payment history slots into the detail when Payments (#7) lands. Tests: StudentScheduleTest + the two repo count tests. composer test (127), cs, and PHPStan level 6 all pass. Refs #22 Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Unsupervised\Schedular\Auth;
|
||||
|
||||
/**
|
||||
* Pure helper for splitting a student's dated rows into upcoming and past.
|
||||
*/
|
||||
class StudentSchedule {
|
||||
|
||||
/**
|
||||
* Partition rows (each with a `start_dt` string in `Y-m-d H:i:s`) relative to
|
||||
* `$now`. Upcoming rows are sorted ascending, past rows descending. Rows
|
||||
* without a usable `start_dt` fall into `past`.
|
||||
*
|
||||
* @param list<array<string, mixed>> $rows
|
||||
* @return array{upcoming: list<array<string, mixed>>, past: list<array<string, mixed>>}
|
||||
*/
|
||||
public static function partition( array $rows, string $now ): array {
|
||||
$upcoming = [];
|
||||
$past = [];
|
||||
|
||||
foreach ( $rows as $row ) {
|
||||
$start = (string) ( $row['start_dt'] ?? '' );
|
||||
if ( '' !== $start && $start >= $now ) {
|
||||
$upcoming[] = $row;
|
||||
} else {
|
||||
$past[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
usort( $upcoming, static fn( array $a, array $b ): int => strcmp( (string) ( $a['start_dt'] ?? '' ), (string) ( $b['start_dt'] ?? '' ) ) );
|
||||
usort( $past, static fn( array $a, array $b ): int => strcmp( (string) ( $b['start_dt'] ?? '' ), (string) ( $a['start_dt'] ?? '' ) ) );
|
||||
|
||||
return [
|
||||
'upcoming' => array_values( $upcoming ),
|
||||
'past' => array_values( $past ),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user