API performance

API performance

by Filippo Carnevali -
Number of replies: 2

Hi,

i'm writing an api to check if the students enrolled in a specific course has completed the course. 

I'm using core_course_get_enrolled_users_by_cmid to get the users list and then i parse it to obtain the IDs. 

After that i run core_completion_get_course_completion_status  to test every IDs and see who completed it and who hasn't.

The goal i have in mind is cycling this through all courses i need to check monthly and the the e-mails of those who has or has not completed the course.

Now i'm having thought about performance. Every course has 10.000 users at least and the core_completion_get_course_completion_status works for single users so i'm looking at 10.000 calls for every calls.

Is there a smarter way of doing this? How?

Thanks,

Filippo


 

Average of ratings: -
In reply to Filippo Carnevali

Re: API performance

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If you're limited to existing web service API calls to gather this information, it doesn't look like there's a better method available.

Other approaches would be to write a Moodle plugin with a new web service function that aggregates all of the data you need in a single call, or with a scheduled task which gathers the data and sends the emails.