A math teacher defended himself against accusations that he locked students out of his classroom during the Florida school shooting. Jim Gard told the South Florida Sun Sentinel newspaper that no one was around when he locked his classroom door during last month's massacre at Marjory Stoneman Douglas High School in Parkland.

Gard spoke to the newspaper after junior Joshua Gallagher said on Twitter that he and more than a dozen classmates were locked out of Gard's classroom as gunshots rang out on the campus on Feb. 14. Authorities have charged former student Nikolas Cruz, 19, with killing 17 people in the massacre.

Gard's classroom is in a different building from where the shooting happened.

Get Breaking News Delivered to Your Inbox

On Wednesday, Joshua said on Twitter that he and his classmates were evacuating the building because the fire alarm went off. When they heard gunshots, they turned around and tried to return to the classroom and found the door locked, Joshua said.

"Which then left me and 15 other students left in the hallways ducking as the screams of classmates and gunshots took over the noise around me," Joshua said. "We were stuck in the hall for 4 total minutes ducking and in fear for our lives."

Im a victim of the Marjory Stoneman Douglas shooting. Please read my story below as I present the truth about a teacher Mr. Gard (Jim Gard) who calls himself a hero, and how the media portrayed him as hero when in reality he is the opposite. pic.twitter.com/MH70M6Sqhe — Josh Gallagher (@JoshBGallagher) March 1, 2018

Another teacher opened their door and let the students in, Joshua said.

Gard told the Sun Sentinel that he didn't see anyone in the hallway when he closed his classroom's door, the paper reported Friday.

"I looked back down the hall and no one was around - no one," Gard said. "You have to close the door. That's protocol. We have no choice."

Gard told the newspaper that he later heard banging on the door and told students with him that he couldn't let anyone in. When he got to the door, the banging had stopped.

"If there were 13 kids outside the door screaming and banging, I would have heard them," Gard said.

On Feb. 15, the day after the shooting, Gard said on CBSN that he was with around six students when the "code red" was announced over the public address system once officials realized that there was no fire.

"There was literally nobody else around," Gard told CBS News correspondent Vladimir Duthiers. "I looked up and down the hallway a little bit, maybe like 10, 12 seconds, close the door, turn the lights off. We all went in, got back towards the closet and told them, 'OK, just hang out,' and they were nervous, what's going on. I said, 'Look, you know, they could be practicing a code red. They talked about doing this. They even talked about police coming on and, you know, shooting blanks, you know, to see what would happen, you know,' and I said, 'It's kinda weird.'"

Gard said in the CBSN interview that he took attendance to see which students were missing.

"We got on our internet," he said. "A lot of teachers were in their classrooms. We're all communicating with each other, 'I have this kid in my room,' 'I have these kids,' 'Here's who's absent.'"

Joshua called Gard an "opportunist" for giving interviews about the shooting, including one while the rampage was happening. (Gard gave an interview over the phone with CBS Miami station WFOR-TV around the time authorities said a suspect was in custody.)

"He is nothing but a coward," Joshua said. "He has revictimized the students he left out of his class by calling himself a hero. I have nightmares at (sic) could have happened because of how selfish and horrific this man is."

Joshua told the Sun Sentinel that he didn't want to be interviewed.

"I want change to happen when it comes to protocol and the way this situation is handled," he said in a statement to the paper over Twitter. "No child can feel the way I did."