Forum Discussion

RobinLeach's avatar
RobinLeach
Community Member
14 years ago

Importing and retaining variables

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

  • ChrisRoetzer's avatar
    ChrisRoetzer
    Community Member

    I searched just now on this topic and was hoping SL2 had a feature where by you could define a set of variables (either manually within the application) or via file import, as well as the capability to import updated values. From there, one would define those variables embedded within text anywhere I need them (ie text to read on a slide/layer, state or within a quizzing Q). None of this is possible?

    I've built a course for new hires with lots of facts and figures about staffing, how much the division represents of the total organization, how one location compares to another etc. All these values are static text, resident within text boxes. I have an offline Excel file I update and it provides #s and %s I need.

    I have an indexed sheet in the workbook which identifies the location within my .story file i need to edit but I'm just editing static text. I was hoping I could define these 'variable data tokens" and reference them anyway for display or calculation purposes within the course. Import new values on whatever frequency I need, republish and Bam, Done.

    Not happening? :(

    • DavidMcGhee's avatar
      DavidMcGhee
      Community Member

      Prepare to be invited to file a formal request, Chris, bcs thats been the
      Artiulate party line on the matter for the past 5 plus years. And still
      even today Articulate can't tell you if its even in their development
      channel.

  • 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();

    • JayDharap's avatar
      JayDharap
      Community Member

      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);

  • CleightonSIVA's avatar
    CleightonSIVA
    Community Member

    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