Package com.ericbouchut.learndev.course
Class InstructorCourseService
java.lang.Object
com.ericbouchut.learndev.course.InstructorCourseService
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 Summary
ConstructorsConstructorDescriptionInstructorCourseService(CourseRepository courses, LessonRepository lessons, EnrollmentRepository enrollments, EnrollmentService enrollmentService, AuditService audit) -
Method Summary
Modifier and TypeMethodDescriptionvoidArchive a DRAFT or PUBLISHED course (v1 has no destructive delete).voidarchiveLesson(Lesson lesson, User actor, String ipAddress) Archive a DRAFT or PUBLISHED lesson.create(User instructor, CourseForm form) Create a new DRAFT course owned by the instructor.createLesson(Course course, LessonForm form) Create a DRAFT lesson at the end of the course (position max + 1).voiddropStudent(Course course, User student, User actor, String ipAddress) Remove a student from the course on the instructor's behalf.The lessons of the course in reading order, all statuses included.voidmoveLessonDown(Course course, Lesson lesson) Swap the lesson with the one after it in reading order (no-op at the bottom).voidmoveLessonUp(Course course, Lesson lesson) Swap the lesson with the one before it in reading order (no-op at the top).The instructor's own courses, whatever their status.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.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.voidPublish a DRAFT course; the first publish stampspublished_at.voidpublishLesson(Lesson lesson, User actor, String ipAddress) Publish a DRAFT lesson.voidRestore an ARCHIVED course to DRAFT ("re-open" in the lifecycle).voidrestoreLesson(Lesson lesson, User actor, String ipAddress) Restore an ARCHIVED lesson to DRAFT.The roster of a course: every enrollment, dropped ones included.voidupdate(Course course, CourseForm form) Update the title and description of the instructor's course.voidupdateLesson(Lesson lesson, LessonForm form) Update the title and Markdown content of a lesson.
-
Constructor Details
-
InstructorCourseService
public InstructorCourseService(CourseRepository courses, LessonRepository lessons, EnrollmentRepository enrollments, EnrollmentService enrollmentService, AuditService audit)
-
-
Method Details
-
myCourses
The instructor's own courses, whatever their status. -
ownedCourse
The course as manageable by the given instructor: 404 when it does not exist, 403 when it belongs to another instructor. -
create
Create a new DRAFT course owned by the instructor. -
update
Update the title and description of the instructor's course. -
publish
Publish a DRAFT course; the first publish stampspublished_at. -
archive
Archive a DRAFT or PUBLISHED course (v1 has no destructive delete). -
restore
Restore an ARCHIVED course to DRAFT ("re-open" in the lifecycle). -
lessonsOf
The lessons of the course in reading order, all statuses included. -
ownedLesson
One lesson of the given course, whatever its status: 404 when the lesson does not exist or belongs to another course. -
createLesson
Create a DRAFT lesson at the end of the course (position max + 1). -
updateLesson
Update the title and Markdown content of a lesson. -
publishLesson
Publish a DRAFT lesson. -
archiveLesson
Archive a DRAFT or PUBLISHED lesson. -
restoreLesson
Restore an ARCHIVED lesson to DRAFT. -
moveLessonUp
Swap the lesson with the one before it in reading order (no-op at the top). -
moveLessonDown
Swap the lesson with the one after it in reading order (no-op at the bottom). -
roster
The roster of a course: every enrollment, dropped ones included. -
dropStudent
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.
-