A ruling that rapes committed by intruders at a job site are work-related -- thus barring the victim from seeking negligence damages from her employer -- was upheld yesterday by the Supreme Court.

The case involved a former District of Columbia teacher who was bound, gagged, assaulted with a knife and repeatedly raped by two non-students after they found her alone grading papers in her Spingarn High School classroom.

Three similar episodes had occured at Spingarn earlier, leading to the hiring of a guard. But he was absent on the May afternoon in 1975 when the intruders attacked the teacher, then 28, and inflicted injuries requiring costly psychological care and legal aid as well as medical treatment.

She filed a $1 million damage suit that blamed the attack directly on the District of Columbia. The city had neglected to provide safe working conditions although it knew or should have known that teachers were at risk, she charged.

The obstacle in her path had been the workmen's compensation law that covers District as well as federal employes. Like similar state laws, it requires an employer to pay for medical expenses and loss of earning power resulting from job-related personal injury. But it excludes compensation for humiliation, mental anguish, pain and suffering. These which the teacher says she suffered in abundance, had been the basis of her lawsuit.

Citing the Federal Employees' Compensation Act, a Superior Court judge dismissed the suit and the decision was upheld last June by the D.C. Court of Appeals. It was the appellate ruling that the woman's attorneys had sought to reverse.

The opinion rejected as "without merit" the teacher's assertion that the act did not provide for her psychic damages. The "underlying cause" of those psychological injuries were the physical injuries, and the law, while failing to provide fully for her injuries, bars her suit, Judge George R. Gallagher wrote.

The court also rejected her claim that the injuries weren't related to a hazard inherent in her work, saying:

"All that is required is that the injury result from a risk incidental to the environment in which the employment places the claimant . . . Appealant was in her classroom during her working hours and was acting in the course of her employment when the attack occurred."

In any event, Gallagher said, the law required the teacher, before suing, to seek relief from the Labor Department, because of the substantial question of whether her injuries were work-related. She hadn't done that.

In their unsuccessful petition for Supreme Court review, attorneys Ronald L. Goldfarb and Ronald A. Schechter asked the justices to decide whether harms such as humiliation and mental anguish are within or without the scope of the compensation law, and whether rapes by intruders who weren't students arose from a teaching job.

"The policies behind workmen's compensation laws -- sharing the risks of workplace, work-related injuries, and expediting claims for injuries on the job -- are wise and useful ones." Goldfarb wrote, "They have nothing to do with claims arising out of a savage rape of a teacher by strangers . . . "