Expert rules for checking user role and group membership

Last modified by Anna Paul-Hasenfuss on 14.09.2026

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]().

Information

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

Author role

Guest

Guest role

ExternalUser

Use cases

General syntax

Entry

Rule result

is[AttrName]()

isGuest()=false

Alternative: !isGuest()

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

isGuest()

Alternative: isGuest() or 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 isExternalUser() 

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

Information

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:

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

Use cases

General syntax

Expert rule example

Expert rule result

inLearningGroup("[string]")

inLearningGroup("Beginner")= false

Alternative: !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("Intern")

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.

 !(inLearningArea("[Learning group1]") or inLearningGroup("[Learning area A]"))If an entry is made in the ‘Visibility’ tab, the course element will be hidden from members of learning group 1 or learning area A. To put it simply, the structure of this assessment is: !(A or B)

(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")

(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 titled "Assessors" within a period of time (03.09.2020 - 13.10.2020), while it will be visible at all times to the person with the user name "Natalie".

is[AttrName]()!(isCourseCoach() or isCourseAdministrator()) If this rule is entered as expert syntax for the ‘Test session visibility’ option in the Visibility tab of a course module test, course coordinators will not see the ‘Start test’ button section in the course view.

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