Skip to main content
Participating Frequently
April 6, 2021
Answered

How to add a rating scale with different weights

  • April 6, 2021
  • 2 replies
  • 7127 views

Hi I am looking on how to add rating scales with different weights to calculate a final score. 

 

I am trying to create fillable PDFs for people to complete performance evaluations on when they can't access our online system. 

 

In this scenario I have 8 questions and the questions have different weights for the final score. 

Question 1-5 and 7 have a 15% weight

Question 6 and 8 have a 5% weight

 

both the employee and manager will give a rating for each question which then gets calculated to an overall score. 

 

This topic has been closed for replies.
Correct answer try67

OK, I see. Then assuming the fields are named Q1 to Q8 you can use this code as the custom calculation script of the total field (formatted as Percentage) to show the result:

 

 

var questionsData = [
	{name: "Q1", rating: 0.15},
	{name: "Q2", rating: 0.15},
	{name: "Q3", rating: 0.15},
	{name: "Q4", rating: 0.15},
	{name: "Q5", rating: 0.15},
	{name: "Q6", rating: 0.05},
	{name: "Q7", rating: 0.15},
	{name: "Q8", rating: 0.05},
]

var total = 0;
for (var i in questionsData) {
	var f = this.getField(questionsData[i].name);
	total+=(Number(f.valueAsString)/5 * questionsData[i].rating);
}
event.value = rating;

Edit: Code fixed thanks to Nesa

 

2 replies

Participating Frequently
April 7, 2021

I should be more specific each question (more of a competency)  has a rating of 1-5 that the employee rates themselves on and then the manager also rates the employee from 1-5. 

try67
try67Correct answer
Community Expert
April 7, 2021

OK, I see. Then assuming the fields are named Q1 to Q8 you can use this code as the custom calculation script of the total field (formatted as Percentage) to show the result:

 

 

var questionsData = [
	{name: "Q1", rating: 0.15},
	{name: "Q2", rating: 0.15},
	{name: "Q3", rating: 0.15},
	{name: "Q4", rating: 0.15},
	{name: "Q5", rating: 0.15},
	{name: "Q6", rating: 0.05},
	{name: "Q7", rating: 0.15},
	{name: "Q8", rating: 0.05},
]

var total = 0;
for (var i in questionsData) {
	var f = this.getField(questionsData[i].name);
	total+=(Number(f.valueAsString)/5 * questionsData[i].rating);
}
event.value = rating;

Edit: Code fixed thanks to Nesa

 

Participating Frequently
April 9, 2021

What exactly is failed? Code doesn't work at all or it calculate wrong?

Code should give you percentage of rating, did you format field as percentage?


I copied the code into the custom calculation script it opened as a "javascript editor"

 

 

 

I then formatted as a percentage 

 

 

I saved the form and opened it up and chose 4 for each of the rating fields labeled Q1-Q8 but the overall score was just showing as 0.00%. 

 

These are what the rating scales look like and they are defaulted to 1 because it's forcing me to chose a default. 

 

 

 

 

try67
Community Expert
April 7, 2021

It's possible with a script. What kind of fields are they? Radio-buttons? Text fields? Drop-downs? Something else?

And where are the correct answers stored, if at all?

Participating Frequently
April 7, 2021

I should be more specific each question (more of a competency)  has a rating of 1-5 that the employee rates themselves on and then the manager also rates the employee from 1-5.