Creating Memberships
Creating Memberships
For adding a User to an Hierarchy, a Memberhsip has to be created in IMS-ES. These Memberships can be created with the following functions.
CreateMembership
This function creates a Membership in IMS-ES, or in other words adds a User to a Hierarchy in Itslearning. Because Memberships also have an unique identifier, which cannot be found anywhere in the Itslearning UI, there are two ways to generate an identifier: automatically (with the option to also export the generated identifier) or by supplying a custom identifier.
Syntax:
OperationResult CreateMembership(string userSyncKey, string hierarchySyncId, HierarchyRole role);
OperationResult CreateMembership(string userSyncKey, string hierarchySyncId, HierarchyRole role, out string membershipId);
OperationResult CreateMembership(string membershipId, string userSyncKey, string hierarchySyncId, HierarchyRole role);
Parameters:
userSyncKey:
The User that has to be added to a Hierarchy.
hierarchyId:
The Hierarchy to which the User should be added.
role:
Role of the User in the Hierarchy.
membershipId:
Either: The generated membership identifier (as out parameter)
or: A custom identifier, given by the user.
Returns:
The OperationResult containing the warning that Itslearning has send back, or if there was none, null.
Exceptions:
- ImsEsException: If IMS-ES encountered an error in Itslearning, this exception will be thrown.
- ValidationException: If the generated identifier is too long (more than 255 characters) this exception will be thrown.
CreateMemberships
This function creates multiple Memberships in IMS-ES. See CreateMembership for more information on the identifiers.
Syntax:
BatchOperationResult CreateMemberships(ICollection<MembershipPair> memberships);
BatchOperationResult CreateMemberships(ICollection<MembershipPair> memberships, out List<string> membershipIds);
BatchOperationResult CreateMemberships(IDictionary<string, MembershipPair> memberships);
Parameters:
memberships:
Either: An ICollection of MembershipPair objects, containing the User synckey, Hierarchy syncid and the role,
or: An dictionary with the custom identifiers as keys, and the MembershipPair objects as values.
membershipIds:
A List with the generated membership identifiers.
Returns:
A BatchOperationResult with the list of warnings that Itslearning has send back (this list can be empty).
Exceptions:
- ImsEsBatchException: If IMS-ES encountered an error in Itslearning, this exception will be thrown.
- ValidationException: If one of the generated identifiers is too long (more than 255 characters) this exception will be thrown.