Copy link to clipboard
Copied
Hello everyone!
I want to create a scoreboard above a page, to add a point every time (and only when) the student gets one answer correct. In case the answer is wrong, no value will be added to the score. I know the math logic behind the scoreboard, but I need some tips about which commands I need to use in Adobe Javascript, in order to bring this to reality.
Would appreciate to receive your tips and comments.
Thank you very much in advance.!!
Copy link to clipboard
Copied
What kind of fields do you use for the answers (text, radio-button, drop-down, something else)? What are the names of these fields?
Copy link to clipboard
Copied
I´m using Text Fields. The names of the fields follow the standard "TextXX". I´m not renaming them.
Copy link to clipboard
Copied
OK... Then you can use something like this as the custom calculation script of the score field:
var score = 0;
if (this.getField("Text1").valueAsString == "A") score++;
if (this.getField("Text2").valueAsString == "B") score++;
if (this.getField("Text3").valueAsString == "5") score++;
if (this.getField("Text4").valueAsString == "Apple") score++;
event.value = score;
Of course, you'll need to adjust the field names as well as the correct answer for each question.
Be aware that JS is case-sensitive, though, so if the student enters "apple" it won't match "Apple".
Also, "an Apple" won't match it, or even "Apple " (with a space after it). It has to be a perfect match (although there are ways around it, like using regular-expressions).
Copy link to clipboard
Copied
Thank you very much!! I will test this script and make the necessary adjustments. Have a nice day!