Forum Discussion

DavidKelling1's avatar
DavidKelling1
Community Member
2 years ago

do once on resume

Hi,

I'd like to do something once (execute a javascript) if the user chose to resume after launching (and therefore not do it if new launch or restart).  I need it to happen once no matter what slide the user resumes to; for performance reasons, I don't want it to execute on every slide as would happen if I put the javascript in the master slide (which would be a way to make sure it executed no matter what slide the user resumed to). Is there any way to know if the user clicked Resume?  I asked the latest AI language model and it made up a built-in variable that does not exist :-(  Is there a way to find out if the user clicked Resume?

Thanks

  • You could create your own True/False Variable that gets set to True when Resume is selected and the add the condition to the Execute JavaScript trigger to only execute if the Variable is False.

  • DavidKelling1's avatar
    DavidKelling1
    Community Member

    Thanks Ron. But... How do I know Resume has been selected? What--in Storyline--tells me that Resume has been clicked?

  • DavidKelling1's avatar
    DavidKelling1
    Community Member

    Ron, I understand you are suggesting I set a variable to True if the user clicks Resume in Storyline's built-in resume prompt.  What built-in Storyline variable changes to True if the user clicks Resume in the built-in resume prompt, so I can set my variable to True?  (If there was such a variable, I wouldn't need mine!) What is the name of that built-in Storyline variable you are suggesting exists?  You are suggesting there is a way for me to know the user clicked Resume. Again, you said (emphasis mine): "You could create your own True/False Variable that gets set to True when Resume is selected"   How do I know Resume got selected? Thanks, David

  • Nedim's avatar
    Nedim
    Community Member

    I think this JavaScript code should do the trick:

    const resumed = document.querySelector('[data-dv_ref="resume"]');
      if (resumed) {
        GetPlayer().SetVar('Resumed', true)
      } 

    In your project, create a variable (eg. Resumed). set it to False. Execute JavaScript When the timeline starts on this slide. When you launch the course for the first time, "Resumed" will be False because the Resume button is not yet visible, When you reload the course, the Resume button shows and turn the "Resumed" variable to True when the course is resumed. You should probably place the Execute JavaScript trigger in the Master slide.  Your "Resumed" variable will keep its value throughout the course unless you change it on purpose.

  • DavidKelling1's avatar
    DavidKelling1
    Community Member

    To anyone else that reads this (Particularly Articulate staff!) I'd like to know if there is a better way. I'm skeptical this will be reliable long-term as Articulate might change how the Resume button is rendered in the future, given the continually changing landscape of browsers and devices. I would love to know if there is another way, that relies on code (an unadvertised built-in variable?) that has been there for years and therefore will likely be there for years to come.