Importing and retaining variables
Jun 06, 2012
By
Robin Leach
Is there a way to import variables from external files. I want to design a review game that instructors can input thier questions into a Storyline presentation from a text file. I want to setup a template game that can be used for any question review.
I'm not sure if this is related to the above question but I would also be interested in being able to save variables so when the Storyline is re-opened it retains variables from the last time it was open.
29 Replies
Hi,
Try this code to get the name from the lms. You can see how to display either first name only or full name.
//get user name
//grab the LMS object
var lmsAPI = parent
//ask the LMS object to get the name
var rawName = lmsAPI.GetStudentName();
//the name comes very formal "Last, First"
//we will fix that by sticking the name into an array
var nameArray = rawName.split(",")
//then we save it the other way round "First Last"
var niceName = nameArray[1] +" "+nameArray[0];
//now we grab the Articulate player
var p = GetPlayer();
Hi Bruce!
Thank you for helping me! What I am getting is teh full name, and I would
like to create a variable with just the first name, so what i wanted to
know is how I could isolate the first name from the array into a variable...
Any thoughts?
Try this.
var player = GetPlayer();
var rawName = lmsAPI.GetStudentName();
var nameArray = rawName.split(",");
var firstName = nameArray[1].replace(/^[ ]+|[ ]+$/g,'');
player.SetVar("LearnerFN", firstName);
Hello in your code
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.OpenTextFile("C:\\Test.txt", 8, true, 0);
is it possible to use the variable name in the file path in place of the file name "Test"?
I want the data to be written to a text file that reflects the participant's name. If possible what is the JavaScript code that would do this?
Thanks
Cleigh