moodlehq / moodle-tool_migratehvp2h5p

Tool to migrate mod_hvp to Moodle 3.9 mod_h5pactivity modules
Other
5 stars 10 forks source link

Execution error on migrated H5V activities #24

Open jibecc opened 3 years ago

jibecc commented 3 years ago

Hi, I've migrate H5P contents during an update from Moodle 3.5.6 to Moodle 3.9.3. Before, I've update the HVP plugin to the latest version 1.21.0. The migration had doing without error.

After migration, on new H5P activites there is the folowing errors when I launch the activities: invalid-content-folder : A valid content folder is missing invalid-h5p-json-file : A valid main h5p.json file is missing

I can resolve this with the folowing procedure:

My questions are:

Best regards,

Jacques.

jmerrill86 commented 3 years ago

I've run into this as well, and it looks like the H5P activities on disk are zero byte H5P files. I can narrow down which activities have this issue with the following query:

select a.course_context_id, a.instance
from (
         select mcm.id as module_instanceid, mh5p.name, mcm.instance, ctx.id as course_context_id
         from mdl_context ctx
                  inner join mdl_course_modules mcm on mcm.course = ctx.instanceid and contextlevel = 50
                  inner join mdl_modules mm on mcm.module = mm.id
                  inner join mdl_h5pactivity mh5p on mcm.instance = mh5p.id
             and mm.name = 'h5pactivity'
         order by course_context_id) as a
         inner join mdl_context ctx on a.module_instanceid = ctx.instanceid and ctx.contextlevel = 70
         inner join mdl_files fil on ctx.id = fil.contextid
where fil.filesize = 0
  and fil.mimetype = 'application/zip.h5p'
group by a.module_instanceid, a.instance;

And then quickly load and save the activity types in the edit content bank PHP page.

MOODLE_SITE/contentbank/edit.php?contextid=COURSE_CONTEXT_ID&plugin=h5p&id=INSTANCE

Once they're saved as new objects, reference IDs are created on new files table records to the files_reference table, and the newly created .h5p files are loaded with the content and directory structure you would expect.

jibecc commented 3 years ago

Hi, Thanks for your return, inkjet2000. I've try your method.

It's OK with the query, I obtain a table like this (the two first lines):

course_context_id | instance |   1360 | 1 1360 | 2

These two instances are realy two H5P activities with the problem.

And for test, I do the following PHP command: MOODLE_SITE/contentbank/edit.php?contextid=1360&plugin=h5p&id=1

The return is: [1] 12984 [2] 12985 Could not open input file: edit.php?contextid=1360

Have you an idea about this error?

Best regards,

Jacques.

jibecc commented 3 years ago

Hi, I come back on my last post.

I'had not understand that the command MOODLE_SITE/contentbank/edit.php?contextid=COURSE_CONTEXT_ID&plugin=h5p&id=INSTANCE must do in browser.

This URL diplay the page where I can save the H5P activity. And it's OK to resolv the issue, but only each time for one instance.

On the moodle there are 662 H5P instances with the problem! Therefore I search a bulk method for this issue.

Thanks for tour help.

Best regards.

Jacques.

sarjona commented 3 years ago

Hi @jibecc and @inkjet2000!

Thanks for reporting this and sharing your findings! I've tried to reproduce the error (because it seems you're not the only one with some issues with the new CB features: https://github.com/moodlehq/moodle-tool_migratehvp2h5p/issues/23).

Could you please check if it's happening always with the same content type and share more information about your environment (DB, PHP)? That's not the expected behaviour and it's annoying to edit all these activities from the content bank so being able to reproduce it (because it's working in my local environment), will help to fix the issue for sure ;-)

Thanks in advance!

jibecc commented 3 years ago

Hi sarjona, Tanks for your work about this issue.

Following more details about our context.

We have at least three Moodle instances with this issue. They have respectivly 686, 187 and 177 instances H5P concerned. I presume that there are different types of H5P activities used.

For the technic features :

Do not hesitate to ask me for other informations if you need.

Best regards,

Jacques.

durzo commented 3 years ago

I wrote a python script that emulates a web browser and automates clicking Edit + Save to fix this issue, you can find it here: https://gist.github.com/durzo/7ea2a92646d7c8cecba16144f96cfe48

It takes a csv file and instructions to generate the file are at the top of the script.

This should be a temporary workaround until the issue is fixed in the migration tool.

sarjona commented 3 years ago

@jibecc thanks for the information. One more question: is that happening in all the H5P activities or only in some content-types? I've tried to reproduce the issue upgrading to 3.9.3 using "Interactive video" and "Arithmetic quiz" and it has worked as expected in both cases.

BTW, @durzo, thanks for sharing this useful script.

jibecc commented 3 years ago

@sarjona On the three Moodle instances where we have the issue, there are any content-types of H5P activities with the issue. "Interactive video" and "Arithmetic quiz" are in this case. I believe the content-type is not a criteria.

Best reagrds,

Jacques.

sarjona commented 3 years ago

Thanks Jacques for checking that. As I can't reproduce the error, it's hard to see what's happening. Last Friday I fixed https://github.com/moodlehq/moodle-tool_migratehvp2h5p/issues/23 but I think this is a different issue (because it shouldn't happen in 3.9.2 onwards). Any information to reproduce this issue would help us to identify and fix it :-)

Tottebee commented 2 years ago

Hi Sarjona, we are actual trying to migrate our h5p activities. the author problem seems to be solved now. But when migrating e.g. "drag the words" Moodle says after migrating : " Invalid-library-json-file : Could not find library.json file with valid json format for library H5P.DragText-1.8 library-missing-file : The file "css/joubel-score-bar.css" is missing from library: "H5P.JoubelUI-1.3""

Debug output: Warning: file_get_contents(/var/www/VirtHosts/fbdc0e7f-c892-46bc-9afd-e7b06e95e0e9/data/upload/moodledata_mess/localcache/e61db31f-64f6-4c16-aabc-0ca63897c550/f6ad03f0-8a86-4cb0-bd24-3172b04cbebf/h5p-619ca6fc7bb79/H5P.DragText-1.8/library.json): failed to open stream: No such file or directory in /var/www/VirtHosts/fbdc0e7f-c892-46bc-9afd-e7b06e95e0e9/data/htdoc/moodle_mess/h5p/h5plib/v124/joubel/core/h5p.classes.php on line 1444

The library itsself is installed and i found no way to convince moodle to update or reload the library to get the missing file. We are using 3.9.11 PHP7.3 on CentOS. Maybe this can help to solve this problems regards Thorsten