(Reuters) - A former University of New Mexico student failed to persuade a federal appeals court that the school violated her free speech rights by rejecting an essay containing anti-lesbian remarks that she had written for a film class.

The 10th U.S. Circuit Court of Appeals on Tuesday said the university had legitimate pedagogical concerns when its professors refused to grade Monica Pompeo’s critique of a film about a lesbian romance and suggested that she rewrite it, prompting her withdrawal from the class in the spring of 2012.

Pompeo had written that the 1985 film, “Desert Hearts,” could be viewed as “entirely perverse in its desire and attempt to reverse the natural roles of man and woman in addition to championing the barren wombs of these women.”

Writing for a two-judge panel, Circuit Judge Carlos Lucero said Pompeo did not have an unfettered right to use language in a course assignment that professors might find offensive.

He said this meant the university and two professors who reviewed Pompeo’s essay were not liable for damages for any alleged First Amendment violations.

“Teaching students to avoid inflammatory language when writing for an academic audience qualifies as a legitimate pedagogical goal,” Lucero wrote. “Short of turning every classroom into a courtroom, we must entrust to educators these decisions that require judgments based on viewpoint.”

Pompeo’s lawyers did not immediately respond to requests for comment.

A university spokeswoman, Dianne Anderson, said in an email on behalf of the professors that the school was pleased that the decision “provides a more complete perspective on the facts” and affirms the lack of evidence of a free speech violation.

The university refunded Pompeo’s tuition for the class, court records show.

Tuesday’s decision by the Denver-based appeals court let stand a September 2015 ruling by Chief Judge M. Christina Armijo of the federal court in Albuquerque.

Circuit Judge Neil Gorsuch, the U.S. Supreme Court nominee of President Donald Trump, was originally part of the 10th Circuit panel but did not participate in Tuesday’s decision.

The case is Pompeo v. Board of Regents of the University of New Mexico et al, 10th U.S. Circuit Court of Appeals, No. 15-2179.