get course language from stepic
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 24 Feb 2015 12:07:52 +0000 (15:07 +0300)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 24 Feb 2015 12:07:52 +0000 (15:07 +0300)
python/educational/src/com/jetbrains/edu/stepic/CourseInfo.java
python/educational/src/com/jetbrains/edu/stepic/EduStepicConnector.java

index 161dc10b059b301f6e056de065e2d47cb2f00f88..38815badc45b016c8a41589e5a853cc339eb4de4 100644 (file)
@@ -15,14 +15,18 @@ public class CourseInfo {
   private String myName;
   @SerializedName("summary")
   private String myDescription;
+  @SerializedName("course_format")
+  //course type in format "pycharm <language>"
+  private String myType;
 
   private String myAuthor;
-  public static CourseInfo INVALID_COURSE = new CourseInfo("", "", "");
+  public static CourseInfo INVALID_COURSE = new CourseInfo("", "", "", "");
 
-  public CourseInfo(String name, String author, String description) {
+  public CourseInfo(String name, String author, String description, String type) {
     myName = name;
     myAuthor = author;
     myDescription = description;
+    myType = type;
   }
 
   public String getName() {
@@ -37,6 +41,10 @@ public class CourseInfo {
     return myDescription;
   }
 
+  public String getType() {
+    return myType;
+  }
+
   @Override
   public String toString() {
     return myName;
index a6e45bbd7c0326c7b9d7a8753e2a112a6b36b85c..56bd969aa9f8cc2fac30a6a41860aa62f3ae1cf3 100644 (file)
@@ -41,6 +41,8 @@ public class EduStepicConnector {
   private static final String ourDomain = "stepic.org";
   private static String ourSessionId = "524iethiwju2tjywaqmf7tbwx0p0jk1b";
   private static String ourCSRFToken = "LJ9n6OyLVA7hxU94dlYWUu65MF51Nx37";
+  //this prefix indicates that course can be opened by educational plugin
+  public static final String PYCHARM_PREFIX = "pycharm ";
 
   private EduStepicConnector() {
   }
@@ -84,7 +86,8 @@ public class EduStepicConnector {
     course.setAuthor(info.getAuthor());
     course.setDescription(info.getDescription());
     course.setName(info.getName());
-    course.setLanguage("Python");  // TODO: get from stepic
+    String courseType = info.getType();
+    course.setLanguage(courseType.substring(PYCHARM_PREFIX.length()));
     course.setUpToDate(true);  // TODO: get from stepic
     try {
       for (Integer section : info.sections) {