Move old feedback into a separate deprecated group

HFP-1174
pull/15/head
Frode Petterson 2017-07-13 15:51:24 +02:00
parent 9b89efad81
commit 6a762b8223
5 changed files with 146 additions and 115 deletions

View File

@ -112,10 +112,12 @@ H5P.QuestionSet = function (options, contentId, contentData) {
showResultPage: true,
noResultMessage: 'Finished',
message: 'Your result:',
oldFeedback: {
successGreeting: '',
successComment: '',
failGreeting: '',
failComment: '',
failComment: ''
},
overallFeedback: [],
finishButtonText: 'Finish',
solutionButtonText: 'Show solution',
@ -158,27 +160,27 @@ H5P.QuestionSet = function (options, contentId, contentData) {
var randomizeQuestionOrdering = function (questions) {
// 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
questionOrdering = H5P.shuffleArray(questionOrdering);
// Retrieve question objects from the first index
var questions = [];
questions = [];
for (var i = 0; i < questionOrdering.length; i++) {
questions[i] = questionOrdering[i][0];
}
// Retrieve the new shuffled order from the second index
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
if (contentData.previousState && contentData.previousState.questionOrder) {
newOrder[i] = questionOrder[questionOrdering[i][1]];
newOrder[j] = questionOrder[questionOrdering[j][1]];
}
else {
newOrder[i] = questionOrdering[i][1];
newOrder[j] = questionOrdering[j][1];
}
}
@ -312,8 +314,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
var _updateButtons = function () {
// Verify that current question is answered when backward nav is disabled
if (params.disableBackwardsNavigation) {
if (questionInstances[currentQuestion].getAnswerGiven()
&& questionInstances.length-1 !== currentQuestion) {
if (questionInstances[currentQuestion].getAnswerGiven() &&
questionInstances.length-1 !== currentQuestion) {
questionInstances[currentQuestion].showButton('next');
}
else {
@ -418,11 +420,11 @@ H5P.QuestionSet = function (options, contentId, contentData) {
var currentQuestion = params.questions[currentQuestionIndex];
var hasAutoPlay = currentQuestion
&& currentQuestion.params.media
&& currentQuestion.params.media.params
&& currentQuestion.params.media.params.playback
&& currentQuestion.params.media.params.playback.autoplay;
var hasAutoPlay = currentQuestion &&
currentQuestion.params.media &&
currentQuestion.params.media.params &&
currentQuestion.params.media.params.playback &&
currentQuestion.params.media.params.playback.autoplay;
if (hasAutoPlay && typeof questionInstances[currentQuestionIndex].play === 'function') {
questionInstances[currentQuestionIndex].play();
@ -592,19 +594,19 @@ H5P.QuestionSet = function (options, contentId, contentData) {
question.attach($('.question-container:eq(' + i + ')', $myDom));
//Show buttons if necessary
if(questionInstances[questionInstances.length -1] === question
&& question.hasButton('finish')) {
if (questionInstances[questionInstances.length -1] === question &&
question.hasButton('finish')) {
question.showButton('finish');
}
if(questionInstances[questionInstances.length -1] !== question
&& question.hasButton('next')) {
if (questionInstances[questionInstances.length -1] !== question &&
question.hasButton('next')) {
question.showButton('next');
}
if(questionInstances[0] !== question
&& question.hasButton('prev')
&& !params.disableBackwardsNavigation) {
if (questionInstances[0] !== question &&
question.hasButton('prev') &&
!params.disableBackwardsNavigation) {
question.showButton('prev');
}
@ -732,8 +734,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
var eparams = {
message: params.endGame.showResultPage ? params.endGame.message : params.endGame.noResultMessage,
comment: params.endGame.showResultPage ? (success ? params.endGame.successGreeting : params.endGame.failGreeting) : undefined,
resulttext: params.endGame.showResultPage ? (success ? params.endGame.successComment : params.endGame.failComment) : undefined,
comment: params.endGame.showResultPage ? (success ? params.endGame.oldFeedback.successGreeting : params.endGame.oldFeedback.failGreeting) : undefined,
resulttext: params.endGame.showResultPage ? (success ? params.endGame.oldFeedback.successComment : params.endGame.oldFeedback.failComment) : undefined,
finishButtonText: params.endGame.finishButtonText,
solutionButtonText: params.endGame.solutionButtonText,
retryButtonText: params.endGame.retryButtonText
@ -1197,7 +1199,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
return {
statement: xAPIEvent.data.statement,
children: getXAPIDataFromChildren(this)
}
};
};
};

View File

@ -153,8 +153,7 @@
{
"label": "Score Range"
},
{
},
{},
{
"label": "Feedback for defined score range",
"placeholder": "Fill in the feedback"
@ -164,6 +163,9 @@
}
]
},
{
"label": "Old Feedback",
"fields": [
{
"label": "Quiz passed greeting",
"description": "This text will be displayed above the score if the user has successfully passed the quiz."
@ -179,6 +181,8 @@
{
"label": "Failed comment",
"description": "This comment will be displayed after the score if the user has failed the quiz."
}
]
},
{
"label": "Solution button label",

View File

@ -3,7 +3,7 @@
"description": "Put together a set of different questions that has to be solved. (Quiz)",
"contentType": "question",
"majorVersion": 1,
"minorVersion": 15,
"minorVersion": 13,
"patchVersion": 0,
"embedTypes": [
"iframe"

View File

@ -339,6 +339,13 @@
}
]
},
{
"name": "oldFeedback",
"type": "group",
"label": "Old Feedback",
"importance": "low",
"deprecated": true,
"fields": [
{
"name": "successGreeting",
"type": "text",
@ -349,8 +356,7 @@
"tags": [
"strong",
"em"
],
"deprecated": true
]
},
{
"name": "successComment",
@ -367,8 +373,7 @@
"em",
"a",
"p"
],
"deprecated": true
]
},
{
"name": "failGreeting",
@ -380,8 +385,7 @@
"tags": [
"strong",
"em"
],
"deprecated": true
]
},
{
"name": "failComment",
@ -398,8 +402,9 @@
"em",
"a",
"p"
],
"deprecated": true
]
}
]
},
{
"name": "solutionButtonText",

View File

@ -78,6 +78,26 @@ H5PUpgrades['H5P.QuestionSet'] = (function ($) {
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);
}
}