Track a User's Progress in a Custom Exercise

Track a user’s progress through a custom exercise by using the sfdc_enablement Apex namespace classes and LearningItemType metadata type.

To implement an evaluation of a user's progress in a custom exercise, extend the sfdc_enablement.LearningItemEvaluationHandler abstract Apex class. Add the Apex class name to the apexEvaluationHandler field of the LearningItemType metadata record.

To calculate the user’s progress through an exercise as a percentage and return the progress status, use the sfdc_enablement.LearningEvaluationResult class inside the sfdc_enablement.LearningItemEvaluationHandler.

To retrieve details of the learning item record and pass it as input to sfdc_enablement.LearningEvaluationResult, use the sfdc_enablement.LearningEvaluation class.

The sfdc_enablement.LearningItemProgressStatus enum provides the progress status, which can be NotStarted, InProgress, or Completed. In this example, we set:

  • NotStarted to be equal to 0.00%
  • InProgress to be greater than 0.00% and less than 100.00%
  • Completed to be equal to 100.00%

LearningEvaluationResult.learningItemProgress expects a double, so only the first 2 decimal values are considered. For example, 0.001 is rounded to 0.00 and 99.999 is rounded to 100.00.

Here’s an example of a custom progress evaluation for the screen flow exercise. See Create a Custom Screen Flow Exercise.

To get the files shown in this example, download enablement_custom_exercise_screen_flow.zip.

This code shows an example of the Apex implementation. You can find this code in the ScreenFlowEvaluationHandler.cls file.

Here’s code showing an example of the LearningItemType metadata record that includes the apexEvaluationHandler field. This field references the ScreenFlowEvaluationHandler Apex class. You can find this code in the ScreenFlowLearningItemType.learningItemType file.