• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

294

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
Community Expert ,
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?

Votes

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.

Votes

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
Community Expert ,
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).

Votes

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!

Votes

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