Moodle Amd Javascript logo

Moodle Amd Javascript

Community
SaadRahman01
moodle-amd-javascript

Use when writing JavaScript for Moodle — AMD modules, ES6 source, grunt build, RequireJS loading, core/ajax + core/str + core/templates + core/modal + core/notification, Mustache template hydration, and AMD unit tests.

Overview

PublisherSaadRahman01
Repositoryclaude-moodle-dev
Skill namemoodle-amd-javascript
Stars
42
Forks
7
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by SaadRahman01 on GitHub. Read the source before you install it.

Installation

Install the Moodle Amd Javascript AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/SaadRahman01/claude-moodle-dev/tree/main/skills/moodle-amd-javascript
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git /tmp/claude-moodle-dev
mkdir -p .claude/skills
cp -r /tmp/claude-moodle-dev/skills/moodle-amd-javascript .claude/skills/moodle-amd-javascript
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Moodle Amd Javascript in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Moodle Amd Javascript on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Moodle Amd Javascript is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Moodle AMD JavaScript

Overview

Moodle uses AMD (RequireJS) for browser JS. Source goes in <plugin>/amd/src/*.js (ES6+), built into minified AMD in amd/build/*.min.js via grunt. Never edit amd/build/ directly. Modules import Moodle core helpers via string IDs (core/ajax, core/str, core/templates).

When to Use

  • Adding interactive JS to a plugin
  • Calling a web service from the browser (core/ajax)
  • Rendering a Mustache template client-side
  • Showing a modal, notification, or toast
  • Building a custom AMD module + grunt config
  • Debugging "module not found" / "build out of date" warnings

Skip when: writing pure backend PHP — use moodle-plugin-development.

File layout

<plugin>/
  amd/
    src/
      foo.js              # ES6 source — edit this
      bar.js
    build/                # generated; commit but never hand-edit
      foo.min.js
      foo.min.js.map

Module ID at runtime = <component>/<filename> (no extension):

  • local/example/amd/src/marker.js → local_example/marker
  • mod/quiz/amd/src/preflight.js → mod_quiz/preflight

Module skeleton

javascript
// amd/src/marker.js
import Ajax from 'core/ajax';
import Notification from 'core/notification';
import {get_string as getString} from 'core/str';
import Templates from 'core/templates';

const SELECTORS = {
    BUTTON: '[data-action="mark-present"]',
    ROW: '[data-region="attendance-row"]',
};

/**
 * Initialise: bind click handlers.
 *
 * @param {number} sessionid
 */
export const init = (sessionid) => {
    document.addEventListener('click', async (e) => {
        const btn = e.target.closest(SELECTORS.BUTTON);
        if (!btn) {
            return;
        }
        e.preventDefault();
        const userid = parseInt(btn.dataset.userid, 10);
        try {
            const result = await markPresent(sessionid, userid);
            const html = await Templates.render('local_example/row', result);
            const row = btn.closest(SELECTORS.ROW);
            Templates.replaceNode(row, html, '');
        } catch (err) {
            Notification.exception(err);
        }
    });
};

const markPresent = (sessionid, userid) => {
    const request = Ajax.call([{
        methodname: 'local_example_mark_present',
        args: {sessionid, userid},
    }]);
    return request[0];
};

Loading from PHP

php
$PAGE->requires->js_call_amd('local_example/marker', 'init', [$sessionid]);

The third argument array is JSON-encoded and passed to your init function.

grunt build

Moodle ships a root Gruntfile.js. From Moodle root:

bash
nvm use                # uses .nvmrc — match Moodle's required Node
npm ci
npx grunt amd          # build all AMD
npx grunt amd --root=local/example   # only your plugin
npx grunt watch        # rebuild on change

