{"id":56503,"date":"2023-01-24T20:22:19","date_gmt":"2023-01-24T14:52:19","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=56503"},"modified":"2023-01-24T20:22:19","modified_gmt":"2023-01-24T14:52:19","slug":"h5p-support-and-integration-with-drupal","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/h5p-support-and-integration-with-drupal\/","title":{"rendered":"H5P support and integration with Drupal"},"content":{"rendered":"<h2>What is H5P?<\/h2>\n<p><span style=\"font-weight: 400;\">H5P is an open-source software platform that allows users to create and share interactive and multimedia content, such as quizzes, interactive videos, and interactive timelines. H5P stands for HTML5 Package, and it is built on top of the HTML5 standard, making it compatible with a wide range of web browsers and devices. The platform also includes a content library where users can access and share content created by others.<\/span><\/p>\n<h2>Integration with Drupal<\/h2>\n<p><span style=\"font-weight: 400;\">It is recommended to install using composer as it contains many external libraries &#8211;\u00a0<\/span><\/p>\n<blockquote><p><span style=\"font-weight: 400;\">composer require &#8216;drupal\/h5p:^2.0@alpha&#8217;<\/span><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Enable H5P and H5P editor from admin panel or using drush command &#8211;<\/span><\/p>\n<blockquote><p><span style=\"font-weight: 400;\">drush en h5p<\/span><\/p>\n<p><span style=\"font-weight: 400;\">drush en h5p_editor<\/span><\/p><\/blockquote>\n<p style=\"text-align: center;\"><strong>OR<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56482 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-FAiWTaRnsYGR3tu.jpg\" alt=\"enable h5p\" width=\"850\" height=\"351\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-FAiWTaRnsYGR3tu.jpg 850w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-FAiWTaRnsYGR3tu-300x124.jpg 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-FAiWTaRnsYGR3tu-768x317.jpg 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-FAiWTaRnsYGR3tu-624x258.jpg 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/a><\/p>\n<h2>Working with H5P<\/h2>\n<p><span style=\"font-weight: 400;\">Create\/Edit any content type and add an field of type h5p.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56483 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-hOdK0dXxDi0swudV.jpg\" alt=\"h5p field\" width=\"360\" height=\"141\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-hOdK0dXxDi0swudV.jpg 360w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-hOdK0dXxDi0swudV-300x118.jpg 300w\" sizes=\"(max-width: 360px) 100vw, 360px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Now in the manage form display section we got 2 types of widgets, h5p upload and h5p editor. Default, we get h5p upload which allows users to upload h5p files (identified by .h5p extensions).\u00a0<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56502 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-q5QIhL116h2NfG.png\" alt=\"\" width=\"850\" height=\"130\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-q5QIhL116h2NfG.png 850w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-q5QIhL116h2NfG-300x46.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-q5QIhL116h2NfG-768x117.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-q5QIhL116h2NfG-624x95.png 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">To do this you can simply go to the H5P website, create any content and click on reuse on the bottom left of that particular content. This will open a dialog box, then click on \u201c Download as an .h5p file\u201d. You can upload this file in drupal and reuse it.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56488 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-jhYBpj1UjEpVZh.jpg\" alt=\"\" width=\"627\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-jhYBpj1UjEpVZh.jpg 627w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-jhYBpj1UjEpVZh-300x172.jpg 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-jhYBpj1UjEpVZh-624x358.jpg 624w\" sizes=\"(max-width: 627px) 100vw, 627px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Another is using an H5P editor. This widget provides a whole set of interactive libraries such as presentations, quizzes, dialog cards, interactive video, etc. <\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-56486\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-YcxeA3J7Su1q4V-1.jpg\" alt=\"\" width=\"850\" height=\"84\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-YcxeA3J7Su1q4V-1.jpg 850w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-YcxeA3J7Su1q4V-1-300x30.jpg 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-YcxeA3J7Su1q4V-1-768x76.jpg 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-YcxeA3J7Su1q4V-1-624x62.jpg 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">When used for the first time, we need\u00a0 to download the libraries that need to be used by simply clicking <\/span> <span style=\"font-weight: 400;\">on the \u201cGET\u201d button. This will hardly take a minute.\u00a0<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56489 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-L5Jjwl3RNNV.jpg\" alt=\"\" width=\"492\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-L5Jjwl3RNNV.jpg 492w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-L5Jjwl3RNNV-300x220.jpg 300w\" sizes=\"(max-width: 492px) 100vw, 492px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\"><strong>Note:<\/strong> These libraries are downloaded in the local drupal directory in <\/span><b>sites\/default\/files\/h5p. <\/b><span style=\"font-weight: 400;\">All the assets such as images and videos or any external files supported will be stored in these folders.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Presentation Example:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Click on the \u201cdetails\u201d button on the Course Presentation Library.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Then you will get an example\/tutorial on how to use this library. On the bottom right, click on \u201cUse\u201d.<\/span><span style=\"font-weight: 400;\">\u00a0<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56500 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-ProTWzRp3ss.png\" alt=\"\" width=\"536\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-ProTWzRp3ss.png 536w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-ProTWzRp3ss-300x201.png 300w\" sizes=\"(max-width: 536px) 100vw, 536px\" \/><\/a> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">This ajax calls the presentation library and we get the slide on screen to edit.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">You will get a proper editor to make your slides interactive. Moreover, you can use other libraries of H5P in slides also such as quizzes, true\/false, fill in the blanks, etc. I have added the screenshots of the working presentation library.<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56492 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-mcT8x0Rhza.jpg\" alt=\"\" width=\"514\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-mcT8x0Rhza.jpg 514w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-mcT8x0Rhza-300x210.jpg 300w\" sizes=\"(max-width: 514px) 100vw, 514px\" \/><\/a><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56493 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-qYoxmFyMzkJ4eSYg.jpg\" alt=\"\" width=\"513\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-qYoxmFyMzkJ4eSYg.jpg 513w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-qYoxmFyMzkJ4eSYg-300x211.jpg 300w\" sizes=\"(max-width: 513px) 100vw, 513px\" \/><\/a><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">When done you can simply publish\/unpublish that node based on requirement and save the node.<\/span><\/li>\n<\/ul>\n<h2><strong>Serving data from H5P<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">H5P serves the content on nodes through node urls, views(block, page, embed, entity reference, REST APIs).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">From Views we can simply add the H5P field that contains the content.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56494 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-y2cfsMhEBXHL.jpg\" alt=\"\" width=\"739\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-y2cfsMhEBXHL.jpg 739w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-y2cfsMhEBXHL-300x146.jpg 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-y2cfsMhEBXHL-624x304.jpg 624w\" sizes=\"(max-width: 739px) 100vw, 739px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">We can also serve data programmatically from H5P supported fields using Drupal entity manager. For this we need to know the H5P database structure. All the data irrespective of libraries is stored in the table \u2018h5p_content\u2019, most of the other tables store information related to downloaded H5P libraries, users and counters. This table contains the column \u2018parameters\u2019 which stores all the content in the form of a JSON string object. All the images, links, videos, and other nested libraries are stored in the form of JSON string objects. To get the data programmatically, we need to load the particular node using entity manager wrapper.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-56501\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-48-43.png\" alt=\"\" width=\"603\" height=\"25\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-48-43.png 603w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-48-43-300x12.png 300w\" sizes=\"(max-width: 603px) 100vw, 603px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">After loading the node we need to get the h5p supported field. This field contains the target id that references the h5p_content table.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-56496\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-51-10.png\" alt=\"\" width=\"536\" height=\"20\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-51-10.png 536w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-51-10-300x11.png 300w\" sizes=\"(max-width: 536px) 100vw, 536px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">After getting the target id aka h5p_content_id, we need to pass this id while loading the h5p_content entity.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-56497\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-53-10.png\" alt=\"\" width=\"720\" height=\"23\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-53-10.png 720w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-53-10-300x10.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-53-10-624x20.png 624w\" sizes=\"(max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">After loading the h5p_content we need to get the parameters. The type of data we get for the current example is given below.<\/span><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-56498\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-54-22.png\" alt=\"\" width=\"735\" height=\"78\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-54-22.png 735w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-54-22-300x32.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2023-01-24-15-54-22-624x66.png 624w\" sizes=\"(max-width: 735px) 100vw, 735px\" \/><\/a><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56499 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-fmMIfbRbyiDULL.png\" alt=\"\" width=\"363\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-fmMIfbRbyiDULL.png 363w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-fmMIfbRbyiDULL-300x298.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-fmMIfbRbyiDULL-150x150.png 150w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-fmMIfbRbyiDULL-120x120.png 120w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-fmMIfbRbyiDULL-24x24.png 24w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-fmMIfbRbyiDULL-48x48.png 48w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/imgonline-com-ua-resize-fmMIfbRbyiDULL-96x96.png 96w\" sizes=\"(max-width: 363px) 100vw, 363px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\"><strong>Note:<\/strong> We can serve this data using RESTful APIs which means this can support decoupled drupal. There might be a limit to how much data we can serve.<\/span><\/p>\n<h2><strong>Limitations<\/strong><\/h2>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">This module contains many libraries that might not work with drupal such as AR and VR-related libraries as it may use a camera but drupal might not support it.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">There is no support on some of the libraries which do not work on drupal.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">You might need to switch to another CMS if some libraries won\u2019t work.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">All the assets such as images, libraries and other supported format files can only be stored on drupal directory, S3FS cannot be integrated with H5P on current state as there is no configuration provided.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">You might face some issues while downloading the libraries. For this, try to switch your php version to 7.4.<\/span><\/li>\n<\/ul>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>What is H5P? H5P is an open-source software platform that allows users to create and share interactive and multimedia content, such as quizzes, interactive videos, and interactive timelines. H5P stands for HTML5 Package, and it is built on top of the HTML5 standard, making it compatible with a wide range of web browsers and devices. [&hellip;]<\/p>\n","protected":false},"author":1539,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":46},"categories":[3602,1],"tags":[5091],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56503"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1539"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=56503"}],"version-history":[{"count":2,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56503\/revisions"}],"predecessor-version":[{"id":56514,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56503\/revisions\/56514"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=56503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=56503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=56503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}