Introducing: Real Time Monitoring Service

Introducing: Real Time Monitoring Service

by Andrew Normore -
Number of replies: 15

https://github.com/YorkvilleEducationCompany/RealTimeMonitoringService


Hello everyone! I have a super crazy plugin system I've been working on for a few months... I think the Moodle community at large is going to love what this solves.


Ever try to run a big report but it crushes your CPU and Moodle dies? 

Now you can run those complex queries in a manner that won't break your Moodle with near real time results!


But how, you say?

I built a QUE CACHE system. At the start of a batch, it scans every single course in your Moodle. Then, it begins processing those on a cron job set to every 1 minute interval. I've tested 50 courses at a time on production, it goes very smoothly.

But if the previous script has not finished processing, the system remains locked, and will simply die(); until the next minute where it will check again.


The first module ever built for RTMS was "Autograde overdue quizzes to a 0", some instructors would miss assigning the zero as they were accustomed to using the grade tool.

So how do we scan for missed quizzes? Every single course, every single quiz, every single student.


What's coming Next?

This year we're going to build a Twilio/Sendgrid integration that will be able to message students as such:

"Dear greg, your Final Exam is due in 3 hours and has not been submitted"

"Dear Greg, your Final Exam is now overdue and has automatically been graded with a 0 -- please contact your instructor if you need additional time"

"Dear Gregs Teacher, Greg missed his final exam and has automatically been given a 0, please contact Greg right away"


Imagine being able to have all this data sending out in near real time to your students, without fear of your entire Moodle install being burnt down.


The code right now works, but needs some love in the settings. You can feel free to experiment with it for now, more updates are soon to follow. Stay tuned here and let me know your thoughts!


Cheers,


Average of ratings: Useful (2)
In reply to Andrew Normore

Re: Introducing: Real Time Monitoring Service

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

The code right now works, but needs some love in the settings.

Honestly, the code needs more love in many other aspects, too.

Let me encourage you to get a bit familiar with Moodle coding guidelines and plugins development. Also, please make sure you are aware of the https://docs.moodle.org/dev/Analytics_API as that has been invented exactly for the use cases you mention.

Good luck.

Average of ratings: Useful (1)
In reply to David Mudrák

Re: Introducing: Real Time Monitoring Service

by Andrew Normore -

Very early days for this plugin. Yes, I will be restructuring code to align more with Moodle.org standards. 

One of the reasons I'm open-sourcing is to get help with Moodle.org standards. 

Having a look at that Analytics API, it is far too complex for myself or clients to understand. Sounds cool. It would take me weeks to understand it.

RTMS is designed to be quick, efficient and easy to develop for. 

In reply to Andrew Normore

Re: Introducing: Real Time Monitoring Service

by Andrew Normore -

Furthermore, regarding the Analytics API -- this is not what we're trying to do here.

We're trying to get a real time change detection system running.

Example: User has 30 minutes remaining on their exam and has not been submitted, send email

Can this example be done within the Analytics API?

In reply to Andrew Normore

Re: Introducing: Real Time Monitoring Service

by David Monllaó -

Hi Andrew,

Thanks for sharing your work. The examples listed in the first post of this series are the sort of things the analytics API is designed to do, including the lock smile. You just need to run the analytics scheduled task more frequently, there is a setting for it.

Regarding your example (" User has 30 minutes remaining on their exam and has not been submitted, send email"), yes, it can be done using the analytics API.

In reply to David Monllaó

Re: Introducing: Real Time Monitoring Service

by Andrew Normore -

No kidding eh? I'll have to experiment with that.

Again, that API looks extremely complicated.

In reply to Andrew Normore

Re: Introducing: Real Time Monitoring Service

by David Monllaó -

Yeah, I agree that it is complicated although most of the complexities come from the fact that the framework allows you to built predictive models (supervised learning) so models can be based on data, not only on assumptions. We are improving the complexity of the API and adding new features in 3.7 and we will continue doing it in future versions  (no work has done on it since 3.4). The idea is to have a set of reusable indicators so people can experiment with it.

In reply to David Monllaó

Re: Introducing: Real Time Monitoring Service

by Andrew Normore -

None of what you wrote makes sense to me. smile

We are rocking Moodle 3.3.2, which is really plagued with some awful nightmares, upgrading is very painful and slow for us. We're scared to upgrade to any further versions of Moodle as something ALWAYS breaks. (But it's sure nice to have a job, if you know what I mean!)

So today I processed 3,000 courses, 50 at a time. Fastest was 0.5 seconds, longest was 38 seconds. Took like an hour to scan all those courses, assignments and students and process some gradework we needed to do.

