Filter course "section" by user attribute

Filter course "section" by user attribute

by Tim TO. -
Number of replies: 5

Hi All,

We have a current need, and I'd love some help brainstorming the best solution. Here it is: 

  • The ability to restrict visibility of course "sections" by one or more states.
  • Therefore, all users with the designated state(s) will be the only ones that can see that course section.
    • Users will already be enrolled into the course, but the goal will be to restrict visibility based on the state(s) they are associated with.

Any thoughts on the best way to customize or implement this? Cheers.

Average of ratings: -
In reply to Tim TO.

Re: Filter course "section" by user attribute

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

If you are using Moodle 2.4 or later, you can use Conditional user fields

Or you can investigate Groupings

In reply to Mary Cooch

Re: Filter course "section" by user attribute

by Tim TO. -

Just came across your Youtube video (

) explaining the same thing. Should work wonders. thanks so much Mary!

In reply to Tim TO.

Re: Filter course "section" by user attribute

by Tim TO. -

As I'm looking into this, I realized that a requirement is to allow assigning multiple states to a user's profile. In noticing that there isn't a "multi-select" custom profile field format, we'd need to use something like the comma-delimited format to store states (Oregon,Washington,Nevada) in the user's state field (which is a text input).

But in regards to the "Restrict Access" based off of conditions with the user profile fields...there is a constraint where a user profile field cannot been declared more than once. Line 274 of /course/editsection_form.php creates the conditions to restrict this.

Does anyone know of customizations that allow for using the same profile field more than once in the "restrict access" conditions? And/Or is there a plugin that allows the ability to create custom fields with the "multi-select" format?

In reply to Tim TO.

Re: Filter course "section" by user attribute

by Andrew Downes -

I have the same issue. Did you get a fix? 

 

Did you try simply removing the validation? If so, did it work? 

 

Thanks, 

Andrew 

In reply to Andrew Downes

Re: Filter course "section" by user attribute

by Andrew Downes -

I notice that on the version of Moodle on my local machine (2.6.2+ (Build: 20140314)) there is no validation. Instead it simply empties the first row referring to the user profile field and only keeps the second reference. So I guess that implies that the validation is there for a reason!

I'll try and remember to create a tracker bug for that once I've eaten my dinner!

Andrew