我正在使用“\ mod_quiz \ event \ attempt_started”事件观察者,但我没有得到任何结果,php错误消息或日志。
我正在为排行榜功能创建自己的本地插件,但我仍然遇到事件观察员调用。
在events.php文件中
$observers = array(
array('eventname' => '\mod_quiz\event\attempt_started',
'includefile'=> '/local/leaderboard/locallib.php',
'callback' => 'quiz_attempt_started',
'internal' => 1
),
array('eventname' => '\mod_quiz\event\attempt_submitted',
'includefile' => '/local/leaderboard/locallib.php',
'callback' => 'quiz_submitted_start'
),
);
在locallib.php中
function quiz_attempt_started($event) {
file_put_contents('/local/leaderboard/log.txt', $event);
//Logic Here
}
function quiz_submitted_start($event) {
file_put_contents('/local/leaderboard/log.txt', $event);
// Logic Here
}
调试就是moodle显示的错误。
PHP注意:在事件观察者'quiz_attempt_submitted'中遇到异常:检测到编码错误,必须由程序员修复:PHP捕获致命错误
- \ local \ leaderboard \ lib.php的第20行:调用default_error_handler()
- 线? of unknownfile:调用quiz_attempt_submitted()
- \ lib \ classes \ event \ manager.php的第155行:调用call_user_func()
- \ lib \ classes \ event \ manager.php第89行:致电 -
核心\事件\经理:: process_buffers()
- \ lib \ dml \ moodle_database.php的第2489行:调用core \ event \ manager :: database_transaction_commited()
- \ lib \ dml \ moodle_transaction.php第92行:调用moodle_database-> commit_delegated_transaction()
- \ mod \ quiz \ attemptlib.php的第2221行:调用moodle_transaction-> allow_commit()
- \ mod \ quiz \ processattempt.php第88行:调用quiz_attempt-> process_attempt()
在E:\ Moodle_Boost \ 03_Execution \ 04_Tech \ 03_Source Code \ lms \ lib \ weblib.php 3096行
这里注意到错误或结果。我忘了或做错了吗?