Is there a "correct" way of using JavaScript inside course module info content?
I developing a video activity plugin that makes use of bootstraps modal dialog to display the video. To make the video pause when the modal dialog is closed I insert inline JS code directly in the cached_cm_info content variable inside the video_get_coursemodule_info function like this:
$info->content .= html_writer::script("
$('#$modalid').on('hide.bs.modal', function () {
jwplayer('mod_video_player_$video->id').pause(true);
});
");
A $PAGE->require() does not work because the video_get_coursemodule_info is only called if the course module info is not in the cache.
I would prefer to make use of an AMD module to correctly request jQuery and bootstrap as a dependency. At the moment the plugin needs jQuery and bootstrap loaded globally by the theme.