It still can take a while in large enrollment courses, but we found that boosting max allowed packets for the database was the most significant positive step we tried. We actually had a course locked up after a teacher did a grade recalculation and this change was what got that course accessible and allowed it to finish up the task. You can try this even as a temporary setting since you can update that one without a server restart (dynamic). The maximum setting is 1073741824, but make sure you have plenty of RAM if you go that high (32GB or more). You may find that this setting boost will also help with restoring to a new course in those courses with large question banks and lots of quizzes.
We also found that increasing max_heap-table_size and tmp_table_size was a big help. Those are also settings you can try without a server restart.
Just remember that if those setting changes do end up helping that you set them temporarily. They will go away in the next server restart. If they help, make them permanent by changing them in my.cnf
set global max_heap_table_size =33554432
set global tmp_table_size = 33554432
set global max_allowed_packet=1073741824
I recommend increasing your setting slowly, but the above values are what we finally settled on since we do have really large question bank courses (5,000 to 10,000 questions) and large enrollment courses (many hundreds of students). We might be able to lower them now. We found out that our remote host accidentally set us up on a file system that had been deprecated. We were on that server two years all the while boosting settings to try to help with those large processes. When they caught their error and moved us to a server with the current file system, we found many things ran much faster. I have not explored if we now can set those settings lower and get as good a result. We definitely needed them on the original server though.