A judge ruled on Wednesday that a Danvers teen is mentally competent to stand trial for allegedly raping and murdering his 9th grade math teacher in 2013.

Philip Chism, 14 at the time, pleaded not guilty to raping and murdering 24-year-old Colleen Ritzer, a math teacher who was found dead in the woods near Danvers High School on October 23, 2013.

The judge made the ruling after Chism underwent a 20-day psychological evaluation, according to CBSBoston.

Ritzer had been raped and her throat was slashed open with a box cutter, according to authorities.

Police who discovered Ritzer's body in the woods near the school said that they found a note that said, “I hate you all.” 

Ritzer had asked Chism to stay after school the day she was reported missing, police said.

Authorities said Chism, now 16, was seen on surveillance video following Ritzer to the bathroom, where the initial attack began. Prosecutors said the footage showed Chism go into the bathroom wearing gloves and a hood and walks out alone about 12 minutes later. He was then seen pushing a recycling barrel outside. The barrel was found near her body. Authorities said Ritzer was sexually assaulted twice, once with a stick. 

RELATED: Philip Chism arraigned for rape, murder of Danvers High School teacher

Chism has also been charged with attempted murder by strangulation, assault with intent to murder and assault and battery with a dangerous weapon after he allegedly attacked a female clinician at the facility where he was being held.

RELATED: DA: Philip Chism punched, choked, stabbed female DYS worker

According to the Boston Herald, Chism was committed to the Worcester Recovery Center and Hospital to be evaluated by Department of Mental Health officials after he spent two days slamming his head against several surfaces, talking to an imaginary friend and talking about his desire to be gunned down by a vigilante back in October. 

Salem District Court Judge David Lowy said that jury selection will resume and the jury will be seated by Nov. 16, barring any other setbacks. Essex County Assistant District Attorney Kate MacDougall said that the trial will likely stretch into December.