prevent empty additional attributes from being saved

This commit is contained in:
anhefti 2022-10-18 10:48:11 +02:00
parent 7869ceb493
commit d5d119fe7d

View file

@ -742,14 +742,20 @@ public class ExamDAOImpl implements ExamDAO {
private QuizData saveAdditionalQuizAttributes(final Long examId, final QuizData quizData) { private QuizData saveAdditionalQuizAttributes(final Long examId, final QuizData quizData) {
final Map<String, String> additionalAttributes = new HashMap<>(quizData.getAdditionalAttributes()); final Map<String, String> additionalAttributes = new HashMap<>(quizData.getAdditionalAttributes());
if (StringUtils.isNotBlank(quizData.description)) {
additionalAttributes.put(QuizData.QUIZ_ATTR_DESCRIPTION, quizData.description); additionalAttributes.put(QuizData.QUIZ_ATTR_DESCRIPTION, quizData.description);
}
if (StringUtils.isNotBlank(quizData.startURL)) {
additionalAttributes.put(QuizData.QUIZ_ATTR_START_URL, quizData.startURL); additionalAttributes.put(QuizData.QUIZ_ATTR_START_URL, quizData.startURL);
}
if (!additionalAttributes.isEmpty()) {
this.additionalAttributesDAO.saveAdditionalAttributes( this.additionalAttributesDAO.saveAdditionalAttributes(
EntityType.EXAM, EntityType.EXAM,
examId, examId,
additionalAttributes) additionalAttributes)
.getOrThrow(); .getOrThrow();
}
return quizData; return quizData;
} }