Added Blanks to questionsset and fixed bugs.

pull/1/head
Frode Petterson 2013-05-06 16:58:24 +02:00
parent 355d847bb1
commit afe6404e0a
3 changed files with 13 additions and 15 deletions

View File

@ -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 {

View File

@ -28,7 +28,7 @@ H5P.QuestionSet = function (options, contentId) {
'<% } %>' +
'<div class="questionset<% if (introPage.showIntroPage) { %> hidden<% } %>">' +
' <% for (var i=0; i<questions.length; i++) { %>' +
' <div class="question-container" id="q-<%= i %>">' +
' <div class="question-container">' +
' <div><%= questions[i].library %></div>' +
' </div>' +
' <% } %>' +
@ -37,7 +37,7 @@ H5P.QuestionSet = function (options, contentId) {
' <% if (progressType == "dots") { %>' +
' <div class="dots-container">' +
' <% for (var i=0; i<questions.length; i++) { %>' +
' <span class="progress-dot unanswered" id="qdot-<%= i %>"></span>' +
' <span class="progress-dot unanswered"></span>' +
' <%} %>' +
' </div>' +
' <% } 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);

View File

@ -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"
]
}
]