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) {
final Map<String, String> additionalAttributes = new HashMap<>(quizData.getAdditionalAttributes());
additionalAttributes.put(QuizData.QUIZ_ATTR_DESCRIPTION, quizData.description);
additionalAttributes.put(QuizData.QUIZ_ATTR_START_URL, quizData.startURL);
if (StringUtils.isNotBlank(quizData.description)) {
additionalAttributes.put(QuizData.QUIZ_ATTR_DESCRIPTION, quizData.description);
}
if (StringUtils.isNotBlank(quizData.startURL)) {
additionalAttributes.put(QuizData.QUIZ_ATTR_START_URL, quizData.startURL);
}
this.additionalAttributesDAO.saveAdditionalAttributes(
EntityType.EXAM,
examId,
additionalAttributes)
.getOrThrow();
if (!additionalAttributes.isEmpty()) {
this.additionalAttributesDAO.saveAdditionalAttributes(
EntityType.EXAM,
examId,
additionalAttributes)
.getOrThrow();
}
return quizData;
}