A school in India has apologized after photos emerged of students wearing cardboard boxes on their heads during an exam to discourage cheating.

The Bhagat Pre-University College in Haveri, in India's southwestern Karnataka state, implemented a trial run of the new measure last Wednesday, according to school management head M.B. Sateesh.

A staff member photographed the students sitting in neat rows, their heads obscured by cardboard boxes.

The front of the boxes had been cut out, allowing students to see their desks and exam sheets but restricting their vision, similar to blinders used on a horse.

The photos were posted on Facebook by a staff member and promptly went viral, according to CNN affiliate CNN-News18.

Before long, the school was facing widespread criticism on social media. Even government officials weighed in -- S. Suresh Kumar, the state education minister, said in a tweet that the school's practice was "unacceptable."

"Nobody has any right to treat anybody more so students like animals," Kumar wrote. "This (perversion) will be dealt with aptly."

The school has provided authorities with a written explanation of the trial and an apology, Sateesh said.

Sateesh emphasized that the trial was optional, the school had notified parents in advance -- and only students with parental approval had been involved. Of the 72 students taking midterm exams that day, only 56 took part in the box experiment, he said.

"They said they were comfortable with the trial," Sateesh said. "The college did not harass any student, it was optional and some (students) experimented, some did not."

The students had brought their own boxes to school, and many took them off after 15 to 30 minutes, Sateesh said. The school asked all students to take off the boxes within an hour of the exam.

The school had faced a widespread and persistent cheating problem last year -- leading to new anti-cheating experiments like the boxes, according to CNN-News18.

There has been a number of cheating scandals across India in recent years. One particularly prominent scandal in 2015 saw parents and family members in Bihar state scaling the exterior walls of school buildings to pass their children cheat sheets.

In a developing economy like India, education is a precious commodity -- it could be the key for much of the population to get out of a vicious cycle of poverty. However, this also means many students are under heavy pressure not to just pass examinations, but to exceed expectations at all costs.

Critics have pointed to such pressure as a motivator to cheat, and a source of poor mental health among students -- earlier this year, 19 students in the southern Indian state of Telangana took their own lives after the release of exam results.