True/False question's dependency on Video 1.3


Starting a new thread for this particular problem. I am making the .Net implementation (this thread and am now expanding the content types supported. I am trying to create an instance of the True/False question with a video file attached. The editor works just fine with the current implementation, but when trying to view the content, it fails since the reference to the H5P.Video-1.3 is missing. This reference is not mentioned anywhere in the preload dependencies of the content type? Is this a bug? Neither is H5P.Image which is the other attachable media type.


I did find that the content.json file produced has a media.library property which references the video content type, but how is this supposed to be detected? Is there a described standard by which these additional resources can be identified? Any documentation, or at least a pointer to the php code where this is done?


There also doesn't seem to be anything in the .js files for H5P.TrueFalse-1.2 which would dynamically request these additional dependencies, so they should be included in the cache package?

It would appear that when creating the .js and .css cache files, you need to scan the content.json file for any property named library and add the library named in it to the dependencies. I assume this is done so you don't load up dependencies unnecessarily, however it does feel a bit obfuscated and unintuitive. Especially as these library attributes can be found within all kinds of properties. What if the system doesn't even have that library saved to it, since it wasn't listed in the dependencies?


Anyway, managed to solve my problem, so moving on. The code for finding these content dependencies is listed below, in case someone else needs it. Written in C#.


var regex = new System.Text.RegularExpressions.Regex("(?<=\"library\":\").*?(?=\")");
var contentDependencies = new List<Tuple<string,int,int>>();
foreach (System.Text.RegularExpressions.Match match in regex.Matches(content_json))
    var firstSplit = match.Value.Split(' ');
    var secondSplit = firstSplit[1].Split('.');
    contentDependencies.Add(new Tuple<string, int, int>(firstSplit[0], int.Parse(secondSplit[0]), int.Parse(secondSplit[1])));
BV52's picture

Hi MiikaLangille,

Thank you for the information and I'm sorry the core team is taking some time answering posts. There is a big push to get released before summer.


Hi BV52,

Not a problem at all. Was able to solve this particular problem by myself. Just posting them publicly in case they might help others who are making their own implementations or integrations.

otacke's picture

Hi Miika!

Just to wrap it up: There are library dependencies that are crucial for H5P content or its editor to work. Those are listed in library.json.

Furthermore, there are dependencies that are optional/their necessity depends on the choice of the content author. when editing. Those are loaded dynamically as needed, but can be identified in advance by looking at the fields that have the type library. These will also have a field called options that may contain further dependencies that are not loaded yet -- and may have additional dependencies themselves.

For example, the editor of True-False-Question will always need the RadioGroup Widget for the answer, that's found in library.json. A True-False-Question can also have an optional image or video above of the question that can be set in the editor and is defined in semantics.json by

    "name": "media",
    "type": "group",
    "label": "Media",
    "importance": "medium",
    "fields": [
        "name": "type",
        "type": "library",
        "label": "Type",
        "importance": "medium",
        "options": [
          "H5P.Image 1.0",
          "H5P.Video 1.4"
        "optional": true,
        "description": "Optional media to display above the question."

This will only load as needed, and that's why you have to wait briefly when you optionally want to set an image or a video in the editor.

I hope that was clear enough?