Hey there,
I am trying to get into moodle development and after doing the block tutorials and some own blocks I wanted to create a task, that downloads at a preset time a file from a link.
So I read the Task API page and followed the example.
I created a file scheduled_file_download_task.php with following content in moodleroot/lib/classes/task/
<?phpand added the following code into the tasks array of moodleroot/lib/db/tasks.php so that the end of the array looks like that
namespace block_mdev_block\task;
class scheduled_file_download_task extends \core\task\scheduled_task {
public function get_name() {
// Shown in admin screens
return get_string('scheduledfiledownload', 'block_mdev_block');
}
public function execute() {
echo "test";
}
}
array( 'classname' => 'core\task\sync_plans_from_template_cohorts_task', 'blocking' => 0, 'minute' => 'R', 'hour' => '*', 'day' => '*', 'dayofweek' => '*', 'month' => '*' ), array( 'classname' => 'block_mdev_block\task\scheduled_file_download_task', 'blocking' => 0, 'minute' => '5', 'hour' => '*', 'day' => '*', 'dayofweek' => '*', 'month' => '*' ), );Then I increased the version number of my block block_mdev_block, but I neither can find my task in admin settings (server > scheduled tasks) nor in the database table mdl_task_scheduled.
Can anyone help me finding my error?