January 28, 2019
Calculate Expiry Date (Expression, variables)
Comments
(2)
January 28, 2019
Calculate Expiry Date (Expression, variables)
Lieve is a civil engineer (ir) and a professional musician. After years of teaching and research (project management/eLearning/instability) she is now a freelancer specializing in advanced Adobe Captivate as trainer and consultant. Her blog is popular with Captivate users worldwide. As an Adobe Community Expert and Adobe Education Leader, she has presented both online and offline. Since 2015 she is moderator on the Adobe forums and was named as Forum Legend (special category) in the Wall of Fame. In 2017 Adobe Captivate users voted for Lieve as a Top Content Experience Strategist.
Legend 245 posts
Followers: 410 people
(2)

Why?

Today a user asked for help with coding to get an expiry date for a certificate slide,  see thread

It is a nice use case for the use of both system and user variables, and the use of the mysterious Expression command which is only available in the Advanced Actions dialog box (not as simple action in the Actions tab of the Properties panel). If  you are totally new to the use of variables, here are some links:

Using System Variables – part 1

Using System Variables – part 2

User Variables – Intro

Workflow described here step-by-step will show how to get the expiry date, 3 years from the present date can be calculated and stored in a user variable. It can of course also be done with JS, but I kept to one advanced action. Since I live in Belgium, I used the date format ‘day/month/year’. It is rather easy to change this to another sequence like the one used by ISO or in the USA.  Maybe I’ll post an interactive output, where you can choose the sequence of the 3 parameters. It is also possible to go for another way of presenting the date, but that is not treated here. Insertion in the Learning Interaction  ‘Certificate’ is not included neither.

Workflow

1. Variables

You will be using these system variables, all from the category System information:

  • cpInfoCurrentYear: its value is a 4-digit number, at this moment 2019
  • cpInfoCurrentMonth: its value is a 2-digit number, still January at this moment, will be 01
  • cpInfoCurrentDate: its value is a 2-digit number, for me at this moment it will be 29; it may seem bit confusing that I don’t use cpInfoCurrentDay, but that gives a 1-digit number for the sequence in the week. Monday will result in 2 if t Sunday is considered to be the first day of the week in your OS settings.

You need two user variables (how to create them, see third link in the Introduction ‘Why?’)

  • v_year: will be used to calculate the expiry year, which would be 2022 for this user (3 years from now).
  • v_date: will have the full date of expiration after the calculations explained later.

The third variable v_choice has been used to offer a choice between the sequence for the date numbers. That is not part of this workflow.

2. Advanced action – creation

You need to create this advanced action, which is non-conditional I will explain each command:

  1. First Expression calculates the expiry year from the present year (cpInfoCurrentYear) and stores it in the user variable v_year. This is possible since the system variable can be seen by Captivate as a number, and using the mathematical operator +. Result will be of course 2022.
  2. The mathematical operator becomes here a ‘concatenation’ operator: it will add the string “/” to the day number. Do not forget the quote marks, because / is a mathematical operator. Result after this expression is the text:    29/   which will be stored in v_date
  3. Another concatenation replaces the value in v_date  by 29/01   
  4. Third concatenation results in v_date = 29/01/
  5. Last expression gives the final result v_date = 29/01/2019

The need for 4 expressions to get to the final value for v_date is due to the fact that the Expression command can have only one operator. You can use the Copy/Paste functionality in the Advanced Actions dialog box to speed up the process.

3. Assign action to Slide On Enter event

Attach the Advanced Action to the On Enter event of the slide, where you need to insert the variable v_date.

How you can insert a variable has been explained in the very first link I posted under ‘Why’.

Challenges!

  • Change the Advanced action to present the date in another sequence, like ‘Year/Month/Day’. If you are on CP2017 or later, maybe this blog could help.
  • For the fans of conditional actions: try to create a version where the learner can choose the sequence. You’ll need probably another user variable in that case and a multiple decision conditional action.
  • Which dangers exist for ‘cheating’ (I am a former professor) in the use case as described here? How would you cope with those dangers?
2 Comments
2019-08-06 19:33:26
2019-08-06 19:33:26

Thanks!  Since I don’t believe in the value of certificates, but know how students can be very inventive when they want to cheat….was smiling. Good idea!

Like
(2)
2019-08-06 17:52:37
2019-08-06 17:52:37

Hello Lieve,

Nice tutorial…

I was able to embed QR code into the certificate, with the user name, date and score.

That take care of the cheating, you can duplicate the certificate but not the QR code.

Keep up the wonderful work.

Luis

 

Like
(2)
Add Comment