How to get list activities avialable for one student

How to get list activities avialable for one student

by Aurélien Besson -
Number of replies: 2

Hi,

I work on my plugin and i want to display all activities in course (use course id) for one user.

Currently my list contains all activities in course for user and i can't check if the student can really access (because i have many group restriction by course). For exemple if my student is in Groupe A, i want to diplay all activities visible for this student (exluding activities for Groupe B in the same course). 

I know it's possible to use 

$courseinfo = new \course_modinfo($course, $USER->id); but the result list all activities.

Anybody can help me ?

Thank you


Thank you

Average of ratings: -
In reply to Aurélien Besson

Re: How to get list activities avialable for one student

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi aurélien,

you're near your goal : )
loop throught all these activities and use Availability API. (Display a list of users who may be able to access the current activity)

$info = new \core_availability\info_module($cm);
$filtered = $info->filter_user_list($users);

But
  • This does not currently include the $cm->visible setting, nor does it take into account the viewhiddenactivities setting.
Hope it's help.

Dominique.


In reply to Dominique Palumbo

Re: How to get list activities avialable for one student

by Aurélien Besson -

Thank you Dominique !!!

It works like a charm, for visibility settings i use a sql request.

I will share my plugin in couple of weeks.