From 729b9f8b7b6d89c2f312d066d42e2fdf6e3c0066 Mon Sep 17 00:00:00 2001 From: "Liana.Bakradze" Date: Tue, 24 Jan 2017 18:43:43 +0300 Subject: [PATCH] EDU-858 Migration doesn't work from version 2.0 to 3.5 We don't add attributes that can be empty when migrating from 2.0 to 3.0, so we got exception when trying to get these attributes in 3.0 format --- .../edu/learning/StudySerializationUtils.java | 10 ++++++---- .../educational-core/student/testData/migration/4.xml | 5 ----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java b/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java index b1c0776513c1..0163a3b895a4 100644 --- a/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java +++ b/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java @@ -219,17 +219,19 @@ public class StudySerializationUtils { for (Element placeholder : getChildList(taskFileElement, ANSWER_PLACEHOLDERS)) { Element valueElement = new Element(SUBTASK_INFO); addChildMap(placeholder, SUBTASK_INFOS, Collections.singletonMap(String.valueOf(0), valueElement)); - for (String childName : ContainerUtil.list(HINT, ADDITIONAL_HINTS, POSSIBLE_ANSWER, SELECTED, STATUS, TASK_TEXT)) { - Element child = getChildWithName(placeholder, childName); + for (String childName : ContainerUtil.list(HINT, POSSIBLE_ANSWER, SELECTED, STATUS, TASK_TEXT)) { + Element child = getChildWithName(placeholder, childName, true); + if (child == null) { + continue; + } valueElement.addContent(child.clone()); } renameElement(getChildWithName(valueElement, TASK_TEXT), PLACEHOLDER_TEXT); - List additionalHints = ContainerUtil.map(getChildList(valueElement, ADDITIONAL_HINTS), Element::clone); Element hint = getChildWithName(valueElement, HINT); Element firstHint = new Element(OPTION).setAttribute(VALUE, hint.getAttributeValue(VALUE)); List newHints = new ArrayList<>(); newHints.add(firstHint); - newHints.addAll(additionalHints); + newHints.addAll(ContainerUtil.map(getChildList(placeholder, ADDITIONAL_HINTS, true), Element::clone)); addChildList(valueElement, "hints", newHints); } } diff --git a/python/educational-core/student/testData/migration/4.xml b/python/educational-core/student/testData/migration/4.xml index 944ffd640b2e..b0c11ff543b8 100644 --- a/python/educational-core/student/testData/migration/4.xml +++ b/python/educational-core/student/testData/migration/4.xml @@ -69,11 +69,6 @@