Show non-adaptive courses first in course list in Project Wizard
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Tue, 2 Aug 2016 11:45:53 +0000 (14:45 +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/StudyUtils.java
python/educational-core/student/src/com/jetbrains/edu/learning/courseGeneration/StudyProjectGenerator.java

index 310e99f046fc6ce2a38affb9f5ed99e7a4131595..4f11fdb8ff2b065614408a2fc33080d2aa1619bc 100644 (file)
@@ -57,6 +57,7 @@ import com.jetbrains.edu.learning.core.EduUtils;
 import com.jetbrains.edu.learning.courseFormat.*;
 import com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator;
 import com.jetbrains.edu.learning.editor.StudyEditor;
+import com.jetbrains.edu.learning.stepic.CourseInfo;
 import com.jetbrains.edu.learning.ui.StudyToolWindow;
 import com.jetbrains.edu.learning.ui.StudyToolWindowFactory;
 import com.petebevin.markdown.MarkdownProcessor;
@@ -66,9 +67,7 @@ import org.jetbrains.annotations.Nullable;
 import javax.swing.*;
 import java.awt.*;
 import java.io.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
+import java.util.*;
 import java.util.List;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
@@ -713,4 +712,15 @@ public class StudyUtils {
       JBPopupFactory.getInstance().createHtmlTextBalloonBuilder("Couldn't post your reaction", MessageType.ERROR, null).createBalloon();
     showCheckPopUp(project, balloon);
   }
+
+  public static void sortCourses(List<CourseInfo> result) {
+    // sort courses so as to have non-adaptive courses in the beginning of the list
+    Collections.sort(result, (c1, c2) -> {
+      if ((c1.isAdaptive() && c2.isAdaptive()) || (!c1.isAdaptive() && !c2.isAdaptive())) {
+        return 0;
+      }
+
+      return c1.isAdaptive() ? 1 : -1;
+    });
+  }
 }
index 5c11ea5aad1332042daa3e5af1555e5613e02344..2169032449f72bfeaeecdd163c4dbcdeaeb3f6e1 100644 (file)
@@ -383,6 +383,7 @@ public class StudyProjectGenerator {
     if (myCourses.isEmpty()) {
       myCourses = getBundledIntro();
     }
+    StudyUtils.sortCourses(myCourses);
     return myCourses;
   }