Comments field on H5P import
Hi,
I am using AI to generate python script to extract content from a .docx file and convert it to H5P format (H5P example attached) - for Course Presentation.
Overall we are having success, but are having trouble getting the "comments" field to show and get the "Always Show Comments" box checked for embedded images.
Our uploaded structure matches the structure in downloaded H5P test files, but we still can't seem to make it work. Ideas? Or is this a known issue?
Below is the relevant section of script if it is helpful. The Alt Text and Hover Text fields are appearing just fine:
if image_folder:
image_file = get_matching_image(slide["match_title"], image_folder)
if image_file:
src = os.path.join(image_folder, image_file)
dst = os.path.join(output_dir, "content", "images", image_file)
compress_image(src, dst)
elements.append({
"x": IMAGE_BOX_LAYOUT["x"],
"y": IMAGE_BOX_LAYOUT["y"],
"width": IMAGE_BOX_LAYOUT["width"],
"height": IMAGE_BOX_LAYOUT["height"],
"action": {
"library": "H5P.Image 1.1",
"params": {
"file": {"path": f"images/{image_file}"},
"decorative": False,
"alt": slide.get("alt", ""),
"title": slide.get("hover", ""),
"copyright": {
"license": "U",
"comment": slide.get("comment", "")
},
"alwaysShowComment": bool(slide.get("comment", ""))
},
"metadata": {"title": slide.get("hover", ""), "license": "U", "contentType": "Image"}
}
})
otacke
Fri, 06/20/2025 - 12:31
Permalink
Hi!"Our uploaded structure
Hi!
"Our uploaded structure matches the structure in downloaded H5P test files" - no, it does not.
I am pretty sure that no developer in his or her right mind is going to be in the mood to debug stupid AI generated code in his or her spare time. Lucky for you, I am a little crazy.
The `alwaysShowComment` property is set on the parameters of `H5P.Image`, but H5P.Image does not use that property. It needs to be set on the element parameters belonging to Course Presentation.
It's even worse for `comment` which is put into the `copyright` section of H5P.Image. It's not valid there or elsewhere. The correct property name for comments is `solution` and also needs to be put among the element parameters of Course Presentation.
Best,
Oliver