RICHMOND, Va. — A bill that protects Virginia high school and college journalists from being disciplined for stories they print won final approval Tuesday and now moves to the Senate.

The legislation was spurred by the landmark McCready v. Virginia case in 2016, in which a judge ruled the state Board of Education violated constitutional rights of a journalism student who was punished for covering a school board meeting in Roanoke.

"I was actually the first reporter to cover a school board meeting in Roanoke," Senate Majority Leader Thomas K. Norment Jr., R-James City, said. "And I have to tell you, I didn't know I could be punished for covering a school board meeting."

As a result of the ruling, five states and Washington, D.C., have similar legislation protecting school publications and teachers and administrators who solicit copies from school students, the Virginia Press Association said in an analysis.

"Teachers should not have to worry if they're going to be reprimanded or punished or even lose their jobs," said Joe Hurley, the association's legislative chair and editor-in-chief of The Roanoke Times.

Under the House Bill 711, teachers and other school personnel who assign work to be published by student publications would not face discipline for it, and the students themselves would not face punishment.

The measure would only apply to students who have permission from the school or a parent or guardian to publish their work, and the freedom to write is not absolute.

Still, the measure is seen as a major legislative victory for educators, who are frequently at odds with conservative lawmakers over the state's approach to education and the conduct of school board members.

It's the third year that the legislation has been debated in the House.

"I think it was the right thing to do for high school and college students to get that protection," said the bill's sponsor, Del. David Yancey, R-Newport News.