From c053069f2380b05bb52939d5be5310450e4369c8 Mon Sep 17 00:00:00 2001 From: Ashley Drake Date: Thu, 26 Mar 2015 10:34:59 -0400 Subject: [PATCH 1/7] Added bonfire links for level 2. --- seed_data/bonfireMDNlinks.js | 12 +++++++++++- seed_data/bonfires.json | 33 ++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/seed_data/bonfireMDNlinks.js b/seed_data/bonfireMDNlinks.js index e604b63919..b5a985a4d9 100644 --- a/seed_data/bonfireMDNlinks.js +++ b/seed_data/bonfireMDNlinks.js @@ -13,10 +13,12 @@ var links = "Global Object" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", "Global String Object" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", "Boolean Objects" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", + "RegExp" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp", + "Arguments object" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments", // ========= PROPERTIES/MISC "String.length" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length", - "Arguments object" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments", + // ========== OBJECT METHODS "Object.getOwnPropertyNames()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames", @@ -29,6 +31,7 @@ var links = "String.charCodeAt()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt", "String.concat()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat", "String.indexOf()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf", + "String.fromCharCode()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode", "String.lastIndexOf()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf", "String.match()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match", "String.replace()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace", @@ -45,6 +48,7 @@ var links = "Array.filter()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter", "Array.forEach()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach", "Array.indexOf()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf", + "Array.isArray()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray", "Array.join()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join", "Array.lastIndexOf()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf", "Array.map()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map", @@ -52,11 +56,17 @@ var links = "Array.push()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push", "Array.reduce()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce", "Array.reverse()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse", + "Array.shift()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift", "Array.slice()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice", "Array.some()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some", "Array.sort()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort", "Array.splice()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice", "Array.toString()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString", + + // ======== MATH METHODS + "Math.max()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max", + "Math.min()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min", + "Remainder" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder_(.25)", // ======== GENERAL JAVASCRIPT REFERENCES "Arithmetic Operators" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators", diff --git a/seed_data/bonfires.json b/seed_data/bonfires.json index cb0c3585cf..b9d5d22553 100644 --- a/seed_data/bonfires.json +++ b/seed_data/bonfires.json @@ -297,7 +297,8 @@ "expect(sumAll([4, 1])).to.equal(10);", "expect(sumAll([5, 10])).to.equal(45);", "expect(sumAll([10, 5])).to.equal(45);" - ] + ], + "MDNlinks" : ["Math.max()", "Math.min()", "Array.reduce()"] }, { "_id": "a5de63ebea8dbee56860f4f2", @@ -331,7 +332,8 @@ "expect(fearNotLetter('bcd')).to.be.undefined;", "expect(fearNotLetter('abcdefghjklmno')).to.equal('i');", "expect(fearNotLetter('yz')).to.be.undefined;" - ] + ], + "MDNlinks" : ["String.charCodeAt()"] }, { "_id": "a77dbc43c33f39daa4429b4f", @@ -351,7 +353,8 @@ "assert.strictEqual(boo(1), false);", "assert.strictEqual(boo(NaN), false);", "assert.strictEqual(boo('a'), false);" - ] + ], + "MDNlinks" : ["Boolean Objects"] }, { "_id": "a105e963526e7de52b219be9", @@ -380,7 +383,8 @@ "tests": [ "assert.strictEqual(convert('Dolce & Gabbana'), 'Dolce & Gabbana', 'should escape characters');", "assert.strictEqual(convert('abc'), 'abc', 'should handle strings with nothing to escape');" - ] + ], + "MDNlinks" : ["RegExp"] }, { "_id": "a103376db3ba46b2d50db289", @@ -395,7 +399,8 @@ "assert.strictEqual(spinalCase('thisIsSpinalTap'), 'this-is-spinal-tap', 'should return spinal case from string with camel case');", "assert.strictEqual(spinalCase('The_Andy_Griffith_Show'), 'the-andy-griffith-show', 'should return spinal case from string with snake case');", "assert.strictEqual(spinalCase('Teletubbies say Eh-oh'), 'teletubbies-say-eh-oh', 'should return spinal case from string with spaces and hyphens');" - ] + ], + "MDNlinks" : ["RegExp", "String.replace()"] }, { "_id": "a5229172f011153519423690", @@ -414,7 +419,8 @@ "expect(sumFibs(4)).to.equal(5);", "expect(sumFibs(75024)).to.equal(60696);", "expect(sumFibs(75025)).to.equal(135721);" - ] + ], + "MDNlinks" : ["Remainder"] }, { "_id": "a3bfc1673c0526e06d3ac698", @@ -459,7 +465,8 @@ "tests": [ "assert.strictEqual(find([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, 'should return first found value');", "assert.strictEqual(find([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, 'should return undefined if not found');" - ] + ], + "MDNlinks" : ["Array.some()"] }, { "_id": "a5deed1811a43193f9f1c841", @@ -473,7 +480,8 @@ "expect(drop([1, 2, 3, 4], function(n) {return n >= 3; })).to.eqls([3, 4]);", "expect(drop([1, 2, 3], function(n) {return n > 0; })).to.eqls([1, 2, 3]);", "expect(drop([1, 2, 3, 4], function(n) {return n > 5; })).to.eqls([]);" - ] + ], + "MDNlinks" : ["Arguments object", "Array.shift()"] }, { "_id": "ab306dbdcc907c7ddfc30830", @@ -487,7 +495,8 @@ "assert.deepEqual(steamroller([[['a']], [['b']]]), ['a', 'b'], 'should flatten nested arrays');", "assert.deepEqual(steamroller([1, [2], [3, [[4]]]]), [1, 2, 3, 4], 'should flatten nested arrays');", "assert.deepEqual(steamroller([1, [], [3, [[4]]]]), [1, 3, 4], 'should work with empty arrays');" - ] + ], + "MDNlinks" : ["Array.isArray()"] }, { "_id": "a8d97bd4c764e91f9d2bda01", @@ -501,7 +510,8 @@ "tests": [ "expect(binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111')).to.equal(\"Aren't bonfires fun!?\");", "expect(binaryAgent('01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001')).to.equal(\"I love FreeCodeCamp!\");" - ] + ], + "MDNlinks" : ["String.charCodeAt()", "String.fromCharCode()"] }, { "_id" : "a3f503de51cfab748ff001aa", @@ -549,7 +559,8 @@ "tests": [ "assert.strictEqual(every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex'), true, 'should return true if predicate returns truthy for all elements in the collection');", "assert.strictEqual(every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], {'sex': 'female'}), false, 'should return false if predicate returns falsey for any element in the collection');" - ] + ], + "MDNlinks" : ["Object.hasOwnProperty()", "Object.getOwnPropertyNames()"] }, { "_id": "a2f1d72d9b908d0bd72bb9f6", From 85c996ad2e657b4430ac4213f7a5cc48fe7833b5 Mon Sep 17 00:00:00 2001 From: Ashley Drake Date: Thu, 26 Mar 2015 10:45:33 -0400 Subject: [PATCH 2/7] Added bonfire links for level 3. --- seed_data/bonfireMDNlinks.js | 5 ++++- seed_data/bonfires.json | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/seed_data/bonfireMDNlinks.js b/seed_data/bonfireMDNlinks.js index b5a985a4d9..891e307687 100644 --- a/seed_data/bonfireMDNlinks.js +++ b/seed_data/bonfireMDNlinks.js @@ -66,11 +66,14 @@ var links = // ======== MATH METHODS "Math.max()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max", "Math.min()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min", + "Math.pow()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow", "Remainder" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder_(.25)", // ======== GENERAL JAVASCRIPT REFERENCES "Arithmetic Operators" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators", - "Comparison Operators" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators" + "Comparison Operators" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators", + "Details of the Object Model" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model", + "Closures" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures" }; module.exports = links; diff --git a/seed_data/bonfires.json b/seed_data/bonfires.json index b9d5d22553..2a9a396b99 100644 --- a/seed_data/bonfires.json +++ b/seed_data/bonfires.json @@ -587,7 +587,8 @@ "bob.setFullName('George Carlin');", "expect(bob.getFullName()).to.eql('George Carlin');", "bob.setFullName('Bob Ross');" - ] + ], + "MDNlinks" : ["Closures", "Details of the Object Model"] }, { "_id": "af4afb223120f7348cdfc9fd", @@ -604,7 +605,8 @@ "tests": [ "expect(orbitalPeriod([{name : \"sputkin\", avgAlt : 35873.5553}])).to.eqls([{name: \"sputkin\", orbitalPeriod: 86400}]);", "expect(orbitalPeriod([{name: \"iss\", avgAlt: 413.6}, {name: \"hubble\", avgAlt: 556.7}, {name: \"moon\", avgAlt: 378632.553}])).to.eqls([{name : \"iss\", orbitalPeriod: 5557}, {name: \"hubble\", orbitalPeriod: 5734}, {name: \"moon\", orbitalPeriod: 2377399}]);" - ] + ], + "MDNlinks" : ["Math.pow()"] }, { "_id": "aff0395860f5d3034dc0bfc9", From ca3d46a7762fa973eedb9921268788ac2a943a57 Mon Sep 17 00:00:00 2001 From: Ashley Drake Date: Sat, 28 Mar 2015 13:53:26 -0400 Subject: [PATCH 3/7] fixed obvious error handlers --- controllers/courseware.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/controllers/courseware.js b/controllers/courseware.js index 58e57cef7d..586f7896a4 100644 --- a/controllers/courseware.js +++ b/controllers/courseware.js @@ -14,7 +14,7 @@ exports.coursewareNames = function(req, res) { }); }; -exports.returnNextCourseware = function(req, res) { +exports.returnNextCourseware = function(req, res, next) { if (!req.user) { return res.redirect('../coursewares/start-our-challenges'); } @@ -27,6 +27,8 @@ exports.returnNextCourseware = function(req, res) { return elem; } }); + + // *****CALLBACK req.user.save(); var uncompletedCoursewares = req.user.uncompletedCoursewares; @@ -34,7 +36,7 @@ exports.returnNextCourseware = function(req, res) { var displayedCoursewares = Courseware.find({'_id': uncompletedCoursewares[0]}); displayedCoursewares.exec(function(err, courseware) { if (err) { - next(err); + return next(err); } courseware = courseware.pop(); if (courseware === undefined) { @@ -55,7 +57,7 @@ exports.returnIndividualCourseware = function(req, res, next) { Courseware.find({"name" : new RegExp(coursewareName, 'i')}, function(err, courseware) { if (err) { - next(err); + return next(err); } // Handle not found if (courseware.length < 1) { @@ -203,7 +205,7 @@ exports.generateChallenge = function(req, res) { res.send(response); }; -exports.completedCourseware = function (req, res) { +exports.completedCourseware = function (req, res, next) { var isCompletedDate = Math.round(+new Date() / 1000); var coursewareHash = req.body.coursewareInfo.coursewareHash; @@ -221,7 +223,7 @@ exports.completedCourseware = function (req, res) { req.user.save(function (err, user) { if (err) { - throw err; + return next(err); } if (user) { res.send(true) From 69533424a3b900c2d9f909a3201bba6268af6bf6 Mon Sep 17 00:00:00 2001 From: Ashley Drake Date: Sat, 28 Mar 2015 14:01:31 -0400 Subject: [PATCH 4/7] Fixed user.save error callback handler --- controllers/courseware.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/controllers/courseware.js b/controllers/courseware.js index 586f7896a4..a9a84d7bf1 100644 --- a/controllers/courseware.js +++ b/controllers/courseware.js @@ -29,7 +29,14 @@ exports.returnNextCourseware = function(req, res, next) { }); // *****CALLBACK - req.user.save(); + req.user.save(function(err) { + if (err) { + return next(err); + } + else { + return; + } + }); var uncompletedCoursewares = req.user.uncompletedCoursewares; From 3e839030ac191064a6cbe5260bb2c058af1b81ff Mon Sep 17 00:00:00 2001 From: Ashley Drake Date: Sat, 28 Mar 2015 14:08:51 -0400 Subject: [PATCH 5/7] Fixed async function --- controllers/courseware.js | 40 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/controllers/courseware.js b/controllers/courseware.js index a9a84d7bf1..b0f89b1116 100644 --- a/controllers/courseware.js +++ b/controllers/courseware.js @@ -28,33 +28,31 @@ exports.returnNextCourseware = function(req, res, next) { } }); - // *****CALLBACK req.user.save(function(err) { if (err) { return next(err); } - else { - return; - } + + var uncompletedCoursewares = req.user.uncompletedCoursewares; + + var displayedCoursewares = Courseware.find({'_id': uncompletedCoursewares[0]}); + displayedCoursewares.exec(function(err, courseware) { + if (err) { + return next(err); + } + courseware = courseware.pop(); + if (courseware === undefined) { + req.flash('errors', { + msg: "It looks like you've completed all the courses we have available. Good job!" + }) + return res.redirect('../coursewares/start-our-challenges'); + } + nameString = courseware.name.toLowerCase().replace(/\s/g, '-'); + return res.redirect('../coursewares/' + nameString); + }); }); - var uncompletedCoursewares = req.user.uncompletedCoursewares; - - var displayedCoursewares = Courseware.find({'_id': uncompletedCoursewares[0]}); - displayedCoursewares.exec(function(err, courseware) { - if (err) { - return next(err); - } - courseware = courseware.pop(); - if (courseware === undefined) { - req.flash('errors', { - msg: "It looks like you've completed all the courses we have available. Good job!" - }) - return res.redirect('../coursewares/start-our-challenges'); - } - nameString = courseware.name.toLowerCase().replace(/\s/g, '-'); - return res.redirect('../coursewares/' + nameString); - }); + }; exports.returnIndividualCourseware = function(req, res, next) { From 64ccae938a33f697ad2abcc63aceac3a48247ec6 Mon Sep 17 00:00:00 2001 From: Geoff Storbeck Date: Sat, 28 Mar 2015 17:18:09 -0400 Subject: [PATCH 6/7] Posts completed status when challenge 2 is opened for issue #274 --- controllers/challenges.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/controllers/challenges.js b/controllers/challenges.js index 6658e18e13..566a3c1fda 100644 --- a/controllers/challenges.js +++ b/controllers/challenges.js @@ -30,8 +30,22 @@ exports.returnNextChallenge = function(req, res) { exports.returnChallenge = function(req, res) { var challengeNumber = parseInt(req.params.challengeNumber) || 0; if (challengeNumber === 2) { + req.user.challengesHash[challengeNumber] = Math.round(+new Date() / 1000); + var timestamp = req.user.challengesHash; + var points = 0; + for (var key in timestamp) { + if (timestamp[key] > 0 && req.body.challengeNumber < 54) { + points += 1; + } + } + req.user.points = points; + req.user.save(function(err) { + if (err) { return done(err); } + }); + return res.redirect('../challenges/3'); } + if (challengeNumber > highestChallengeNumber) { req.flash('errors', { msg: "It looks like you've either completed all the challenges we have available or requested a challenge we don't have." From 9fe8bf2fbf92135912736f67708b2ef656777e91 Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Sun, 29 Mar 2015 15:14:13 -0700 Subject: [PATCH 7/7] remove references to codepen from codebase --- models/User.js | 4 ---- views/account/account.jade | 9 --------- 2 files changed, 13 deletions(-) diff --git a/models/User.js b/models/User.js index 5ad54fd610..f2f154e5bd 100644 --- a/models/User.js +++ b/models/User.js @@ -300,10 +300,6 @@ var userSchema = new mongoose.Schema({ type: String, default: '' }, - coderbyteProfile: { - type: String, - default: '' - }, codepenProfile: { type: String, default: '' diff --git a/views/account/account.jade b/views/account/account.jade index 2edf5fff54..80424c1b56 100644 --- a/views/account/account.jade +++ b/views/account/account.jade @@ -134,15 +134,6 @@ block content span.ion-close-circled | Please enter a valid URL format (http://www.example.com). - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='email') CoderByte - .col-sm-4 - input.form-control(type='url', name='coderbyteProfile', id='coderbyteProfile', autocomplete="off", ng-model='user.profile.coderbyteProfile', placeholder='http://') - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.coderbyteProfile.$error.url && !profileForm.coderbyteProfile.$pristine") - alert(type='danger') - span.ion-close-circled - | Please enter a valid URL format (http://www.example.com). - .form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') LinkedIn .col-sm-4