use of com.jetbrains.edu.learning.courseFormat.Course in project intellij-community by JetBrains.
the class CCNewSubtaskAction method createTestsForNewSubtask.
private static void createTestsForNewSubtask(Project project, Task task) {
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
CCLanguageManager manager = CCUtils.getStudyLanguageManager(course);
if (manager == null) {
return;
}
manager.createTestsForNewSubtask(project, task);
}
use of com.jetbrains.edu.learning.courseFormat.Course in project intellij-community by JetBrains.
the class CCPluginConfigurator method accept.
@Override
public boolean accept(@NotNull Project project) {
final StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
final Course course = taskManager.getCourse();
if (course != null) {
final String mode = course.getCourseMode();
return COURSE_MODE.equals(mode);
}
return false;
}
use of com.jetbrains.edu.learning.courseFormat.Course in project intellij-community by JetBrains.
the class CCUtils method isTestsFile.
public static boolean isTestsFile(@NotNull Project project, @NotNull VirtualFile file) {
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return false;
}
CCLanguageManager manager = getStudyLanguageManager(course);
if (manager == null) {
return false;
}
return manager.isTestFile(file);
}
use of com.jetbrains.edu.learning.courseFormat.Course in project intellij-community by JetBrains.
the class CCUtils method isLessonDir.
public static boolean isLessonDir(PsiDirectory sourceDirectory) {
if (sourceDirectory == null) {
return false;
}
Project project = sourceDirectory.getProject();
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course != null && isCourseCreator(project) && course.getLesson(sourceDirectory.getName()) != null) {
return true;
}
return false;
}
use of com.jetbrains.edu.learning.courseFormat.Course in project intellij-community by JetBrains.
the class CCUtils method updateResources.
public static void updateResources(Project project, Task task, VirtualFile taskDir) {
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
VirtualFile lessonVF = taskDir.getParent();
if (lessonVF == null) {
return;
}
String taskResourcesPath = FileUtil.join(course.getCourseDirectory(), lessonVF.getName(), taskDir.getName());
File taskResourceFile = new File(taskResourcesPath);
if (!taskResourceFile.exists()) {
if (!taskResourceFile.mkdirs()) {
LOG.info("Failed to create resources for task " + taskResourcesPath);
}
}
VirtualFile studentDir = LocalFileSystem.getInstance().findFileByIoFile(taskResourceFile);
if (studentDir == null) {
return;
}
for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
String name = entry.getKey();
VirtualFile answerFile = taskDir.findFileByRelativePath(name);
if (answerFile == null) {
continue;
}
ApplicationManager.getApplication().runWriteAction(() -> {
EduUtils.createStudentFile(CCUtils.class, project, answerFile, studentDir, null, task.getActiveSubtaskIndex());
});
}
}
Aggregations