From 4d319b34249ebee9a72fdd1c1d8022d893313a42 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 18 Sep 2013 10:30:12 +0200 Subject: [PATCH 1/2] Merged in changed from drupal git. --- h5p.classes.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 29ce875..0068902 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -90,10 +90,10 @@ interface H5PFrameworkInterface { * FALSE otherwise */ public function isPatchedLibrary($library); - + /** * Is H5P in development mode? - * + * * @return boolean * TRUE if H5P development mode is active * FALSE otherwise @@ -784,12 +784,12 @@ class H5PValidator { */ private function getJsonData($filePath, $return_as_string = FALSE) { $json = file_get_contents($filePath); - if (!$json) { - return FALSE; + if ($json === FALSE) { + return FALSE; // Cannot read from file. } $jsonData = json_decode($json, TRUE); - if (!$jsonData) { - return FALSE; + if ($jsonData === NULL) { + return FALSE; // JSON cannot be decoded or the recursion limit has been reached. } return $return_as_string ? $json : $jsonData; } From d6336970657b4ce2447dad490360d5ff8b9429bb Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 18 Sep 2013 15:52:06 +0200 Subject: [PATCH 2/2] Added users stats function: setFinished. --- js/h5p.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/h5p.js b/js/h5p.js index 0bb48c7..e4b7f68 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -303,6 +303,19 @@ H5P.shuffleArray = function(array) { return array; }; +/** + * Post finished results for user. + * + * @param {Number} contentId + * @param {Number} points + * @param {Number} maxPoints + */ +H5P.setFinished = function (contentId, points, maxPoints) { + if (H5P.postUserStatistics === true) { + H5P.jQuery.post(H5P.ajaxPath + 'setFinished', {contentId: contentId, points: points, maxPoints: maxPoints}); + } +}; + // Add indexOf to browsers that lack them. (IEs) if(!Array.prototype.indexOf) { Array.prototype.indexOf = function(needle) {