xAPI-vle / moodle-logstore_xapi

A Moodle plugin to send xAPI statements to an LRS using events in the Moodle logstore.
GNU General Public License v3.0
75 stars 84 forks source link

deprecation warnings still shown on Moodle 4.1.10+ #857

Open jpahullo opened 4 months ago

jpahullo commented 4 months ago

Description

Version

Steps to reproduce the bug

  1. Enable developer level debug on Moodle.
  2. Uninstall plugin if exists from web administration. Delete files completely. Purge caches. See that no warning appear when going to administration page.
  3. Install plugin from master branch from github.
  4. Go to administration page
  5. See these deprecation warnings:
core\event\content_viewed has been deprecated. Please extend base event or other relevant abstract class.
line 32 of /lib/classes/event/content_viewed.php: call to debugging()
line 137 of /lib/classes/component.php: call to include_once()
line ? of unknownfile: call to core_component::classloader()
line 920 of /lib/classes/component.php: call to class_exists()
line 62 of /report/eventlist/classes/list_generator.php: call to core_component::get_component_classes_in_namespace()
line 101 of /admin/tool/log/store/xapi/src/transformer/get_event_function_map.php: call to report_eventlist_list_generator::get_all_events_list()
line 133 of /admin/tool/log/store/xapi/settings.php: call to src\transformer\get_event_function_map()
line 90 of /admin/tool/log/classes/plugininfo/logstore.php: call to include()
line 46 of /admin/tool/log/settings.php: call to tool_log\plugininfo\logstore->load_settings()
line 81 of /lib/classes/plugininfo/tool.php: call to include()
line 735 of /admin/settings/plugins.php: call to core\plugininfo\tool->load_settings()
line 8878 of /lib/adminlib.php: call to require()
line 8759 of /lib/adminlib.php: call to admin_get_root()
line 28 of /admin/search.php: call to admin_externalpage_setup()
core\event\course_module_instances_list_viewed has been deperecated. Please use core\event\course_module_instance_list_viewed instead
line 31 of /lib/classes/event/course_module_instances_list_viewed.php: call to debugging()
line 137 of /lib/classes/component.php: call to include_once()
line ? of unknownfile: call to core_component::classloader()
line 920 of /lib/classes/component.php: call to class_exists()
line 62 of /report/eventlist/classes/list_generator.php: call to core_component::get_component_classes_in_namespace()
line 101 of /admin/tool/log/store/xapi/src/transformer/get_event_function_map.php: call to report_eventlist_list_generator::get_all_events_list()
line 133 of /admin/tool/log/store/xapi/settings.php: call to src\transformer\get_event_function_map()
line 90 of /admin/tool/log/classes/plugininfo/logstore.php: call to include()
line 46 of /admin/tool/log/settings.php: call to tool_log\plugininfo\logstore->load_settings()
line 81 of /lib/classes/plugininfo/tool.php: call to include()
line 735 of /admin/settings/plugins.php: call to core\plugininfo\tool->load_settings()
line 8878 of /lib/adminlib.php: call to require()
line 8759 of /lib/adminlib.php: call to admin_get_root()
line 28 of /admin/search.php: call to admin_externalpage_setup()
core\event\role_capabilities_updated has been deprecated. Please use core\event\capability_assigned instead
line 31 of /lib/classes/event/role_capabilities_updated.php: call to debugging()
line 137 of /lib/classes/component.php: call to include_once()
line ? of unknownfile: call to core_component::classloader()
line 920 of /lib/classes/component.php: call to class_exists()
line 62 of /report/eventlist/classes/list_generator.php: call to core_component::get_component_classes_in_namespace()
line 101 of /admin/tool/log/store/xapi/src/transformer/get_event_function_map.php: call to report_eventlist_list_generator::get_all_events_list()
line 133 of /admin/tool/log/store/xapi/settings.php: call to src\transformer\get_event_function_map()
line 90 of /admin/tool/log/classes/plugininfo/logstore.php: call to include()
line 46 of /admin/tool/log/settings.php: call to tool_log\plugininfo\logstore->load_settings()
line 81 of /lib/classes/plugininfo/tool.php: call to include()
line 735 of /admin/settings/plugins.php: call to core\plugininfo\tool->load_settings()
line 8878 of /lib/adminlib.php: call to require()
line 8759 of /lib/adminlib.php: call to admin_get_root()
line 28 of /admin/search.php: call to admin_externalpage_setup()
mod_lesson\event\highscore_added has been deprecated. Since the functionality no longer resides in the lesson module.
line 31 of /mod/lesson/classes/event/highscore_added.php: call to debugging()
line 137 of /lib/classes/component.php: call to include_once()
line ? of unknownfile: call to core_component::classloader()
line 920 of /lib/classes/component.php: call to class_exists()
line 62 of /report/eventlist/classes/list_generator.php: call to core_component::get_component_classes_in_namespace()
line 101 of /admin/tool/log/store/xapi/src/transformer/get_event_function_map.php: call to report_eventlist_list_generator::get_all_events_list()
line 133 of /admin/tool/log/store/xapi/settings.php: call to src\transformer\get_event_function_map()
line 90 of /admin/tool/log/classes/plugininfo/logstore.php: call to include()
line 46 of /admin/tool/log/settings.php: call to tool_log\plugininfo\logstore->load_settings()
line 81 of /lib/classes/plugininfo/tool.php: call to include()
line 735 of /admin/settings/plugins.php: call to core\plugininfo\tool->load_settings()
line 8878 of /lib/adminlib.php: call to require()
line 8759 of /lib/adminlib.php: call to admin_get_root()
line 28 of /admin/search.php: call to admin_externalpage_setup()
mod_lesson\event\highscores_viewed has been deprecated. Since the functionality no longer resides in the lesson module.
line 31 of /mod/lesson/classes/event/highscores_viewed.php: call to debugging()
line 137 of /lib/classes/component.php: call to include_once()
line ? of unknownfile: call to core_component::classloader()
line 920 of /lib/classes/component.php: call to class_exists()
line 62 of /report/eventlist/classes/list_generator.php: call to core_component::get_component_classes_in_namespace()
line 101 of /admin/tool/log/store/xapi/src/transformer/get_event_function_map.php: call to report_eventlist_list_generator::get_all_events_list()
line 133 of /admin/tool/log/store/xapi/settings.php: call to src\transformer\get_event_function_map()
line 90 of /admin/tool/log/classes/plugininfo/logstore.php: call to include()
line 46 of /admin/tool/log/settings.php: call to tool_log\plugininfo\logstore->load_settings()
line 81 of /lib/classes/plugininfo/tool.php: call to include()
line 735 of /admin/settings/plugins.php: call to core\plugininfo\tool->load_settings()
line 8878 of /lib/adminlib.php: call to require()
line 8759 of /lib/adminlib.php: call to admin_get_root()
line 28 of /admin/search.php: call to admin_externalpage_setup()

