offerings->findById( $enrollment->offeringId ); $student = get_userdata( $enrollment->studentId ); return [ 'student' => $student ? $student->display_name : (string) $enrollment->studentId, 'offering' => $offering ? $offering->title : (string) $enrollment->offeringId, 'status' => $enrollment->status, ]; }, $this->enrollments->findAllActive() ); 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'; } }