use of org.stepik.core.courseFormat.StudyNode in project intellij-plugins by StepicOrg.
the class ProjectPsiFilesUtils method isNotMovableOrRenameElement.
public static boolean isNotMovableOrRenameElement(@NotNull PsiElement element, @NotNull Set<Class<? extends PsiElement>> acceptableClasses) {
Project project = element.getProject();
StudyNode root = StepikProjectManager.getProjectRoot(project);
if (root == null) {
return false;
}
if (notAccept(element, acceptableClasses)) {
return false;
}
PsiFileSystemItem file = getFile(element);
if (file == null) {
return false;
}
String path = getRelativePath(file);
return ProjectFilesUtils.isNotMovableOrRenameElement(root, path);
}
use of org.stepik.core.courseFormat.StudyNode in project intellij-plugins by StepicOrg.
the class StepikDirectoryNode method getTypeSortWeight.
@Override
public int getTypeSortWeight(boolean sortByType) {
StudyNode node = StudyUtils.getStudyNode(myProject, getValue().getVirtualFile());
String path = getRelativePath(getValue());
if (node != null && node.getPath().equals(path)) {
return node.getPosition();
}
return Integer.MAX_VALUE;
}
use of org.stepik.core.courseFormat.StudyNode in project intellij-plugins by StepicOrg.
the class StudyUtils method getStudyNode.
@Nullable
public static StudyNode getStudyNode(@NotNull Project project, @NotNull VirtualFile nodeVF) {
String path = getRelativePath(project, nodeVF);
StudyNode root = StepikProjectManager.getProjectRoot(project);
if (root == null) {
return null;
}
return getStudyNode(root, path);
}
use of org.stepik.core.courseFormat.StudyNode in project intellij-plugins by StepicOrg.
the class StudyUtils method getRecommendation.
@Nullable
public static StudyNode<?, ?> getRecommendation(@NotNull StudyNode root) {
StudyObject data = root.getData();
if (data == null || !data.isAdaptive()) {
return null;
}
StudyNode studyNode = null;
StepikApiClient stepikClient = authAndGetStepikApiClient();
if (!isAuthenticated()) {
return null;
}
try {
Recommendations recommendations = stepikClient.recommendations().get().course(root.getId()).execute();
if (!recommendations.isEmpty()) {
Recommendation recommendation = recommendations.getFirst();
long lesson = recommendation.getLesson();
Steps steps = stepikClient.steps().get().lesson(lesson).execute();
if (!steps.isEmpty()) {
long stepId = steps.getFirst().getId();
studyNode = root.getChildByClassAndId(Step.class, stepId);
}
}
} catch (StepikClientException e) {
logger.warn(e);
}
return studyNode;
}
use of org.stepik.core.courseFormat.StudyNode in project intellij-plugins by StepicOrg.
the class StepHelper method solvedLesson.
public boolean solvedLesson() {
try {
StudyNode lesson = stepNode.getParent();
if (lesson == null) {
return false;
}
StudyObject data = lesson.getData();
if (data == null) {
return false;
}
String progressId = data.getProgress();
StepikApiClient stepikApiClient = authAndGetStepikApiClient();
Progresses progresses = stepikApiClient.progresses().get().id(progressId).execute();
return !progresses.isEmpty() && progresses.getFirst().isPassed();
} catch (StepikClientException e) {
logger.warn(e);
}
return false;
}
Aggregations