Wiki source code of Expertenregeln zur Prüfung auf ein Benutzerattribut
Last modified by Carina Enke on 13.03.2026
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{section}} | ||
| 2 | {{column width="60%"}} | ||
| 3 | Expert rules let you evaluate user attributes and thus control the visibility and access of a course section or course element. To do this, use the expert rules **hasAttribute, isInAttribute** or **getUserProperty**. | ||
| 4 | |||
| 5 | {{info}} | ||
| 6 | All of the following example rules can be created for both the **visibility** and** access** of a course element. To simplify matters, only one scenario is described in each of the following examples. To learn more about the difference between visibility and access, see the page [[Publishing within courses (visibility and access)>>doc:LMS.Benutzerhandbuch OPAL.Lehren.Kurs.Freigabe von Kursen und Kursinhalten.Freigabe innerhalb von Kursen Sichtbarkeit und Zugang.WebHome||shape="rect"]]. | ||
| 7 | {{/info}} | ||
| 8 | {{/column}} | ||
| 9 | |||
| 10 | {{column width="30%"}} | ||
| 11 | {{panel title="Content"}} | ||
| 12 | {{toc start="2" depth="2"/}} | ||
| 13 | {{/panel}} | ||
| 14 | {{/column}} | ||
| 15 | {{/section}} | ||
| 16 | |||
| 17 | |||
| 18 | == General user attributes == | ||
| 19 | |||
| 20 | The following user attributes are available in the learning platform and can be used for expert rules: | ||
| 21 | |||
| 22 | |=((( | ||
| 23 | Attribut | ||
| 24 | )))|=((( | ||
| 25 | Contains the user-specific value | ||
| 26 | ))) | ||
| 27 | |=(% colspan="1" %)(% colspan="1" %) | ||
| 28 | ((( | ||
| 29 | firstName | ||
| 30 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 31 | ((( | ||
| 32 | First name | ||
| 33 | ))) | ||
| 34 | |=(% colspan="1" %)(% colspan="1" %) | ||
| 35 | ((( | ||
| 36 | lastName | ||
| 37 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 38 | ((( | ||
| 39 | Last name | ||
| 40 | ))) | ||
| 41 | |=((( | ||
| 42 | username / userid | ||
| 43 | )))|((( | ||
| 44 | User name | ||
| 45 | ))) | ||
| 46 | |=((( | ||
| 47 | |||
| 48 | )))|((( | ||
| 49 | Email address | ||
| 50 | ))) | ||
| 51 | |=((( | ||
| 52 | institutionalName | ||
| 53 | )))|((( | ||
| 54 | Institution / University | ||
| 55 | ))) | ||
| 56 | |=(% colspan="1" %)(% colspan="1" %) | ||
| 57 | ((( | ||
| 58 | institutionalUserIdentifier | ||
| 59 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 60 | ((( | ||
| 61 | Matriculation number / User number at the institution | ||
| 62 | ))) | ||
| 63 | |=(% colspan="1" %)(% colspan="1" %) | ||
| 64 | ((( | ||
| 65 | standort | ||
| 66 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 67 | ((( | ||
| 68 | Location | ||
| 69 | ))) | ||
| 70 | |=(% colspan="1" %)(% colspan="1" %) | ||
| 71 | ((( | ||
| 72 | termsOfStudy | ||
| 73 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 74 | ((( | ||
| 75 | Term of study | ||
| 76 | ))) | ||
| 77 | |=(% colspan="1" %)(% colspan="1" %) | ||
| 78 | ((( | ||
| 79 | studySubject | ||
| 80 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 81 | ((( | ||
| 82 | Study programme | ||
| 83 | ))) | ||
| 84 | |=(% colspan="1" %)(% colspan="1" %) | ||
| 85 | ((( | ||
| 86 | studyGroup | ||
| 87 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 88 | ((( | ||
| 89 | Study group | ||
| 90 | ))) | ||
| 91 | |=(% colspan="1" %)(% colspan="1" %) | ||
| 92 | ((( | ||
| 93 | orgUnit | ||
| 94 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 95 | ((( | ||
| 96 | Organisation unit | ||
| 97 | ))) | ||
| 98 | |||
| 99 | {{note}} | ||
| 100 | === Institution-specific user attributes === | ||
| 101 | |||
| 102 | Apart from the general user attributes, there are also institution-specific restrictions or extensions possible. Therefore, check which of the user attributes are available in your platform before using it. Please refer to the page [[Overview of OPAL Shibboleth Attributes>>doc:LMS.Benutzerhandbuch OPAL.Administration.OPAL Shibboleth Attribute.WebHome||shape="rect"]] for an overview of these usable attributes and corresponding example values. | ||
| 103 | {{/note}} | ||
| 104 | |||
| 105 | |||
| 106 | == Checking for a user attribute == | ||
| 107 | |||
| 108 | In general, | ||
| 109 | |||
| 110 | |||
| 111 | * **hasAttribute** is used to check whether a user has a specific attribute or not. The function returns true when the attribute exists, regardless of its value. This rule is suitable for simple existence checks. | ||
| 112 | * i**sInAttribute** is used when you want to pass on whether the attribute value is included in a list of permitted values. The rule checks multi-value lists or enumerations, e.g. roles or group memberships. | ||
| 113 | * **getUserProperty** is used when the exact value of a user attribute needs to be retrieved and then compared with a condition. It is ideal for exact value comparisons or dynamic calculations with attribute values. | ||
| 114 | |||
| 115 | |=Syntax in general|=Example of an expert rule|=Result of this rule | ||
| 116 | |(% colspan="1" rowspan="2" %)//isInAttribute("//[AttrName]//","//[string]//")//|isInAttribute("studySubject","Chemie")|((( | ||
| 117 | If this rule has been defined in the tab Access, the course element is accessible for all persons whose attribute Study programme contains the letter sequence "Chemistry". | ||
| 118 | |||
| 119 | This means that users with the study programme “Chemistry BA" or “Chemistry MA" can use the course element. Users with the study subject “Chemical water treatment”, however, cannot. | ||
| 120 | ))) | ||
| 121 | |isInAttribute("language","de")|If this rule has been entered in the Access tab, the course element is accessible to all persons whose user language is German. | ||
| 122 | |//getUserProperty("//[string]//")//|getUserProperty("orgUnit") = "Marketing"|Only users from the "Marketing" organisation unit can see the course element if this rule has been used in the Visibility tab. | ||
| 123 | |(% colspan="1" rowspan="2" %)//hasAttribute("//[AttrName]//","//[string]//")//|hasAttribute("email","muster.mann@opal.de")|((( | ||
| 124 | Only a user with this email address will get access to the course section. | ||
| 125 | ))) | ||
| 126 | |hasAttribute("language","en")|Only persons with the selected [[user language>>doc:LMS.Benutzerhandbuch OPAL.Meine Lernplattform.Meine Einstellungen.System Settings.WebHome]] ‘English’ will be granted access to the course section. | ||
| 127 | |||
| 128 | Create additional rules by using expert syntax. A tabular overview is provided on the [[Expert>>doc:LMS.Benutzerhandbuch OPAL.Lehren.Kurs.Freigabe von Kursen und Kursinhalten.Expertenmodus zur Freigabe innerhalb von Kursen.Expertensyntax.WebHome]] [[syntax>>doc:LMS.Benutzerhandbuch OPAL.Lehren.Kurs.Freigabe von Kursen und Kursinhalten.Expertenmodus zur Freigabe innerhalb von Kursen.Expertensyntax.WebHome]] help page. |