Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed of enrolment? #17

Open
VOOM108 opened this issue Sep 5, 2020 · 6 comments
Open

Speed of enrolment? #17

VOOM108 opened this issue Sep 5, 2020 · 6 comments
Labels

Comments

@VOOM108
Copy link

VOOM108 commented Sep 5, 2020

As I understand, the enrolment checks via event observation for course completion, not as a cron job, thus it should happen rather instantly? Or is it still reliant on some general Moodle cronjob?

@ewallah
Copy link
Owner

ewallah commented Sep 6, 2020

The enrollment by course completion happens when the course_completed event is triggered. This is not instantly, but very fast: triggered events are queued in FIFO buffer and are processed only after all observers of the event are notified.

This plugin is only using the the good old Moodle cron job to send welcome emails: these messages are not sent immediately but generated during an adhoc task. Adhoc tasks do not run out of the blue, but start because cron tells them to do so.

@amenk
Copy link

amenk commented Sep 29, 2020

But I thin course_completed is triggered in (some?) cases only by a cron on Moodle 3.9 ?

@VOOM108
Copy link
Author

VOOM108 commented Sep 29, 2020

Indeed, that is sth we realized, too. So we had to trigger cron more frequently to reduce the time until the enrollment completes. And added a note to the users, to wait a few minutes and try again.

@amenk
Copy link

amenk commented Sep 29, 2020

Sometimes the cron needs to be executed even twice. In another task we wrote this to enforce the completion calculation

function local_foo_force_aggregation() {
    global $DB;

    $completionTask = new \core\task\completion_regular_task();
    $completionTask->execute();

    // Force reaggregate
    $sql = "UPDATE {course_completions}
	               SET reaggregate = 1
	             WHERE reaggregate > 0";
    $DB->execute($sql);

    $completionTask->execute();
}

@iplusacademy
Copy link

Did you ever try to create an additional cron task running every minute with this as content:

#!/bin/bash

php admin/tool/task/cli/schedule_task.php  --execute='completion_regular_task' > /dev/null
sleep 15
php admin/tool/task/cli/schedule_task.php  --execute='completion_regular_task' > /dev/null
sleep 15
php admin/tool/task/cli/schedule_task.php  --execute='completion_regular_task' > /dev/null

@ewallah
Copy link
Owner

ewallah commented Sep 14, 2023

MDL-32103 made course completion instant for activity based completion criteria. Other criteria still need 2 cron jobs.

So there is a significant change in the speed of the enrolment when using activity based completion criteria.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants