Search in sources :

Example 21 with StepikApiClient

use of org.stepik.api.client.StepikApiClient 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;
}
Also used : StepikAuthManager.authAndGetStepikApiClient(org.stepik.core.stepik.StepikAuthManager.authAndGetStepikApiClient) StepikApiClient(org.stepik.api.client.StepikApiClient) Progresses(org.stepik.api.objects.progresses.Progresses) StudyObject(org.stepik.api.objects.StudyObject) StepikClientException(org.stepik.api.exceptions.StepikClientException) StudyNode(org.stepik.core.courseFormat.StudyNode)

Example 22 with StepikApiClient

use of org.stepik.api.client.StepikApiClient in project intellij-plugins by StepicOrg.

the class Utils method getCourseStudyObject.

@NotNull
private static StudyObject getCourseStudyObject(long id) {
    StepikApiClient stepikApiClient = authAndGetStepikApiClient();
    Course course = getCourse(stepikApiClient, id);
    return course != null ? course : EMPTY_STUDY_OBJECT;
}
Also used : StepikAuthManager.authAndGetStepikApiClient(org.stepik.core.stepik.StepikAuthManager.authAndGetStepikApiClient) StepikApiClient(org.stepik.api.client.StepikApiClient) Course(org.stepik.api.objects.courses.Course) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StepikApiClient (org.stepik.api.client.StepikApiClient)22 StepikAuthManager.authAndGetStepikApiClient (org.stepik.core.stepik.StepikAuthManager.authAndGetStepikApiClient)18 StepikClientException (org.stepik.api.exceptions.StepikClientException)12 NotNull (org.jetbrains.annotations.NotNull)9 StudyNode (org.stepik.core.courseFormat.StudyNode)5 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)4 StepNode (org.stepik.core.courseFormat.StepNode)4 Task (com.intellij.openapi.progress.Task)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 Nullable (org.jetbrains.annotations.Nullable)3 StudyObject (org.stepik.api.objects.StudyObject)3 TokenInfo (org.stepik.api.objects.auth.TokenInfo)3 Submission (org.stepik.api.objects.submissions.Submission)3 User (org.stepik.api.objects.users.User)3 StepikAuthManager.getCurrentUser (org.stepik.core.stepik.StepikAuthManager.getCurrentUser)3 Application (com.intellij.openapi.application.Application)2 Logger (com.intellij.openapi.diagnostic.Logger)2 Project (com.intellij.openapi.project.Project)2