Concatenate slide numbers into variable

Dec 05, 2023

Hello,

I would like to keep track of a user's progress through a course by concatenating slide numbers (and a comma) every time a slide is started. I can get the Project.SlideNumber variable, but it is a number and I can't add it to a string variable, not to mention I can't figure out how to concatenate it even if it were a string. Any ideas on how to accomplish this?

3 Replies
Brian Dennis

let learnersPath = ''; // define learnersPath as a string type SL variable

// Code for a javascript trigger to run at slide timeline start
const slideNumberFromPlayer= 1; // example; get actually from the Player() using your JS code
learnersPath = learnersPath + "," + exampleSlideNumber;

// console.log(learnersPath);

 

Jim Owen

For anyone who needs this, I have learned how to add line breaks to the body of JS output when composing an email. The string '%0D%0A' acts as a line break. So my code looks something like this:

var p = GetPlayer()
var progress = p.GetVar("progress")
var reviewed = p.GetVar("reviewed")
var answers = p.GetVar("answers")
var times = p.GetVar("times")
var feedback = p.GetVar("TextEntry")
var br = '%0D%0A'

var body = feedback + br + br
var body = body + "PROGRESS " + progress + br
var body = body + "REVIEWED " + reviewed + br
var body = body + "ANSWERS " + answers + br
var body = body + "TIMES " + times + br

var email="me@email.com";
var subject="Sent from Storyline";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body;
win=window.open(mailto_link,'emailWin');