School and breakdowns

I’m a overall pretty good student. I’ve never failed a class until last year when I failed algebra. I was fine with it and decided to take the class again because I knew that I didn’t understand it. My thoughts where that if I took it again it would make more sense. I doesn’t. I do all my work, I study, I stay after school and I still don’t get it. We took a test two weeks ago and looking at it I felt like I didn’t know anything. I felt like crying and my mind just wouldn’t stop racing. Every time I think about math I just feel so stupid and horrible. It’s gotten to the point where I don’t even want to go to class anymore. I’m trying. I really am, but nothing seems to be working.