update to automatically redirect based on highest completed challenge hash value
This commit is contained in:
@@ -7,7 +7,7 @@ var _ = require('lodash');
|
||||
|
||||
exports.returnChallenge = function(req, res, next) {
|
||||
var challengeNumber = parseInt(req.params.challengeNumber) || 0;
|
||||
if (challengeNumber > 60) { challengeNumber = 0; }
|
||||
if (challengeNumber > 59) { challengeNumber = 0; }
|
||||
Challenge.findOne({challengeNumber: challengeNumber}, function (err, c) {
|
||||
if (err) {
|
||||
console.error('Challenge err: ', err);
|
||||
|
@@ -5,9 +5,13 @@
|
||||
|
||||
exports.index = function(req, res) {
|
||||
if (req.user) {
|
||||
if (req.user.challengesCompleted.length > 0) {
|
||||
nextChallenge = Math.max.apply(Math, req.user.challengesHash) + 1;
|
||||
res.redirect("challenges/" + nextChallenge);
|
||||
ch = req.user.challengesHash;
|
||||
if (req.user.challengesHash[0] > 0) {
|
||||
var max = Object.keys(ch).reduce(function(max,key){
|
||||
return (max === undefined || ch[key] > ch[max]) ? +key : max;
|
||||
});
|
||||
nextChallenge = max + 1;
|
||||
res.redirect("challenges/" + nextChallenge);
|
||||
} else {
|
||||
res.redirect("challenges/0");
|
||||
}
|
||||
|
@@ -66,12 +66,17 @@ exports.pairProgramWithTeamViewer = function(req, res) {
|
||||
"Be sure to pair program on these challenges, and remember to apply the RSAP methodology.",
|
||||
"Click the button below to return to the Pair Programming challenge, then mark it complete."],
|
||||
cc: req.user.challengesHash
|
||||
|
||||
});
|
||||
}
|
||||
exports.about = function(req, res) {
|
||||
res.render('about', {
|
||||
title: 'Who We Are'
|
||||
title: 'About Free Code Camp and Our Team of Volunteers'
|
||||
});
|
||||
}
|
||||
|
||||
exports.doneWithFirst100Hours = function(req, res) {
|
||||
res.render('done-with-first-100-hours', {
|
||||
title: 'Congratulations on finishing the first 100 hours of Free Code Camp!'
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user