We now know the main problems. How to solve them?
Use a cache! This could be caching the output in memory or in a single file that can be served directly.
Also use an opcache to cache your PHP structures (function, classes).
Because a module has to be dispensed to persons from different background and with ways of learning, we will try a new excerice.
For the next weeks, we will do this exercice for the 2nd hour, or both hours when no lectures are planned.
Principle: a student ask a question (anything related to the module), and the class discuss it and comes with an answer (could be a workflow, a process or a code idea). I as lecturer, will use my computer and implement a proof of concept of the solution live, in front of the class.