switch to the next subtask when prev is solved
authorLiana.Bakradze <liana.bakradze@jetbrains.com>
Thu, 29 Sep 2016 16:58:45 +0000 (19:58 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Thu, 17 Nov 2016 14:08:22 +0000 (17:08 +0300)
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCAddAnswerPlaceholder.java
python/educational-core/student/src/com/jetbrains/edu/learning/checker/StudyCheckTask.java
python/educational-core/student/src/com/jetbrains/edu/learning/courseFormat/Task.java

index efb6a91a46b612acc8edd08f5076a722a9c0f91d..564c68abc7a9ac8a0276a16e1bceab4546bebca2 100644 (file)
@@ -92,7 +92,7 @@ public class CCAddAnswerPlaceholder extends CCAnswerPlaceholderAction {
     String answerPlaceholderText = dlg.getTaskText();
     answerPlaceholder.setPossibleAnswer(model.hasSelection() ? model.getSelectedText() : defaultPlaceholderText);
     answerPlaceholder.setTaskText(StringUtil.notNullize(answerPlaceholderText));
-    answerPlaceholder.setLength(StringUtil.notNullize(answerPlaceholderText).length());
+    answerPlaceholder.setLength(model.hasSelection() ? StringUtil.notNullize(answerPlaceholderText).length() : 0);
     answerPlaceholder.setHints(dlg.getHints());
 
     if (!model.hasSelection()) {
index 36b81208eb809dbcadb4d7257a860d62d26f4fdf..168012eef90aceccc17969aadd83e79833d55492 100644 (file)
@@ -11,10 +11,7 @@ import com.intellij.openapi.ui.MessageType;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.jetbrains.edu.learning.StudyPluginConfigurator;
-import com.jetbrains.edu.learning.StudyState;
-import com.jetbrains.edu.learning.StudyTaskManager;
-import com.jetbrains.edu.learning.StudyUtils;
+import com.jetbrains.edu.learning.*;
 import com.jetbrains.edu.learning.actions.StudyAfterCheckAction;
 import com.jetbrains.edu.learning.core.EduNames;
 import com.jetbrains.edu.learning.core.EduUtils;
@@ -189,8 +186,15 @@ public class StudyCheckTask extends com.intellij.openapi.progress.Task.Backgroun
           });
       }
       else {
-        ApplicationManager.getApplication()
-          .invokeLater(() -> StudyCheckUtils.showTestResultPopUp(message, MessageType.INFO.getPopupBackground(), myProject));
+        boolean hasMoreSubtasks = myTask.hasSubtasks() && myTask.getActiveSubtaskIndex() != myTask.getSubtaskNum() - 1;
+        int visibleSubtaskIndex = myTask.getActiveSubtaskIndex() + 1;
+        ApplicationManager.getApplication().invokeLater(() -> {
+          String resultMessage = !hasMoreSubtasks ? message : "Subtask " + visibleSubtaskIndex + "/" + myTask.getSubtaskNum() + " solved";
+          StudyCheckUtils.showTestResultPopUp(resultMessage, MessageType.INFO.getPopupBackground(), myProject);
+          if (hasMoreSubtasks) {
+            StudySubtaskUtils.switchStep(myProject, myTask, myTask.getActiveSubtaskIndex() + 1);
+          }
+        });
       }
     }
   }
index 4d582f6016161406d053b974adb1f9184f132f47..aaa72fe823bee8954693dc59ff3b0cffbd37213e 100644 (file)
@@ -220,12 +220,15 @@ public class Task implements StudyItem {
   }
   
   public void setStatus(StudyStatus status) {
-    myStatus = status;
     for (TaskFile taskFile : taskFiles.values()) {
       for (AnswerPlaceholder placeholder : taskFile.getActivePlaceholders()) {
         placeholder.setStatus(status);
       }
     }
+    if (status == StudyStatus.Solved && hasSubtasks() && getActiveSubtaskIndex() != getSubtaskNum() - 1) {
+      return;
+    }
+    myStatus = status;
   }
 
   public Task copy() {