"cmi5 allowed" Statement methods
The optional "cmi5 allowed" statement methods for communicating module status.

progress

Sends the learner's progress for the AU.

Example

1
import Cmi5 from "@xapi/cmi5";
2
3
const cmi5 = new Cmi5();
4
5
// initialize etc
6
7
cmi5.progress(50);
Copied!

Parameters

Parameter
Type
Required
Description
percent
number
true
The learners progress of the AU as a percentage.

Returns

This returns a Promise containing an array with the resulting statementId if successful.

interactionTrueFalse

Sends the learner's boolean based answer to an interaction.

Example

1
import Cmi5 from "@xapi/cmi5";
2
import { LanguageMap } from "@xapi/xapi";
3
4
const cmi5 = new Cmi5();
5
6
const testId = "test1";
7
const questionId = "is-true-true";
8
const answer = true;
9
const correctAnswer = true;
10
const success = answer === correctAnswer;
11
const name: LanguageMap = {
12
"en-US": "Is True True"
13
};
14
const description: LanguageMap = {
15
"en-US": "In a boolean context, is true truthy?"
16
};
17
18
cmi5.interactionTrueFalse(testId, questionId, answer, correctAnswer, name, description, success);
Copied!

Parameters

Parameter
Type
Required
Description
testId
string
true
The identifier of the test.
questionId
string
true
The identifier of the question.
answer
boolean
true
The answer supplied by the learner.
correctAnswer
boolean
false
The correct answer decided by the learning designer.
name
false
The name of the interaction.
description
false
The description of the interaction.
success
boolean
false
Whether the learner interaction result was a success or not.
duration
Period
false
The period it took the learner to perform the interaction.
objective
false
The objective achieved by the learner.

Returns

This returns a Promise containing an array with the resulting statementId if successful.

interactionChoice

Sends the learner's choice based answer to an interaction.

Example

1
import Cmi5 from "@xapi/cmi5";
2
import { LanguageMap, InteractionComponent } from "@xapi/xapi";
3
4
const cmi5 = new Cmi5();
5
6
const testId = "test1";
7
const questionId = "first-two-choices";
8
const answerIds: string[] = ["choice1", "choice4"];
9
const correctAnswerIds: string[] = ["choice1", "choice2"];
10
const success = false;
11
const choices: InteractionComponent[] = [{
12
id: "choice1",
13
description: {
14
"en-US": "Choice 1"
15
}
16
},
17
{
18
id: "choice2",
19
description: {
20
"en-US": "Choice 2"
21
}
22
},
23
{
24
id: "choice3",
25
description: {
26
"en-US": "Choice 3"
27
}
28
},
29
{
30
id: "choice4",
31
description: {
32
"en-US": "Choice 4"
33
}
34
}];
35
36
const name: LanguageMap = {
37
"en-US": "First Two Choices"
38
};
39
const description: LanguageMap = {
40
"en-US": "What are the first two choices?"
41
};
42
43
cmi5.interactionChoice(testId, questionId, answerIds, correctAnswerIds, choices, name, description, success);
Copied!

Parameters

Parameter
Type
Required
Description
testId
string
true
The identifier of the test.
questionId
string
true
The identifier of the question.
answerIds
string[]
true
The Id(s) of the answer(s) supplied by the learner.
correctAnswerIds
string[]
false
The correct Id(s) of the answer(s) decided by the learning designer.
choices
false
The identifiers and descriptions of the possible answers.
name
false
The name of the interaction.
description
false
The description of the interaction.
success
boolean
false
Whether the learner interaction result was a success or not.
duration
Period
false
The period it took the learner to perform the interaction.
objective
false
The objective achieved by the learner.

Returns

This returns a Promise containing an array with the resulting statementId if successful.

interactionFillIn

Sends the learner's short text based answer to an interaction.

Example

