Easier to use override

pull/4/head
Frode Petterson 2016-04-04 15:50:41 +02:00
parent 1be48174bb
commit bb943bbb3b
10 changed files with 200 additions and 88 deletions

View File

@ -94,11 +94,6 @@ H5P.QuestionSet = function (options, contentId) {
retryButtonText: 'Retry', retryButtonText: 'Retry',
showAnimations: false showAnimations: false
}, },
override: {
overrideButtons: false,
overrideShowSolutionButton: false,
overrideRetry: false
},
questionLabel: 'Question' questionLabel: 'Question'
}; };
@ -113,18 +108,30 @@ H5P.QuestionSet = function (options, contentId) {
var up; var up;
renderSolutions = false; renderSolutions = false;
// Set overrides for questions
var override;
if (params.override.showSolutionButton || params.override.retryButton) {
override = {};
if (params.override.showSolutionButton) {
// Force "Show solution" button to be on or off for all interactions
override.enableSolutionsButton =
(params.override.showSolutionButton === 'on' ? true : false);
}
if (params.override.retryButton) {
// Force "Retry" button to be on or off for all interactions
override.enableRetry =
(params.override.retryButton === 'on' ? true : false);
}
}
// Instantiate question instances // Instantiate question instances
for (var i = 0; i < params.questions.length; i++) { for (var i = 0; i < params.questions.length; i++) {
var question = params.questions[i]; var question = params.questions[i];
// TODO: Render on init, inject in template.
// override content parameters. if (override) {
if (params.override.overrideButtons) {
// Extend subcontent with the overrided settings. // Extend subcontent with the overrided settings.
$.extend(question.params.behaviour, { $.extend(question.params.behaviour, override);
enableRetry: params.override.overrideRetry,
enableSolutionsButton: params.override.overrideShowSolutionButton
});
} }
var questionInstance = H5P.newRunnable(question, contentId, undefined, undefined, {parent: self}); var questionInstance = H5P.newRunnable(question, contentId, undefined, undefined, {parent: self});
questionInstance.on('resize', function () { questionInstance.on('resize', function () {

View File

@ -139,19 +139,30 @@
}, },
{ {
"label": "إعدادات زر \"مشاهدة حل \" وزر \"إعادة المحاولة\" ", "label": "إعدادات زر \"مشاهدة حل \" وزر \"إعادة المحاولة\" ",
"description": "وهذه الخيارات تمكنك من تجاوز وقت العرض بزر \"مشاهدة حل \" وزر \"إعادة المحاولة \" في محتويات متكامل h5p.",
"fields": [ "fields": [
{ {
"label": "تفعيل زر تجاوز \"مشاهدة حل \" و إعدادات \"إعادة \"المحاولة", "label": "Override \"Show Solution\" button",
"description": "وإذا تم تفعيل هذه الأسئلة سيتم تجاهل الإعدادات الخاصة وسيتم استخدام الضبط أدناه بدلا من ذلك" "description": "This option determines if the \"Show Solution\" button will be shown for all questions, disabled for all or configured for each question individually.",
"options": [
{
"label": "Enabled"
}, },
{ {
"label": "تفعيل زر \"إظهار الحل\"", "label": "Disabled"
"description": "تفعيل هذا الخيار يجعل الأسئلة تظهر زر \"مشاهدة الحل\"" }
]
}, },
{ {
"label": "تفعيل زر \"إعادة المحاولة\"", "label": "Override \"Retry\" button",
"description": "تفعيل هذا الخيار يجعل المستخدم قادرا على \"إعادة المحاولة\"" "description": "This option determines if the \"Retry\" button will be shown for all questions, disabled for all or configured for each question individually.",
"options": [
{
"label": "Enabled"
},
{
"label": "Disabled"
}
]
} }
] ]
}, },

View File

@ -154,19 +154,30 @@
}, },
{ {
"label": "Einstellungen für \"Zeige die Lösung\" Button und \"Nochmal\".", "label": "Einstellungen für \"Zeige die Lösung\" Button und \"Nochmal\".",
"description": "Diese Möglichkeiten überschreiben die Anzeige von \"Zeige die Lösung\" Button und \"Nochmal\" bei integrierten h5p Inhalten.",
"fields": [ "fields": [
{ {
"label": "Aktiviert das Überschreiben für \"Zeige die Lösung\" Button und \"Wiederholen\" Einstellungen.", "label": "Override \"Show Solution\" button",
"description": "Wenn dies ausgewählt wurde, werden die Einstellungen der Frage ignoriert und stattdessen werden die nachfolgenden Einstellungen verwendet." "description": "This option determines if the \"Show Solution\" button will be shown for all questions, disabled for all or configured for each question individually.",
"options": [
{
"label": "Enabled"
}, },
{ {
"label": "Aktiviert \"Zeige die Lösung\" Buttons.", "label": "Disabled"
"description": "Wenn dies ausgewählt wurde, werden die Fragen den \"Zeige die Lösung\" Button haben." }
]
}, },
{ {
"label": "Aktiviert \"Wiederholen\".", "label": "Override \"Retry\" button",
"description": "Wenn diese Option gewählt wurde, ermöglicht es den Benutzern zu \"Wiederholen\" ." "description": "This option determines if the \"Retry\" button will be shown for all questions, disabled for all or configured for each question individually.",
"options": [
{
"label": "Enabled"
},
{
"label": "Disabled"
}
]
} }
] ]
} }

View File

@ -139,19 +139,30 @@
}, },
{ {
"label": "Options pour les boutons \"Montrer la solution\" et \"Réessayer\".", "label": "Options pour les boutons \"Montrer la solution\" et \"Réessayer\".",
"description": "Ces options vous permettent de choisir quand afficher les boutons \"Solutions\" et \"Réessayer\" dans votre acivité h5p..",
"fields": [ "fields": [
{ {
"label": "Activer les réglages par défaut pour les boutons \"Solution\" et \"Réessayer\".", "label": "Override \"Show Solution\" button",
"description": "Si cette option est choisie, les réglages seront valables pour toutes les questions, les réglages individuels ne seront pas pris en compte." "description": "This option determines if the \"Show Solution\" button will be shown for all questions, disabled for all or configured for each question individually.",
"options": [
{
"label": "Enabled"
}, },
{ {
"label": "Afficher le bouton \"Solution\".", "label": "Disabled"
"description": "Affiche le bouton \"Solution\"." }
]
}, },
{ {
"label": "Afficher le bouton \"Réessayer\".", "label": "Override \"Retry\" button",
"description": "Affiche le bouton \"Réessayer\"." "description": "This option determines if the \"Retry\" button will be shown for all questions, disabled for all or configured for each question individually.",
"options": [
{
"label": "Enabled"
},
{
"label": "Disabled"
}
]
} }
] ]
}, },

