Package com.ericbouchut.learndev.course
Class InstructorCourseController
java.lang.Object
com.ericbouchut.learndev.course.InstructorCourseController
@Controller
@RequestMapping("/instructor/courses")
public class InstructorCourseController
extends Object
Web endpoints of the instructor authoring area under
/instructor/** (gated to ROLE_INSTRUCTOR by the security
rules): the instructor's course list, the course create/edit forms, and
the publication lifecycle actions. Ownership and transition rules live in
InstructorCourseService.-
Constructor Summary
ConstructorsConstructorDescriptionInstructorCourseController(InstructorCourseService instructorCourses, UserRepository users) -
Method Summary
Modifier and TypeMethodDescriptionarchiveCourse(Long courseId, Principal principal, jakarta.servlet.http.HttpServletRequest request) Archive the course (PRG with anarchivedflag).createCourse(@Valid CourseForm form, org.springframework.validation.BindingResult binding, Principal principal, org.springframework.ui.Model model) Create a DRAFT course from the submitted form.createLesson(Long courseId, @Valid LessonForm form, org.springframework.validation.BindingResult binding, Principal principal, org.springframework.ui.Model model) Create a DRAFT lesson at the end of the course.dropStudent(Long courseId, UUID userId, Principal principal, jakarta.servlet.http.HttpServletRequest request) Remove a student from the course (PRG with adroppedflag).editCourseForm(Long courseId, Principal principal, org.springframework.ui.Model model) Display the edit form of one of the instructor's courses.editLessonForm(Long courseId, Long lessonId, Principal principal, org.springframework.ui.Model model) Display the edit form of one lesson.moveLesson(Long courseId, Long lessonId, String direction, Principal principal) Move a lesson one step up or down in reading order (PRG).Display the instructor's courses, all statuses included.newCourseForm(org.springframework.ui.Model model) Display the course creation form.newLessonForm(Long courseId, Principal principal, org.springframework.ui.Model model) Display the lesson creation form for one of the instructor's courses.publishCourse(Long courseId, Principal principal, jakarta.servlet.http.HttpServletRequest request) Publish the course (PRG with apublishedflag).restoreCourse(Long courseId, Principal principal, jakarta.servlet.http.HttpServletRequest request) Restore an archived course to draft (PRG with arestoredflag).Display the roster of the course: every enrollment with its status and lifecycle dates.transitionLesson(Long courseId, Long lessonId, String action, Principal principal, jakarta.servlet.http.HttpServletRequest request) Publish, archive, or restore a lesson (PRG back to the course editor).updateCourse(Long courseId, @Valid CourseForm form, org.springframework.validation.BindingResult binding, Principal principal, org.springframework.ui.Model model) Update the course from the submitted form.updateLesson(Long courseId, Long lessonId, @Valid LessonForm form, org.springframework.validation.BindingResult binding, Principal principal, org.springframework.ui.Model model) Update the lesson from the submitted form.
-
Constructor Details
-
InstructorCourseController
-
-
Method Details
-
myCourses
Display the instructor's courses, all statuses included.- Parameters:
principal- the logged-in instructormodel- receives the instructor's courses- Returns:
- the instructor course list view name
-
newCourseForm
Display the course creation form.- Parameters:
model- receives an empty form- Returns:
- the course form view name
-
createCourse
@PostMapping("/new") public String createCourse(@Valid @ModelAttribute("form") @Valid CourseForm form, org.springframework.validation.BindingResult binding, Principal principal, org.springframework.ui.Model model) Create a DRAFT course from the submitted form.- Parameters:
form- the submitted form, validated by@Validbinding- collects validation errorsprincipal- the logged-in instructormodel- re-exposes the (null) course on re-render- Returns:
- a redirect to the edit page, or the re-rendered form on error
-
editCourseForm
@GetMapping("/{courseId}/edit") public String editCourseForm(@PathVariable Long courseId, Principal principal, org.springframework.ui.Model model) Display the edit form of one of the instructor's courses.- Parameters:
courseId- the course to editprincipal- the logged-in instructor (ownership check)model- receives the course and its pre-filled form- Returns:
- the course form view name
-
updateCourse
@PostMapping("/{courseId}/edit") public String updateCourse(@PathVariable Long courseId, @Valid @ModelAttribute("form") @Valid CourseForm form, org.springframework.validation.BindingResult binding, Principal principal, org.springframework.ui.Model model) Update the course from the submitted form.- Parameters:
courseId- the course to updateform- the submitted form, validated by@Validbinding- collects validation errorsprincipal- the logged-in instructor (ownership check)model- re-exposes the course on re-render- Returns:
- a redirect to the edit page, or the re-rendered form on error
-
publishCourse
@PostMapping("/{courseId}/publish") public String publishCourse(@PathVariable Long courseId, Principal principal, jakarta.servlet.http.HttpServletRequest request) Publish the course (PRG with apublishedflag).- Parameters:
courseId- the course to publishprincipal- the logged-in instructor (ownership check)request- provides the client IP for the audit trail- Returns:
- a redirect to the edit page
-
archiveCourse
@PostMapping("/{courseId}/archive") public String archiveCourse(@PathVariable Long courseId, Principal principal, jakarta.servlet.http.HttpServletRequest request) Archive the course (PRG with anarchivedflag).- Parameters:
courseId- the course to archiveprincipal- the logged-in instructor (ownership check)request- provides the client IP for the audit trail- Returns:
- a redirect to the edit page
-
restoreCourse
@PostMapping("/{courseId}/restore") public String restoreCourse(@PathVariable Long courseId, Principal principal, jakarta.servlet.http.HttpServletRequest request) Restore an archived course to draft (PRG with arestoredflag).- Parameters:
courseId- the course to restoreprincipal- the logged-in instructor (ownership check)request- provides the client IP for the audit trail- Returns:
- a redirect to the edit page
-
newLessonForm
@GetMapping("/{courseId}/lessons/new") public String newLessonForm(@PathVariable Long courseId, Principal principal, org.springframework.ui.Model model) Display the lesson creation form for one of the instructor's courses.- Parameters:
courseId- the course the lesson will belong toprincipal- the logged-in instructor (ownership check)model- receives the course and an empty form- Returns:
- the lesson form view name
-
createLesson
@PostMapping("/{courseId}/lessons/new") public String createLesson(@PathVariable Long courseId, @Valid @ModelAttribute("form") @Valid LessonForm form, org.springframework.validation.BindingResult binding, Principal principal, org.springframework.ui.Model model) Create a DRAFT lesson at the end of the course.- Parameters:
courseId- the course the lesson belongs toform- the submitted form, validated by@Validbinding- collects validation errorsprincipal- the logged-in instructor (ownership check)model- re-exposes the course on re-render- Returns:
- a redirect to the course editor, or the re-rendered form
-
editLessonForm
@GetMapping("/{courseId}/lessons/{lessonId}/edit") public String editLessonForm(@PathVariable Long courseId, @PathVariable Long lessonId, Principal principal, org.springframework.ui.Model model) Display the edit form of one lesson.- Parameters:
courseId- the course the lesson belongs tolessonId- the lesson to editprincipal- the logged-in instructor (ownership check)model- receives the course, the lesson, and its form- Returns:
- the lesson form view name
-
updateLesson
@PostMapping("/{courseId}/lessons/{lessonId}/edit") public String updateLesson(@PathVariable Long courseId, @PathVariable Long lessonId, @Valid @ModelAttribute("form") @Valid LessonForm form, org.springframework.validation.BindingResult binding, Principal principal, org.springframework.ui.Model model) Update the lesson from the submitted form.- Parameters:
courseId- the course the lesson belongs tolessonId- the lesson to updateform- the submitted form, validated by@Validbinding- collects validation errorsprincipal- the logged-in instructor (ownership check)model- re-exposes the course and lesson on re-render- Returns:
- a redirect to the course editor, or the re-rendered form
-
transitionLesson
@PostMapping("/{courseId}/lessons/{lessonId}/{action:publish|archive|restore}") public String transitionLesson(@PathVariable Long courseId, @PathVariable Long lessonId, @PathVariable String action, Principal principal, jakarta.servlet.http.HttpServletRequest request) Publish, archive, or restore a lesson (PRG back to the course editor).- Parameters:
courseId- the course the lesson belongs tolessonId- the lesson to transitionaction- one ofpublish,archive,restoreprincipal- the logged-in instructor (ownership check)request- provides the client IP for the audit trail- Returns:
- a redirect to the course editor
-
moveLesson
@PostMapping("/{courseId}/lessons/{lessonId}/{direction:move-up|move-down}") public String moveLesson(@PathVariable Long courseId, @PathVariable Long lessonId, @PathVariable String direction, Principal principal) Move a lesson one step up or down in reading order (PRG).- Parameters:
courseId- the course the lesson belongs tolessonId- the lesson to movedirection-move-upormove-downprincipal- the logged-in instructor (ownership check)- Returns:
- a redirect to the course editor
-
roster
@GetMapping("/{courseId}/students") public String roster(@PathVariable Long courseId, Principal principal, org.springframework.ui.Model model) Display the roster of the course: every enrollment with its status and lifecycle dates.- Parameters:
courseId- the course whose roster to showprincipal- the logged-in instructor (ownership check)model- receives the course and its enrollments- Returns:
- the roster view name
-
dropStudent
@PostMapping("/{courseId}/students/{userId}/drop") public String dropStudent(@PathVariable Long courseId, @PathVariable UUID userId, Principal principal, jakarta.servlet.http.HttpServletRequest request) Remove a student from the course (PRG with adroppedflag).- Parameters:
courseId- the course to remove the student fromuserId- the student to removeprincipal- the logged-in instructor (ownership check)request- provides the client IP for the audit trail- Returns:
- a redirect to the roster
-