Class InstructorCourseService

java.lang.Object
com.ericbouchut.learndev.course.InstructorCourseService

@Service public class InstructorCourseService extends Object
Write side of the course domain for instructors: authoring and the publication lifecycle of CONTRIBUTING.md (publish from DRAFT, archive from DRAFT or PUBLISHED, restore an ARCHIVED item to DRAFT). An instructor manages only their own courses: another instructor's course answers 403 (the course may be public, its existence is not a secret, unlike student-invisible drafts which answer 404 on the student side). Invalid lifecycle transitions answer 409.

published_at is set on the first publish only and kept on a re-publish after restore, so it records when the course first went live.

  • Constructor Details

  • Method Details

    • myCourses

      public List<Course> myCourses(User instructor)
      The instructor's own courses, whatever their status.
    • ownedCourse

      public Course ownedCourse(Long courseId, User instructor)
      The course as manageable by the given instructor: 404 when it does not exist, 403 when it belongs to another instructor.
    • create

      @Transactional public Course create(User instructor, CourseForm form)
      Create a new DRAFT course owned by the instructor.
    • update

      @Transactional public void update(Course course, CourseForm form)
      Update the title and description of the instructor's course.
    • publish

      @Transactional public void publish(Course course, User actor, String ipAddress)
      Publish a DRAFT course; the first publish stamps published_at.
    • archive

      @Transactional public void archive(Course course, User actor, String ipAddress)
      Archive a DRAFT or PUBLISHED course (v1 has no destructive delete).
    • restore

      @Transactional public void restore(Course course, User actor, String ipAddress)
      Restore an ARCHIVED course to DRAFT ("re-open" in the lifecycle).
    • lessonsOf

      public List<Lesson> lessonsOf(Course course)
      The lessons of the course in reading order, all statuses included.
    • ownedLesson

      public Lesson ownedLesson(Course course, Long lessonId)
      One lesson of the given course, whatever its status: 404 when the lesson does not exist or belongs to another course.
    • createLesson

      @Transactional public Lesson createLesson(Course course, LessonForm form)
      Create a DRAFT lesson at the end of the course (position max + 1).
    • updateLesson

      @Transactional public void updateLesson(Lesson lesson, LessonForm form)
      Update the title and Markdown content of a lesson.
    • publishLesson

      @Transactional public void publishLesson(Lesson lesson, User actor, String ipAddress)
      Publish a DRAFT lesson.
    • archiveLesson

      @Transactional public void archiveLesson(Lesson lesson, User actor, String ipAddress)
      Archive a DRAFT or PUBLISHED lesson.
    • restoreLesson

      @Transactional public void restoreLesson(Lesson lesson, User actor, String ipAddress)
      Restore an ARCHIVED lesson to DRAFT.
    • moveLessonUp

      @Transactional public void moveLessonUp(Course course, Lesson lesson)
      Swap the lesson with the one before it in reading order (no-op at the top).
    • moveLessonDown

      @Transactional public void moveLessonDown(Course course, Lesson lesson)
      Swap the lesson with the one after it in reading order (no-op at the bottom).
    • roster

      public List<Enrollment> roster(Course course)
      The roster of a course: every enrollment, dropped ones included.
    • dropStudent

      @Transactional public void dropStudent(Course course, User student, User actor, String ipAddress)
      Remove a student from the course on the instructor's behalf. Reuses the student-side drop rules (idempotent, COMPLETED untouched) and audits the action separately from a self-drop.