I agree with Elena. She needs to advocate for herself and speak to the teacher directly. She should go for extra help (free, after school - she can ask the teacher which days the teacher is there). She can have a talk with the guidance counselor about her lack of motivation and whether she is properly placed in a class.
I think you have to look at this as ONE TEST. A test is a measure of what a student knows - if everyone does poorly, the teacher needs to look at the test. If the student does poorly, the student needs to assess what she did wrong. But I don't believe in taking one test as anything other than an indicator that a student didn't understand the material. It's not the end of the world, and people can't go so stressed out about grades that kids feel they can't change and do better.
A parent's job is NOT to be studying with the child, giving her problems to do, etc. If you thought she would get a B, then you may be like many other parents - not as clear on the teacher's expectations or the math concepts involved. So don't be her tutor, and don't be her motivator. And don't put the pressure on her to get As and Bs all the time - sometimes a kid is going to blow the test, that's all. If she just got over-confident because she took a supplemental course and thought she knew it all, then she knows she was wrong in her self-assessment. Put it back on her and, if you insist on anything, it should be that she meet with the teacher and then report back to you that it has been done.
Figure out what bothers you so much about this grade - if it's that she was cocky and had attitude, then the grade has humbled her. If it was all the complaining she did, then you know that you need to walk away from that and not listen to it. If she has a complaint, she can talk to the teacher. This is part of being a middle schooler and then a high schooler - the parents stop doing it all and having all the conferences, and the kids start to take on more responsibility.
I'm not saying it's good to have a kid who is lazy and not trying, but sometimes kids complain because they are really afraid that they can't manage the material, so they take the attitude that it's all "stupid" and "not worth my time." She has one job, which is to do her work and to have as much fun as possible doing it. If she makes herself miserable, that's on her. If she's overwhelmed, then you can guide her into working with the staff to find a way out of it. Maybe she needs a tutor, but maybe she just needs some one-on-one time with the teacher who watches her do a few problems and identifies where your child is blocked or making an error.
If it were me, I would give my daughter a week to speak to the teacher and set up an appointment for extra help. After that, I would consider taking away a privilege only for not contacting the teacher - I would not make a big thing out of the grade itself. And I'd maybe (maybe) email the teacher saying I have instructed my kid to contact you, and please let me know if there's anything you need me to do on this end.
If the bad grades become a long-term thing (like the next 2 tests), then I might sit down with teacher and/or guidance counselor to find out why my kid is so lost. Kids need to learn that things aren't always easy the first time out, and they have to work at it.