Skip to content

Commit

Permalink
FEV-130 - IVQ, Skip Back/Next
Browse files Browse the repository at this point in the history
1: add comments
2: change logic
  • Loading branch information
Maksym Korniiov committed Feb 22, 2018
1 parent 34b439b commit 7e7fc59
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions modules/Quiz/resources/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,42 +639,46 @@
var _this = this;
var allPoints = $.cpObject.cpArray;
var currentPoint = allPoints[questionNr];
var nextBtn = $('<a/>').addClass('cp-navigation-btn next-cp disabled');
var prevBtn = $('<a/>').addClass('cp-navigation-btn prev-cp disabled');
var separator = $("<div/>").addClass('separator-block').append($('<span/>').addClass('separator'));

if(currentPoint.key > allPoints[0].key){
if(currentPoint){
var nextBtn = $('<a/>').addClass('cp-navigation-btn next-cp disabled');
var prevBtn = $('<a/>').addClass('cp-navigation-btn prev-cp disabled');
var separator = $("<div/>").addClass('separator-block').append($('<span/>').addClass('separator'));
var prevQuePoint = allPoints[currentPoint.key-1];
if( (prevQuePoint && _this.KIVQModule.canSkip) || (!_this.KIVQModule.canSkip && prevQuePoint && prevQuePoint.isAnswerd)){
prevBtn.attr({'href':'#','tabindex': 7}).removeClass('disabled')
.on('keydown', _this.keyDownHandler)
.on('click',function (e) {
e.preventDefault();
_this.KIVQModule.continuePlay();
_this.seekToQuestionTime = prevQuePoint.startTime;
_this.KIVQModule.gotoScrubberPos(prevQuePoint.key);
_this.isSeekingIVQ = true;
mw.log("Quiz: gotoScrubberPos : " + prevQuePoint.key);
});
if(currentPoint.key > allPoints[0].key && prevQuePoint){
//allow go to prev CP: 1 - if canSkip is true; 2 - if canSkip is false but current CP and prev CP is already answered
if( (_this.KIVQModule.canSkip) || (!_this.KIVQModule.canSkip && currentPoint.isAnswerd && prevQuePoint.isAnswerd) ){
prevBtn.attr({'href':'#','tabindex': 7}).removeClass('disabled')
.on('keydown', _this.keyDownHandler)
.on('click',function (e) {
e.preventDefault();
_this.KIVQModule.continuePlay();
_this.seekToQuestionTime = prevQuePoint.startTime;
_this.KIVQModule.gotoScrubberPos(prevQuePoint.key);
_this.isSeekingIVQ = true;
mw.log("Quiz: gotoScrubberPos : " + prevQuePoint.key);
});
}
}
}
if(currentPoint.key < allPoints[allPoints.length-1].key){
var nextQuePoint = allPoints[currentPoint.key+1];
if( (nextQuePoint && _this.KIVQModule.canSkip) || (!_this.KIVQModule.canSkip && nextQuePoint && nextQuePoint.isAnswerd)){
nextBtn.attr({'href':'#','tabindex': 8}).removeClass('disabled')
.on('keydown', _this.keyDownHandler)
.on('click',function (e) {
e.preventDefault();
_this.KIVQModule.continuePlay();
_this.seekToQuestionTime = nextQuePoint.startTime;
_this.KIVQModule.gotoScrubberPos(nextQuePoint.key);
_this.isSeekingIVQ = true;
mw.log("Quiz: gotoScrubberPos : " + nextQuePoint.key);
});
if(currentPoint.key < allPoints[allPoints.length-1].key && nextQuePoint){
//allow go to next CP: 1 - if canSkip is true; 2 - if canSkip is false but current CP and next CP is already answered
if( (_this.KIVQModule.canSkip) || (!_this.KIVQModule.canSkip && nextQuePoint.isAnswerd)){
nextBtn.attr({'href':'#','tabindex': 8}).removeClass('disabled')
.on('keydown', _this.keyDownHandler)
.on('click',function (e) {
e.preventDefault();
_this.KIVQModule.continuePlay();
_this.seekToQuestionTime = nextQuePoint.startTime;
_this.KIVQModule.gotoScrubberPos(nextQuePoint.key);
_this.isSeekingIVQ = true;
mw.log("Quiz: gotoScrubberPos : " + nextQuePoint.key);
});
}
}
var navigation = $("<div/>").addClass('cp-navigation').append(prevBtn, separator, nextBtn );
$('.ftr-container').prepend( navigation);
}
var navigation = $("<div/>").addClass('cp-navigation').append(prevBtn, separator, nextBtn );
$('.ftr-container').prepend( navigation);
},
addFooter: function (questionNr) {
var _this = this;
Expand Down

0 comments on commit 7e7fc59

Please sign in to comment.