A cmi5 client library is available for enabling cmi5 support in content to work with a cmi5 conformant LMS (Learning Management System). The library is available at the following gitHub site:
Here are 3 common examples for using the cmi5 client library.
In this scenario, we will implement the bare minimum for a cmi5 enabled AU (content). Launch and exit.
See https://github.com/adlnet/xAPIWrapper/tree/master/dist ).
<script src="Scripts/xapiwrapper.min.js"></script>
See https://github.com/adlnet/cmi5-Client-Library/tree/master/Examples/Scripts
<script src="Scripts/cmi5Controller.js"></script>
See https://github.com/adlnet/cmi5-Client-Library/tree/master/Examples/Scripts
<script src="Scripts/cmi5Wrapper.js"></script>
Parse launch parameters passed on the URL Launch line and set properties of the cmi5 controller.
cmi5Controller.setEndPoint(parse("endpoint"));
cmi5Controller.setFetchUrl(parse("fetch"));
cmi5Controller.setRegistration(parse("registration"));
cmi5Controller.setActivityId(parse("activityid"));
cmi5Controller.setActor(parse("actor"));
Call the cmi5Controller.startUp() method. Two call back functions are passed:
It is called once the controller has fetched the authorization token, read the State document and the agent Profile.
Create the “cmi5Ready” function.
Issue the initialized Statement
SendStatement("Initialized");
Create the “startUpError” function.
In this scenario, the learner views or does all of the relevant activities in an AU presentation and exits.
Steps 1 thru 7 (Same as Example #1)
When learner finishes all activities - Send Completed Statement
SendStatement("Completed");
Add reference to FinishAU() in your UI for learner exit event.
In this scenario, the learner will be assessed in a scored activity. The activity has a MasteryScore associated with it from the course structure.
Steps 1 thru 7 (Same as Example #1)
Get the MasteryScore
var score = cmi5Controller.getMasteryScore();
Assess Learner (Learner performs assessment activity)
Judge Score – Based on Score , Send Statement:
if (score >= cmi5Controller.getMasteryScore()) {
SendStatement("Passed", score);
} else {
SendStatement("Failed", score);
}
Add reference to FinishAU() in your UI for learner exit event.