The function returns the number of modules completed by a user and
executes a COUNT aggregate function to avoid running many queries
to obtain this information, aiming to optimize performance.
Co-authored-by: Carlos Castillo <carlos.castillo@moodle.com>
SQL was fetching activities where completion state was 'completed,
but not passed reqyured grade'. For course completion such states
must be ignored.
Also fixed progress bar on my courses page. Same reasoning as above.