I don't understand the "Scenario" of the Analytics API. Would you build something like "If a user hasn't submitted 30 minutes before an exam"? How does Moodle take an action at this time... using a predictive model?

In reply to Andrew Normore

Re: Introducing: Real Time Monitoring Service

by David Monllaó -

Hi Andrew,

Regarding your feedback about moodle's nightmares and painful upgrades, I haven't heard of any recent upgrade issue, but as a general statement, Moodle 2.x releases were quite more painful to upgrade than recent versions smile We actually got good feedback about our recent releases. I would encourage you to channel your frustration with Moodle in a more effective way (http://tracker.moodle.org).

Reading https://docs.moodle.org/dev/Analytics_API (https://docs.moodle.org/dev/Analytics_API#Static_models) would shed some light on my previous words. As a 3rd party developer you can code things as you want, I am commenting here because you asked for feedback about your tool. You are getting feedback from people that worked on similar problems than you but I am not sure if you are interpreting my feedback in a positive way.

In reply to David Monllaó

Re: Introducing: Real Time Monitoring Service

by Andrew Normore -

We're struck with a Moodle 2.7 -> Moodle 3.3.2 upgrade, which required a PHP 5 -> PHP 7 upgrade, which really messed with other PHP systems we had. We got through it, but was super weird and very tricky.

Happily, we launch Moodle 3.3.2 only to find out that the course backup/restore is majorly bugged, it changes some dates around in unrelated courses when you do a backup/restore. It was fixed in Moodle. 3.4.x. 

So in order to move forward with Moodle, we have to create an additional test site and spend days testing this system so we can confirm it's fixed.

We always feel installing new Moodle updates often times bring more troubles than solutions.


--- And yes! I'm just thrilled anyone is paying attention to my ramblings in any capacity. 

In reply to Andrew Normore

Re: Introducing: Real Time Monitoring Service

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Hey Andrew, 

Great stuff. I am not sure why the comments so far have not been more supportive. I think you should keep at it, and either go your own way with style, or go with the flow and integrate the Analytics API. I recall you posted about this a while back and nobody then told you about the analytics API. 
https://moodle.org/mod/forum/discuss.php?d=374668

I wish I had been able to, but I only know about the bits of Moodle that I have encountered. I expect thats the way for many of us. The bigger your own project is, the harder it is to keep up with Moodle which keeps racing off into the future. The next step is to get it into the Plugins directory. You will need to follow some rules to get there, but it just makes you a better and more knowledgable Moodle dev. in the end. 

A good thing to do would be to look at the plugins under review in the tracker and see where they are falling down.

https://moodle.org/plugins/report/index.php?report=unapproved_plugins_public

In reply to Justin Hunt

Re: Introducing: Real Time Monitoring Service

by Andrew Normore -

Hey thanks, Justin!

Yes I've already done many patches, it's now more "Moodley" in terms of plugin structure, code standards. Has a DB Installer and proper versioning etc.

The idea of what I'm writing here is a SIMPLE method that can be deployed that allows a coder to do really complex things with a lot of fire power behind it. 

I'm going to do a video on the subject soon enough, I'll post here smile

In reply to Justin Hunt

Re: Introducing: Real Time Monitoring Service

by David Monllaó -

Hi,

Pity that we missed the original post (I am not subscribed to General plugins forum sorry) because it would have been great to join efforts.

In reply to David Monllaó

Re: Introducing: Real Time Monitoring Service

by Andrew Normore -

Join efforts in what capacity, David?

In reply to Andrew Normore

Re: Introducing: Real Time Monitoring Service

by David Monllaó -

Moodle is an open source project, we provide a platform for others to extend. The better APIs we provide the better for everybody, building two separate tools solving the same problem is not usually ideal. By join efforts I mean that we could have collaborated to adapt the core implementation to possible specific needs you have as the use cases you presented are the sort of things the analytics API is designed to do.

In reply to David Monllaó

Re: Introducing: Real Time Monitoring Service

by Andrew Normore -

I'm really still in the problem identification phase, with a prototype solution. 

I'm not exactly saying this is the only solution, and if your Analytics API is CPU/RAM friendly, perhaps that is indeed the way forward. But I'm still here in Moodle 3.3 land. 

So once I get our problems solved with my Prototype, it would be prudent to check out the Analytics API. Sounds like there is a lot to be learned here regarding machine learning algorithms, at any rate. It sounds very cool.

But, I haven't been able to read it because I am not familiar at all with the buzz words or concepts.