Skip to content

Commit 4909bfa

Browse files
committed
add local data source attribute attendeeWaitingList
1 parent 4e8490d commit 4909bfa

5 files changed

Lines changed: 40 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Add local data attribute attendeeWaitingList
6+
57
## v0.2.8
68

79
- Add local data source attributes expectedPreviousKnowledge, teachingMethodKey, and teachingMethodDescription

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"require": {
66
"php": ">=8.2",
77
"ext-json": "*",
8-
"dbp/campusonline-api": "^0.3.37",
8+
"dbp/campusonline-api": "^0.3.43",
99
"dbp/relay-base-course-bundle": "^0.2.17",
1010
"dbp/relay-core-bundle": "^0.1.228",
1111
"doctrine/dbal": "^4.2",

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/EventSubscriber/CourseEventSubscriber.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Dbp\Relay\BaseCourseConnectorCampusonlineBundle\EventSubscriber;
66

7+
use Dbp\CampusonlineApi\PublicRestApi\Courses\CourseRegistrationResource;
78
use Dbp\Relay\BaseCourseBundle\Entity\Course;
89
use Dbp\Relay\BaseCourseConnectorCampusonlineBundle\Event\CoursePostEvent;
910
use Dbp\Relay\BaseCourseConnectorCampusonlineBundle\Event\CoursePreEvent;
@@ -15,6 +16,7 @@ class CourseEventSubscriber extends AbstractLocalDataEventSubscriber
1516
{
1617
public const LECTURERS_SOURCE_DATA_ATTRIBUTE = 'lecturers';
1718
public const ATTENDEES_SOURCE_DATA_ATTRIBUTE = 'attendees';
19+
public const ATTENDEE_WAITING_LIST_SOURCE_DATA_ATTRIBUTE = 'attendeeWaitingList';
1820
public const COURSE_GROUPS_SOURCE_DATA_ATTRIBUTE = 'courseGroups';
1921
public const DESCRIPTION_SOURCE_DATA_ATTRIBUTE = 'description';
2022
public const STATUS_WITHIN_CURRICULUM_URL_SOURCE_DATA_ATTRIBUTE = 'statusWithinCurriculumUrl';
@@ -51,7 +53,11 @@ protected function getAttributeValue(LocalDataPostEvent $postEvent, array $attri
5153

5254
case self::ATTENDEES_SOURCE_DATA_ATTRIBUTE:
5355
return $this->courseProvider->getAttendeesByCourse(
54-
$course->getIdentifier(), $postEvent->getOptions());
56+
$course->getIdentifier(), CourseRegistrationResource::REGISTRATION_STATUS_FIXED);
57+
58+
case self::ATTENDEE_WAITING_LIST_SOURCE_DATA_ATTRIBUTE:
59+
return $this->courseProvider->getAttendeesByCourse(
60+
$course->getIdentifier(), CourseRegistrationResource::REGISTRATION_STATUS_WAITING_LIST);
5561

5662
case self::COURSE_GROUPS_SOURCE_DATA_ATTRIBUTE:
5763
return $this->courseProvider->getGroupsByCourse(

src/Service/CourseProvider.php

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,20 +338,24 @@ public function getCourseEvents(int $currentPageNumber, int $maxNumItemsPerPage,
338338
}
339339

340340
/**
341-
* @param array $options Available options:
342-
* * Locale::LANGUAGE_OPTION (language in ISO 639‑1 format)
341+
* @param string|null $registrationStatus if specified, only attendees with the given registration status are returned, otherwise all attendees are returned
343342
*
344343
* @return array<int, array<string, mixed>>
345344
*
346345
* @throws ApiError
347346
*/
348-
public function getAttendeesByCourse(string $courseIdentifier, array $options = []): array
347+
public function getAttendeesByCourse(
348+
string $courseIdentifier,
349+
?string $registrationStatus = CourseRegistrationResource::REGISTRATION_STATUS_FIXED): array
349350
{
350351
$attendeeIds = [];
351352
foreach ($this->getCourseRegistrationResourcesCached($courseIdentifier) as $registrationResource) {
352-
$attendeeIds[] = [
353-
'personIdentifier' => $registrationResource->getPersonUid(),
354-
];
353+
if ($registrationStatus === null
354+
|| $registrationStatus === $registrationResource->getRegistrationStatus()) {
355+
$attendeeIds[] = [
356+
'personIdentifier' => $registrationResource->getPersonUid(),
357+
];
358+
}
355359
}
356360

357361
return $attendeeIds;
@@ -390,6 +394,7 @@ public function getGroupsByCourse(string $courseIdentifier, array $options = [])
390394
$courseGroupApi = new CourseGroupApi($this->getCourseApi()->getConnection());
391395

392396
$ATTENDEE_PERSON_IDENTIFIERS_KEY = 'attendeeIdentifiers';
397+
$ATTENDEE_WAITING_LIST_PERSON_IDENTIFIERS_KEY = 'attendeeWaitingListIdentifiers';
393398
$LECTURER_PERSON_IDENTIFIERS_KEY = 'lecturerIdentifiers';
394399

395400
$courseGroupPeopleMap = [];
@@ -398,17 +403,26 @@ public function getGroupsByCourse(string $courseIdentifier, array $options = [])
398403
if (null === ($courseGroupPeopleMap[$courseGroupIdentifier] ?? null)) {
399404
$courseGroupPeople = [
400405
$ATTENDEE_PERSON_IDENTIFIERS_KEY => [],
406+
$ATTENDEE_WAITING_LIST_PERSON_IDENTIFIERS_KEY => [],
401407
$LECTURER_PERSON_IDENTIFIERS_KEY => [],
402408
];
403409
$courseGroupPeopleMap[$courseGroupIdentifier] = $courseGroupPeople;
404410
}
405-
$courseGroupPeopleMap[$courseGroupIdentifier][$ATTENDEE_PERSON_IDENTIFIERS_KEY][] = $registrationResource->getPersonUid();
411+
switch ($registrationResource->getRegistrationStatus()) {
412+
case CourseRegistrationResource::REGISTRATION_STATUS_FIXED:
413+
$courseGroupPeopleMap[$courseGroupIdentifier][$ATTENDEE_PERSON_IDENTIFIERS_KEY][] = $registrationResource->getPersonUid();
414+
break;
415+
case CourseRegistrationResource::REGISTRATION_STATUS_WAITING_LIST:
416+
$courseGroupPeopleMap[$courseGroupIdentifier][$ATTENDEE_WAITING_LIST_PERSON_IDENTIFIERS_KEY][] = $registrationResource->getPersonUid();
417+
break;
418+
}
406419
}
407420
foreach ($this->getLectureshipResourcesCached($courseIdentifier) as $lectureshipResource) {
408421
foreach ($lectureshipResource->getGroupUids() as $courseGroupIdentifier) {
409422
if (null === ($courseGroupPeopleMap[$courseGroupIdentifier] ?? null)) {
410423
$courseGroupPeople = [
411424
$ATTENDEE_PERSON_IDENTIFIERS_KEY => [],
425+
$ATTENDEE_WAITING_LIST_PERSON_IDENTIFIERS_KEY => [],
412426
$LECTURER_PERSON_IDENTIFIERS_KEY => [],
413427
];
414428
$courseGroupPeopleMap[$courseGroupIdentifier] = $courseGroupPeople;
@@ -423,6 +437,7 @@ public function getGroupsByCourse(string $courseIdentifier, array $options = [])
423437
'identifier' => $courseGroupPeople->getUid(),
424438
'name' => $courseGroupPeople->getName(Options::getLanguage($options) ?? self::DEFAULT_LANGUAGE_TAG),
425439
$ATTENDEE_PERSON_IDENTIFIERS_KEY => $courseGroupPeopleMap[$courseGroupPeople->getUid()][$ATTENDEE_PERSON_IDENTIFIERS_KEY] ?? [],
440+
$ATTENDEE_WAITING_LIST_PERSON_IDENTIFIERS_KEY => $courseGroupPeopleMap[$courseGroupPeople->getUid()][$ATTENDEE_WAITING_LIST_PERSON_IDENTIFIERS_KEY] ?? [],
426441
$LECTURER_PERSON_IDENTIFIERS_KEY => $courseGroupPeopleMap[$courseGroupPeople->getUid()][$LECTURER_PERSON_IDENTIFIERS_KEY] ?? [],
427442
];
428443
}
@@ -538,6 +553,7 @@ private function getCourseApi(): CourseApi
538553
$this->config[Configuration::CAMPUS_ONLINE_NODE][Configuration::CLIENT_SECRET_NODE] ?? ''
539554
)
540555
);
556+
$this->courseApi->setLogger($this->logger);
541557
}
542558

543559
return $this->courseApi;
@@ -576,7 +592,6 @@ public function getCoursesInternal(int $currentPageNumber, int $maxNumItemsPerPa
576592
}
577593

578594
if ($filter = Options::getFilter($options)) {
579-
dump($filter);
580595
$pathMapping = [
581596
'identifier' => $CACHED_COURSE_ENTITY_ALIAS.'.'.CachedCourse::UID_COLUMN_NAME,
582597
'code' => $CACHED_COURSE_ENTITY_ALIAS.'.'.CachedCourse::COURSE_CODE_COLUMN_NAME,

0 commit comments

Comments
 (0)