Copy link to clipboard
Copied
I'm making a graduation assesment form (grades are 1 - 10). The final grade FG is the (weighted) average of several partial grades PG (PG_1, PG_2 etc). The partial grades are simply calculated as the average of the grades for subgoals (field 1.1_grade, 1.2_grade etc; 2.1_grade, 2.2_grade etc). All calculationsin my form work well, but there's 2 (or 3) finetuning issues…
Question 1. The final grade is supposed to be rounded to the nearest half ==> how do I do this?
Example: everything up to 6.24 rounds to 6; 6.25 - 6.74 round to 6.5; 6.75 - 7.24 round to 7 etc.
(it must be something like the answer given in the post down here - but I don't understand it well enough to use it… https://community.adobe.com/t5/acrobat-sdk-discussions/rounding-down-numbers-using-decimels/m-p/1251...)
Question 2. The partial grade PG is supposed to show only after the subgrades are filled. In the same way, final grade FG doesn't show until all the partial grades are filled (= all 22 or so subgrades are filled == 0).
I've solved this problem now using a validation script using text color: text color of partial grade is white (thus: invisible) until all subgrades (default: 0) are filled.
var g11 = this.getField("1.1_grade").valueAsString;
var g12 = this.getField("1.2_grade").valueAsString;
var g13 = this.getField("1.3_grade").valueAsString;
var g14 = this.getField("1.4_grade").valueAsString;
var g15 = this.getField("1.5_grade").valueAsString;
if (g11 == 0 || g12 == 0 || g13 == 0 || g14 == 0 || g15 == 0) {event.target.textColor = color.white ;}
else {event.target.textColor = color.black ;}
This works pretty well for the partial grades, but the above statement gets pretty long for the final grade (declaring all the 22 variables one by one and then making the if-statement).
==> is there a better/easier/cleaner way to do this? (I tried to declare the variables on the document level, but my coding knowledge sadly failed...)
Bonus question (let's call it 3.) text color FG is supposed to show red when one of the PG is below 6.0 (or gives another type of 'alert', because that means the student has failed…).
I could write another statement like the above, but I'm not sure how those 2 are supposed to interact (one statement is based on 1.1_grade, 1.2_grade; the other on PG_1, PG_2 etc)... And there should be a more beautiful way...
Copy link to clipboard
Copied
Try the forum for Adobe Acrobat.
Copy link to clipboard
Copied
Isn't this the forum for Acrobat...?
Copy link to clipboard
Copied
This is the forum for Acrobat Reader.
Copy link to clipboard
Copied
Oops, thx...