这些是开发者文档 - https://docs.moodle.org/dev/Main_Page
取决于您需要开发哪个插件 - https://docs.moodle.org/dev/Plugin_types
如果它是课程的一部分,那么您将需要开发一个活动模块 - https://docs.moodle.org/dev/Activity_modules
如果没有,那么您可能需要一个本地插件 - https://docs.moodle.org/dev/Local_plugins
更新:
使用本地插件并响应其中一个测验事件。
https://docs.moodle.org/dev/Event_2#Event_observers
这是一个概述:
创建一个本地插件 - https://docs.moodle.org/dev/Local_plugins
然后在local/yourpluginname/db/events/php 有类似的东西
defined('MOODLE_INTERNAL') || die();
$observers = array(
array(
'eventname' => '\mod_quiz\event\attempt_submitted',
'includefile' => '/local/yourpluginname/locallib.php',
'callback' => 'local_yourpluginname_attempt_submitted',
'internal' => false
),
);
这将在用户提交测验时响应attempt_submitted 事件。我猜这是您需要使用的事件。如果没有,那么这里还有其他人/mod/quiz/classes/event/
然后在/local/yourpluginname/locallib.php 有类似的东西
/**
* Handle the quiz_attempt_submitted event.
*
* @global moodle_database $DB
* @param mod_quiz\event\attempt_submitted $event
* @return boolean
*/
function local_yourpluginname_attempt_submitted(mod_quiz\event\attempt_submitted $event) {
global $DB;
$course = $DB->get_record('course', array('id' => $event->courseid));
$attempt = $event->get_record_snapshot('quiz_attempts', $event->objectid);
$quiz = $event->get_record_snapshot('quiz', $attempt->quiz);
$cm = get_coursemodule_from_id('quiz', $event->get_context()->instanceid, $event->courseid);
if (!($course && $quiz && $cm && $attempt)) {
// Something has been deleted since the event was raised. Therefore, the
// event is no longer relevant.
return true;
}
// Your code here to send the data to an external server.
return true;
}
这应该让你开始。