The science exam given annually to District students was so error-ridden that the superintendent announced Friday that she is throwing out scores for the past two years and canceling this year’s test.

The decision puts the city in violation of federal law, and the superintendent’s office said some federal funding could be in jeopardy.

Under the law, school districts must test students in science once during their elementary school years, once in middle school and once in high school. Tests vary by district, and state and local school leaders determine how exams are administered.

D.C. State Superintendent of Education Hanseul Kang said she had little choice but to cancel the District’s $370,000 contract with WestEd, a national education company that developed the citywide exam known as the DC Science Assessment. The two-hour, computerized test is not used to determine whether students can advance to the next grade.

“We recognize that this is an extraordinary step we are taking, and it is not a decision we are taking lightly,” Kang said in an interview. “If we had gone forward with releasing these results, we felt we would have been giving schools an inaccurate reflection of how students are doing, which would have been absolutely unjust.”

While examining 2017 test results, Kang said employees in her office noticed that eighth-graders’ scores had declined significantly over the previous year. That result did not match trends in other grade levels and was inconsistent with the middle-schoolers’ performance on other standardized tests.

District officials determined that the 2016 science exam had 70 questions; in 2017, the score reflected only 50 questions — making each question worth more and, thus, susceptible to bigger changes in overall results.

Eighth-grade students in 2017 were originally given a 70-question test, Kang said, but WestEd later invalidated 20 questions without notifying her office. Questions can be invalidated for a host of technical reasons: They can be deemed unclear, or found to not properly assess what students know. (The test is not entirely multiple choice.)

Max McConkey, chief policy and communications officer at WestEd, said the company is aware of errors in the exams but said he was surprised the superintendent’s office canceled the contract.

“We knew there were errors, but we thought we had put corrective measures in place,” he said. “We want them to be happy, we want the kids to be served, and if that’s the direction they want to go we will — at no expense — work with any new vendor.”

WestEd administered its first science exam in the District in spring 2016. The city previously used the DC-CAS Science Assessment, but the superintendent’s office developed a new test in 2014 after the city passed updated science curriculum standards.

Kang said errors existed in the 2017 tests across all grade levels, and WestEd did not follow protocol to ensure the exams could be accurately compared year over year.

“That is a basic function of the tests,” she said. “There were core industry principles that were not followed.”

The Office of the State Superintendent of Education oversees the administration of standardized tests for schools and is exploring whether it will take legal action against WestEd, officials said.

Kang said her office has been in contact with the Education Department and is working to mitigate the consequences for not administering a science exam. The department did not immediately reply Friday to a request for comment.

The superintendent’s office opened a competitive bidding process for a new test administrator and plans to give students the exam in spring 2019.

“2019 will become our new baseline because we don’t have previous tests,” Kang said.