From a148b3ca65b4717e35793cc46d19cd48b57ca28e Mon Sep 17 00:00:00 2001 From: uhensler <urs.hensler@frentix.com> Date: Mon, 29 Jun 2020 10:48:44 +0200 Subject: [PATCH] OO-4630: Show right number of selected appointments --- .../ui/TopicsRunCoachController.java | 28 +++++++++++++------ .../ui/_i18n/LocalStrings_de.properties | 2 ++ .../ui/_i18n/LocalStrings_en.properties | 2 ++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/olat/course/nodes/appointments/ui/TopicsRunCoachController.java b/src/main/java/org/olat/course/nodes/appointments/ui/TopicsRunCoachController.java index fcd3ea69fed..395db9db152 100644 --- a/src/main/java/org/olat/course/nodes/appointments/ui/TopicsRunCoachController.java +++ b/src/main/java/org/olat/course/nodes/appointments/ui/TopicsRunCoachController.java @@ -205,7 +205,11 @@ public class TopicsRunCoachController extends BasicController { long confirmableAppointmentsCount = appointments.stream() .filter(a -> isConfirmable(a, appointmentKeyToParticipations)) .count(); - wrapMessage(wrapper, appointments.size(), numParticipants, confirmableAppointmentsCount); + long numAppointmentsWithParticipations = participations.stream() + .map(p -> p.getAppointment().getKey()) + .distinct() + .count(); + wrapMessage(wrapper, appointments.size(), numParticipants, numAppointmentsWithParticipations, confirmableAppointmentsCount); Date now = new Date(); Optional<Appointment> nextAppointment; @@ -252,24 +256,30 @@ public class TopicsRunCoachController extends BasicController { : false; } - private void wrapMessage(TopicWrapper wrapper, int totalAppointments, long numParticipants, long confirmableAppointmentsCount) { + private void wrapMessage(TopicWrapper wrapper, int totalAppointments, long numParticipants, + long numAppointmentsWithParticipations, long confirmableAppointmentsCount) { List<String> messages = new ArrayList<>(2); if (totalAppointments == 0) { messages.add(translate("no.appointments")); } else { - if (numParticipants == 1 && totalAppointments == 1) { + if (totalAppointments == 1) { + messages.add(translate("appointments.total.one")); + } else { + messages.add(translate("appointments.total", new String[] { String.valueOf(totalAppointments) })); + } + if (numParticipants == 1 && numAppointmentsWithParticipations == 1) { messages.add(translate("participations.selected.one.one")); - } else if (numParticipants == 1 && totalAppointments > 1) { - messages.add(translate("participations.selected.one.many", new String[] { String.valueOf(totalAppointments) })); - } else if (numParticipants > 1 && totalAppointments == 1) { + } else if (numParticipants == 1 && numAppointmentsWithParticipations > 1) { + messages.add(translate("participations.selected.one.many", new String[] { String.valueOf(numAppointmentsWithParticipations) })); + } else if (numParticipants > 1 && numAppointmentsWithParticipations == 1) { messages.add(translate("participations.selected.many.one", new String[] { String.valueOf(numParticipants) })); - } else if (numParticipants > 1 && totalAppointments > 1) { - messages.add(translate("participations.selected.many.many", new String[] { String.valueOf(numParticipants), String.valueOf(numParticipants) })); + } else if (numParticipants > 1 && numAppointmentsWithParticipations > 1) { + messages.add(translate("participations.selected.many.many", new String[] { String.valueOf(numParticipants), String.valueOf(numAppointmentsWithParticipations) })); } else { messages.add(translate("participations.selected.many.many", new String[] { String.valueOf(0), String.valueOf(0) })); } - if (Type.finding != wrapper.getTopic().getType()) { + if (!wrapper.getTopic().isAutoConfirmation() && numAppointmentsWithParticipations > 0) { if (confirmableAppointmentsCount == 1) { messages.add(translate("appointments.confirmable.one")); } else if (confirmableAppointmentsCount > 1) { diff --git a/src/main/java/org/olat/course/nodes/appointments/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/course/nodes/appointments/ui/_i18n/LocalStrings_de.properties index 01ae64d6b92..137a1adcbfd 100644 --- a/src/main/java/org/olat/course/nodes/appointments/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/course/nodes/appointments/ui/_i18n/LocalStrings_de.properties @@ -42,6 +42,8 @@ appointments.select.multi.message=W\u00e4hlen Sie bitte die gew\u00fcnschten Ter appointments.select.one.message=W\u00e4hlen Sie bitte den gew\u00fcnschten Termin aus. appointments.selected=Sie haben {0} Termine ausgew\u00e4hlt. appointments.selected.not.confirmed=Es wurde noch kein Termin best\u00e4tigt. +appointments.total=Es sind insgesamt {0} Termine vorhanden. +appointments.total.one=Es ist insgesamt ein Termin vorhanden. condition.accessibility.title=Zugang config.confirmation=Terminbest\u00e4tigung durch Coach config.multi.participation=Auswahl mehrerer Termine diff --git a/src/main/java/org/olat/course/nodes/appointments/ui/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/course/nodes/appointments/ui/_i18n/LocalStrings_en.properties index 5e062eeb58a..3e19c107b38 100644 --- a/src/main/java/org/olat/course/nodes/appointments/ui/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/course/nodes/appointments/ui/_i18n/LocalStrings_en.properties @@ -42,6 +42,8 @@ appointments.select.multi.message=Please select the desired appointments. appointments.select.one.message=Please select the desired appointment. appointments.selected=You have {0} appointments selected. appointments.selected.not.confirmed=No appointment has been confirmed yet. +appointments.total=There are {0} appointments available. +appointments.total.one=There is one appointment available. condition.accessibility.title=Access config.confirmation=Confirmation by coach config.multi.participation=Selection of several appointments -- GitLab