Using Moodle as a backend with a custom front end and middleware

Using Moodle as a backend with a custom front end and middleware

by Laurent School -
Number of replies: 15

Hi everyone,

I'm software engineer and I'm currently developing to build an online school available on the web and mobile.

During my researches I found Moodle and its huge community.

Moodle is great since it already deal on all the problems we could have while building an online school.

I'm really impressed and it's a great job!

However the documentation isn't really easy and I still kind of lost regarding Moodle.


I'm still wondering if Moodle could be a great fit for my project. Here are the requirements of my project:

  • I would like to use Moodle as a backend only.
  • I would like to have a separate front end (developed in React for the moment) from Moodle.
  • I will have a middleware developed in Spring which will call Moodle using the Moodle web services.


I'm going on this way because it enables to separate the differents stack of the project. If I need to change the front end I won't touch to the back. If I need to change the database (i.e Moodle) it will be possible without having to change the front/middle-ware.


My questions are focused on Moodle web services.

  1. The document is not very clear on it but do the web services give all the features of the Moodle  I had the feeling that using only web services didn't give the full features of Moodle.
  2.  If I need to use a plugin, let's say attendance, will it be possible to uses this plugin using only web services too?
  3. Is it reasonable to go with the described tech stack and having a decoupled front end, middleware and Moodle being used only as a backend/database? Are there any drawbacks I wouldn't have seen?


Let me know if you would need more information regarding it.


Thank you.


Average of ratings: -
In reply to Laurent School

Re: Using Moodle as a backend with a custom front end and middleware

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
The mobile app does this for student activity participation, so in theory you could do it in another js framework. However it would be a very significant task.
Code does not exist to allow this from a teacher/admin perspective. So you can take quiz questions in the mobile app, but you cannot create new ones. To add the code for the teacher/admin perspective would require a team of developers and a significant allocation of time.
In reply to Marcus Green

Re: Using Moodle as a backend with a custom front end and middleware

by Laurent School -
Thank you for your feedback.

Yes, I totally understand that this stack will require some code.
On the other hand, I've developed applications for more than 15 years.
So it will give me more flexibility and enable me to reach the UI faster than trying to edit the Moodle platform. In fact the middleware will only be a "pass through".
For example, in the majority, the middleware will have an endpoint /getCourses and it will juste call the 'getCourses endpoint of Moodle.

From your reply, if I understand it well, the web services don't replace the admin site page of Moodle. I won't be able to create a page for teacher only where they could write some course and where my middleware would be able to "do a POST for a new course", is it right?
In reply to Laurent School

Re: Using Moodle as a backend with a custom front end and middleware

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Yes, if it involves creating new learning materials the generally mobile app does not support it. You can download the app and experiment with what it and there is a forum for web services https://moodle.org/mod/forum/view.php?id=6971

Moodle is a large application that installs over 400 tables and has around a million lines of code
In reply to Marcus Green

Re: Using Moodle as a backend with a custom front end and middleware

by Laurent School -
Yes I'm totally aware about the Moodle codebase. That's why I just want to create an instance of Moodle and communicate with it.
If I need for exemple 10 services, my middleware will only be 10 services.
I just want to separate the backend and the frontend code. The middleware is here just to avoid big refactoring if one day I will need to change the backend or the frontend.

You said it was not possible to add course but I just found a `core_course_create_courses` web services where the documentation says "Create new courses". So it seems to be possible but not implemented in the Moodle mobile app.

In face my main question was "can we do the same as using a regular Moodle app if using only web services for core Moodle and plugins". I cannot manage to find an answer to it. 
In reply to Laurent School

Re: Using Moodle as a backend with a custom front end and middleware

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
"In face my main question was "can we do the same as using a regular Moodle app if using only web services ". 

There are web services that the Mobile app does not use.

You can do what the Mobile app does by using web services. You cannot replicate everything that a teacher/admin can do with existing web services.
In reply to Marcus Green

Re: Using Moodle as a backend with a custom front end and middleware

by Laurent School -
Marcus, I think I misspoke and I apologize for that.
When I talked about the Moodle app I didn't mean the "Moodle mobile application" but the Moodle instance, the one that we can use on MoodleCloud for exemple.

I found the API documentation in the admin settings. But I don't know if it's only the 40%, 60% of 100% features of the Moodle instance.

