MDL-42400 modlib: include module file when it's used

- changed the place where module file is included to make sure that add_moduleinfo() can be called independently from create_module()
- removed permission check from add_moduleinfo() because this function is not supposed to check permissions. Besides it's only half-check. See can_add_moduleinfo()
- added phpdocs to some functions to indicate that they can throw an exception
MDL-42400 generator: module generators call add_moduleinfo instead of direct inserts
MDL-42400 generator: save db query in module generation
generators for glossary
generators for lesson
generators for scorm
generators for survey
generators for url
generators for wiki
generators for workshop
generators for imscp (unfinished)
experimental course cache
cache course object
Revert "MDL-42400 generator: save db query in module generation"

This reverts commit fa9770012381e64534dffa84625d39ba6093fb1b.
generator cache
speed up add_moduleinfo, remove unnecessary queries
change to module generator, course retrieval