use of org.stepik.api.objects.lessons.Lesson in project intellij-plugins by StepicOrg.
the class LessonNode method loadData.
@Override
protected boolean loadData(@NotNull StepikApiClient stepikApiClient, long id) {
try {
CompoundUnitLesson data = getData();
if (data == null) {
return true;
}
String updateDate = data.getUpdateDate();
Lessons lessons = stepikApiClient.lessons().get().id(id).execute();
Lesson lesson;
if (!lessons.isEmpty()) {
lesson = lessons.getFirst();
} else {
lesson = new Lesson();
lesson.setId(id);
}
data.setLesson(lesson);
return !updateDate.equals(data.getUpdateDate());
} catch (StepikClientException logged) {
logger.warn(String.format("Failed load lesson data id=%d", id), logged);
}
return true;
}
use of org.stepik.api.objects.lessons.Lesson in project intellij-plugins by StepicOrg.
the class Utils method getCompoundUnitLessonStudyObject.
@NotNull
private static CompoundUnitLesson getCompoundUnitLessonStudyObject(@NotNull StepikApiClient stepikApiClient, long unitId, long lessonId) {
Units units = null;
if (unitId != 0) {
try {
units = stepikApiClient.units().get().id(unitId).execute();
} catch (StepikClientException e) {
logger.warn(e);
units = new Units();
}
}
Unit unit = null;
if (unitId != 0 && !units.isEmpty()) {
unit = units.getFirst();
}
Lesson lesson = getLesson(lessonId, stepikApiClient);
return lesson != null ? new CompoundUnitLesson(unit, lesson) : new CompoundUnitLesson();
}
use of org.stepik.api.objects.lessons.Lesson in project intellij-plugins by StepicOrg.
the class StudyNodeFactory method createTree.
public static StudyNode createTree(@NotNull Project project, @NotNull StepikApiClient stepikApiClient, @NotNull StudyObject data) {
StudyNode root = null;
if (data instanceof Course) {
root = new CourseNode(project, stepikApiClient, (Course) data);
} else if (data instanceof Section) {
root = new SectionNode(project, stepikApiClient, (Section) data);
} else if (data instanceof Lesson) {
CompoundUnitLesson compoundData = new CompoundUnitLesson(null, (Lesson) data);
root = new LessonNode(project, stepikApiClient, compoundData);
} else if (data instanceof CompoundUnitLesson) {
root = new LessonNode(project, stepikApiClient, (CompoundUnitLesson) data);
} else if (data instanceof Step) {
root = new StepNode(project, stepikApiClient, (Step) data);
}
return root;
}
Aggregations