fixed Select all and delete doesn't work: "it's not allowed to delete answer placehol...
authorEkaterina Tuzova <Ekaterina.Tuzova@jetbrains.com>
Thu, 30 Jul 2015 08:28:55 +0000 (11:28 +0300)
committerEkaterina Tuzova <Ekaterina.Tuzova@jetbrains.com>
Thu, 30 Jul 2015 08:30:19 +0000 (11:30 +0300)
python/educational/interactive-learning/src/com/jetbrains/edu/learning/StudyTaskManager.java

index 1722e67aedfa131f13b961c65885a6d5cc808fb6..5ca158f09fe5d4838ca1e27b82f9e0d174573ad2 100644 (file)
@@ -34,6 +34,7 @@ import java.util.Map;
 public class StudyTaskManager implements PersistentStateComponent<StudyTaskManager>, DumbAware {
   private Course myCourse;
   public Map<AnswerPlaceholder, StudyStatus> myStudyStatusMap = new HashMap<AnswerPlaceholder, StudyStatus>();
+  public Map<TaskFile, StudyStatus> myTaskStatusMap = new HashMap<TaskFile, StudyStatus>();
   public Map<Task, List<UserTest>> myUserTests = new HashMap<Task, List<UserTest>>();
 
   private StudyTaskManager() {
@@ -89,6 +90,12 @@ public class StudyTaskManager implements PersistentStateComponent<StudyTaskManag
   }
 
   public void setStatus(TaskFile file, StudyStatus status) {
+    if (file.getAnswerPlaceholders().isEmpty()) {
+      if (myTaskStatusMap == null) {
+        myTaskStatusMap = new HashMap<TaskFile, StudyStatus>();
+      }
+      myTaskStatusMap.put(file, status);
+    }
     for (AnswerPlaceholder answerPlaceholder : file.getAnswerPlaceholders()) {
       setStatus(answerPlaceholder, status);
     }
@@ -128,12 +135,17 @@ public class StudyTaskManager implements PersistentStateComponent<StudyTaskManag
   }
 
   private StudyStatus getStatus(@NotNull final TaskFile file) {
+    if (file.getAnswerPlaceholders().isEmpty()) {
+      if (myTaskStatusMap == null) return StudyStatus.Solved;
+      return myTaskStatusMap.get(file);
+
+    }
     for (AnswerPlaceholder answerPlaceholder : file.getAnswerPlaceholders()) {
-      StudyStatus windowStatus = getStatus(answerPlaceholder);
-      if (windowStatus == StudyStatus.Failed) {
+      StudyStatus placeholderStatus = getStatus(answerPlaceholder);
+      if (placeholderStatus == StudyStatus.Failed) {
         return StudyStatus.Failed;
       }
-      if (windowStatus == StudyStatus.Unchecked) {
+      if (placeholderStatus == StudyStatus.Unchecked) {
         return StudyStatus.Unchecked;
       }
     }