Moodle 3.4 Participants list debugging

Moodle 3.4 Participants list debugging

by T K -
Number of replies: 0

Hi all, I am currently using Moodle 3.4

A few months ago I was seeing this problem on my moodle courses-> participants list that it was showing empty page. Only after a few times of refreshing it would display the full page.

I even posted the problem & debugging steps here:
https://moodle.org/mod/forum/discuss.php?d=394689

I was not able to find a solution here. But after working with a developer team we found the following:

1) Issue happen in below file where by the function participants_table terminated and returning empty results

  /var/www/html/moodle/lms/user/index.php : Line 228

 

2) Checking through the constructor in participants_table class, and found out it is terminated once calling get_users_roles function

  /var/www/html/moodle/lms/user/classes/participants_table.php : Line 236

 

3) Further check and gound out issue coming from get_records_sql at below file 

  /var/www/html/moodle/lms/lib/accesslib.php : Line 2717

 

4) As checked the coding for get_users_roles, there is a looping to format the keys into array after getting the results by running SQL query. However it was terminated automatically due to too many records. 

 

5) In order to resolve the issue by not affecting others functions that possibly using get_users_roles function, we are extending 1 more optional parameter for get_users_roles to pass in the courseid and further format the SQL query to query only records for specific course id.

  /var/www/html/moodle/lms/lib/accesslib.php, the following is the diff between original & the edited :

2689c2689

< function get_users_roles(context $context, $userids = [], $checkparentcontexts = true, $order = 'c.contextlevel DESC, r.sortorder ASC', $log = false) {

---

> function get_users_roles(context $context, $userids = [], $checkparentcontexts = true, $order = 'c.contextlevel DESC, r.sortorder ASC', $courseid = null) {

2692,2695d2691


2728c2712

<                 FROM {role_assignments} ra, {role} r, {context} c

---

>                 FROM {role_assignments} ra, {role} r, {context} c, {user_enrolments} ue, {enrol} e

2731a2716,2718

>                     AND ue.userid = ra.userid

>                     AND ue.enrolid = e.id

>                     AND e.courseid = $courseid

2733c2720

<             ORDER BY $order LIMIT 50";

---

>             ORDER BY $order";

  /var/www/html/moodle/lms/user/classes/participants_table.php, following line was added :
$this->allroleassignments = get_users_roles($this->context, [], true, 'c.contextlevel DESC, r.sortorder ASC', $courseid);

 

6) As such it will be more efficient to query only the necessary records directly with SQL query instead of getting large set of unused data at the first place.


My concern here is: Is this a known bug in Moodle? Is this problem being addressed in the newer  versions?



Average of ratings: -