Search code examples
phpmoodlemoodle-mobile

Local Plugin tasks are not showing up in the schedule tasks list in moodle


I have made a local plugin. It is installed and shows up under plugins as well as created its initial tables etc, but the task is not appearing in task list.

$tasks = array(
    array(
        'classname' => 'tool_mobilechathelper\task\sync_chats',
        'blocking' => 0,
        'minute' => 0,
        'hour' => 22,
        'day' => '*',
        'dayofweek' => '*',
        'month' => '*'
    ),
);

enter image description here


Solution

  • Try it this way, the time values should be strings not numbers. They have to match the syntax of unix cron, blocking should stay the same though.

    $tasks = array(
        array(
            'classname' => 'tool_mobilechathelper\task\sync_chats',
            'blocking' => 0,
            'minute' => '0',
            'hour' => '22',
            'day' => '*',
            'dayofweek' => '*',
            'month' => '*'
        ),
    );
    

    Also, make sure to have namespace in your task class,

    namespace tool_mobilechathelper\task;
    

    and upgrade your version.php, then run php admin/cli/upgrade.php.