From what I understand only some less-used feature like editing a quizz are not available.
In reply to Laurent School

Re: Using Moodle as a backend with a custom front end and middleware

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I may be wrong here, but the webservice API only provides a fairly small subset of features for interacting with Moodle.

It is reasonable to use it to create a high-level management system (i.e. something to create a set of courses, within categories, create users and enrol them onto those courses) and some of the activity types support more fine-grained interactions (e.g. assignment submissions can be retrieved and graded, as far as I can see). However, I don't believe there is any way for a teacher to create an activity within a course using webservices.

Moodle is a vast and complex system - much of the more recent functionality has been written to support webservices, but there are a huge number of parts that do not support this method (because Moodle was never designed from the ground up to be fully controllable via webservice functions).

Your project sounds interesting, but it also sounds like an attempt to re-implement, on your own, a system that has been developed over nearly 20 years by hundreds of different contributors.
Average of ratings: Useful (3)
In reply to Davo Smith

Re: Using Moodle as a backend with a custom front end and middleware

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Like me Davo has over a decade of intense focus on what is possible with Moodle. I agree with Davo.
Actually I just looked up his profile, his first post here was 14 years 311 days ago as of today.

I have my own reasons for wanting to be able to do all question creation/editing through web services, but to do it would mean doing nothing else full time for about 12 months at minimum.
Average of ratings: Useful (3)
In reply to Marcus Green

Re: Using Moodle as a backend with a custom front end and middleware

by Laurent School -
Yes I understand. I thought webservices were developed at the same with new feature. Having a table with "current feature" and "webservice available" could be really useful since for me it wasn't really clear which feature would is available or not via webservice.
But yes, if most of them doesn't have webservice, I totally understand the time to add them.
In reply to Laurent School

Re: Using Moodle as a backend with a custom front end and middleware

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
"Having a table with "current feature" and "webservice available" could be really useful"
Yes it would be useful. If you do further work on this I suggest you start a documents page on it as the documents are Wikis and can be edited by anyone.

Although it may seem a significant job to add to the documents I have found once you start other people may add to it. When I started this page on using the VSCode IDE, it was only a small amount of information, but as you can see from the history several other people have added to it.
https://docs.moodle.org/dev/Setting_up_VSCode
In reply to Davo Smith

Re: Using Moodle as a backend with a custom front end and middleware

by Laurent School -
First I'm sorry for my late reply.
Also thank you for your detailed answer.

I don't want to re implement moodle, the middleware will be very small. If I use only 5 webservices, I will just use the middleware to re direct the front request to moodle backend.
I could also directly call Moodle from the front end, since I'm looking for a "headless moodle" but having the middleware could save me time in a possible future migration.

I think the best thing is to start to implement a mvp with all my needed webservices and see if they are available or not.
In reply to Laurent School

Re: Using Moodle as a backend with a custom front end and middleware

by Jorge C. -
Picture of Plugin developers
Maybe I'm missing something in this conversation, but if a particular services does not exist yet (say, to edit a quiz), you can just create it. So I suppose the answer is yes. This may not let you to develop only the frontend, but it lets you to have both completely separated.
Average of ratings: Useful (1)
In reply to Jorge C.

Re: Using Moodle as a backend with a custom front end and middleware

by Laurent School -
Jorge, yes you're totally right. As you understand I want to separate the frontend from Moodle. This ways I could switch easily both of them and use the most of the stacks (i.e as a React dev, it would be easier and faster for me to create the frontend I want using this rather than learning Moodle theme designing).

As you said I could create the missing services. I know that I will create some. My question was more about how many would I need to create. If I see that I need to create a tons of service, the fastest way would I been to create my own backend. Moodle comes from a lot of feature and I just need a little of that.

Also some plugins are available but I didn't know if it was possible to use them with the webservices too. I think about attendance or bigbluebutton.
In reply to Laurent School

Re: Using Moodle as a backend with a custom front end and middleware

by Marko Schütz -
Exposing all functionality as web services opens another use case that I would like to see: custom automation. I use an institutional Moodle instance which I do not administrate myself, but I like to automate my workflows. For example setting up attendances for all my courses for the entire semester taking holidays into account or getting the list of all participants and adding their group according to a specific grouping into that list or creating multiple quizzes with the same group overrides across several courses all at once.