A Mexican teacher has been honoured after video footage showed her calming pupils as a gun battle raged outside her school.

Martha Rivera Alanis was presented with a certificate on Monday to recognise her bravery in ordering her class of five- and six-year-olds to lie on the floor of their classroom, before attempting to soothe them by leading a chorus of a song from television show Barney & Friends.

Rivera Alanis filmed some of the scenes from inside the classroom in Monterrey – the sound of gunfire can be clearly heard – and posted the resulting video on Twitter. It was picked up and quickly spread around the internet, with the 33-year-old teacher earning the admiration of many.

"Of course, I was afraid, but I tell you, my kids get me through it," Rivera Alanis said after a ceremony hosted by the governor of the northeastern province of Nuevo León.

The teacher used her phone to film a one-and-a-half-minute clip from inside the classroom. The footage shows Rivera Alanis's 15 young pupils lying face down on the floor.

"No, my love, nothing is going to happen, just put your little face on the floor," Rivera Alanis is heard telling one worried girl, before loud bursts of gunfire can be heard.

Paramedics later confirmed gunmen had killed five people at a taxi stand near the school.

In the video, Rivera Alanis attempts to distract the children by leading them in a song from Barney & Friends. "If the rain drops were chocolate, I would love to be there, opening my mouth to taste them," the class sang as they lay on the floor.

"My only thought was to take their minds off that noise," Rivera Alanis told reporters on Monday. "So I thought of that song."

The teacher posted her video to her Twitter account, from which it was reposted on to YouTube.

Monterrey has been plagued by a wave of drug-related violence, in which gangs have staged gunfights, blocked streets and opened fire on civilians.

Rivera Alanis, a mother of two, said her young students had set an example for the rest of the city.

"I'm going to carry on, of course it is possible," she said. "If my five- and six-year-olds can do it, it is up to the rest of us to carry on."

Rivera Alanis's school and those in several Mexican cities hit by drug violence have held emergency drills in the past to instruct teachers and students what to do in case of gunfire. Drug-related violence is said to have killed more than 35,000 people in Mexico over the past four years.

"We do drills constantly, because the area where we are is a high-risk zone," River Alanis said, adding that the children "behaved in the way we had practised".