SEBSERV-212 fixed quizz mapping bug

This commit is contained in:
anhefti 2021-07-19 12:11:05 +02:00
parent 86f3b61272
commit a59f5bd375

View file

@ -476,12 +476,8 @@ public class MoodleCourseAccess extends AbstractCourseAccess {
final Map<String, CourseData> finalCourseDataRef = courseData;
courseQuizData.quizzes
.forEach(quiz -> {
final CourseData course = finalCourseDataRef.get(quiz.course);
if (course != null) {
course.quizzes.add(quiz);
}
});
.stream()
.forEach(quiz -> fillSelectedQuizzes(quizIds, finalCourseDataRef, quiz));
final String urlPrefix = (lmsSetup.lmsApiUrl.endsWith(Constants.URL_PATH_SEPARATOR))
? lmsSetup.lmsApiUrl + MOODLE_QUIZ_START_URL_PATH
@ -510,6 +506,27 @@ public class MoodleCourseAccess extends AbstractCourseAccess {
}
}
private void fillSelectedQuizzes(
final Set<String> quizIds,
final Map<String, CourseData> finalCourseDataRef,
final CourseQuiz quiz) {
try {
final CourseData course = finalCourseDataRef.get(quiz.course);
if (course != null) {
final String internalQuizId = getInternalQuizId(
quiz.course_module,
course.id,
course.short_name,
course.idnumber);
if (quizIds.contains(internalQuizId)) {
course.quizzes.add(quiz);
}
}
} catch (final Exception e) {
log.error("Failed to verify selected quiz for course: {}", e.getMessage());
}
}
private Collection<CourseData> getCoursesForIds(
final MoodleAPIRestTemplate restTemplate,
final Set<String> ids) {