parent
9b89efad81
commit
6a762b8223
|
@ -112,10 +112,12 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
showResultPage: true,
|
showResultPage: true,
|
||||||
noResultMessage: 'Finished',
|
noResultMessage: 'Finished',
|
||||||
message: 'Your result:',
|
message: 'Your result:',
|
||||||
successGreeting: '',
|
oldFeedback: {
|
||||||
successComment: '',
|
successGreeting: '',
|
||||||
failGreeting: '',
|
successComment: '',
|
||||||
failComment: '',
|
failGreeting: '',
|
||||||
|
failComment: ''
|
||||||
|
},
|
||||||
overallFeedback: [],
|
overallFeedback: [],
|
||||||
finishButtonText: 'Finish',
|
finishButtonText: 'Finish',
|
||||||
solutionButtonText: 'Show solution',
|
solutionButtonText: 'Show solution',
|
||||||
|
@ -158,27 +160,27 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
var randomizeQuestionOrdering = function (questions) {
|
var randomizeQuestionOrdering = function (questions) {
|
||||||
|
|
||||||
// Save the original order of the questions in a multidimensional array [[question0,0],[question1,1]...
|
// Save the original order of the questions in a multidimensional array [[question0,0],[question1,1]...
|
||||||
var questionOrdering = questions.map(function(questionInstance, index) { return [questionInstance, index] });
|
var questionOrdering = questions.map(function (questionInstance, index) { return [questionInstance, index]; });
|
||||||
|
|
||||||
// Shuffle the multidimensional array
|
// Shuffle the multidimensional array
|
||||||
questionOrdering = H5P.shuffleArray(questionOrdering);
|
questionOrdering = H5P.shuffleArray(questionOrdering);
|
||||||
|
|
||||||
// Retrieve question objects from the first index
|
// Retrieve question objects from the first index
|
||||||
var questions = [];
|
questions = [];
|
||||||
for (var i = 0; i < questionOrdering.length; i++) {
|
for (var i = 0; i < questionOrdering.length; i++) {
|
||||||
questions[i] = questionOrdering[i][0];
|
questions[i] = questionOrdering[i][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the new shuffled order from the second index
|
// Retrieve the new shuffled order from the second index
|
||||||
var newOrder = [];
|
var newOrder = [];
|
||||||
for (var i = 0; i< questionOrdering.length; i++) {
|
for (var j = 0; j < questionOrdering.length; j++) {
|
||||||
|
|
||||||
// Use a previous order if it exists
|
// Use a previous order if it exists
|
||||||
if(contentData.previousState && contentData.previousState.questionOrder) {
|
if (contentData.previousState && contentData.previousState.questionOrder) {
|
||||||
newOrder[i] = questionOrder[questionOrdering[i][1]];
|
newOrder[j] = questionOrder[questionOrdering[j][1]];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newOrder[i] = questionOrdering[i][1];
|
newOrder[j] = questionOrdering[j][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +195,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
if (params.poolSize > 0) {
|
if (params.poolSize > 0) {
|
||||||
|
|
||||||
// If a previous pool exists, recreate it
|
// If a previous pool exists, recreate it
|
||||||
if(contentData.previousState && contentData.previousState.poolOrder) {
|
if (contentData.previousState && contentData.previousState.poolOrder) {
|
||||||
poolOrder = contentData.previousState.poolOrder;
|
poolOrder = contentData.previousState.poolOrder;
|
||||||
|
|
||||||
// Recreate the pool from the saved data
|
// Recreate the pool from the saved data
|
||||||
|
@ -247,7 +249,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
* @param {object} questions H5P content types to be created as instances
|
* @param {object} questions H5P content types to be created as instances
|
||||||
* @return {array} Array of questions instances
|
* @return {array} Array of questions instances
|
||||||
*/
|
*/
|
||||||
var createQuestionInstancesFromQuestions = function(questions) {
|
var createQuestionInstancesFromQuestions = function (questions) {
|
||||||
var result = [];
|
var result = [];
|
||||||
// Create question instances from questions
|
// Create question instances from questions
|
||||||
// Instantiate question instances
|
// Instantiate question instances
|
||||||
|
@ -312,8 +314,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
var _updateButtons = function () {
|
var _updateButtons = function () {
|
||||||
// Verify that current question is answered when backward nav is disabled
|
// Verify that current question is answered when backward nav is disabled
|
||||||
if (params.disableBackwardsNavigation) {
|
if (params.disableBackwardsNavigation) {
|
||||||
if (questionInstances[currentQuestion].getAnswerGiven()
|
if (questionInstances[currentQuestion].getAnswerGiven() &&
|
||||||
&& questionInstances.length-1 !== currentQuestion) {
|
questionInstances.length-1 !== currentQuestion) {
|
||||||
questionInstances[currentQuestion].showButton('next');
|
questionInstances[currentQuestion].showButton('next');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -418,11 +420,11 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
|
|
||||||
var currentQuestion = params.questions[currentQuestionIndex];
|
var currentQuestion = params.questions[currentQuestionIndex];
|
||||||
|
|
||||||
var hasAutoPlay = currentQuestion
|
var hasAutoPlay = currentQuestion &&
|
||||||
&& currentQuestion.params.media
|
currentQuestion.params.media &&
|
||||||
&& currentQuestion.params.media.params
|
currentQuestion.params.media.params &&
|
||||||
&& currentQuestion.params.media.params.playback
|
currentQuestion.params.media.params.playback &&
|
||||||
&& currentQuestion.params.media.params.playback.autoplay;
|
currentQuestion.params.media.params.playback.autoplay;
|
||||||
|
|
||||||
if (hasAutoPlay && typeof questionInstances[currentQuestionIndex].play === 'function') {
|
if (hasAutoPlay && typeof questionInstances[currentQuestionIndex].play === 'function') {
|
||||||
questionInstances[currentQuestionIndex].play();
|
questionInstances[currentQuestionIndex].play();
|
||||||
|
@ -524,7 +526,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
//Force the last page to be reRendered
|
//Force the last page to be reRendered
|
||||||
rendered = false;
|
rendered = false;
|
||||||
|
|
||||||
if(params.poolSize > 0){
|
if (params.poolSize > 0) {
|
||||||
|
|
||||||
// Make new pool from params.questions
|
// Make new pool from params.questions
|
||||||
// Randomize and get the results
|
// Randomize and get the results
|
||||||
|
@ -577,7 +579,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
var replaceQuestionsInDOM = function (questionInstances) {
|
var replaceQuestionsInDOM = function (questionInstances) {
|
||||||
|
|
||||||
// Find all question containers and detach questions from them
|
// Find all question containers and detach questions from them
|
||||||
$('.question-container', $myDom).each(function (){
|
$('.question-container', $myDom).each(function () {
|
||||||
$(this).children().detach();
|
$(this).children().detach();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -592,19 +594,19 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
question.attach($('.question-container:eq(' + i + ')', $myDom));
|
question.attach($('.question-container:eq(' + i + ')', $myDom));
|
||||||
|
|
||||||
//Show buttons if necessary
|
//Show buttons if necessary
|
||||||
if(questionInstances[questionInstances.length -1] === question
|
if (questionInstances[questionInstances.length -1] === question &&
|
||||||
&& question.hasButton('finish')) {
|
question.hasButton('finish')) {
|
||||||
question.showButton('finish');
|
question.showButton('finish');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(questionInstances[questionInstances.length -1] !== question
|
if (questionInstances[questionInstances.length -1] !== question &&
|
||||||
&& question.hasButton('next')) {
|
question.hasButton('next')) {
|
||||||
question.showButton('next');
|
question.showButton('next');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(questionInstances[0] !== question
|
if (questionInstances[0] !== question &&
|
||||||
&& question.hasButton('prev')
|
question.hasButton('prev') &&
|
||||||
&& !params.disableBackwardsNavigation) {
|
!params.disableBackwardsNavigation) {
|
||||||
question.showButton('prev');
|
question.showButton('prev');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,7 +647,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
* @param {number} dotIndex Index of dot
|
* @param {number} dotIndex Index of dot
|
||||||
* @param {boolean} isAnswered True if is answered, False if not answered
|
* @param {boolean} isAnswered True if is answered, False if not answered
|
||||||
*/
|
*/
|
||||||
var toggleAnsweredDot = function(dotIndex, isAnswered) {
|
var toggleAnsweredDot = function (dotIndex, isAnswered) {
|
||||||
var $el = $('.progress-dot:eq(' + dotIndex +')', $myDom);
|
var $el = $('.progress-dot:eq(' + dotIndex +')', $myDom);
|
||||||
|
|
||||||
// Skip current button
|
// Skip current button
|
||||||
|
@ -732,8 +734,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
|
|
||||||
var eparams = {
|
var eparams = {
|
||||||
message: params.endGame.showResultPage ? params.endGame.message : params.endGame.noResultMessage,
|
message: params.endGame.showResultPage ? params.endGame.message : params.endGame.noResultMessage,
|
||||||
comment: params.endGame.showResultPage ? (success ? params.endGame.successGreeting : params.endGame.failGreeting) : undefined,
|
comment: params.endGame.showResultPage ? (success ? params.endGame.oldFeedback.successGreeting : params.endGame.oldFeedback.failGreeting) : undefined,
|
||||||
resulttext: params.endGame.showResultPage ? (success ? params.endGame.successComment : params.endGame.failComment) : undefined,
|
resulttext: params.endGame.showResultPage ? (success ? params.endGame.oldFeedback.successComment : params.endGame.oldFeedback.failComment) : undefined,
|
||||||
finishButtonText: params.endGame.finishButtonText,
|
finishButtonText: params.endGame.finishButtonText,
|
||||||
solutionButtonText: params.endGame.solutionButtonText,
|
solutionButtonText: params.endGame.solutionButtonText,
|
||||||
retryButtonText: params.endGame.retryButtonText
|
retryButtonText: params.endGame.retryButtonText
|
||||||
|
@ -873,7 +875,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Hide next button if it is the last question
|
// Hide next button if it is the last question
|
||||||
if(questionInstances[questionInstances.length -1] === question) {
|
if (questionInstances[questionInstances.length -1] === question) {
|
||||||
question.hideButton('next');
|
question.hideButton('next');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1101,10 +1103,10 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
};
|
};
|
||||||
this.getQuestions = function() {
|
this.getQuestions = function () {
|
||||||
return questionInstances;
|
return questionInstances;
|
||||||
};
|
};
|
||||||
this.showSolutions = function() {
|
this.showSolutions = function () {
|
||||||
renderSolutions = true;
|
renderSolutions = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1162,7 +1164,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
/**
|
/**
|
||||||
* Add the question itself to the definition part of an xAPIEvent
|
* Add the question itself to the definition part of an xAPIEvent
|
||||||
*/
|
*/
|
||||||
var addQuestionToXAPI = function(xAPIEvent) {
|
var addQuestionToXAPI = function (xAPIEvent) {
|
||||||
var definition = xAPIEvent.getVerifiedStatementValue(['object', 'definition']);
|
var definition = xAPIEvent.getVerifiedStatementValue(['object', 'definition']);
|
||||||
$.extend(definition, getxAPIDefinition());
|
$.extend(definition, getxAPIDefinition());
|
||||||
};
|
};
|
||||||
|
@ -1173,8 +1175,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
* @param {Object} metaContentType
|
* @param {Object} metaContentType
|
||||||
* @returns {array}
|
* @returns {array}
|
||||||
*/
|
*/
|
||||||
var getXAPIDataFromChildren = function(metaContentType) {
|
var getXAPIDataFromChildren = function (metaContentType) {
|
||||||
return metaContentType.getQuestions().map(function(question) {
|
return metaContentType.getQuestions().map(function (question) {
|
||||||
return question.getXAPIData();
|
return question.getXAPIData();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1185,7 +1187,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
*
|
*
|
||||||
* @see contract at {@link https://h5p.org/documentation/developers/contracts#guides-header-6}
|
* @see contract at {@link https://h5p.org/documentation/developers/contracts#guides-header-6}
|
||||||
*/
|
*/
|
||||||
this.getXAPIData = function(){
|
this.getXAPIData = function () {
|
||||||
var xAPIEvent = this.createXAPIEventTemplate('answered');
|
var xAPIEvent = this.createXAPIEventTemplate('answered');
|
||||||
addQuestionToXAPI(xAPIEvent);
|
addQuestionToXAPI(xAPIEvent);
|
||||||
xAPIEvent.setScoredResult(this.getScore(),
|
xAPIEvent.setScoredResult(this.getScore(),
|
||||||
|
@ -1197,7 +1199,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
return {
|
return {
|
||||||
statement: xAPIEvent.data.statement,
|
statement: xAPIEvent.data.statement,
|
||||||
children: getXAPIDataFromChildren(this)
|
children: getXAPIDataFromChildren(this)
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -153,8 +153,7 @@
|
||||||
{
|
{
|
||||||
"label": "Score Range"
|
"label": "Score Range"
|
||||||
},
|
},
|
||||||
{
|
{},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label": "Feedback for defined score range",
|
"label": "Feedback for defined score range",
|
||||||
"placeholder": "Fill in the feedback"
|
"placeholder": "Fill in the feedback"
|
||||||
|
@ -165,20 +164,25 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Quiz passed greeting",
|
"label": "Old Feedback",
|
||||||
"description": "This text will be displayed above the score if the user has successfully passed the quiz."
|
"fields": [
|
||||||
},
|
{
|
||||||
{
|
"label": "Quiz passed greeting",
|
||||||
"label": "Passed comment",
|
"description": "This text will be displayed above the score if the user has successfully passed the quiz."
|
||||||
"description": "This comment will be displayed after the score if the user has successfully passed the quiz."
|
},
|
||||||
},
|
{
|
||||||
{
|
"label": "Passed comment",
|
||||||
"label": "Quiz failed title",
|
"description": "This comment will be displayed after the score if the user has successfully passed the quiz."
|
||||||
"description": "This text will be displayed above the score if the user has failed the quiz."
|
},
|
||||||
},
|
{
|
||||||
{
|
"label": "Quiz failed title",
|
||||||
"label": "Failed comment",
|
"description": "This text will be displayed above the score if the user has failed the quiz."
|
||||||
"description": "This comment will be displayed after the score if the user has failed the quiz."
|
},
|
||||||
|
{
|
||||||
|
"label": "Failed comment",
|
||||||
|
"description": "This comment will be displayed after the score if the user has failed the quiz."
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Solution button label",
|
"label": "Solution button label",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"description": "Put together a set of different questions that has to be solved. (Quiz)",
|
"description": "Put together a set of different questions that has to be solved. (Quiz)",
|
||||||
"contentType": "question",
|
"contentType": "question",
|
||||||
"majorVersion": 1,
|
"majorVersion": 1,
|
||||||
"minorVersion": 15,
|
"minorVersion": 13,
|
||||||
"patchVersion": 0,
|
"patchVersion": 0,
|
||||||
"embedTypes": [
|
"embedTypes": [
|
||||||
"iframe"
|
"iframe"
|
||||||
|
|
123
semantics.json
123
semantics.json
|
@ -340,66 +340,71 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "successGreeting",
|
"name": "oldFeedback",
|
||||||
"type": "text",
|
"type": "group",
|
||||||
"label": "Quiz passed greeting",
|
"label": "Old Feedback",
|
||||||
"importance": "low",
|
"importance": "low",
|
||||||
"optional": true,
|
"deprecated": true,
|
||||||
"description": "This text will be displayed above the score if the user has successfully passed the quiz.",
|
"fields": [
|
||||||
"tags": [
|
{
|
||||||
"strong",
|
"name": "successGreeting",
|
||||||
"em"
|
"type": "text",
|
||||||
],
|
"label": "Quiz passed greeting",
|
||||||
"deprecated": true
|
"importance": "low",
|
||||||
},
|
"optional": true,
|
||||||
{
|
"description": "This text will be displayed above the score if the user has successfully passed the quiz.",
|
||||||
"name": "successComment",
|
"tags": [
|
||||||
"type": "text",
|
"strong",
|
||||||
"widget": "html",
|
"em"
|
||||||
"label": "Passed comment",
|
]
|
||||||
"importance": "low",
|
},
|
||||||
"optional": true,
|
{
|
||||||
"description": "This comment will be displayed after the score if the user has successfully passed the quiz.",
|
"name": "successComment",
|
||||||
"tags": [
|
"type": "text",
|
||||||
"sub",
|
"widget": "html",
|
||||||
"sup",
|
"label": "Passed comment",
|
||||||
"strong",
|
"importance": "low",
|
||||||
"em",
|
"optional": true,
|
||||||
"a",
|
"description": "This comment will be displayed after the score if the user has successfully passed the quiz.",
|
||||||
"p"
|
"tags": [
|
||||||
],
|
"sub",
|
||||||
"deprecated": true
|
"sup",
|
||||||
},
|
"strong",
|
||||||
{
|
"em",
|
||||||
"name": "failGreeting",
|
"a",
|
||||||
"type": "text",
|
"p"
|
||||||
"label": "Quiz failed title",
|
]
|
||||||
"importance": "low",
|
},
|
||||||
"optional": true,
|
{
|
||||||
"description": "This text will be displayed above the score if the user has failed the quiz.",
|
"name": "failGreeting",
|
||||||
"tags": [
|
"type": "text",
|
||||||
"strong",
|
"label": "Quiz failed title",
|
||||||
"em"
|
"importance": "low",
|
||||||
],
|
"optional": true,
|
||||||
"deprecated": true
|
"description": "This text will be displayed above the score if the user has failed the quiz.",
|
||||||
},
|
"tags": [
|
||||||
{
|
"strong",
|
||||||
"name": "failComment",
|
"em"
|
||||||
"type": "text",
|
]
|
||||||
"widget": "html",
|
},
|
||||||
"label": "Failed comment",
|
{
|
||||||
"importance": "low",
|
"name": "failComment",
|
||||||
"optional": true,
|
"type": "text",
|
||||||
"description": "This comment will be displayed after the score if the user has failed the quiz.",
|
"widget": "html",
|
||||||
"tags": [
|
"label": "Failed comment",
|
||||||
"sub",
|
"importance": "low",
|
||||||
"sup",
|
"optional": true,
|
||||||
"strong",
|
"description": "This comment will be displayed after the score if the user has failed the quiz.",
|
||||||
"em",
|
"tags": [
|
||||||
"a",
|
"sub",
|
||||||
"p"
|
"sup",
|
||||||
],
|
"strong",
|
||||||
"deprecated": true
|
"em",
|
||||||
|
"a",
|
||||||
|
"p"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "solutionButtonText",
|
"name": "solutionButtonText",
|
||||||
|
|
20
upgrades.js
20
upgrades.js
|
@ -78,6 +78,26 @@ H5PUpgrades['H5P.QuestionSet'] = (function ($) {
|
||||||
delete parameters.endGame.scoreString;
|
delete parameters.endGame.scoreString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Group old feedback fields
|
||||||
|
if (parameters.endGame.successGreeting ||
|
||||||
|
parameters.endGame.successComment ||
|
||||||
|
parameters.endGame.failGreeting ||
|
||||||
|
parameters.endGame.failComment) {
|
||||||
|
parameters.endGame.oldFeedback = {};
|
||||||
|
if (parameters.endGame.successGreeting) {
|
||||||
|
parameters.endGame.oldFeedback.successGreeting = parameters.endGame.successGreeting;
|
||||||
|
}
|
||||||
|
if (parameters.endGame.successComment) {
|
||||||
|
parameters.endGame.oldFeedback.successComment = parameters.endGame.successComment;
|
||||||
|
}
|
||||||
|
if (parameters.endGame.failGreeting) {
|
||||||
|
parameters.endGame.oldFeedback.failGreeting = parameters.endGame.failGreeting;
|
||||||
|
}
|
||||||
|
if (parameters.endGame.failComment) {
|
||||||
|
parameters.endGame.oldFeedback.failComment = parameters.endGame.failComment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
finished(null, parameters);
|
finished(null, parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue