Numerus bug fixes and improved editor for boardgame.

Fixed CKEditor readonly when created in invisible field.
pull/1/head
Frode Petterson 2013-05-02 14:41:39 +02:00
parent 0118a7dfe9
commit 9b3130b463
3 changed files with 114 additions and 107 deletions

View File

@ -54,7 +54,7 @@
} }
.questionset-results .greeting { .questionset-results .greeting {
margin-top: 180px; margin: 1em;
} }
.questionset-results .score { .questionset-results .score {

View File

@ -71,14 +71,14 @@ H5P.QuestionSet = function (options, contentId) {
title: '', title: '',
randomOrder: false, randomOrder: false,
initialQuestion: 0, initialQuestion: 0,
backgroundImage: '', backgroundImage: undefined,
progressType: 'dots', progressType: 'dots',
passPercentage: 50, passPercentage: 50,
questions: [], questions: [],
introPage: { introPage: {
showIntroPage: true, showIntroPage: true,
title: 'Welcome', title: '',
introduction: 'Click start to start.', introduction: '',
startButtonText: 'Start' startButtonText: 'Start'
}, },
texts: { texts: {
@ -89,19 +89,15 @@ H5P.QuestionSet = function (options, contentId) {
}, },
endGame: { endGame: {
showResultPage: true, showResultPage: true,
resultPage: { successGreeting: 'Congratulations!',
successGreeting: 'Congratulations!', successComment: 'You have enough correct answers to pass the test.',
successComment: 'You have enough correct answers to pass the test.', failGreeting: 'Sorry!',
failGreeting: 'Sorry!', failComment: "You don't have enough correct answers to pass this test.",
failComment: "You don't have enough correct answers to pass this test.", scoreString: '@score/@total',
scoreString: '@score/@total', finishButtonText: 'Finish',
finishButtonText: 'Finish' showAnimations: false,
}, successVideo: undefined,
animations: { failVideo: undefined
showAnimations: false,
successVideo: undefined,
failVideo: undefined
}
} }
}; };
@ -186,7 +182,7 @@ H5P.QuestionSet = function (options, contentId) {
// Get total score. // Get total score.
var finals = getScore(); var finals = getScore();
var totals = totalScore(); var totals = totalScore();
var scoreString = params.endGame.resultPage.scoreString.replace("@score", finals).replace("@total", totals); var scoreString = params.endGame.scoreString.replace("@score", finals).replace("@total", totals);
var success = ((100 * finals / totals) >= params.passPercentage); var success = ((100 * finals / totals) >= params.passPercentage);
var eventData = { var eventData = {
score: scoreString, score: scoreString,
@ -199,11 +195,11 @@ H5P.QuestionSet = function (options, contentId) {
} }
var eparams = { var eparams = {
greeting: (success ? params.endGame.resultPage.succesGreeting : params.endGame.resultPage.failGreeting), greeting: (success ? params.endGame.successGreeting : params.endGame.failGreeting),
score: scoreString, score: scoreString,
scoreclass: (success ? 'success' : 'fail'), scoreclass: (success ? 'success' : 'fail'),
resulttext: (success ? params.endGame.resultPage.successComment : params.endGame.resultPage.failComment), resulttext: (success ? params.endGame.successComment : params.endGame.failComment),
finishButtonText: params.endGame.resultPage.finishButtonText finishButtonText: params.endGame.finishButtonText
}; };
// Show result page. // Show result page.
@ -214,8 +210,8 @@ H5P.QuestionSet = function (options, contentId) {
}); });
}; };
if (params.endGame.animations.showAnimations) { if (params.endGame.showAnimations) {
var videoData = success ? params.endGame.animations.successVideo : params.endGame.animations.failVideo; var videoData = success ? params.endGame.successVideo : params.endGame.failVideo;
if (videoData) { if (videoData) {
var $videoContainer = $('<div class="video-container"></div>').appendTo($myDom); var $videoContainer = $('<div class="video-container"></div>').appendTo($myDom);
@ -231,8 +227,8 @@ H5P.QuestionSet = function (options, contentId) {
}; };
video.attach($videoContainer); video.attach($videoContainer);
if (params.endGame.animations.skipButtonText) { if (params.endGame.skipButtonText) {
$('<a class="button skip">' + params.endGame.animations.skipButtonText + '</a>').click(function () { $('<a class="button skip">' + params.endGame.skipButtonText + '</a>').click(function () {
video.stop(); video.stop();
$videoContainer.hide(); $videoContainer.hide();
displayResults(); displayResults();
@ -256,9 +252,12 @@ H5P.QuestionSet = function (options, contentId) {
} }
// Render own DOM into target. // Render own DOM into target.
$myDom.html(template.render(params)).css({ $myDom.html(template.render(params));
backgroundImage: 'url(' + cp + params.backgroundImage.path + ')' if (params.backgroundImage !== undefined) {
}); $myDom.css({
background: 'url(' + cp + params.backgroundImage.path + ')'
});
}
// Attach questions // Attach questions
for (var i = 0; i < questionInstances.length; i++) { for (var i = 0; i < questionInstances.length; i++) {

View File

@ -15,12 +15,14 @@
"name": "initialQuestion", "name": "initialQuestion",
"type": "number", "type": "number",
"label": "Initial question", "label": "Initial question",
"description": "Which question to start with. Count from 0." "description": "Which question to start with. Count from 0.",
"default": 0
}, },
{ {
"name": "backgroundImage", "name": "backgroundImage",
"type": "image", "type": "image",
"label": "Background image", "label": "Background image",
"optional": true,
"description": "An optional background image for the Question set." "description": "An optional background image for the Question set."
}, },
{ {
@ -52,6 +54,7 @@
}, },
{ {
"name": "questions", "name": "questions",
"label": "Questions",
"type": "list", "type": "list",
"entity": "question", "entity": "question",
"field": { "field": {
@ -74,28 +77,35 @@
{ {
"name": "introPage", "name": "introPage",
"type": "group", "type": "group",
"label": "Intro page", "label": "Quiz introduction",
"description": "Data for the intro page.",
"fields": [ "fields": [
{ {
"name": "showIntroPage", "name": "showIntroPage",
"type": "boolean", "type": "boolean",
"label": "Show intro page?" "label": "Display introduction"
}, },
{ {
"name": "title", "name": "title",
"type": "text", "type": "text",
"label": "Title" "label": "Title",
"optional": true,
"description": "This title will be displayed above the introduction text."
}, },
{ {
"name": "introduction", "name": "introduction",
"type": "text", "type": "text",
"label": "Introduction text" "widget": "textarea",
"label": "Introduction text",
"optional": true,
"description": "This text will be displayed before the quiz starts."
}, },
{ {
"name": "startButtonText", "name": "startButtonText",
"type": "text", "type": "text",
"label": "Start button text" "label": "Start button text",
"optional": true,
"placeholder": "Start Quiz",
"default": "Start Quiz"
} }
] ]
}, },
@ -135,86 +145,84 @@
{ {
"name": "endGame", "name": "endGame",
"type": "group", "type": "group",
"label": "End game data", "label": "Quiz finished",
"fields": [ "fields": [
{ {
"name": "showResultPage", "name": "showResultPage",
"type": "boolean", "type": "boolean",
"label": "Show result page", "label": "Display results",
"default": true "default": true
}, },
{ {
"name": "resultPage", "name": "successGreeting",
"type": "group", "type": "text",
"label": "Result page", "label": "Quiz passed title",
"description": "Data and texts for the result page.", "placeholder": "Congratulations!",
"fields": [ "default": "Congratulations!",
{ "description": "This title will be displayed above results if the user has successfully passed the quiz."
"name": "successGreeting",
"type": "text",
"label": "Success greeting",
"description": "Title in result page on success."
},
{
"name": "successComment",
"type": "text",
"label": "Success comment",
"description": "Comment shown after the score."
},
{
"name": "failGreeting",
"type": "text",
"label": "Failed greeting",
"description": "Title in result page on failed quiz."
},
{
"name": "failComment",
"type": "text",
"label": "Failed comment",
"description": "Comment shown after the score on failed quiz."
},
{
"name": "finishButtonText",
"type": "text",
"label": "Finish button text",
"description": "Text for the finish button."
}
]
}, },
{ {
"name": "animations", "name": "successComment",
"type": "group", "type": "text",
"label": "Animations", "widget": "textarea",
"fields": [ "label": "Passed comment",
{ "default": "You did very well!",
"name": "showAnimations", "description": "This comment will be displayed after the score if the user has successfully passed the quiz."
"type": "boolean", },
"label": "Show animations" {
}, "name": "failGreeting",
{ "type": "text",
"name": "skippable", "label": "Quiz failed title",
"type": "boolean", "placeholder": "Oh, no!",
"label": "Skippable" "default": "Oh, no!",
}, "description": "This title will be displayed above the results if the user has failed the quiz."
{ },
"name": "skipButtonText", {
"type": "text", "name": "failComment",
"label": "Skip button text", "type": "text",
"common": true "widget": "textarea",
}, "label": "Failed comment",
{ "default": "This didn't go so well.",
"name": "successVideo", "description": "This comment will be displayed after the score if the user has failed the quiz."
"type": "video", },
"label": "Success video", {
"description": "Video displayed on successful quiz." "name": "finishButtonText",
}, "type": "text",
{ "label": "Finish button text",
"name": "failVideo", "default": "Finish",
"type": "video", "description": "Text for the finish button."
"label": "Fail video", },
"description": "Video displayed on failed quiz." {
} "name": "showAnimations",
] "type": "boolean",
"label": "Display video before quiz results"
},
{
"name": "skippable",
"type": "boolean",
"label": "Enable skip video button"
},
{
"name": "skipButtonText",
"type": "text",
"label": "Skip video button label",
"default": "Skip video",
"description": "This is the label for the button which allows users to skip videos after a quiz.",
"common": true
},
{
"name": "successVideo",
"type": "video",
"label": "Passed video",
"optional": true,
"description": "This video will be played if the user successfully passed the quiz."
},
{
"name": "failVideo",
"type": "video",
"label": "Fail video",
"optional": true,
"description": "This video will be played if the user failes the quiz."
} }
] ]
} }