• Global community
• Language:
• Deutsch
• English
• EspaÃ±ol
• FranÃ§ais
• PortuguÃªs
• æ—¥æœ¬èªžã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£
Dedicated community for Japanese speakers
• í•œêµ­ ì»¤ë®¤ë‹ˆí‹°
Dedicated community for Korean speakers
Exit
• Re: Rounding a calculated grade and constructing c...

# Rounding a calculated grade and constructing complicated conditional formatting in form

Explorer ,
Jan 30, 2023 Jan 30, 2023

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;

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...

TOPICS
PDF forms

Views

494

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
4 Replies 4
Community Expert ,
Jan 30, 2023 Jan 30, 2023

Copied

Try the forum for Adobe Acrobat.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Jan 30, 2023 Jan 30, 2023

Copied

Isn't this the forum for Acrobat...?

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Jan 30, 2023 Jan 30, 2023

Copied

This is the forum for Acrobat Reader.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Jan 30, 2023 Jan 30, 2023

Copied

LATEST

Oops, thx...