This, and this again. Did the teacher choose her because she is not just a good student, but a girl, who should be docile? Did she get in trouble for cursing because she is a girl, would a boy have the same punishment? Why should she accept daily HARRASSMENT? I had teachers who told me to shut up when the unruly boys touched me (daily). So this hits a huge nerve. 
I would take your daughter to see the principle and teacher and talk this out. Let them know you will talk toa lawyer if this boy harasses your daughter and interferes with her learning. And you 100% agree it is not her job to get this boy to comply with the standards of common decency. I would tell your daughter you agree with what she was trying to do, and she should never accept being harrassed.  I would discuss with Alan why it is OK with him that a teacher set up your daughter to be harrased. And unless he never curses in front of her make him apologize for the over punishment she was given. 
You already know, she may never get over how unjustly she was treated by her teacher, the school and her father. Interestingly the asshat kid is the least guilty in all this.