kaltura / moodle_plugin

8 stars 37 forks source link

Kaltura resource error in "Default activity completion" #426

Open jaume77 opened 2 months ago

jaume77 commented 2 months ago

Hello,

Moodle version: 4.3.2 Kaltura plugin version: 2023100901

After installing the Kaltura plugin package, when accessing the "Default activity completion" page, the following error is displayed:

"Coding error detected, it must be fixed by a programmer: Cannot call moodle_page::add_body_class after output has been started."

image

Coding error detected, it must be fixed by a programmer: Cannot call moodle_page::add_body_class after output has been started.

[More information about this error](http://docs.moodle.org/403/en/error/debug/codingerror)

Debug info:
Error code: codingerror×Dismiss this notification
Stack trace:
line 1357 of /lib/pagelib.php: coding_exception thrown
line 42 of /mod/kalvidres/mod_form.php: call to moodle_page->add_body_class()
line 217 of /lib/formslib.php: call to mod_kalvidres_mod_form->definition()
line 127 of /course/moodleform_mod.php: call to moodleform->__construct()
line 96 of /completion/classes/defaultedit_form.php: call to moodleform_mod->__construct()
line 120 of /completion/classes/defaultedit_form.php: call to core_completion_defaultedit_form->get_module_form()
line 217 of /lib/formslib.php: call to core_completion_defaultedit_form->definition()
line 45 of /completion/classes/defaultedit_form.php: call to moodleform->__construct()
line 86 of /course/classes/output/bulk_activity_completion_renderer.php: call to core_completion_defaultedit_form->__construct()
line 97 of /course/defaultcompletion.php: call to core_course_bulk_activity_completion_renderer->defaultcompletion()

If the "Kaltura resource" activity is disabled, the page loads correctly.

The path to the page is "Site Administration" -> "Courses" -> "Default settings" -> "Default activity completion"

Greetings and thanks Jaume R.

simmonsgc commented 2 months ago

Is this the same issue as https://github.com/kaltura/moodle_plugin/issues/396 perhaps?

jaume77 commented 2 months ago

This error should have appeared in a previous version of the plugin, an attempt was made to solve it (the code of the version that I indicate, which is the latest available on moodle.org, is different), but in version 4.3 of Moodle, on the configuration page What I indicated, it still doesn't work.

In line 41 and 42 of the file mod_form.php, the code is :

...
$pageclass = 'kaltura-kalvidres-body';
$PAGE->add_body_class($pageclass);
...
jaume77 commented 1 month ago

Hi, It seems that by commenting line 42 of the file mod_form.php the error disappears.

...
$pageclass = 'kaltura-kalvidres-body';
//$PAGE->add_body_class($pageclass);
...

image

I don't know if there will be any "side" effects. Greetings

jaume77 commented 1 month ago

Speaking of "side effects"...

When applying the change, and commenting on the line, the "Default activity completion" screen is displayed correctly, and the activity creation form can be accessed correctly... except for the "Restrict access" section.

image

I have added an "if" in the code, to execute the line if it is in a course.

If id is 1 (we are in the environment administration) the line is not executed. If it is different than 1 (we are in a course), we execute it.

...
$pageclass = 'kaltura-kalvidres-body';
if($COURSE->id <> 1) {
     $PAGE->add_body_class($pageclass);
}
...

Waiting for a better solution.... :-)

Thanks! Jaume R.