Building a custom Moodle activity module

A custom activity module is justified only when no core or vetted plugin fits the teaching need. This page covers what the build includes, the integration points that drive effort, and what to confirm before starting.

On this page

When a custom Moodle activity module is worth building

A custom activity module is worth building only when a teaching or assessment need cannot be met by the activities Moodle already ships or by a vetted plugin, and when the institution accepts that it will own that code for as long as the activity is used. Start by writing the need as a learning outcome or assessment rule, then test it against the core activities, the question bank, H5P content, and existing community plugins. Moodle documents more than 50 plugin types, and activity modules are only one of them. Many requirements that look like a new activity are really a block, a report, a local plugin that adds a setting, or a configuration change to an existing module. Those options should be ruled out first, because each one carries a smaller upgrade burden.

Once core and vetted options are ruled out, the cost to weigh is ownership across upgrades, not the first build. A custom activity adds its own database tables, capability definitions, backup and restore handlers, grade and completion hooks, privacy provider code and, if students use the app, mobile support. Each of those touches Moodle's internal APIs, which change between major releases. Moodle 5.1 and 5.3 each have their own minimum PHP and database versions, and sites must upgrade through supported starting points, so the module must be retested on every target release. Ask any partner to quote the initial build and also the recurring work of testing the module against each Moodle release your institution plans to run, including security fixes.

Before committing, confirm three things in writing: who will maintain the module after handover and at what level of effort, whether the activity can be exit-planned if it is later abandoned (including how existing data is exported or converted), and whether the institution's privacy and data governance team has reviewed what personal and grade data the module stores. A useful check is a short pilot with a single course that records what the activity stores and how it behaves in a backup and restore, before any wider rollout. If the answers are unclear, the requirement is often better met by configuring an existing tool or by a plugin with an active maintainer.

Deciding between core, a third-party plugin and a custom build

Before writing any code, four questions decide whether a new activity type is justified. Each answer narrows the options, and the cards below set out what each answer commits you to. Check them in order, because a configuration of an existing core activity is almost always cheaper to run than a module you must maintain.

Can core activities cover the need?

Start by testing whether a core activity, a quiz with its question types and feedback settings, or an existing workflow such as assignments with rubrics already produces the behavior you want. Write the learner journey as steps and map each step to a core setting. If the gap is only presentation or wording, a theme or language change is the right tool, not a module. A custom activity is only justified when the interaction itself is new.

Moodle plugin types

Does a maintained community plugin exist?

Search the Moodle plugins directory for activity modules that match the interaction. Check the listed Moodle versions, the date of the last release, the open issues and whether the maintainer has shipped against your target release. A plugin that supports only your current version will block your next upgrade. Treat an unmaintained plugin as a custom build you did not write, and plan to own its risk.

How must it report grades and completion?

Decide early whether the activity creates gradebook items, reports a numeric or scale grade, or only marks completion. Each path requires different callbacks and completion rules, and changing them after learners have data is expensive. Confirm with the gradebook and reporting owners which values must appear in course reports, and whether those values must survive a restore into another course.

Who maintains it after launch?

Name an owner before the build starts. The module must be tested against each Moodle release you run, including the Bootstrap 5 changes in the 5.0 move and the removal of themes and features in later releases. Ask whether the internal team or a partner will fix security findings, update privacy declarations and re-run backup and restore tests on each upgrade, and whether that work is written into a retainer.

Does the data need a privacy declaration?

If the activity stores learner responses, personal feedback or uploaded files, it must describe that data through the Privacy API so export and deletion requests can be answered. Decide which personal data the module keeps, how long it is retained and who can read it. Those answers shape the schema and the test plan, so settle them before the first table is designed.

How a Moodle activity module is structured

