The FieloELR.CourseService class includes three methods.
Obtain Courses (getCourses)
static List<FieloELR__Course__c> FieloELR.CourseService.getCourses (Set<String> fieldsCourse, Set<String> fieldsCourseDependency, Set<String> fieldsModule, Set<Id> courseIds, Id programId, Id memberId, Boolean filterByDependencies, Boolean filterBySegments, Boolean filterByNotTaken, Integer quantity, Integer offset, String orderBy, String dynamicFilter)
Allows you to get a list of the Courses that Members can take based on the given parameters.
Parameters
| Parameter | Type | Description |
|---|---|---|
| fieldsCourse | Set<String> | Set of API names to return in the response. |
| fieldsCourseDependency | Set<String> | Set of API names to return in the response. If null, no related records list is returned. |
| fieldsModule | Set<String> | Set of API names to return in the response. If null, no related record list is returned. |
| courseIds | Id | Course IDs. |
| programId | Id | Program ID. |
| memberId | Id | Member ID. |
| filterByDependencies | Boolean | When memberId is established, it returns the Courses that a Member can take based on the approved Course dependency. |
| filterBySegments | Boolean | When memberId is established, it returns the Courses that a Member can take based on Member Segments. |
| filterByNotTaken | Boolean | When memberId is specified, it returns the Courses that a Member has not taken. |
| quantity | Integer | Number of items to be retrieved. |
| offset | Integer | Number of records from a collection to skip. |
| orderBy | String | Records returned in an ascending or descending order. |
| dynamicFilter | String | JSON parameter to filter by an additional WHERE Clause. |
dynamicFilter
dynamicFilter is a JSON parameter which can contain an array of Filter Wrappers.
Filter Wrapper
| Parameter | Description |
|---|---|
| andOrOperator (Optional) | Logical operator. Possible values are: "", and, or. If empty, default value is and. |
| openPars (Optional) | Open parenthesis. If empty, default value is null. |
| field (Required) | Field API name. |
| operator (optional) | Relational operators. Possible values are: equals, not equals, greater than, greater or equal, less than, less or equal, in, like. If empty, default value is equals. |
| value (Required) | Value to be compared. If relational operator is in, value must be empty. |
| closePars | Close parenthesis. |
| subQueryFilter | Condition for WHERE in Clauses. Specified only when using in. subQueryFilter includes the following: |
subQueryFilter
| Parameter | Description |
|---|---|
| field (Required) | Field API name. |
| objectName (Required) | Object API name. |
| filters | Array of filters. |
[
{
"field":"FieloCMSPLT__Category__r.Name",
"value":"Training",
},
{
"andOrOperator":"and",
"field":"Id",
"operator":"in",
"subQueryFilter":{
"field":"FieloELR__Course__c",
"objectName":"FieloCMS__CourseStatus__c"
"filters":[
{
"field":"FieloELR__Member__c",
"value":"a0Z5000000FBlsBEAT"
}
]
}
}
]This will append to the query WHERE Clause as follows: FieloCMSPLT__Category__r.Name = 'Training' and Id IN (SELECT FieloELR__Course__c FROM FieloELR__CourseStatus__c WHERE FieloELR__Member__c = 'a0Z5000000FBlsBEAT')
Return Value
| Type | Description |
|---|---|
| List<FieloELR__Course__c> | List of Courses. |
Status and Date filteringCourses are automatically filtered by valid dates and Status Active.
Set<String> fieldsCourse = new Set<String>{'Name','FieloELR__Description__c'};
Set<String> fieldsModule = new Set<String>{'Name','FieloELR__Description__c', 'FieloELR__ApprovalGrade__c'};
//getMemberId should be a custom API to get logged member Id
FieloPLT__Member__c member = [SELECT Id, FieloPLT__Program__c FROM FieloPLT__Member__c WHERE Id =: MemberService.getMemberId()];
//In the JSON parameter the field Category__c is a custom field from the Org
List<FieloELR__Course__c> courses = FieloELR.CourseService.getCourses(fieldsCourse, null,fieldsModule,null, member.FieloPLT__Program__c, member.Id, true, true, true, 10, 0, 'FieloELR__Order__c','[{"field":"Category__c","value":"Education","operator":"eq","andOrOperator":""}]');Obtain Mapped Courses (getCoursesMap)
static List<FieloELR.CourseService.CourseWrapper> FieloELR.CourseService.getCoursesMap (Set<String> fieldsCourse, Set<String> fieldsCourseDependency, Set<String> fieldsModule, Set<String> fieldsModuleDependency,Set<Id> courseIds, Id programId, Id memberId, Boolean filterByDependencies, Boolean filterBySegments, Integer quantity, Integer offset, String orderBy, String dynamicFilter)
It allows you to get a list of Courses that Members can take based on the given parameters. Course list map - by means of the Course Wrapper class - returns Course Status, Modules and Modules Responses.
Parameters
| Parameter | Type | Description |
|---|---|---|
| fieldsCourse | Set<String> | Set of API names to return in the response. |
| fieldsCourseDependency | Set<String> | Set of API names to return in the response. If null, no related record list is returned. |
| fieldsModule | Set<String> | Set of API names to return in the response. If null, no related record list is returned. |
| fieldsModuleDependency | Set<String> | Set of API names to return in the response. If null, no related record list is returned. |
| courseIds | Id | Course IDs. |
| programId | Id | Program ID. |
| memberId | Id | Member ID. |
| filterByDependencies | Boolean | When memberId is specified, it returns the Courses that a Member can take based on the approved Course dependency. |
| filterBySegments | Boolean | When memberId is specified, it returns the Courses that a Member can take based on Segments. |
| filterByNotTaken | Boolean | When memberId is specified, it returns the Courses that a Member has not taken. |
| quantity | Integer | Number of items to be retrieved. |
| offset | Integer | Number of records from a collection to skip. |
| orderBy | String | Records returned in an ascending or descending order. |
| dynamicFilter | String | JSON parameter to filter by an additional WHERE Clause. |
Return Value
| Type | Description |
|---|---|
| List<FieloELR.CourseService.CourseWrapper> | List of Course Wrappers. Course Wrapper contains the Course information as follows: |
class FieloELR.CourseService.CourseWrapper{
//Course info and related lists of course dependencies. If course dependencies fieldset is Not Null then it will return its related list
Course__c course;
//If the member is not participating in the course, it will return Null. If he has already joined the course, it will return the fields: 'FieloELR__Course__c','FieloELR__Progress__c'
CourseStatus__c courseStatus;
//If true it means that the course has no segmentation or that the member belongs to at least one of the segments of the course
Boolean allowedForSegment;
//If true, the course has no dependencies or all dependent courses were already completed
Boolean allowedForDependency;
//Returns info from the global class ModuleWrapper
List<ModuleWrapper> modules;
}
class FieloELR.CourseService.ModuleWrapper{
//Module info
Module__c module;
//If true, the module has no dependencies or all dependent modules were already completed
Boolean allowedForDependency;
//Total number of attempts that member made
Integer numberOfAttempts;
//If true it means that at least at one attempt the member had a module response approved
Boolean isApproved;
//List of all module responses with this fieldset: 'FieloELR__GradeValue__c','FieloELR__IsApproved__c','FieloELR__NumberOfAttempt__c','FieloELR__Module__c'
List<ModuleResponse__c> moduleResponses;
//Related list of module dependencies. If module dependencies fieldset is different from Null, then it returns the related list.
List<ModuleDependency__c> dependencies;
}Set<String> fieldsCourse = new Set<String>{'Name','FieloELR__Description__c'};
Set<String> fieldsModule = new Set<String>{'Name','FieloELR__Description__c', 'FieloELR__ApprovalGrade__c'};
//getMemberId should be a custom API to obtain the ID of the logged Member.
FieloPLT__Member__c member = [SELECT Id, FieloPLT__Program__c FROM FieloPLT__Member__c WHERE Id =: MemberService.getMemberId()];
//Category__c is an ORG Custom field.
List<FieloELR.CourseService.CourseWrapper> courseWrappers = FieloELR.CourseService.getCourses(fieldsCourse, fieldsCourseStatus,null,fieldsModule,fieldsModuleResponse,null, member.FieloPLT__Program__c, member.Id, true, true, true, 10, 0, 'FieloELR__Order__c','[{"field":"Category__c","value":"Education","operator":"eq","andOrOperator":""}]');
for(FieloELR.CourseService.CourseWrapper cWrapper : courseWrappers){
FieloELR__Course__c course = cWrapper.course; //includes related list of dependencies
FieloELR__CourseStatus__c courseStatus = cWrapper.courseStatus;
Boolean allowedForSegment = cWrapper.allowedForSegment;
Boolean courseAllowedForDependency = cWrapper.allowedForDependency;
for(FieloELR.CourseService.ModuleWrapper mWrapper : cWrapper.modules){
FieloELR__Module__c module = mWrapper.module;
Boolean moduleAllowedForDependency = mWrapper.allowedForDependency;
Integer numberOfAttempts = mWrapper.numberOfAttempts;
Boolean isApproved = mWrapper.isApproved;
List<FieloELR__ModuleResponse__c> moduleResponses = mWrapper.moduleResponses;
List<FieloELR__ModuleDependency__c> dependencies = mWrapper.dependencies;
}
}Obtain Course Status (getCourseStatus)
static List<FieloELR__CourseStatus__c> FieloELR.CourseService.getCourseStatus (Set<String> fieldsCourseStatus, Set<String> fieldsModuleResponse, Set<Id> courseIds, Id memberId, Integer quantity, Integer offset, String orderBy
Member Course subscriptionMember must be already subscribed to the Course to check the Status.
Get Course Status from a specific Member. There are five possible Statuses: Draft, Active, Scheduled, Completed and Inactive.
Parameters
| Parameter | Type | Description |
|---|---|---|
| fieldsCourseStatus | Set<String> | Set of API names to return in the response. |
| fieldsModuleResponse | Set<String> | Set of API names to return in the response. If null, no related records list is returned. |
| courseIds | Id | Course IDs. |
| memberId | Id | Member ID. |
| quantity | Integer | Number of items to be retrieved. |
| offset | Integer | Number of records from a collection to skip. |
| orderBy | String | Records returned in an ascending or descending order. |
Return Value
| Type | Description |
|---|---|
| List<FieloELR__CourseStatus__c> | List of Course Status |
Set<String> fieldsCourseStatus = new Set<String>{'Name','FieloELR__Progress__c','FieloELR__Course__r.Name'};
Set<String> fieldsModuleResponse = new Set<String>{'Name','FieloELR__Grade__c', 'FieloELR__Module__r.Name'};
//getMemberId should be a custom API to get logged member Id
FieloPLT__Member__c member = [SELECT Id, FieloPLT__Program__c FROM FieloPLT__Member__c WHERE Id =: MemberService.getMemberId()];
List<FieloELR__CourseStatus__c> courses = FieloELR.CourseService.getCourseStatus(fieldsCourseStatus, fieldsModuleResponse,null, member.Id, 10, 0, 'FieloELR__Course__r.FieloELR__Order__c');