Skip to content
Learnomy
Get Learnomy Pro

Course Prerequisites

How to Set Course Prerequisites in Learnomy2:27Chapters and transcript

Prerequisites let you require a student to finish one or more other courses before they can enrol in this one. It is how you enforce a learning order instead of letting students jump straight to the advanced material.

What you can do#

  • Require one or several other courses to be completed before a student can enrol in this course.
  • Block enrollment for any student who has not finished all of the required courses.
  • Show the required courses on the course page as links, so a student can discover and take them first.
  • Leave prerequisites empty to keep a course open to everyone.

Course Prerequisites first view

How to use it#

Step 1 -- open the Prerequisites section#

Edit the course and open the Prerequisites, difficulty & target section of the course editor. The prerequisite picker appears when you are editing an existing course and there is at least one other course to choose from.

Step 2 -- pick the required courses#

Type part of a course title in the Search courses by name box and choose the course from the results. Each chosen course appears as a chip under Already chosen, showing its state (Published, Draft, Private, Pending review). Click the × on a chip to remove it. You can choose as many as you need. The course you are editing is never offered.

Search works the same however many courses your site has: courses you chose earlier always show as chips, even on a site with thousands of courses.

Who can choose what:

  • An instructor can only require their own courses. Courses by other instructors are never offered or shown.
  • An admin can require any course on the site.
  • If an admin set another instructor's course as a prerequisite on your course, you see it as an unnamed chip, A required course from another instructor. You can remove it, and saving your course keeps it unless you do.

Step 3 -- save#

Save the course. If a published course now requires a course students can't reach, the editor warns you, for example:

Students can't enroll in this course: "Advanced SQL" is a draft. Publish "Advanced SQL" or remove it from Prerequisites.

The save still goes through. The course also shows Can't be bought: prerequisite not published in the course list until you fix it. Both warnings clear as soon as the required course is published or removed.

Step 4 -- what the student sees#

When every required course is published, the course page lists them under a Prerequisites heading as links, with a Go to the required course button, so a student can go take them first. When a student tries to enroll, Learnomy checks that they hold a completed enrollment for every required course. If any is missing or only in progress, enrollment is refused with Complete these courses first: and the course names.

When a required course is one the student can never reach (a draft, private, pending review or archived course), the course isn't buyable at all. Guests and students see This course is not open for enrollment yet., with no buy or enroll button. The hidden course is never named, linked or counted. The same applies on the catalog card, the cart and the checkout page.

Settings and options#

  • Completed, not just enrolled. A prerequisite is satisfied only once the student has finished the required course. An in-progress enrollment does not unlock the target course. A course the student finished stays finished: its fixed term ending, or reopening it for a retake, does not lock the next course again.
  • All required courses must pass. Every course in the list must be completed; there is no "any one of" mode.
  • Enforced everywhere. The prerequisite check runs at the service layer, so it applies to REST, admin, and CLI enrollment paths alike, not just the front-end Enrol button.
  • A required course students can't reach closes enrollment. Draft, private, pending-review and archived prerequisites all close it, and students see "This course is not open for enrollment yet." You, as the author or an admin, see the warning and can fix it. A hidden prerequisite the student had already completed still counts as met.
  • Deleted courses count as met. If a required course is deleted, it no longer blocks anyone, so nobody stays locked out by a course that doesn't exist.
  • Guest checkout checks prerequisites too. A guest buyer has completed nothing yet, so a course with prerequisites can't be bought by a guest who skips signing in.
  • Empty means open. A course with no prerequisites is open to everyone (subject to its pricing and access model).

For developers#

Service (Learnomy\Services\Course_Service):

  • check_prerequisites( $user_id, $course_id ) -- returns true when the user has completed every prerequisite course, or the course has none.
  • unmet_prerequisites( $user_id, $course_id ) -- the Course rows still to complete. Enrollment_Service::enroll() refuses with a learnomy_prerequisites_not_met WP_Error (status 403) when this is not empty.
  • Course_Service::prerequisite_names( $courses, $viewer_id ) -- how to word a list of prerequisites to one viewer: the rows they may see named, how many are hidden, and the one-line refusal. Use it whenever you print prerequisite titles.

Storage: lrn_courses.prerequisites holds a JSON array of course IDs. The courses REST controller accepts a prerequisites array on create/update and stores it as JSON. When an instructor sends another instructor's course, the request is refused with 400 learnomy_invalid_prerequisite ("You can only require your own courses."). An id already stored by an admin is kept on the instructor's next save; only new ids are checked.

REST:

  • POST /learnomy/v1/courses/{id}/enroll and POST /learnomy/v1/checkout answer 403 learnomy_prerequisites_not_met when prerequisites are unmet, with the message worded by prerequisite_names(). The error's course_ids lists only the courses that message names: the reachable ids, or [] when the course is closed by a prerequisite the viewer can't reach.
  • GET /learnomy/v1/courses and GET /learnomy/v1/courses/{id} return in prerequisites only the ids the viewer may open. The author and admins get every id.
  • GET /learnomy/v1/courses/picker?search=…&page=… is the search behind the admin picker: 20 courses a page, each with its state. An instructor gets only their own courses whatever they send.