Plugin: Getting each student in a course, then getting each student's mentor(s)

Plugin: Getting each student in a course, then getting each student's mentor(s)

by Juno Sprite -
Number of replies: 0

I have a Mento role and Student A has Mentor A and Mentor B.

I'm making a plugin where I need to get each student in a particular course. I did that. Now, I want to, subsequently, show a list of each student's mentors (and later, parents and teachers) below the student's name. Here's the idea:

while ($userdata = $gui->next_user()) {
echo $userdata->user->firstname
;

// This is where I need some help
foreach($listofstudentmentors as $mentor) {
echo $mentor->firstname;
}
}

I'm still not super skilled with the usages of $context, but I know this must be relatively easy to do. I've been looking at 'admin/roles/assign.php' for guidance but can't work it out.

I appreciate any help from the Moodle community!
Average of ratings: -