Incomplete saving of my content type data

Forums: 

Hello all,
as part of my bachelor thesis I am working on the content type H5P.RealityBox.
It should make it possible to integrate 3D models into learning environments, which can also be viewed on VR headsets and Google Cardboard using WebXR.

The corresponding github repositories can be found here:

https://github.com/rwth-acis/h5p-realitybox
https://github.com/rwth-acis/h5p-babylonbox
https://github.com/rwth-acis/h5p-editor-realitybox

For the creation of the editor I followed the example of H5PEditor.InteractiveVideo.
The editor works so far, but I can't handle it to save the annotations that can be added to a model. All other things like the uploaded file and other additional information are saved.

I haven't noticed anything unusual during debugging: Right before sending, all options, including those of the annotations, are written into the hidden input field "json_content" and then sent to the server. But in the MySQL table the object was stored without the key "annotations".

Does anyone have an idea what this could be. All other content types, like Interactive Video can be saved without problems.

For the development I am using Drupal 7 together with the development folder.

 

Kind regards

jballmann

Content types: 
otacke's picture

Hi jballmann!

As far as I can see from a glimpse at your code, your editor widget is not calling the setValue callback function when you would want to inform the editor about value changes.

Best,
Oliver

Hi Oliver,
thank you for your quick response.

As it looks, the complete content is stored in the MySQL table in the column "json_content", but not in the column "filtered", which is used to call the constructor.

I have no idea where exactly is filtered by. But any content from H5PEditor.RealityBox is not there anymore.

Kind regards
Johannes

otacke's picture

Hi Johannes!

The filtered column stores the result of processing and validating the json_content. Illegal values that are not meeting the specification for the particular field type (and empty arrays and empty objects AFAIR) will be removed, text may be HTML encoded, etc., cmp. https://h5p.org/semantics.

Best,
Oliver

Hi Oliver,
I have checked my semantics.json several times, but I can't find any error that could trigger this.

For the lists I didn't specify the mandatory fields label and entity, but this shouldn't be a problem because it wasn't done for Interactive Video either.

Here is an example for "json_content"

{
  "realitybox": {
    "assets": {
      "annotations": [
        {
          "position": {
            "x": 0.9602248603189909,
            "y": 1.2819426833458092,
            "z": -0.6875340843704913
          },
          "normalRef": {
            "x": -0.4226183028320243,
            "y": 0,
            "z": 0.9063077678754494
          },
          "content": {
            "library": "H5P.Column 1.13",
            "params": {
              "content": [
                {
                  "content": {
                    "params": {
                      "text": "<p>hello world<\\/p>\n"
                    },
                    "library": "H5P.AdvancedText 1.1",
                    "metadata": {
                      "contentType": "Text",
                      "license": "U",
                      "title": "Untitled Text",
                      "authors": [],
                      "changes": []
                    },
                    "subContentId": "43e09dd4-e464-4c14-9395-7c05fb900828"
                  },
                  "useSeparator": "auto"
                }
              ]
            },
            "subContentId": "9c5da170-08ef-408d-937c-7c55e3bd7ea5",
            "metadata": {
              "contentType": "Column",
              "license": "U",
              "title": "annotation1",
              "authors": [],
              "changes": [],
              "extraTitle": "annotation1"
            }
          },
          "id": "077c7d7c-1f6e-4ddf-b7a9-2ba806818654"
        }
      ]
    },
    "settings": {},
    "model": {
      "path": "files\\/file-6078455325db0.txt#tmp",
      "mime": "text\\/plain",
      "copyright": {
        "license": "U"
      }
    }
  }
}

 

And this is what comes out when filtered

{
  "realitybox": {
    "settings": {},
    "model": {
      "path": "files\\/file-6078455325db0.txt",
      "mime": "text\\/plain",
      "copyright": {
        "license": "U"
      }
    }
  }
}

 

Is it possible to find out somewhere why something was filtered out e.g. by error message or log?
And is everything ignored if, in the object somewhere an error occurs or only all contents within the incorrect object?

Kind regards
Johannes

otacke's picture

Hi Johannes!

I assume that filter function is in the H5PEditor core and passed its results to the plugin, but I don't know where exactly.

Best,
Oliver

otacke's picture

Out of curiosity I just had a quick look. I suppose that https://github.com/h5p/h5p-php-library/blob/master/h5p.classes.php#L2234 does the validation.

Hi Oliver,
thanks for the hint.

After logging every single validation function, I realized that you declare lists only with an array (without specifying the name).
I have modified H5PEditor.RealityBox accordingly.

Kind regards
Johannes

- - -

For explanation:

This is how json_content must look like:

{
  "realitybox": {
    "assets": [
      {
        "position": {
          "x": 0.8461366379573472,
          "y": 1.1334576679787236,
          "z": -0.7407343024604538
        },
        "normalRef": {
          "x": -0.4226183028320243,
          "y": 0,
          "z": 0.9063077678754494
        },
        "content": {
          "library": "H5P.Column 1.13",
          "params": {
            "content": [
              {
                "content": {
                  "params": {
                    "text": "<p>hello world<\\/p>\n"
                  },
                  "library": "H5P.AdvancedText 1.1",
                  "metadata": {
                    "contentType": "Text",
                    "license": "U",
                    "title": "Untitled Text",
                    "authors": [],
                    "changes": []
                  },
                  "subContentId": "6c66c2ae-c412-4bf7-892b-8b8120c109c1"
                },
                "useSeparator": "auto"
              }
            ]
          },
          "subContentId": "f9c903f1-ec65-448a-9073-acf369deb110",
          "metadata": {
            "contentType": "Column",
            "license": "U",
            "title": "Untitled Column",
            "authors": [],
            "changes": [],
            "extraTitle": "Untitled Column"
          }
        },
        "id": "ced1f269-1c97-4e7d-91d1-3d850a40803f"
      }
    ],
    "settings": {},
    "model": {
      "path": "files\\/file-6079b81c5a44d.txt#tmp",
      "mime": "text\\/plain",
      "copyright": {
        "license": "U"
      }
    }
  }
}

Instead of:

{
  "realitybox": {
    "assets": {
      "annotations": [
        {
          "position": {
            "x": 0.8461366379573472,
            "y": 1.1334576679787236,
            "z": -0.7407343024604538
          },
          "normalRef": {
            "x": -0.4226183028320243,
            "y": 0,
            "z": 0.9063077678754494
          },
          "content": {
            "library": "H5P.Column 1.13",
            "params": {
              "content": [
                {
                  "content": {
                    "params": {
                      "text": "<p>hello world<\\/p>\n"
                    },
                    "library": "H5P.AdvancedText 1.1",
                    "metadata": {
                      "contentType": "Text",
                      "license": "U",
                      "title": "Untitled Text",
                      "authors": [],
                      "changes": []
                    },
                    "subContentId": "6c66c2ae-c412-4bf7-892b-8b8120c109c1"
                  },
                  "useSeparator": "auto"
                }
              ]
            },
            "subContentId": "f9c903f1-ec65-448a-9073-acf369deb110",
            "metadata": {
              "contentType": "Column",
              "license": "U",
              "title": "Untitled Column",
              "authors": [],
              "changes": [],
              "extraTitle": "Untitled Column"
            }
          },
          "id": "ced1f269-1c97-4e7d-91d1-3d850a40803f"
        }
      ]
    },
    "settings": {},
    "model": {
      "path": "files\\/file-6079b81c5a44d.txt#tmp",
      "mime": "text\\/plain",
      "copyright": {
        "license": "U"
      }
    }
  }
}