Forum Discussion
User notes that they can print and email
I know this is an old thread, but hoping there are still some followers...
I modified Stephanie's Javascript for a course I'm developing in which I want to compile several variable values into an email at the end of the module. Most are text variables, which seem to be working fine, but I'd also like to include the learner's score on the assessment in the module (using the system variable Results.ScorePoints). No matter what the actual score is, when I compile the JavaScript email at the end of the course, it says "null" where that point value should be.
This is my first attempt at doing anything with JavaScript so I'm just guessing here, but maybe it's because it's a numeric variable rather than text? Is there a way to convert numeric variables to string in the JavaScript that someone would be able to show me?
Below is the JavaScript code I'm using, followed by the text of the email it compiles:
var player = GetPlayer();
var useremail=player.GetVar("UserEmail");
var username=player.GetVar("UserName");
var usernamepledge=player.GetVar("UserNamePledge");
var subject="Module 1 Portfolio Notes";
var exercisenotes1=player.GetVar("Reasons");
var exercisenotes2=player.GetVar("FirstMgtDescrpt");
var mgmtscore=player.GetVar("Results.ScorePoints");
var mgmtdescrpt=player.GetVar("MgmtDescrpt");
var systemdate=player.GetVar("SystemDate");
var mailto_link='mailto:'+'hello@graciagoldberg.com'+'?subject='+subject+'&body='+"Module 1 Portfolio Notes for:"+username+"("+useremail+")%0d%0A%0d%0AReflection 1 - Top Reasons For Going into Business:%0d%0A%0d%0A"+exercisenotes1+"%0d%0A%0d%0AReflection 2 - The Role of Manager in My Organization:%0d%0A%0d%0A"+exercisenotes2+"%0d%0A%0d%0AManagement Inventory Assessment Score:"+mgmtscore+"%0d%0AWhat your score means:"+mgmtdescrpt+"%0d%0A%0d%0A"+usernamepledge+" signed the Course Commitment Pledge on"+systemdate;
win=window.open(mailto_link,'emailWin');
Here is the email currently being created (variable values are in bold):
Module 1 Portfolio Notes for:Gracia(hello@graciagoldberg.com)
Reflection 1 - Top Reasons For Going into Business:
example text 1
Reflection 2 - The Role of Manager in My Organization:
example text 2
Management Inventory Assessment Score:null
What your score means:You may be foundationally strong in most areas, but the areas in which you are weak may prove to be fatal. A score in this range means that there are several areas that pose a threat to the well-being of the business. Focus on becoming a better manager than is called for.
Gracia signed the Course Commitment Pledge on8/10/2018
I also can't seem to get it to include spaces in there if you noticed... I tried using " " and it seemed to break everything...
- OwenHolt8 years agoSuper Hero
StoryLine protects the score variables to protect them from direct manipulation. Try adding an additional variable in StoryLine and setting its value equal to the Results.ScorePoints variable prior to executing the JavaScript. Then pull in that variable's value. There is no need to convert from numeric value to text.
Related Content
- 9 months ago
- 7 months ago
- 8 months ago
- 9 months ago
- 12 months ago