1
import Cmi5 from "@xapi/cmi5";
2
import { LanguageMap } from "@xapi/xapi";
3
4
const cmi5 = new Cmi5();
5
6
const testId = "test1";
7
const questionId = "hello";
8
const answers = ["whos there?"];
9
const correctAnswers = ["world", "World"];
10
const success = false;
11
const name: LanguageMap = {
12
"en-US": "Hello"
13
};
14
const description: LanguageMap = {
15
"en-US": "Hello?"
16
};
17
18
cmi5.interactionFillIn(testId, questionId, answers, correctAnswers, name, description, success);
Copied!

Parameters

Parameter
Type
Required
Description
testId
string
true
The identifier of the test.
questionId
string
true
The identifier of the question.
answers
string[]
true
The answer(s) to the question.
correctAnswers
string[]
false
The correct possible answer(s) to the question.
name
false
The name of the interaction.
description
false
The description of the interaction.
success
boolean
false
Whether the learner interaction result was a success or not.
duration
Period
false
The period it took the learner to perform the interaction.
objective
false
The objective achieved by the learner.

Returns

This returns a Promise containing an array with the resulting statementId if successful.

interactionLongFillIn

Sends the learner's long text based answer to an interaction.

Example

1
import Cmi5 from "@xapi/cmi5";
2
import { LanguageMap } from "@xapi/xapi";
3
4
const cmi5 = new Cmi5();
5
6
const testId = "test1";
7
const questionId = "hello-long";
8
const answers = ["whos there?"];
9
const correctAnswers = ["world", "World"];
10
const success = false;
11
const name: LanguageMap = {
12
"en-US": "Hello"
13
};
14
const description: LanguageMap = {
15
"en-US": "Hello?"
16
};
17
18
cmi5.interactionFillIn(testId, questionId, answers, correctAnswers, name, description, success);
Copied!

Parameters

Parameter
Type
Required
Description
testId
string
true
The identifier of the test.
questionId
string
true
The identifier of the question.
answers
string[]
true
The answer(s) to the question.
correctAnswers
string[]
false
The correct possible answer(s) to the question.
name
false
The name of the interaction.
description
false
The description of the interaction.
success
boolean
false
Whether the learner interaction result was a success or not.
duration
Period
false
The period it took the learner to perform the interaction.
objective
false
The objective achieved by the learner.

Returns

This returns a Promise containing an array with the resulting statementId if successful.

interactionLikert

Sends the learner's Likert based answer to an interaction.

Example

1
import Cmi5 from "@xapi/cmi5";
2
import { InteractionComponent } from "@xapi/xapi";
3
4
const cmi5 = new Cmi5();
5
6
const testId = "test1";
7
const questionId = "highest-value";
8
const answerId = "likert4";
9
const correctAnswerId = "likert4";
10
const scale: InteractionComponent[] = [{
11
id: "likert0",
12
description: {
13
"en-US": "Very Unsatisfied"
14
}
15
},
16
{
17
id: "likert1",
18
description: {
19
"en-US": "Unsatisfied"
20
}
21
},
22
{
23
id: "likert2",
24
description: {
25
"en-US": "Neutral"
26
}
27
},
28
{
29
id: "likert3",
30
description: {
31
"en-US": "Satisfied"
32
}
33
},
34
{
35
id: "likert4",
36
description: {
37
"en-US": "Very Satisfied"
38
}
39
}];
40
const name: LanguageMap = {
41
"en-US": "Highest Value"
42
};
43
const description: LanguageMap = {
44
"en-US": "What is the highest value on this scale?"
45
};
46
47
cmi5.interactionLikert(testId, questionId, answerId, correctAnswerId, scale, name, description)
Copied!

Parameters

Parameter
Type
Required
Description
testId
string
true
The identifier of the test.
questionId
string
true
The identifier of the question.
answerId
string
true
The Id of the answer supplied by the learner.
correctAnswerId
string
false
The correct Id of the answer decided by the learning designer.
scale
false
The identifiers and descriptions of the Likert scale.
name
false
The name of the interaction.
description
false
The description of the interaction.
success
boolean
false
Whether the learner interaction result was a success or not.
duration
Period
false
The period it took the learner to perform the interaction.
objective
false
The objective achieved by the learner.

Returns

