From 9ce538484bd74573b83677770a94716b5a6bc152 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 28 Oct 2021 13:45:34 +0200 Subject: [PATCH] fixed single moodle course bug --- .../lms/impl/moodle/MoodleCourseDataAsyncLoader.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleCourseDataAsyncLoader.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleCourseDataAsyncLoader.java index 4d3a9730..290afbc2 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleCourseDataAsyncLoader.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleCourseDataAsyncLoader.java @@ -14,6 +14,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; @@ -215,9 +216,14 @@ public class MoodleCourseDataAsyncLoader { // then get all quizzes of courses and filter final LinkedMultiValueMap attributes = new LinkedMultiValueMap<>(); + final List courseIds = new ArrayList<>(courseData.keySet()); + if (courseIds.size() == 1) { + // NOTE: This is a workaround because the Moodle API do not support lists with only one element. + courseIds.add("0"); + } attributes.put( MoodleCourseAccess.MOODLE_COURSE_API_COURSE_IDS, - new ArrayList<>(courseData.keySet())); + courseIds); final String quizzesJSON = callMoodleRestAPI( restTemplate,