Skip to content

Generating a content id

Sebastian Rettig edited this page Nov 5, 2019 · 1 revision
  1. contentIds are integers and are not necessarily the same as the id of the CMS/LMS's content node. (Even though this would be possible if the ids of the CMS/LMS are integers too)
  2. They seem to be generated by the CMS/LMS (plugin). In the moodle implementation it is simply the auto-generated key of the database entry of a saved piece of content.
  3. When editing an existing content piece the contentId is passed to the editor in H5PIntegration.editor.nodeVersionId.
  4. When uploading images in already existing content, the contentId is in the property contentId of the request's body (form data). It is 0 if the user is creating new content. In both cases the image is uploaded to a global temporary location, though. I'm not sure how the PHP implementation keeps track of the connection between new uploaded images and the unsaved content (that only exists in the client at this point). It looks like this is connected to the current session and not to the contentId received through the body. I've checked in the Moodle implementation: If I upload an image in an unsaved piece of content and "abort" editing by opening other Moodle pages, I can still access the image by calling the temporary URL (http://moodle/pluginfile.php/XXXXXXX/mod_hvp/editor/images/file-5d61958f640a9.png). I don't have access to it once I've logged out of moodle or from another browser with the same user. So uploaded temporary images seem to exist at session scope (and are deleted through a timeout).
  5. When saving a new piece of content, the contentId is generated and there is a HTML redirect to the viewer (or to the course overview, depending on what the user clicked). There it is passed to the JavaScript client as described in 6.
  6. When viewing a piece of content, the contentId is passed to the JavaScript viewer by the plugin
    1. by setting an object to H5PIntegration.contents["cid-XXX"] and
    2. by setting a HTML property in