View File

@ -139,19 +139,30 @@
}, },
{ {
"label": "Impostazioni per i pulsanti \"Mostra soluzione\" e \"Riprova\".", "label": "Impostazioni per i pulsanti \"Mostra soluzione\" e \"Riprova\".",
"description": "Queste opzioni consentono di ignorare quando visualizzare i pulsanti \"Mostra soluzione\" e \"Riprova\" nel contenuto H5P integrato.",
"fields": [ "fields": [
{ {
"label": "Abilita ignora impostazioni per \"Mostra soluzione\" e \"Riprova\".", "label": "Override \"Show Solution\" button",
"description": "Se questa opzione è abilitata le proprie impostazioni per le domande saranno ignorate e verranno utilizzate le impostazioni seguenti." "description": "This option determines if the \"Show Solution\" button will be shown for all questions, disabled for all or configured for each question individually.",
"options": [
{
"label": "Enabled"
}, },
{ {
"label": "Abilita pulsanti \"Mostra soluzione\".", "label": "Disabled"
"description": "L'attivazione di questa opzione farà in modo che le domande mostrino il tasto \"Mostra soluzione\"." }
]
}, },
{ {
"label": "Abilita \"Riprova\".", "label": "Override \"Retry\" button",
"description": "L'attivazione di questa opzione farà in modo che per l'utente sia abilitata l'opzione \"Riprova\"." "description": "This option determines if the \"Retry\" button will be shown for all questions, disabled for all or configured for each question individually.",
"options": [
{
"label": "Enabled"
},
{
"label": "Disabled"
}
]
} }
] ]
}, },

View File

@ -150,20 +150,31 @@
] ]
}, },
{ {
"label": "Innstillinger for \"Vis svar\" knapp og \"Prøv igjen\".", "label": "Innstillinger for «Vis svar»- og «Prøv igjen»-knapp",
"description": "Disse instillingene lar deg overstyre når \"Vis svar\" knapp og \"Prøv igjen\" er slått på i integrert h5p innhold.",
"fields": [ "fields": [
{ {
"label": "Slå på overstyring for \"Vis svar\" og \"Prøv igjen\".", "label": "Overstyr «Vis svar»-knapp",
"description": "Aktivering vil overstyre de følgende innstillingene for integrert innhold." "description": "Dette valget avgjør om «Vis svar»-knappen vil vises for alle spørsmål, skjules for alle eller konfigureres individuelt for hvert spørsmål.",
"options": [
{
"label": "Aktivert"
}, },
{ {
"label": "Slå på \"Vis svar\" knapp.", "label": "Deaktivert"
"description": "Aktivering vil slå på \"Vis svar\" knappen." }
]
}, },
{ {
"label": "Slå på \"Prøv igjen\".", "label": "Overstyr «Prøv igjen»-knapp",
"description": "Aktivering vil slå på \"Prøv igjen\" ." "description": "Dette valget avgjør om «Prøv igjen»-knappen vil vises for alle spørsmål, skjules for alle eller konfigureres individuelt for hvert spørsmål.",
"options": [
{
"label": "Aktivert"
},
{
"label": "Deaktivert"
}
]
} }
] ]
}, },

