From 6ab68eb6e24f2fa3b7ef6d81e36d42d61f07c328 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Mon, 30 Jan 2017 08:43:47 +0100 Subject: [PATCH 1/4] Minor cleaning --- js/h5p-action-bar.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/h5p-action-bar.js b/js/h5p-action-bar.js index 8e34eb7..261082d 100644 --- a/js/h5p-action-bar.js +++ b/js/h5p-action-bar.js @@ -19,6 +19,9 @@ H5P.ActionBar = (function ($, EventDispatcher) { * @param {string} customClass Instead of type class */ var addActionButton = function (type, customClass) { + /** + * Handles selection of action + */ var handler = function () { self.trigger(type); }; @@ -78,8 +81,8 @@ H5P.ActionBar = (function ($, EventDispatcher) { */ self.hasActions = function () { return hasActions; - } - }; + }; + } ActionBar.prototype = Object.create(EventDispatcher.prototype); ActionBar.prototype.constructor = ActionBar; From ef4165a11dc1c1319e803099c2c9fe0cb397d6ad Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Mon, 30 Jan 2017 11:38:34 +0100 Subject: [PATCH 2/4] Fixed developer mode for Drupal --- h5p.classes.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 1eea282..9ca296a 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1725,7 +1725,7 @@ class H5PCore { public static $defaultContentWhitelist = 'json png jpg jpeg gif bmp tif tiff svg eot ttf woff woff2 otf webm mp4 ogg mp3 txt pdf rtf doc docx xls xlsx ppt pptx odt ods odp xml csv diff patch swf md textile'; public static $defaultLibraryWhitelistExtras = 'js css'; - public $librariesJsonData, $contentJsonData, $mainJsonData, $h5pF, $fs, $development_mode, $h5pD, $disableFileCheck; + public $librariesJsonData, $contentJsonData, $mainJsonData, $h5pF, $fs, $h5pD, $disableFileCheck; const SECONDS_IN_WEEK = 604800; private $exportEnabled; @@ -1761,23 +1761,17 @@ class H5PCore { * @param string $url To file storage directory. * @param string $language code. Defaults to english. * @param boolean $export enabled? - * @param int $development_mode mode. */ - public function __construct(H5PFrameworkInterface $H5PFramework, $path, $url, $language = 'en', $export = FALSE, $development_mode = H5PDevelopment::MODE_NONE) { + public function __construct(H5PFrameworkInterface $H5PFramework, $path, $url, $language = 'en', $export = FALSE) { $this->h5pF = $H5PFramework; $this->fs = ($path instanceof \H5PFileStorage ? $path : new \H5PDefaultStorage($path)); $this->url = $url; $this->exportEnabled = $export; - $this->development_mode = $development_mode; $this->aggregateAssets = FALSE; // Off by default.. for now - if ($development_mode & H5PDevelopment::MODE_LIBRARY) { - $this->h5pD = new H5PDevelopment($this->h5pF, $path . '/', $language); - } - $this->detectSiteType(); $this->fullPluginPath = preg_replace('/\/[^\/]+[\/]?$/', '' , dirname(__FILE__)); @@ -1785,6 +1779,8 @@ class H5PCore { $this->relativePathRegExp = '/^((\.\.\/){1,2})(.*content\/)?(\d+|editor)\/(.+)$/'; } + + /** * Save content and clear cache. * @@ -1827,7 +1823,7 @@ class H5PCore { unset($content['libraryId'], $content['libraryName'], $content['libraryEmbedTypes'], $content['libraryFullscreen']); // // TODO: Move to filterParameters? -// if ($this->development_mode & H5PDevelopment::MODE_CONTENT) { +// if (isset($this->h5pD)) { // // TODO: Remove Drupal specific stuff // $json_content_path = file_create_path(file_directory_path() . '/' . variable_get('h5p_default_path', 'h5p') . '/content/' . $id . '/content.json'); // if (file_exists($json_content_path) === TRUE) { @@ -1937,7 +1933,7 @@ class H5PCore { public function loadContentDependencies($id, $type = NULL) { $dependencies = $this->h5pF->loadContentDependencies($id, $type); - if ($this->development_mode & H5PDevelopment::MODE_LIBRARY) { + if (isset($this->h5pD)) { $developmentLibraries = $this->h5pD->getLibraries(); foreach ($dependencies as $key => $dependency) { @@ -2086,7 +2082,7 @@ class H5PCore { */ public function loadLibrarySemantics($name, $majorVersion, $minorVersion) { $semantics = NULL; - if ($this->development_mode & H5PDevelopment::MODE_LIBRARY) { + if (isset($this->h5pD)) { // Try to load from dev lib $semantics = $this->h5pD->getSemantics($name, $majorVersion, $minorVersion); } @@ -2114,7 +2110,7 @@ class H5PCore { */ public function loadLibrary($name, $majorVersion, $minorVersion) { $library = NULL; - if ($this->development_mode & H5PDevelopment::MODE_LIBRARY) { + if (isset($this->h5pD)) { // Try to load from dev $library = $this->h5pD->getLibrary($name, $majorVersion, $minorVersion); if ($library !== NULL) { From 3b9dd956838713ebbfe8d29c7b3330d1ca774ed9 Mon Sep 17 00:00:00 2001 From: Timothy Lim Date: Mon, 30 Jan 2017 14:49:09 +0100 Subject: [PATCH 3/4] HFP-580 Update regex --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 9ca296a..97ee2de 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -580,7 +580,7 @@ class H5PValidator { // Schemas used to validate the h5p files private $h5pRequired = array( 'title' => '/^.{1,255}$/', - 'language' => '/^[/-,a-z]{1,5}$/', + 'language' => '/^[-a-zA-Z]{1,10}$/', 'preloadedDependencies' => array( 'machineName' => '/^[\w0-9\-\.]{1,255}$/i', 'majorVersion' => '/^[0-9]{1,5}$/', From e548b3575f0396440f42453abb11dd6f0a95f1cc Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 31 Jan 2017 13:35:23 +0100 Subject: [PATCH 4/4] Add custom xAPI events for action toolbar buttons --- js/h5p-x-api-event.js | 7 ++++++- js/h5p.js | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/js/h5p-x-api-event.js b/js/h5p-x-api-event.js index cc7fd66..e5d6368 100644 --- a/js/h5p-x-api-event.js +++ b/js/h5p-x-api-event.js @@ -308,5 +308,10 @@ H5P.XAPIEvent.allowedXAPIVerbs = [ 'shared', 'suspended', 'terminated', - 'voided' + 'voided', + + // Custom verbs used for action toolbar below content + 'downloaded', + 'accessed-embed', + 'accessed-copyright' ]; diff --git a/js/h5p.js b/js/h5p.js index e4d0138..88a9666 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -158,16 +158,19 @@ H5P.init = function (target) { actionBar.on('download', function () { window.location.href = contentData.exportUrl; + instance.triggerXAPI('downloaded'); }); actionBar.on('copyrights', function () { var dialog = new H5P.Dialog('copyrights', H5P.t('copyrightInformation'), copyrights, $container); dialog.open(); + instance.triggerXAPI('accessed-copyright'); }); actionBar.on('embed', function () { H5P.openEmbedDialog($actions, contentData.embedCode, contentData.resizeCode, { width: $element.width(), height: $element.height() }); + instance.triggerXAPI('accessed-embed'); }); if (actionBar.hasActions()) {