Okay so what I did was. I created a block period that run every day. I then created subject called 'All teachers' that run on all school days. I created a course called teachers and course periods called teacher1, teacher 2 etc. And I assigned each course period to a teacher. Then I used group schedule and assigned all the courses to all the students students . It works.
Alternatively, I attempted to modify the code. It worked but i got a violation error.