getLearningPath
query. The embedded activity iframe is constructed using data from the getLearningPathContentData
query.
Since the embedded activity iframe is the main element of the Take Learning Path interface, letโs focus on it next.
getLearningPathContentData
query provides the key data needed to render the embedded activity section of the Take Learning Path interface. It returns two primary elements:
SAVE_ANSWER
or TAKE_EDGE
, which primarily act as form controls and enable interaction with the Take Training interface.embeddedUrl
seen in the response is the main gateway to let the user perform an activity.
message
event on the document
saveAnswer
mutationmessage
event. When the user completes the activity inside the iframe, a message is sent to the parent window.
The activity completion message contains a type
, which can be one of the following:
activityAttemptResult
activityAttemptFeedback
activityAttemptFeedback
type is specific and only used in certain configurations for limited activities. For more details, see the Submitting an Activity Answer with Display results and feedback option enabled section.
In most cases, you will receive the activityAttemptResult
message type โ this will be the focus of the following example.
Below is an example of how this process might look (the JavaScript code snippet is available below the video):
saveAnswer
mutation until the complete result message is received from the iframe. answer
โ the userโs answer.order
โ internal metadata, specific to some activity types.activityType
โ the activity type.answerData
payload required for the saveAnswer
mutation.answer
โ the answer
value from the iframe message.order
โ the order
value from the iframe message.lpAttemptContextId
โ the Learning Path Attempt Context ID (provided by the client routing system).edgeRid
โ the Edge Revision ID (provided by the client routing system).attemptStatus
โ usually it should be COMPLETED
. Since the triggering of the save action occurs on the client side, this value should also be provided by the client.activityType
โ the activityType
value from the iframe message.saveAnswer
mutation should be triggered when the user clicks the Next button (associated with the SAVE_ANSWER
CTA).
Below is an example of the saveAnswer
mutation:
TAKE_EDGE
CTA, which indicates that the user should be redirected to the next activity.
VIEW_RESULTS
CTA, indicating that the next step is the edge result screen (typically the module results page).If there is no next stepโmeaning the activity is the last within the Learning Pathโthe system will return a VIEW_LP
CTA, indicating that the user should be redirected to the Learning Path homepage.activityAttemptFeedback
message type indicates that the Display results and feedback option is enabled for this activity. When this message type is received, the system should display the attempt results and feedback to the learner as part of the activity flow.saveAnswer
process works the same way as for other activities. The difference lies in the iframe message type โ which in this case will be activityAttemptFeedback
โ and in the available CTAs returned by the API. See the saveAnswer
mutation example below:
REVIEW_EDGE_EMBED
CTA in the saveAnswer
response. This means that you need to reload the iframe using the URL provided in the src
key of the REVIEW_EDGE_EMBED
CTA, in order to display the attempt results and feedback.
The Next button should no longer trigger the saveAnswer
mutation, as the answer has already been saved. Instead, it should be replaced with a simple link to the next step. The URL for the next step should be constructed using the data available from one of the CTAs in the saveAnswer
response โ either VIEW_RESULTS
or TAKE_EDGE
, depending on the current activityโs position within the module.