Expected behaviour

Actual behaviour

Server information

Client information

Additional information

jpahullo commented 4 months ago

I have checked the Moodle path for some of those events, like in:

https://github.com/moodle/moodle/tree/main/lib/classes/event

in particular:

https://github.com/moodle/moodle/blob/MOODLE_401_STABLE/lib/classes/event/content_viewed.php

and yes, there is the deprecation message.

If I understand it correctly, since this plugin collects all possible events in Moodle, we will see these deprecation messages, unfortunately.

So, maybe it is not a problem really. Maybe we just need to know that this deprecation warnings appear if developer level debug is activated on Moodle.

jpahullo commented 4 months ago

The real problem, maybe, is that these deprecation messages appear everywhere, on every single page from administration menu and also on the Moodle Home page (moodle.url/). These deprecation messages do not appear on the moodle.url/my/ page nor on moodle.url/my/courses.php.

Should these deprecation messages appear only when editing the plugin parameters and while running the scheduled task, if the developer level debug is activated?

It is like the plugin is loaded on every single page.

If we are telling the plugin that the events will be sent through scheduled task, maybe there is no need to load the plugin on every page.

I do no know, just mentioning it.

Thanks,

Jordi

jpahullo commented 4 months ago

What I detected also is that events from deprecation messages does not appear on the list of candidate events to send into the LRS. So, the list of events eligible to be sent into LRS seems correct.

The only problem is regarding seeing everywhere the deprecation messages.

Without this plugin, it does not happen.

Thanks,

Jordi

jpahullo commented 4 months ago

I have reached to know why this debugging messages are shown.

In our Moodle we make use of $CFG->debugusers = '...';. In the debugging() function, it is considered as $forceddebug if this variable is set and the current user is in that list of users.

My idea was what it is actually done already on the core:

https://github.com/moodle/moodle/blob/main/report/eventlist/classes/list_generator.php#L47-L52

However, I realize that having the $CFG->debugusers in use, it has no effect.

Would you like to be provided with a patch like this?

diff --git a/admin/tool/log/store/xapi/src/transformer/get_event_function_map.php b/admin/tool/log/store/xapi/src/transformer/get_event_function_map.php
index 4a325584277..1ed74740e03 100644
--- a/admin/tool/log/store/xapi/src/transformer/get_event_function_map.php
+++ b/admin/tool/log/store/xapi/src/transformer/get_event_function_map.php
@@ -97,8 +97,12 @@ function get_event_function_map() {
         '\totara_program\event\program_assigned' => 'totara_program\program_assigned'
     ];

+    global $CFG;
+    $debugusers = $CFG->debugusers;
+    $CFG->debugusers = '';
     $environmentevents = class_exists("report_eventlist_list_generator") ?
         array_keys(\report_eventlist_list_generator::get_all_events_list(false)) : array_keys($availableevents);
+    $CFG->debugusers = $debugusers;

     return array_filter($availableevents, function($k) use ($environmentevents) {
         return in_array($k, $environmentevents);

With this patch, we do not see any debugging message while navigating through administration options. It is really annoying.

What do you think?

Jordi

jpahullo commented 4 months ago

Finally, we have added this patch #858 to our Moodle site, so that we would like to contribute it to you and this plugin.

Thanks a lot for your support.

Jordi