Fix EDU-663 Exception on adding next recommendation in adaptive course
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Wed, 3 Aug 2016 12:27:02 +0000 (15:27 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Wed, 3 Aug 2016 15:58:55 +0000 (18:58 +0300)
python/educational-core/student/src/com/jetbrains/edu/learning/stepic/EduAdaptiveStepicConnector.java

index ced98a78dd423cc428f2504d1d6a86f8401befad..21d0c10863e3091149f64ccb8db40d3e1984faa1 100644 (file)
@@ -268,18 +268,18 @@ public class EduAdaptiveStepicConnector {
             if (lessonDir != null) {
               ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> {
                 try {
+                  final File lessonDirectory = new File(course.getCourseDirectory(), EduNames.LESSON + String.valueOf(adaptive.getIndex()));
+                  final File taskDir = new File(lessonDirectory, EduNames.TASK + String.valueOf(task.getIndex()));
+                  StudyProjectGenerator.flushTask(task, taskDir);
+                  StudyProjectGenerator.flushCourseJson(course, new File(course.getCourseDirectory()));
                   StudyGenerator.createTask(task, lessonDir, new File(course.getCourseDirectory(), lessonDir.getName()), project);
+                  adaptive.initLesson(course, true);
                 }
                 catch (IOException e) {
                   LOG.warn(e.getMessage());
                 }
               }));
             }
-
-            final File lessonDirectory = new File(course.getCourseDirectory(), EduNames.LESSON + String.valueOf(adaptive.getIndex()));
-            StudyProjectGenerator.flushLesson(lessonDirectory, adaptive);
-            StudyProjectGenerator.flushCourseJson(course, new File(course.getCourseDirectory()));
-            adaptive.initLesson(course, true);
           }
         }
         ApplicationManager.getApplication().invokeLater(() -> {