Question component methods
getQuestionMetrics
Arguments
Argument | Type | Description |
---|---|---|
componentId | string - required | Component Id of the Question component |
This method returns the metrics of the Question component. Metrics returned are all the questions in the component, and for each answer a count of how many times the specific answer has been selected. The answers for the current user are included in the metrics result that are returned by this method.
info
The Question Component loads the metrics into the experience as it needs them. For normal use when the getQuestionMetrics
would get called the metrics are available, however sometimes this is not the case. In that case there is a Quiz Metrics Loaded event can be used to get the metrics as soon as they become available.
Example
const metrics = window.wyng['_WYNG_ID_'].getQuestionMetrics('quiz_123456');
console.log(metrics);
Potential Output
{
question_123456: {
answer_123456: 120,
answer_234567: 240,
answer_345678: 57,
answer_456789: 97
},
question_234567: {
answer_987654: 119,
answer_876543: 372,
answer_765432: 613
}
}