Skip to content

Commit b878692

Browse files
committed
reaction doc example
1 parent f7c2a46 commit b878692

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

doc/reactions.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,64 @@ Booleans compose multiple rules together. Booleans are objects with a single key
169169

170170
`template` describes the xAPI statement the reaction will produce. It is identical to an xAPI statement, except that object properties may be substituted with `$templatePath`. This is a path that points to a value in a statement matched by `conditions`, using the same syntax as an `identityPaths` path. In the above example, the `$templatePath` points to the actor `mbox` for the actor matched by condition `a`.
171171

172+
## Example
173+
174+
Given the reaction specified above, if the following statements are posted to the LRS:
175+
176+
``` json
177+
[
178+
{
179+
"actor": {
180+
"mbox": "mailto:[email protected]"
181+
},
182+
"verb": {
183+
"id": "https://example.com/verbs/completed"
184+
},
185+
"object": {
186+
"id": "https://example.com/activities/a",
187+
"objectType": "Activity"
188+
},
189+
"result": {
190+
"success": true
191+
},
192+
"timestamp": "2024-01-23T01:00:00.000Z"
193+
},
194+
{
195+
"actor": {
196+
"mbox": "mailto:[email protected]"
197+
},
198+
"verb": {
199+
"id": "https://example.com/verbs/completed"
200+
},
201+
"object": {
202+
"id": "https://example.com/activities/b",
203+
"objectType": "Activity"
204+
},
205+
"result": {
206+
"success": true
207+
},
208+
"timestamp": "2024-01-23T02:00:00.000Z"
209+
}
210+
]
211+
212+
```
213+
214+
Then the following statement will be added subsequently (note that some unrelated fields are removed for clarity):
215+
216+
``` json
217+
{
218+
"actor": {
219+
"mbox": "mailto:[email protected]"
220+
},
221+
"verb": {
222+
"id": "https://example.com/verbs/completed"
223+
},
224+
"object": {
225+
"id": "https://example.com/activities/a-and-b",
226+
"objectType": "Activity"
227+
}
228+
}
229+
230+
```
231+
172232
[<- Back to Index](index.md)

0 commit comments

Comments
 (0)