From 059fe5f39bb5f3399dd76b81aeca2efa06859dd0 Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Tue, 16 Dec 2014 10:31:19 -0800 Subject: [PATCH] update to automatically redirect based on highest completed challenge hash value --- app.js | 28 +-- controllers/challenges.js | 2 +- controllers/home.js | 10 +- controllers/resources.js | 9 +- views/about.jade | 5 +- views/done-with-first-100-hours.jade | 6 + views/partials/challenges.jade | 2 +- views/text-based-adventure-tutorial-app.jade | 202 ------------------- 8 files changed, 28 insertions(+), 236 deletions(-) create mode 100644 views/done-with-first-100-hours.jade delete mode 100644 views/text-based-adventure-tutorial-app.jade diff --git a/app.js b/app.js index 0168a5b8b8..05c9ad8c27 100644 --- a/app.js +++ b/app.js @@ -133,7 +133,9 @@ app.get('/privacy', resourcesController.privacy); app.get('/jquery-exercises', resourcesController.jqueryExercises); app.get('/chromebook', resourcesController.chromebook); app.get('/pair-program-with-team-viewer', resourcesController.pairProgramWithTeamViewer); +app.get('/done-with-first-100-hours', resourcesController.doneWithFirst100Hours); app.get('/programmer-interview-questions-app', resourcesController.programmerInterviewQuestionsApp); + app.get('/about', resourcesController.about); app.get('/login', userController.getLogin); app.post('/login', userController.postLogin); @@ -243,28 +245,4 @@ app.listen(app.get('port'), function() { ); }); -module.exports = app; - -//app.get('/api', apiController.getApi); -//app.get('/api/lastfm', apiController.getLastfm); -//app.get('/api/nyt', apiController.getNewYorkTimes); -//app.get('/api/aviary', apiController.getAviary); -//app.get('/api/steam', apiController.getSteam); -//app.get('/api/stripe', apiController.getStripe); -//app.post('/api/stripe', apiController.postStripe); -//app.get('/api/scraping', apiController.getScraping); -//app.get('/api/twilio', apiController.getTwilio); -//app.post('/api/twilio', apiController.postTwilio); -//app.get('/api/clockwork', apiController.getClockwork); -//app.post('/api/clockwork', apiController.postClockwork); -//app.get('/api/foursquare', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getFoursquare); -//app.get('/api/tumblr', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getTumblr); -//app.get('/api/facebook', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getFacebook); -//app.get('/api/github', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getGithub); -//app.get('/api/twitter', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getTwitter); -//app.post('/api/twitter', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.postTwitter); -//app.get('/api/venmo', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getVenmo); -//app.post('/api/venmo', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.postVenmo); -//app.get('/api/linkedin', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getLinkedin); -//app.get('/api/instagram', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getInstagram); -//app.get('/api/yahoo', apiController.getYahoo); +module.exports = app; \ No newline at end of file diff --git a/controllers/challenges.js b/controllers/challenges.js index 3bf2046b1c..382aa369a5 100644 --- a/controllers/challenges.js +++ b/controllers/challenges.js @@ -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); diff --git a/controllers/home.js b/controllers/home.js index df6ff23c8c..049a710008 100644 --- a/controllers/home.js +++ b/controllers/home.js @@ -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"); } diff --git a/controllers/resources.js b/controllers/resources.js index 3232b76f24..97e62df360 100644 --- a/controllers/resources.js +++ b/controllers/resources.js @@ -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!' }); } diff --git a/views/about.jade b/views/about.jade index b24f3a7fca..407bc4b624 100644 --- a/views/about.jade +++ b/views/about.jade @@ -1,4 +1,5 @@ extends layout block content - h1 About Free Code Camp - h2 this is a placeholder page. Our about us page is coming soon. \ No newline at end of file + include partials/about-us + br + include partials/faq \ No newline at end of file diff --git a/views/done-with-first-100-hours.jade b/views/done-with-first-100-hours.jade new file mode 100644 index 0000000000..38cfbd39f2 --- /dev/null +++ b/views/done-with-first-100-hours.jade @@ -0,0 +1,6 @@ +extends layout +block content + .jumbotron.negative-15.text-center + h1.hug-top Congratulations on finishing the first 100 hours of Free Code Camp! + h2 Now you're ready to continue your learning by building solutions for nonprofits! + h3 Private message Quincy Larson in the Free Code Camp Chatroom and he'll help you get started on your first project. \ No newline at end of file diff --git a/views/partials/challenges.jade b/views/partials/challenges.jade index d1e9069381..a4d259ae79 100644 --- a/views/partials/challenges.jade +++ b/views/partials/challenges.jade @@ -183,4 +183,4 @@ a(href="/challenges/59", class="#{ cc[59] > 0 ? 'strikethrough' : '' }") Create Angular.js Services |   (45 minutes) - a.btn.btn-primary.disabled(href="/done-with-first-100-hours") I've finished all Free Code Camp challenges and all the Easy and Medium CoderByte Challenges \ No newline at end of file + a.btn.btn-primary(href="/done-with-first-100-hours", class="#{ cc[59] > 0 ? '' : 'disabled' }") I've finished all Free Code Camp challenges and all the Easy and Medium CoderByte Challenges \ No newline at end of file diff --git a/views/text-based-adventure-tutorial-app.jade b/views/text-based-adventure-tutorial-app.jade deleted file mode 100644 index 966e8ba1e9..0000000000 --- a/views/text-based-adventure-tutorial-app.jade +++ /dev/null @@ -1,202 +0,0 @@ -extends layout -block content - script. - $(document).ready(function () { - var directions = { - 0: "To get started, open your Chrome DevTools. The #next-exercise button is disabled below. Try using jQuery's .attr() method to turn the disabled attribute to false.", - 1: "Move the .target element from #location1 to #location2.", - 2: "Change the background color of .target to red.", - 3: "Change the background color of the even-numbered targets to red.", - 4: "Change the background color of the target4 to red.", - 5: "Clone the target2 in #location1 so that it also exists in #location2.", - 6: "Remove the target3 from element from #location1.", - 7: "Check the following checkboxes using jQuery.", - 8: "Make the text input field read-only.", - 9: "Select the target2 option in the select box.", - 10: "Add the following css classes to .target: 'animated' and 'hinge'.", - 11: "Use jQuery to read the data of .target.", - 12: "Use 'length' to count the number of child elements in #location1, then display that value in #location2.", - 13: "There's an element hidden in #location1. Show it using jQuery, and then click on it." - }; - var hint = { - 0: "$('#next-exercise').attr('disabled', false);", - 1: "$('.target').appendTo('#location2');", - 2: "$('.target').css('background', 'red');", - 3: "$('.target:even').css('background', 'red');", - 4: "$('.target:nth-child(4)').css('background', 'red');", - 5: "$('.target:nth-child(2)').clone().appendTo($('#location2'));", - 6: "$('.target:nth-child(3)').remove();", - 7: "$('#location1 input').attr('checked', 'true')", - 8: "$('#location1 input').attr('readonly', 'true')", - 9: "$('#location1 select').val('target2');", - 10: "$('.target').addClass('animated hinge');", - 11: "$('.target').data();", - 12: "$('#location2').text($('#location1').children().length)", - 13: "$('#finished-button').show().click();" - }; - var elements = { - 0: "", - 1: "
.target
", - 2: "
.target
", - 3: "
target0
target1
target2
target3
target4
", - 4: "
target1
target2
target3
target4
target5
", - 5: "
target1
target2
target3
target4
target5
", - 6: "
target1
target2
target3
target4
target5
", - 7: "checkbox1
checkbox2", - 8: "", - 9: "", - 10: "
.target
", - 11: "
.target
", - 12: "
target1
target2
target3
target4
target5
", - 13: "
Finish!
" - }; - - function refreshEverything() { - $('#directions').text("Exercise " + currentExercise + ": " + directions[currentExercise]); - $('#location1').html(elements[currentExercise]); - $('#hint').text(hint[currentExercise]); - handleExerciseTransition(); - } - - $('#exercise-directory').on('click', 'li', event, function () { - currentExercise = $(this).index(); - event.preventDefault(); - refreshEverything(event); - }); - $('#next-exercise').on('click', event, function () { - ++currentExercise; - event.preventDefault(); - refreshEverything(event); - }); - $('#solution-button').on('click', function () { - $('#hint-modal').modal({backdrop: "static"}); - }); - $('#location1').on('click', '#finished-button', function () { - $('#finished-modal').modal({backdrop: "static"}); - }); - function handleExerciseTransition() { - if (currentExercise === 0) { - $('#next-exercise').attr('disabled', true); - } else { - $('#next-exercise').attr('disabled', false); - } - if (currentExercise === 2 || currentExercise === 6) { - $('#location2 .target').remove(); - } - if (currentExercise === 13) { - $('#location2').text(''); - $('#finished-button').hide(); - $('#next-exercise').attr('disabled', true); - } - } - - var currentExercise = 0; - refreshEverything(currentExercise); - }); - style. - #directions { - text-align: left; - font-size: 15px; - } - - .well { - text-align: left; - height: 200px; - } - - #exercise-directory { - font-size: 20px; - } - - #current-exercise { - text-size: 250px; - } - html. -
- -
- -