From eb7ccdd5239e0d9485ad3b183aed794767030a0a Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Mon, 24 Feb 2014 16:26:07 +0100 Subject: [PATCH 1/3] HFJ-179: Prepared for new API version. Using new resize events, removed some deprecated stuff. Fixed a bug in CP editor. --- css/questionset.css | 10 +++++----- js/questionset.js | 30 +++++------------------------- library.json | 16 +++++----------- 3 files changed, 15 insertions(+), 41 deletions(-) diff --git a/css/questionset.css b/css/questionset.css index 0f6bf83..261c28d 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -121,12 +121,12 @@ } .qs-footer a.next.button:after { - font-family: H5PFontAwesome; + font-family: H5PFontAwesome4; content: " \f054"; } .qs-footer a.prev.button:before { - font-family: H5PFontAwesome; + font-family: H5PFontAwesome4; content: "\f053 "; } @@ -135,12 +135,12 @@ } .qs-footer a.finish.button:before { - font-family: H5PFontAwesome; + font-family: H5PFontAwesome4; content: "\f00c "; } .questionset-results a.button.qs-solutionbutton:before { - font-family: H5PFontAwesome; + font-family: H5PFontAwesome4; content: "\f06e "; } @@ -244,4 +244,4 @@ font-style: normal; color: #6aa81b; text-align: left; -} \ No newline at end of file +} diff --git a/js/questionset.js b/js/questionset.js index be05071..200fc51 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -1,24 +1,5 @@ var H5P = H5P || {}; -if (H5P.getPath === undefined) { - /** - * Find the path to the content files based on the id of the content - * - * Also identifies and returns absolute paths - * - * @param {String} path Absolute path to a file, or relative path to a file in the content folder - * @param {Number} contentId Identifier of the content requesting the path - * @returns {String} The path to use. - */ - H5P.getPath = function (path, contentId) { - if (path.substr(0, 7) === 'http://' || path.substr(0, 8) === 'https://') { - return path; - } - - return H5PIntegration.getContentPath(contentId) + path; - }; -} - /** * Will render a Question with multiple choices for answers. * @@ -130,13 +111,11 @@ H5P.QuestionSet = function (options, contentId) { var question = params.questions[i]; // TODO: Render on init, inject in template. - var libraryObject = H5P.libraryFromString(question.library); $.extend(question.params, { displaySolutionsButton: false, postUserStatistics: false }); - var tmp = new (H5P.classFromName(libraryObject.machineName))(question.params, contentId); - questionInstances.push(tmp); + questionInstances.push(H5P.newRunnable(question, contentId)); } // Update button state. @@ -175,8 +154,9 @@ H5P.QuestionSet = function (options, contentId) { $('.question-container', $myDom).hide().eq(questionNumber).show(); // Trigger resize on question in case the size of the QS has changed. - if (questionInstances[questionNumber].resize !== undefined) { - questionInstances[questionNumber].resize(); + var instance = questionInstances[questionNumber]; + if (instance.$ !== undefined) { + instance.$.trigger('h5pResize'); } // Update progress indicator @@ -389,4 +369,4 @@ H5P.QuestionSet = function (options, contentId) { defaults: defaults // Provide defaults for inspection }; return returnObject; -}; \ No newline at end of file +}; diff --git a/library.json b/library.json index 4e2bf6b..26b09b2 100644 --- a/library.json +++ b/library.json @@ -3,11 +3,15 @@ "contentType": "question", "majorVersion": 1, "minorVersion": 0, - "patchVersion": 39, + "patchVersion": 40, "runnable": 1, "fullscreen": 0, "machineName": "H5P.QuestionSet", "author": "Amendor AS", + "coreApi": { + "majorVersion": 1, + "minorVersion": 1 + }, "license": "cc-by-sa", "preloadedJs": [ {"path": "js/questionset.js"} @@ -16,21 +20,11 @@ {"path": "css/questionset.css"} ], "preloadedDependencies": [ - { - "machineName": "H5P.API", - "majorVersion": 1, - "minorVersion": 0 - }, { "machineName": "EmbeddedJS", "majorVersion": 1, "minorVersion": 0 }, - { - "machineName": "FontAwesome", - "majorVersion": 3, - "minorVersion": 1 - }, { "machineName": "H5P.Video", "majorVersion": 1, From 9e5e3b4e89313e79b2d91d0f3e16d3559e617c2e Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 26 Feb 2014 10:59:53 +0100 Subject: [PATCH 2/3] HFJ-170: Removed question padding. Removed unused outdated content example. --- css/questionset.css | 1 - library.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/css/questionset.css b/css/questionset.css index 261c28d..646d7ee 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -30,7 +30,6 @@ } .h5p-multichoice > .h5p-question { text-align: left; - padding: 0.5em 0.5em 0.4em; margin: 0.5em 0.5em 0.7em; background: rgba(255, 255, 255, 0.9); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#e6FFFFFF,endColorstr=#e6FFFFFF); diff --git a/library.json b/library.json index 26b09b2..503afd9 100644 --- a/library.json +++ b/library.json @@ -3,7 +3,7 @@ "contentType": "question", "majorVersion": 1, "minorVersion": 0, - "patchVersion": 40, + "patchVersion": 41, "runnable": 1, "fullscreen": 0, "machineName": "H5P.QuestionSet", From 856f0e8412c3b25e3100d18e78ad724816f1a7ba Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 19 Mar 2014 09:26:33 +0100 Subject: [PATCH 3/3] HFJ-179: Fixed usage of api-1.1 --- js/questionset.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/questionset.js b/js/questionset.js index 200fc51..764ba43 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -155,8 +155,8 @@ H5P.QuestionSet = function (options, contentId) { // Trigger resize on question in case the size of the QS has changed. var instance = questionInstances[questionNumber]; - if (instance.$ !== undefined) { - instance.$.trigger('h5pResize'); + if (instance.resize !== undefined) { + instance.resize(); } // Update progress indicator