Do not save empty choice parameters for non-choice tasks

This commit is contained in:
Valentina Kiryushkina
2016-12-19 14:58:03 +03:00
parent 46f9e05c48
commit 1ed16d75d3
2 changed files with 9 additions and 3 deletions
@@ -44,7 +44,7 @@ public class Task implements StudyItem {
@Transient private Lesson myLesson;
@Expose @SerializedName("update_date") private Date myUpdateDate;
@Expose @SerializedName("choice_parameters") private ChoiceParameters myChoiceParameters = new ChoiceParameters();
@Expose @SerializedName("choice_parameters") private ChoiceParameters myChoiceParameters;
private int myActiveSubtaskIndex = 0;
@SerializedName("last_subtask_index")
@Expose private int myLastSubtaskIndex = 0;
@@ -54,6 +54,12 @@ public class Task implements StudyItem {
public Task(@NotNull final String name) {
this.name = name;
}
public static Task createChoiceTask(@NotNull String name) {
final Task task = new Task(name);
task.setChoiceParameters(new ChoiceParameters());
return task;
}
/**
* Initializes state of task file
@@ -326,7 +332,7 @@ public class Task implements StudyItem {
}
public boolean isChoiceTask() {
return !myChoiceParameters.getChoiceVariants().isEmpty();
return myChoiceParameters != null;
}
// used for serialization
@@ -156,7 +156,7 @@ public class EduAdaptiveStepicConnector {
@NotNull String lessonName,
@NotNull StepicWrappers.Step block,
int stepId) {
final Task task = new Task(lessonName);
final Task task = Task.createChoiceTask(lessonName);
task.setStepId(stepId);
task.setText(block.text);