This returns a Promise containing an array with the resulting statementId if successful.

interactionMatching

Sends the learner's matching based answer to an interaction.

Example

1
import Cmi5 from "@xapi/cmi5";
2
import { LanguageMap, InteractionComponent } from "@xapi/xapi";
3
4
const cmi5 = new Cmi5();
5
6
const testId = "test1";
7
const questionId = "food-groups";
8
const answers = {
9
apple: "fruit",
10
carrot: "vegetable"
11
};
12
const correctAnswers = {
13
apple: "fruit",
14
carrot: "vegetable"
15
};
16
const success = true;
17
const source: InteractionComponent[] = [{
18
id: "apple",
19
description: {
20
"en-US": "Apple"
21
}
22
}, {
23
id: "carrot",
24
description: {
25
"en-US": "Carrot"
26
}
27
}];
28
const target: InteractionComponent[] = [{
29
id: "fruit",
30
description: {
31
"en-US": "Fruit"
32
}
33
},
34
{
35
id: "vegetable",
36
description: {
37
"en-US": "Vegetable"
38
}
39
}];
40
const name: LanguageMap = {
41
"en-US": "Food Groups"
42
};
43
const description: LanguageMap = {
44
"en-US": "Match the food items to their groups."
45
};
46
47
cmi5.interactionMatching(testId, questionId, answers, correctAnswers, source, target, name, description, success);
Copied!

Parameters

Parameter
Type
Required
Description
testId
string
true
The identifier of the test.
questionId
string
true
The identifier of the question.
answers
{[key: string]: string}
true
The source-target key-value pairings of the answers supplied by the learner.
correctAnswers
{[key: string]: string}
false
The correct source-target key-value pairings of the answers decided by the learning designer.
source
false
The identifiers and descriptions of the sources.
target
false
The identifiers and descriptions of the targets.
name
false
The name of the interaction.
description
false
The description of the interaction.
success
boolean
false
Whether the learner interaction result was a success or not.
duration
Period
false
The period it took the learner to perform the interaction.
objective
false
The objective achieved by the learner.

Returns

This returns a Promise containing an array with the resulting statementId if successful.

interactionPerformance

Sends the learner's performance based answer to an interaction.

Example

1
import Cmi5, { Performance, PerformanceCriteria } from "@xapi/cmi5";
2
import { LanguageMap } from "@xapi/xapi";
3
4
const cmi5 = new Cmi5();
5
6
const testId = "test1";
7
const questionId = "trex-runner";
8
const answers: Performance = {
9
distance: 500
10
};
11
const correctAnswers: PerformanceCriteria[] = [{
12
id: "distance",
13
min: 100
14
}];
15
const success = true;
16
const name: LanguageMap = {
17
"en-US": "T-Rex Runner"
18
};
19
const description: LanguageMap = {
20
"en-US": "Get a score of minimum 100 on T-Rex Runner"
21
};
22
23
cmi5.interactionPerformance(testId, questionId, answers, correctAnswers, name, description, success);
Copied!

Parameters

Parameter
Type
Required
Description
testId
string
true
The identifier of the test.
questionId
string
true
The identifier of the question.
answers
true
The source-target key-value pairings of the answers supplied by the learner.
correctAnswers
false
The correct source-target key-value pairings of the answers decided by the learning designer.
name
false
The name of the interaction.
description
false
The description of the interaction.
success
boolean
false
Whether the learner interaction result was a success or not.
duration
Period
false
The period it took the learner to perform the interaction.
objective
false
The objective achieved by the learner.

Returns

This returns a Promise containing an array with the resulting statementId if successful.

interactionSequencing

Sends the learner's sequence based answer to an interaction.

Example