An activity module is one of Moodle's plugin types, and it is the only one that a teacher places inside a course as a visible item with its own settings, grade and completion state. Its code lives in its own directory under mod/, named after the plugin's frontend name, and that directory holds the entry points Moodle calls for everything the module does. The core contract is a small set of functions in lib.php that Moodle expects to find, covering creating and updating an instance, deleting it, reporting supported features, and feeding grades back to the gradebook. Each instance is a row in a table named after the module, linked to a course module record that carries the course placement, visibility, and completion settings shared with every other activity type. Because Moodle core owns the course module and gradebook tables, your module's own tables should hold only what is specific to the activity.

Around that core sit the pieces that make the module behave like a first-class activity. Capability definitions in db/access.php decide which roles can add the activity, view it, submit to it, or grade it, and views are typically built from view.php and renderers that check those capabilities before showing anything. Other plugin types sit alongside the module without being part of it: local plugins can react to events the module raises, themes control how its pages look, and web service functions can expose its data. Within the wider plugin family, an activity module is distinct from a block or a local plugin because it is the only type that owns course-level instances. Before you design anything, confirm the exact file layout, required callback names and API calls for your Moodle version, using the plugin types documentation as the reference, since these have changed between releases and your starting point depends on which release you run.

How gradebook, completion, backup, privacy and mobile support each add effort

The gradebook integration determines whether your activity's marks appear in course totals, categories and reports, and whether teachers can override them. The module must declare its grade items, store grades per user, and push updates to the gradebook through the core grading API rather than writing directly to grade tables. Without this, the activity shows marks inside its own screens but teachers cannot total them, export them or apply weightings, and course reports silently omit the work.

  • Grade item declaration: the module registers grade items with the correct type, maximum grade and scale, so course totals and categories can include it.
  • Grade override and history: teachers need overrides that the module respects on later regrades, and the gradebook should keep a record of changes.
  • Regrade on change: when rubric weights or maximum grades change, the module must trigger regrading rather than leave stale totals.
  • Hidden and locked grades: grade visibility and locking settings must apply to your activity's grades in the same way as core activities.

Effort rises with the number of grading models you support, such as points, scales, rubrics or peer assessment. Confirm against the Moodle developer documentation for your target version what the grading API expects before estimating the work.

Activity instance data reaches the gradebook, completion and backups through fixed hand-offs

The flow starts when a course author adds the activity to a course, which creates a course module record and a module instance table in the database. The module then reports grade items to the gradebook and completion state to course completion, and Moodle's backup and restore code reads and writes the same instance data. The privacy API hooks sit on that same data, so a missing hook shows up at export or deletion time. Check each hand-off with a test course before you build the UI.

Hand-offs between the activity module, gradebook, completion, backup and privacy code.

How the build runs from specification to release

