Go to next step is enabled after user finishes step challenge
This commit is contained in:
@ -41,6 +41,14 @@ const challengeView = {
|
||||
7: 'coursewares/showStep'
|
||||
};
|
||||
|
||||
function isChallengeCompleted(user, challengeId) {
|
||||
if (!user) {
|
||||
return false;
|
||||
}
|
||||
return user.completedChallenges.some(challenge =>
|
||||
challenge.id === challengeId );
|
||||
}
|
||||
|
||||
function numberWithCommas(x) {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
}
|
||||
@ -293,6 +301,9 @@ module.exports = function(app) {
|
||||
tail: challenge.tail,
|
||||
tests: challenge.tests,
|
||||
|
||||
// identifies if a challenge is completed
|
||||
isCompleted: isChallengeCompleted(req.user, challenge.id),
|
||||
|
||||
// video challenges
|
||||
video: challenge.challengeSeed[0],
|
||||
|
||||
|
@ -18,9 +18,9 @@ block content
|
||||
.btn.btn-warning.col-sm-5.col-xs-12.challenge-step-btn-prev(id='#{index - 1}') Go to my previous step
|
||||
.challenge-step-counter.large-p.col-sm-2.col-xs-12.text-center (#{index + 1} / #{description.length})
|
||||
if index + 1 === description.length
|
||||
.btn.btn-primary.col-sm-5.col-xs-12.challenge-step-btn-finish(id='last' class=step[3] ? 'disabled' : '') Finish challenge
|
||||
.btn.btn-primary.col-sm-5.col-xs-12.challenge-step-btn-finish(id='last' class=step[3] && !isCompleted ? 'disabled' : '') Finish challenge
|
||||
else
|
||||
.btn.btn-primary.col-sm-5.col-xs-12.challenge-step-btn-next(id='#{index}' class=step[3] ? 'disabled' : '') Go to my next step
|
||||
.btn.btn-primary.col-sm-5.col-xs-12.challenge-step-btn-next(id='#{index}' class=step[3] && !isCompleted ? 'disabled' : '') Go to my next step
|
||||
.clearfix
|
||||
#challenge-step-modal.modal(tabindex='-1')
|
||||
.modal-dialog.animated.fadeIn.fast-animation
|
||||
|
Reference in New Issue
Block a user