🛠 Fixing Moodle Admin Errors and Supporting Multi-Tenancy for Ejss App
A Step-by-Step Illustrated Guide for Moodle Administrators
Maintaining Moodle in production sometimes means solving unexpected problems quickly and then adapting to long-term changes. This guide covers two practical fixes:
-
Problem accessing Site Administration
-
Supporting multi-tenancy in Ejss App (EJS JavaScript simulations via LTI)
1. 🚨 Problem Accessing Site Administration
The Issue
An unusual file appeared in the Moodle installation:
admin/settings/moodleservices.php
This file prevented administrators from opening the Site Administration menu.
Quick Fix (Terminal Commands)
From your Moodle root directory (/home/iwtstudy/public_html/moodle402):
cd /home/iwtstudy/public_html/moodle402
# Rename the suspicious file
mv admin/settings/moodleservices.php admin/settings/moodleservices.php.off
# Purge Moodle caches
php admin/cli/purge_caches.php
✅ Site Administration became accessible again.
📸 Screenshot after fix (Site Admin working)
Why This Works
-
Renaming disables the rogue file.
-
Purging caches clears stale references.
⚠️ Since the origin is unknown, it may reappear. If it does, check:
-
Recently installed plugins
-
Custom code commits
-
Server security logs
2. 🌐 Multi-Tenancy in Ejss App (LTI Integration)
The Ejss App connects to Moodle using LTI. With multi-tenancy, the Deployment ID format changed.
| link |
Old vs New Deployment ID Format
Old (single tenant):
49c45537-c322-45ea-bb7b-b756a2d08bd1
New (multi-tenant, with school code):
49c45537-c322-45ea-bb7b-b756a2d08bd1_0701 (SchoolCode 0701)
49c45537-c322-45ea-bb7b-b756a2d08bd1_0702 (SchoolCode 0702)
📸 Screenshot of Registered Platforms in Moodle (multiple deployment IDs shown)
| link |
The Problem
Moodle treated each variation as a different deployment, breaking existing integrations.
Code Fix (Patch in Moodle Core)
We modified lib/lti1p3/src/LtiMessageLaunch.php so Moodle ignores the _SchoolCode.
Before (default behavior)
Moodle expected an exact match, so _0701 and _0702 were considered different.
📸 Code diff screenshot (before)
After (patched behavior)
// Deployment ID has new format (OID_SCHOOLID), we only use OID
$deploymentId = $this->jwt['body'][LtiConstants::DEPLOYMENT_ID];
$oid = strstr($deploymentId, '_', true) ?: $deploymentId;
$this->jwt['body'][LtiConstants::DEPLOYMENT_ID] = $oid;
Why This Works
-
strstr($deploymentId, '_', true)extracts only the original ID before_. -
If no
_exists, it keeps the full ID (backward compatible). -
Moodle now validates Ejss App consistently across schools.
📸 Screenshot showing Ejss App working again in Moodle
| https://vle.sandbox.sls.moe.edu.sg/my-drive/module/view/eb6aaafa-4e1d-472d-802f-949beabb249b/section/28/activity/30?pageNo=1 |
3. 📝 Key Takeaways
-
Admin Access Fix: Rogue files like
moodleservices.phpcan break admin. Disable + purge caches to recover. -
Multi-Tenancy Fix: New Deployment ID format required a code patch to strip
_SchoolCode. -
Best Practices:
-
Always document quick fixes.
-
Clearly comment custom patches for future upgrades.
-
Watch Moodle release notes in case an upstream fix arrives.
-
✅ Conclusion
Running Moodle at scale means handling both unexpected admin errors and external platform changes.
-
For Site Admin errors, quick terminal fixes restore access.
-
For Ejss App, a small code change future-proofs Moodle against new Deployment ID formats.
Together, these fixes keep Moodle stable and fully integrated with evolving EdTech platforms.
No comments:
Post a Comment