I am creating a storyline 360 slide trigger that executes Javascript when the timeline starts. The code is supposed to take created project text variables in storyline and replace their default values with specific messages based on what the slide number is.
In preview, the console provides the following message:
bootstrapper.min.js:2 actionator::exeJavaScript – Script1 is not defined
Here is the code placed into the Execute Javascript trigger:
function setTexts(SlideNumber) {
console.log("setTexts function called with slideNumber: " + slideNumber); // Log the function call
var correctTexts = [
"This is a credit card statement with the amount of money that student owes.",
"This document is intended to give a record of purchases and payments. It gives the card holder a summary of how much the card has been used during the billing period, as well as the amount that is due for that billing cycle."
];
var incorrectPromptTexts = [
"Here's a hint, there are dollar amounts on there and itemized activity, what type of document best fit these?",
"Think about why you would need a statement for bills, please try again."
];
var studentUnderstandTexts = [
"Got it! I always get these confused with my car insurance for some reason.",
"Yes now that I think about it, having an itemized record is very helpful, even if it's quite annoying to always get these in the mail."
];
var positiveFeedbackTexts = [
"_user_ you answered correctly! Awesome job!",
"_user_ you got the question correct!",
"_user_ you answered correctly awesome job!",
"_user_! You answered correctly!",
"_user_! You answered the question right!",
"_user_, You answered right!",
"_user_, You answered the question right!",
"_user_, you answered correctly! Keep it up!",
"_user_, You answered the question right! Keep up the great work",
"_user_ you are doing great! Keep it up!"
];
var negativeFeedbackTexts = [
"_user_, sorry. the answer you gave wasn't what I was looking for.",
"_user_, your answer was not quite right.",
"_user_, It looks like you picked the wrong answer.",
"_user_, I'm afraid the answer you chose wasn't the best one."
];
var player = GetPlayer();
// Log the text being set for each variable
var correctText = correctTexts[slideNumber - 1];
console.log("Setting Correct to: " + correctText);
player.SetVar("Correct", correctText);
var incorrectPromptText = incorrectPromptTexts[slideNumber - 1];
console.log("Setting IncorrectPrompt to: " + incorrectPromptText);
player.SetVar("IncorrectPrompt", incorrectPromptText);
var studentUnderstandText = studentUnderstandTexts[slideNumber - 1];
console.log("Setting StudentUnderstand to: " + studentUnderstandText);
player.SetVar("StudentUnderstand", studentUnderstandText);
// Randomly select positive and negative feedback
var randomPositiveFeedback = positiveFeedbackTexts[Math.floor(Math.random() * positiveFeedbackTexts.length)];
var randomNegativeFeedback = negativeFeedbackTexts[Math.floor(Math.random() * negativeFeedbackTexts.length)];
console.log("Setting PositiveFeedbacktoUser to: " + randomPositiveFeedback);
player.SetVar("PositiveFeedbacktoUser", randomPositiveFeedback);
console.log("Setting NegativeFeedbacktoUser to: " + randomNegativeFeedback);
player.SetVar("NegativeFeedbacktoUser", randomNegativeFeedback);
}