Expert rules for checking user role and group membership

Last modified by Carina Enke on 19.01.2024

By using expert rules, you can control the visibility and the access to course elements by evaluating the user role or group membership. To do this, use the expert rules is[AttrName]() and in[AttrName]().

All of the following example rules can be created for both the visibility and access of a course element. For matters of simplicity, the following examples only describe one scenario at a time. To learn more about the difference between visibility and access, see the page Publishing within courses (visibility and access).

Checking for user role

The following role attributes are available in the learning platform and can be used for expert rules:

Attribute

User with

GlobalAuthor

Role Author

Guest

Role Guest

ExternalUser

Role Externer Nutzer

Examples of Use

Syntax in general

Entry

Result of this rule

is[AttrName]()

isGuest()=false

Alternativ: !isGuest()

If an entry is made in the Access tab, guests will not have access to this course element.

isGuest()

Alternativ: isGuest()=true oder isGuest()=1

If an entry is made in the Visibility tab, only guests will see this course element, while all the registered users will not.

isGuest() or isCourseAdministrator() 

If an entry is made in the Visibility tab, only guests and course owners will see the course element.

Further details on the guest scenario with sample images of the course view for each user role can be found here: Controlling based on the guest role

 

Checking for group membership

The following memberships of a user in connection with a course can be used for expert rules:

Attribute

User is a member

LearningGroup

of a learning group

LearningArea

of a learning area

LearningGroupWaitingList

LearningAreaWaitingList

of the waiting list of a learning group or learning area

CourseAdministrator

of the course owners

CourseCoach

of the learning group tutor

RightGroup

of a rights group

Examples of Use

Syntax in general

Example of an expert rule

Result of this rule

inLearningGroup("[string]")

inLearningGroup("Beginner")= false

Alternativ: !inLearningGroup("Beginner")

If an entry is made in the Visibility tab, all course participants except for the (learning) group with the "Beginner" title will see the course element.

inLearningGroup("Internal")

If an entry is made in the Visibility tab, only members of the "Internal" group will see the course element. Even course owners and group tutors cannot see the course element in the course navigation.

(now >= date("tt.mm.yyy hh:mm")) and (now <= date("tt.mm.yyy hh:mm")) or inLearningGroup("[string]")

(now >= date("22.03.2020 12:00")) and (now <= date("23.08.2020 18:00")) or inLearningGroup("Tutor")

If an entry is made in the Visibility tab, the course element will be visible to all course participants within a certain period of time (22.03.2020 - 23.08.2020), while it will be visible to members of the learning group with the title “tutor" at any time.

(now >= date("tt.mm.yyy hh:mm")) and (now <= date("tt.mm.yyy hh:mm")) or inRightGroup("[string]") or isUser("[string]")

(now >= date("03.09.2020 00:00")) and (now <= date("13.10.2020 00:00")) and inRightGroup("Assessors")or isUser("Natalie")

If an entry is made in the Visibility tab, the course element will be visible to all course participants in the rights group with the title "Assessors" within a period of time (03.09.2020 - 13.10.2020), while it will be visible to the person with the user name "Natalie" at all times.

Create additional rules by using expert syntax. A tabular overview is provided on the page Expertensyntax.