Moved constant definitions out of function, so they are not run repeatedly giving lots of warnings. Merged from MOODLE_16_STABLE.
Moved constant definitions out of function, so they are not run repeatedly giving lots of warnings. Merged from MOODLE_16_STABLE.

dilawar/moodle