Forum Discussion
Storyline 2 Example - Generating a PDF Certificate for users who successfully complete a quiz
Hi Ryan,
I know this is an old post but thought I might give it a try anyway. Your code is working great on my end. Good job!
I have a few variables in my course (True/False). Based on user choice these variables represents certain parts of the course that have been done/not done. I would like the done parts to show up in the certificate.
I have a variable named CameraControlDone. I get this from the player as demonstrated in your javascript
// Retrieve the status camera control variable
var cameracontrol = player.GetVar("CameraControlDone");
According to my limited javascript skills the following should display the camera control text if CameraControlDone is set to true (code placed in content section).
// Include Camera control
if (cameracontrol = true) {
text: "Camera control",
fontSize: 16,
alignment: 'center',
margin: [0, 0, 0, 0]
},
However clicking the Download button doesn't do anything. It works without this code though. Any ideas?
Best regards
Michael
Hi Michael,
If you replace this:
// Include Camera control
if (cameracontrol = true) {
text: "Camera control",
fontSize: 16,
alignment: 'center',
margin: [0, 0, 0, 0]
},
with this:
// Include Camera control
(function () {if (cameracontrol) {return {text:'Camera Control', fontSize: 16, alignment: 'center', margin: [0, 0, 0, 0]}} else { return null; }})(),
It should work as desired.
Cheers,
Ryan
- DiarmaidCollins6 years agoCommunity Member
Hi Ryan. This PDFMake thing is simply amazing. A really clever solution.
I just had a couple of quick questions if you had the time to respond?
You mention the following code (which works perfectly) as a solution to Michael's problem above:
// Include Camera control
(function () {if (cameracontrol) {return {text:'Camera Control', fontSize: 16, alignment: 'center', margin: [0, 0, 0, 0]}} else { return null; }})(),There's no declaration there that the variable
cameracontrol
has to be TRUE in order to display the text - is it just assumed TRUE equals display text and FALSE equals ignore text?What if one wanted two or more items to be visible/hidden dependant on the one variable?
Currently, I have two duplicates of that above code displaying two lines, themselves two variables,
List_A_Option_01_TITLE
andList_A_Option_01_INFO
. The visibility of both TITLE and INFO is dependent onList_A_Option_01
being TRUE.(function () {if (List_A_Option_01) {return {text: List_A_Option_01_TITLE, style: "title"}} else { return null; }})(),
(function () {if (List_A_Option_01) {return {text: List_A_Option_01_INFO, style: "info"}} else { return null; }})(),How does one combine these two functions into one?
Also (apologies), and this what wrecks my head testing out variations of the Certificate Template you have supplied, I have managed to get the cert to work in previous projects by naming the
html
file to whatever, say, certificate.html, but now, with this project, I rename my file to ChecklistCOMPILE.html and when I try to import the webobject it says there is no index file and I cannot get it to work?What stupid thing am I doing stupidly?