Teacher brought loaded gun, knife into Royal Palm High School. Here's what he learned in court.

WEST PALM BEACH — A judge has placed a Palm Beach County school teacher accused of bringing a loaded handgun and a knife to the campus of Royal Palm Beach High School in January into a pre-trial diversion program.

Circuit Judge Caroline Shepherd ordered that Robert Krasnicki be placed under the supervision of the state Department of Corrections for one year during a hearing Friday at the Palm Beach County Courthouse.

Shepherd also ordered that Krasnicki notify his employers about his entry into the program, undergo a mental-health evaluation with treatment, complete a firearms-safety course and perform 40 hours of community service.

Court records show he is represented by a public defender. The Palm Beach County Public Defender's Office does not comment on active cases as a matter of policy.

For subscribers: Why private, public school officials took a field trip to New York's Hudson Yards

What happened? Two longtime Palm Beach County principals removed from the job, replaced.

'Angry Patriot Hippie': She threatened to kill FBI agents. She fears the penalty may kill her.

Teacher had handgun, knife in waistband while at school

If Krasnicki successfully completes the terms of the pre-trial agreement and avoids any new violations, the state will dismiss a charge of possession of a weapon on school property. The Palm Beach County State Attorney's Office in February chose not to pursue a second count of possession of a firearm at school, court records show.

Krasnicki, who turned 43 on Wednesday, was arrested Jan. 19 after Palm Beach County School District police alleged he had a knife and a loaded 9 mm handgun in his waistband while on school property.

He was administratively reassigned following a court order barring him from having contact either with students or the school grounds. Krasnicki later chose to resign in lieu of involuntary termination of his employment, the school district said Monday.

Reports indicate teacher had struggled prior to arrest

He joined the school district in 2016. Documents released in the days after his arrest showed that police had concerns about his mental health, guns and possible drug use in the months leading up to the arrest.

A report stated that Krasnicki in November took pictures with a rifle and a handgun in his bedroom, at one point aiming a gun at the camera before sending the pictures to an ex-girlfriend.

West Palm Beach police investigated an allegation from Krasnicki's ex-girlfriend that he traded drugs with students for good grades and used a school-district computer system to lower her son’s grades and locate her address.

City police did not arrest Krasnicki, and it was not clear whether school police investigated the allegations.

Shortly after his arrest in January, Royal Palm Beach High Principal Michelle Fleming informed parents about the accusation and said Krasnicki would not be returning to the school.

Following his arrest, the Palm Beach County Sheriff's Office sought a risk-protection order against Krasnicki. The order temporarily bans him from possessing weapons. Records show it is in effect through January 2024.

Julius Whigham II is a criminal justice and public safety reporter for The Palm Beach Post. You can reach him at jwhigham@pbpost.com and follow him on Twitter at @JuliusWhigham. Help support our work: Subscribe today.

This article originally appeared on Palm Beach Post: Judge sentences Royal Palm teacher caught with loaded gun, knife at school