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 Details

  • Method Details

    • myCourses

      @GetMapping public String myCourses(Principal principal, org.springframework.ui.Model model)
      Display the instructor's courses, all statuses included.
      Parameters:
      principal - the logged-in instructor
      model - receives the instructor's courses
      Returns:
      the instructor course list view name
    • newCourseForm

      @GetMapping("/new") public String newCourseForm(org.springframework.ui.Model model)
      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 @Valid
      binding - collects validation errors
      principal - the logged-in instructor
      model - 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 edit
      principal - 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 update
      form - the submitted form, validated by @Valid
      binding - collects validation errors
      principal - 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 a published flag).
      Parameters:
      courseId - the course to publish
      principal - 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 an archived flag).
      Parameters:
      courseId - the course to archive
      principal - 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 a restored flag).
      Parameters:
      courseId - the course to restore
      principal - 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 to
      principal - 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 to
      form - the submitted form, validated by @Valid
      binding - collects validation errors
      principal - 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 to
      lessonId - the lesson to edit
      principal - 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 to
      lessonId - the lesson to update
      form - the submitted form, validated by @Valid
      binding - collects validation errors
      principal - 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 to
      lessonId - the lesson to transition
      action - one of publish, archive, restore
      principal - 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 to
      lessonId - the lesson to move
      direction - move-up or move-down
      principal - 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 show
      principal - 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 a dropped flag).
      Parameters:
      courseId - the course to remove the student from
      userId - the student to remove
      principal - the logged-in instructor (ownership check)
      request - provides the client IP for the audit trail
      Returns:
      a redirect to the roster