From afe6404e0a0ffce96692c0de6b9e47af015f48d8 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Mon, 6 May 2013 16:58:24 +0200 Subject: [PATCH] Added Blanks to questionsset and fixed bugs. --- css/questionset.css | 2 +- js/questionset.js | 23 ++++++++++------------- semantics.json | 3 ++- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/css/questionset.css b/css/questionset.css index 469029f..6da07d3 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -4,7 +4,7 @@ .questionset.hidden { display: none; } -.questionset .h5p-multichoice > .h5p-show-solution { +.questionset .h5p-multichoice > .h5p-show-solution, .h5p-blanks .h5p-button { display: none; } .dots-container { diff --git a/js/questionset.js b/js/questionset.js index b8d5c89..7ce5e96 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -28,7 +28,7 @@ H5P.QuestionSet = function (options, contentId) { '<% } %>' + '
' + ' <% for (var i=0; i' + - '
' + + '
' + '
<%= questions[i].library %>
' + '
' + ' <% } %>' + @@ -37,7 +37,7 @@ H5P.QuestionSet = function (options, contentId) { ' <% if (progressType == "dots") { %>' + '
' + ' <% for (var i=0; i' + - ' ' + + ' ' + ' <%} %>' + '
' + ' <% } else if (progressType == "textual") { %>' + @@ -148,10 +148,7 @@ H5P.QuestionSet = function (options, contentId) { } // Hide all questions - $('.question-container', $myDom).hide(); - - // Reshow the requested question - $('#q-' + questionNumber, $myDom).show(); + $('.question-container', $myDom).hide().eq(questionNumber).show(); // Update progress indicator // Test if current has been answered. @@ -161,7 +158,7 @@ H5P.QuestionSet = function (options, contentId) { else { // Set currentNess $('.progress-dot.current', $myDom).removeClass('current'); - $('#qdot-' + questionNumber, $myDom).addClass('current'); + $('.progress-dot:eq(' + questionNumber +')', $myDom).addClass('current'); } // Remember where we are @@ -279,14 +276,15 @@ H5P.QuestionSet = function (options, contentId) { // Attach questions for (var i = 0; i < questionInstances.length; i++) { var question = questionInstances[i]; - // TODO: Render on init, inject in template. - question.attach('q-' + i); + + question.attach($('.question-container:eq(' + i + ')', $myDom)); $(question).on('h5pQuestionAnswered', function () { - $('#qdot-' + currentQuestion, $myDom).removeClass('unanswered').addClass('answered'); + $('.progress-dot:eq(' + currentQuestion +')', $myDom).removeClass('unanswered').addClass('answered'); _updateButtons(); }); if (question.getAnswerGiven()) { - $('#qdot-'+i, $myDom).removeClass('unanswered').addClass('answered'); + $('.progress-dot:eq(' + i +')' + , $myDom).removeClass('unanswered').addClass('answered'); } } @@ -300,8 +298,7 @@ H5P.QuestionSet = function (options, contentId) { // Set event listeners. $('.progress-dot', $myDom).click(function () { - var idx = parseInt($(this).attr('id').split('-')[1], 10); - _showQuestion(idx); + _showQuestion($(this).index()); }); $('.next.button', $myDom).click(function () { _showQuestion(currentQuestion + 1); diff --git a/semantics.json b/semantics.json index a785859..02a3544 100644 --- a/semantics.json +++ b/semantics.json @@ -50,7 +50,8 @@ "description": "Library for this question.", "options": [ "H5P.MultiChoice 1.0", - "H5P.DragQuestion 1.0" + "H5P.DragQuestion 1.0", + "H5P.Blanks 1.0" ] } ]