1
import Cmi5 from "@xapi/cmi5";
2
import { LanguageMap, InteractionComponent } from "@xapi/xapi";
3
4
const cmi5 = new Cmi5();
5
6
const testId = "test1";
7
const questionId = "number-order";
8
const answerIds: string[] = ["one", "three", "two", "four"];
9
const correctAnswerIds: string[] = ["one", "two", "three", "four"];
10
const choices = InteractionComponent[] = [{
11
id: "one",
12
description: {
13
"en-US": "One"
14
}
15
},
16
{
17
id: "two",
18
description: {
19
"en-US": "Two"
20
}
21
},
22
{
23
id: "three",
24
description: {
25
"en-US": "Three"
26
}
27
},
28
{
29
id: "four",
30
description: {
31
"en-US": "Four"
32
}
33
}];
34
const success = false;
35
const name: LanguageMap = {
36
"en-US": "Number Order"
37
};
38
const description: LanguageMap = {
39
"en-US": "Put the numbers in order"
40
};
41
42
cmi5.interactionSequencing(testId, questionId, answerIds, correctAnswerIds, choices, name, description, success);
Copied!

Parameters

Parameter
Type
Required
Description
testId
string
true
The identifier of the test.
questionId
string
true
The identifier of the question.
answerIds
string[]
true
The Id sequence of the answers supplied by the learner.
correctAnswerIds
string[]
false
The correct Id sequence of the answers decided by the learning designer.
choices
false
The identifiers and descriptions of the options.
name
false
The name of the interaction.
description
false
The description of the interaction.
success
boolean
false
Whether the learner interaction result was a success or not.
duration
Period
false
The period it took the learner to perform the interaction.
objective
false
The objective achieved by the learner.

Returns

This returns a Promise containing an array with the resulting statementId if successful.

interactionNumeric

Sends the learner's numeric based answer to an interaction.

Example

1
import Cmi5, { NumericCriteria } from "@xapi/cmi5";
2
import { LanguageMap } from "@xapi/xapi";
3
4
const cmi5 = new Cmi5();
5
6
const testId = "test1";
7
const questionId = "human-legs";
8
const answer = 2;
9
const correctAnswer: NumericCriteria = {
10
exact: 2
11
};
12
const success = true;
13
const name: LanguageMap = {
14
"en-US": "Human Legs"
15
};
16
const description: LanguageMap = {
17
"en-US": "How many legs does a human have?"
18
};
19
cmi5.interactionNumeric(testId, questionId, answer, correctAnswer, name, description, success);
Copied!

Parameters

Parameter
Type
Required
Description
testId
string
true
The identifier of the test.
questionId
string
true
The identifier of the question.
answer
number
true
The answer supplied by the learner.
correctAnswerIds
false
The correct answer decided by the learning designer.
name
false
The name of the interaction.
description
false
The description of the interaction.
success
boolean
false
Whether the learner interaction result was a success or not.
duration
Period
false
The period it took the learner to perform the interaction.
objective
false
The objective achieved by the learner.

Returns

This returns a Promise containing an array with the resulting statementId if successful.

interactionOther

Sends the learner's "other" based answer to an interaction.

Example

1
import Cmi5, { NumericCriteria } from "@xapi/cmi5";
2
import { LanguageMap } from "@xapi/xapi";
3
4
const cmi5 = new Cmi5();
5
6
const testId = "test1";
7
const questionId = "plymouth-location";
8
const answer = "(53.756898, -4.501819)";
9
const correctAnswer = "(53.756898, -4.501819)";
10
const success = true;
11
const name: LanguageMap = {
12
"en-US": "Plymouth Location"
13
};
14
const description: LanguageMap = {
15
"en-US": "On this map, please mark Plymouth, Devon"
16
};
17
cmi5.interactionOther(testId, questionId, answer, correctAnswer, name, description, success);
Copied!

Parameters

Parameter
Type
Required
Description
testId
string
true
The identifier of the test.
questionId
string
true
The identifier of the question.
answer
string
true
The answer to the question.
correctAnswer
string
false
The correct possible answer to the question.
name
false
The name of the interaction.
description
false
The description of the interaction.
success
boolean
false
Whether the learner interaction result was a success or not.
duration
Period
false
The period it took the learner to perform the interaction.
objective
false
The objective achieved by the learner.

Returns

This returns a Promise containing an array with the resulting statementId if successful.
Last modified 7mo ago