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
This commit is contained in:
Liana.Bakradze
2017-01-24 18:43:43 +03:00
parent d3f783a01d
commit 729b9f8b7b
2 changed files with 6 additions and 9 deletions
@@ -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<Element> 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<Element> newHints = new ArrayList<>();
newHints.add(firstHint);
newHints.addAll(additionalHints);
newHints.addAll(ContainerUtil.map(getChildList(placeholder, ADDITIONAL_HINTS, true), Element::clone));
addChildList(valueElement, "hints", newHints);
}
}
@@ -69,11 +69,6 @@
<value>
<AnswerPlaceholderSubtaskInfo>
<option name="hint" value="hint 1"/>
<option name="additionalHints">
<list>
<option value="hint 2"/>
</list>
</option>
<option name="possibleAnswer" value="Liana"/>
<option name="selected" value="false"/>
<option name="status" value="Solved"/>