检测到 Moodle 编码错误

Moodle coding error detected

我的心情给了我这个错误: "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."

我在谷歌上搜索了一下,但找不到针对此错误的确切解决方案。我自己以前从未遇到过。如果您需要有关代码或文件的任何额外信息,请务必告诉我。

如果 $OUTPUT->footer() 被调用但 $OUTPUT->header() 没有被调用,就会发生这种情况。该页面应处于以下状态之一:

/** 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;

可能是一些自定义代码。将调试切换到开发人员级别以找出位置。在你的 config.php 添加

$CFG->debug = E_ALL | E_STRICT;
$CFG->debugdisplay = true;