Sounds like the stress in school really gets to her - any idea if it is the academic pressure, peers, or what may be the cause of the anxiety - the school counselor may be able to help identify the cause as well as strategies to deal with it. If this is happening every year, I'd try to identify the root cause.
Meanwhile, here are some ideas for the stress reduction at school:
1. Put a coin or some other object in the pocket or at the desk - a coin, a die, a beanie, and whenever DD feels the need to bite her fingernails, she can manipulate this object in her hand instead. Let the teacher know about this as well so the teacher - the teacher may not want a beanie baby (too distracting), but may have other suggestions for objects.
2. Get a manicure - she may be less likely to bite her nails when they are polished - they will be harder to bite. I wouldn't suggest a bitter-tasting nail biting inhibitor without having a strategy to deal with the stress in the first place. Pretty nails, however, may help.
Depending on how the grades are structured, is this her first year in middle school? That will probably raise her stress level.
You indicate you considered holding her back - you say she struggled every year - is she struggling academically? With all subjects, or something in particular? Is reading stressing her out? Or having to "perform" in class? Identify the stressor(s). If it is only 1 or 2 academic areas, such as reading and math, tutoring may be the way to go - perhaps she needs different strategies for understanding the content, or additional time to process the content.
Hope you find some solutions!