Search in sources :

Example 1 with StudyCheckTask

use of com.jetbrains.edu.learning.checker.StudyCheckTask in project intellij-community by JetBrains.

the class PyStudyCheckAction method getCheckTask.

@NotNull
private StudyCheckTask getCheckTask(@NotNull final Project project, final StudyState studyState, final StudyTestRunner testRunner, final Process testProcess, final String commandLine) {
    return new StudyCheckTask(project, studyState, myCheckInProgress, testProcess, commandLine) {

        @Override
        protected void onTaskFailed(@NotNull String message) {
            ApplicationManager.getApplication().invokeLater(() -> {
                if (myTaskDir == null)
                    return;
                myTask.setStatus(StudyStatus.Failed);
                for (Map.Entry<String, TaskFile> entry : myTask.getTaskFiles().entrySet()) {
                    final String name = entry.getKey();
                    final TaskFile taskFile = entry.getValue();
                    if (taskFile.getActivePlaceholders().size() < 2) {
                        continue;
                    }
                    final Course course = myTaskManger.getCourse();
                    if (course != null && EduNames.STUDY.equals(course.getCourseMode())) {
                        CommandProcessor.getInstance().runUndoTransparentAction(() -> ApplicationManager.getApplication().runWriteAction(() -> {
                            StudyCheckUtils.runSmartTestProcess(myTaskDir, testRunner, name, taskFile, project);
                        }));
                    }
                }
                final StudyToolWindow toolWindow = StudyUtils.getStudyToolWindow(project);
                if (toolWindow != null) {
                    final Course course = StudyTaskManager.getInstance(project).getCourse();
                    if (course != null) {
                        if (course.isAdaptive()) {
                            if (myTask.isChoiceTask()) {
                                StudyCheckUtils.showTestResultPopUp("Wrong answer", MessageType.ERROR.getPopupBackground(), project);
                            } else {
                                StudyCheckUtils.showTestResultPopUp("Wrong answer", MessageType.ERROR.getPopupBackground(), project);
                                StudyCheckUtils.showTestResultsToolWindow(project, message, false);
                            }
                            repaintChoicePanel(project, myTask);
                        } else {
                            StudyCheckUtils.showTestResultPopUp(message, MessageType.ERROR.getPopupBackground(), project);
                        }
                    }
                    StudyCheckUtils.navigateToFailedPlaceholder(myStudyState, myTask, myTaskDir, project);
                }
            });
        }
    };
}
Also used : TaskFile(com.jetbrains.edu.learning.courseFormat.TaskFile) StudyToolWindow(com.jetbrains.edu.learning.ui.StudyToolWindow) StudyCheckTask(com.jetbrains.edu.learning.checker.StudyCheckTask) Course(com.jetbrains.edu.learning.courseFormat.Course) NotNull(org.jetbrains.annotations.NotNull) Map(java.util.Map) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StudyCheckTask (com.jetbrains.edu.learning.checker.StudyCheckTask)1 Course (com.jetbrains.edu.learning.courseFormat.Course)1 TaskFile (com.jetbrains.edu.learning.courseFormat.TaskFile)1 StudyToolWindow (com.jetbrains.edu.learning.ui.StudyToolWindow)1 Map (java.util.Map)1 NotNull (org.jetbrains.annotations.NotNull)1