Skip to main content
Motivationeer
Participating Frequently
September 24, 2022
Question

I want a formula to create reverse score for someone's entry when taking an assessment

  • September 24, 2022
  • 1 reply
  • 14498 views

I am creating an assessment with 10 questions where a person will have to choose a score between 0 and 4 for each question. This is a standard Likert scale of 0=never, 1=almost never, 2=sometimes, 3=faily often, 4=very often.

The assessment, however, has some questions that are "positive" questions and some that are "negative" questions. For example, "how often have you felt nervous and stressed" is a negative question while "how often have you felt confident" is a positve question. 

Then, when I tally the results within the form, I want to reverse their scores for every positve question such that:

- if they entered 0, what gets calculated in the total is a 4

- if they entered 1, what gets calculated in the total is a 3

- if they entered 2, what gets calculated in the total is still a 2

- if they entered 3, what gets calculated in the total is a 1

- if they entered 4, what gets calculated in the total is a 0

I don't know how to write java script so I'm hoping someone can just give me the actual string of text so I can copy it and paste it into my Adobe form creator.

And I assume this will go into the Custom Calculation Script of the calculate tab in the Text Field Properties.

Thaksn for any help.

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
September 24, 2022

You could use something like this to reverse score:

Change "Field1","Field2","Field3" (add more fields names as needed) with fields names of which you want to reverse score.

var fields = ["Field1","Field2","Field3"];
var total = 0;
for(var i in fields){
var f = this.getField(fields[i]).valueAsString;
if(f==="0")total+=4;
if(f==="1")total+=3;
if(f==="2")total+=2;
if(f==="3")total+=1;}

Now you can use variable 'total' in calculation with rest of the fields.

Motivationeer
Participating Frequently
September 24, 2022

Thank you for your quick reply. This is helpful but I think there may be something missing.

I have 10 questions, each will have a score from 0 to 4. Of those 10 questions, four of them will be reversed when I do a final tally calculation.

So, in the TOTAL field, I want to add Field1 + Field2 + Field3 + Reverse Field4 + Reverse Field 5 + Field 6 + Reverse Field7 + Reverse Field8 + Field9 + Field10.

using your formula above, how will I write this out?

(And will the code be placed into the "Custom Calculation Script" field of the calculate tab?)

try67
Community Expert
Community Expert
September 24, 2022

Okay, I just tested it and confirmed that it is not working. 

I copied and pasted your commands string into the TOTAL field Custom Caluculation Script.

When I save teh file and then use it as a PDF Form, entering in values for all 10 fields, the TOTAL box remains empty. No addition happens. 

Attached is a screen shot.

 


Check the JS Console (Ctrl+J) for errors. If you can't figure it out, share the file with us, please.