Moodle 2.8 Scheduled Task question

Moodle 2.8 Scheduled Task question

by Clem Smith -
Number of replies: 4

I am working on creating a new scheduled task that is in a plug-in of its own. Moodle has detected the version.php file and lists it as a plug-in. However, it has not added the scheduled task - and I even increased the version number once to try to get it to find it. When I try to run it from the command line, I get this error:

Task '\local_plugin_name\task\plugin_class_name' not found

One thing that I can see *might* be a problem is that my plugin name has an underscore in it. So, it's "something_else", which makes the plug-in's namespace into "local_something_else". Any suggestions for what to look at or how I might fix this will be quite appreciated!

Average of ratings: -
In reply to Clem Smith

Re: Moodle 2.8 Scheduled Task question

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers
I think the name of the file is also important. Underscores are ok.
Look at other classes for how they do it. Two of my own, look like this..

For the ad_hoc task in the poodll filter.

In [Moodle]/filter/poodll/classes/task/adhoc_convert_media.php

namespace filter_poodll\task;
defined('MOODLE_INTERNAL') || die();
class adhoc_convert_media extends \core\task\adhoc_task

For a scheduled task in the waitinglist enrolment plugin (unreleased):
in [Moodle]/enrol/waitinglist/classes/task/waitinglisttask.php

namespace enrol_waitinglist\task;
class waitinglisttask extends \core\task\scheduled_task {

Hope that helps
In reply to Justin Hunt

Re: Moodle 2.8 Scheduled Task question

by Clem Smith -

Justin,

Thanks! That did the trick. It was a bad file name. So, I fixed that and then had to bump the version number of my plug-in and now Moodle is able to find it.

Thanks again!

Clem

In reply to Clem Smith

Re: Moodle 2.8 Scheduled Task question

by Damyon Wiese -
Here are the docs for namespaces if that helps. https://docs.moodle.org/dev/Automatic_class_loading

In reply to Damyon Wiese

Re: Moodle 2.8 Scheduled Task question

by Clem Smith -

Damyon,

Thank you for that link. I've now bookmarked it for ease of reference. I hadn't thought to look that up before I posted on Friday.

Clem