Venting: is this really the future of LMSs?

Venting: is this really the future of LMSs?

by William Entriken -
Number of replies: 5
I wrote my own LMS 12 years ago and thought I would move my business over to Moodle as a modern open source project.

When I started my first plugin and setting up the database... there's an XML file??? Like 1990s XML?

Then I need to create a user in my plugin, Google can't even find the documentation that applies here. And ChatGPT is saying that `user_create_user` isn't actually documented.

Poking around I see a bunch of the databases have `timecreated` as nullables fields. I wanted to pull-request to fix that. Great it's on GitHub... just kidding that's a mirror.

Am I, like, spelling Moodle wrong when I'm trying to learn about this? Or are the people that make this just a bunch of pre-GitHub people that like XML, FORTRAN and SOAP?
Average of ratings: -
In reply to William Entriken

Re: Venting: is this really the future of LMSs?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Do you have a link to the LMS you created?
In reply to William Entriken

Re: Venting: is this really the future of LMSs?

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi William - welcome to Moodle development.

Please bear in mind, whilst some parts of Moodle are new and written in a modern style, Moodle itself is a huge piece of application written over the last 20 years. Many part of it are a bit old and clunky, but would require a lot of rewriting to update (as well as potentially breaking a lot of 3rd-party code in the process). Even if some bits are a bit ugly, they do actually work, so refactoring them is not always the top of the priority list.

To address specific things you raise - I'm not clear what the objection is to the XML file - it is a good way to define DB tables in a way that can be automatically adapted to create tables for all of the supported database engines. Ultimately, it is just a machine readable file that you should never be manually editing (Moodle has a built-in XMLDB editor, under Site admin > Developer, which is the only way you should ever edit install.xml files).

Do you have a specific question about user_create_user, which isn't clear from looking at the code for the function?

You haven't mentioned specific tables with nullable 'timecreated' fields in them, so I can't comment directly on those cases. At a guess, these may well be tables where the field was added at a later date, so there may well be a whole lot of historical records whereby there is no legitimate 'timecreated' to store (retrospectively forcing those fields to be non-null would likely break a whole lot of existing installs of Moodle).

I've not noticed and FORTRAN in Moodle, XML is mostly limited to the database table definitions (where, as I've already suggested, it is a perfectly reasonable format to use for the purpose) and SOAP is horrible (but, in this case, it is an optional webservice format for external servers that want to use it to connect to Moodle, I suspect the vast majority of external servers will use the REST alternative; providing a SOAP version if someone really wants to use it, doesn't hurt anyone who doesn't want to use it).
Average of ratings: Useful (4)
In reply to Davo Smith

Re: Venting: is this really the future of LMSs?

by Francis Devine -
Picture of Core developers
Yeah personally Moodle's use of XML here is easily defendable, they use a pretty limited set of tags and attributes and they don't venture into the realm of XSLT or anything crazy like that.

once you know the format it's pretty easy to hand code up the table defs to avoid the clicking pain of the XMLDB editor too.

The documentation has always been a weaker point, but the new dev site is a good place to look - https://moodledev.io/ however often i'll resort to reading the code to actually understand a function or API.
Average of ratings: Useful (1)
In reply to Francis Devine

Re: Venting: is this really the future of LMSs?

by William Entriken -
Thank you. For user_create_user, the documentation is at https://github.com/moodle/moodle/blob/master/user/lib.php. It specifies the input is stdClass|array. But it hugely leaves out *which* fields in that input need to be included and which are processed. For an example of a modern PHP application that properly defines an input, please see https://api-docs.freescout.net/#create-conversation explaining the inputs required for the create-conversation function.

---

For timecreated, here's over a dozen what I would call errors:

```
grep 'NAME="timecreated"' **/install.xml | grep -v 'NOTNULL="true"'
admin/tool/brickfield/db/install.xml: admin/tool/log/store/standard/db/install.xml: admin/tool/mfa/db/install.xml: admin/tool/recyclebin/db/install.xml: admin/tool/recyclebin/db/install.xml: enrol/lti/db/install.xml: lib/db/install.xml: lib/db/install.xml: lib/db/install.xml: lib/db/install.xml: lib/db/install.xml: lib/db/install.xml: lib/db/install.xml: lib/db/install.xml: lib/db/install.xml: lib/db/install.xml: lib/db/install.xml: mod/h5pactivity/db/install.xml: mod/scheduler/db/install.xml: mod/workshop/db/install.xml: ```

If these errors are kept in place because previously the designers didn't know what they know now about databases, this just shows me that migrations/changes/upgrades must be too hard in Moodle to bother doing, even though Moodle already made 36 backwards-compatibility-breaking (i.e. "major") releases. (This is hidden by the fact that Moodle does not use Semantic Versioning.)

---

For XML, obviously this would have used JSON if it were made today. And since this is something every plugin developer sees right when they start learning/developing and I see people complaining about the XML tool, obviously there is some inertia or difficulty in changing things in Moodle which I can expect to permeate across other feature... probably everything, since everything comes after setting up your database smile

---

This is an official rant post so I'm allowed to be negative here smile