Follow

Advanced Integrations - Retrieving the interaction detail from a Registration

Avatar

We store all interactions data as reported by the content in the SCORM Engine. If you desire to report on this information or to push the data to your LMS tables for aggregation, then the best place in your integration to do this is in your RollupRegistration (or RollupRegistrationOnExit) method.

Below is some sample code to show you how to loop through all the Activities and Interactions to get the desired information. It outputs most of the relevant interaction details to the log so that you can see what your courses are actually reporting.

This sample code is in C#, but works the same in a Java integration.

 

// Retrieves the full registration details, not just summary data
Registration reg = ScormEngineManager.Implementation.GetRegistration(externalReg, externalConfig);

foreach (Activity activity in reg.Activities)
{
if (activity.RunTime != null)
{
// This is the item identifier for this SCO, from the manifest.
string activityId = activity.ScormObject.ItemIdentifier;

ActivityRunTimeInteraction[] interactions = activity.RunTime.Interactions;

foreach (ActivityRunTimeInteraction interaction in interactions)
{
// The index for this interaction; the "n" in "cmi.interactions.n".
int index = interaction.InteractionIndex;

// cmi.interactions.n.id. A unique label for the interaction
// (This will sometimes hold the question text in SCORM 1.2 courses)
string id = interaction.Id;

// cmi.interactions.n.type
string type = interaction.Type.ToString();

// cmi.interactions.n.description (SCORM 2004 Only)
// This often has the question text
string description = interaction.Description.ToString();

// cmi.interactions.n.weighting. This can be a "null" value, so check for that.
// Also, be sure to use the "invariant" culture if converting to a string, otherwise
// how the number is formatted will depend on the current thread's culture setting.
string weighting = interaction.Weighting == NullConstants.NullDouble
? ""
: interaction.Weighting.ToString(System.Globalization.CultureInfo.InvariantCulture);

// cmi.interactions.n.correct_responses. There can be multiple correct responses for a // particular interaction, so combine them here.
string correctResponses = String.Join(" || ", interaction.CorrectResponses);
// cmi.interactions.n.student_response (SCORM 1.2) or cmi.interactions.n.learner_response (SCORM 2004)
string learnerResponse = interaction.LearnerResponse.ToString();
// cmi.interactions.n.result. Depending on the type of interaction, this can be a numeric value.
string result = interaction.Result.Value == InteractionResultValue.Real
? interaction.Result.NumericValue.ToString(System.Globalization.CultureInfo.InvariantCulture)
: interaction.Result.ToString();
// cmi.interactions.n.latency. This can be a "null" value, so check for that.
// This is the amount of time it took the learner to make the interaction (in hundredths of a second).
// [Note: This value is often not set by content]
string latency = interaction.Latency.Value == NullConstants.NullLong
? ""
: interaction.Latency.Value.ToString();

// You will most likely want to persist this data to a reporting table in your LMS.
// This will combine all the values into a formatted string and write it to the log,
// to help you see what your courses are reporting for interactions.
string interactionReport = String.Format(@"registration: {0}
activity: {1}
interaction: {2}
id: {3}
type: {4}
description: {5}
weighting: {6}
correctResponses: {7}
learnerResponse: {8}
result: {9}
latency: {10}",
externalReg.PersistToString(),
activityId, index, id, type, description, weighting,
correctResponses, learnerResponse, result, latency);
LogDetail("ROLLUPREGISTRATION - interaction found:" + interactionReport, externalConfig);
}
}

 

This is the preferred method for getting this data over going directly to the database for these values. 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request
Powered by Zendesk