View File

@ -150,20 +150,31 @@
] ]
}, },
{ {
"label": "Innstillinger for \"Vis svar\" knapp og \"Prøv igjen\".", "label": "Innstillinger for «Vis svar»- og «Prøv igjen»-knapp",
"description": "Disse instillingene lar deg overstyre når \"Vis svar\" knapp og \"Prøv igjen\" er slått på i integrert h5p innhald.",
"fields": [ "fields": [
{ {
"label": "Slå på overstyring for \"Vis svar\" og \"Prøv igjen\".", "label": "Overstyr «Vis svar»-knapp",
"description": "Aktivering vil overstyre dei følgjande innstillingene for integrert innhald." "description": "Dette valget avgjør om «Vis svar»-knappen vil vises for alle spørsmål, skjules for alle eller konfigureres individuelt for hvert spørsmål.",
"options": [
{
"label": "Aktivert"
}, },
{ {
"label": "Slå på \"Vis svar\" knapp.", "label": "Deaktivert"
"description": "Aktivering vil slå på \"Vis svar\" knappen." }
]
}, },
{ {
"label": "Slå på \"Prøv igjen\".", "label": "Overstyr «Prøv igjen»-knapp",
"description": "Aktivering vil slå på \"Prøv igjen\" ." "description": "Dette valget avgjør om «Prøv igjen»-knappen vil vises for alle spørsmål, skjules for alle eller konfigureres individuelt for hvert spørsmål.",
"options": [
{
"label": "Aktivert"
},
{
"label": "Deaktivert"
}
]
} }
] ]
}, },

View File

@ -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": 7, "minorVersion": 8,
"patchVersion": 0, "patchVersion": 0,
"embedTypes": [ "embedTypes": [
"iframe" "iframe"

View File

@ -300,30 +300,42 @@
{ {
"name": "override", "name": "override",
"type": "group", "type": "group",
"label": "Settings for \"Show solution\" button and \"Retry\".", "label": "Settings for \"Show solution\" and \"Retry\" buttons",
"description": "These options will let you override when to display \"Show solution\" button and \"Retry\" in integrated h5p content.",
"optional": true, "optional": true,
"fields": [ "fields": [
{ {
"name": "overrideButtons", "name": "showSolutionButton",
"type": "boolean", "type": "select",
"label": "Enable override for \"Show solution\" and \"Retry\" settings.", "label": "Override \"Show Solution\" button",
"description": "If this is enabled the questions own settings will be ignored and the below settings will be used instead.", "description": "This option determines if the \"Show Solution\" button will be shown for all questions, disabled for all or configured for each question individually.",
"default": false "optional": true,
"options": [
{
"value": "on",
"label": "Enabled"
}, },
{ {
"name": "overrideShowSolutionButton", "value": "off",
"type": "boolean", "label": "Disabled"
"label": "Enable \"Show solution\" buttons.", }
"description": "Enabling this option will make questions show the \"Show solution\" button.", ]
"default": false
}, },
{ {
"name": "overrideRetry", "name": "retryButton",
"type": "boolean", "type": "select",
"label": "Enable \"Retry\".", "label": "Override \"Retry\" button",
"description": "Enabling this option will make the user able to \"Retry\" .", "description": "This option determines if the \"Retry\" button will be shown for all questions, disabled for all or configured for each question individually.",
"default": false "optional": true,
"options": [
{
"value": "on",
"label": "Enabled"
},
{
"value": "off",
"label": "Disabled"
}
]
} }
] ]
}, },

View File

@ -14,6 +14,33 @@ H5PUpgrades['H5P.QuestionSet'] = (function ($) {
}); });
} }
} }
finished(null, parameters);
},
/**
* Asynchronous content upgrade hook.
* Upgrades content parameters to support IV 1.7.
*
* Groups all UI text strings to make them eaiser to translate and handle.
*
* @params {Object} parameters
* @params {function} finished
*/
8: function (parameters, finished) {
if (parameters.override.overrideButtons) {
// Set new variables
parameters.override.showSolutionButton =
(parameters.override.overrideShowSolutionButton ? 'on' : 'off');
parameters.override.retryButton =
(parameters.override.overrideRetry ? 'on' : 'off');
}
// Remove old field variables
delete parameters.override.overrideButtons;
delete parameters.override.overrideShowSolutionButton;
delete parameters.override.overrideRetry;
finished(null, parameters); finished(null, parameters);
} }
} }