use of org.stepik.api.objects.StudyObject in project intellij-plugins by StepicOrg.
the class StepikPyProjectGenerator method fireStateChanged.
@Override
public void fireStateChanged() {
if (!keepLocation && getLocationField() != null) {
StudyObject studyObject = wizardStep.getSelectedStudyObject();
String projectDirectory = new File(getLocation()).getParent();
String projectName = ProjectWizardUtils.getProjectDefaultName(projectDirectory, studyObject);
setLocation(projectDirectory + "/" + projectName);
}
super.fireStateChanged();
}
use of org.stepik.api.objects.StudyObject 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.api.objects.StudyObject 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