Since President Barack Obama pressured educators to adopt a new code of conduct making it harder to suspend or expel students of color, even kids who punch out their teacher aren’t automatically kicked out of school anymore.

Previously, “If you hit a teacher, you’re gone,” said Peter Kirsanow, a black conservative on the US Commission on Civil Rights. But that’s no longer the case, he says, thanks to race-based discipline quotas sweeping the nation’s schools.

In just the first year after Obama in January 2014 issued his new discipline guidelines — which came with threats of federal investigations and defunding — schools saw more than 160,000 “physical attacks” on teachers across the country. And yet the assailants were expelled in fewer than 130,000 cases, Kirsanow said, citing the latest available federal data.

Many teachers have been sent to the hospital by students emboldened by the lax discipline rules — which remain in full force, despite the change in administration, and have now been adopted by 53 of the nation’s largest school districts, including NYC.

The growing number of classroom horror stories and backlash from teachers unions have left former Obama educrats scrambling to defend the lower discipline standards. “No one has ever advocated for policies that make students or teachers unsafe,” argued Catherine Lhamon, the Education Department civil-rights chief who rolled out Obama’s directive.

But a former St. Paul, Minn., science teacher, who was “beaten and choked out” by a 16-year-old black student, blames the discipline policies, which he says are “preferential towards African-American students.” The high school student allegedly came up behind the instructor, calling him a “f–king white cracker,” and put him in a stranglehold, before bashing his head into a concrete wall and pavement, causing him to suffer a concussion and brain damage.

John Ekblad, who is still dealing with short-term memory loss and hearing problems from the December 2015 attack, says school violence “is still rising out of control.”

“The district is not suspending students for fighting, theft, drugs and alcohol in an effort to show less students of color are suspended,” Ekblad said, adding that the administration has even paid principals as much as $2,500 in bonuses for low suspension rates.

A surge in violence has also followed Mayor de Blasio’s racially motivated anti-discipline push, started in early 2015.

While he touts a dramatic drop in NYC school suspensions, school assaults — including attacks on teachers — have soared 48 percent, in the 2015-2016, according to State Education Department data. Schools have turned deadly on his watch. In September, a high-school student stabbed two other students inside their Bronx classroom, killing one and critically injuring the other. It was the first killing in NYC schools in nearly a quarter-century. (Abel Cedeno, 18, has pleaded not guilty to manslaughter charges.)

Meanwhile:

In Harrisburg, Pa., a series of violent altercations with students led to a wave of teacher resignations last month. At least 45 teachers quit due to safety concerns stemming from “alternative” discipline practices and a three-year backlog of expulsion cases — including more than 100 involving assaults on teachers. Even elementary-school teachers complained of kids slapping, kicking, scratching and spitting on them.

In Buffalo, a teacher who got kicked in the head by a student said: “We have fights here almost every day. The kids walk around and say, ‘We can’t get suspended — we don’t care what you say.’ ”

In Charlotte, NC, assaults on faculty have climbed two years in a row, as schools implement Obama’s discipline reforms. “There were staff that were afraid of students,” said Annette Albright, one of more than 300 staffers hit by students in the last reported school year.

In Silver Springs, Md., disobedient students became more brazen, bringing “knives in school [and] threatening teachers,” after Montgomery County public-school administrators told teachers that “the number of minority suspensions had to be closer to the percentage of the whole student body,” high-school history teacher Jamie Frank complained. Even repeat offenders are given a pass: “It’s most likely that that child will be back in school if they are a minority student,” Frank said.

In Oklahoma City, which softened student punishments in response to a federal bias complaint, “Students are yelling, cursing, hitting and screaming at teachers, and nothing is being done,” an Oklahoma City public-school teacher said. “These students know there is nothing a teacher can do.”

In Milwaukee, which also has complied with the Obama mandate, a 16-year-old black student in August knocked a teacher to the ground and punched him over and over, while a sixth-grader tried to strangle another staffer with his lanyard and faced no consequences.

Last month, a group of teachers met with Trump education officials to urge them to scrap the directive. In turn, Lhamon, who now heads the US Commission on Civil Rights, called no fewer than four former Obama officials to testify in support of it at a hearing earlier this month on the alleged “school-to-prison pipeline.”

One repeated an apocryphal tale to support the notion black students are unfairly suspended for minor offenses. Anurima Bhargava, who led federal enforcement of civil rights in schools, cited the “arrest of students for wearing the wrong color socks” in Mississippi. In fact, the students were mildly disciplined, not arrested, for wearing the wrong uniform.

Another friendly panelist claimed foes of reform are making “a straw-man argument” by citing teacher attacks. “It is important to put the debate about the safety of students and teachers to one side,” UCLA civil-rights professor Daniel Losen said. “Safety also includes protection from oppression and bigotry.”

Paul Sperry is a former Hoover Institution media fellow and author of several books.