LMSFACTORY / local_moofactory_notification

1 stars 1 forks source link

Error during the scheduled task's run with new update #1

Open mciotti opened 4 months ago

mciotti commented 4 months ago

Hello, I updated to the latest version of the plugin (2024031800) and the scheduled task "Sending notifications in the event of non-access to courses for a certain time" ( \local_moofactory_notification\task\send_coursesaccess_notification) get this error: Argument #2 ($callback) must be a valid callback, function "format_moofactory_compare_times" not found or invalid function name.

I'm currently using the 4.4 Moodle's version with Postgresql db.

Here the run's log: Execute scheduled task: Sending notifications in the event of non-access to courses for a certain time (local_moofactory_notification\task\send_coursesaccess_notification) ... started 03:07:15. Current memory use 4.5 MB. ... used 15 dbqueries ... used 0.13260388374329 seconds Scheduled task failed: Sending notifications in the event of non-access to courses for a certain time (local_moofactory_notification\task\send_coursesaccess_notification),usort(): Argument #2 ($callback) must be a valid callback, function "format_moofactory_compare_times" not found or invalid function name Backtrace:

Thank you in advance for the support

guillefd commented 2 weeks ago

These are the missing functions, for a quick patch modify /moofactory_notification/lib.php file as needed

  1. add this lines
    
    /**
    * Used to compare two activities/resources based on order on course page
    *
    * @param array $a array of event information
    * @param array $b array of event information
    * @return <0, 0 or >0 depending on order of activities/resources on course page
    */
    function local_moofactory_compare_events($a, $b) {
    if ($a['section'] != $b['section']) {
        return $a['section'] - $b['section'];
    } else {
        return $a['position'] - $b['position'];
    }
    }

/**

  1. line 712 > modify
    // Sort by first value in each element, which is time due.
    if ($forceorder == 'orderbycourse' || ($config && $config->orderby == 'orderbycourse')) {
    usort($activities, 'local_moofactory_compare_events');
    } else {
    usort($activities, 'local_moofactory_compare_times');
    }