Q:

Moodle coding error detected

My moodle gave me this error:
"Coding error detected, it must be fixed by a programmer: Invalid state passed to moodle_page::set_state. We are in state 0 and state 3 was requested."
I googled for a bit, but couldn't find an exact solution for this error. I have never encountered it myself before. If you need any extra information on the code or file, be sure to tell me.

A:

This can happen if $OUTPUT->footer() is called but $OUTPUT->header() hasn't. The page should be in one of these states:
/** The state of the page before it has printed the header **/
const STATE_BEFORE_HEADER = 0;

/** The state the page is in temporarily while the header is being printed **/
const STATE_PRINTING_HEADER = 1;

/** The state the page is in while content is presumably being printed **/
const STATE_IN_BODY = 2;

/**
 * The state the page is when the footer has been printed and its function is
 * complete.
 */
const STATE_DONE = 3;

Probably some custom code. Switch on debugging to developer level to find out where. In your config.php add
$CFG->debug = E_ALL | E_STRICT;
$CFG->debugdisplay = true;

