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