Is there a way to load values into variables on course launch from an external file, such as XML, CSV, or something similar? I have a bunch (60 or so) variables that need to get populated with content. Right now I have text entry fields for all of them and the user has to type them in, which is time-consuming. It also doesn't allow for doing the same things twice because at best it's copy/paste each variable, one at a time, from a spreadsheet or something into Storyline. I'd love to find a way to store those in a file that can be edited and prepared ahead of time that Storyline reads on launch to load the values. Any ideas?
I should add that I have seen it can be done by loading an XML file on the server with the course, but that doesn't meet the need. I need to share this with several people who would need to edit the file on a local hard drive each time the course is run, and they will not have access to the LMS files.
You won't be able to do this automatically on course launch. There is web browser security in place preventing direct access to the users file system.
What you can do, is provide a Browse button that the user can click on. Then they can choose the XML file. After choosing the XML file the values will be read into the Storyline variables.
Take a look at this sample project.
It has WebObject. This WebObject has one file in it called index.html. This WebObject reads the values from the XML and loads them into the Storyline variables. You can make changes to the code by opening this file in Notepad. Currently it only reads 3 variables. You will need to edit it to add in more. Below is a screen shot of the code inside of index.html
You will also need to add more variables to the xml. You can also edit this in notepad.
Russell, is there a limit to the number of variables you can use or something? I can't seem to get it to load more than five, even though the syntax and everything looks good. Are there certain characters that can't be used (like underscore _)? Are there certain words that don't work for variable names? Can't seem to get past loading only five items, no matter what I try, and I need almost 40 to load with this method. All text variables as you can see in the attached. I've tried many different names and such but it only loads the first five and stops.
You are correct; in my copy/pasting of the version I uploaded, I had Team5 twice. But even changing it to Team6 doesn't fix the problem--it only loads the first five variables. Does it work for you? I've tried up to 20 variables, with different names and values, and seem to be stuck with this problem no matter what I do. Appreciate any help you can offer. I have a way to let the person manually input all the variables but this would be so much easier I'd love to figure it out.
Its difficult for me to look at it now. I’m not in the office until Monday. Every time you make a change to the WebObject you will have to delete it in Storyline and reinsert it.
If you provide me with an xml with all of your variables in it, I will look at it Monday morning when I can use a computer.
Russell, I see the problem, based on your comment. I was not deleting and adding back in the web object when I changed it. I thought it was updating in Storyline when I published, but I see now that it updates when you embed the web object on the page itself. I haven't finished the project yet but from the testing I just did, that seems to address the issue I was seeing (which makes perfect sense once you said that). So I think I'm good to go--thank you VERY MUCH for your help with this!
9 Replies
I should add that I have seen it can be done by loading an XML file on the server with the course, but that doesn't meet the need. I need to share this with several people who would need to edit the file on a local hard drive each time the course is run, and they will not have access to the LMS files.
Hello Dave,
You won't be able to do this automatically on course launch. There is web browser security in place preventing direct access to the users file system.
What you can do, is provide a Browse button that the user can click on. Then they can choose the XML file. After choosing the XML file the values will be read into the Storyline variables.
Take a look at this sample project.
It has WebObject. This WebObject has one file in it called index.html. This WebObject reads the values from the XML and loads them into the Storyline variables. You can make changes to the code by opening this file in Notepad. Currently it only reads 3 variables. You will need to edit it to add in more. Below is a screen shot of the code inside of index.html
You will also need to add more variables to the xml. You can also edit this in notepad.
Brilliant, Russell! I think this will work perfectly for my project. Thank you very much.
Russell, is there a limit to the number of variables you can use or something? I can't seem to get it to load more than five, even though the syntax and everything looks good. Are there certain characters that can't be used (like underscore _)? Are there certain words that don't work for variable names? Can't seem to get past loading only five items, no matter what I try, and I need almost 40 to load with this method. All text variables as you can see in the attached. I've tried many different names and such but it only loads the first five and stops.
Hi Dave,
The WebObject has Team5 in it twice. The last player.SetVar should be for Team6
You are correct; in my copy/pasting of the version I uploaded, I had Team5 twice. But even changing it to Team6 doesn't fix the problem--it only loads the first five variables. Does it work for you? I've tried up to 20 variables, with different names and values, and seem to be stuck with this problem no matter what I do. Appreciate any help you can offer. I have a way to let the person manually input all the variables but this would be so much easier I'd love to figure it out.
Its difficult for me to look at it now. I’m not in the office until Monday. Every time you make a change to the WebObject you will have to delete it in Storyline and reinsert it.
If you provide me with an xml with all of your variables in it, I will look at it Monday morning when I can use a computer.
Here's one that is working with 10 Variables.
Russell, I see the problem, based on your comment. I was not deleting and adding back in the web object when I changed it. I thought it was updating in Storyline when I published, but I see now that it updates when you embed the web object on the page itself. I haven't finished the project yet but from the testing I just did, that seems to address the issue I was seeing (which makes perfect sense once you said that). So I think I'm good to go--thank you VERY MUCH for your help with this!
This discussion is closed. You can start a new discussion or contact Articulate Support.