• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Variables not keeping decimal places when relaunching course

New Here ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Hello,

When the user clicks on a button, it simply assigns a variable that I've created with 2.5.
It works fine. But when the user exits the course and then reenters (on moodle), the variable just shows 2. I'm using Captivate 11 (2019).
Any idea why this is happening?
Thank you

Views

155

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

To format a number correctly, you'll need to use JS.

Have a look at this blog post, at the end you'll see the JS function which I used to have the correct number of decimals. Captivate has no way to achieve this directly:

https://blog.lilybiri.com/percentage-progress-indicator-non-linear-course-solution-1

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Hello Lilybiri,
Thank you for your response.
I tried your solution. However, it still doesn't work - when reentering the course, the variable only shows 2.
Any thoughts?

Elearning321290924m75_0-1711373651113.png

The javascript I put:

var v01js = window.cpAPIInterface.getVariableValue(“v01”); window.cpAPIInterface.setVariableValue(“v01”,v01js.toFixed(2));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Hmmm...

Which event do you use to trigger this advanced action?

Which exact version of Captivate do you use? In all versions before version 12 the variables have no real type, they can be used for both strings, numbers, T/F.... etc.  Did you give that variable a default value to start with? How do you display it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Since I'm testing this issue, I have just one slide with one button and a shape to display the variable value (as shown in the image I've sent). I'm adding the advanced action to the button. The default value for the variable is zero.
When the user clicks on the button it shows the correct value - 2.55. But when he exits and reenters the course, the value is now 2.
I'm using Captivate 11 (2019) - 11.5.5.553

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

You are using the most stable version of Captivate ever.

It is the first time you show now that the value is negative, which is another issue for Captivate, due to the lack of variable types.

Those types exist in the new version, but it causes also issues.

If I understand correctly this is about a user variable.  Such a variable is reset when you start a new version, its value is not retrieved from the previous version. It starts to be confusing. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

No, it's not negative. I wrote "it shows the correct value - 2.55" but I should have written "it shows the correct value of 2.55".

Yes, it's a user variable. You said the variable is reset when starting a new version but in that case it should show the number zero (default value) and not the number 2.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

I think there is some misunderstanding. 

Do you view the variable when you enter the course; before clicking the button which triggers that advanced action with the Assign and the JS? That was the reason for my 'display' question in a previous comment.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

Elearning321290924m75_1-1711444648733.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

LATEST

This is really weird... I wonder what is going awry.  It is possible to keep the value of a variable using cookies, but I don't think you are using that workflow. Is it possible to access the course for the second session from another system? 

What happens when you apply the JS command to the On Enter action of this slide? That would mean that the original value 0 would also show with two decimals.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources