use last subtask index instead of subtask number
[idea/community.git] / python / educational-core / course-creator / src / com / jetbrains / edu / coursecreator / actions / CCNewSubtaskAction.java
index 5f84c1bf25b0bc99780067764f845c098d9d7cb8..11581f3d8830b75b0131d69afd8b41feda0581b8 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.psi.PsiManager;
 import com.jetbrains.edu.coursecreator.CCLanguageManager;
 import com.jetbrains.edu.coursecreator.CCUtils;
 import com.jetbrains.edu.coursecreator.settings.CCSettings;
+import com.jetbrains.edu.learning.StudySubtaskUtils;
 import com.jetbrains.edu.learning.StudyTaskManager;
 import com.jetbrains.edu.learning.StudyUtils;
 import com.jetbrains.edu.learning.core.EduNames;
@@ -53,17 +54,16 @@ public class CCNewSubtaskAction extends DumbAwareAction {
     if (taskFile == null) {
       return;
     }
-    VirtualFile taskDir = StudyUtils.getTaskDir(virtualFile);
+    Task task = taskFile.getTask();
+    VirtualFile taskDir = task.getTaskDir(project);
     if (taskDir == null) {
       return;
     }
-    Task task = taskFile.getTask();
     createTestsForNewSubtask(project, task);
-    int num = task.getSubtaskNum();
+    int num = task.getLastSubtaskIndex() + 1;
     createTaskDescriptionFile(project, taskDir, num);
-    task.setSubtaskNum(num + 1);
-    task.setActiveSubtaskIndex(num);
-    //TODO: switch subtask
+    task.setLastSubtaskIndex(num);
+    StudySubtaskUtils.switchStep(project, task, num);
   }
 
   private static void createTestsForNewSubtask(Project project, Task task) {