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

Nesa Nurani
Community Expert
Community Expert
September 24, 2022

Yes, script goes to 'Custom calculation script'.

Try this:

 

var fields = ["Field4","Field5","Field7","Field8"];
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;}
var f1= Number(this.getField("Field1").valueAsString);
var f2= Number(this.getField("Field2").valueAsString);
var f3= Number(this.getField("Field3").valueAsString);
var f4= Number(this.getField("Field6").valueAsString);
var f5= Number(this.getField("Field9").valueAsString);
var f6= Number(this.getField("Field10").valueAsString);
var pos = f1+f2+f3+f4+f5+f6;
event.value = total+pos;