Import of content in Moodle / Validation

Hi,

we have a problem importing h5p-content into Moodle. Even if we download content that works in Moodle, and we download/export it as h5p-File, unzip it, then zip it again without changes and try to upload again (with suffix .h5p), we get the error "The file xy is not allowed. File type not allowed." We get these error message for every folder that the package includes. That happens on any OS.

Any idea?

Thanks!

Content types: 
otacke's picture

Hi Erik!

When you upload the file, H5P is complaining because it expects some flags to be set when zipping:

  -D do not add directory entries

  -X eXclude eXtra file attributes

On a command line, you'd use

zip -rDX myNewFile.h5p *

to pack all files in the current directory into a valid H5P content file named myNewFile.h5p.

Best,

Oliver

Thanks!

Okay, I managed it, thanks. That led me to another question, because now I get the error

- Missing valid directory
- Missing valid h5p.json

Is it not possible to add a new folder, for example with css styles? We added something like
{"machineName":"H5P.OurFolder","majorVersion":"1","minorVersion":"0"}]}
and the page works outside Moodle. We added the H5P.OurFolder and put the line above into h5p.json.

Is there something to know about it?

Thanks!

otacke's picture

Hi Erik! 

Not sure what you're trying to achieve, but what you are doing doesn't make sense ;-)

You can find the specification documented at https://h5p.org/documentation/developers/h5p-specification Mind the difference between content files (to be uploaded in the Content Hub) and library files (to be uploaded on the library settings page) that both bear the extension .h5p.

Short answer: No, you can currently not have your custom CSS to be shared with content. If you just need a custom stylesheet locally, you should check the documentation on customization at https://h5p.org/node/2692

Best,

Oliver 

Hi Oliver,
thanks again for your reply. Well, for us it makes sense to customize the content. If you create lessons with H5P, the design is very poor. And as a standalone solution our "re-design" works fine. Every lesson we create is an individual bundle of modules (e.g. H5P.JoubelUI, H5P.Question, etc) that we can export. So I cannot believe, that this is checked by Moodle file by file. And even if we change nothing, we get this directory error.

I very appreciate that you took the time to share the above information and I will check if it helps. And my first issue I could solve because of your hint.

Thanks and regards!

otacke's picture

Hi Erik!

I didn't say that customizing the design wouldn't make sense, but what you did in h5p.json.

You can customize the stylesheets as documented at https://h5p.org/node/2692 locally, but you currently cannot share that design. The downloadable files do not have space for custom designs. You could, of course, replace the original CSS in that file, but H5P still wouldn't load it if the libraries (library versions) thar are used by the content are already installed.

Best,

Oliver 

Best,

Oliver 

I followed those instructions: https://h5p.org/library-development

But I see the problem now. Its a very restricitve system.

otacke's picture

Compared to what?

---

We get the error even if we try to upload the package without any changes. Means, as described above, we export a package, unzip it, zipp it again without changing the content, and then get the error "valid directory missing" and "valid h5p.json missing"

otacke's picture

Could you please check if you zipped the folder (won't work) or all the files (should work)?

Thanks, Oliver, you made my day with your help :-) Zipping on the server worked, on Mac locally it was always packed in a folder. No more errors.

Thanks again!

 Its always with folder. When I am in 'myFiles' and type the command
zip -rDX myfiles.zip *
the zip contains the folder 'myFiles'. (on Mac with terminal.app)

Hi,

I encounter a similar problem when importing an h5p file (created in our own H5P editor) to a current Moodle:

I get the message "invalid-content-folder : Ein gültiger Inhaltsordner fehlt."

My h5p file is a zip file compressed by default PHP ZIP class, it has no D attribute and no extended attributes. As a very simple example I created a h5p chart with our own editor and compared it to the h5p chart from the H5P hub, that can be imported to Moodle. The attached screenshot shows my h5p on the left the file from the hub on the right. I can see no difference.

Any ideas what I'm missing here?

Thanks a lot

Hyper

 

H5P file: 
Attachments: 

Well, meanwhile I've hacked into the h5p.classes.php of the current Moodle and found that there is a comparison for a file "content/content.json".

When analyzing my h5p file (that was created using the very powerful and fast 7zip instead of PHP's ZipArchive) I can see that it contains only a file "content\content.json", i.e. a backslash and not a slash.

So, to overcome this very strict validation you need to make sure the zip file you create uses / as path delimiters and not \.