Good judgment is apparently not part of the curriculum.

When notorious rapper Tekashi 6ix9ine showed up at his former middle school in Brooklyn last year, he was welcomed in and gave a spontaneous performance that quickly turned into a “dangerous situation” — when he threw cash at starstruck students, a newly released investigative report obtained by The Post reveals.

“This used to be my school!” Tekashi shouts to a crowd of kids, frenetic footage from inside the Juan Morel Campos Secondary School in Williamsburg shows.

When the heavily inked hip-hopper “made it rain” by flinging cash in the air, taller teens jumped to snatch the fluttering notes as shorter kids scrambled on the floor to scoop up what the others missed.

Yet it’s unclear why a school staffer allowed the rainbow-maned rapper into the building in the first place.

Tekashi, whose given name is Daniel Hernandez, was expelled in the eighth grade, joined a street gang, and in 2015 posted a video on his Instagram account in which other men were seen having sex with a 13-year-old girl while he touched her and clowned for the camera.

He pleaded guilty to felony charges of using a child in a sexual performance in Manhattan Supreme Court.

In a federal case, Tekashi, 23, admitted in November that he belonged to the Nine Trey Gangsta Bloods and took part in shooting a rival rapper, gunpoint robberies and heroin sales. The feds found an AK-15 assault rifle in Tekashi’s Brooklyn home, officials said.

His sentencing has been postponed while he cooperates against co-defendants, but he remains in federal custody, said his lawyer, Dawn Florio.

Eight months before that guilty plea, the hip-hop artist, who has “69” inked onto his face, showed up at Juan Morel Campos on March 19, 2018, and asked to see a teacher, according to the report by the city’s Special Commissioner of Investigation.

A staffer then escorted him to the third floor, where a crowd quickly formed.

In the video, Tekashi gives props to his old teachers, saying, “I used to give them hell,” then tells the students, “If you follow your dreams, bro, I’m telling you — you can do whatever the f- -k you want.”

Students were thrilled.

“No celebrity came to the school before, and he was really popular at the time,” recalled seventh-grader Roselyn Almonte.

“Everybody was singing his latest song. Then he started throwing the money. He kept throwing it. He threw it high.”

While the older kids “grabbed it from the sky,” she said, “the short ones grabbed it from the floor.”

The video shows one seventh-grade girl excitedly showing off what appears to be at least $100 in $20 bills in her hands.

The “Oof” and “Gummo” rapper only wanted to connect with his Brooklyn roots, Florio said.

“Mr. Hernandez was trying to do a good thing by visiting the school,” she said. “A lot of students are fans of his. He did it to give back and show that he’s still one of them.”

Almonte recalled: “Before he threw the money, he gave us a speech — finish school, don’t drop out, go to college.”

Assistant Principal Jason Rosenbaum, who recorded the performance on his personal cellphone, “failed to properly supervise a potentially dangerous situation,” the Special Commissioner of Investigation concluded in a letter to Chancellor Richard Carranza.

Only after Tekashi began spreading his wealth did Rosenbaum ask security to remove the rapper from the building, says the SCI report.

Rosenbaum, in charge because Principal Esther Shali-Ogli was away, told probers he took pictures on his cellphone “merely to demonstrate that no students were injured.”

The city Department of Education said Rosenbaum got a letter of reprimand.

Florio said, “If an assistant principal got disciplined, I think that’s ridiculous.”

Rosenbaum and Shali-Ogli did not return multiple messages.