Skip to main content
sishamIAGD
Community Expert
Community Expert
February 19, 2018
Answered

Is it possible to do something in a pdf so it could ‘score’ itself and provide output text on the basis of the responses?

  • February 19, 2018
  • 2 replies
  • 1343 views

I suppose almost like a survey kind of process..?

You have multiple options to select, say a score from 1-7 via a checkbox for about 15 questions (maybe over a couple of pages) and depending on what you select it displays an answer at the end once completed.

I hope this makes sense and any suggestions help would be great.

Thanks.

This topic has been closed for replies.
Correct answer try67

OK, then you can use something like this as the custom calculation script of the field where you want to show the result.

Of course, you can adjust the field names, texts and scores to match your needs...

var score = 0;

for (var i=1; i<=15; i++) {

    var f = this.getField("Q"+i);

    if (f.valueAsString!="Off") score+=Number(f.valueAsString);

}

if (score==0) event.value = "";

else if (score<10) event.value = "Your score is: " + score + ". That's pretty bad.";

else if (score<20) event.value = "Your score is: " + score + ". That's bad.";

else if (score<40) event.value = "Your score is: " + score + ". That's OK.";

else if (score<60) event.value = "Your score is: " + score + ". That's good!";

else event.value = "Your score is: " + score + ". That's great!";

2 replies

try67
Community Expert
Community Expert
March 6, 2018

So do you have 15 groups of check-box fields, with export values of 1-7, and you want to display some text based on the total score?

sishamIAGD
Community Expert
Community Expert
March 6, 2018

Yes that's the kind of thing I'm looking to do..?

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 6, 2018

OK, then you can use something like this as the custom calculation script of the field where you want to show the result.

Of course, you can adjust the field names, texts and scores to match your needs...

var score = 0;

for (var i=1; i<=15; i++) {

    var f = this.getField("Q"+i);

    if (f.valueAsString!="Off") score+=Number(f.valueAsString);

}

if (score==0) event.value = "";

else if (score<10) event.value = "Your score is: " + score + ". That's pretty bad.";

else if (score<20) event.value = "Your score is: " + score + ". That's bad.";

else if (score<40) event.value = "Your score is: " + score + ". That's OK.";

else if (score<60) event.value = "Your score is: " + score + ". That's good!";

else event.value = "Your score is: " + score + ". That's great!";

Inspiring
February 19, 2018

Yes, that's certainly possible. You could use a custom JavaScript in the final score field that gets the value of each input field and calculates the result. If you just want a simple sum, you may be able to use the built-in Sum calculation.

sishamIAGD
Community Expert
Community Expert
February 20, 2018

Thanks for getting back to me.

Do you know where I could find the resources/tutorials to be able to do this? Or even a step by step guide?

Thanks

Inspiring
February 20, 2018

A retired Math professor D.P. Story has started a company AcroTeX that has a product that can create exams. He provides many examples for simple math to calculus.