Markdown Converter
Agent skill for markdown-converter
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sign in to like and favorite skills
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
REB Library (
local_reblibrary) is a Moodle local plugin for managing the Rwanda Education Board digital library. It provides a complete resource management system with categorization, author management, and integration with Rwanda's education structure (levels, sublevels, classes, and A-Level sections).
Location:
moodle_app/public/local/reblibrary/
Version: 1.3.1 (2025102403)
Tech Stack:
The plugin defines 8 custom tables in
db/install.xml:
Education Structure Tables:
local_reblibrary_edu_levels - Main levels (Pre-primary, Primary, Secondary)local_reblibrary_edu_sublevels - Sublevels (Nursery, Lower Primary, A Level, etc.)local_reblibrary_classes - Grade levels (N1, P4, S6, etc.) with unique class codeslocal_reblibrary_sections - A-Level subject combinations (PCM, HEG, etc.)Resource Management Tables:
local_reblibrary_resources - Main resource/book table (title, ISBN, description, file URLs)local_reblibrary_authors - Author information (first name, last name, bio)local_reblibrary_categories - Hierarchical categories (self-referencing for nesting)Junction Tables:
local_reblibrary_res_assigns - Links resources to classes/sectionslocal_reblibrary_res_categories - Many-to-many resources ↔ categoriesAll CRUD operations are exposed via Moodle external API (AJAX-enabled). Defined in
db/services.php:
Resources API (
classes/external/resources.php):
local_reblibrary_get_all_resourceslocal_reblibrary_get_resource_by_idlocal_reblibrary_create_resourcelocal_reblibrary_update_resourcelocal_reblibrary_delete_resourceEducation Structure API (
classes/external/edu_structure.php):
Categories API (
classes/external/categories.php):
Authors API (
classes/external/authors.php):
TypeScript + Preact + Tailwind CSS:
amd/src/*.ts and amd/src/*.tsxamd/src/components/ (admin UI, education structure, shared components)amd/build/*.js (AMD modules for Moodle's RequireJS)Key Frontend Modules:
library-home.ts - Public library home pagedashboard.ts - Admin dashboardresources.ts - Resource management UIcategories.ts - Category management UIed-structure.ts - Education structure management UIBuild System:
vite.config.ts.ts/.tsx files in amd/src/app, types, store (imported by other modules)Admin pages located in
admin/:
admin/index.php - Main dashboardadmin/resources.php - Resource managementadmin/categories.php - Category managementadmin/ed_structure.php - Education structure setupAccess requires
moodle/site:config capability.
Defined in
db/access.php:
local/reblibrary:view - View library (all users)local/reblibrary:manageresources - Manage resources (teachers, managers)local/reblibrary:manageauthors - Manage authors (teachers, managers)local/reblibrary:managecategories - Manage categories (teachers, managers)local/reblibrary:manageedulevels - Manage education levels (managers only)local/reblibrary:manageedusublevels - Manage sublevels (managers only)local/reblibrary:manageclasses - Manage classes (managers only)local/reblibrary:managesections - Manage A-Level sections (managers only)local/reblibrary:manageassignments - Assign resources to classes/sectionsAll commands run from the plugin directory:
# Install dependencies (first time only) pnpm install # Build once pnpm run build # Watch for changes (development mode) pnpm run dev
Critical: After building frontend, always purge Moodle caches:
# From project root docker compose exec php php /var/www/html/moodle_app/admin/cli/purge_caches.php
# Purge caches (after PHP, template, or language string changes) docker compose exec php php /var/www/html/moodle_app/admin/cli/purge_caches.php # Run database upgrade (after changing db/install.xml or db/upgrade.php) docker compose exec php php /var/www/html/moodle_app/admin/cli/upgrade.php --non-interactive # Check plugin status docker compose exec -T mariadb mariadb -u moodleuser -pmoodlepass moodle -e \ "SELECT name, value FROM mdl_config_plugins WHERE plugin='local_reblibrary';"
# Access database shell docker compose exec mariadb mariadb -u moodleuser -pmoodlepass moodle # List plugin tables docker compose exec -T mariadb mariadb -u moodleuser -pmoodlepass moodle -e \ "SHOW TABLES LIKE 'mdl_local_reblibrary_%';" # View resources docker compose exec -T mariadb mariadb -u moodleuser -pmoodlepass moodle -e \ "SELECT * FROM mdl_local_reblibrary_resources;"
amd/src/ (e.g., amd/src/mymodule.ts)init function or other exportspnpm run build$PAGE->requires->js_call_amd('local_reblibrary/mymodule', 'init');docker compose exec php php /var/www/html/moodle_app/admin/cli/purge_caches.phpExample:
// amd/src/mymodule.ts import { h, render } from 'preact'; export const init = () => { const container = document.getElementById('app'); render(<div className="p-4 bg-blue-500">Hello Tailwind!</div>, container); };
classes/external/resources.php){method}_parameters() function{method}_returns() functiondb/services.php with capability requirements$plugin->version in version.phpPattern:
// classes/external/myapi.php namespace local_reblibrary\external; class myapi extends external_api { public static function my_method_parameters() { return new external_function_parameters([...]); } public static function my_method($param) { $params = self::validate_parameters(self::my_method_parameters(), ['param' => $param]); $context = context_system::instance(); self::validate_context($context); require_capability('local/reblibrary:view', $context); // Implementation... } public static function my_method_returns() { return new external_single_structure([...]); } }
db/install.xml using XMLDB syntaxdb/upgrade.php:
if ($oldversion < 2025102404) { // Create/modify tables using $dbman upgrade_plugin_savepoint(true, 2025102404, 'local', 'reblibrary'); }
$plugin->version in version.php to 2025102404docker compose exec php php /var/www/html/moodle_app/admin/cli/upgrade.phpComponents should be placed in
amd/src/components/:
// amd/src/components/MyComponent.tsx import { h } from 'preact'; interface Props { title: string; } export default function MyComponent({ title }: Props) { return ( <div className="p-4 rounded-lg bg-white shadow-md"> <h2 className="text-xl font-bold">{title}</h2> </div> ); }
Import in entry point module (not excluded in
vite.config.ts):
// amd/src/mypage.ts import { h, render } from 'preact'; import MyComponent from './components/MyComponent'; export const init = () => { render(<MyComponent title="Hello" />, document.getElementById('app')); };
Entry points: Auto-discovered from
amd/src/*.ts and amd/src/*.tsx (root level only)
Excluded from entries:
app, types, store (defined in vite.config.ts)
Output format: AMD (for Moodle's RequireJS)
Bundling: Dependencies (Preact, Tailwind CSS) are bundled into each module
Tailwind CSS: v4 with modern
@import "tailwindcss" syntax. Styles are injected via JavaScript.
Source maps: Generated for debugging
Minification: Enabled (esbuild)
If you create a new root-level TypeScript file in
amd/src/:
amd/build/{filename}.jsexcludeFromEntries in vite.config.tsThis plugin is part of a Moodle 5.1 Docker environment:
moodle_app/public/ (Moodle 5.0+ structure)admin / Admin123!/Users/bahatijustin/Dev/reb/elearning-app/CLAUDE.mdPublic:
Admin (requires site config capability):
$DB->get_records(), $DB->insert_record(), etc.required_param(), optional_param(), and external API validationrequire_capability()version.php after database schema changes to trigger upgradesamd/src/types.ts for type safety@preact/signals) for reactive state managementglobal $DB; - DML API (get_records(), insert_record(), update_record())global $OUTPUT; - Rendering (render_from_template(), header(), footer())global $PAGE; - Page setup (set_context(), set_url(), requires->js_call_amd())global $USER; - Current user objectget_config('local_reblibrary', 'settingname')require_capability(), has_capability()context_system::instance(), context_course::instance($courseid)Changes not showing up:
docker compose exec php php /var/www/html/moodle_app/admin/cli/purge_caches.phppnpm run buildDatabase changes not applied:
version.phpdocker compose exec php php /var/www/html/moodle_app/admin/cli/upgrade.phpTypeScript module not found:
amd/src/ root (not subdirectory like components/)vite.config.tspnpm run buildWeb service not working:
db/services.php{method}_parameters(), {method}_returns())