Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to to create a score display

Participant ,
Aug 12, 2021 Aug 12, 2021

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.!!

TOPICS
Create PDFs, How to, PDF forms

Views

32

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 12, 2021 Aug 12, 2021

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?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 12, 2021 Aug 12, 2021

Copy link to clipboard

Copied

I´m using Text Fields. The names of the fields follow the standard "TextXX". I´m not renaming them.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 12, 2021 Aug 12, 2021

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).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 12, 2021 Aug 12, 2021

Copy link to clipboard

Copied

LATEST

Thank you very much!! I will test this script and make the necessary adjustments. Have a nice day!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines