Add instructor group-class roster view under My Lessons
CI / Tests (PHP 8.2) (pull_request) Successful in 47s
CI / Tests (PHP 8.1) (pull_request) Successful in 38s
CI / No Debug Code (pull_request) Successful in 2s
CI / Coding Standards (pull_request) Successful in 2m50s
CI / PHPStan (pull_request) Successful in 2m54s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m42s
CI / Build Plugin Zip (pull_request) Skipped
CI / Tests (PHP 8.2) (pull_request) Successful in 47s
CI / Tests (PHP 8.1) (pull_request) Successful in 38s
CI / No Debug Code (pull_request) Successful in 2s
CI / Coding Standards (pull_request) Successful in 2m50s
CI / PHPStan (pull_request) Successful in 2m54s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m42s
CI / Build Plugin Zip (pull_request) Skipped
Instructors can now see their own group classes under My Lessons → My Group Classes (view_own_lessons): each class shows its active enrolment count against capacity plus a roster of enrolled students with enrolment and payment status. GroupClassController gains renderInstructorPage(), backed by the existing per-instructor enrolment query and a newly injected PaymentRepository for payment status. Wired as a submenu under the existing My Lessons menu, inside the same !view_all_lessons guard so owner-operators don't get a duplicate item. Closes #71 Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
@@ -4,13 +4,16 @@ declare(strict_types=1);
|
||||
namespace Unsupervised\Schedular\GroupClass;
|
||||
|
||||
use Unsupervised\Schedular\Auth\RoleManager;
|
||||
use Unsupervised\Schedular\Offering\Offering;
|
||||
use Unsupervised\Schedular\Offering\OfferingRepository;
|
||||
use Unsupervised\Schedular\Payment\PaymentRepository;
|
||||
|
||||
class GroupClassController {
|
||||
|
||||
public function __construct(
|
||||
private EnrollmentRepository $enrollments,
|
||||
private OfferingRepository $offerings,
|
||||
private PaymentRepository $payments,
|
||||
) {}
|
||||
|
||||
public function renderPage(): void {
|
||||
@@ -34,4 +37,54 @@ class GroupClassController {
|
||||
|
||||
include USC_PLUGIN_DIR . 'templates/admin/group-classes.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructor view: their own group classes with per-class rosters. Each class
|
||||
* shows its enrolment count against capacity plus a roster of enrolled
|
||||
* students with enrolment and payment status.
|
||||
*/
|
||||
public function renderInstructorPage(): void {
|
||||
if ( ! current_user_can( RoleManager::CAP_VIEW_LESSONS ) ) {
|
||||
wp_die( esc_html__( 'You do not have permission to view group classes.', 'unsupervised-schedular' ) );
|
||||
}
|
||||
|
||||
$instructorId = get_current_user_id();
|
||||
$enrollments = $this->enrollments->findByInstructor( $instructorId );
|
||||
|
||||
$classes = array_map(
|
||||
function ( Offering $offering ) use ( $enrollments ): array {
|
||||
$roster = [];
|
||||
$enrolled = 0;
|
||||
|
||||
foreach ( $enrollments as $enrollment ) {
|
||||
if ( $enrollment->offeringId !== $offering->id ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( Enrollment::STATUS_ACTIVE === $enrollment->status ) {
|
||||
++$enrolled;
|
||||
}
|
||||
|
||||
$student = get_userdata( $enrollment->studentId );
|
||||
$payment = null !== $enrollment->paymentId ? $this->payments->findById( $enrollment->paymentId ) : null;
|
||||
|
||||
$roster[] = [
|
||||
'student' => $student ? $student->display_name : (string) $enrollment->studentId,
|
||||
'status' => $enrollment->status,
|
||||
'payment' => $payment?->status,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'title' => $offering->title,
|
||||
'capacity' => $offering->capacity,
|
||||
'enrolled' => $enrolled,
|
||||
'roster' => $roster,
|
||||
];
|
||||
},
|
||||
$this->offerings->findAll( $instructorId, Offering::KIND_GROUP_CLASS )
|
||||
);
|
||||
|
||||
include USC_PLUGIN_DIR . 'templates/admin/my-group-classes.php';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user