Forum Discussion

Jonathan_Hill's avatar
Jonathan_Hill
Super Hero
7 days ago

Santa's Naughty or Nice List

Happy Holidays, everyone!

I recently built a sorting exercise for a client which used Javascript to split the learner's text entry answer into individual sentences and display these as draggable Post-It notes. The learner was then asked to sort the Post-It notes into 'good' and 'bad' ideas.

Which got me thinking... could Santa use a similar method to decide who's been naughty or nice?


In this Christmas-themed version, I've simplified the Javascript to recognise only individual words (by space or line break) and generate up to 10 Post-It notes for the sorting exercise.

// Get the learner's response from the Storyline text variable
var player = GetPlayer();
var learnerResponse = player.GetVar("Christmas_List");

// Split the text into individual words
// This handles multiple spaces, line breaks, and other whitespace
var words = learnerResponse.split(/\s+/);

// Remove any empty strings from the array
words = words.filter(function(word) {
    return word.trim().length > 0;
});

// Assign each word to numbered variables (Person_1, Person_2, etc.)
// Limited to 20 slots
var maxSlots = 20;
for (var i = 0; i < words.length && i < maxSlots; i++) {
    var varName = "Person_" + (i + 1);
    var trimmedWord = words[i].trim();
    player.SetVar(varName, trimmedWord);
}

// Optional: Store the total number of words processed
player.SetVar("TotalWords", Math.min(words.length, maxSlots));

 

Each of the 10 Post-It notes only becomes visible if a name has been assigned to it.


Depending on the split between 'naughty' and 'nice', you'll see a different video message from Santa.



I created the Santa videos with Powtoon's AI Text to Video tool.

Warning: it's Drag and Drop
As fun as this is, Drag and Drop isn't fully accessible, and I'm still tinkering with the master file to see if I can add keyboard fallback controls and preserve the counting system. Watch this space!


Play here!

No RepliesBe the first to reply