I'm a beginner in Japanese so I'm trying to read and translate a light novel to improve my vocabulary so I came across this sentence:
他{ほか}の生徒{せいと}たちが部活{ぶかつ}に帰宅{きたく}にと平和{へいわ}な放課後{ほうかご}を過{す}ごす中{なか}、保健室{ほけんしつ}には、少女{しょうじょ}の悲鳴{ひめい}が響{ひび}き渡{わた}っていた.
As a translation I came up with:
"The other students were heading home after their club activities after spending a peaceful afterschool time when a girl’s scream echoed from the infirmary."
But I'm unsure about this so I have those questions:
Did the other students already leave the school after their club activities or are they still doing them?
What's the function of にと before 平和な放課後を過ごす中?
Is the translation I provided satisfactory?
Thank you in advance.