cache course object
Revert "MDL-42400 generator: save db query in module generation"

This reverts commit fa9770012381e64534dffa84625d39ba6093fb1b.