Child course

Activities ::: mod_childcourse
Maintained by Eduardo Kraus
Adds the "Linked Course" activity, enables automatic enrollment, links groups and roles, and maintains incremental synchronization of completion and grades, with support for the Moodle App.
Latest release:
3 sites
15 downloads
1 fans
Current versions available: 1

Child course

mod_childcourse adds a Moodle activity that works as a shortcut inside a parent course. When clicked, the user is redirected to a child course and (optionally) the plugin performs automatic enrolment, group mapping, and incremental synchronization of completion and grades.

Auto enrol Groups Completion rules Incremental sync Mobile support
Mental model
Parent course contains a "Child course" activity → user clicks → (optional enrol + group mapping) → redirect to the child course.
Illustration: a course activity acting as a shortcut to another course
Tip: replace this image with your plugin banner or a screenshot of the activity configuration / teacher dashboard.

What the plugin solves (in practice)

Moodle can link courses in many ways, but most solutions become fragile when you need controlled access, consistent group mapping, and reliable tracking. This module adds the missing layer: enrolment rules + stateful synchronization inside a single activity.

Clean shortcut inside the parent course
A single activity points to the child course, with optional "open in new tab" to streamline navigation.
Automatic enrolment (optional)
Enrol users when they access the activity, preserving roles and reducing "permission error" friction.
Group mapping that makes sense
Enrol into a specific group or inherit groups from the parent course to the child course (optional).
Incremental sync (completion + grades)
A scheduled task keeps state and syncs changes incrementally, avoiding "full rebuild" runs.
Designed for real courses
  • Supports Backup/Restore.
  • Can hide the child course from "My courses / Overview" to reduce clutter.
  • On delete, choose whether to unenrol link-enrolled users or keep enrolments.

How it works

The module stores configuration in the instance table and tracks the operational mapping/state in dedicated tables. On access, it optionally enrols and maps groups, then redirects the user. Synchronization runs on schedule (and can be forced manually).

Student access flow
  1. User opens "Child course" activity.
  2. If enabled: enrolment is performed (role preserved if configured).
  3. Optional: group mapping (fixed group or inherited groups).
  4. Redirect to the child course (same tab or new tab).
Important
If automatic enrolment is disabled, the user must already have permission to access the child course, otherwise Moodle will show a permission error in the child course.
Teacher / manager tools
  • Manual sync action (when the user has permission) for immediate incremental sync.
  • Manage instances via a course management page (requires moodle/course:update).
  • Index page listing all instances inside the course.
Plugin pages
  • view.php — main activity page (student redirects; teacher sees a dashboard)
  • manage.php — lists/manages instances in the course
  • index.php — lists module instances in the course

Activity completion rules

When Moodle completion is set to Automatic, the activity can mark itself complete using additional rules based on the child course.

None
The plugin does not automatically control completion for this activity.
Course completed
Marks the activity complete when the user completes the child course.
All activities
Marks the activity complete when the user completes all trackable activities in the child course (per plugin logic).
Note
The child course must have enablecompletion = 1 for completion-based rules to work.

Synchronization (grades and completion)

Synchronization is designed to be incremental. Instead of recalculating everything, the plugin tracks state and updates only what changed.

Scheduled task
The task \mod_childcourse\task\sync_task runs by default every 15 minutes (see db/tasks.php) and performs incremental synchronization for all instances.
Operational idea
Keep a state cache per user/instance and sync only deltas to reduce load on large sites.
Manual sync
On the activity page (for users with permission), a Sync button/action forces an immediate incremental run.
  • Useful after configuration changes.
  • Useful for debugging or support.
  • Does not require waiting for cron schedule.

Mobile support (Moodle App)

In the Moodle App, the activity renders a simple screen with a single button to open the child course. Clicking it performs the same enrolment + access flow as the web version.

Mobile UI rule
Keep it minimal: one button, no noise — fast, reliable, and easy for students.

Data structure (tables)

The plugin uses dedicated tables to keep configuration clean and synchronization scalable.

{childcourse}
Instance settings (including completion rules and sync timestamps).
{childcourse_map}
Tracks enrolments / groups created per instance and per user.
{childcourse_state}
State cache for incremental synchronization (grades / completion).
Why this matters
Separating "settings", "mapping", and "state" prevents slow scans and keeps sync predictable as enrolments grow.

Support

For questions, bugs, improvements, or suggestions, open an issue with enough context to reproduce.
Back to top
When opening a ticket, include
  • Moodle version
  • Steps to reproduce
  • Which activity instance (parent course + child course IDs)
  • Whether auto-enrol / groups / role-preserve were enabled
  • Cron / task logs (if it’s about sync)
Best practices
  • Enable auto-enrol when you want a "one-click access" experience.
  • Use group mapping to keep cohorts consistent across parent/child courses.
  • Prefer incremental sync for large sites (avoid manual full sync habits).
  • Test completion rules on a staging site before rolling to production.
Why this approach works
  • No core modifications.
  • Single activity UX inside the parent course.

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3
Screenshot #4

Contributors

Eduardo Kraus (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments

Show comments
Please login to post comments