From 8f845961427162f6fd4084913bb8e9258e6255ab Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 5 Oct 2015 16:38:58 -0700 Subject: [PATCH 1/6] Fix 500 out of range bug when completing last challenge --- server/boot/challenge.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/boot/challenge.js b/server/boot/challenge.js index 15cb507855..adf4c95c21 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -183,9 +183,9 @@ module.exports = function(app) { 'could not find challenge block for ' + challenge.block ); } - const nextBlock$ = blocks$.elementAt(blockIndex + 1); - const firstChallengeOfNextBlock$ = nextBlock$ - .map(block => block.challenges[0]); + const firstChallengeOfNextBlock$ = blocks$ + .elementAtOrDefault(blockIndex + 1, {}) + .map(({ challenges = [] }) => challenges[0]); return blocks$ .elementAt(blockIndex) @@ -214,6 +214,9 @@ module.exports = function(app) { }); }) .map(nextChallenge => { + if (!nextChallenge) { + return null; + } nextChallengeName = nextChallenge.dashedName; return nextChallengeName; }) From 85f2c005cdf5c3cbf74b9ab187011337a8e7306a Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 5 Oct 2015 20:18:52 -0700 Subject: [PATCH 2/6] fix shareable challenges solution undefined During challenges when a user tries to navigate to a challenge and hits the name redirect, the solution is filled with undefined starting the user with an empty box. This PR fixes the issue by ignoring the solution param if it is empty --- server/boot/challenge.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/boot/challenge.js b/server/boot/challenge.js index 6a056b705d..dade963b1e 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -267,12 +267,13 @@ module.exports = function(app) { } if (dasherize(challenge.name) !== origChallengeName) { - return Observable.just( - '/challenges/' + - dasherize(challenge.name) + - '?solution=' + - encodeURIComponent(solutionCode) - ); + let redirectUrl = `/challenges/${dasherize(challenge.name)}`; + + if (solutionCode) { + redirectUrl += `?solution=${encodeURIComponent(solutionCode)}`; + } + + return Observable.just(redirectUrl); } // save user does nothing if user does not exist From 68b12caf485404eda634e850f5b6c7a0e0c77557 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Fri, 2 Oct 2015 23:58:22 -0700 Subject: [PATCH 3/6] minor improvements to onboarding and create skeleton commit page --- seed/challenges/getting-started.json | 2 +- server/boot/user.js | 10 ++++++ server/views/account/commit.jade | 49 ++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 server/views/account/commit.jade diff --git a/seed/challenges/getting-started.json b/seed/challenges/getting-started.json index c35c3541f8..23b43e6b59 100644 --- a/seed/challenges/getting-started.json +++ b/seed/challenges/getting-started.json @@ -242,7 +242,7 @@ [ "", "", - "Free Code Camp will always be free. If you want to feel more motivated to earn our certificates faster, we encourage you to instead donate each month to a nonprofit.", + "Free Code Camp will always be free. If you want to feel more motivated to earn our certificates faster, we encourage you to instead pledge to donate to a nonprofit each day.", "" ] ], diff --git a/server/boot/user.js b/server/boot/user.js index a7c6fe2978..ae7accda41 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -80,6 +80,10 @@ module.exports = function(app) { router.post('/reset-password', postReset); router.get('/email-signup', getEmailSignup); router.get('/email-signin', getEmailSignin); + router.get( + '/commit', + commitToNonprofit + ); router.get( '/toggle-lockdown-mode', sendNonUserToMap, @@ -122,6 +126,12 @@ module.exports = function(app) { }); } + function commitToNonprofit(req, res) { + res.render('account/commit', { + title: 'Commit to a nonprofit. Commit to your goal.' + }); + } + function signout(req, res) { req.logout(); res.redirect('/'); diff --git a/server/views/account/commit.jade b/server/views/account/commit.jade new file mode 100644 index 0000000000..32629096df --- /dev/null +++ b/server/views/account/commit.jade @@ -0,0 +1,49 @@ +extends ../layout +block content + .panel.panel-info + .panel-body + h3.text-center Commit to your goal. Commit to a nonprofit. + .col-xs-12.col-sm-6.col-sm-offset-3 + h4 Step 1: Choose your goal + .radio + label + input(type='radio' id='front-end-development-certificate' name='goal') + | Front End Development Certificate (takes about 400 hours) + .radio + label + input(type='radio' id='full-stack-development-certificate' name='goal') + | Full Stack Development Certificate (takes about 800 hours) + .spacer + h4 Step 2: Choose your nonprofit + .row + .col-xs-12.col-sm-6 + a(href="http://i.imgur.com/U1CyEuA.jpg" data-lightbox="img-enlarge") + img.img-responsive(src='http://i.imgur.com/U1CyEuA.jpg' alt="Girl Develop It participants coding at tables.") + .radio + label + input(type='radio' id='girl-develop-it' name='nonprofit') + | Girl Develop It is a nonprofit that provides in-person classes for women to learn to code. + .col-xs-12.col-sm-6 + a(href="http://i.imgur.com/NERytFF.jpg" data-lightbox="img-enlarge") + img.img-responsive(src='http://i.imgur.com/NERytFF.jpg' alt="Vets in Tech participants standing together at a conference.") + .radio + label + input(type='radio' id='vets-in-tech' name='nonprofit') + | Vets in Tech is a nonprofit that helps veterans prepare for tech jobs. + + .spacer + h4 Step 3: Choose your monthly pledge + .radio + label + input(type='radio' id='10-dollar-pledge' name='pledge-amount') + | $10 per month + .radio + label + input(type='radio' id='50-dollar-pledge' name='pledge-amount') + | $50 per month + + .spacer + a.button.btn.btn-block.btn-primary(href='https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=T3x0DY-bLMFXuhmjYZXs-BhmDoiXfuNh5BWad5VBcMomkkDSZY0b_-_W3HS&dispatch=5885d80a13c0db1f8e263663d3faee8d0b9dcb01a9b6dc564e45f62871326a5e') Commit + .button-spacer + a.button.btn.btn-block.btn-warning(href='/') Maybe later + .spacer From f02b3ffd4c59a50f7862efabaccb7aee08d1d13f Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Sat, 3 Oct 2015 08:32:25 -0700 Subject: [PATCH 4/6] update commit copy --- server/views/account/commit.jade | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/views/account/commit.jade b/server/views/account/commit.jade index 32629096df..4786369441 100644 --- a/server/views/account/commit.jade +++ b/server/views/account/commit.jade @@ -2,7 +2,9 @@ extends ../layout block content .panel.panel-info .panel-body - h3.text-center Commit to your goal. Commit to a nonprofit. + h3.text-center Commit to yourself. Commit to a nonprofit. + .col-xs-12.col-sm-6.col-sm-offset-3 + p Are you looking for a burst of motivation? Do you want to help nonprofits before you’re ready to code for them? You can do both by pledging a monthly donation to a nonprofit until you've earned either your Front End or Full Stack Development certificate. Join Commit below or click "maybe later". .col-xs-12.col-sm-6.col-sm-offset-3 h4 Step 1: Choose your goal .radio @@ -14,7 +16,7 @@ block content input(type='radio' id='full-stack-development-certificate' name='goal') | Full Stack Development Certificate (takes about 800 hours) .spacer - h4 Step 2: Choose your nonprofit + h4 Step 2: Choose one of our nonprofits .row .col-xs-12.col-sm-6 a(href="http://i.imgur.com/U1CyEuA.jpg" data-lightbox="img-enlarge") @@ -30,7 +32,6 @@ block content label input(type='radio' id='vets-in-tech' name='nonprofit') | Vets in Tech is a nonprofit that helps veterans prepare for tech jobs. - .spacer h4 Step 3: Choose your monthly pledge .radio From e16efc832cd949c40612bca72c0b4289340897e8 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 5 Oct 2015 21:13:11 -0700 Subject: [PATCH 5/6] Move commit to separate router --- server/boot/commit.js | 15 +++++++++++++++ server/boot/user.js | 10 ---------- .../{account/commit.jade => commit/index.jade} | 0 3 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 server/boot/commit.js rename server/views/{account/commit.jade => commit/index.jade} (100%) diff --git a/server/boot/commit.js b/server/boot/commit.js new file mode 100644 index 0000000000..a54dc19506 --- /dev/null +++ b/server/boot/commit.js @@ -0,0 +1,15 @@ +export default function commit(app) { + const router = app.loopback.Router(); + router.get( + '/commit', + commitToNonprofit + ); + + app.use(router); + + function commitToNonprofit(req, res) { + res.render('commit/', { + title: 'Commit to a nonprofit. Commit to your goal.' + }); + } +} diff --git a/server/boot/user.js b/server/boot/user.js index ae7accda41..a7c6fe2978 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -80,10 +80,6 @@ module.exports = function(app) { router.post('/reset-password', postReset); router.get('/email-signup', getEmailSignup); router.get('/email-signin', getEmailSignin); - router.get( - '/commit', - commitToNonprofit - ); router.get( '/toggle-lockdown-mode', sendNonUserToMap, @@ -126,12 +122,6 @@ module.exports = function(app) { }); } - function commitToNonprofit(req, res) { - res.render('account/commit', { - title: 'Commit to a nonprofit. Commit to your goal.' - }); - } - function signout(req, res) { req.logout(); res.redirect('/'); diff --git a/server/views/account/commit.jade b/server/views/commit/index.jade similarity index 100% rename from server/views/account/commit.jade rename to server/views/commit/index.jade From e6afda62c7354a83b00b293b66c22d482d22e695 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 5 Oct 2015 22:18:50 -0700 Subject: [PATCH 6/6] Add 5 dollar option to commit --- server/views/commit/index.jade | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index 4786369441..ba15d37fc1 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -34,6 +34,10 @@ block content | Vets in Tech is a nonprofit that helps veterans prepare for tech jobs. .spacer h4 Step 3: Choose your monthly pledge + .radio + label + input(type='radio' id='5-dollar-pledge' name='pledge-amount') + | $5 per month .radio label input(type='radio' id='10-dollar-pledge' name='pledge-amount')