The quickest way to do this is with csv upload. You can assign the students to groups all at once with one csv file. See documentation here - https://docs.moodle.org/29/en/Upload_users
Just make sure to update existing and create new when you run the import.