Skip to content

Conversation

@clpetersonucf
Copy link
Member

Adds the H5P URL to the list of parameters passed to the Materia engine core via the initWidget postMessage

Enables the Materia.Engine.getH5PUrl() method to be callable from H5P widgets

Paired with ljoks/Materia#3

ljoks
ljoks previously approved these changes Apr 11, 2022
@clpetersonucf clpetersonucf changed the base branch from master to dev/2.5.0 April 11, 2022 20:50
@clpetersonucf clpetersonucf dismissed ljoks’s stale review April 11, 2022 20:50

The base branch was changed.

Copy link
Contributor

@FrenjaminBanklin FrenjaminBanklin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming there’s a corresponding change in Materia to write H5P_URL into the global scope, and assuming anything relying on the cores' getH5PUrl functions is okay with them returning undefined, this looks okay to me.

The only nits I would pick: if the creator controller is no longer checking for .swf widgets, the player controller probably shouldn't be checking for them any more, either. And the suggested change to the creator controller, but that's not really necessary.

Comment on lines +144 to +145
if (inst_id != null) sendToCreator('initExistingWidget', [instance.name, instance.widget, keepQSet.data, keepQSet.version, BASE_URL, MEDIA_URL, H5P_URL])
else sendToCreator('initNewWidget', [widget_info, BASE_URL, MEDIA_URL, H5P_URL])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works in two lines but it's a little harder to read. More verbosity would make it clearer, but would also bloat it a little. Fine either way.

Suggested change
if (inst_id != null) sendToCreator('initExistingWidget', [instance.name, instance.widget, keepQSet.data, keepQSet.version, BASE_URL, MEDIA_URL, H5P_URL])
else sendToCreator('initNewWidget', [widget_info, BASE_URL, MEDIA_URL, H5P_URL])
let creatorMethod = 'initNewWidget'
let args = [BASE_URL, MEDIA_URL, H5P_URL]
if (inst_id != null) {
creatorMethod = 'initExistingWidget'
args = [
instance.name,
instance.widget,
keepQSet.data,
keepQSet.version,
...args
]
} else {
args = [widget_info, ...args]
}
sendToCreator(creatorMethod, args)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants