Search in sources :

Example 31 with Course

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);
}
Also used : CCLanguageManager(com.jetbrains.edu.coursecreator.CCLanguageManager) Course(com.jetbrains.edu.learning.courseFormat.Course)

Example 32 with Course

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;
}
Also used : StudyTaskManager(com.jetbrains.edu.learning.StudyTaskManager) Course(com.jetbrains.edu.learning.courseFormat.Course)

Example 33 with Course

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);
}
Also used : Course(com.jetbrains.edu.learning.courseFormat.Course)

Example 34 with Course

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;
}
Also used : Project(com.intellij.openapi.project.Project) Course(com.jetbrains.edu.learning.courseFormat.Course)

Example 35 with Course

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());
        });
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TaskFile(com.jetbrains.edu.learning.courseFormat.TaskFile) Course(com.jetbrains.edu.learning.courseFormat.Course) VirtualFile(com.intellij.openapi.vfs.VirtualFile) TaskFile(com.jetbrains.edu.learning.courseFormat.TaskFile) File(java.io.File) Map(java.util.Map)

Aggregations

Course (com.jetbrains.edu.learning.courseFormat.Course)51 Project (com.intellij.openapi.project.Project)26 VirtualFile (com.intellij.openapi.vfs.VirtualFile)21 TaskFile (com.jetbrains.edu.learning.courseFormat.TaskFile)12 PsiDirectory (com.intellij.psi.PsiDirectory)11 Lesson (com.jetbrains.edu.learning.courseFormat.Lesson)10 File (java.io.File)10 IdeView (com.intellij.ide.IdeView)8 Nullable (org.jetbrains.annotations.Nullable)6 Presentation (com.intellij.openapi.actionSystem.Presentation)5 PsiFile (com.intellij.psi.PsiFile)5 Task (com.jetbrains.edu.learning.courseFormat.Task)5 NotNull (org.jetbrains.annotations.NotNull)5 Editor (com.intellij.openapi.editor.Editor)4 PsiElement (com.intellij.psi.PsiElement)4 List (java.util.List)4 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)3 ApplicationManager (com.intellij.openapi.application.ApplicationManager)3 Module (com.intellij.openapi.module.Module)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3