Forum Discussion
Adding References to Certificate of Completions
There was an error with this code, and it should be looping through an object and not an array:
The following code can be inserted into the setupPrint function at around line 306. In the following instance, the script is retrieving variable values from storyline. The variable names that are being assigned to the quizzes are Section_1_Title through to Section_4_Title. The loop simply using $quiznum variable and incrementing it within the loop and reassigning the individual quiz names, strQuizName, with the Section_n_Title.
let $player = window.opener.GetPlayer();
let $quiznum = 1;
for(let quiz in quizzes)
{
quizzes[quiz].strQuizName = $player.GetVar('Section_'$quiznum+'_Title');
$quiznum++;
}
The function could be further modified if the variable names cannot be accessed using an index such as $quiznum in the title. An array of variable names could be used as follows:
let $player = window.opener.GetPlayer();
// array index
let $quiznum = 0;
// an array of Storyline variable used to name the quizzes
let $variable = ['QuizA1Title','QuizA2Title','QuizBTitle','QuizCTitle','FinalQuiz']
for(let quiz in quizzes)
{
quizzes[quiz].strQuizName = $player.GetVar($variable[$quiznum]);
$quiznum++;
}