Copy link to clipboard
Copied
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.
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.getF
...
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Just to add, change Q6 and Q8 to 0.05 and in last line change 'rating' to 'total'.
Copy link to clipboard
Copied
How would I enter the 1-5 scale when it comes to each question. Just a drop down list? Would it calculate both the employee's ratings and manager's ratings?
Copy link to clipboard
Copied
Yes, a drop-down list is probably the best option.
And yes, it will calculate a weighted total of all the ratings.
Copy link to clipboard
Copied
Last line is still wrong.
I belive OP wants separate field for employeers and managers, they both can't use same field to make ratings.
Copy link to clipboard
Copied
You're correct, and I fixed it. Thanks!
Copy link to clipboard
Copied
Thank you very much, can you have the old script up as well? I may only use the managers rating for the overall calculation and let the employee rate themselves through a drop down, but not have it affect the score. I apologize for switching up and appreciate the help.
Copy link to clipboard
Copied
Also Im using this version of Adobe Acrobat and I don't see a calculate tab when going into the properties of the text box
Copy link to clipboard
Copied
I found how to bring it in "revert to acrobat form" but it would help great if i can get the calculation from prior. I will no longer use the employee's rating to calculate the final overall score, it would just be the managers. same number of questions and weighting and using a drop down from 1-5. Thank you for the help so far.
Copy link to clipboard
Copied
Did you try to use code try67 gave you?
Copy link to clipboard
Copied
I did and it failed. I believe its because he changed it since I requested it to calculate both the employees score from 1-5 and managers score from 1-5 to count for the overall score.
I stand corrected, only the managers score should count. Therefore I am leaving the managers drop downs with the field names of Q1-Q8 like his code and will name the code for the employees code something else so it doesn't calculate it.
The employee can rate themselves too so each question will have two drop downs next to it, but the employee's rating is just for show if that makes sense. Only the managers score should count at the end where I have a text field and using the calculate tab. Sorry for changing my requests many times and not having it set in stone before I posed the question.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I see, try reading last part of @Nesa Nurani post above and see if that resolve issue.
Copy link to clipboard
Copied
oh man that worked. you guys are awesome.
Just a couple things for the future
1) is there a way i don't have to elect a number in the drop down, and be able to leave it blank, so that overall score isn't preloaded with a percentage?
2) for other job positions I may need to add questions. Would it be as simple as keeping everything the same and adjusting the rating weight and adding multiple lines for the extra questions?
I'm curious how this code was created in the first place. I would have never understood how to code it myself. Are there tutorials to learn this? This was a great help and appreciate going out the way everyone.
Copy link to clipboard
Copied
Hi, could you please help me with this similar problem.
I have 3 fields called "Text1" "Text2" and "Text3". I have to calculate weighted average of these 3 fields which will appear in a field called "Total".
The Total should contain : 10% of the value of "Text1", 20% of the value of "Text2", 70% of the value of "Text3".
I have urgent need to get this done. Thanks in advance.
Copy link to clipboard
Copied
That one's easy. Under the Simple Field Notation option of the Calculate tab enter the following:
(Text1 * 0.1) + (Text2 * 0.2) + (Text3 * 0.7)
Copy link to clipboard
Copied
Thank you. Perfect.
Is there any easy way of locking all the fields on a page quickly without having to select individual fields or group of fields ?
Copy link to clipboard
Copied
I would like to ask anyone what is the best way to send a pdf . If I send it by email, some items like drop downs don't work anymore. But if the same file is copied from a pendrive , it works perfectly. Any way to avoid this ? I don't think it's a question of Mac or pc, because we both use acrobat reader.
Copy link to clipboard
Copied
This is probably happening because they're not opening the emailed file in Reader, but using some other application.
Copy link to clipboard
Copied
What you need to do is force the users to only view your PDF in an application where it will work, i.e. Acrobat Reader. It's unfortunate, but users are often forced into opening PDFs on crappy PDF Viewers, like the Safari PDF viewer, or MS Edge.
There is a solution to this problem:
https://www.pdfscripting.com/public/Lite-Document-Security-Description.cfm
Contact me if you are interested and I can help you with setting up your document.