Package com.ericbouchut.learndev.course
Class EnrollmentService
java.lang.Object
com.ericbouchut.learndev.course.EnrollmentService
Student-side enrollment lifecycle (see the diagram in CONTRIBUTING.md).
The (user, course) pair is the primary key, so a student has at most one
enrollment row per course: enrolling again re-activates a
DROPPED
row instead of inserting a second one, and both operations are idempotent
(re-posting a form must not fail).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDrop the student from a course:ENROLLEDorIN_PROGRESSbecomesDROPPEDwith a drop timestamp.voidEnroll the student in a published course.enrollmentFor(User student, Course course) The enrollment of a student in a course, if any (dropped included).myEnrollments(User student) All enrollments of a student, dropped included (the dashboard filters).
-
Constructor Details
-
EnrollmentService
-
-
Method Details
-
enroll
Enroll the student in a published course. ADROPPEDenrollment is re-activated (back toENROLLED, drop timestamp cleared, enrollment timestamp refreshed); an active one is left untouched.- Throws:
org.springframework.web.server.ResponseStatusException- 404 when the course is not published (only published courses accept new enrollments)
-
drop
Drop the student from a course:ENROLLEDorIN_PROGRESSbecomesDROPPEDwith a drop timestamp. No-op when the student is not enrolled, already dropped, or completed the course (the lifecycle has no transition out of COMPLETED). -
enrollmentFor
The enrollment of a student in a course, if any (dropped included). -
myEnrollments
All enrollments of a student, dropped included (the dashboard filters).
-