Search in sources :

Example 1 with StepikSubmissionsPostQuery

use of org.stepik.api.queries.submissions.StepikSubmissionsPostQuery in project intellij-plugins by StepicOrg.

the class FormListener method sendStep.

private static void sendStep(@NotNull Project project, @NotNull StepNode stepNode, @NotNull Elements elements, @NotNull StepType type, long attemptId, @Nullable String data) {
    StepikApiClient stepikApiClient = authAndGetStepikApiClient(true);
    StepikSubmissionsPostQuery query = stepikApiClient.submissions().post().attempt(attemptId);
    Reply reply = getReply(stepNode, type, elements, data);
    if (reply == null) {
        return;
    }
    query.reply(reply).executeAsync().whenComplete(((submissions, e) -> {
        if (submissions == null) {
            logger.warn("Failed send step from browser", e);
            StepikProjectManager.updateSelection(project);
            return;
        }
        if (submissions.isEmpty()) {
            logger.warn("Failed send step from browser", e);
            return;
        }
        Submission submission = submissions.getFirst();
        SendAction.checkStepStatus(project, stepikApiClient, stepNode, submission.getId(), new EmptyProgressIndicator());
    }));
}
Also used : HTMLFormElement(org.w3c.dom.html.HTMLFormElement) StepikAuthManager.authAndGetStepikApiClient(org.stepik.core.stepik.StepikAuthManager.authAndGetStepikApiClient) VirtualFile(com.intellij.openapi.vfs.VirtualFile) StudyNode(org.stepik.core.courseFormat.StudyNode) StepikSubmissionsPostQuery(org.stepik.api.queries.submissions.StepikSubmissionsPostQuery) Project(com.intellij.openapi.project.Project) Logger(com.intellij.openapi.diagnostic.Logger) Submission(org.stepik.api.objects.submissions.Submission) StepikAuthState(org.stepik.core.stepik.StepikAuthState) Files(java.nio.file.Files) StepNode(org.stepik.core.courseFormat.StepNode) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) File(java.io.File) StudyUtils(org.stepik.core.StudyUtils) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) FileChooser(javafx.stage.FileChooser) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) SendAction(org.stepik.plugin.actions.SendAction) EventListener(org.w3c.dom.events.EventListener) StepType(org.stepik.core.courseFormat.StepType) Event(org.w3c.dom.events.Event) StepikProjectManager(org.stepik.core.StepikProjectManager) StepikApiClient(org.stepik.api.client.StepikApiClient) Reply(org.stepik.api.objects.submissions.Reply) StepikAuthManager(org.stepik.core.stepik.StepikAuthManager) NotNull(org.jetbrains.annotations.NotNull) StepDescriptionUtils.getReply(org.stepik.core.ui.StepDescriptionUtils.getReply) ProjectFilesUtils.getOrCreateSrcDirectory(org.stepik.core.utils.ProjectFilesUtils.getOrCreateSrcDirectory) StepikAuthManager.authAndGetStepikApiClient(org.stepik.core.stepik.StepikAuthManager.authAndGetStepikApiClient) StepikApiClient(org.stepik.api.client.StepikApiClient) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) Submission(org.stepik.api.objects.submissions.Submission) Reply(org.stepik.api.objects.submissions.Reply) StepDescriptionUtils.getReply(org.stepik.core.ui.StepDescriptionUtils.getReply) StepikSubmissionsPostQuery(org.stepik.api.queries.submissions.StepikSubmissionsPostQuery)

Aggregations

Logger (com.intellij.openapi.diagnostic.Logger)1 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 FileChooser (javafx.stage.FileChooser)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 StepikApiClient (org.stepik.api.client.StepikApiClient)1 Reply (org.stepik.api.objects.submissions.Reply)1 Submission (org.stepik.api.objects.submissions.Submission)1 StepikSubmissionsPostQuery (org.stepik.api.queries.submissions.StepikSubmissionsPostQuery)1 StepikProjectManager (org.stepik.core.StepikProjectManager)1 StudyUtils (org.stepik.core.StudyUtils)1 StepNode (org.stepik.core.courseFormat.StepNode)1 StepType (org.stepik.core.courseFormat.StepType)1