コード例 #1
0
 @Override
 public void actionPerformed(@NotNull AnActionEvent e) {
   final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
   final Project project = e.getData(CommonDataKeys.PROJECT);
   if (view == null || project == null) {
     return;
   }
   final Course course = StudyTaskManager.getInstance(project).getCourse();
   if (course == null) {
     return;
   }
   if (course.getId() > 0) {
     ProgressManager.getInstance()
         .run(
             new Task.Modal(project, "Updating Course", true) {
               @Override
               public void run(@NotNull ProgressIndicator indicator) {
                 for (Lesson lesson : course.getLessons()) {
                   if (lesson.getId() > 0) {
                     CCStepicConnector.updateLesson(project, lesson, indicator);
                   } else {
                     final CourseInfo info = CourseInfo.fromCourse(course);
                     final int lessonId = CCStepicConnector.postLesson(project, lesson, indicator);
                     final List<Integer> sections = info.getSections();
                     final Integer sectionId = sections.get(sections.size() - 1);
                     CCStepicConnector.postUnit(lessonId, lesson.getIndex(), sectionId);
                   }
                 }
               }
             });
   } else {
     CCStepicConnector.postCourseWithProgress(project, course);
   }
   EduUsagesCollector.courseUploaded();
 }
コード例 #2
0
 @Override
 public void update(@NotNull AnActionEvent e) {
   Presentation presentation = e.getPresentation();
   Project project = e.getProject();
   presentation.setEnabledAndVisible(project != null && CCUtils.isCourseCreator(project));
   if (project != null) {
     final Course course = StudyTaskManager.getInstance(project).getCourse();
     if (course != null) {
       final int id = course.getId();
       if (id > 0) {
         presentation.setText("Update Course on Stepik");
       }
     }
   }
 }
コード例 #3
0
  @Override
  public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    presentation.setEnabledAndVisible(false);
    Project project = e.getProject();
    if (project == null) {
      return;
    }
    Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course == null) {
      return;
    }

    if (!EduNames.STUDY.equals(course.getCourseMode())) {
      presentation.setVisible(true);
      return;
    }

    if (getAnswerPlaceholder(e) == null) {
      presentation.setEnabledAndVisible(false);
      return;
    }
    presentation.setEnabledAndVisible(true);
  }
コード例 #4
0
  @Override
  public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    if (project == null) {
      return;
    }
    Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course == null) {
      return;
    }

    CCNewProjectPanel panel =
        new CCNewProjectPanel(
            course.getName(),
            Course.getAuthorsString(course.getAuthors()),
            course.getDescription());
    DialogBuilder builder = createChangeInfoDialog(project, panel);
    if (builder.showAndGet()) {
      course.setAuthors(panel.getAuthors());
      course.setName(panel.getName());
      course.setDescription(panel.getDescription());
      ProjectView.getInstance(project).refresh();
    }
  }
コード例 #5
0
  @NotNull
  private static Course getCourse(
      @NotNull Project project,
      @NotNull String name,
      @NotNull String[] authors,
      @NotNull String description) {
    final Course course = new Course();
    course.setName(name);
    course.setAuthors(authors);
    course.setDescription(description);
    course.setLanguage(PythonLanguage.getInstance().getID());
    course.setCourseMode(CCUtils.COURSE_MODE);

    File coursesDir = new File(PathManager.getConfigPath(), "courses");
    File courseDir = new File(coursesDir, name + "-" + project.getName());
    course.setCourseDirectory(courseDir.getPath());

    StudyTaskManager.getInstance(project).setCourse(course);
    StudyProjectComponent.getInstance(project).registerStudyToolWindow(course);
    return course;
  }