I have a course with manual scoring using a variable. The total possible score is 150,000 points. I have placed the Reference %score% on each page, but the numbers display without commas. This means that a perfect score shows as 150000. This makes it hard to read.
I recently encountered a similar challenge and you are right, the commas are not automatic. I found a workaround and thought I would share it with you.
I followed your instructions and this worked beautifully on a regular slide. I tried to copy and paste to the next slide and the triggers did not come along with the commas, so that means that I would have to manually create all 5 triggers (the score goes over 100,000) on every slide, which is too time consuming if I want to meet my deadline. I tried to do the same thing on the master slide, but it does not work for some reason. Any ideas why not?
Have you guys tried just right-justifying the score variable so that the commas should always stay in the same places once the score goes over 1,000 and 1,000,000? I haven't tried this in practice but, in theory, it seems to me like that should work. Then you can still use Montse's workaround (which is excellent, by the way!) but it shouldn't require so many triggers to make it work. Of course, this is also presuming that right-justification works for your particular layout...
Montse's solution is awesome and Mel, I gave your right-alignment suggestion a try and it's equally awesome. That way, there's no need to insert more than one comma, thus eliminating extra triggers.
Jill, I was able to get this to work in the Master, but of course I don't know what exactly is going on in your story that may be preventing it.
The following javascript code could do the job too:
Create a variable "value" of type number create a value "stringvalue" of type text
create a trigger: when variable "value" changes -> execute javascript
add this javascript code:
var player = GetPlayer(); var res= player.GetVar("value"); res= res.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); player.SetVar("stringvalue", res);
stringvalue is now formatted text with commas
That's really neat, Johanna! I have a basic understanding of HTML and CSS but I'm not a programmer and I've never really used javascript before so I don't fully understand its capabilities or how to write it. It does open up a whole new realm of what you can do, though! I will have to look and see what resources are available, both on Articulate's website and elsewhere online, to see if there are simple pieces of code that we "non-programmers" can use to fix our dilemmas in Storyline! Do you have any suggestions for that?
It does open up a whole new realm of what you can do, though! I will have to look and see what resources are available, both on Articulate's website and elsewhere online, to see if there are simple pieces of code that we "non-programmers" can use to fix our dilemmas in Storyline! Do you have any suggestions for that?
In this vein, I would love to have a small (?) library of Javascript code available with explanations, demo, and code that us "non-programmers" could refer to and use. Almost like a community plug-in library.
One thing to keep in mind when using JavaScript in Storyline is that JavaScript does not work with the Articulate Mobile player on the iPad so if you are planning to use this format, I would steer clear of JavaScript for now.
16 Replies
Hey Jill!
Unless I'm overseeing something also, I think that might need to be logged as a feature request. Thanks!
Hey Jill,
I recently encountered a similar challenge and you are right, the commas are not automatic. I found a workaround and thought I would share it with you.
Let me know if you have any questions!
That's awesome, Montse!
Bookmarking!
Thanks so much Montse! I will definitely give that a try!
This is great. I was struggling with this same issue a while ago and never did come up with a solution.
Thanks Montse, 3 observations:
1> Awesome solution...
2> Numerical formatting should not really require a kludge, no matter how awesome! I have posted a New Feature Request.
3> Cupcake ipsum! Even more awesome that the patent Anderson comma kludge
Bruce
Hi Montse,
I followed your instructions and this worked beautifully on a regular slide. I tried to copy and paste to the next slide and the triggers did not come along with the commas, so that means that I would have to manually create all 5 triggers (the score goes over 100,000) on every slide, which is too time consuming if I want to meet my deadline. I tried to do the same thing on the master slide, but it does not work for some reason. Any ideas why not?
Have you guys tried just right-justifying the score variable so that the commas should always stay in the same places once the score goes over 1,000 and 1,000,000? I haven't tried this in practice but, in theory, it seems to me like that should work. Then you can still use Montse's workaround (which is excellent, by the way!) but it shouldn't require so many triggers to make it work. Of course, this is also presuming that right-justification works for your particular layout...
Montse's solution is awesome and Mel, I gave your right-alignment suggestion a try and it's equally awesome. That way, there's no need to insert more than one comma, thus eliminating extra triggers.
Jill, I was able to get this to work in the Master, but of course I don't know what exactly is going on in your story that may be preventing it.
The following javascript code could do the job too:
Create a variable "value" of type number
create a value "stringvalue" of type text
create a trigger: when variable "value" changes -> execute javascript
add this javascript code:
var player = GetPlayer();
var res= player.GetVar("value");
res= res.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
player.SetVar("stringvalue", res);
stringvalue is now formatted text with commas
Hope this helps
That's really neat, Johanna! I have a basic understanding of HTML and CSS but I'm not a programmer and I've never really used javascript before so I don't fully understand its capabilities or how to write it. It does open up a whole new realm of what you can do, though! I will have to look and see what resources are available, both on Articulate's website and elsewhere online, to see if there are simple pieces of code that we "non-programmers" can use to fix our dilemmas in Storyline! Do you have any suggestions for that?
Bruce
I second that motion, Bruce!
Hi,
sorry, needed some days to answer, currently, there's a lot to do.
Here is the official info for javascript @ articulate Website
http://www.articulate.com/support/kb_article.php?product=st1&id=llwes8cn32vg
I don't have special ressources to look at, I'm just searching the web all the time
A javascript library would be great, if there's a good place to share, just tell me :)
Johanna
Hi, if any of you are interested in learning more about JavaScript, there is a really great website that you can use to learn the basics.
http://www.codecademy.com/#!/exercises/0
One thing to keep in mind when using JavaScript in Storyline is that JavaScript does not work with the Articulate Mobile player on the iPad so if you are planning to use this format, I would steer clear of JavaScript for now.
Thanks, Nancy. Another item to add to the list. In the meantime:
I'd like to 3rd Bruce's motion.
This discussion is closed. You can start a new discussion or contact Articulate Support.