The sequence turns a justified activity idea into a tested, backed-up, privacy-ready module that has a named upgrade path before it reaches production. Each step closes with a check so the team knows when to move on.

  1. Write the activity specification and data model

    The product owner and a Moodle developer write a short specification covering what learners do, what teachers configure, how the activity is graded, and which user data it stores. From that, they draft the database tables, their keys, and the relationship to the course module instance. Someone who knows the course design team reviews the spec against the existing core activities to confirm the new module is still justified. The step is done when the spec and data model are signed off and each stored field has a stated purpose.

  2. Confirm the target Moodle version and its requirements

    The team picks the Moodle release the module will target and checks its server requirements before any code is written. For Moodle 5.1, the facts supplied list 64-bit PHP 8.2 or later (8.3 and 8.4 supported), PostgreSQL 15, MySQL 8.4, MariaDB 10.11, or Microsoft SQL Server 2017 or later. For Moodle 5.3, they list 64-bit PHP 8.3 or later (8.4 supported), PostgreSQL 17, MySQL 8.4, MariaDB 11.4, or SQL Server 2019 or later. Ask the platform team to confirm that the staging and production stacks match the chosen release. The step is done when the target version and stack are written into the project plan.

  3. Build the module with capability checks

    Developers scaffold the activity module from the plugin structure Moodle documents for activity modules, then implement the database access, forms, views and settings from the specification. Every page and action checks the relevant capability in the correct context, and input is validated and output escaped before rendering. Teachers, students and other roles are tested against the capability matrix written in the spec. The step is done when the module installs cleanly on a development site and each capability gate behaves as the matrix says for every role.

  4. Add gradebook and completion integration

    Developers connect the module to the gradebook through grade item creation, grade updates and grade item deletion, and wire completion rules so that the activity can count toward course and activity completion. The team agrees with the course designers which completion conditions the module supports and how grades are displayed to learners and teachers. The step is done when a test grade flows into the gradebook, a completion condition changes state as specified, and deleting the activity removes its grade items.

  5. Implement backup, restore and privacy support

    Developers add the backup and restore steps that carry the module's settings and user data through course backup, then test restoring into a different course and site. They also implement the Privacy API provider so that the module reports what personal data it stores and can export or delete it for a given user. A reviewer checks the privacy metadata against the data model from step one. The step is done when a backup and restore round trip keeps the expected data and the privacy export and deletion tests pass for a test user.

  6. Add mobile app support where it is needed

    If learners need the activity in the Moodle mobile app, developers decide which views and actions the app should show and implement the supporting web service calls and mobile content handling. The team decides this at the specification stage, because it changes the web service design and the offline behavior. If mobile use is out of scope, the step records that decision and confirms the activity shows a clear message in the app. The step is done when the agreed mobile behavior is tested on a supported app build against the staging site.

  7. Test on a staging copy of production

    The team restores a recent copy of the production database and files into staging, installs the module there, and runs the functional, capability, gradebook, backup and privacy test scripts against it. Testers include teachers and learners from the design team who work through realistic course content. Any issues found in staging are logged, fixed, and retested. The step is done when the test plan passes on the staging copy, the defect list is closed or formally accepted, and the restore procedure has been confirmed.

  8. Plan the upgrade path and release

    Before release, developers record the Moodle versions the module supports and set the version and requirements metadata in the plugin. The team writes the upgrade runbook, including the database schema changes, the rollback approach, and the process for testing when the next Moodle release arrives, and it checks the plugin for the Moodle release that the site will move to next. The site owner confirms the change window with the platform team and the release is deployed. The step is done when the upgrade runbook is approved, a test upgrade has run on staging, and the module is live with a named owner for future updates.

Which integration options fit which activity types

This table compares three ways to meet a new need in Moodle: configuring a core activity, extending an existing activity through a local or block plugin, and building a standalone activity module. Read each row as the question to answer before committing, and note that the upgrade and maintenance columns grow as you move down the rows.

Build optionWhen it fitsMaintenance and upgrade effect
Configure a core activityThe need is met by existing settings, templates or an existing activity type with a different layout or workflowLowest upgrade risk; confirm which settings change across the releases you plan to run
Extend an existing activity with a local pluginBehaviour must be added around an activity, such as event observers, reports or admin settings, without a new course activity typeModerate; depends on core events and APIs staying stable, so test observers after each upgrade
Add a block or report pluginThe need is a learner or teacher view, dashboard or report that reads from existing activity dataModerate; reads core tables and APIs, so check queries and output markup after upgrades
Build a standalone activity moduleLearners must create, submit or be graded on a new kind of interaction that no core or existing activity can representHighest; you own the schema, gradebook, backup, privacy, mobile and upgrade work for the life of the module
Use a third-party activity pluginA maintained community plugin already covers the need and its listing passes vettingDepends on the maintainer; confirm supported versions and privacy API support before adopting it
Question of fit to confirmWhether the requirement is a workflow, a data capture or a presentation problemDecide before design; a mismatch here is the most common reason custom activities are later retired

Security and operational risks in a custom activity

A custom activity module runs inside Moodle's permission model, handles learner input and files, and must keep working after every Moodle release. The cards below pair each risk with the control that keeps it contained, so the build plan and the test plan can be written from the same list.

Capability checks on every view and action

Each page, form submission, AJAX call and download in the module must confirm the user holds the right capability in the correct context, not just that they are logged in. Check the course module context for activity views, and the course context for management actions. Review every entry point, including the ones added later for mobile or reports, because a missed check on one URL exposes the whole activity. Ask for a list of every capability the plugin defines and which roles receive them by default.

