From e269fca98e5f8dd3b355456fa6c4e38ce097fcdc Mon Sep 17 00:00:00 2001 From: uhensler <urs.hensler@frentix.com> Date: Thu, 2 Jul 2020 14:55:26 +0200 Subject: [PATCH] OO-4630: Participant may select a confirmed appointment if self confirmation --- .../AppointmentListSelectionController.java | 19 +++++++++---------- .../appointments/ui/TopicsRunController.java | 4 ++-- .../ui/_content/appointment_row.html | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/olat/modules/appointments/ui/AppointmentListSelectionController.java b/src/main/java/org/olat/modules/appointments/ui/AppointmentListSelectionController.java index 6cdb6c61de9..0be04341426 100644 --- a/src/main/java/org/olat/modules/appointments/ui/AppointmentListSelectionController.java +++ b/src/main/java/org/olat/modules/appointments/ui/AppointmentListSelectionController.java @@ -131,8 +131,13 @@ public class AppointmentListSelectionController extends AppointmentListControlle .filter(p -> p.getIdentity().getKey().equals(getIdentity().getKey())) .findFirst(); boolean selected = myParticipation.isPresent(); - boolean confirmed = Status.confirmed == appointment.getStatus(); - if (Type.finding != topic.getType() && confirmed && !selected) { + boolean confirmedByCoach = !topic.isAutoConfirmation() && Status.confirmed == appointment.getStatus(); + Integer maxParticipations = appointment.getMaxParticipations(); + Integer freeParticipations = maxParticipations != null + ? maxParticipations.intValue() - participations.size() + : null; + boolean noFreePlace = freeParticipations != null && freeParticipations < 1; + if (Type.finding != topic.getType() && !selected && (confirmedByCoach || noFreePlace)) { return null; } @@ -156,7 +161,7 @@ public class AppointmentListSelectionController extends AppointmentListControlle } } - if (selected || confirmed) { + if (selected || confirmedByCoach) { row.setTranslatedStatus(translate("appointment.status." + appointment.getStatus().name())); row.setStatusCSS("o_ap_status_" + appointment.getStatus().name()); } @@ -172,15 +177,9 @@ public class AppointmentListSelectionController extends AppointmentListControlle forgeSelectionLink(row, selected, noConfirmedAppointments); } } else if (topic.isMultiParticipation() || userHasNoConfirmedParticipation) { - Integer numberOfParticipations = Integer.valueOf(participations.size()); - row.setNumberOfParticipations(numberOfParticipations); - Integer maxParticipations = appointment.getMaxParticipations(); - Integer freeParticipations = maxParticipations != null - ? maxParticipations.intValue() - participations.size() - : null; row.setFreeParticipations(freeParticipations); - boolean selectable = Appointment.Status.confirmed == appointment.getStatus() + boolean selectable = confirmedByCoach ? false : freeParticipations == null // no limit || freeParticipations.intValue() > 0; diff --git a/src/main/java/org/olat/modules/appointments/ui/TopicsRunController.java b/src/main/java/org/olat/modules/appointments/ui/TopicsRunController.java index 453a09dd27f..045f5ebbc9a 100644 --- a/src/main/java/org/olat/modules/appointments/ui/TopicsRunController.java +++ b/src/main/java/org/olat/modules/appointments/ui/TopicsRunController.java @@ -333,9 +333,9 @@ public class TopicsRunController extends BasicController implements Activateable if (selectedAppointments == 0) { if (Type.finding != topic.getType()) { if (freeAppointments != null) { - if (freeAppointments == 1) { + if (freeAppointments.longValue() == 1) { messages.add(translate("appointments.free.one")); - } else if (freeAppointments > 1) { + } else if (freeAppointments.longValue() > 1) { messages.add(translate("appointments.free", new String[] { freeAppointments.toString() })); } } diff --git a/src/main/java/org/olat/modules/appointments/ui/_content/appointment_row.html b/src/main/java/org/olat/modules/appointments/ui/_content/appointment_row.html index 5e045784a74..d51847484fb 100644 --- a/src/main/java/org/olat/modules/appointments/ui/_content/appointment_row.html +++ b/src/main/java/org/olat/modules/appointments/ui/_content/appointment_row.html @@ -69,7 +69,7 @@ #end #if($r.isNotNull($row.getFreeParticipations())) <div> - #if($row.getFreeAppointments() == 1) + #if($row.getFreeParticipations() == 1) $r.translate("participations.free.one") #else $r.translate("participations.free", $row.getFreeParticipations().toString()) -- GitLab