Fixed Exam quiz data update for additional attributes (delete null)

This commit is contained in:
anhefti 2022-11-14 16:24:58 +01:00
parent e1c1b10aa3
commit 8828b2f4e8

View file

@ -749,13 +749,24 @@ public class ExamDAOImpl implements ExamDAO {
additionalAttributes.put(QuizData.QUIZ_ATTR_START_URL, quizData.startURL); additionalAttributes.put(QuizData.QUIZ_ATTR_START_URL, quizData.startURL);
} }
if (!additionalAttributes.isEmpty()) { additionalAttributes.entrySet().forEach(entry -> {
this.additionalAttributesDAO.saveAdditionalAttributes( final String value = entry.getValue();
EntityType.EXAM, if (value == null) {
examId, this.additionalAttributesDAO.delete(
additionalAttributes) EntityType.EXAM,
.getOrThrow(); examId,
} entry.getKey());
} else {
this.additionalAttributesDAO.saveAdditionalAttribute(
EntityType.EXAM,
examId,
entry.getKey(),
value)
.onError(error -> log.error("Failed to save additional quiz attribute: {}",
entry.getKey(),
error));
}
});
return quizData; return quizData;
} }