use of com.jetbrains.edu.learning.courseFormat.TaskFile in project intellij-community by JetBrains.
the class StudyStepicFormatTest method doStepOptionsCreationTest.
private static StepicWrappers.StepOptions doStepOptionsCreationTest(String fileName) throws IOException {
String responseString = FileUtil.loadFile(new File(getTestDataPath(), fileName));
StepicWrappers.StepSource stepSource = EduStepicClient.deserializeStepicResponse(StepicWrappers.StepContainer.class, responseString).steps.get(0);
StepicWrappers.StepOptions options = stepSource.block.options;
List<TaskFile> files = options.files;
assertTrue("Wrong number of task files", files.size() == 1);
List<AnswerPlaceholder> placeholders = files.get(0).getAnswerPlaceholders();
assertTrue("Wrong number of placeholders", placeholders.size() == 1);
Map<Integer, AnswerPlaceholderSubtaskInfo> infos = placeholders.get(0).getSubtaskInfos();
assertNotNull(infos);
assertEquals(Collections.singletonList("Type your name here."), infos.get(0).getHints());
assertEquals("Liana", infos.get(0).getPossibleAnswer());
return options;
}
use of com.jetbrains.edu.learning.courseFormat.TaskFile in project intellij-community by JetBrains.
the class PyCCCommandLineState method getCurrentTaskFilePath.
@Nullable
private String getCurrentTaskFilePath() {
String textFile = null;
for (Map.Entry<String, TaskFile> entry : myTask.getTaskFiles().entrySet()) {
String path = getTaskFilePath(entry.getKey());
if (!entry.getValue().getActivePlaceholders().isEmpty()) {
return path;
}
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path);
if (virtualFile == null) {
continue;
}
if (TextEditorProvider.isTextFile(virtualFile)) {
textFile = path;
}
}
return textFile;
}
use of com.jetbrains.edu.learning.courseFormat.TaskFile 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);
}
});
}
};
}
use of com.jetbrains.edu.learning.courseFormat.TaskFile in project intellij-community by JetBrains.
the class PyStudyCheckAction method getTaskVirtualFile.
@Nullable
private static VirtualFile getTaskVirtualFile(@NotNull final StudyState studyState, @NotNull final Task task, @NotNull final VirtualFile taskDir) {
VirtualFile taskVirtualFile = studyState.getVirtualFile();
for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
String name = entry.getKey();
TaskFile taskFile = entry.getValue();
VirtualFile virtualFile = taskDir.findFileByRelativePath(name);
if (virtualFile != null) {
if (!taskFile.getActivePlaceholders().isEmpty()) {
taskVirtualFile = virtualFile;
}
}
}
return taskVirtualFile;
}
Aggregations