mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make use of new stepik API
This commit is contained in:
@@ -31,6 +31,7 @@ public class CourseInfo {
|
||||
@Nullable private String username;
|
||||
|
||||
@SerializedName("update_date") private Date updateDate;
|
||||
@SerializedName("is_idea_compatible") private boolean isCompatible = true;
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
@@ -151,4 +152,12 @@ public class CourseInfo {
|
||||
public List<Integer> getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public boolean isCompatible() {
|
||||
return isCompatible;
|
||||
}
|
||||
|
||||
public void setCompatible(boolean compatible) {
|
||||
isCompatible = compatible;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-4
@@ -340,17 +340,25 @@ public class EduStepicConnector {
|
||||
}
|
||||
|
||||
private static boolean addCoursesFromStepic(List<CourseInfo> result, int pageNumber) throws IOException {
|
||||
final String url = pageNumber == 0 ? EduStepicNames.COURSES : EduStepicNames.COURSES_FROM_PAGE + String.valueOf(pageNumber);
|
||||
final StepicWrappers.CoursesContainer coursesContainer = getFromStepic(url, StepicWrappers.CoursesContainer.class);
|
||||
final URI url;
|
||||
try {
|
||||
url = new URIBuilder(EduStepicNames.COURSES).addParameter("is_idea_compatible", "true").
|
||||
addParameter("page", String.valueOf(pageNumber)).build();
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
LOG.error(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
final StepicWrappers.CoursesContainer coursesContainer = getFromStepic(url.toString(), StepicWrappers.CoursesContainer.class);
|
||||
final List<CourseInfo> courseInfos = coursesContainer.courses;
|
||||
for (CourseInfo info : courseInfos) {
|
||||
final String courseType = info.getType();
|
||||
if (!info.isAdaptive() && StringUtil.isEmptyOrSpaces(courseType)) continue;
|
||||
final List<String> typeLanguage = StringUtil.split(courseType, " ");
|
||||
// TODO: should adaptive course be of PyCharmType ?
|
||||
if (info.isAdaptive() || (typeLanguage.size() == 2 && PYCHARM_PREFIX.equals(typeLanguage.get(0)))) {
|
||||
for (Integer instructor : info.instructors) {
|
||||
final StepicUser author = getFromStepic(EduStepicNames.USERS + "/" + String.valueOf(instructor), StepicWrappers.AuthorWrapper.class).users.get(0);
|
||||
final StepicUser author = getFromStepic(EduStepicNames.USERS + "/" + String.valueOf(instructor),
|
||||
StepicWrappers.AuthorWrapper.class).users.get(0);
|
||||
info.addAuthor(author);
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -18,7 +18,6 @@ public class EduStepicNames {
|
||||
public static final String STEP_SOURCES = "/step-sources/";
|
||||
public static final String CURRENT_USER = "/stepics/1";
|
||||
public static final String COURSES = "/courses";
|
||||
public static final String COURSES_FROM_PAGE = COURSES + "?page=";
|
||||
public static final String STEPS = "/steps";
|
||||
public static final String SECTIONS = "/sections/";
|
||||
public static final String ENROLLMENTS = "/enrollments";
|
||||
|
||||
Reference in New Issue
Block a user