Build also runs ESLint + minification. amd/build/*.min.js and *.min.js.map are commit-required (Moodle plugin policy).

Common core modules

ModuleUse
core/ajaxCall web services
core/strLoad lang strings (getString('foo', 'local_example'))
core/templatesRender Mustache (render, renderForPromise, replaceNode, appendNodeContents)
core/notificationToasts, alerts, exception handling (Notification.exception(err))
core/modal (Moodle 4.3+)Replaces core/modal_factory
core/modal_factory(deprecated 4.3+) — use core/modal
core/toastBootstrap-style ephemeral toasts (add(msg, {type}))
core/pendingMark async work pending — required for Behat to wait
core/eventCustom DOM events for cross-module pub/sub
core/logConsole logging (silenced in production)
core/fragmentServer-rendered HTML fragments via mod_x_output_fragment_*
core/urlBuild Moodle URLs
core/configAccess M.cfg (wwwroot, sesskey) safely

Mustache template + JS pair

php
// PHP
$data = ['items' => $items, 'sesskey' => sesskey()];
echo $OUTPUT->render_from_template('local_example/list', $data);
$PAGE->requires->js_call_amd('local_example/list', 'init');
mustache
{{! templates/list.mustache }}
<ul data-region="item-list">
  {{#items}}
  <li data-id="{{id}}">{{name}}</li>
  {{/items}}
</ul>
javascript
// amd/src/list.js
import {get_strings as getStrings} from 'core/str';

export const init = async () => {
    const [confirmTitle, confirmBody] = await getStrings([
        {key: 'confirm', component: 'core'},
        {key: 'confirmdelete', component: 'local_example'},
    ]);
    // ...
};

Pending — make Behat wait

Whenever JS does async work, mark it pending so Behat's I wait until the page is ready actually waits:

javascript
import Pending from 'core/pending';

const pending = new Pending('local_example/marker:save');
try {
    await markPresent(...);
} finally {
    pending.resolve();
}

Without Pending, Behat scenarios are flaky.

Modal (Moodle 4.3+)

javascript
import Modal from 'core/modal';
import ModalEvents from 'core/modal_events';

const modal = await Modal.create({
    title: 'Confirm',
    body: Templates.render('local_example/confirm', data),
    show: true,
    removeOnClose: true,
});
modal.getRoot().on(ModalEvents.save, () => { /* handler */ });

ESLint / coding style

Moodle ships .eslintrc in root. Run:

bash
npx grunt eslint --root=local/example

Rules:

  • ES2018+ source, transpile via grunt
  • Prefer const/let, never var
  • Arrow functions for callbacks
  • JSDoc on every exported function (@param, @return)
  • 4-space indent
  • Single quotes for strings
  • Semicolons mandatory
  • No console.log (use core/log)

Common Mistakes

MistakeFix
Editing amd/build/*.min.jsEdit amd/src/*.js, run npx grunt amd
Forgetting to commit amd/build/Plugin policy — commit both src + build
Wrong module ID (local_example/amd/marker)Use local_example/marker (no amd/)
require(['jquery'], ...) syntaxUse ES6 imports — grunt transpiles to AMD
No Pending around asyncBehat scenarios flake — wrap with core/pending
Hard-coded stringsLoad via core/str so they translate
core/modal_factory in 4.3+Switch to core/modal
Not passing args to js_call_amdArgs become init(arg1, arg2) parameters
Building with wrong Node versionnvm use from Moodle root respects .nvmrc
M.cfg.wwwroot directlyImport core/config for safe access

Calling web services

javascript
import Ajax from 'core/ajax';

const requests = Ajax.call([
    {methodname: 'local_example_get_items', args: {courseid: 5}},
    {methodname: 'local_example_get_users', args: {courseid: 5}},
]);
const [items, users] = await Promise.all(requests);

Methods must be declared 'ajax' => true in db/services.php. The web service token is auto-attached from session (no manual sesskey for AJAX).

Testing AMD

Moodle's AMD has limited unit-test infrastructure. Options:

  • Manual — load page, interact, watch console (Notification.exception surfaces errors)
  • Behat with @javascript — full browser testing
  • Jest (Moodle 4.4+) — npx grunt jest runs tests/jest/*.test.js if present

References

Frequently asked questions

What does the Moodle Amd Javascript AI skill do?

Use when writing JavaScript for Moodle — AMD modules, ES6 source, grunt build, RequireJS loading, core/ajax + core/str + core/templates + core/modal + core/notification, Mustache template hydration, and AMD unit tests.

Why use Moodle Amd Javascript on TypingMind?

Because you install it once and use it with any model. Moodle Amd Javascript is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Moodle Amd Javascript in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/SaadRahman01/claude-moodle-dev/tree/main/skills/moodle-amd-javascript. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Moodle Amd Javascript?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Moodle Amd Javascript?

As many as you like. As long as a model supports skills, you can use Moodle Amd Javascript with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Moodle Amd Javascript AI skill free?

Yes. It is published on GitHub by SaadRahman01 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