创建 Moodle 插件

Creating Moodle plugin

我想控制测试中用户在做什么(点击回答、完成测试等)?可能吗?

我认为,为此任务需要创建插件吗?我对吗? 亲爱的社区,你能帮我一些吗 material - 如何开发插件?也许可以推荐一些网站或文章?因为现在我不明白这个过程。

比如我知道Moodle需要安装插件?但是在安装之前在哪里创建插件?在moodle也?但是如何在 Moodle 插件中导出到安装包?

对我来说很重要的问题-如何创建带插件的安装包,其他用户可以安装它。

不好意思问了很多,谢谢你的帮助。

这些是开发者文档 - https://docs.moodle.org/dev/Main_Page

取决于你需要开发哪个插件 - https://docs.moodle.org/dev/Plugin_types

如果它是课程的一部分,那么您将需要开发一个 activity 模块 - 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;
}

这应该让你开始。