let's say I have 10 different text variables in my project (Q1, Q2, Q3, etc). I would like to obtain a single text variable out of them (result="Q1+Q2+Q3+, etc"). Is that possible? maybe with javascript? does anyone can help me with the code?
I'm far from expert in Javascript, but this approach does work. Below, variables Q1, Q2, Q3, and Q4 are text variables in Storyline. Their values are put into new Javascript variables, and in the last line of the Javascript, those are being concatanated with spaces between them and placed into the variable Totals, which is another Storyline text variable in this example.
var player = GetPlayer();
var jsQ1 = player.GetVar("Q1"); var jsQ2 = player.GetVar("Q2"); var jsQ3 = player.GetVar("Q3"); var jsQ4 = player.GetVar("Q4");
Let me explain what I'm doing. The purpose is to send to LMS a text variable (called "result1") using a hidden survey question in order to track quiz results. My need is to be able to know in a 10 questions quiz, to which question the student answered right or wrong. Also, since the test has 60 seconds time limit, I need to know to which question the student didn't answered.
This is what I did. When the scorm starts I set 10 text variables in this way:
Q_1= "TC1x", Q_2="TC2x", Q_3="TC3x".... and so on... (the x after the number stands for "not answered yet")
I also create another text variable called "Result1" and set it "AAAAAAAAAA" as default value.
When the person answer the first question, variable Q_1 will change from value "TC1x" to "TC1y" in case the student got that right, or "TC1n" in case of wrong answer. The same process will go for the other nine questions. If the student can't answer to some questions because of the time, the value will remain "x" (for instance "TC9x", "TC10x" if he couldn't answer to the last two questions)
I would like that "result1" will have inside the results of those ten questions that the student answered before. As I said, the result of those questions are the text variables from Q_1 to Q_10. The main purpose is to make the LMS to read this "result1" variable and build a report according to its content.
This is what I did according to what you wrote:
var player = GetPlayer(); var jsQ1 = player.GetVar("Q_1"); var jsQ2 = player.GetVar("Q_2"); var jsQ3 = player.GetVar("Q_3"); var jsQ4 = player.GetVar("Q_4"); var jsQ5 = player.GetVar("Q_5"); var jsQ2 = player.GetVar("Q_6"); var jsQ3 = player.GetVar("Q_7"); var jsQ4 = player.GetVar("Q_8"); var jsQ1 = player.GetVar("Q_9"); var jsQ2 = player.GetVar("Q_10");
So, my goal is to obtain from "Result1" something like : "TC1n TC2y TC3n TC4n TC5y TC6y TC7y TC8x TC9x TC10x"...... which can be transformed in a report that says which one was wrong, right, or not answered.
But... is not working. In the last slide, after the JS, I have a text box with "Result1" in, that stays on the AAAAAAAAAA value that I set as default at the beginning... What am I doing wrong?
Thank you very much and sorry for my really poor english... I'm italian and I have learned it from The Simpsons...
Any reason why you don't use the built in question types as this should handle all of this. Are you using a text entry for the final as it should really be a number entry
Sorry Phil... I don't get it. I'm using built in question types. But as far as I know (and probably I'm totally wrong) articulate passes to the LMS only if you pass a quiz or not and the percentage. What I need is to track which answer were right or wrong.. If there's another way please let me know.
Most LMS will get the data on which questions were marked correct or incorrect, a score is not sent but a percentage is sent, you could send the result.scorepoints variable to the LMS using a hidden number survey question and set each question to 1 point which willl give you a total
What Phil says is absolutely true, in terms of the LMS's ability to collect data.
To the narrower question about the Javascript, there were a few small errors, and it is very picky. (You had a couple of extra parentheses characters, and while you had created Javascript variables jsQ1, jsQ2, etc., the script was trying to use js_Q1, js_Q2, etc.
I was able to get it to work with the Javascript below.
var player = GetPlayer(); var jsQ1 = player.GetVar("Q_1"); var jsQ2 = player.GetVar("Q_2"); var jsQ3 = player.GetVar("Q_3"); var jsQ4 = player.GetVar("Q_4"); var jsQ5 = player.GetVar("Q_5"); var jsQ6 = player.GetVar("Q_6"); var jsQ7 = player.GetVar("Q_7"); var jsQ8 = player.GetVar("Q_8"); var jsQ9 = player.GetVar("Q_9"); var jsQ10 = player.GetVar("Q_10");
Now I have understand what Phil meant (thanks again Phil). I have some knowledge about how to use the software but I don't know the basic mechanisms behind it. I have talked with our programmer, I "kindly" forced him to have a look to the issue and he's going to work on it. (He said something like "yes, yes... no problem, but now I'm busy"...eh eh eh)
But, still, for personal knowledge and understanding, I would like to solve the variable sum issue. I know I am going to need it anyways.
So, I've tried your last js, checking again variable names, but still doesn't work. After last question I have a slide which execute the js. Then, I have a result slide where I have inserted two text boxes with the variables values. As you can see from attached screenshot, even though Q_1, Q_2, etc. show the correct values (y or n), Result1 is still set as default (AAAAAAAAAAAAA). I don't understand what I'm doing wrong. It should show Result 1= y y y n n y n y y y
I'm pretty sure I'm not seeing some obvious mistake
12 Replies
Hi Francesco,
I'm far from expert in Javascript, but this approach does work. Below, variables Q1, Q2, Q3, and Q4 are text variables in Storyline. Their values are put into new Javascript variables, and in the last line of the Javascript, those are being concatanated with spaces between them and placed into the variable Totals, which is another Storyline text variable in this example.
var player = GetPlayer();
var jsQ1 = player.GetVar("Q1");
var jsQ2 = player.GetVar("Q2");
var jsQ3 = player.GetVar("Q3");
var jsQ4 = player.GetVar("Q4");
player.SetVar("Totals", jsQ1+" "+jsQ2+" "+jsQ3+" "+jsQ4)
David,
first of all thank you.
Let me explain what I'm doing. The purpose is to send to LMS a text variable (called "result1") using a hidden survey question in order to track quiz results. My need is to be able to know in a 10 questions quiz, to which question the student answered right or wrong. Also, since the test has 60 seconds time limit, I need to know to which question the student didn't answered.
This is what I did. When the scorm starts I set 10 text variables in this way:
Q_1= "TC1x", Q_2="TC2x", Q_3="TC3x".... and so on... (the x after the number stands for "not answered yet")
I also create another text variable called "Result1" and set it "AAAAAAAAAA" as default value.
When the person answer the first question, variable Q_1 will change from value "TC1x" to "TC1y" in case the student got that right, or "TC1n" in case of wrong answer. The same process will go for the other nine questions. If the student can't answer to some questions because of the time, the value will remain "x" (for instance "TC9x", "TC10x" if he couldn't answer to the last two questions)
I would like that "result1" will have inside the results of those ten questions that the student answered before. As I said, the result of those questions are the text variables from Q_1 to Q_10. The main purpose is to make the LMS to read this "result1" variable and build a report according to its content.
This is what I did according to what you wrote:
var player = GetPlayer();
var jsQ1 = player.GetVar("Q_1");
var jsQ2 = player.GetVar("Q_2");
var jsQ3 = player.GetVar("Q_3");
var jsQ4 = player.GetVar("Q_4");
var jsQ5 = player.GetVar("Q_5");
var jsQ2 = player.GetVar("Q_6");
var jsQ3 = player.GetVar("Q_7");
var jsQ4 = player.GetVar("Q_8");
var jsQ1 = player.GetVar("Q_9");
var jsQ2 = player.GetVar("Q_10");
player.SetVar("Result1", jsQ_1+" "+jsQ_2+" "+jsQ_3+" "+jsQ_4)+" "+jsQ_5+" "+jsQ_6+" "+jsQ_7)+" "+jsQ_8+" "+jsQ_9+" "+jsQ_10)
So, my goal is to obtain from "Result1" something like : "TC1n TC2y TC3n TC4n TC5y TC6y TC7y TC8x TC9x TC10x"...... which can be transformed in a report that says which one was wrong, right, or not answered.
But... is not working. In the last slide, after the JS, I have a text box with "Result1" in, that stays on the AAAAAAAAAA value that I set as default at the beginning... What am I doing wrong?
Thank you very much and sorry for my really poor english... I'm italian and I have learned it from The Simpsons...
Any reason why you don't use the built in question types as this should handle all of this. Are you using a text entry for the final as it should really be a number entry
Sorry Phil... I don't get it. I'm using built in question types. But as far as I know (and probably I'm totally wrong) articulate passes to the LMS only if you pass a quiz or not and the percentage. What I need is to track which answer were right or wrong.. If there's another way please let me know.
Most LMS will get the data on which questions were marked correct or incorrect, a score is not sent but a percentage is sent, you could send the result.scorepoints variable to the LMS using a hidden number survey question and set each question to 1 point which willl give you a total
Phil... I think I got it... and I'm getting depressed...
By the way... thank you very much... even though I would have like to solve also the javascript thing I published before.
Hi Francesco,
What Phil says is absolutely true, in terms of the LMS's ability to collect data.
To the narrower question about the Javascript, there were a few small errors, and it is very picky. (You had a couple of extra parentheses characters, and while you had created Javascript variables jsQ1, jsQ2, etc., the script was trying to use js_Q1, js_Q2, etc.
I was able to get it to work with the Javascript below.
var player = GetPlayer();
var jsQ1 = player.GetVar("Q_1");
var jsQ2 = player.GetVar("Q_2");
var jsQ3 = player.GetVar("Q_3");
var jsQ4 = player.GetVar("Q_4");
var jsQ5 = player.GetVar("Q_5");
var jsQ6 = player.GetVar("Q_6");
var jsQ7 = player.GetVar("Q_7");
var jsQ8 = player.GetVar("Q_8");
var jsQ9 = player.GetVar("Q_9");
var jsQ10 = player.GetVar("Q_10");
player.SetVar("Result1",jsQ1+" "+jsQ2+" "+jsQ3+" "+jsQ4+" "+jsQ5+" "+jsQ6+" "+jsQ7+" "+jsQ8+" "+jsQ9+" "+jsQ10)
Hi David, thank you for reply.
Now I have understand what Phil meant (thanks again Phil). I have some knowledge about how to use the software but I don't know the basic mechanisms behind it. I have talked with our programmer, I "kindly" forced him to have a look to the issue and he's going to work on it. (He said something like "yes, yes... no problem, but now I'm busy"...eh eh eh)
But, still, for personal knowledge and understanding, I would like to solve the variable sum issue. I know I am going to need it anyways.
So, I've tried your last js, checking again variable names, but still doesn't work. After last question I have a slide which execute the js. Then, I have a result slide where I have inserted two text boxes with the variables values. As you can see from attached screenshot, even though Q_1, Q_2, etc. show the correct values (y or n), Result1 is still set as default (AAAAAAAAAAAAA). I don't understand what I'm doing wrong. It should show Result 1= y y y n n y n y y y
I'm pretty sure I'm not seeing some obvious mistake
Thank you again
Hi Francesco,
Could you share your Storyline file? From what you say, I don't see a reason why it would not be working.
I'm attaching mine, using the same variables, and it works as expected.
https://360.articulate.com/review/content/4af2e08a-0585-4e6d-b597-a2f42ea82b17/review
David...
in italian we can say that I have what we call "capa tosta", which means something like stubborn.
So, I did the all thing again, new slides, new variables, new javascript and... It works perfectly....
Thanks again
Francesco,
I'm glad you got it working!
Buona sera,
David