How to Pull Current Date in Articulate Storyline [Using JavaScript]

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ต.ค. 2024
  • Using JavaScript inside of Articulate Storyline gives you extended features and capabilities. You can create custom animations, detect the user's operating system, and more. One of the cool things you can do is detect the current date and time the user is taking your course and then change content based on the date.
    In this example, I walk you through how to pull the date and format it to display to the user. I also show you how to isolate the month and then change a state of a Storyline object depending on the month. So you can modify things in your training like backgrounds or variable information to personalize content based on when the learner is taking the course. All it takes is the simple code snippet below and some logic inside Storyline. Check it out.
    let currentTime = new Date();
    let month = currentTime.getMonth() + 1;
    let day = currentTime.getDate();
    let year = currentTime.getFullYear();
    // Putting it together
    let dateString = month + "/" + day + "/" + year;
    //Pushing data to Storyline
    let player = GetPlayer();
    player.SetVar("todaysDate", dateString);
    player.SetVar("month", month);
    If you want to experience the full course check out www.udemy.com/...
    If you would like learn more visit learningdojo.n...

ความคิดเห็น • 41

  • @felicial7628
    @felicial7628 ปีที่แล้ว +2

    This video has been incredibly helpful! I have been struggling to learn JavaScript. And, this is my first time being able to 'read' code. AND, I can't tell you how many times I have tried to do this unsuccessfully. SUBSCRIBED!

    • @LearningDojo
      @LearningDojo  ปีที่แล้ว

      Glad it helped! That makes me happy to hear. I am planning on more JS and Storyline videos so stay tuned.

  • @michelleej
    @michelleej 5 หลายเดือนก่อน

    I love the tip about using the grid paper, then changing it later!

  • @bluegrasslearningsolutions
    @bluegrasslearningsolutions 5 หลายเดือนก่อน

    Great tutorial. Thank you for sharing the code and walking through your thought process.

    • @LearningDojo
      @LearningDojo  5 หลายเดือนก่อน

      Glad it was helpful!

  • @DannyWoodMusic
    @DannyWoodMusic ปีที่แล้ว

    Thanks Jeff! This is exactly what I needed for a project I'm working on.

    • @LearningDojo
      @LearningDojo  ปีที่แล้ว

      Awesome! Happy to help Danny

  • @rossiboy1962
    @rossiboy1962 8 หลายเดือนก่อน

    Thanks Jeff, this is exactly what i needed. Am new to the use of JavaScript in Articulate so I can me myself using your content a lot more. We are also looking to push results of a test out to training staff via an outlook email. Is this something you could help with or direct us to please ?

    • @LearningDojo
      @LearningDojo  8 หลายเดือนก่อน

      You could connect using something like Zapier to do something like that. It is a tool to help automations.

  • @luisrobles943
    @luisrobles943 ปีที่แล้ว

    Hey there, great video as usual. I was wondering if you can show how to set up a timer. I’m thinking this could be useful for a bunch of compliance courses. Thanks!

    • @LearningDojo
      @LearningDojo  ปีที่แล้ว

      Luis - I have a timer example in the pipeline. So stay tuned and you will see a video about it.

  • @JulieTaylor-d4r
    @JulieTaylor-d4r ปีที่แล้ว

    Hi Jeff, this is great thank you, I am confused though as to what type of variable I need to select in SL to allow date to be collected?

    • @LearningDojo
      @LearningDojo  ปีที่แล้ว

      Text variable should be the one.

  • @jigglypuff8391
    @jigglypuff8391 ปีที่แล้ว

    This isn't working for me. I've set up two variables in storyline, one named month and one named todaysDate. They are both text variables. Then I have a text box reading %month% and another reading %todaysDate%. They are spelled the same as the variable in the javascript. I have a trigger that says: when user clicks this rectangle, execute javascript, where I've copied and pasted this code. Yet when I publish this in review 360, nothing happens when I click the rectangle. What am I missing?

    • @LearningDojo
      @LearningDojo  ปีที่แล้ว

      Hard to say, most of the time I need to take a look at the code exactly. Can you email me your example? jeff@learningdojo.ninja

  • @fiveironscott
    @fiveironscott 2 หลายเดือนก่อน

    Hey Jeff, it seems I could feasibly send SCORM files to clients and let them know they must renew a contract they by a certain date and put a reminder and an execution date in my file via this method.

    • @LearningDojo
      @LearningDojo  2 หลายเดือนก่อน

      Yeah maybe add a redirect based on the date.

  • @Kanaxtheic
    @Kanaxtheic หลายเดือนก่อน

    Very nice! Thanks for this video.

    • @LearningDojo
      @LearningDojo  หลายเดือนก่อน

      Glad you liked it!

  • @YouTubeVanced-xc6te
    @YouTubeVanced-xc6te ปีที่แล้ว

    Hi, I tried your approach but what if I want the month in MM format? Like for example for month March it returns only '3' how do I get '03'

    • @LearningDojo
      @LearningDojo  ปีที่แล้ว +2

      You might have to add the 0 manually. So have a condition that does the following.
      if (month

    • @YouTubeVanced-xc6te
      @YouTubeVanced-xc6te ปีที่แล้ว

      @@LearningDojo thank you!

  • @mindgulag
    @mindgulag ปีที่แล้ว

    Thanks a million, Jeff. This has helped me a lot. I've managed to successfully pull the date and add the 0 before the (single digit( months (September).
    I've run into a complex problem, however:
    I've tried to push that storyline line variable (todaysDate) into a certificate (PDF) that already has a learner name in it.
    Unfortunately, it's not working. I've tried changing the text variable to a string, but that also didn't do the trick.
    Do you have any ideas about what I might do?
    Thanks a million!

    • @LearningDojo
      @LearningDojo  ปีที่แล้ว +1

      Hmm, can you email me the exact code you are using? Wondering if it is a syntax error. jeff@learningdojo.ninja

    • @mindgulag
      @mindgulag ปีที่แล้ว

      @@LearningDojo Hi. Thanks a lot for your response! I'm ashamed to admit it but it was a trivial error. I had forgotten to add one small element which caused the entire code to fail.
      ChatGPT was able to debug it, heh. So it's all good and working. Thanks a lot!

    • @LearningDojo
      @LearningDojo  ปีที่แล้ว +1

      @@mindgulagGreat use of ChatGPT! Yeah I have been there too. I spent hours once trying to debug code and it turned out to be a small syntax error. Welcome to coding 😁

  • @kyleyates6706
    @kyleyates6706 4 หลายเดือนก่อน

    This worked great for displaying the current date... I want to lock out the final test for 24 hours if they fail. I've got everything in place and am using the top pull the system date, but the part I can't figure out is how to check if the current date is at least 24 hours AFTER the date when they failed... I imagine this should be possible but my java skills aren't good enough.

    • @LearningDojo
      @LearningDojo  4 หลายเดือนก่อน

      Hmm, I am not sure how to lock out the quiz though. Are you talking about disabling the Storyline button that allows them to retake the quiz for 24 hours? You might have to have a variable but the problem is keeping that in place after they close the course. That may have to use like a LMS storage or something. Might be beyond what I have ever done as well.

    • @kyleyates6706
      @kyleyates6706 4 หลายเดือนก่อน

      @@LearningDojo I think I figured it out doing something similar to your months, capturing a variable called "failday" = day, "failmonth" = month, "failyear" = year, and then changing the state of a button when the timeline starts if "failday" < day etc... everything is working as intended, but I need to wait for tomorrow when the system day changes to confirm... if it works I'll post a sample on the storyline forums and update you here. You're video and the month thing was the first steps... resume state appears to only work correctly as a separate storyline file, not when imbedded in rise.

    • @LearningDojo
      @LearningDojo  3 หลายเดือนก่อน

      @@kyleyates6706 Sorry for the delay but curious of that worked.

  • @RaviKumar-je2np
    @RaviKumar-je2np 11 หลายเดือนก่อน

    Can i call course completion Date to Storyline so that i can display the same in the Certificate..

    • @LearningDojo
      @LearningDojo  11 หลายเดือนก่อน

      Completion is recorded but pulling the date may require the LMS API. Not sure would have to do some digging.

  • @billhaf
    @billhaf ปีที่แล้ว

    Good video! I would like to pull up the month as text though. How would I do that?

    • @LearningDojo
      @LearningDojo  ปีที่แล้ว

      So basically you would just pass in the "month" variable as the variable in Storyline. That way it just gives you the number of the month and then display that on a page. Does that help?

  • @radiusvsl457
    @radiusvsl457 หลายเดือนก่อน

    Can we add no. Of time visited in this code

    • @LearningDojo
      @LearningDojo  หลายเดือนก่อน

      Like how many times a user comes back to the course? Is the house in an LMS?

  • @RaviKumar-je2np
    @RaviKumar-je2np 11 หลายเดือนก่อน

    Hi... Jeff... Can you please give me this links of this page of ur web page.. So that u can copy code..

    • @LearningDojo
      @LearningDojo  11 หลายเดือนก่อน

      It is here learningdojo.ninja/blog/pull_date_into_storyline.html

  • @isabellelemarchal
    @isabellelemarchal 10 หลายเดือนก่อน

    Many thanks !

    • @LearningDojo
      @LearningDojo  10 หลายเดือนก่อน

      You are welcome!