use of org.stepik.api.objects.sections.Sections in project intellij-plugins by StepicOrg.
the class LessonNode method getCourseId.
@Override
public long getCourseId(@NotNull StepikApiClient stepikApiClient) {
StudyNode parent = getParent();
if (parent != null) {
return parent.getCourseId(stepikApiClient);
}
if (courseId != 0) {
return courseId;
}
CompoundUnitLesson data = getData();
int sectionId = data != null ? data.getUnit().getSection() : 0;
if (sectionId == 0) {
return 0;
}
try {
Sections sections = stepikApiClient.sections().get().id(sectionId).execute();
if (sections.isEmpty()) {
return 0;
}
courseId = sections.getFirst().getCourse();
return courseId;
} catch (StepikClientException ignored) {
}
return 0;
}
use of org.stepik.api.objects.sections.Sections in project intellij-plugins by StepicOrg.
the class SectionNode method loadData.
@Override
protected boolean loadData(@NotNull StepikApiClient stepikApiClient, long id) {
try {
Sections sections = stepikApiClient.sections().get().id(id).execute();
Section data;
if (!sections.isEmpty()) {
data = sections.getFirst();
} else {
data = new Section();
data.setId(id);
}
Section oldData = this.getData();
setData(data);
return oldData == null || !oldData.getUpdateDate().equals(data.getUpdateDate());
} catch (StepikClientException logged) {
logger.warn(String.format("Failed load section data id=%d", id), logged);
}
return true;
}
use of org.stepik.api.objects.sections.Sections in project intellij-plugins by StepicOrg.
the class CourseNode method getChildDataList.
@Override
protected List<Section> getChildDataList(@NotNull StepikApiClient stepikApiClient) {
Sections sections = new Sections();
try {
Course data = getData();
List<Long> sectionsIds = data != null ? getData().getSections() : Collections.emptyList();
if (!sectionsIds.isEmpty()) {
sections = stepikApiClient.sections().get().id(sectionsIds).execute();
}
} catch (StepikClientException logged) {
logger.warn("A course initialization don't is fully", logged);
}
return sections.getSections();
}
Aggregations