Plugin types docs

Parameter validation on all inputs

Every value read from a URL, form or web service call should pass through Moodle's parameter types with required_param or optional_param, then be checked against the rules the activity expects. Unvalidated IDs let a learner point a request at another user's submission or another course's record. Confirm that record lookups include the course and module IDs, not only the record ID, and that the code uses the form API for text fields so cleaning and escaping stay consistent.

Uploaded files and file handling

If the activity accepts uploads, store them through the File API instead of writing to disk paths you manage, so Moodle controls file areas, permissions and deletion. Restrict accepted file types and sizes on the server, not only in the browser. Check how files are served to other users, since file URLs are not protected by the view page alone. Ask whether the site runs antivirus on uploads and which scanner or hook is used before submissions are opened to graders.

External content and embedded resources

Activities that fetch remote content, embed frames, or render user-supplied HTML create a path for cross-site scripting and data leakage. Clean output with the correct format functions, avoid printing raw request data, and decide which external hosts the activity may call. Outbound requests should go through Moodle's curl wrapper so proxy settings and blocked hosts apply. Confirm with the security team whether any remote host the activity reaches is one the organization has approved.

Testing against each new Moodle release

Moodle ships major releases in April and October and minor point releases every two months, so a custom activity needs a regression run on each target version before production upgrades. Core APIs change, including the Bootstrap and template changes that come with major versions. Plan a standing test environment that matches the production database and PHP version, and agree who owns the fixes and retest. Ask any partner to quote this as recurring work, not a one-time build cost.

Minor point releases
Every 2 months

Data retention and privacy obligations

The activity will store learner responses and grades, so its privacy provider must declare every personal data field and its purpose, and must export and delete that data on request. Gaps here are easy to miss because the data lives in custom tables that core tools do not see. Check that deletion removes records when a course, module or user is deleted, and that backup and restore carry the same data as the live site without leaking records between users.

Questions buyers ask before building a Moodle activity module

What drives the cost of building a custom Moodle activity module?

The cost is driven mainly by how much behaviour the activity needs and how many parts of Moodle it touches. A module that only stores a few fields and displays them is far smaller than one that feeds grades into the gradebook, handles group and override rules, supports backup and restore, implements the privacy API and works in the mobile app. Each of those integrations is separate design, code and test work. Ask any quote to list these parts individually, so you can see which ones you are paying for and which you could drop. Whether you buy it as a one-time build or as a retainer for ongoing maintenance also changes the total.

Who pays for what in a Moodle activity module project?

In a fixed-scope engagement, the client pays a single agreed price for the written deliverables, and the partner carries the design, build, test and documentation work defined in that scope. Your organization still pays separately for the hosting, the Moodle environment, any licensed third-party services, and the staff time your teachers and administrators spend on requirements and acceptance testing. Ongoing work such as Moodle version upgrades, security patches and fixes to the module is usually a separate agreement, so ask whether maintenance is included, excluded or quoted as a retainer.

How long does a custom activity module take to build, and what changes that?

Duration depends on the activity's behaviour, the number of Moodle subsystems it integrates with, and how settled the requirements are when work starts. A module with a clear data model, one grading method and no mobile requirement can move through build and test much faster than one with branching completion rules, several grade items and offline mobile use. Late requirement changes, unclear ownership of decisions, and the availability of test users and course data are common causes of delay. Ask for a timeline in the written scope that lists the milestones and the client inputs each one depends on.

Can our internal team build a custom Moodle activity module?

Yes, if your team has PHP developers who know Moodle's plugin architecture, the database API and the Moodle coding guidelines, and if someone owns the module after go-live. The harder part is not the first build but the parts that are easy to miss: capability checks, backup and restore of every table, privacy API metadata, grade and completion events, and testing across the supported database engines. Before deciding, check whether your team has built a Moodle plugin before, who will review the code, and who will handle the Moodle upgrade that follows. A partner can cover the gaps or work alongside your developers.

