mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
remove hack for storing multiple hints
This commit is contained in:
committed by
liana.bakradze
parent
b81e4aebdd
commit
d922d92ab1
+8
@@ -22,6 +22,7 @@ import org.jdom.output.XMLOutputter;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -223,6 +224,13 @@ public class StudySerializationUtils {
|
||||
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);
|
||||
addChildList(valueElement, "hints", newHints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-55
@@ -3,21 +3,16 @@ package com.jetbrains.edu.learning.courseFormat;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AnswerPlaceholderSubtaskInfo {
|
||||
private static final Logger LOG = Logger.getInstance(AnswerPlaceholderSubtaskInfo.class);
|
||||
@SerializedName("hint")
|
||||
@Expose private String myHint = "";
|
||||
|
||||
@SerializedName("additional_hints")
|
||||
@Expose private List<String> myAdditionalHints = new ArrayList<>();
|
||||
@SerializedName("hints")
|
||||
@Expose private List<String> myHints = new ArrayList<>();
|
||||
|
||||
@SerializedName("possible_answer")
|
||||
@Expose private String possibleAnswer = "";
|
||||
@@ -38,57 +33,25 @@ public class AnswerPlaceholderSubtaskInfo {
|
||||
myStatus = status;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public List<String> getHints() {
|
||||
if (myHint.isEmpty() && myAdditionalHints.isEmpty()) return Collections.emptyList();
|
||||
final ArrayList<String> result = new ArrayList<>();
|
||||
result.add(myHint);
|
||||
result.addAll(myAdditionalHints);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public void setHints(@NotNull final List<String> hints) {
|
||||
if (hints.isEmpty()) {
|
||||
myHint = "";
|
||||
myAdditionalHints.clear();
|
||||
}
|
||||
else {
|
||||
myHint = hints.get(0);
|
||||
myAdditionalHints = hints.subList(1, hints.size());
|
||||
}
|
||||
}
|
||||
|
||||
public void addHint(@NotNull final String text) {
|
||||
if (myHint.isEmpty() && myAdditionalHints.isEmpty()) {
|
||||
myHint = text;
|
||||
}
|
||||
else {
|
||||
myAdditionalHints.add(text);
|
||||
}
|
||||
myHints.add(text);
|
||||
}
|
||||
|
||||
public void removeHint(int i) {
|
||||
if (i == 0) {
|
||||
myHint = "";
|
||||
if (i < myHints.size()) {
|
||||
myHints.remove(i);
|
||||
}
|
||||
else {
|
||||
if (i - 1 <myAdditionalHints.size()) {
|
||||
myAdditionalHints.remove(i - 1);
|
||||
}
|
||||
else {
|
||||
LOG.warn("Trying to remove nonexistent hint. Hint to remove number: " + (i - 1) + "number of hints: " + getHints().size());
|
||||
}
|
||||
LOG.warn("Trying to remove nonexistent hint. Hint to remove number: " + i + " number of hints: " + myHints.size());
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> getAdditionalHints() {
|
||||
return myAdditionalHints;
|
||||
public List<String> getHints() {
|
||||
return myHints;
|
||||
}
|
||||
|
||||
public void setAdditionalHints(@Nullable final List<String> additionalHints) {
|
||||
myAdditionalHints = additionalHints;
|
||||
public void setHints(List<String> hints) {
|
||||
myHints = hints;
|
||||
}
|
||||
|
||||
public String getPossibleAnswer() {
|
||||
@@ -107,14 +70,6 @@ public class AnswerPlaceholderSubtaskInfo {
|
||||
myPlaceholderText = placeholderText;
|
||||
}
|
||||
|
||||
public String getHint() {
|
||||
return myHint;
|
||||
}
|
||||
|
||||
public void setHint(String hint) {
|
||||
myHint = hint;
|
||||
}
|
||||
|
||||
public boolean getSelected() {
|
||||
return mySelected;
|
||||
}
|
||||
|
||||
@@ -78,6 +78,12 @@
|
||||
<option name="selected" value="false"/>
|
||||
<option name="status" value="Solved"/>
|
||||
<option name="placeholderText" value="test text"/>
|
||||
<option name="hints">
|
||||
<list>
|
||||
<option value="hint 1"/>
|
||||
<option value="hint 2"/>
|
||||
</list>
|
||||
</option>
|
||||
</AnswerPlaceholderSubtaskInfo>
|
||||
</value>
|
||||
</entry>
|
||||
|
||||
Reference in New Issue
Block a user