What does the client need to provide for an activity module build?

The client provides the functional requirements, the people who make decisions about how the activity behaves, and access to a non-production Moodle environment that matches the production version and database. You will also need sample courses, test accounts for each role (teacher, student, manager and guest), and realistic data for backup and restore testing. For grading and completion, your academic or training staff must confirm the rules in writing, since those rules are hard to change once learners have data. Agree on who signs off each deliverable and how long acceptance testing will take before work begins.

How do Moodle upgrades affect a custom activity module?

Each Moodle release can change the APIs, database schema, renderers and JavaScript that a module depends on, so a custom module needs testing against every target version before production upgrades. Deprecated functions that still work in one release can be removed in a later one. Upgrade effort is shaped by how closely the module follows core APIs, how much it overrides core output, and whether it has automated tests. Confirm the Moodle versions you will run and their support windows, using the Moodle releases page, and plan the module's maintenance around them.

When should we choose an existing Moodle plugin instead of building an activity module?

Choose an existing plugin when it meets the requirement without changing how learners or teachers work, is actively maintained for your Moodle version, and supports the privacy API and backup needs your organization requires. Building is justified when the activity's data model, grading or workflow is specific to your organization and no plugin covers it without workarounds. Before you decide, review the plugin's listing for supported versions, maintainer activity and overlap with core features. Plugin types such as activity modules, blocks and local plugins are documented in Moodle's developer docs, which can help you compare options.

Where to check the plugin API and version requirements

Before any design work starts, confirm the plugin API and the server requirements for the exact Moodle version you will run in production. The plugin types reference in the Moodle plugin types documentation explains how an activity module (mod) fits alongside other plugin types, but the documentation is versioned, so read the page that matches your target release. Note which activity module APIs your team will call, such as the module's lib.php callbacks, and check that each one still exists in the target version before you commit to a design.

The release notes carry the requirements that decide whether your hosting plan works. The Moodle 5.1 release notes and the Moodle 5.3 release notes list the minimum 64-bit PHP version, the supported database engines and versions, and the minimum version a site must be on before it can upgrade. The 5.3 notes raise the PHP floor to 8.3 and the database floors (for example PostgreSQL 17 and MariaDB 11.4), so a module built for 5.1 may need a different server stack for 5.3. Ask your platform team to record the chosen release, its database and PHP versions, and the upgrade path from your current site in the design document.

Treat this check as a gate. If a required API has changed, or your hosting cannot meet the chosen release's requirements, revisit the release choice before writing code rather than patching around it later. Ask DeployOpen or your internal developers to write the confirmed API list, the target release and the server baseline into the design record, so that the testing and upgrade plan refer to the same versions.

How DeployOpen scopes and delivers a custom Moodle activity

DeployOpen approaches a custom Moodle activity module as a scoped engineering job inside infrastructure you control. We agree what the activity must do, which Moodle APIs it will use, and how it reaches your gradebook, backups and mobile users before any code is written. The build, testing and handover then follow that written scope.

How we scope

  • We confirm whether a new activity type is needed or whether an existing core or community activity already meets the requirement.
  • We document the activity's learning purpose, capabilities, grading behavior and completion rules in a written scope before work starts.
  • We list the Moodle version and database targets the module must support, so the scope matches your upgrade plan.

How we build

  • We structure the module to Moodle's activity module conventions, with the required files, install hooks and capability definitions.
  • We wire gradebook, completion and event integration, then add backup and restore and a privacy API provider for personal data.
  • We test the module on a staging copy of your Moodle, including restore into a clean site and mobile app behavior where in scope.

How we hand over

  • You receive the source code, installation notes, a test record and documentation for administrators and course designers.
  • We document any deliberate core-adjacent decisions and the upgrade checks your team should run before each Moodle release.
  • Handover includes a walkthrough with your platform team so the module can be maintained without us.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work begins.
  • Ongoing support, upgrades and continuous testing for the module are available as a retainer.
  • Ask any provider to confirm the test environment, the Moodle versions covered and who owns the code after handover.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.