Merge branch 'staging' into nonprofit-improvements
Conflicts: controllers/resources.js seed_data/bonfires.json views/partials/navbar.jade
This commit is contained in:
23
.eslintrc
23
.eslintrc
@ -7,6 +7,10 @@
|
||||
"mocha": true,
|
||||
"node": true
|
||||
},
|
||||
"parser": "babel-eslint",
|
||||
"plugins": [
|
||||
"react"
|
||||
],
|
||||
"globals": {
|
||||
"window": true,
|
||||
"$": true,
|
||||
@ -41,7 +45,7 @@
|
||||
"valid-jsdoc": 2,
|
||||
"valid-typeof": 2,
|
||||
|
||||
"block-scoped-var": 2,
|
||||
"block-scoped-var": 0,
|
||||
"complexity": 0,
|
||||
"consistent-return": 2,
|
||||
"curly": 2,
|
||||
@ -215,6 +219,21 @@
|
||||
"max-params": 0,
|
||||
"max-statements": 0,
|
||||
"no-bitwise": 1,
|
||||
"no-plusplus": 0
|
||||
"no-plusplus": 0,
|
||||
|
||||
"react/display-name": 1,
|
||||
"react/jsx-boolean-value": 1,
|
||||
"react/jsx-quotes": [1, "single", "avoid-escape"],
|
||||
"react/jsx-no-undef": 1,
|
||||
"react/jsx-sort-props": 1,
|
||||
"react/jsx-uses-react": 1,
|
||||
"react/jsx-uses-vars": 1,
|
||||
"react/no-did-mount-set-state": 2,
|
||||
"react/no-did-update-set-state": 2,
|
||||
"react/no-multi-comp": 2,
|
||||
"react/prop-types": 2,
|
||||
"react/react-in-jsx-scope": 1,
|
||||
"react/self-closing-comp": 1,
|
||||
"react/wrap-multilines": 1
|
||||
}
|
||||
}
|
51
app.js
51
app.js
@ -40,10 +40,9 @@ var express = require('express'),
|
||||
resourcesController = require('./controllers/resources'),
|
||||
userController = require('./controllers/user'),
|
||||
nonprofitController = require('./controllers/nonprofits'),
|
||||
bonfireController = require('./controllers/bonfire'),
|
||||
coursewareController = require('./controllers/courseware'),
|
||||
fieldGuideController = require('./controllers/fieldGuide'),
|
||||
challengeMapController = require('./controllers/challengeMap'),
|
||||
challengeController = require('./controllers/challenge'),
|
||||
|
||||
/**
|
||||
* Stories
|
||||
@ -341,6 +340,8 @@ app.get('/privacy', function(req, res) {
|
||||
res.redirect(301, '/field-guide/what-is-the-free-code-camp-privacy-policy?');
|
||||
});
|
||||
|
||||
app.get('/submit-cat-photo', resourcesController.catPhotoSubmit);
|
||||
|
||||
app.get('/api/slack', function(req, res) {
|
||||
if (req.user) {
|
||||
if (req.user.email) {
|
||||
@ -494,38 +495,10 @@ app.get('/api/trello', resourcesController.trelloCalls);
|
||||
|
||||
app.get('/api/codepen/twitter/:screenName', resourcesController.codepenResources.twitter);
|
||||
|
||||
/**
|
||||
* Bonfire related routes
|
||||
*/
|
||||
|
||||
app.get('/field-guide/getFieldGuideList', fieldGuideController.showAllFieldGuides);
|
||||
|
||||
app.get('/playground', bonfireController.index);
|
||||
|
||||
app.get('/bonfires', bonfireController.returnNextBonfire);
|
||||
|
||||
app.get('/bonfire-json-generator', bonfireController.returnGenerator);
|
||||
|
||||
app.post('/bonfire-json-generator', bonfireController.generateChallenge);
|
||||
|
||||
app.get('/bonfire-challenge-generator', bonfireController.publicGenerator);
|
||||
|
||||
app.post('/bonfire-challenge-generator', bonfireController.testBonfire);
|
||||
|
||||
app.get(
|
||||
'/bonfires/:bonfireName',
|
||||
bonfireController.returnIndividualBonfire
|
||||
);
|
||||
|
||||
app.get('/bonfire', function(req, res) {
|
||||
res.redirect(301, '/playground');
|
||||
});
|
||||
|
||||
app.post('/completed-bonfire/', bonfireController.completedBonfire);
|
||||
|
||||
/**
|
||||
* Field Guide related routes
|
||||
*/
|
||||
app.get('/field-guide/getFieldGuideList', fieldGuideController.showAllFieldGuides);
|
||||
|
||||
|
||||
app.get('/field-guide/:fieldGuideName',
|
||||
@ -538,20 +511,24 @@ app.post('/completed-field-guide/', fieldGuideController.completedFieldGuide);
|
||||
|
||||
|
||||
/**
|
||||
* Courseware related routes
|
||||
* Challenge related routes
|
||||
*/
|
||||
|
||||
app.get('/challenges/', coursewareController.returnNextCourseware);
|
||||
app.get('/challenges/next-challenge', challengeController.returnNextChallenge);
|
||||
|
||||
app.get(
|
||||
'/challenges/:coursewareName',
|
||||
coursewareController.returnIndividualCourseware
|
||||
'/challenges/:challengeName',
|
||||
challengeController.returnIndividualChallenge
|
||||
);
|
||||
|
||||
app.post('/completed-courseware/', coursewareController.completedCourseware);
|
||||
app.get('/challenges/', challengeController.returnCurrentChallenge);
|
||||
// todo refactor these routes
|
||||
app.post('/completed-challenge/', challengeController.completedChallenge);
|
||||
|
||||
app.post('/completed-zipline-or-basejump',
|
||||
coursewareController.completedZiplineOrBasejump);
|
||||
challengeController.completedZiplineOrBasejump);
|
||||
|
||||
app.post('/completed-bonfire', challengeController.completedBonfire);
|
||||
|
||||
// Unique Check API route
|
||||
app.get('/api/checkUniqueUsername/:username',
|
||||
|
@ -25,6 +25,7 @@
|
||||
"font-awesome": "~4.3.0",
|
||||
"moment": "~2.10.2",
|
||||
"angular-bootstrap": "~0.13.0",
|
||||
"ramda": "~0.13.0"
|
||||
"ramda": "~0.13.0",
|
||||
"jshint": "~2.7.0"
|
||||
}
|
||||
}
|
||||
|
29
config/bootstrap.js
vendored
29
config/bootstrap.js
vendored
@ -1,29 +0,0 @@
|
||||
var mongoose = require('mongoose'),
|
||||
debug = require('debug')('freecc:config:boot'),
|
||||
secrets = require('./secrets'),
|
||||
courses = require('../seed_data/courses.json'),
|
||||
Course = require('./../models/Course'),
|
||||
challenges = require('../seed_data/challenges.json'),
|
||||
Challenge = require('./../models/Challenge');
|
||||
|
||||
mongoose.connect(secrets.db);
|
||||
mongoose.connection.on('error', function() {
|
||||
console.error('MongoDB Connection Error. Make sure MongoDB is running.');
|
||||
});
|
||||
|
||||
|
||||
Course.create(courses, function(err, data) {
|
||||
if (err) {
|
||||
debug(err);
|
||||
} else {
|
||||
debug('Saved ', data);
|
||||
}
|
||||
});
|
||||
|
||||
Challenge.create(challenges, function(err, data) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log('Saved ', data);
|
||||
}
|
||||
});
|
@ -1,333 +0,0 @@
|
||||
var _ = require('lodash'),
|
||||
debug = require('debug')('freecc:cntr:bonfires'),
|
||||
Bonfire = require('./../models/Bonfire'),
|
||||
User = require('./../models/User'),
|
||||
resources = require('./resources'),
|
||||
R = require('ramda');
|
||||
MDNlinks = require('./../seed_data/bonfireMDNlinks');
|
||||
|
||||
/**
|
||||
* Bonfire controller
|
||||
*/
|
||||
|
||||
exports.showAllBonfires = function(req, res) {
|
||||
var completedBonfires = [];
|
||||
if(req.user) {
|
||||
completedBonfires = req.user.completedBonfires.map(function (elem) {
|
||||
return elem._id;
|
||||
});
|
||||
}
|
||||
var noDuplicateBonfires = R.uniq(completedBonfires);
|
||||
var data = {};
|
||||
data.bonfireList = resources.allBonfireNames();
|
||||
data.completedList = noDuplicateBonfires;
|
||||
res.send(data);
|
||||
};
|
||||
|
||||
exports.index = function(req, res) {
|
||||
res.render('bonfire/show.jade', {
|
||||
completedWith: null,
|
||||
title: 'Bonfire Playground',
|
||||
name: 'Bonfire Playground',
|
||||
difficulty: 0,
|
||||
brief: 'Feel free to play around!',
|
||||
details: '',
|
||||
tests: [],
|
||||
challengeSeed: '',
|
||||
cc: req.user ? req.user.bonfiresHash : undefined,
|
||||
progressTimestamps: req.user ? req.user.progressTimestamps : undefined,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliments: resources.randomCompliment(),
|
||||
bonfires: [],
|
||||
bonfireHash: 'test'
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
exports.returnNextBonfire = function(req, res, next) {
|
||||
if (!req.user) {
|
||||
return res.redirect('../bonfires/meet-bonfire');
|
||||
}
|
||||
var completed = req.user.completedBonfires.map(function (elem) {
|
||||
return elem._id;
|
||||
});
|
||||
|
||||
req.user.uncompletedBonfires = resources.allBonfireIds().filter(function (elem) {
|
||||
if (completed.indexOf(elem) === -1) {
|
||||
return elem;
|
||||
}
|
||||
});
|
||||
req.user.save();
|
||||
|
||||
var uncompletedBonfires = req.user.uncompletedBonfires;
|
||||
|
||||
var displayedBonfires = Bonfire.find({'_id': uncompletedBonfires[0]});
|
||||
displayedBonfires.exec(function(err, bonfireFromMongo) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
var bonfire = bonfireFromMongo.pop();
|
||||
if (typeof bonfire === 'undefined') {
|
||||
req.flash('errors', {
|
||||
msg: "It looks like you've completed all the bonfires we have available. Good job!"
|
||||
});
|
||||
return res.redirect('../bonfires/meet-bonfire');
|
||||
}
|
||||
var nameString = bonfire.name.toLowerCase().replace(/\s/g, '-');
|
||||
return res.redirect('../bonfires/' + nameString);
|
||||
});
|
||||
};
|
||||
|
||||
exports.returnIndividualBonfire = function(req, res, next) {
|
||||
var dashedName = req.params.bonfireName;
|
||||
|
||||
var bonfireName = dashedName.replace(/\-/g, ' ');
|
||||
|
||||
Bonfire.find({'name': new RegExp(bonfireName, 'i')}, function(err, bonfireFromMongo) {
|
||||
if (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
|
||||
if (bonfireFromMongo.length < 1) {
|
||||
req.flash('errors', {
|
||||
msg: "404: We couldn't find a bonfire with that name. Please double check the name."
|
||||
});
|
||||
|
||||
return res.redirect('/bonfires');
|
||||
}
|
||||
|
||||
var bonfire = bonfireFromMongo.pop();
|
||||
var dashedNameFull = bonfire.name.toLowerCase().replace(/\s/g, '-');
|
||||
if (dashedNameFull !== dashedName) {
|
||||
return res.redirect('../bonfires/' + dashedNameFull);
|
||||
}
|
||||
res.render('bonfire/show', {
|
||||
completedWith: null,
|
||||
title: bonfire.name,
|
||||
dashedName: dashedName,
|
||||
name: bonfire.name,
|
||||
difficulty: Math.floor(+bonfire.difficulty),
|
||||
brief: bonfire.description.shift(),
|
||||
details: bonfire.description,
|
||||
tests: bonfire.tests,
|
||||
challengeSeed: bonfire.challengeSeed,
|
||||
points: req.user ? req.user.points : undefined,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
bonfires: bonfire,
|
||||
bonfireHash: bonfire._id,
|
||||
MDNkeys: bonfire.MDNlinks,
|
||||
MDNlinks: getMDNlinks(bonfire.MDNlinks)
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Bonfire Generator
|
||||
* @param req Request Object
|
||||
* @param res Response Object
|
||||
* @returns void
|
||||
*/
|
||||
|
||||
exports.returnGenerator = function(req, res) {
|
||||
res.render('bonfire/generator', {
|
||||
title: null,
|
||||
name: null,
|
||||
difficulty: null,
|
||||
brief: null,
|
||||
details: null,
|
||||
tests: null,
|
||||
challengeSeed: null,
|
||||
bonfireHash: randomString()
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Post for bonfire generation
|
||||
*/
|
||||
|
||||
function randomString() {
|
||||
var chars = '0123456789abcdef';
|
||||
var string_length = 23;
|
||||
var randomstring = 'a';
|
||||
for (var i = 0; i < string_length; i++) {
|
||||
var rnum = Math.floor(Math.random() * chars.length);
|
||||
randomstring += chars.substring(rnum, rnum + 1);
|
||||
}
|
||||
return randomstring;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to populate the MDN links array.
|
||||
*/
|
||||
|
||||
function getMDNlinks(links) {
|
||||
// takes in an array of links, which are strings
|
||||
var populatedLinks = [];
|
||||
|
||||
// for each key value, push the corresponding link from the MDNlinks object into a new array
|
||||
links.forEach(function(value, index) {
|
||||
populatedLinks.push(MDNlinks[value]);
|
||||
});
|
||||
|
||||
return populatedLinks;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
exports.testBonfire = function(req, res) {
|
||||
var bonfireName = req.body.name,
|
||||
bonfireTests = req.body.tests,
|
||||
bonfireDifficulty = req.body.difficulty,
|
||||
bonfireDescription = req.body.description,
|
||||
bonfireChallengeSeed = req.body.challengeSeed;
|
||||
bonfireTests = bonfireTests.split('\r\n');
|
||||
bonfireDescription = bonfireDescription.split('\r\n');
|
||||
bonfireTests.filter(getRidOfEmpties);
|
||||
bonfireDescription.filter(getRidOfEmpties);
|
||||
bonfireChallengeSeed = bonfireChallengeSeed.replace('\r', '');
|
||||
|
||||
res.render('bonfire/show', {
|
||||
completedWith: null,
|
||||
title: bonfireName,
|
||||
name: bonfireName,
|
||||
difficulty: +bonfireDifficulty,
|
||||
brief: bonfireDescription[0],
|
||||
details: bonfireDescription.slice(1),
|
||||
tests: bonfireTests,
|
||||
challengeSeed: bonfireChallengeSeed,
|
||||
cc: req.user ? req.user.bonfiresHash : undefined,
|
||||
progressTimestamps: req.user ? req.user.progressTimestamps : undefined,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
bonfires: [],
|
||||
bonfireHash: 'test'
|
||||
});
|
||||
};
|
||||
|
||||
function getRidOfEmpties(elem) {
|
||||
if (elem.length > 0) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
|
||||
exports.publicGenerator = function(req, res) {
|
||||
res.render('bonfire/public-generator');
|
||||
};
|
||||
|
||||
exports.generateChallenge = function(req, res) {
|
||||
var bonfireName = req.body.name,
|
||||
bonfireTests = req.body.tests,
|
||||
bonfireDifficulty = req.body.difficulty,
|
||||
bonfireDescription = req.body.description,
|
||||
bonfireChallengeSeed = req.body.challengeSeed;
|
||||
bonfireTests = bonfireTests.split('\r\n');
|
||||
bonfireDescription = bonfireDescription.split('\r\n');
|
||||
bonfireTests.filter(getRidOfEmpties);
|
||||
bonfireDescription.filter(getRidOfEmpties);
|
||||
bonfireChallengeSeed = bonfireChallengeSeed.replace('\r', '');
|
||||
|
||||
|
||||
var response = {
|
||||
_id: randomString(),
|
||||
name: bonfireName,
|
||||
difficulty: bonfireDifficulty,
|
||||
description: bonfireDescription,
|
||||
challengeSeed: bonfireChallengeSeed,
|
||||
tests: bonfireTests
|
||||
};
|
||||
res.send(response);
|
||||
};
|
||||
|
||||
exports.completedBonfire = function (req, res, next) {
|
||||
var isCompletedWith = req.body.bonfireInfo.completedWith || '';
|
||||
var isCompletedDate = Math.round(+new Date());
|
||||
var bonfireHash = req.body.bonfireInfo.bonfireHash;
|
||||
var isSolution = req.body.bonfireInfo.solution;
|
||||
var bonfireName = req.body.bonfireInfo.bonfireName;
|
||||
|
||||
if (isCompletedWith) {
|
||||
var paired = User.find({'profile.username': isCompletedWith
|
||||
.toLowerCase()}).limit(1);
|
||||
paired.exec(function (err, pairedWith) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else {
|
||||
var index = req.user.uncompletedBonfires.indexOf(bonfireHash);
|
||||
if (index > -1) {
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.uncompletedBonfires.splice(index, 1);
|
||||
}
|
||||
pairedWith = pairedWith.pop();
|
||||
|
||||
index = pairedWith.uncompletedBonfires.indexOf(bonfireHash);
|
||||
if (index > -1) {
|
||||
pairedWith.progressTimestamps.push(Date.now() || 0);
|
||||
pairedWith.uncompletedBonfires.splice(index, 1);
|
||||
|
||||
}
|
||||
|
||||
pairedWith.completedBonfires.push({
|
||||
_id: bonfireHash,
|
||||
name: bonfireName,
|
||||
completedWith: req.user._id,
|
||||
completedDate: isCompletedDate,
|
||||
solution: isSolution
|
||||
});
|
||||
|
||||
req.user.completedBonfires.push({
|
||||
_id: bonfireHash,
|
||||
name: bonfireName,
|
||||
completedWith: pairedWith._id,
|
||||
completedDate: isCompletedDate,
|
||||
solution: isSolution
|
||||
});
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
pairedWith.save(function (err, paired) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (user && paired) {
|
||||
res.send(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
req.user.completedBonfires.push({
|
||||
_id: bonfireHash,
|
||||
name: bonfireName,
|
||||
completedWith: null,
|
||||
completedDate: isCompletedDate,
|
||||
solution: isSolution
|
||||
});
|
||||
|
||||
var index = req.user.uncompletedBonfires.indexOf(bonfireHash);
|
||||
if (index > -1) {
|
||||
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.uncompletedBonfires.splice(index, 1);
|
||||
}
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (user) {
|
||||
res.send(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
524
controllers/challenge.js
Normal file
524
controllers/challenge.js
Normal file
@ -0,0 +1,524 @@
|
||||
/**
|
||||
* Created by nathanleniz on 5/15/15.
|
||||
* Copyright (c) 2015, Free Code Camp
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
var R = require('ramda'),
|
||||
Challenge = require('./../models/Challenge'),
|
||||
User = require('./../models/User'),
|
||||
resources = require('./resources'),
|
||||
MDNlinks = require('./../seed_data/bonfireMDNlinks');
|
||||
|
||||
var challengeMapWithNames = resources.getChallengeMapWithNames();
|
||||
var challengeMapWithIds = resources.getChallengeMapWithIds();
|
||||
|
||||
function getMDNlinks(links) {
|
||||
// takes in an array of links, which are strings
|
||||
var populatedLinks = [];
|
||||
|
||||
// for each key value, push the corresponding link
|
||||
// from the MDNlinks object into a new array
|
||||
if (links) {
|
||||
links.forEach(function (value) {
|
||||
populatedLinks.push(MDNlinks[value]);
|
||||
});
|
||||
}
|
||||
return populatedLinks;
|
||||
}
|
||||
|
||||
exports.returnNextChallenge = function(req, res, next) {
|
||||
if (!req.user) {
|
||||
return res.redirect('../challenges/learn-how-free-code-camp-works');
|
||||
}
|
||||
var completed = req.user.completedChallenges.map(function (elem) {
|
||||
return elem._id;
|
||||
});
|
||||
|
||||
req.user.uncompletedChallenges = resources.allChallengeIds()
|
||||
.filter(function (elem) {
|
||||
if (completed.indexOf(elem) === -1) {
|
||||
return elem;
|
||||
}
|
||||
});
|
||||
|
||||
// find the user's current challenge and block
|
||||
// look in that block and find the index of their current challenge
|
||||
// if index + 1 < block.challenges.length
|
||||
// serve index + 1 challenge
|
||||
// otherwise increment block key and serve the first challenge in that block
|
||||
// unless the next block is undefined, which means no next block
|
||||
var nextChallengeName;
|
||||
|
||||
var challengeId = String(req.user.currentChallenge.challengeId);
|
||||
var challengeBlock = req.user.currentChallenge.challengeBlock;
|
||||
var indexOfChallenge = challengeMapWithIds[challengeBlock]
|
||||
.indexOf(challengeId);
|
||||
|
||||
if (indexOfChallenge + 1
|
||||
< challengeMapWithIds[challengeBlock].length) {
|
||||
nextChallengeName =
|
||||
challengeMapWithNames[challengeBlock][++indexOfChallenge];
|
||||
} else if (typeof challengeMapWithIds[++challengeBlock] !== 'undefined') {
|
||||
nextChallengeName = R.head(challengeMapWithNames[challengeBlock]);
|
||||
} else {
|
||||
req.flash('errors', {
|
||||
msg: 'It looks like you have finished all of our challenges.' +
|
||||
' Great job! Now on to helping nonprofits!'
|
||||
});
|
||||
nextChallengeName = R.head(challengeMapWithNames[0].challenges);
|
||||
}
|
||||
|
||||
var nameString = nextChallengeName.trim()
|
||||
.toLowerCase()
|
||||
.replace(/\s/g, '-');
|
||||
|
||||
req.user.save(function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
return res.redirect('../challenges/' + nameString);
|
||||
});
|
||||
};
|
||||
|
||||
exports.returnCurrentChallenge = function(req, res, next) {
|
||||
if (!req.user) {
|
||||
return res.redirect('../challenges/learn-how-free-code-camp-works');
|
||||
}
|
||||
var completed = req.user.completedChallenges.map(function (elem) {
|
||||
return elem._id;
|
||||
});
|
||||
|
||||
req.user.uncompletedChallenges = resources.allChallengeIds()
|
||||
.filter(function (elem) {
|
||||
if (completed.indexOf(elem) === -1) {
|
||||
return elem;
|
||||
}
|
||||
});
|
||||
if (!req.user.currentChallenge) {
|
||||
req.user.currentChallenge = {};
|
||||
req.user.currentChallenge.challengeId = challengeMapWithIds['0'][0];
|
||||
req.user.currentChallenge.challengeName = challengeMapWithNames['0'][0];
|
||||
req.user.currentChallenge.challengeBlock = '0';
|
||||
req.user.save(function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
return res.redirect('../challenges/learn-how-free-code-camp-works');
|
||||
});
|
||||
}
|
||||
var nameString = req.user.currentChallenge.challengeName.trim()
|
||||
.toLowerCase()
|
||||
.replace(/\s/g, '-');
|
||||
req.user.save(function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
return res.redirect('../challenges/' + nameString);
|
||||
});
|
||||
};
|
||||
|
||||
exports.returnIndividualChallenge = function(req, res, next) {
|
||||
var dashedName = req.params.challengeName;
|
||||
|
||||
var challengeName = dashedName.replace(/\-/g, ' ');
|
||||
|
||||
Challenge.find({'name': new RegExp(challengeName, 'i')},
|
||||
function(err, challengeFromMongo) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
// Handle not found
|
||||
if (challengeFromMongo.length < 1) {
|
||||
req.flash('errors', {
|
||||
msg: '404: We couldn\'t find a challenge with that name. ' +
|
||||
'Please double check the name.'
|
||||
});
|
||||
return res.redirect('/challenges');
|
||||
}
|
||||
var challenge = challengeFromMongo.pop();
|
||||
// Redirect to full name if the user only entered a partial
|
||||
var dashedNameFull = challenge.name.toLowerCase().replace(/\s/g, '-');
|
||||
if (dashedNameFull !== dashedName) {
|
||||
return res.redirect('../challenges/' + dashedNameFull);
|
||||
} else {
|
||||
req.user.currentChallenge = {
|
||||
challengeId: challenge._id,
|
||||
challengeName: challenge.name,
|
||||
challengeBlock: R.head(R.flatten(Object.keys(challengeMapWithIds).
|
||||
map(function(key) {
|
||||
return challengeMapWithIds[key]
|
||||
.filter(function(elem) {
|
||||
return String(elem) === String(challenge._id);
|
||||
}).map(function() {
|
||||
return key;
|
||||
});
|
||||
})
|
||||
))
|
||||
};
|
||||
}
|
||||
|
||||
var challengeType = {
|
||||
0: function() {
|
||||
res.render('coursewares/showHTML', {
|
||||
title: challenge.name,
|
||||
dashedName: dashedName,
|
||||
name: challenge.name,
|
||||
brief: challenge.description[0],
|
||||
details: challenge.description.slice(1),
|
||||
tests: challenge.tests,
|
||||
challengeSeed: challenge.challengeSeed,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
challengeId: challenge._id,
|
||||
environment: resources.whichEnvironment(),
|
||||
challengeType: challenge.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
1: function() {
|
||||
res.render('coursewares/showJS', {
|
||||
title: challenge.name,
|
||||
dashedName: dashedName,
|
||||
name: challenge.name,
|
||||
brief: challenge.description[0],
|
||||
details: challenge.description.slice(1),
|
||||
tests: challenge.tests,
|
||||
challengeSeed: challenge.challengeSeed,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
challengeId: challenge._id,
|
||||
challengeType: challenge.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
2: function() {
|
||||
res.render('coursewares/showVideo', {
|
||||
title: challenge.name,
|
||||
dashedName: dashedName,
|
||||
name: challenge.name,
|
||||
details: challenge.description,
|
||||
tests: challenge.tests,
|
||||
video: challenge.challengeSeed[0],
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
challengeId: challenge._id,
|
||||
challengeType: challenge.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
3: function() {
|
||||
res.render('coursewares/showZiplineOrBasejump', {
|
||||
title: challenge.name,
|
||||
dashedName: dashedName,
|
||||
name: challenge.name,
|
||||
details: challenge.description,
|
||||
video: challenge.challengeSeed[0],
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
challengeId: challenge._id,
|
||||
challengeType: challenge.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
4: function() {
|
||||
res.render('coursewares/showZiplineOrBasejump', {
|
||||
title: challenge.name,
|
||||
dashedName: dashedName,
|
||||
name: challenge.name,
|
||||
details: challenge.description,
|
||||
video: challenge.challengeSeed[0],
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
challengeId: challenge._id,
|
||||
challengeType: challenge.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
5: function() {
|
||||
res.render('coursewares/showBonfire', {
|
||||
completedWith: null,
|
||||
title: challenge.name,
|
||||
dashedName: dashedName,
|
||||
name: challenge.name,
|
||||
difficulty: Math.floor(+challenge.difficulty),
|
||||
brief: challenge.description.shift(),
|
||||
details: challenge.description,
|
||||
tests: challenge.tests,
|
||||
challengeSeed: challenge.challengeSeed,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
bonfires: challenge,
|
||||
challengeId: challenge._id,
|
||||
MDNkeys: challenge.MDNlinks,
|
||||
MDNlinks: getMDNlinks(challenge.MDNlinks),
|
||||
challengeType: challenge.challengeType
|
||||
});
|
||||
}
|
||||
};
|
||||
req.user.save(function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
return challengeType[challenge.challengeType]();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.completedBonfire = function (req, res, next) {
|
||||
var isCompletedWith = req.body.challengeInfo.completedWith || '';
|
||||
var isCompletedDate = Math.round(+new Date());
|
||||
var challengeId = req.body.challengeInfo.challengeId;
|
||||
var isSolution = req.body.challengeInfo.solution;
|
||||
var challengeName = req.body.challengeInfo.challengeName;
|
||||
|
||||
if (isCompletedWith) {
|
||||
var paired = User.find({'profile.username': isCompletedWith.toLowerCase()})
|
||||
.limit(1);
|
||||
paired.exec(function (err, pairedWith) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else {
|
||||
var index = req.user.uncompletedChallenges.indexOf(challengeId);
|
||||
if (index > -1) {
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.uncompletedChallenges.splice(index, 1);
|
||||
}
|
||||
pairedWith = pairedWith.pop();
|
||||
|
||||
index = pairedWith.uncompletedChallenges.indexOf(challengeId);
|
||||
if (index > -1) {
|
||||
pairedWith.progressTimestamps.push(Date.now() || 0);
|
||||
pairedWith.uncompletedChallenges.splice(index, 1);
|
||||
|
||||
}
|
||||
|
||||
pairedWith.completedChallenges.push({
|
||||
_id: challengeId,
|
||||
name: challengeName,
|
||||
completedWith: req.user._id,
|
||||
completedDate: isCompletedDate,
|
||||
solution: isSolution,
|
||||
challengeType: 5
|
||||
});
|
||||
|
||||
req.user.completedChallenges.push({
|
||||
_id: challengeId,
|
||||
name: challengeName,
|
||||
completedWith: pairedWith._id,
|
||||
completedDate: isCompletedDate,
|
||||
solution: isSolution,
|
||||
challengeType: 5
|
||||
});
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
pairedWith.save(function (err, paired) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (user && paired) {
|
||||
res.send(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
req.user.completedChallenges.push({
|
||||
_id: challengeId,
|
||||
name: challengeName,
|
||||
completedWith: null,
|
||||
completedDate: isCompletedDate,
|
||||
solution: isSolution,
|
||||
challengeType: 5
|
||||
});
|
||||
|
||||
var index = req.user.uncompletedChallenges.indexOf(challengeId);
|
||||
if (index > -1) {
|
||||
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.uncompletedChallenges.splice(index, 1);
|
||||
}
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
// NOTE(berks): Under certain conditions the res is never ended
|
||||
if (user) {
|
||||
res.send(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.completedChallenge = function (req, res, next) {
|
||||
|
||||
var isCompletedDate = Math.round(+new Date());
|
||||
var challengeId = req.body.challengeInfo.challengeId;
|
||||
|
||||
req.user.completedChallenges.push({
|
||||
_id: challengeId,
|
||||
completedDate: isCompletedDate,
|
||||
name: req.body.challengeInfo.challengeName,
|
||||
solution: null,
|
||||
githubLink: null,
|
||||
verified: true
|
||||
});
|
||||
var index = req.user.uncompletedChallenges.indexOf(challengeId);
|
||||
|
||||
if (index > -1) {
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.uncompletedChallenges.splice(index, 1);
|
||||
}
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (user) {
|
||||
res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.completedZiplineOrBasejump = function (req, res, next) {
|
||||
|
||||
var isCompletedWith = req.body.challengeInfo.completedWith || false;
|
||||
var isCompletedDate = Math.round(+new Date());
|
||||
var challengeId = req.body.challengeInfo.challengeId;
|
||||
var solutionLink = req.body.challengeInfo.publicURL;
|
||||
var githubLink = req.body.challengeInfo.challengeType === '4'
|
||||
? req.body.challengeInfo.githubURL : true;
|
||||
if (!solutionLink || !githubLink) {
|
||||
req.flash('errors', {
|
||||
msg: 'You haven\'t supplied the necessary URLs for us to inspect ' +
|
||||
'your work.'
|
||||
});
|
||||
return res.sendStatus(403);
|
||||
}
|
||||
|
||||
if (isCompletedWith) {
|
||||
var paired = User.find({'profile.username': isCompletedWith.toLowerCase()})
|
||||
.limit(1);
|
||||
|
||||
paired.exec(function (err, pairedWithFromMongo) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else {
|
||||
var index = req.user.uncompletedChallenges.indexOf(challengeId);
|
||||
if (index > -1) {
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.uncompletedChallenges.splice(index, 1);
|
||||
}
|
||||
var pairedWith = pairedWithFromMongo.pop();
|
||||
|
||||
req.user.completedChallenges.push({
|
||||
_id: challengeId,
|
||||
name: req.body.challengeInfo.challengeName,
|
||||
completedWith: pairedWith._id,
|
||||
completedDate: isCompletedDate,
|
||||
solution: solutionLink,
|
||||
githubLink: githubLink,
|
||||
verified: false
|
||||
});
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (req.user._id.toString() === pairedWith._id.toString()) {
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
index = pairedWith.uncompletedChallenges.indexOf(challengeId);
|
||||
if (index > -1) {
|
||||
pairedWith.progressTimestamps.push(Date.now() || 0);
|
||||
pairedWith.uncompletedChallenges.splice(index, 1);
|
||||
|
||||
}
|
||||
|
||||
pairedWith.completedChallenges.push({
|
||||
_id: challengeId,
|
||||
name: req.body.challengeInfo.coursewareName,
|
||||
completedWith: req.user._id,
|
||||
completedDate: isCompletedDate,
|
||||
solution: solutionLink,
|
||||
githubLink: githubLink,
|
||||
verified: false
|
||||
});
|
||||
pairedWith.save(function (err, paired) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (user && paired) {
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
req.user.completedChallenges.push({
|
||||
_id: challengeId,
|
||||
name: req.body.challengeInfo.challengeName,
|
||||
completedWith: null,
|
||||
completedDate: isCompletedDate,
|
||||
solution: solutionLink,
|
||||
githubLink: githubLink,
|
||||
verified: false
|
||||
});
|
||||
|
||||
var index = req.user.uncompletedChallenges.indexOf(challengeId);
|
||||
if (index > -1) {
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.uncompletedChallenges.splice(index, 1);
|
||||
}
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
// NOTE(berks): under certain conditions this will not close the response.
|
||||
if (user) {
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
@ -1,62 +1,85 @@
|
||||
var async = require('async'),
|
||||
var R = require('ramda'),
|
||||
debug = require('debug')('freecc:cntr:challengeMap'),
|
||||
User = require('../models/User'),
|
||||
Bonfire = require('./../models/Bonfire'),
|
||||
Story = require('./../models/Story'),
|
||||
Nonprofit = require('./../models/Nonprofit'),
|
||||
Comment = require('./../models/Comment'),
|
||||
Courseware = require('./../models/Courseware'),
|
||||
resources = require('./resources'),
|
||||
steps = resources.steps,
|
||||
secrets = require('./../config/secrets'),
|
||||
bonfires = require('../seed_data/bonfires.json'),
|
||||
nonprofits = require('../seed_data/nonprofits.json'),
|
||||
coursewares = require('../seed_data/coursewares.json'),
|
||||
moment = require('moment'),
|
||||
https = require('https'),
|
||||
debug = require('debug')('freecc:cntr:resources'),
|
||||
cheerio = require('cheerio'),
|
||||
request = require('request'),
|
||||
R = require('ramda');
|
||||
resources = require('./resources');
|
||||
|
||||
var challengeTypes = {
|
||||
'HTML_CSS_JQ': 0,
|
||||
'JAVASCRIPT': 1,
|
||||
'VIDEO': 2,
|
||||
'ZIPLINE': 3,
|
||||
'BASEJUMP': 4,
|
||||
'BONFIRE': 5
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
challengeMap: function challengeMap(req, res) {
|
||||
var completedBonfires = [];
|
||||
challengeMap: function challengeMap(req, res, next) {
|
||||
var completedList = [];
|
||||
|
||||
if (req.user) {
|
||||
completedBonfires = req.user.completedBonfires.map(function (elem) {
|
||||
return elem._id;
|
||||
});
|
||||
completedList = req.user.completedChallenges;
|
||||
}
|
||||
|
||||
if (req.user) {
|
||||
completedList = req.user.completedCoursewares.map(function (elem) {
|
||||
return elem._id;
|
||||
var noDuplicatedChallenges = R.uniq(completedList);
|
||||
|
||||
|
||||
var challengeList = resources.allChallenges();
|
||||
var completedChallengeList = noDuplicatedChallenges
|
||||
.map(function(challenge) {
|
||||
return challenge._id;
|
||||
});
|
||||
|
||||
var bonfireList = challengeList
|
||||
.filter(function(challenge) {
|
||||
return challenge.challengeType === challengeTypes.BONFIRE;
|
||||
})
|
||||
.map(function(bonfire) {
|
||||
return ({
|
||||
'_id': bonfire._id,
|
||||
'name': bonfire.name
|
||||
});
|
||||
});
|
||||
|
||||
var waypoints = challengeList.filter(function(challenge) {
|
||||
if (challenge.challengeType === challengeTypes.VIDEO
|
||||
|| challenge.challengeType === challengeTypes.HTML_CSS_JQ
|
||||
|| challenge.challengeType === challengeTypes.JAVASCRIPT) {
|
||||
return challenge;
|
||||
}
|
||||
|
||||
var noDuplicateBonfires = R.uniq(completedBonfires);
|
||||
var noDuplicatedCoursewares = R.uniq(completedList);
|
||||
|
||||
bonfireList = resources.allBonfireNames();
|
||||
completedBonfireList = noDuplicateBonfires;
|
||||
coursewareList = resources.allCoursewareNames();
|
||||
completedCoursewareList = noDuplicatedCoursewares;
|
||||
waypoints = coursewareList.filter(function(challenge) {
|
||||
if (challenge.challengeType === 2) { return challenge }
|
||||
}).map(function(waypoint) {
|
||||
return ({
|
||||
'_id': waypoint._id,
|
||||
'name': waypoint.name
|
||||
});
|
||||
ziplines = coursewareList.filter(function(challenge) {
|
||||
if (challenge.challengeType === 3) { return challenge }
|
||||
});
|
||||
basejumps = coursewareList.filter(function(challenge) {
|
||||
if (challenge.challengeType === 4) { return challenge }
|
||||
|
||||
var ziplines = challengeList.filter(function(challenge) {
|
||||
if (challenge.challengeType === challengeTypes.ZIPLINE) {
|
||||
return challenge;
|
||||
}
|
||||
}).map(function(zipline) {
|
||||
return ({
|
||||
'_id': zipline._id,
|
||||
'name': zipline.name
|
||||
});
|
||||
});
|
||||
|
||||
var basejumps = challengeList.filter(function(challenge) {
|
||||
if (challenge.challengeType === challengeTypes.BASEJUMP) {
|
||||
return challenge;
|
||||
}
|
||||
}).map(function(basejump) {
|
||||
return ({
|
||||
'_id': basejump._id,
|
||||
'name': basejump.name
|
||||
});
|
||||
});
|
||||
|
||||
function numberWithCommas(x) {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
}
|
||||
|
||||
var date1 = new Date("10/15/2014");
|
||||
var date1 = new Date('10/15/2014');
|
||||
var date2 = new Date();
|
||||
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
|
||||
var daysRunning = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
||||
@ -74,8 +97,7 @@ module.exports = {
|
||||
waypoints: waypoints,
|
||||
ziplines: ziplines,
|
||||
basejumps: basejumps,
|
||||
completedBonfireList: completedBonfireList,
|
||||
completedCoursewareList: completedCoursewareList
|
||||
completedChallengeList: completedChallengeList
|
||||
});
|
||||
});
|
||||
}
|
||||
|
3
controllers/constantStrings.json
Normal file
3
controllers/constantStrings.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"gitHubUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1521.3 Safari/537.36"
|
||||
}
|
@ -1,388 +0,0 @@
|
||||
var _ = require('lodash'),
|
||||
debug = require('debug')('freecc:cntr:courseware'),
|
||||
Courseware = require('./../models/Courseware'),
|
||||
User = require('./../models/User'),
|
||||
resources = require('./resources'),
|
||||
R = require('ramda'),
|
||||
moment = require('moment');
|
||||
|
||||
/**
|
||||
* Courseware controller
|
||||
*/
|
||||
|
||||
exports.showAllCoursewares = function(req, res) {
|
||||
var completedList = [];
|
||||
if(req.user) {
|
||||
completedList = req.user.completedCoursewares.map(function (elem) {
|
||||
return elem._id;
|
||||
});
|
||||
}
|
||||
var noDuplicatedCoursewares = R.uniq(completedList);
|
||||
var data = {};
|
||||
data.coursewareList = resources.allCoursewareNames();
|
||||
data.completedList = noDuplicatedCoursewares;
|
||||
res.send(data);
|
||||
};
|
||||
|
||||
exports.returnNextCourseware = function(req, res, next) {
|
||||
if (!req.user) {
|
||||
return res.redirect('../challenges/learn-how-free-code-camp-works');
|
||||
}
|
||||
if (req.user.finishedWaypoints && req.user.uncompletedBonfires.length > 0) {
|
||||
return res.redirect('../bonfires')
|
||||
}
|
||||
|
||||
var completed = req.user.completedCoursewares.map(function (elem) {
|
||||
return elem._id;
|
||||
});
|
||||
|
||||
req.user.uncompletedCoursewares = resources.allCoursewareIds()
|
||||
.filter(function (elem) {
|
||||
if (completed.indexOf(elem) === -1) {
|
||||
return elem;
|
||||
}
|
||||
});
|
||||
req.user.save();
|
||||
|
||||
var uncompletedCoursewares = req.user.uncompletedCoursewares[0];
|
||||
|
||||
|
||||
var displayedCoursewares = Courseware.find({'_id': uncompletedCoursewares});
|
||||
displayedCoursewares.exec(function(err, courseware) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
courseware = courseware.pop();
|
||||
if (typeof courseware === 'undefined') {
|
||||
req.flash('errors', {
|
||||
msg: "It looks like you've completed all the courses we have " +
|
||||
"available. Good job!"
|
||||
});
|
||||
return res.redirect('../challenges/learn-how-free-code-camp-works');
|
||||
}
|
||||
var nameString = courseware.name.toLowerCase().replace(/\s/g, '-');
|
||||
return res.redirect('../challenges/' + nameString);
|
||||
});
|
||||
};
|
||||
|
||||
exports.returnIndividualCourseware = function(req, res, next) {
|
||||
var dashedName = req.params.coursewareName;
|
||||
|
||||
var coursewareName = dashedName.replace(/\-/g, ' ');
|
||||
|
||||
Courseware.find({'name': new RegExp(coursewareName, 'i')},
|
||||
function(err, coursewareFromMongo) {
|
||||
if (err) {
|
||||
next(err);
|
||||
}
|
||||
// Handle not found
|
||||
if (coursewareFromMongo.length < 1) {
|
||||
req.flash('errors', {
|
||||
msg: "404: We couldn't find a challenge with that name. " +
|
||||
"Please double check the name."
|
||||
});
|
||||
return res.redirect('/challenges');
|
||||
}
|
||||
var courseware = coursewareFromMongo.pop();
|
||||
|
||||
// Redirect to full name if the user only entered a partial
|
||||
var dashedNameFull = courseware.name.toLowerCase().replace(/\s/g, '-');
|
||||
if (dashedNameFull !== dashedName) {
|
||||
return res.redirect('../challenges/' + dashedNameFull);
|
||||
}
|
||||
|
||||
var challengeType = {
|
||||
0: function() {
|
||||
res.render('coursewares/showHTML', {
|
||||
title: courseware.name,
|
||||
dashedName: dashedName,
|
||||
name: courseware.name,
|
||||
brief: courseware.description[0],
|
||||
details: courseware.description.slice(1),
|
||||
tests: courseware.tests,
|
||||
challengeSeed: courseware.challengeSeed,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
coursewareHash: courseware._id,
|
||||
environment: resources.whichEnvironment(),
|
||||
challengeType: courseware.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
1: function() {
|
||||
res.render('coursewares/showJS', {
|
||||
title: courseware.name,
|
||||
dashedName: dashedName,
|
||||
name: courseware.name,
|
||||
brief: courseware.description[0],
|
||||
details: courseware.description.slice(1),
|
||||
tests: courseware.tests,
|
||||
challengeSeed: courseware.challengeSeed,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
coursewareHash: courseware._id,
|
||||
challengeType: courseware.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
2: function() {
|
||||
res.render('coursewares/showVideo', {
|
||||
title: courseware.name,
|
||||
dashedName: dashedName,
|
||||
name: courseware.name,
|
||||
details: courseware.description,
|
||||
tests: courseware.tests,
|
||||
video: courseware.challengeSeed[0],
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
coursewareHash: courseware._id,
|
||||
challengeType: courseware.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
3: function() {
|
||||
res.render('coursewares/showZiplineOrBasejump', {
|
||||
title: courseware.name,
|
||||
dashedName: dashedName,
|
||||
name: courseware.name,
|
||||
details: courseware.description,
|
||||
video: courseware.challengeSeed[0],
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
coursewareHash: courseware._id,
|
||||
challengeType: courseware.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
4: function() {
|
||||
res.render('coursewares/showZiplineOrBasejump', {
|
||||
title: courseware.name,
|
||||
dashedName: dashedName,
|
||||
name: courseware.name,
|
||||
details: courseware.description,
|
||||
video: courseware.challengeSeed[0],
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
coursewareHash: courseware._id,
|
||||
challengeType: courseware.challengeType
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return challengeType[courseware.challengeType]();
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
exports.testCourseware = function(req, res) {
|
||||
var coursewareName = req.body.name,
|
||||
coursewareTests = req.body.tests,
|
||||
coursewareDifficulty = req.body.difficulty,
|
||||
coursewareDescription = req.body.description,
|
||||
coursewareEntryPoint = req.body.challengeEntryPoint,
|
||||
coursewareChallengeSeed = req.body.challengeSeed;
|
||||
coursewareTests = coursewareTests.split('\r\n');
|
||||
coursewareDescription = coursewareDescription.split('\r\n');
|
||||
coursewareTests.filter(getRidOfEmpties);
|
||||
coursewareDescription.filter(getRidOfEmpties);
|
||||
coursewareChallengeSeed = coursewareChallengeSeed.replace('\r', '');
|
||||
res.render('courseware/show', {
|
||||
completedWith: null,
|
||||
title: coursewareName,
|
||||
name: coursewareName,
|
||||
difficulty: +coursewareDifficulty,
|
||||
brief: coursewareDescription[0],
|
||||
details: coursewareDescription.slice(1),
|
||||
tests: coursewareTests,
|
||||
challengeSeed: coursewareChallengeSeed,
|
||||
challengeEntryPoint: coursewareEntryPoint,
|
||||
cc: req.user ? req.user.coursewaresHash : undefined,
|
||||
progressTimestamps: req.user ? req.user.progressTimestamps : undefined,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
coursewares: [],
|
||||
coursewareHash: 'test'
|
||||
});
|
||||
};
|
||||
|
||||
function getRidOfEmpties(elem) {
|
||||
if (elem.length > 0) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
|
||||
exports.publicGenerator = function(req, res) {
|
||||
res.render('courseware/public-generator');
|
||||
};
|
||||
|
||||
exports.generateChallenge = function(req, res) {
|
||||
var coursewareName = req.body.name,
|
||||
coursewareTests = req.body.tests,
|
||||
coursewareDifficulty = req.body.difficulty,
|
||||
coursewareDescription = req.body.description,
|
||||
coursewareEntryPoint = req.body.challengeEntryPoint,
|
||||
coursewareChallengeSeed = req.body.challengeSeed;
|
||||
coursewareTests = coursewareTests.split('\r\n');
|
||||
coursewareDescription = coursewareDescription.split('\r\n');
|
||||
coursewareTests.filter(getRidOfEmpties);
|
||||
coursewareDescription.filter(getRidOfEmpties);
|
||||
coursewareChallengeSeed = coursewareChallengeSeed.replace('\r', '');
|
||||
|
||||
var response = {
|
||||
_id: randomString(),
|
||||
name: coursewareName,
|
||||
difficulty: coursewareDifficulty,
|
||||
description: coursewareDescription,
|
||||
challengeEntryPoint: coursewareEntryPoint,
|
||||
challengeSeed: coursewareChallengeSeed,
|
||||
tests: coursewareTests
|
||||
};
|
||||
res.send(response);
|
||||
};
|
||||
|
||||
exports.completedCourseware = function (req, res, next) {
|
||||
|
||||
var isCompletedDate = Math.round(+new Date());
|
||||
var coursewareHash = req.body.coursewareInfo.coursewareHash;
|
||||
if (coursewareHash === "bd7139d8c441eddfaeb5bdef") {
|
||||
req.user.finishedWaypoints = true;
|
||||
}
|
||||
|
||||
req.user.completedCoursewares.push({
|
||||
_id: coursewareHash,
|
||||
completedDate: isCompletedDate,
|
||||
name: req.body.coursewareInfo.coursewareName,
|
||||
solution: null,
|
||||
githubLink: null,
|
||||
verified: true
|
||||
});
|
||||
var index = req.user.uncompletedCoursewares.indexOf(coursewareHash);
|
||||
|
||||
if (index > -1) {
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.uncompletedCoursewares.splice(index, 1);
|
||||
}
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (user) {
|
||||
res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.completedZiplineOrBasejump = function (req, res, next) {
|
||||
debug('Inside controller for completed zipline or basejump with data %s',
|
||||
req.body.coursewareInfo);
|
||||
var isCompletedWith = req.body.coursewareInfo.completedWith || false;
|
||||
var isCompletedDate = Math.round(+new Date());
|
||||
var coursewareHash = req.body.coursewareInfo.coursewareHash;
|
||||
var solutionLink = req.body.coursewareInfo.publicURL;
|
||||
var githubLink = req.body.coursewareInfo.challengeType === '4'
|
||||
? req.body.coursewareInfo.githubURL : true;
|
||||
if (!solutionLink || !githubLink) {
|
||||
req.flash('errors', {
|
||||
msg: 'You haven\'t supplied the necessary URLs for us to inspect ' +
|
||||
'your work.'
|
||||
});
|
||||
return res.sendStatus(403);
|
||||
}
|
||||
|
||||
if (isCompletedWith) {
|
||||
var paired = User.find({'profile.username': isCompletedWith.toLowerCase()}).limit(1);
|
||||
paired.exec(function (err, pairedWithFromMongo) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else {
|
||||
var index = req.user.uncompletedCoursewares.indexOf(coursewareHash);
|
||||
if (index > -1) {
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.uncompletedCoursewares.splice(index, 1);
|
||||
}
|
||||
var pairedWith = pairedWithFromMongo.pop();
|
||||
|
||||
req.user.completedCoursewares.push({
|
||||
_id: coursewareHash,
|
||||
name: req.body.coursewareInfo.coursewareName,
|
||||
completedWith: pairedWith._id,
|
||||
completedDate: isCompletedDate,
|
||||
solution: solutionLink,
|
||||
githubLink: githubLink,
|
||||
verified: false
|
||||
});
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
debug('this is the user object returned %s,' +
|
||||
' this is the req.user._id %s, ' +
|
||||
'this is the pairedWith._id %s', user, req.user._id, pairedWith._id);
|
||||
debug(req.user._id.toString() === pairedWith._id.toString());
|
||||
if (req.user._id.toString() === pairedWith._id.toString()) {
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
index = pairedWith.uncompletedCoursewares.indexOf(coursewareHash);
|
||||
if (index > -1) {
|
||||
pairedWith.progressTimestamps.push(Date.now() || 0);
|
||||
pairedWith.uncompletedCoursewares.splice(index, 1);
|
||||
|
||||
}
|
||||
|
||||
pairedWith.completedCoursewares.push({
|
||||
_id: coursewareHash,
|
||||
name: req.body.coursewareInfo.coursewareName,
|
||||
completedWith: req.user._id,
|
||||
completedDate: isCompletedDate,
|
||||
solution: solutionLink,
|
||||
githubLink: githubLink,
|
||||
verified: false
|
||||
});
|
||||
pairedWith.save(function (err, paired) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (user && paired) {
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
req.user.completedCoursewares.push({
|
||||
_id: coursewareHash,
|
||||
name: req.body.coursewareInfo.coursewareName,
|
||||
completedWith: null,
|
||||
completedDate: isCompletedDate,
|
||||
solution: solutionLink,
|
||||
githubLink: githubLink,
|
||||
verified: false
|
||||
});
|
||||
|
||||
var index = req.user.uncompletedCoursewares.indexOf(coursewareHash);
|
||||
if (index > -1) {
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.uncompletedCoursewares.splice(index, 1);
|
||||
}
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (user) {
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
@ -1,8 +1,6 @@
|
||||
var _ = require('lodash'),
|
||||
debug = require('debug')('freecc:cntr:fieldGuide'),
|
||||
var R = require('ramda'),
|
||||
FieldGuide = require('./../models/FieldGuide'),
|
||||
resources = require('./resources'),
|
||||
R = require('ramda');
|
||||
resources = require('./resources');
|
||||
|
||||
exports.returnIndividualFieldGuide = function(req, res, next) {
|
||||
var dashedName = req.params.fieldGuideName;
|
||||
@ -12,30 +10,37 @@ exports.returnIndividualFieldGuide = function(req, res, next) {
|
||||
if (req.user) {
|
||||
var completed = req.user.completedFieldGuides;
|
||||
|
||||
var uncompletedFieldGuides = resources.allFieldGuideIds().filter(function (elem) {
|
||||
var uncompletedFieldGuides = resources.allFieldGuideIds()
|
||||
.filter(function (elem) {
|
||||
if (completed.indexOf(elem) === -1) {
|
||||
return elem;
|
||||
}
|
||||
});
|
||||
req.user.uncompletedFieldGuides = uncompletedFieldGuides;
|
||||
// TODO(berks): handle callback properly
|
||||
req.user.save();
|
||||
}
|
||||
|
||||
FieldGuide.find({'name': new RegExp(fieldGuideName, 'i')}, function(err, fieldGuideFromMongo) {
|
||||
FieldGuide.find(
|
||||
{ name: new RegExp(fieldGuideName, 'i') },
|
||||
function(err, fieldGuideFromMongo) {
|
||||
if (err) {
|
||||
next(err);
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (fieldGuideFromMongo.length < 1) {
|
||||
req.flash('errors', {
|
||||
msg: "404: We couldn't find a field guide entry with that name. Please double check the name."
|
||||
msg: "404: We couldn't find a field guide entry with that name. " +
|
||||
'Please double check the name.'
|
||||
});
|
||||
|
||||
return res.redirect('/field-guide');
|
||||
}
|
||||
|
||||
var fieldGuide = R.head(fieldGuideFromMongo);
|
||||
var dashedNameFull = fieldGuide.name.toLowerCase().replace(/\s/g, '-').replace(/\?/g, '');
|
||||
var dashedNameFull =
|
||||
fieldGuide.name.toLowerCase().replace(/\s/g, '-').replace(/\?/g, '');
|
||||
|
||||
if (dashedNameFull !== dashedName) {
|
||||
return res.redirect('../field-guide/' + dashedNameFull);
|
||||
}
|
||||
@ -44,13 +49,15 @@ exports.returnIndividualFieldGuide = function(req, res, next) {
|
||||
fieldGuideId: fieldGuide._id,
|
||||
description: fieldGuide.description.join('')
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
exports.showAllFieldGuides = function(req, res) {
|
||||
var data = {};
|
||||
data.fieldGuideList = resources.allFieldGuideNames();
|
||||
data.fieldGuideIds = resources.allFieldGuideIds();
|
||||
|
||||
if (req.user && req.user.completedFieldGuides) {
|
||||
data.completedFieldGuides = req.user.completedFieldGuides;
|
||||
} else {
|
||||
@ -64,16 +71,22 @@ exports.returnNextFieldGuide = function(req, res, next) {
|
||||
return res.redirect('/field-guide/how-do-i-use-this-guide?');
|
||||
}
|
||||
|
||||
var displayedFieldGuides = FieldGuide.find({'_id': req.user.uncompletedFieldGuides[0]});
|
||||
var displayedFieldGuides =
|
||||
FieldGuide.find({'_id': req.user.uncompletedFieldGuides[0]});
|
||||
|
||||
displayedFieldGuides.exec(function(err, fieldGuide) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (err) { return next(err); }
|
||||
fieldGuide = fieldGuide.pop();
|
||||
|
||||
if (typeof fieldGuide === 'undefined') {
|
||||
if (req.user.completedFieldGuides.length > 0) {
|
||||
req.flash('success', {
|
||||
msg: "You've read all our current Field Guide entries. You can contribute to our Field Guide <a href='https://github.com/FreeCodeCamp/freecodecamp/blob/master/seed_data/field-guides.json'>here</a>."
|
||||
msg: [
|
||||
"You've read all our current Field Guide entries. You can ",
|
||||
'contribute to our Field Guide ',
|
||||
"<a href='https://github.com/FreeCodeCamp/freecodecamp/blob/",
|
||||
"staging/seed_data/field-guides.json'>here</a>."
|
||||
].join('')
|
||||
});
|
||||
}
|
||||
return res.redirect('../field-guide/how-do-i-use-this-guide?');
|
||||
@ -94,12 +107,10 @@ exports.completedFieldGuide = function (req, res, next) {
|
||||
req.user.uncompletedFieldGuides.splice(index, 1);
|
||||
}
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
req.user.save(function (err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (user) {
|
||||
res.send(true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -1,16 +1,16 @@
|
||||
/**
|
||||
* GET /
|
||||
* Home page.
|
||||
*/
|
||||
var message =
|
||||
'Learn to Code JavaScript and get a Coding Job by Helping Nonprofits';
|
||||
|
||||
exports.index = function(req, res, next) {
|
||||
if (req.user && !req.user.profile.picture) {
|
||||
req.user.profile.picture = 'https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png';
|
||||
req.user.profile.picture =
|
||||
'https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png';
|
||||
|
||||
req.user.save(function(err) {
|
||||
if (err) { return next(err); }
|
||||
res.render('home', { title: message });
|
||||
});
|
||||
} else {
|
||||
res.render('home', { title: message });
|
||||
}
|
||||
res.render('home', {
|
||||
title: 'Learn to Code JavaScript and get a Coding Job by Helping Nonprofits'
|
||||
});
|
||||
};
|
||||
|
@ -1,16 +1,11 @@
|
||||
var async = require('async'),
|
||||
var moment = require('moment'),
|
||||
Nonprofit = require('./../models/Nonprofit'),
|
||||
resources = require('./resources'),
|
||||
secrets = require('./../config/secrets'),
|
||||
moment = require('moment'),
|
||||
debug = require('debug')('freecc:cntr:nonprofits'),
|
||||
R = require('ramda');
|
||||
resources = require('./resources');
|
||||
|
||||
exports.nonprofitsDirectory = function(req, res) {
|
||||
exports.nonprofitsDirectory = function(req, res, next) {
|
||||
Nonprofit.find({estimatedHours: { $gt: 0 } }, function(err, nonprofits) {
|
||||
if (err) {
|
||||
next(err);
|
||||
}
|
||||
if (err) { return next(err); }
|
||||
|
||||
res.render('nonprofits/directory', {
|
||||
title: 'Nonprofits we help',
|
||||
nonprofits: nonprofits
|
||||
@ -25,11 +20,16 @@ exports.areYouWithARegisteredNonprofit = function(req, res) {
|
||||
});
|
||||
};
|
||||
|
||||
exports.areTherePeopleThatAreAlreadyBenefitingFromYourServices = function(req, res) {
|
||||
res.render('nonprofits/are-there-people-that-are-already-benefiting-from-your-services', {
|
||||
exports.areTherePeopleThatAreAlreadyBenefitingFromYourServices =
|
||||
function(req, res) {
|
||||
res.render(
|
||||
'nonprofits/' +
|
||||
'are-there-people-that-are-already-benefiting-from-your-services',
|
||||
{
|
||||
title: 'Are there people already benefiting from your services',
|
||||
step: 2
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
exports.okWithJavaScript = function(req, res) {
|
||||
@ -83,11 +83,14 @@ exports.tellUsYourName = function(req, res) {
|
||||
};
|
||||
|
||||
exports.yourNonprofitProjectApplicationHasBeenSubmitted = function(req, res) {
|
||||
res.render('nonprofits/your-nonprofit-project-application-has-been-submitted', {
|
||||
res.render(
|
||||
'nonprofits/your-nonprofit-project-application-has-been-submitted',
|
||||
{
|
||||
title: 'Your Nonprofit Project application has been submitted!',
|
||||
step: 10,
|
||||
getBackDay: moment().weekday(5).format('dddd')
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
exports.otherSolutions = function(req, res) {
|
||||
@ -98,17 +101,19 @@ exports.otherSolutions = function(req, res) {
|
||||
|
||||
exports.returnIndividualNonprofit = function(req, res, next) {
|
||||
var dashedName = req.params.nonprofitName;
|
||||
|
||||
var nonprofitName = dashedName.replace(/\-/g, ' ');
|
||||
|
||||
Nonprofit.find({'name': new RegExp(nonprofitName, 'i')}, function(err, nonprofit) {
|
||||
Nonprofit.find(
|
||||
{ name: new RegExp(nonprofitName, 'i') },
|
||||
function(err, nonprofit) {
|
||||
if (err) {
|
||||
next(err);
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (nonprofit.length < 1) {
|
||||
req.flash('errors', {
|
||||
msg: "404: We couldn't find a nonprofit with that name. Please double check the name."
|
||||
msg: "404: We couldn't find a nonprofit with that name. " +
|
||||
'Please double check the name.'
|
||||
});
|
||||
|
||||
return res.redirect('/nonprofits');
|
||||
@ -116,36 +121,52 @@ exports.returnIndividualNonprofit = function(req, res, next) {
|
||||
|
||||
nonprofit = nonprofit.pop();
|
||||
var dashedNameFull = nonprofit.name.toLowerCase().replace(/\s/g, '-');
|
||||
if (dashedNameFull != dashedName) {
|
||||
if (dashedNameFull !== dashedName) {
|
||||
return res.redirect('../nonprofit/' + dashedNameFull);
|
||||
}
|
||||
var buttonActive = false;
|
||||
if (req.user) {
|
||||
if (req.user.uncompletedBonfires.length === 0) {
|
||||
if (req.user.completedCoursewares.length > 63) {
|
||||
var hasShownInterest = nonprofit.interestedCampers.filter(function ( obj ) {
|
||||
var hasShownInterest =
|
||||
nonprofit.interestedCampers.filter(function ( obj ) {
|
||||
return obj.username === req.user.profile.username;
|
||||
});
|
||||
|
||||
if (hasShownInterest.length === 0) {
|
||||
buttonActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.render('nonprofits/show', {
|
||||
dashedName: dashedNameFull,
|
||||
title: nonprofit.name,
|
||||
logoUrl: nonprofit.logoUrl,
|
||||
estimatedHours: nonprofit.estimatedHours,
|
||||
projectDescription: nonprofit.projectDescription,
|
||||
approvedOther: nonprofit.approvedDeliverables.indexOf('other') > -1,
|
||||
approvedWebsite: nonprofit.approvedDeliverables.indexOf('website') > -1,
|
||||
approvedDonor: nonprofit.approvedDeliverables.indexOf('donor') > -1,
|
||||
approvedInventory: nonprofit.approvedDeliverables.indexOf('inventory') > -1,
|
||||
approvedVolunteer: nonprofit.approvedDeliverables.indexOf('volunteer') > -1,
|
||||
approvedForm: nonprofit.approvedDeliverables.indexOf('form') > -1,
|
||||
approvedCommunity: nonprofit.approvedDeliverables.indexOf('community') > -1,
|
||||
approvedELearning: nonprofit.approvedDeliverables.indexOf('eLearning') > -1,
|
||||
|
||||
approvedOther:
|
||||
nonprofit.approvedDeliverables.indexOf('other') > -1,
|
||||
approvedWebsite:
|
||||
nonprofit.approvedDeliverables.indexOf('website') > -1,
|
||||
|
||||
approvedDonor:
|
||||
nonprofit.approvedDeliverables.indexOf('donor') > -1,
|
||||
approvedInventory:
|
||||
nonprofit.approvedDeliverables.indexOf('inventory') > -1,
|
||||
|
||||
approvedVolunteer:
|
||||
nonprofit.approvedDeliverables.indexOf('volunteer') > -1,
|
||||
approvedForm:
|
||||
nonprofit.approvedDeliverables.indexOf('form') > -1,
|
||||
|
||||
approvedCommunity:
|
||||
nonprofit.approvedDeliverables.indexOf('community') > -1,
|
||||
approvedELearning:
|
||||
nonprofit.approvedDeliverables.indexOf('eLearning') > -1,
|
||||
|
||||
websiteLink: nonprofit.websiteLink,
|
||||
imageUrl: nonprofit.imageUrl,
|
||||
whatDoesNonprofitDo: nonprofit.whatDoesNonprofitDo,
|
||||
@ -154,7 +175,8 @@ exports.returnIndividualNonprofit = function(req, res, next) {
|
||||
buttonActive: buttonActive,
|
||||
currentStatus: nonprofit.currentStatus
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
exports.showAllNonprofits = function(req, res) {
|
||||
@ -163,19 +185,26 @@ exports.showAllNonprofits = function(req, res) {
|
||||
res.send(data);
|
||||
};
|
||||
|
||||
exports.interestedInNonprofit = function(req, res) {
|
||||
exports.interestedInNonprofit = function(req, res, next) {
|
||||
if (req.user) {
|
||||
Nonprofit.findOne({name: new RegExp(req.params.nonprofitName.replace(/-/, ' '), 'i')}, function(err, nonprofit) {
|
||||
Nonprofit.findOne(
|
||||
{ name: new RegExp(req.params.nonprofitName.replace(/-/, ' '), 'i') },
|
||||
function(err, nonprofit) {
|
||||
if (err) { return next(err); }
|
||||
nonprofit.interestedCampers.push({"username": req.user.profile.username,
|
||||
"picture": req.user.profile.picture,
|
||||
"timeOfInterest": Date.now()
|
||||
nonprofit.interestedCampers.push({
|
||||
username: req.user.profile.username,
|
||||
picture: req.user.profile.picture,
|
||||
timeOfInterest: Date.now()
|
||||
});
|
||||
nonprofit.save(function(err) {
|
||||
if (err) { return done(err); }
|
||||
req.flash('success', { msg: "Thanks for expressing interest in this nonprofit project! We've added you to this project as an interested camper!" });
|
||||
if (err) { return next(err); }
|
||||
req.flash('success', {
|
||||
msg: 'Thanks for expressing interest in this nonprofit project! ' +
|
||||
"We've added you to this project as an interested camper!"
|
||||
});
|
||||
res.redirect('back');
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -1,32 +1,32 @@
|
||||
var async = require('async'),
|
||||
path = require('path'),
|
||||
moment = require('moment'),
|
||||
Twit = require('twit'),
|
||||
debug = require('debug')('freecc:cntr:resources'),
|
||||
cheerio = require('cheerio'),
|
||||
request = require('request'),
|
||||
R = require('ramda'),
|
||||
_ = require('lodash'),
|
||||
fs = require('fs'),
|
||||
|
||||
constantStrings = require('./constantStrings.json'),
|
||||
User = require('../models/User'),
|
||||
Challenge = require('./../models/Challenge'),
|
||||
Courseware = require('./../models/Courseware'),
|
||||
Bonfire = require('./../models/Bonfire'),
|
||||
Story = require('./../models/Story'),
|
||||
FieldGuide = require('./../models/FieldGuide'),
|
||||
Nonprofit = require('./../models/Nonprofit'),
|
||||
Comment = require('./../models/Comment'),
|
||||
resources = require('./resources.json'),
|
||||
secrets = require('./../config/secrets'),
|
||||
bonfires = require('../seed_data/bonfires.json'),
|
||||
nonprofits = require('../seed_data/nonprofits.json'),
|
||||
coursewares = require('../seed_data/coursewares.json'),
|
||||
fieldGuides = require('../seed_data/field-guides.json'),
|
||||
moment = require('moment'),
|
||||
Twit = require('twit'),
|
||||
https = require('https'),
|
||||
debug = require('debug')('freecc:cntr:resources'),
|
||||
cheerio = require('cheerio'),
|
||||
request = require('request'),
|
||||
R = require('ramda');
|
||||
fieldGuides = require('../seed_data/field-guides.json');
|
||||
|
||||
/**
|
||||
* Cached values
|
||||
*/
|
||||
var allBonfireIds, allBonfireNames, allCoursewareIds, allCoursewareNames,
|
||||
allFieldGuideIds, allFieldGuideNames, allNonprofitNames,
|
||||
allBonfireIndexesAndNames;
|
||||
var allFieldGuideIds, allFieldGuideNames, allNonprofitNames,
|
||||
challengeMap, challengeMapWithIds,
|
||||
challengeMapWithNames, allChallengeIds, allChallenges;
|
||||
|
||||
/**
|
||||
* GET /
|
||||
@ -44,7 +44,81 @@ Array.zip = function(left, right, combinerFunction) {
|
||||
return results;
|
||||
};
|
||||
|
||||
(function() {
|
||||
if (!challengeMap) {
|
||||
var localChallengeMap = {};
|
||||
var files = fs.readdirSync(
|
||||
path.join(__dirname, '/../seed_data/challenges')
|
||||
);
|
||||
var keyCounter = 0;
|
||||
files = files.map(function (file) {
|
||||
return require(
|
||||
path.join(__dirname, '/../seed_data/challenges/' + file)
|
||||
);
|
||||
});
|
||||
files = files.sort(function (a, b) {
|
||||
return a.order - b.order;
|
||||
});
|
||||
files.forEach(function (file) {
|
||||
localChallengeMap[keyCounter++] = file;
|
||||
});
|
||||
challengeMap = _.cloneDeep(localChallengeMap);
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
getChallengeMapWithIds: function() {
|
||||
if (!challengeMapWithIds) {
|
||||
challengeMapWithIds = {};
|
||||
Object.keys(challengeMap).forEach(function (key) {
|
||||
var onlyIds = challengeMap[key].challenges.map(function (elem) {
|
||||
return elem._id;
|
||||
});
|
||||
challengeMapWithIds[key] = onlyIds;
|
||||
});
|
||||
}
|
||||
return challengeMapWithIds;
|
||||
},
|
||||
|
||||
allChallengeIds: function() {
|
||||
|
||||
if (!allChallengeIds) {
|
||||
allChallengeIds = [];
|
||||
Object.keys(this.getChallengeMapWithIds()).forEach(function(key) {
|
||||
allChallengeIds.push(challengeMapWithIds[key]);
|
||||
});
|
||||
allChallengeIds = R.flatten(allChallengeIds);
|
||||
}
|
||||
return allChallengeIds;
|
||||
},
|
||||
|
||||
allChallenges: function() {
|
||||
if (!allChallenges) {
|
||||
allChallenges = [];
|
||||
Object.keys(this.getChallengeMapWithNames()).forEach(function(key) {
|
||||
allChallenges.push(challengeMap[key].challenges);
|
||||
});
|
||||
allChallenges = R.flatten(allChallenges);
|
||||
}
|
||||
return allChallenges;
|
||||
},
|
||||
|
||||
getChallengeMapWithNames: function() {
|
||||
if (!challengeMapWithNames) {
|
||||
challengeMapWithNames = {};
|
||||
Object.keys(challengeMap).
|
||||
forEach(function (key) {
|
||||
var onlyNames = challengeMap[key].challenges.map(function (elem) {
|
||||
return elem.name;
|
||||
});
|
||||
challengeMapWithNames[key] = onlyNames;
|
||||
});
|
||||
}
|
||||
return challengeMapWithNames;
|
||||
},
|
||||
|
||||
sitemap: function sitemap(req, res, next) {
|
||||
var appUrl = 'http://www.freecodecamp.com';
|
||||
var now = moment(new Date()).format('YYYY-MM-DD');
|
||||
@ -66,29 +140,17 @@ module.exports = {
|
||||
},
|
||||
|
||||
challenges: function (callback) {
|
||||
Courseware.aggregate()
|
||||
Challenge.aggregate()
|
||||
.group({_id: 1, names: { $addToSet: '$name'}})
|
||||
.exec(function (err, challenges) {
|
||||
if (err) {
|
||||
debug('Courseware err: ', err);
|
||||
debug('Challenge err: ', err);
|
||||
callback(err);
|
||||
} else {
|
||||
callback(null, challenges[0].names);
|
||||
}
|
||||
});
|
||||
},
|
||||
bonfires: function (callback) {
|
||||
Bonfire.aggregate()
|
||||
.group({_id: 1, names: { $addToSet: '$name'}})
|
||||
.exec(function (err, bonfires) {
|
||||
if (err) {
|
||||
debug('Bonfire err: ', err);
|
||||
callback(err);
|
||||
} else {
|
||||
callback(null, bonfires[0].names);
|
||||
}
|
||||
});
|
||||
},
|
||||
stories: function (callback) {
|
||||
Story.aggregate()
|
||||
.group({_id: 1, links: {$addToSet: '$link'}})
|
||||
@ -136,7 +198,6 @@ module.exports = {
|
||||
now: now,
|
||||
users: results.users,
|
||||
challenges: results.challenges,
|
||||
bonfires: results.bonfires,
|
||||
stories: results.stories,
|
||||
nonprofits: results.nonprofits,
|
||||
fieldGuides: results.fieldGuides
|
||||
@ -152,7 +213,7 @@ module.exports = {
|
||||
res.redirect('http://freecode.slack.com');
|
||||
} else {
|
||||
res.render('resources/chat', {
|
||||
title: "Watch us code live on Twitch.tv"
|
||||
title: 'Watch us code live on Twitch.tv'
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -169,6 +230,13 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
catPhotoSubmit: function catPhotoSubmit(req, res) {
|
||||
res.send(
|
||||
'Success! You have submitted your cat photo. Return to your website ' +
|
||||
'by typing any letter into your code editor.'
|
||||
);
|
||||
},
|
||||
|
||||
nonprofits: function nonprofits(req, res) {
|
||||
res.render('resources/nonprofits', {
|
||||
title: 'A guide to our Nonprofit Projects'
|
||||
@ -199,7 +267,7 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
unsubscribe: function unsubscribe(req, res) {
|
||||
unsubscribe: function unsubscribe(req, res, next) {
|
||||
User.findOne({ email: req.params.email }, function(err, user) {
|
||||
if (user) {
|
||||
if (err) {
|
||||
@ -220,52 +288,106 @@ module.exports = {
|
||||
|
||||
unsubscribed: function unsubscribed(req, res) {
|
||||
res.render('resources/unsubscribed', {
|
||||
title: "You have been unsubscribed"
|
||||
title: 'You have been unsubscribed'
|
||||
});
|
||||
},
|
||||
|
||||
githubCalls: function(req, res) {
|
||||
var githubHeaders = {headers: {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1521.3 Safari/537.36'}, port:80 };
|
||||
request('https://api.github.com/repos/freecodecamp/freecodecamp/pulls?client_id=' + secrets.github.clientID + '&client_secret=' + secrets.github.clientSecret, githubHeaders, function(err, status1, pulls) {
|
||||
pulls = pulls ? Object.keys(JSON.parse(pulls)).length : "Can't connect to github";
|
||||
request('https://api.github.com/repos/freecodecamp/freecodecamp/issues?client_id=' + secrets.github.clientID + '&client_secret=' + secrets.github.clientSecret, githubHeaders, function (err, status2, issues) {
|
||||
issues = ((pulls === parseInt(pulls)) && issues) ? Object.keys(JSON.parse(issues)).length - pulls : "Can't connect to GitHub";
|
||||
res.send({"issues": issues, "pulls" : pulls});
|
||||
});
|
||||
githubCalls: function(req, res, next) {
|
||||
var githubHeaders = {
|
||||
headers: {
|
||||
'User-Agent': constantStrings.gitHubUserAgent
|
||||
},
|
||||
port: 80
|
||||
};
|
||||
request(
|
||||
[
|
||||
'https://api.github.com/repos/freecodecamp/',
|
||||
'freecodecamp/pulls?client_id=',
|
||||
secrets.github.clientID,
|
||||
'&client_secret=',
|
||||
secrets.github.clientSecret
|
||||
].join(''),
|
||||
githubHeaders,
|
||||
function(err, status1, pulls) {
|
||||
if (err) { return next(err); }
|
||||
pulls = pulls ?
|
||||
Object.keys(JSON.parse(pulls)).length :
|
||||
"Can't connect to github";
|
||||
|
||||
request(
|
||||
[
|
||||
'https://api.github.com/repos/freecodecamp/',
|
||||
'freecodecamp/issues?client_id=',
|
||||
secrets.github.clientID,
|
||||
'&client_secret=',
|
||||
secrets.github.clientSecret
|
||||
].join(''),
|
||||
githubHeaders,
|
||||
function (err, status2, issues) {
|
||||
if (err) { return next(err); }
|
||||
issues = ((pulls === parseInt(pulls, 10)) && issues) ?
|
||||
Object.keys(JSON.parse(issues)).length - pulls :
|
||||
"Can't connect to GitHub";
|
||||
res.send({
|
||||
issues: issues,
|
||||
pulls: pulls
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
trelloCalls: function(req, res, next) {
|
||||
request('https://trello.com/1/boards/BA3xVpz9/cards?key=' + secrets.trello.key, function(err, status, trello) {
|
||||
request(
|
||||
'https://trello.com/1/boards/BA3xVpz9/cards?key=' +
|
||||
secrets.trello.key,
|
||||
function(err, status, trello) {
|
||||
if (err) { return next(err); }
|
||||
trello = (status && status.statusCode === 200) ? (JSON.parse(trello)) : "Can't connect to to Trello";
|
||||
trello = (status && status.statusCode === 200) ?
|
||||
(JSON.parse(trello)) :
|
||||
"Can't connect to to Trello";
|
||||
|
||||
res.end(JSON.stringify(trello));
|
||||
});
|
||||
},
|
||||
|
||||
bloggerCalls: function(req, res, next) {
|
||||
request('https://www.googleapis.com/blogger/v3/blogs/2421288658305323950/posts?key=' + secrets.blogger.key, function (err, status, blog) {
|
||||
request(
|
||||
'https://www.googleapis.com/blogger/v3/blogs/2421288658305323950/' +
|
||||
'posts?key=' +
|
||||
secrets.blogger.key,
|
||||
function (err, status, blog) {
|
||||
if (err) { return next(err); }
|
||||
blog = (status && status.statusCode === 200) ? JSON.parse(blog) : "Can't connect to Blogger";
|
||||
|
||||
blog = (status && status.statusCode === 200) ?
|
||||
JSON.parse(blog) :
|
||||
"Can't connect to Blogger";
|
||||
res.end(JSON.stringify(blog));
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
about: function(req, res, next) {
|
||||
if (req.user) {
|
||||
if (!req.user.profile.picture || req.user.profile.picture === "https://s3.amazonaws.com/freecodecamp/favicons/apple-touch-icon-180x180.png") {
|
||||
req.user.profile.picture = "https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png";
|
||||
if (
|
||||
!req.user.profile.picture ||
|
||||
req.user.profile.picture.indexOf('apple-touch-icon-180x180.png') !== -1
|
||||
) {
|
||||
req.user.profile.picture =
|
||||
'https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png';
|
||||
// TODO(berks): unhandled callback
|
||||
req.user.save();
|
||||
}
|
||||
}
|
||||
var date1 = new Date("10/15/2014");
|
||||
var date1 = new Date('10/15/2014');
|
||||
var date2 = new Date();
|
||||
|
||||
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
|
||||
var daysRunning = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
||||
var announcements = resources.announcements;
|
||||
function numberWithCommas(x) {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
}
|
||||
User.count({}, function (err, c3) {
|
||||
if (err) {
|
||||
@ -283,112 +405,40 @@ module.exports = {
|
||||
},
|
||||
|
||||
randomPhrase: function() {
|
||||
return resources.phrases[Math.floor(
|
||||
Math.random() * resources.phrases.length)];
|
||||
return resources.phrases[
|
||||
Math.floor(Math.random() * resources.phrases.length)
|
||||
];
|
||||
},
|
||||
|
||||
randomVerb: function() {
|
||||
return resources.verbs[Math.floor(
|
||||
Math.random() * resources.verbs.length)];
|
||||
return resources.verbs[
|
||||
Math.floor(Math.random() * resources.verbs.length)
|
||||
];
|
||||
},
|
||||
|
||||
randomCompliment: function() {
|
||||
return resources.compliments[Math.floor(
|
||||
Math.random() * resources.compliments.length)];
|
||||
},
|
||||
|
||||
allBonfireIds: function() {
|
||||
if (allBonfireIds) {
|
||||
return allBonfireIds;
|
||||
} else {
|
||||
allBonfireIds = bonfires.
|
||||
map(function (elem) {
|
||||
return {
|
||||
_id: elem._id,
|
||||
difficulty: elem.difficulty
|
||||
};
|
||||
}).
|
||||
sort(function (a, b) {
|
||||
return a.difficulty - b.difficulty;
|
||||
}).
|
||||
map(function (elem) {
|
||||
return elem._id;
|
||||
});
|
||||
return allBonfireIds;
|
||||
}
|
||||
},
|
||||
|
||||
bonfiresIndexesAndNames: function() {
|
||||
if (allBonfireIndexesAndNames) {
|
||||
return allBonfireIndexesAndNames
|
||||
} else {
|
||||
var obj = {};
|
||||
bonfires.forEach(function(elem) {
|
||||
obj[elem._id] = elem.name;
|
||||
});
|
||||
allBonfireIndexesAndNames = obj;
|
||||
return allBonfireIndexesAndNames;
|
||||
}
|
||||
},
|
||||
|
||||
ensureBonfireNames: function(completedBonfires) {
|
||||
return completedBonfires.map(function(elem) {
|
||||
return ({
|
||||
name: this.bonfiresIndexesAndNames()[elem._id],
|
||||
_id: elem.id,
|
||||
completedDate: elem.completedDate,
|
||||
completedWith: elem.completedWith,
|
||||
solution: elem.solution
|
||||
});
|
||||
}.bind(this));
|
||||
return resources.compliments[
|
||||
Math.floor(Math.random() * resources.compliments.length)
|
||||
];
|
||||
},
|
||||
|
||||
allFieldGuideIds: function() {
|
||||
if (allFieldGuideIds) {
|
||||
return allFieldGuideIds;
|
||||
} else {
|
||||
allFieldGuideIds = fieldGuides.
|
||||
map(function (elem) {
|
||||
allFieldGuideIds = fieldGuides.map(function (elem) {
|
||||
return elem._id;
|
||||
});
|
||||
return allFieldGuideIds;
|
||||
}
|
||||
},
|
||||
|
||||
allBonfireNames: function() {
|
||||
if (allBonfireNames) {
|
||||
return allBonfireNames;
|
||||
} else {
|
||||
allBonfireNames = bonfires.
|
||||
map(function (elem) {
|
||||
return {
|
||||
name: elem.name,
|
||||
difficulty: elem.difficulty,
|
||||
_id: elem._id
|
||||
};
|
||||
}).
|
||||
sort(function (a, b) {
|
||||
return a.difficulty - b.difficulty;
|
||||
}).
|
||||
map(function (elem) {
|
||||
return {
|
||||
name: elem.name,
|
||||
_id: elem._id
|
||||
};
|
||||
});
|
||||
return allBonfireNames;
|
||||
}
|
||||
},
|
||||
|
||||
allFieldGuideNames: function() {
|
||||
if (allFieldGuideNames) {
|
||||
return allFieldGuideNames;
|
||||
} else {
|
||||
allFieldGuideNames = fieldGuides.
|
||||
map(function (elem) {
|
||||
return {
|
||||
name: elem.name
|
||||
};
|
||||
allFieldGuideNames = fieldGuides.map(function (elem) {
|
||||
return { name: elem.name };
|
||||
});
|
||||
return allFieldGuideNames;
|
||||
}
|
||||
@ -398,64 +448,13 @@ module.exports = {
|
||||
if (allNonprofitNames) {
|
||||
return allNonprofitNames;
|
||||
} else {
|
||||
allNonprofitNames = nonprofits.
|
||||
map(function (elem) {
|
||||
return {
|
||||
name: elem.name
|
||||
};
|
||||
allNonprofitNames = nonprofits.map(function (elem) {
|
||||
return { name: elem.name };
|
||||
});
|
||||
return allNonprofitNames;
|
||||
}
|
||||
},
|
||||
|
||||
allCoursewareIds: function() {
|
||||
if (allCoursewareIds) {
|
||||
return allCoursewareIds;
|
||||
} else {
|
||||
allCoursewareIds = coursewares.
|
||||
map(function (elem) {
|
||||
return {
|
||||
_id: elem._id,
|
||||
difficulty: elem.difficulty
|
||||
};
|
||||
}).
|
||||
sort(function (a, b) {
|
||||
return a.difficulty - b.difficulty;
|
||||
}).
|
||||
map(function (elem) {
|
||||
return elem._id;
|
||||
});
|
||||
return allCoursewareIds;
|
||||
}
|
||||
},
|
||||
|
||||
allCoursewareNames: function() {
|
||||
if (allCoursewareNames) {
|
||||
return allCoursewareNames;
|
||||
} else {
|
||||
allCoursewareNames = coursewares.
|
||||
map(function (elem) {
|
||||
return {
|
||||
name: elem.name,
|
||||
difficulty: elem.difficulty,
|
||||
challengeType: elem.challengeType,
|
||||
_id: elem._id
|
||||
};
|
||||
}).
|
||||
sort(function (a, b) {
|
||||
return a.difficulty - b.difficulty;
|
||||
}).
|
||||
map(function (elem) {
|
||||
return {
|
||||
name: elem.name,
|
||||
challengeType: elem.challengeType,
|
||||
_id: elem._id
|
||||
};
|
||||
});
|
||||
return allCoursewareNames;
|
||||
}
|
||||
},
|
||||
|
||||
whichEnvironment: function() {
|
||||
return process.env.NODE_ENV;
|
||||
},
|
||||
@ -468,15 +467,24 @@ module.exports = {
|
||||
var $ = cheerio.load(body);
|
||||
var metaDescription = $("meta[name='description']");
|
||||
var metaImage = $("meta[property='og:image']");
|
||||
var urlImage = metaImage.attr('content') ? metaImage.attr('content') : '';
|
||||
var urlImage = metaImage.attr('content') ?
|
||||
metaImage.attr('content') :
|
||||
'';
|
||||
|
||||
var metaTitle = $('title');
|
||||
var description = metaDescription.attr('content') ? metaDescription.attr('content') : '';
|
||||
result.title = metaTitle.text().length < 90 ? metaTitle.text() : metaTitle.text().slice(0, 87) + "...";
|
||||
var description = metaDescription.attr('content') ?
|
||||
metaDescription.attr('content') :
|
||||
'';
|
||||
|
||||
result.title = metaTitle.text().length < 90 ?
|
||||
metaTitle.text() :
|
||||
metaTitle.text().slice(0, 87) + '...';
|
||||
|
||||
result.image = urlImage;
|
||||
result.description = description;
|
||||
callback(null, result);
|
||||
} else {
|
||||
callback('failed');
|
||||
callback(new Error('failed'));
|
||||
}
|
||||
});
|
||||
})();
|
||||
@ -536,24 +544,33 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
codepenResources: {
|
||||
twitter: function(req, res) {
|
||||
twitter: function(req, res, next) {
|
||||
// sends out random tweets about javascript
|
||||
var T = new Twit({
|
||||
consumer_key: secrets.twitter.consumerKey,
|
||||
consumer_secret: secrets.twitter.consumerSecret,
|
||||
access_token: secrets.twitter.token,
|
||||
access_token_secret: secrets.twitter.tokenSecret
|
||||
'consumer_key': secrets.twitter.consumerKey,
|
||||
'consumer_secret': secrets.twitter.consumerSecret,
|
||||
'access_token': secrets.twitter.token,
|
||||
'access_token_secret': secrets.twitter.tokenSecret
|
||||
});
|
||||
|
||||
var screenName;
|
||||
if (req.params.screenName) {
|
||||
screenName = req.params.screenName;
|
||||
} else {
|
||||
screenName = 'freecodecamp';
|
||||
}
|
||||
|
||||
T.get('statuses/user_timeline', {screen_name: screenName, count:10}, function(err, data, response) {
|
||||
T.get(
|
||||
'statuses/user_timeline',
|
||||
{
|
||||
'screen_name': screenName,
|
||||
count: 10
|
||||
},
|
||||
function(err, data) {
|
||||
if (err) { return next(err); }
|
||||
return res.json(data);
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
twitterFCCStream: function() {
|
||||
// sends out a tweet stream from FCC's account
|
||||
|
@ -129,7 +129,8 @@ exports.returnIndividualStory = function(req, res, next) {
|
||||
|
||||
if (story.length < 1) {
|
||||
req.flash('errors', {
|
||||
msg: "404: We couldn't find a story with that name. Please double check the name."
|
||||
msg: "404: We couldn't find a story with that name. " +
|
||||
'Please double check the name.'
|
||||
});
|
||||
|
||||
return res.redirect('/news/');
|
||||
@ -149,7 +150,7 @@ exports.returnIndividualStory = function(req, res, next) {
|
||||
if (votedObj.length > 0) {
|
||||
userVoted = true;
|
||||
}
|
||||
} catch(err) {
|
||||
} catch(e) {
|
||||
userVoted = false;
|
||||
}
|
||||
res.render('stories/index', {
|
||||
@ -230,12 +231,10 @@ exports.upvote = function(req, res, next) {
|
||||
);
|
||||
story.markModified('rank');
|
||||
story.save();
|
||||
User.find({'_id': story.author.userId}, function(err, user) {
|
||||
'use strict';
|
||||
User.findOne({'_id': story.author.userId}, function(err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
user = user.pop();
|
||||
user.progressTimestamps.push(Date.now() || 0);
|
||||
user.save(function (err, user) {
|
||||
req.user.save(function (err, user) {
|
||||
@ -340,7 +339,7 @@ exports.storySubmission = function(req, res, next) {
|
||||
if (link.search(/^https?:\/\//g) === -1) {
|
||||
link = 'http://' + link;
|
||||
}
|
||||
Story.count({'storyLink': new RegExp('^' + storyLink + '(?: [0-9]+)?$', 'i')}, function (err, storyCount) {
|
||||
Story.count({ storyLink: new RegExp('^' + storyLink + '(?: [0-9]+)?$', 'i')}, function (err, storyCount) {
|
||||
if (err) {
|
||||
return res.status(500);
|
||||
}
|
||||
@ -514,7 +513,8 @@ exports.storySubmission = function(req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
try {
|
||||
// Based on the context retrieve the parent object of the comment (Story/Comment)
|
||||
// Based on the context retrieve the parent
|
||||
// object of the comment (Story/Comment)
|
||||
Context.find({'_id': data.associatedPost}, function (err, associatedContext) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@ -534,8 +534,15 @@ exports.storySubmission = function(req, res, next) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
// If the emails of both authors differ, only then proceed with email notification
|
||||
if (typeof data.author !== 'undefined' && data.author.email && typeof recipient !== 'undefined' && recipient.email && (data.author.email !== recipient.email)) {
|
||||
// If the emails of both authors differ,
|
||||
// only then proceed with email notification
|
||||
if (
|
||||
typeof data.author !== 'undefined' &&
|
||||
data.author.email &&
|
||||
typeof recipient !== 'undefined' &&
|
||||
recipient.email &&
|
||||
(data.author.email !== recipient.email)
|
||||
) {
|
||||
var transporter = nodemailer.createTransport({
|
||||
service: 'Mandrill',
|
||||
auth: {
|
||||
@ -547,11 +554,16 @@ exports.storySubmission = function(req, res, next) {
|
||||
var mailOptions = {
|
||||
to: recipient.email,
|
||||
from: 'Team@freecodecamp.com',
|
||||
subject: data.author.username + ' replied to your post on Camper News',
|
||||
subject: data.author.username +
|
||||
' replied to your post on Camper News',
|
||||
text: [
|
||||
'Just a quick heads-up: ' + data.author.username + ' replied to you on Camper News.',
|
||||
'Just a quick heads-up: ',
|
||||
data.author.username,
|
||||
' replied to you on Camper News.',
|
||||
'You can keep this conversation going.',
|
||||
'Just head back to the discussion here: http://freecodecamp.com/news/' + data.originalStoryLink,
|
||||
'Just head back to the discussion here: ',
|
||||
'http://freecodecamp.com/news/',
|
||||
data.originalStoryLink,
|
||||
'- the Free Code Camp Volunteer Team'
|
||||
].join('\n')
|
||||
};
|
||||
|
@ -53,6 +53,12 @@ exports.postSignin = function(req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
req.flash('success', { msg: 'Success! You are logged in.' });
|
||||
if (/hotStories/.test(req.session.returnTo)) {
|
||||
return res.redirect('../news');
|
||||
}
|
||||
if (/field-guide/.test(req.session.returnTo)) {
|
||||
return res.redirect('../field-guide');
|
||||
}
|
||||
return res.redirect(req.session.returnTo || '/');
|
||||
});
|
||||
})(req, res, next);
|
||||
@ -102,8 +108,6 @@ exports.getEmailSignup = function(req, res) {
|
||||
*/
|
||||
|
||||
exports.postEmailSignup = function(req, res, next) {
|
||||
|
||||
|
||||
req.assert('email', 'valid email required').isEmail();
|
||||
var errors = req.validationErrors();
|
||||
|
||||
@ -134,7 +138,8 @@ exports.postEmailSignup = function(req, res, next) {
|
||||
password: req.body.password,
|
||||
profile: {
|
||||
username: req.body.username.trim(),
|
||||
picture: 'https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png'
|
||||
picture:
|
||||
'https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png'
|
||||
}
|
||||
});
|
||||
|
||||
@ -149,7 +154,9 @@ exports.postEmailSignup = function(req, res, next) {
|
||||
});
|
||||
return res.redirect('/email-signup');
|
||||
}
|
||||
User.findOne({'profile.username': req.body.username }, function(err, existingUsername) {
|
||||
User.findOne(
|
||||
{ 'profile.username': req.body.username },
|
||||
function(err, existingUsername) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -181,8 +188,10 @@ exports.postEmailSignup = function(req, res, next) {
|
||||
text: [
|
||||
'Greetings from San Francisco!\n\n',
|
||||
'Thank you for joining our community.\n',
|
||||
'Feel free to email us at this address if you have any questions about Free Code Camp.\n',
|
||||
'And if you have a moment, check out our blog: blog.freecodecamp.com.\n',
|
||||
'Feel free to email us at this address if you have ',
|
||||
'any questions about Free Code Camp.\n',
|
||||
'And if you have a moment, check out our blog: ',
|
||||
'blog.freecodecamp.com.\n',
|
||||
'Good luck with the challenges!\n\n',
|
||||
'- the Volunteer Camp Counselor Team'
|
||||
].join('')
|
||||
@ -220,9 +229,11 @@ exports.getAccountAngular = function(req, res) {
|
||||
*/
|
||||
|
||||
exports.checkUniqueUsername = function(req, res, next) {
|
||||
User.count({'profile.username': req.params.username.toLowerCase()}, function (err, data) {
|
||||
User.count(
|
||||
{ 'profile.username': req.params.username.toLowerCase() },
|
||||
function (err, data) {
|
||||
if (err) { return next(err); }
|
||||
if (data == 1) {
|
||||
if (data === 1) {
|
||||
return res.send(true);
|
||||
} else {
|
||||
return res.send(false);
|
||||
@ -234,14 +245,17 @@ exports.checkUniqueUsername = function(req, res, next) {
|
||||
* Existing username check
|
||||
*/
|
||||
exports.checkExistingUsername = function(req, res, next) {
|
||||
User.count({'profile.username': req.params.username.toLowerCase()}, function (err, data) {
|
||||
User.count(
|
||||
{ 'profile.username': req.params.username.toLowerCase() },
|
||||
function (err, data) {
|
||||
if (err) { return next(err); }
|
||||
if (data === 1) {
|
||||
return res.send(true);
|
||||
} else {
|
||||
return res.send(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -249,14 +263,17 @@ exports.checkExistingUsername = function(req, res, next) {
|
||||
*/
|
||||
|
||||
exports.checkUniqueEmail = function(req, res, next) {
|
||||
User.count({'email': decodeURIComponent(req.params.email).toLowerCase()}, function (err, data) {
|
||||
User.count(
|
||||
{ email: decodeURIComponent(req.params.email).toLowerCase() },
|
||||
function (err, data) {
|
||||
if (err) { return next(err); }
|
||||
if (data === 1) {
|
||||
return res.send(true);
|
||||
} else {
|
||||
return res.send(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -266,8 +283,13 @@ exports.checkUniqueEmail = function(req, res, next) {
|
||||
*/
|
||||
|
||||
exports.returnUser = function(req, res, next) {
|
||||
User.find({'profile.username': req.params.username.toLowerCase()}, function(err, user) {
|
||||
if (err) { debug('Username err: ', err); next(err); }
|
||||
User.find(
|
||||
{ 'profile.username': req.params.username.toLowerCase() },
|
||||
function(err, user) {
|
||||
if (err) {
|
||||
debug('Username err: ', err);
|
||||
return next(err);
|
||||
}
|
||||
if (user[0]) {
|
||||
user = user[0];
|
||||
|
||||
@ -302,14 +324,21 @@ exports.returnUser = function(req, res, next) {
|
||||
user.currentStreak = 1;
|
||||
var today = moment(Date.now()).format('YYYY-MM-DD');
|
||||
|
||||
if (moment(today).toString() === moment(timeKeys[0]).toString() ||
|
||||
if (
|
||||
moment(today).toString() === moment(timeKeys[0]).toString() ||
|
||||
moment(today).subtract(1, 'd').toString() ===
|
||||
moment(timeKeys[0]).toString()) {
|
||||
for (var i = 1; i <= timeKeys.length; i++) {
|
||||
if (moment(timeKeys[i - 1]).subtract(1, 'd').toString()
|
||||
=== moment(timeKeys[i]).toString()) {
|
||||
debug(timeKeys[i - 1], timeKeys[i]);
|
||||
moment(timeKeys[0]).toString()
|
||||
) {
|
||||
for (var _i = 1; _i <= timeKeys.length; _i++) {
|
||||
|
||||
if (
|
||||
moment(timeKeys[_i - 1]).subtract(1, 'd').toString() ===
|
||||
moment(timeKeys[_i]).toString()
|
||||
) {
|
||||
|
||||
debug(timeKeys[_i - 1], timeKeys[_i]);
|
||||
tmpLongest++;
|
||||
|
||||
if (tmpLongest > user.currentStreak) {
|
||||
user.currentStreak = tmpLongest;
|
||||
}
|
||||
@ -325,7 +354,6 @@ exports.returnUser = function(req, res, next) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
});
|
||||
|
||||
var data = {};
|
||||
var progressTimestamps = user.progressTimestamps;
|
||||
@ -333,23 +361,12 @@ exports.returnUser = function(req, res, next) {
|
||||
data[(timeStamp / 1000)] = 1;
|
||||
});
|
||||
|
||||
if (!user.needsMigration) {
|
||||
var currentlySolvedBonfires = user.completedBonfires;
|
||||
user.completedBonfires =
|
||||
resources.ensureBonfireNames(currentlySolvedBonfires);
|
||||
user.needsMigration = true;
|
||||
user.save(function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
user.currentStreak = user.currentStreak || 1;
|
||||
user.longestStreak = user.longestStreak || 1;
|
||||
var challenges = user.completedCoursewares.filter(function ( obj ) {
|
||||
return !!obj.solution;
|
||||
});
|
||||
|
||||
res.render('account/show', {
|
||||
title: 'Camper ' + user.profile.username + '\'s portfolio',
|
||||
username: user.profile.username,
|
||||
@ -373,20 +390,26 @@ exports.returnUser = function(req, res, next) {
|
||||
website3Title: user.portfolio.website3Title,
|
||||
website3Image: user.portfolio.website3Image,
|
||||
challenges: challenges,
|
||||
bonfires: user.completedBonfires,
|
||||
bonfires: user.completedChallenges.filter(function(challenge) {
|
||||
return challenge.challengeType === 5;
|
||||
}),
|
||||
calender: data,
|
||||
moment: moment,
|
||||
longestStreak: user.longestStreak + (user.longestStreak === 1 ? " day" : " days"),
|
||||
currentStreak: user.currentStreak + (user.currentStreak === 1 ? " day" : " days")
|
||||
longestStreak: user.longestStreak +
|
||||
(user.longestStreak === 1 ? ' day' : ' days'),
|
||||
currentStreak: user.currentStreak +
|
||||
(user.currentStreak === 1 ? ' day' : ' days')
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
req.flash('errors', {
|
||||
msg: "404: We couldn't find a page with that url. Please double check the link."
|
||||
msg: "404: We couldn't find a page with that url. " +
|
||||
'Please double check the link.'
|
||||
});
|
||||
return res.redirect('/');
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -395,9 +418,9 @@ exports.returnUser = function(req, res, next) {
|
||||
* Update profile information.
|
||||
*/
|
||||
|
||||
exports.updateProgress = function(req, res) {
|
||||
exports.updateProgress = function(req, res, next) {
|
||||
User.findById(req.user.id, function(err, user) {
|
||||
if (err) return next(err);
|
||||
if (err) { return next(err); }
|
||||
user.email = req.body.email || '';
|
||||
user.profile.name = req.body.name || '';
|
||||
user.profile.gender = req.body.gender || '';
|
||||
@ -405,7 +428,7 @@ exports.updateProgress = function(req, res) {
|
||||
user.profile.website = req.body.website || '';
|
||||
|
||||
user.save(function(err) {
|
||||
if (err) return next(err);
|
||||
if (err) { return next(err); }
|
||||
req.flash('success', { msg: 'Profile information updated.' });
|
||||
res.redirect('/account');
|
||||
});
|
||||
@ -419,8 +442,8 @@ exports.updateProgress = function(req, res) {
|
||||
|
||||
exports.postUpdateProfile = function(req, res, next) {
|
||||
|
||||
User.findById(req.user.id, function(err, user) {
|
||||
if (err) return next(err);
|
||||
User.findById(req.user.id, function(err) {
|
||||
if (err) { return next(err); }
|
||||
var errors = req.validationErrors();
|
||||
if (errors) {
|
||||
req.flash('errors', errors);
|
||||
@ -432,18 +455,23 @@ exports.postUpdateProfile = function(req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
var user = req.user;
|
||||
if (existingEmail && existingEmail.email != user.email) {
|
||||
if (existingEmail && existingEmail.email !== user.email) {
|
||||
req.flash('errors', {
|
||||
msg: "An account with that email address already exists."
|
||||
msg: 'An account with that email address already exists.'
|
||||
});
|
||||
return res.redirect('/account');
|
||||
}
|
||||
User.findOne({ 'profile.username': req.body.username }, function(err, existingUsername) {
|
||||
User.findOne(
|
||||
{ 'profile.username': req.body.username },
|
||||
function(err, existingUsername) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
var user = req.user;
|
||||
if (existingUsername && existingUsername.profile.username !== user.profile.username) {
|
||||
if (
|
||||
existingUsername &&
|
||||
existingUsername.profile.username !== user.profile.username
|
||||
) {
|
||||
req.flash('errors', {
|
||||
msg: 'An account with that username already exists.'
|
||||
});
|
||||
@ -459,7 +487,10 @@ exports.postUpdateProfile = function(req, res, next) {
|
||||
user.profile.codepenProfile = req.body.codepenProfile.trim() || '';
|
||||
user.profile.twitterHandle = req.body.twitterHandle.trim() || '';
|
||||
user.profile.bio = req.body.bio.trim() || '';
|
||||
user.profile.picture = req.body.picture.trim() || 'https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png';
|
||||
|
||||
user.profile.picture = req.body.picture.trim() ||
|
||||
'https://s3.amazonaws.com/freecodecamp/' +
|
||||
'camper-image-placeholder.png';
|
||||
user.portfolio.website1Title = req.body.website1Title.trim() || '';
|
||||
user.portfolio.website1Link = req.body.website1Link.trim() || '';
|
||||
user.portfolio.website1Image = req.body.website1Image.trim() || '';
|
||||
@ -488,7 +519,8 @@ exports.postUpdateProfile = function(req, res, next) {
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
@ -548,7 +580,7 @@ exports.getOauthUnlink = function(req, res, next) {
|
||||
User.findById(req.user.id, function(err, user) {
|
||||
if (err) { return next(err); }
|
||||
|
||||
user[provider] = undefined;
|
||||
user[provider] = null;
|
||||
user.tokens =
|
||||
_.reject(user.tokens, function(token) {
|
||||
return token.kind === provider;
|
||||
@ -567,7 +599,7 @@ exports.getOauthUnlink = function(req, res, next) {
|
||||
* Reset Password page.
|
||||
*/
|
||||
|
||||
exports.getReset = function(req, res) {
|
||||
exports.getReset = function(req, res, next) {
|
||||
if (req.isAuthenticated()) {
|
||||
return res.redirect('/');
|
||||
}
|
||||
@ -617,8 +649,8 @@ exports.postReset = function(req, res, next) {
|
||||
}
|
||||
|
||||
user.password = req.body.password;
|
||||
user.resetPasswordToken = undefined;
|
||||
user.resetPasswordExpires = undefined;
|
||||
user.resetPasswordToken = null;
|
||||
user.resetPasswordExpires = null;
|
||||
|
||||
user.save(function(err) {
|
||||
if (err) { return done(err); }
|
||||
|
@ -15,7 +15,7 @@ var bonfireSchema = new mongoose.Schema({
|
||||
difficulty: String,
|
||||
description: Array,
|
||||
tests: Array,
|
||||
challengeSeed: String,
|
||||
challengeSeed: Array,
|
||||
MDNlinks: [String]
|
||||
});
|
||||
|
||||
|
@ -1,16 +1,23 @@
|
||||
var mongoose = require('mongoose');
|
||||
var secrets = require('../config/secrets');
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {exports.Schema}
|
||||
*/
|
||||
|
||||
var challengeSchema = new mongoose.Schema({
|
||||
name: {
|
||||
type: String,
|
||||
unique: true
|
||||
},
|
||||
link: String,
|
||||
time: String,
|
||||
challengeNumber: Number,
|
||||
video: String,
|
||||
steps: Array
|
||||
difficulty: String,
|
||||
description: Array,
|
||||
tests: Array,
|
||||
challengeSeed: Array,
|
||||
completionMessage: String, // Congratulations! You've finished our HTML and CSS track!
|
||||
challengeType: Number, // 0 = html, 1 = javascript only, 2 = video, 3 = zipline, 4 = basejump
|
||||
MDNlinks: Array
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Challenge', challengeSchema);
|
||||
|
@ -15,7 +15,6 @@ var coursewareSchema = new mongoose.Schema({
|
||||
description: Array,
|
||||
tests: Array,
|
||||
challengeSeed: Array,
|
||||
completionMessage: String, // Congratulations! You've finished our HTML and CSS track!
|
||||
challengeType: Number // 0 = html, 1 = javascript only, 2 = video, 3 = zipline, 4 = basejump
|
||||
});
|
||||
|
||||
|
@ -124,7 +124,10 @@ var userSchema = new mongoose.Schema({
|
||||
uncompletedCoursewares: Array,
|
||||
completedCoursewares: [
|
||||
{
|
||||
completedDate: Long,
|
||||
completedDate: {
|
||||
type: Long,
|
||||
default: Date.now()
|
||||
},
|
||||
_id: String,
|
||||
name: String,
|
||||
completedWith: String,
|
||||
@ -149,7 +152,24 @@ var userSchema = new mongoose.Schema({
|
||||
needsMigration: { type: Boolean, default: true },
|
||||
finishedWaypoints: { type: Boolean, default: false },
|
||||
sendMonthlyEmail: { type: Boolean, default: true },
|
||||
challengesHash: {}
|
||||
challengesHash: {},
|
||||
currentChallenge: {},
|
||||
completedChallenges: [
|
||||
{
|
||||
completedDate: Long,
|
||||
_id: String,
|
||||
name: String,
|
||||
completedWith: String,
|
||||
solution: String,
|
||||
githubLink: String,
|
||||
verified: Boolean,
|
||||
challengeType: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
}
|
||||
],
|
||||
uncompletedChallenges: Array
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node app.js",
|
||||
"lint": "eslint --ext=.js,.jsx .",
|
||||
"test": "mocha"
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
@ -82,10 +83,13 @@
|
||||
"yui": "~3.18.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^3.1.7",
|
||||
"blessed": "~0.0.37",
|
||||
"bower-main-files": "~0.0.4",
|
||||
"browser-sync": "~1.8.1",
|
||||
"chai": "~1.10.0",
|
||||
"eslint": "^0.21.2",
|
||||
"eslint-plugin-react": "^2.3.0",
|
||||
"gulp": "~3.8.8",
|
||||
"gulp-eslint": "~0.9.0",
|
||||
"gulp-inject": "~1.0.2",
|
||||
|
@ -20,6 +20,16 @@ li, .wrappable {
|
||||
word-wrap: break-word; /* IE 5+ */
|
||||
}
|
||||
|
||||
pre.wrappable {
|
||||
white-space: pre; /* CSS 2.0 */
|
||||
white-space: pre-wrap; /* CSS 2.1 */
|
||||
white-space: -pre-wrap; /* Opera 4-6 */
|
||||
white-space: -o-pre-wrap; /* Opera 7 */
|
||||
white-space: -moz-pre-wrap; /* Mozilla */
|
||||
white-space: -hp-pre-wrap; /* HP Printers */
|
||||
word-wrap: break-word; /* IE 5+ */
|
||||
}
|
||||
|
||||
html {
|
||||
position: relative;
|
||||
min-height: 100%;
|
||||
|
@ -1,262 +0,0 @@
|
||||
var widgets = [];
|
||||
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("codeEditor"), {
|
||||
lineNumbers: true,
|
||||
mode: "javascript",
|
||||
theme: 'monokai',
|
||||
runnable: true,
|
||||
lint: true,
|
||||
matchBrackets: true,
|
||||
autoCloseBrackets: true,
|
||||
scrollbarStyle: 'null',
|
||||
lineWrapping: true,
|
||||
gutters: ["CodeMirror-lint-markers"],
|
||||
onKeyEvent: doLinting
|
||||
});
|
||||
var editor = myCodeMirror;
|
||||
editor.setSize("100%", "auto");
|
||||
|
||||
// Hijack tab key to enter two spaces intead
|
||||
editor.setOption("extraKeys", {
|
||||
Tab: function(cm) {
|
||||
if (cm.somethingSelected()){
|
||||
cm.indentSelection("add");
|
||||
} else {
|
||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
},
|
||||
"Shift-Tab": function(cm) {
|
||||
if (cm.somethingSelected()){
|
||||
cm.indentSelection("subtract");
|
||||
} else {
|
||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
"Ctrl-Enter": function() {
|
||||
bonfireExecute();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
var attempts = 0;
|
||||
if (attempts) {
|
||||
attempts = 0;
|
||||
}
|
||||
|
||||
// Default value for editor if one isn't provided in (i.e. a challenge)
|
||||
var nonChallengeValue = '/*Welcome to Bonfire, Free Code Camp\'s future CoderByte replacement.\n' +
|
||||
'Please feel free to use Bonfire as an in-browser playground and linting tool.\n' +
|
||||
'Note that you can also write tests using Chai.js by using the keywords assert and expect */\n\n' +
|
||||
'function test() {\n' +
|
||||
' assert(2 !== 3, "2 is not equal to 3");\n' +
|
||||
' return [1,2,3].map(function(elem) {\n' +
|
||||
' return elem * elem;\n' +
|
||||
' });\n' +
|
||||
'}\n' +
|
||||
'expect(test()).to.be.a("array");\n\n' +
|
||||
'assert.deepEqual(test(), [1,4,9]);\n\n' +
|
||||
'var foo = test();\n' +
|
||||
'foo.should.be.a("array");\n\n' +
|
||||
'test();\n';
|
||||
|
||||
var codeOutput = CodeMirror.fromTextArea(document.getElementById("codeOutput"), {
|
||||
lineNumbers: false,
|
||||
mode: "text",
|
||||
theme: 'monokai',
|
||||
readOnly: 'nocursor',
|
||||
lineWrapping: true
|
||||
});
|
||||
|
||||
codeOutput.setValue('/**\n' +
|
||||
' * Your output will go here.\n' + ' * Console.log() -type statements\n' +
|
||||
' * will appear in your browser\'s\n' + ' * DevTools JavaScript console.\n' +
|
||||
' */');
|
||||
codeOutput.setSize("100%", "100%");
|
||||
var info = editor.getScrollInfo();
|
||||
var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
|
||||
if (info.top + info.clientHeight < after)
|
||||
editor.scrollTo(null, after - info.clientHeight + 3);
|
||||
|
||||
var editorValue;
|
||||
|
||||
|
||||
var challengeSeed = challengeSeed || null;
|
||||
var tests = tests || [];
|
||||
|
||||
|
||||
if (challengeSeed !== null) {
|
||||
editorValue = challengeSeed;
|
||||
} else {
|
||||
editorValue = nonChallengeValue;
|
||||
}
|
||||
|
||||
|
||||
myCodeMirror.setValue(editorValue);
|
||||
|
||||
function doLinting () {
|
||||
editor.operation(function () {
|
||||
for (var i = 0; i < widgets.length; ++i)
|
||||
editor.removeLineWidget(widgets[i]);
|
||||
widgets.length = 0;
|
||||
JSHINT(editor.getValue());
|
||||
for (var i = 0; i < JSHINT.errors.length; ++i) {
|
||||
var err = JSHINT.errors[i];
|
||||
if (!err) continue;
|
||||
var msg = document.createElement("div");
|
||||
var icon = msg.appendChild(document.createElement("span"));
|
||||
icon.innerHTML = "!!";
|
||||
icon.className = "lint-error-icon";
|
||||
msg.appendChild(document.createTextNode(err.reason));
|
||||
msg.className = "lint-error";
|
||||
widgets.push(editor.addLineWidget(err.line - 1, msg, {
|
||||
coverGutter: false,
|
||||
noHScroll: true
|
||||
}));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$('#submitButton').on('click', function () {
|
||||
bonfireExecute();
|
||||
});
|
||||
|
||||
function bonfireExecute() {
|
||||
attempts++;
|
||||
ga('send', 'event', 'Bonfire', 'ran-code', challengeName);
|
||||
userTests= null;
|
||||
$('#codeOutput').empty();
|
||||
var userJavaScript = myCodeMirror.getValue();
|
||||
userJavaScript = removeComments(userJavaScript);
|
||||
userJavaScript = scrapeTests(userJavaScript);
|
||||
// simple fix in case the user forgets to invoke their function
|
||||
|
||||
submit(userJavaScript, function(cls, message) {
|
||||
if (cls) {
|
||||
codeOutput.setValue(message.error);
|
||||
runTests('Error', null);
|
||||
} else {
|
||||
codeOutput.setValue(message.output);
|
||||
message.input = removeLogs(message.input);
|
||||
runTests(null, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var userTests;
|
||||
var testSalt = Math.random();
|
||||
|
||||
|
||||
var scrapeTests = function(userJavaScript) {
|
||||
|
||||
// insert tests from mongo
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
userJavaScript += '\n' + tests[i];
|
||||
}
|
||||
|
||||
var counter = 0;
|
||||
var regex = new RegExp(/(expect(\s+)?\(.*\;)|(assert(\s+)?\(.*\;)|(assert\.\w.*\;)|(.*\.should\..*\;)/);
|
||||
var match = regex.exec(userJavaScript);
|
||||
while (match != null) {
|
||||
var replacement = '//' + counter + testSalt;
|
||||
userJavaScript = userJavaScript.substring(0, match.index) + replacement + userJavaScript.substring(match.index + match[0].length);
|
||||
|
||||
if (!userTests) {
|
||||
userTests= [];
|
||||
}
|
||||
userTests.push({"text": match[0], "line": counter, "err": null});
|
||||
counter++;
|
||||
match = regex.exec(userJavaScript);
|
||||
}
|
||||
|
||||
return userJavaScript;
|
||||
};
|
||||
|
||||
function removeComments(userJavaScript) {
|
||||
var regex = new RegExp(/(\/\*[^(\*\/)]*\*\/)|\/\/[^\n]*/g);
|
||||
return userJavaScript.replace(regex, '');
|
||||
}
|
||||
|
||||
function removeLogs(userJavaScript) {
|
||||
return userJavaScript.replace(/(console\.[\w]+\s*\(.*\;)/g, '');
|
||||
}
|
||||
|
||||
var pushed = false;
|
||||
var createTestDisplay = function() {
|
||||
if (pushed) {
|
||||
userTests.pop();
|
||||
}
|
||||
for (var i = 0; i < userTests.length;i++) {
|
||||
var test = userTests[i];
|
||||
var testDoc = document.createElement("div");
|
||||
if (test.err != null) {
|
||||
$(testDoc)
|
||||
.html("<div class='row'><div class='col-xs-1 text-center'><i class='ion-close-circled big-error-icon'></i></div><div class='col-xs-11 test-output wrappable grayed-out-test-output'>" + test.text + "</div><div class='col-xs-11 test-output wrappable'>" + test.err + "</div></div><div class='ten-pixel-break'/>")
|
||||
.prependTo($('#testSuite'))
|
||||
} else {
|
||||
$(testDoc)
|
||||
.html("<div class='row'><div class='col-xs-1 text-center'><i class='ion-checkmark-circled big-success-icon'></i></div><div class='col-xs-11 test-output test-vertical-center wrappable '>" + test.text + "</div></div><div class='ten-pixel-break'/>")
|
||||
.appendTo($('#testSuite'));
|
||||
}
|
||||
};
|
||||
};
|
||||
var assert = chai.assert;
|
||||
var expect = chai.expect;
|
||||
var should = chai.should();
|
||||
chai.config.showDiff = true;
|
||||
|
||||
var reassembleTest = function(test, data) {
|
||||
var lineNum = test.line;
|
||||
var regexp = new RegExp("\/\/" + lineNum + testSalt);
|
||||
return data.input.replace(regexp, test.text);
|
||||
};
|
||||
|
||||
var runTests = function(err, data) {
|
||||
var allTestsPassed = true;
|
||||
pushed = false;
|
||||
$('#testSuite').children().remove();
|
||||
if (err && userTests.length > 0) {
|
||||
userTests= [{text:"Program Execution Failure", err: "No user tests were run."}];
|
||||
createTestDisplay();
|
||||
} else if (userTests) {
|
||||
userTests.push(false);
|
||||
pushed = true;
|
||||
userTests.forEach(function(test, ix, arr){
|
||||
try {
|
||||
if (test) {
|
||||
var output = eval(reassembleTest(test, data));
|
||||
}
|
||||
} catch(error) {
|
||||
allTestsPassed = false;
|
||||
arr[ix].err = error.message;
|
||||
} finally {
|
||||
if (!test) {
|
||||
createTestDisplay();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (allTestsPassed) {
|
||||
allTestsPassed = false;
|
||||
showCompletion();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function showCompletion() {
|
||||
var time = Math.floor(Date.now()) - started;
|
||||
ga('send', 'event', 'Challenge', 'solved', challengeName + ', Time: ' + time +', Attempts: ' + attempts);
|
||||
$('#complete-bonfire-dialog').modal('show');
|
||||
$('#complete-bonfire-dialog').keydown(function(e) {
|
||||
if (e.ctrlKey && e.keyCode == 13) {
|
||||
$('.next-bonfire-button').click();
|
||||
}
|
||||
});
|
||||
}
|
@ -723,7 +723,7 @@
|
||||
<li>Add support for <a href="manual.html#option_lineWrapping">line
|
||||
wrapping</a> and <a href="manual.html#hideLine">code
|
||||
folding</a>.</li>
|
||||
<li>Add <a href="../mode/gfm/index.html">Github-style Markdown</a> mode.</li>
|
||||
<li>Add <a href="../mode/gfm/index.html">GitHub-style Markdown</a> mode.</li>
|
||||
<li>Add <a href="../theme/monokai.css">Monokai</a>
|
||||
and <a href="../theme/rubyblue.css">Rubyblue</a> themes.</li>
|
||||
<li>Add <a href="manual.html#setBookmark"><code>setBookmark</code></a> method.</li>
|
||||
|
@ -107,11 +107,11 @@ var tests = tests || [];
|
||||
var allSeeds = '';
|
||||
(function() {
|
||||
challengeSeed.forEach(function(elem) {
|
||||
allSeeds += elem + '\n';
|
||||
allSeeds += elem.replace(/fccss/g, '<script>').replace(/fcces/g,'</script>') + '\n';
|
||||
});
|
||||
editor.setValue(allSeeds);
|
||||
})();
|
||||
|
||||
editor.setValue(allSeeds);
|
||||
|
||||
function doLinting () {
|
||||
editor.operation(function () {
|
||||
@ -139,7 +139,7 @@ function doLinting () {
|
||||
//$('#testSuite').empty();
|
||||
function showCompletion() {
|
||||
var time = Math.floor(Date.now()) - started;
|
||||
ga('send', 'event', 'Challenge', 'solved', challengeName + ', Time: ' + time);
|
||||
ga('send', 'event', 'Challenge', 'solved', challenge_Name + ', Time: ' + time);
|
||||
$('#next-courseware-button').removeAttr('disabled');
|
||||
$('#next-courseware-button').addClass('animated tada');
|
||||
if (!userLoggedIn) {
|
||||
|
@ -1,246 +0,0 @@
|
||||
var widgets = [];
|
||||
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("codeEditor"), {
|
||||
lineNumbers: true,
|
||||
mode: "javascript",
|
||||
theme: 'monokai',
|
||||
runnable: true,
|
||||
lint: true,
|
||||
matchBrackets: true,
|
||||
autoCloseBrackets: true,
|
||||
scrollbarStyle: 'null',
|
||||
lineWrapping: true,
|
||||
gutters: ["CodeMirror-lint-markers"],
|
||||
onKeyEvent: doLinting
|
||||
});
|
||||
var editor = myCodeMirror;
|
||||
editor.setSize("100%", "auto");
|
||||
|
||||
// Hijack tab key to enter two spaces intead
|
||||
editor.setOption("extraKeys", {
|
||||
Tab: function(cm) {
|
||||
if (cm.somethingSelected()){
|
||||
cm.indentSelection("add");
|
||||
} else {
|
||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
},
|
||||
"Shift-Tab": function(cm) {
|
||||
if (cm.somethingSelected()){
|
||||
cm.indentSelection("subtract");
|
||||
} else {
|
||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
},
|
||||
"Ctrl-Enter": function() {
|
||||
bonfireExecute();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
var attempts = 0;
|
||||
if (attempts) {
|
||||
attempts = 0;
|
||||
}
|
||||
|
||||
|
||||
var codeOutput = CodeMirror.fromTextArea(document.getElementById("codeOutput"), {
|
||||
lineNumbers: false,
|
||||
mode: "text",
|
||||
theme: 'monokai',
|
||||
readOnly: 'nocursor',
|
||||
lineWrapping: true
|
||||
});
|
||||
|
||||
codeOutput.setValue('/**\n' +
|
||||
' * Your output will go here.\n' + ' * Console.log() -type statements\n' +
|
||||
' * will appear in your browser\'s\n' + ' * DevTools JavaScript console.\n' +
|
||||
' */');
|
||||
codeOutput.setSize("100%", "100%");
|
||||
var info = editor.getScrollInfo();
|
||||
var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
|
||||
if (info.top + info.clientHeight < after)
|
||||
editor.scrollTo(null, after - info.clientHeight + 3);
|
||||
|
||||
var editorValue;
|
||||
|
||||
|
||||
var challengeSeed = challengeSeed || null;
|
||||
var tests = tests || [];
|
||||
|
||||
var allSeeds = '';
|
||||
(function() {
|
||||
challengeSeed.forEach(function(elem) {
|
||||
allSeeds += elem + '\n';
|
||||
});
|
||||
})();
|
||||
|
||||
editorValue = allSeeds;
|
||||
|
||||
|
||||
myCodeMirror.setValue(editorValue);
|
||||
|
||||
function doLinting () {
|
||||
editor.operation(function () {
|
||||
for (var i = 0; i < widgets.length; ++i)
|
||||
editor.removeLineWidget(widgets[i]);
|
||||
widgets.length = 0;
|
||||
JSHINT(editor.getValue());
|
||||
for (var i = 0; i < JSHINT.errors.length; ++i) {
|
||||
var err = JSHINT.errors[i];
|
||||
if (!err) continue;
|
||||
var msg = document.createElement("div");
|
||||
var icon = msg.appendChild(document.createElement("span"));
|
||||
icon.innerHTML = "!!";
|
||||
icon.className = "lint-error-icon";
|
||||
msg.appendChild(document.createTextNode(err.reason));
|
||||
msg.className = "lint-error";
|
||||
widgets.push(editor.addLineWidget(err.line - 1, msg, {
|
||||
coverGutter: false,
|
||||
noHScroll: true
|
||||
}));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$('#submitButton').on('click', function () {
|
||||
bonfireExecute();
|
||||
});
|
||||
|
||||
function bonfireExecute() {
|
||||
attempts++;
|
||||
ga('send', 'event', 'Challenge', 'ran-code', challengeName);
|
||||
userTests= null;
|
||||
$('#codeOutput').empty();
|
||||
var userJavaScript = myCodeMirror.getValue();
|
||||
userJavaScript = removeComments(userJavaScript);
|
||||
userJavaScript = scrapeTests(userJavaScript);
|
||||
// simple fix in case the user forgets to invoke their function
|
||||
|
||||
submit(userJavaScript, function(cls, message) {
|
||||
if (cls) {
|
||||
codeOutput.setValue(message.error);
|
||||
runTests('Error', null);
|
||||
} else {
|
||||
codeOutput.setValue(message.output);
|
||||
message.input = removeLogs(message.input);
|
||||
runTests(null, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var userTests;
|
||||
var testSalt = Math.random();
|
||||
|
||||
|
||||
var scrapeTests = function(userJavaScript) {
|
||||
|
||||
// insert tests from mongo
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
userJavaScript += '\n' + tests[i];
|
||||
}
|
||||
|
||||
var counter = 0;
|
||||
var regex = new RegExp(/(expect(\s+)?\(.*\;)|(assert(\s+)?\(.*\;)|(assert\.\w.*\;)|(.*\.should\..*\;)/);
|
||||
var match = regex.exec(userJavaScript);
|
||||
while (match != null) {
|
||||
var replacement = '//' + counter + testSalt;
|
||||
userJavaScript = userJavaScript.substring(0, match.index) + replacement + userJavaScript.substring(match.index + match[0].length);
|
||||
|
||||
if (!userTests) {
|
||||
userTests= [];
|
||||
}
|
||||
userTests.push({"text": match[0], "line": counter, "err": null});
|
||||
counter++;
|
||||
match = regex.exec(userJavaScript);
|
||||
}
|
||||
|
||||
return userJavaScript;
|
||||
};
|
||||
|
||||
function removeComments(userJavaScript) {
|
||||
var regex = new RegExp(/(\/\*[^(\*\/)]*\*\/)|\/\/[^\n]*/g);
|
||||
return userJavaScript.replace(regex, '');
|
||||
}
|
||||
|
||||
function removeLogs(userJavaScript) {
|
||||
return userJavaScript.replace(/(console\.[\w]+\s*\(.*\;)/g, '');
|
||||
}
|
||||
|
||||
var pushed = false;
|
||||
var createTestDisplay = function() {
|
||||
if (pushed) {
|
||||
userTests.pop();
|
||||
}
|
||||
for (var i = 0; i < userTests.length;i++) {
|
||||
var test = userTests[i];
|
||||
var testDoc = document.createElement("div");
|
||||
if (test.err != null) {
|
||||
console.log('Should be displaying bad tests');
|
||||
$(testDoc)
|
||||
.html("<div class='row'><div class='col-xs-2 text-center'><i class='ion-close-circled big-error-icon'></i></div><div class='col-xs-10 test-output wrappable test-vertical-center grayed-out-test-output'>" + test.text + "</div><div class='col-xs-10 test-output wrappable'>" + test.err + "</div></div><div class='ten-pixel-break'/>")
|
||||
.prependTo($('#testSuite'))
|
||||
} else {
|
||||
$(testDoc)
|
||||
.html("<div class='row'><div class='col-xs-2 text-center'><i class='ion-checkmark-circled big-success-icon'></i></div><div class='col-xs-10 test-output test-vertical-center wrappable grayed-out-test-output'>" + test.text + "</div></div><div class='ten-pixel-break'/>")
|
||||
.appendTo($('#testSuite'));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var expect = chai.expect;
|
||||
|
||||
|
||||
var reassembleTest = function(test, data) {
|
||||
var lineNum = test.line;
|
||||
var regexp = new RegExp("\/\/" + lineNum + testSalt);
|
||||
return data.input.replace(regexp, test.text);
|
||||
};
|
||||
|
||||
var runTests = function(err, data) {
|
||||
var allTestsPassed = true;
|
||||
pushed = false;
|
||||
$('#testSuite').children().remove();
|
||||
if (err && userTests.length > 0) {
|
||||
userTests= [{text:"Program Execution Failure", err: "No user tests were run."}];
|
||||
createTestDisplay();
|
||||
} else if (userTests) {
|
||||
userTests.push(false);
|
||||
pushed = true;
|
||||
userTests.forEach(function(test, ix, arr){
|
||||
try {
|
||||
if (test) {
|
||||
var output = eval(reassembleTest(test, data));
|
||||
}
|
||||
} catch(error) {
|
||||
allTestsPassed = false;
|
||||
arr[ix].err = error.message;
|
||||
} finally {
|
||||
if (!test) {
|
||||
createTestDisplay();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (allTestsPassed) {
|
||||
allTestsPassed = false;
|
||||
showCompletion();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function showCompletion() {
|
||||
var time = Math.floor(Date.now()) - started;
|
||||
ga('send', 'event', 'Challenge', 'solved', challengeName + ', Time: ' + time +', Attempts: ' + attempts);
|
||||
$('#complete-courseware-dialog').modal('show');
|
||||
$('#complete-courseware-dialog').keydown(function(e) {
|
||||
if (e.ctrlKey && e.keyCode == 13) {
|
||||
$('#next-courseware-button').click();
|
||||
}
|
||||
});
|
||||
}
|
248
public/js/lib/coursewares/coursewaresJSFramework_0.0.2.js
Normal file
248
public/js/lib/coursewares/coursewaresJSFramework_0.0.2.js
Normal file
@ -0,0 +1,248 @@
|
||||
var widgets = [];
|
||||
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("codeEditor"), {
|
||||
lineNumbers: true,
|
||||
mode: "javascript",
|
||||
theme: 'monokai',
|
||||
runnable: true,
|
||||
lint: true,
|
||||
matchBrackets: true,
|
||||
autoCloseBrackets: true,
|
||||
scrollbarStyle: 'null',
|
||||
lineWrapping: true,
|
||||
gutters: ["CodeMirror-lint-markers"],
|
||||
onKeyEvent: doLinting
|
||||
});
|
||||
var editor = myCodeMirror;
|
||||
editor.setSize("100%", "auto");
|
||||
|
||||
// Hijack tab key to enter two spaces intead
|
||||
editor.setOption("extraKeys", {
|
||||
Tab: function(cm) {
|
||||
if (cm.somethingSelected()){
|
||||
cm.indentSelection("add");
|
||||
} else {
|
||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
},
|
||||
"Shift-Tab": function(cm) {
|
||||
if (cm.somethingSelected()){
|
||||
cm.indentSelection("subtract");
|
||||
} else {
|
||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
},
|
||||
"Ctrl-Enter": function() {
|
||||
bonfireExecute();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
var attempts = 0;
|
||||
if (attempts) {
|
||||
attempts = 0;
|
||||
}
|
||||
|
||||
|
||||
var codeOutput = CodeMirror.fromTextArea(document.getElementById("codeOutput"), {
|
||||
lineNumbers: false,
|
||||
mode: "text",
|
||||
theme: 'monokai',
|
||||
readOnly: 'nocursor',
|
||||
lineWrapping: true
|
||||
});
|
||||
|
||||
codeOutput.setValue('/**\n' +
|
||||
' * Your output will go here.\n' + ' * Console.log() -type statements\n' +
|
||||
' * will appear in your browser\'s\n' + ' * DevTools JavaScript console.\n' +
|
||||
' */');
|
||||
codeOutput.setSize("100%", "100%");
|
||||
var info = editor.getScrollInfo();
|
||||
var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
|
||||
if (info.top + info.clientHeight < after)
|
||||
editor.scrollTo(null, after - info.clientHeight + 3);
|
||||
|
||||
var editorValue;
|
||||
|
||||
|
||||
var challengeSeed = challengeSeed || null;
|
||||
var tests = tests || [];
|
||||
|
||||
var allSeeds = '';
|
||||
(function() {
|
||||
challengeSeed.forEach(function(elem) {
|
||||
allSeeds += elem + '\n';
|
||||
});
|
||||
})();
|
||||
|
||||
editorValue = allSeeds;
|
||||
|
||||
|
||||
myCodeMirror.setValue(editorValue);
|
||||
|
||||
function doLinting () {
|
||||
editor.operation(function () {
|
||||
for (var i = 0; i < widgets.length; ++i)
|
||||
editor.removeLineWidget(widgets[i]);
|
||||
widgets.length = 0;
|
||||
JSHINT(editor.getValue());
|
||||
for (var i = 0; i < JSHINT.errors.length; ++i) {
|
||||
var err = JSHINT.errors[i];
|
||||
if (!err) continue;
|
||||
var msg = document.createElement("div");
|
||||
var icon = msg.appendChild(document.createElement("span"));
|
||||
icon.innerHTML = "!!";
|
||||
icon.className = "lint-error-icon";
|
||||
msg.appendChild(document.createTextNode(err.reason));
|
||||
msg.className = "lint-error";
|
||||
widgets.push(editor.addLineWidget(err.line - 1, msg, {
|
||||
coverGutter: false,
|
||||
noHScroll: true
|
||||
}));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$('#submitButton').on('click', function () {
|
||||
bonfireExecute();
|
||||
});
|
||||
|
||||
function bonfireExecute() {
|
||||
attempts++;
|
||||
ga('send', 'event', 'Challenge', 'ran-code', challenge_Name);
|
||||
userTests= null;
|
||||
$('#codeOutput').empty();
|
||||
var userJavaScript = myCodeMirror.getValue();
|
||||
userJavaScript = removeComments(userJavaScript);
|
||||
userJavaScript = scrapeTests(userJavaScript);
|
||||
// simple fix in case the user forgets to invoke their function
|
||||
|
||||
submit(userJavaScript, function(cls, message) {
|
||||
if (cls) {
|
||||
codeOutput.setValue(message.error);
|
||||
runTests('Error', null);
|
||||
} else {
|
||||
codeOutput.setValue(message.output);
|
||||
message.input = removeLogs(message.input);
|
||||
runTests(null, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var userTests;
|
||||
var testSalt = Math.random();
|
||||
|
||||
|
||||
var scrapeTests = function(userJavaScript) {
|
||||
|
||||
// insert tests from mongo
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
userJavaScript += '\n' + tests[i];
|
||||
}
|
||||
|
||||
var counter = 0;
|
||||
var regex = new RegExp(/(expect(\s+)?\(.*\;)|(assert(\s+)?\(.*\;)|(assert\.\w.*\;)|(.*\.should\..*\;)/);
|
||||
var match = regex.exec(userJavaScript);
|
||||
while (match != null) {
|
||||
var replacement = '//' + counter + testSalt;
|
||||
userJavaScript = userJavaScript.substring(0, match.index) + replacement + userJavaScript.substring(match.index + match[0].length);
|
||||
|
||||
if (!userTests) {
|
||||
userTests= [];
|
||||
}
|
||||
userTests.push({"text": match[0], "line": counter, "err": null});
|
||||
counter++;
|
||||
match = regex.exec(userJavaScript);
|
||||
}
|
||||
|
||||
return userJavaScript;
|
||||
};
|
||||
|
||||
function removeComments(userJavaScript) {
|
||||
var regex = new RegExp(/(\/\*[^(\*\/)]*\*\/)|\/\/[^\n]*/g);
|
||||
return userJavaScript.replace(regex, '');
|
||||
}
|
||||
|
||||
function removeLogs(userJavaScript) {
|
||||
return userJavaScript.replace(/(console\.[\w]+\s*\(.*\;)/g, '');
|
||||
}
|
||||
|
||||
var pushed = false;
|
||||
var createTestDisplay = function() {
|
||||
if (pushed) {
|
||||
userTests.pop();
|
||||
}
|
||||
for (var i = 0; i < userTests.length;i++) {
|
||||
var test = userTests[i];
|
||||
var testDoc = document.createElement("div");
|
||||
if (test.err != null) {
|
||||
console.log('Should be displaying bad tests');
|
||||
$(testDoc)
|
||||
.html("<div class='row'><div class='col-xs-2 text-center'><i class='ion-close-circled big-error-icon'></i></div><div class='col-xs-10 test-output wrappable test-vertical-center grayed-out-test-output'>" + test.text + "</div><div class='col-xs-10 test-output wrappable'>" + test.err + "</div></div><div class='ten-pixel-break'/>")
|
||||
.prependTo($('#testSuite'))
|
||||
} else {
|
||||
$(testDoc)
|
||||
.html("<div class='row'><div class='col-xs-2 text-center'><i class='ion-checkmark-circled big-success-icon'></i></div><div class='col-xs-10 test-output test-vertical-center wrappable grayed-out-test-output'>" + test.text + "</div></div><div class='ten-pixel-break'/>")
|
||||
.appendTo($('#testSuite'));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var expect = chai.expect;
|
||||
var assert = chai.assert;
|
||||
var should = chai.should;
|
||||
|
||||
|
||||
var reassembleTest = function(test, data) {
|
||||
var lineNum = test.line;
|
||||
var regexp = new RegExp("\/\/" + lineNum + testSalt);
|
||||
return data.input.replace(regexp, test.text);
|
||||
};
|
||||
|
||||
var runTests = function(err, data) {
|
||||
var allTestsPassed = true;
|
||||
pushed = false;
|
||||
$('#testSuite').children().remove();
|
||||
if (err && userTests.length > 0) {
|
||||
userTests= [{text:"Program Execution Failure", err: "No user tests were run."}];
|
||||
createTestDisplay();
|
||||
} else if (userTests) {
|
||||
userTests.push(false);
|
||||
pushed = true;
|
||||
userTests.forEach(function(test, ix, arr){
|
||||
try {
|
||||
if (test) {
|
||||
var output = eval(reassembleTest(test, data));
|
||||
}
|
||||
} catch(error) {
|
||||
allTestsPassed = false;
|
||||
arr[ix].err = error.message;
|
||||
} finally {
|
||||
if (!test) {
|
||||
createTestDisplay();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (allTestsPassed) {
|
||||
allTestsPassed = false;
|
||||
showCompletion();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function showCompletion() {
|
||||
var time = Math.floor(Date.now()) - started;
|
||||
ga('send', 'event', 'Challenge', 'solved', challenge_Name + ', Time: ' + time +', Attempts: ' + attempts);
|
||||
$('#complete-courseware-dialog').modal('show');
|
||||
$('#complete-courseware-dialog').keydown(function(e) {
|
||||
if (e.ctrlKey && e.keyCode == 13) {
|
||||
$('#next-courseware-button').click();
|
||||
}
|
||||
});
|
||||
}
|
@ -47,28 +47,6 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
function completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash, bonfireName) {
|
||||
$('#complete-bonfire-dialog').modal('show');
|
||||
// Only post to server if there is an authenticated user
|
||||
if ($('.signup-btn-nav').length < 1) {
|
||||
$.post(
|
||||
'/completed-bonfire',
|
||||
{
|
||||
bonfireInfo: {
|
||||
completedWith: didCompleteWith,
|
||||
solution: bonfireSolution,
|
||||
bonfireHash: thisBonfireHash,
|
||||
bonfireName: bonfireName
|
||||
}
|
||||
},
|
||||
function(res) {
|
||||
if (res) {
|
||||
window.location.href = '/bonfires'
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function completedFieldGuide(fieldGuideId) {
|
||||
if ($('.signup-btn-nav').length < 1) {
|
||||
$.post(
|
||||
@ -86,15 +64,6 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
|
||||
$('.next-bonfire-button').on('click', function() {
|
||||
var bonfireSolution = myCodeMirror.getValue();
|
||||
var thisBonfireHash = passedBonfireHash || null;
|
||||
var bonfireName = $('#bonfire-name').text();
|
||||
var didCompleteWith = $('#completed-with').val() || null;
|
||||
completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash, bonfireName);
|
||||
|
||||
});
|
||||
|
||||
$('.next-field-guide-button').on('click', function() {
|
||||
var fieldGuideId = $('#fieldGuideId').text();
|
||||
completedFieldGuide(fieldGuideId);
|
||||
@ -112,66 +81,70 @@ $(document).ready(function() {
|
||||
$('#complete-zipline-or-basejump-dialog').modal('show');
|
||||
});
|
||||
|
||||
$('#complete-bonfire-dialog').on('hidden.bs.modal', function() {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
$('#complete-courseware-dialog').on('hidden.bs.modal', function() {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
var challengeTypes = {
|
||||
'HTML_CSS_JQ': 0,
|
||||
'JAVASCRIPT': 1,
|
||||
'VIDEO': 2,
|
||||
'ZIPLINE': 3,
|
||||
'BASEJUMP': 4,
|
||||
'BONFIRE': 5
|
||||
};
|
||||
$('#next-courseware-button').on('click', function() {
|
||||
if ($('.signup-btn-nav').length < 1) {
|
||||
switch (challengeType) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case challengeTypes.HTML_CSS_JQ:
|
||||
case challengeTypes.JAVASCRIPT:
|
||||
case challengeTypes.VIDEO:
|
||||
console.log(challenge_Id);
|
||||
$.post(
|
||||
'/completed-courseware/',
|
||||
'/completed-challenge/',
|
||||
{
|
||||
coursewareInfo: {
|
||||
coursewareHash: passedCoursewareHash,
|
||||
coursewareName: passedCoursewareName
|
||||
challengeInfo: {
|
||||
challengeId: challenge_Id,
|
||||
challengeName: challenge_Name
|
||||
}
|
||||
}).success(
|
||||
function(res) {
|
||||
if (res) {
|
||||
window.location.href = '/challenges';
|
||||
window.location.href = '/challenges/next-challenge';
|
||||
}
|
||||
}
|
||||
);
|
||||
break;
|
||||
case 3:
|
||||
case challengeTypes.ZIPLINE:
|
||||
var didCompleteWith = $('#completed-with').val() || null;
|
||||
var publicURL = $('#public-url').val() || null;
|
||||
$.post(
|
||||
'/completed-zipline-or-basejump/',
|
||||
{
|
||||
coursewareInfo: {
|
||||
coursewareHash: passedCoursewareHash,
|
||||
coursewareName: passedCoursewareName,
|
||||
challengeInfo: {
|
||||
challengeId: challenge_Id,
|
||||
challengeName: challenge_Name,
|
||||
completedWith: didCompleteWith,
|
||||
publicURL: publicURL,
|
||||
challengeType: challengeType
|
||||
}
|
||||
}).success(
|
||||
function() {
|
||||
window.location.href = '/challenges';
|
||||
window.location.href = '/challenges/next-challenge';
|
||||
}).fail(
|
||||
function() {
|
||||
window.location.href = '/challenges';
|
||||
});
|
||||
break;
|
||||
case 4:
|
||||
case challengeTypes.BASEJUMP:
|
||||
var didCompleteWith = $('#completed-with').val() || null;
|
||||
var publicURL = $('#public-url').val() || null;
|
||||
var githubURL = $('#github-url').val() || null;
|
||||
$.post(
|
||||
'/completed-zipline-or-basejump/',
|
||||
{
|
||||
coursewareInfo: {
|
||||
coursewareHash: passedCoursewareHash,
|
||||
coursewareName: passedCoursewareName,
|
||||
challengeInfo: {
|
||||
challengeId: challenge_Id,
|
||||
challengeName: challenge_Name,
|
||||
completedWith: didCompleteWith,
|
||||
publicURL: publicURL,
|
||||
githubURL: githubURL,
|
||||
@ -179,11 +152,31 @@ $(document).ready(function() {
|
||||
verified: false
|
||||
}
|
||||
}).success(function() {
|
||||
window.location.href = '/challenges';
|
||||
window.location.href = '/challenges/next-challenge';
|
||||
}).fail(function() {
|
||||
window.location.replace(window.location.href);
|
||||
});
|
||||
break;
|
||||
case challengeTypes.BONFIRE:
|
||||
var bonfireSolution = myCodeMirror.getValue();
|
||||
var didCompleteWith = $('#completed-with').val() || null;
|
||||
$.post(
|
||||
'/completed-bonfire/',
|
||||
{
|
||||
challengeInfo: {
|
||||
challengeId: challenge_Id,
|
||||
challengeName: challenge_Name,
|
||||
completedWith: didCompleteWith,
|
||||
challengeType: challengeType,
|
||||
solution: bonfireSolution
|
||||
}
|
||||
},
|
||||
function(res) {
|
||||
if (res) {
|
||||
window.location.href = '/challenges/next-challenge';
|
||||
}
|
||||
}
|
||||
);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -14,7 +14,18 @@
|
||||
"expect(meetBonfire()).to.be.a(\"boolean\");",
|
||||
"expect(meetBonfire()).to.be.true;"
|
||||
],
|
||||
"challengeSeed": "function meetBonfire(argument) {\n // Good luck!\n console.log(\"you can read this function's argument in the developer tools\", argument);\n\n return false;\n}\n\n\n\nmeetBonfire(\"You can do this!\");"
|
||||
"challengeSeed": [
|
||||
"function meetBonfire(argument) {",
|
||||
" // Good luck!",
|
||||
" console.log(\"you can read this function's argument in the developer tools\", argument);",
|
||||
"",
|
||||
" return false;",
|
||||
"}",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"meetBonfire(\"You can do this!\");"
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": "a202eed8fc186c8434cb6d61",
|
||||
@ -31,7 +42,13 @@
|
||||
"You may need to turn the string into an array before you can reverse it.",
|
||||
"Your result must be a string."
|
||||
],
|
||||
"challengeSeed": "function reverseString(str) {\n return str;\r\n}\n\nreverseString('hello');",
|
||||
"challengeSeed": [
|
||||
"function reverseString(str) {",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"reverseString('hello');"
|
||||
],
|
||||
"MDNlinks": ["Global String Object", "String.split()", "Array.reverse()", "Array.join()"]
|
||||
},
|
||||
{
|
||||
@ -50,7 +67,13 @@
|
||||
"Factorials are often represented with the shorthand notation n!",
|
||||
"For example: 5! = 1 * 2 * 3 * 4 * 5 = 120f"
|
||||
],
|
||||
"challengeSeed": "function factorialize(num) {\n return num;\r\n}\n\nfactorialize(5);",
|
||||
"challengeSeed": [
|
||||
"function factorialize(num) {",
|
||||
" return num;",
|
||||
"}",
|
||||
"",
|
||||
"factorialize(5);"
|
||||
],
|
||||
"MDNlinks": ["Arithmetic Operators"]
|
||||
},
|
||||
{
|
||||
@ -72,7 +95,16 @@
|
||||
"assert.deepEqual(palindrome(\"never odd or even\"), true);",
|
||||
"assert.deepEqual(palindrome(\"nope\"), false);"
|
||||
],
|
||||
"challengeSeed": "function palindrome(str) {\n // Good luck!\n return true;\n}\n\n\n\npalindrome(\"eye\");",
|
||||
"challengeSeed": [
|
||||
"function palindrome(str) {",
|
||||
" // Good luck!",
|
||||
" return true;",
|
||||
"}",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"palindrome(\"eye\");"
|
||||
],
|
||||
"MDNlinks": ["String.replace()", "String.toLowerCase()"]
|
||||
},
|
||||
{
|
||||
@ -83,7 +115,13 @@
|
||||
"Return the length of the longest word in the provided sentence.",
|
||||
"Your response should be a number."
|
||||
],
|
||||
"challengeSeed": "function findLongestWord(str) {\n return str.length;\r\n}\n\nfindLongestWord('The quick brown fox jumped over the lazy dog');",
|
||||
"challengeSeed": [
|
||||
"function findLongestWord(str) {",
|
||||
" return str.length;",
|
||||
"}",
|
||||
"",
|
||||
"findLongestWord('The quick brown fox jumped over the lazy dog');"
|
||||
],
|
||||
"tests": [
|
||||
"expect(findLongestWord('The quick brown fox jumped over the lazy dog')).to.be.a('Number');",
|
||||
"expect(findLongestWord('The quick brown fox jumped over the lazy dog')).to.equal(6);",
|
||||
@ -101,7 +139,13 @@
|
||||
"Return the provided string with the first letter of each word capitalized.",
|
||||
"For the purpose of this exercise, you should also capitalize connecting words like 'the' and 'of'."
|
||||
],
|
||||
"challengeSeed": "function titleCase(str) {\n return str;\r\n}\n\ntitleCase(\"I'm a little tea pot\");",
|
||||
"challengeSeed": [
|
||||
"function titleCase(str) {",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"titleCase(\"I'm a little tea pot\");"
|
||||
],
|
||||
"tests": [
|
||||
"expect(titleCase(\"I'm a little tea pot\")).to.be.a('String');",
|
||||
"expect(titleCase(\"I'm a little tea pot\")).to.equal(\"I'm A Little Tea Pot\");",
|
||||
@ -119,7 +163,14 @@
|
||||
"Remember, you can iterate through an array with a simple for loop, and access each member with array syntax arr[i] .",
|
||||
"If you are writing your own Chai.js tests, be sure to use a deep equal statement instead of an equal statement when comparing arrays."
|
||||
],
|
||||
"challengeSeed": "function largestOfFour(arr) {\n // You can do this!\r\n return arr;\r\n}\n\nlargestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);",
|
||||
"challengeSeed": [
|
||||
"function largestOfFour(arr) {",
|
||||
" // You can do this!",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])).to.be.a('array');",
|
||||
"(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])).should.eql([5,27,39,1001]);",
|
||||
@ -135,7 +186,15 @@
|
||||
"Check if a string (first argument) ends with the given target string (second argument)."
|
||||
],
|
||||
|
||||
"challengeSeed": "function end(str, target) {\n // \"Never give up and good luck will find you.\"\r\n // -- Falcor\r\n return str;\r\n}\n\nend('Bastian', 'n');",
|
||||
"challengeSeed": [
|
||||
"function end(str, target) {",
|
||||
" // \"Never give up and good luck will find you.\"",
|
||||
" // -- Falcor",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"end('Bastian', 'n');"
|
||||
],
|
||||
"tests": [
|
||||
"assert.strictEqual(end('Bastian', 'n'), true, 'should equal true if target equals end of string');",
|
||||
"assert.strictEqual(end('He has to give me a new name', 'name'), true, 'should equal true if target equals end of string');",
|
||||
@ -150,7 +209,14 @@
|
||||
"description": [
|
||||
"Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number."
|
||||
],
|
||||
"challengeSeed": "function repeat(str, num) {\n // repeat after me\r\n return str;\r\n}\n\nrepeat('abc', 3);",
|
||||
"challengeSeed": [
|
||||
"function repeat(str, num) {",
|
||||
" // repeat after me",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"repeat('abc', 3);"
|
||||
],
|
||||
"tests": [
|
||||
"assert.strictEqual(repeat('*', 3), '***', 'should repeat a string n times');",
|
||||
"assert.strictEqual(repeat('abc', 3), 'abcabcabc', 'should repeat a string n times');",
|
||||
@ -166,7 +232,14 @@
|
||||
"Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a '...' ending.",
|
||||
"Note that the three dots at the end add to the string length."
|
||||
],
|
||||
"challengeSeed":"function truncate(str, num) {\n // Clear out that junk in your trunk\r\n return str;\r\n}\n\ntruncate('A-tisket a-tasket A green and yellow basket', 11);",
|
||||
"challengeSeed": [
|
||||
"function truncate(str, num) {",
|
||||
" // Clear out that junk in your trunk",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"truncate('A-tisket a-tasket A green and yellow basket', 11);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(truncate('A-tisket a-tasket A green and yellow basket', 11)).to.eqls('A-tisket...');",
|
||||
"assert(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length) === 'A-tisket a-tasket A green and yellow basket', 'should not truncate if string is = length');",
|
||||
@ -181,7 +254,14 @@
|
||||
"description": [
|
||||
"Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a multidimensional array."
|
||||
],
|
||||
"challengeSeed": "function chunk(arr, size) {\n // Break it up.\r\n return arr;\r\n}\n\nchunk(['a', 'b', 'c', 'd'], 2);",
|
||||
"challengeSeed": [
|
||||
"function chunk(arr, size) {",
|
||||
" // Break it up.",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"chunk(['a', 'b', 'c', 'd'], 2);"
|
||||
],
|
||||
"tests": [
|
||||
"assert.deepEqual(chunk(['a', 'b', 'c', 'd'], 2), [['a', 'b'], ['c', 'd']], 'should return chunked arrays');",
|
||||
"assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 3), [[0, 1, 2], [3, 4, 5]], 'should return chunked arrays');",
|
||||
@ -196,7 +276,14 @@
|
||||
"description": [
|
||||
"Return the remaining elements of an array after chopping off n elements from the head."
|
||||
],
|
||||
"challengeSeed": "function slasher(arr, howMany) {\n // it doesn't always pay to be first\r\n return arr;\r\n}\n\nslasher([1, 2, 3], 2);",
|
||||
"challengeSeed": [
|
||||
"function slasher(arr, howMany) {",
|
||||
" // it doesn't always pay to be first",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"slasher([1, 2, 3], 2);"
|
||||
],
|
||||
"tests": [
|
||||
"assert.deepEqual(slasher([1, 2, 3], 2), [3], 'should drop the first two elements');",
|
||||
"assert.deepEqual(slasher([1, 2, 3], 0), [1, 2, 3], 'should return all elements when n < 1');",
|
||||
@ -214,7 +301,13 @@
|
||||
"The arguments ['hello', 'hey'] should return false because the string 'hello' does not contain a 'y'.",
|
||||
"Another example, ['Alien', 'line'], should return true because all of the letters in 'line' are present in 'Alien'."
|
||||
],
|
||||
"challengeSeed": "function mutation(arr) {\n return arr;\n}\n\nmutation(['hello', 'hey']);",
|
||||
"challengeSeed": [
|
||||
"function mutation(arr) {",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"mutation(['hello', 'hey']);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(mutation(['hello', 'hey'])).to.be.false;",
|
||||
"expect(mutation(['hello', 'Hello'])).to.be.true;",
|
||||
@ -232,7 +325,14 @@
|
||||
"Remove all falsey values from an array.",
|
||||
"Falsey values in javascript are false, null, 0, \"\", undefined, and NaN."
|
||||
],
|
||||
"challengeSeed": "function bouncer(arr) {\n // Don't show a false ID to this bouncer.\r\n return arr;\r\n}\n\nbouncer([7, 'ate', '', false, 9]);",
|
||||
"challengeSeed": [
|
||||
"function bouncer(arr) {",
|
||||
" // Don't show a false ID to this bouncer.",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"bouncer([7, 'ate', '', false, 9]);"
|
||||
],
|
||||
"tests": [
|
||||
"assert.deepEqual(bouncer([7, 'ate', '', false, 9]), [7, 'ate', 9], 'should remove falsey values');",
|
||||
"assert.deepEqual(bouncer(['a', 'b', 'c']), ['a', 'b', 'c'], 'should return full array if no falsey elements');",
|
||||
@ -247,7 +347,15 @@
|
||||
"description":[
|
||||
"Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument)."
|
||||
],
|
||||
"challengeSeed":"function where(collection, source) {\n var arr = [];\r\n // What's in a name?\r\n return arr;\r\n}\n\nwhere([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });",
|
||||
"challengeSeed": [
|
||||
"function where(collection, source) {",
|
||||
" var arr = [];",
|
||||
" // What's in a name?",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });"
|
||||
],
|
||||
"tests":[
|
||||
"assert.deepEqual(where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' }), [{ first: 'Tybalt', last: 'Capulet' }], 'should return an array of objects');",
|
||||
"assert.deepEqual(where([{ 'a': 1 }, { 'a': 1 }, { 'a': 1, 'b': 2 }], { 'a': 1 }), [{ 'a': 1 }, { 'a': 1 }, { 'a': 1, 'b': 2 }], 'should return with multiples');"
|
||||
@ -261,7 +369,14 @@
|
||||
"description":[
|
||||
"You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments."
|
||||
],
|
||||
"challengeSeed": "function destroyer(arr) {\n // Remove all the values\r\n return arr;\r\n}\n\ndestroyer([1, 2, 3, 1, 2, 3], 2, 3);",
|
||||
"challengeSeed": [
|
||||
"function destroyer(arr) {",
|
||||
" // Remove all the values",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"destroyer([1, 2, 3, 1, 2, 3], 2, 3);"
|
||||
],
|
||||
"tests": [
|
||||
"assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1], 'should remove correct values from an array');",
|
||||
"assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1], 'should remove correct values from an array');"
|
||||
@ -276,7 +391,14 @@
|
||||
"Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument).",
|
||||
"For example, where([1,2,3,4], 1.5) should return 1 because it is greater than 1 (0th index), but less than 2 (1st index)."
|
||||
],
|
||||
"challengeSeed": "function where(arr, num) {\n // Find my place in this sorted array.\r\n return num;\r\n}\n\nwhere([40, 60], 50);",
|
||||
"challengeSeed": [
|
||||
"function where(arr, num) {",
|
||||
" // Find my place in this sorted array.",
|
||||
" return num;",
|
||||
"}",
|
||||
"",
|
||||
"where([40, 60], 50);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(where([10, 20, 30, 40, 50], 35)).to.equal(3);",
|
||||
"expect(where([10, 20, 30, 40, 50], 30)).to.equal(2);"
|
||||
@ -291,7 +413,13 @@
|
||||
"We'll pass you an array of two numbers. Return the sum of those two numbers and all numbers between them.",
|
||||
"The lowest number will not always come first."
|
||||
],
|
||||
"challengeSeed": "function sumAll(arr) {\n return(1);\r\n}\n\nsumAll([1, 4]);",
|
||||
"challengeSeed": [
|
||||
"function sumAll(arr) {",
|
||||
" return(1);",
|
||||
"}",
|
||||
"",
|
||||
"sumAll([1, 4]);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(sumAll([1, 4])).to.be.a('Number');",
|
||||
"expect(sumAll([1, 4])).to.equal(10);",
|
||||
@ -308,7 +436,15 @@
|
||||
"description": [
|
||||
"Compare two arrays and return a new array with any items not found in both of the original arrays."
|
||||
],
|
||||
"challengeSeed": "function diff(arr1, arr2) {\n var newArr = [];\r\n // Same, same; but different.\r\n return newArr;\r\n}\n\ndiff([1, 2, 3, 5], [1, 2, 3, 4, 5]);",
|
||||
"challengeSeed": [
|
||||
"function diff(arr1, arr2) {",
|
||||
" var newArr = [];",
|
||||
" // Same, same; but different.",
|
||||
" return newArr;",
|
||||
"}",
|
||||
"",
|
||||
"diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(diff([1, 2, 3, 5], [1, 2, 3, 4, 5])).to.be.a('array');",
|
||||
"assert.deepEqual(diff(['diorite', 'andesite', 'grass', 'dirt', 'pink wool', 'dead shrub'], ['diorite', 'andesite', 'grass', 'dirt', 'dead shrub']), ['pink wool'], 'arrays with only one difference');",
|
||||
@ -318,7 +454,7 @@
|
||||
"assert.includeMembers(diff([1, 'calf', 3, 'piglet'], [1, 'calf', 3, 4]), ['piglet', 4], 'arrays with numbers and strings');",
|
||||
"assert.deepEqual(diff([], ['snuffleupagus', 'cookie monster', 'elmo']), ['snuffleupagus', 'cookie monster', 'elmo'], 'empty array');"
|
||||
],
|
||||
"MDNlinks" : ["Comparison Operators"]
|
||||
"MDNlinks" : ["Comparison Operators", "String.slice()", "Array.filter()", "Array.indexOf()", "String.concat()"]
|
||||
},
|
||||
{
|
||||
"_id": "a7f4d8f2483413a6ce226cac",
|
||||
@ -335,7 +471,13 @@
|
||||
"Convert the given number into a roman numeral.",
|
||||
"All <a href=\"http://www.mathsisfun.com/roman-numerals.html\">roman numerals</a> answers should be provided in upper-case."
|
||||
],
|
||||
"challengeSeed": "function convert(num) {\n return num;\r\n}\n\nconvert(36);",
|
||||
"challengeSeed": [
|
||||
"function convert(num) {",
|
||||
" return num;",
|
||||
"}",
|
||||
"",
|
||||
"convert(36);"
|
||||
],
|
||||
"MDNlinks": ["Array.splice()", "Array.indexOf()", "Array.join()"]
|
||||
},
|
||||
{
|
||||
@ -356,7 +498,13 @@
|
||||
"Third argument is what you will be replacing the second argument with (after).",
|
||||
"NOTE: Preserve the case of the original word when you are replacing it. For example if you mean to replace the word 'Book' with the word 'dog', it should be replaced as 'Dog'"
|
||||
],
|
||||
"challengeSeed": "function replace(str, before, after) {\n return str;\r\n}\n\nreplace(\"A quick brown fox jumped over the lazy dog\", \"jumped\", \"leaped\");",
|
||||
"challengeSeed": [
|
||||
"function replace(str, before, after) {",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"replace(\"A quick brown fox jumped over the lazy dog\", \"jumped\", \"leaped\");"
|
||||
],
|
||||
"MDNlinks": ["Array.splice()", "String.replace()", "Array.join()"]
|
||||
},
|
||||
{
|
||||
@ -375,7 +523,13 @@
|
||||
"<a href=\"http://en.wikipedia.org/wiki/Pig_Latin\">Pig Latin</a> takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an \"ay\".",
|
||||
"If a word begins with a vowel you just add \"way\" to the end."
|
||||
],
|
||||
"challengeSeed": "function translate(str) {\n return str;\r\n}\n\ntranslate(\"consonant\");",
|
||||
"challengeSeed": [
|
||||
"function translate(str) {",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"translate(\"consonant\");"
|
||||
],
|
||||
"MDNlinks": ["Array.indexOf()", "Array.push()", "Array.join()", "String.substr()", "String.split()"]
|
||||
},
|
||||
{
|
||||
@ -392,7 +546,13 @@
|
||||
"<a href=\"http://en.wikipedia.org/wiki/Base_pair\">Base pairs</a> are a pair of AT and CG. Match the missing element to the provided character.",
|
||||
"Return the provided character as the first element in each array."
|
||||
],
|
||||
"challengeSeed": "function pair(str) {\n return str;\r\n}\n\npair(\"GCG\");",
|
||||
"challengeSeed": [
|
||||
"function pair(str) {",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"pair(\"GCG\");"
|
||||
],
|
||||
"MDNlinks": ["Array.push()", "String.split()"]
|
||||
},
|
||||
{
|
||||
@ -403,7 +563,13 @@
|
||||
"Find the missing letter in the passed letter range and return it.",
|
||||
"If all letters are present in the range, return undefined."
|
||||
],
|
||||
"challengeSeed": "function fearNotLetter(str) {\n return str;\n}\n\nfearNotLetter('abce');",
|
||||
"challengeSeed": [
|
||||
"function fearNotLetter(str) {",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"fearNotLetter('abce');"
|
||||
],
|
||||
"tests": [
|
||||
"expect(fearNotLetter('abce')).to.equal('d');",
|
||||
"expect(fearNotLetter('bcd')).to.be.undefined;",
|
||||
@ -420,7 +586,14 @@
|
||||
"Check if a value is classified as a boolean primitive. Return true or false.",
|
||||
"Boolean primitives are true and false."
|
||||
],
|
||||
"challengeSeed": "function boo(bool) {\n // What is the new fad diet for ghost developers? The Boolean.\r\n return bool;\r\n}\n\nboo(null);",
|
||||
"challengeSeed": [
|
||||
"function boo(bool) {",
|
||||
" // What is the new fad diet for ghost developers? The Boolean.",
|
||||
" return bool;",
|
||||
"}",
|
||||
"",
|
||||
"boo(null);"
|
||||
],
|
||||
"tests": [
|
||||
"assert.strictEqual(boo(true), true);",
|
||||
"assert.strictEqual(boo(false), true);",
|
||||
@ -443,7 +616,13 @@
|
||||
"The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.",
|
||||
"Check the assertion tests for examples."
|
||||
],
|
||||
"challengeSeed": "function unite(arr1, arr2, arr3) {\n return arr1;\r\n}\n\nunite([1, 2, 3], [5, 2, 1, 4], [2, 1]);",
|
||||
"challengeSeed": [
|
||||
"function unite(arr1, arr2, arr3) {",
|
||||
" return arr1;",
|
||||
"}",
|
||||
"",
|
||||
"unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);"
|
||||
],
|
||||
"tests": [
|
||||
"assert.deepEqual(unite([1, 3, 2], [5, 2, 1, 4], [2, 1]), [1, 3, 2, 5, 4], 'should return the union of the given arrays');",
|
||||
"assert.deepEqual(unite([1, 3, 2], [1, [5]], [2, [4]]), [1, 3, 2, [5], [4]], 'should not flatten nested arrays');"
|
||||
@ -457,7 +636,14 @@
|
||||
"description": [
|
||||
"Convert the characters \"&\", \"<\", \">\", '\"', and \"'\", in a string to their corresponding HTML entities."
|
||||
],
|
||||
"challengeSeed": "function convert(str) {\n // :)\r\n return str;\r\n}\n\nconvert('Dolce & Gabbana');",
|
||||
"challengeSeed": [
|
||||
"function convert(str) {",
|
||||
" // :)",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"convert('Dolce & Gabbana');"
|
||||
],
|
||||
"tests": [
|
||||
"assert.strictEqual(convert('Dolce & Gabbana'), 'Dolce & Gabbana', 'should escape characters');",
|
||||
"assert.strictEqual(convert('abc'), 'abc', 'should handle strings with nothing to escape');"
|
||||
@ -471,7 +657,15 @@
|
||||
"description": [
|
||||
"Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes."
|
||||
],
|
||||
"challengeSeed": "function spinalCase(str) {\n // \"It's such a fine line between stupid, and clever.\"\r\n // --David St. Hubbins\r\n return str;\r\n}\n\nspinalCase('This Is Spinal Tap');",
|
||||
"challengeSeed": [
|
||||
"function spinalCase(str) {",
|
||||
" // \"It's such a fine line between stupid, and clever.\"",
|
||||
" // --David St. Hubbins",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"spinalCase('This Is Spinal Tap');"
|
||||
],
|
||||
"tests": [
|
||||
"assert.strictEqual(spinalCase('This Is Spinal Tap'), 'this-is-spinal-tap', 'should return spinal case from string with spaces');",
|
||||
"assert.strictEqual(spinalCase('thisIsSpinalTap'), 'this-is-spinal-tap', 'should return spinal case from string with camel case');",
|
||||
@ -489,7 +683,13 @@
|
||||
"The first few numbers of the Fibonacci sequence are 1, 1, 2, 3, 5 and 8, and each subsequent number is the sum of the previous two numbers.",
|
||||
"As an example, passing 4 to the function should return 5 because all the odd Fibonacci numbers under 4 are 1, 1, and 3."
|
||||
],
|
||||
"challengeSeed": "function sumFibs(num) {\n return num;\r\n}\n\nsumFibs(4);",
|
||||
"challengeSeed": [
|
||||
"function sumFibs(num) {",
|
||||
" return num;",
|
||||
"}",
|
||||
"",
|
||||
"sumFibs(4);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(sumFibs(1)).to.be.a('number');",
|
||||
"expect(sumFibs(1000)).to.equal(1785);",
|
||||
@ -509,7 +709,13 @@
|
||||
"A prime number is defined as having only two divisors, 1 and itself. For example, 2 is a prime number because it's only divisible by 1 and 2. 1 isn't a prime number, because it's only divisible by itself.",
|
||||
"The provided number may not be a prime."
|
||||
],
|
||||
"challengeSeed": "function sumPrimes(num) {\n return num;\r\n}\n\nsumPrimes(10);",
|
||||
"challengeSeed": [
|
||||
"function sumPrimes(num) {",
|
||||
" return num;",
|
||||
"}",
|
||||
"",
|
||||
"sumPrimes(10);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(sumPrimes(10)).to.be.a('number');",
|
||||
"expect(sumPrimes(10)).to.equal(17);",
|
||||
@ -525,7 +731,14 @@
|
||||
"Find the smallest number that is evenly divisible by all numbers in the provided range.",
|
||||
"The range will be an array of two numbers that will not necessarily be in numerical order."
|
||||
],
|
||||
"challengeSeed": "function smallestCommons(arr) {\n return arr;\r\n}\r\n\n\nsmallestCommons([1,5]);",
|
||||
"challengeSeed": [
|
||||
"function smallestCommons(arr) {",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"",
|
||||
"smallestCommons([1,5]);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(smallestCommons([1,5])).to.be.a('number');",
|
||||
"expect(smallestCommons([1,5])).to.equal(60);",
|
||||
@ -541,7 +754,14 @@
|
||||
"description": [
|
||||
"Create a function that looks through an array (first argument) and returns the first element in the array that passes a truth test (second argument)."
|
||||
],
|
||||
"challengeSeed": "function find(arr, func) {\n var num = 0;\r\n return num;\r\n}\n\nfind([1, 2, 3, 4], function(num){ return num % 2 === 0; });",
|
||||
"challengeSeed": [
|
||||
"function find(arr, func) {",
|
||||
" var num = 0;",
|
||||
" return num;",
|
||||
"}",
|
||||
"",
|
||||
"find([1, 2, 3, 4], function(num){ return num % 2 === 0; });"
|
||||
],
|
||||
"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');"
|
||||
@ -555,7 +775,14 @@
|
||||
"description": [
|
||||
"Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true."
|
||||
],
|
||||
"challengeSeed": "function drop(arr, func) {\n // Drop them elements.\r\n return arr;\r\n}\n\ndrop([1, 2, 3], function(n) {return n < 3; });",
|
||||
"challengeSeed": [
|
||||
"function drop(arr, func) {",
|
||||
" // Drop them elements.",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"drop([1, 2, 3], function(n) {return n < 3; });"
|
||||
],
|
||||
"tests": [
|
||||
"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]);",
|
||||
@ -570,7 +797,14 @@
|
||||
"description": [
|
||||
"Flatten a nested array. You must account for varying levels of nesting."
|
||||
],
|
||||
"challengeSeed": "function steamroller(arr) {\n // I'm a steamroller, baby\r\n return arr;\r\n}\n\nsteamroller([1, [2], [3, [[4]]]]);",
|
||||
"challengeSeed": [
|
||||
"function steamroller(arr) {",
|
||||
" // I'm a steamroller, baby",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"steamroller([1, [2], [3, [[4]]]]);"
|
||||
],
|
||||
"tests": [
|
||||
"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');",
|
||||
@ -586,12 +820,19 @@
|
||||
"Return an English translated sentence of the passed binary string.",
|
||||
"The binary string will be space separated."
|
||||
],
|
||||
"challengeSeed": "function binaryAgent(str) {\n return str;\r\n}\n\nbinaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111');",
|
||||
"challengeSeed": [
|
||||
"function binaryAgent(str) {",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111');"
|
||||
],
|
||||
"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()"]
|
||||
"MDNlinks": ["String.charCodeAt()", "String.fromCharCode()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": "a10d2431ad0c6a099a4b8b52",
|
||||
@ -602,7 +843,14 @@
|
||||
"For this, check to see if the property defined in the second argument is present on every element of the collection.",
|
||||
"Remember, you can access object properties through either dot notation or [] notation."
|
||||
],
|
||||
"challengeSeed": "function every(collection, pre) {\n // Does everyone have one of these?\r\n return pre;\r\n}\n\nevery([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex');",
|
||||
"challengeSeed": [
|
||||
"function every(collection, pre) {",
|
||||
" // Does everyone have one of these?",
|
||||
" return pre;",
|
||||
"}",
|
||||
"",
|
||||
"every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex');"
|
||||
],
|
||||
"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');"
|
||||
@ -618,7 +866,13 @@
|
||||
"For example, add(2, 3) should return 5, and add(2) should return a function that is waiting for an argument so that <code>var sum2And = add(2); return sum2And(3); // 5</code>",
|
||||
"If either argument isn't a valid number, return undefined."
|
||||
],
|
||||
"challengeSeed": "function add() {\n return false;\n}\n\nadd(2,3);",
|
||||
"challengeSeed": [
|
||||
"function add() {",
|
||||
" return false;",
|
||||
"}",
|
||||
"",
|
||||
"add(2,3);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(add(2, 3)).to.equal(5);",
|
||||
"expect(add(2)(3)).to.equal(5);",
|
||||
@ -638,7 +892,14 @@
|
||||
"All functions that take an argument have an arity of 1, and the argument will be a string.",
|
||||
"These methods must be the only available means for interacting with the object."
|
||||
],
|
||||
"challengeSeed": "var Person = function(firstAndLast) {\n return firstAndLast;\r\n};\n\nvar bob = new Person('Bob Ross');\nbob.getFullName();",
|
||||
"challengeSeed": [
|
||||
"var Person = function(firstAndLast) {",
|
||||
" return firstAndLast;",
|
||||
"};",
|
||||
"",
|
||||
"var bob = new Person('Bob Ross');",
|
||||
"bob.getFullName();"
|
||||
],
|
||||
"tests": [
|
||||
"expect(Object.keys(bob).length).to.eql(6);",
|
||||
"expect(bob instanceof Person).to.be.true;",
|
||||
@ -668,7 +929,15 @@
|
||||
"The values should be rounded to the nearest whole number. The body being orbited is Earth.",
|
||||
"The radius of the earth is 6367.4447 kilometers, and the GM value of earth is 398600.4418"
|
||||
],
|
||||
"challengeSeed": "function orbitalPeriod(arr) {\n var GM = 398600.4418;\n var earthRadius = 6367.4447;\n return arr;\r\n}\r\n\r\norbitalPeriod([{name : \"sputkin\", avgAlt : 35873.5553}]);",
|
||||
"challengeSeed": [
|
||||
"function orbitalPeriod(arr) {",
|
||||
" var GM = 398600.4418;",
|
||||
" var earthRadius = 6367.4447;",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"orbitalPeriod([{name : \"sputkin\", avgAlt : 35873.5553}]);"
|
||||
],
|
||||
"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}]);"
|
||||
@ -728,8 +997,17 @@
|
||||
"assert.deepEqual(telephoneCheck(\"2(757)6227382\"), false);",
|
||||
"assert.deepEqual(telephoneCheck(\"2(757)622-7382\"), false);"
|
||||
],
|
||||
"challengeSeed": "function telephoneCheck(str) {\n // Good luck!\n return true;\n}\n\n\n\ntelephoneCheck(\"555-555-5555\");",
|
||||
"MDNlinks" : ["RegExp"]
|
||||
"MDNlinks" : ["RegExp"],
|
||||
"challengeSeed": [
|
||||
"function telephoneCheck(str) {",
|
||||
" // Good luck!",
|
||||
" return true;",
|
||||
"}",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"telephoneCheck(\"555-555-5555\");"
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": "a3f503de51cf954ede28891d",
|
||||
@ -739,7 +1017,13 @@
|
||||
"Create a function that takes two or more arrays and returns an array of the symmetric difference of the provided arrays.",
|
||||
"The mathematical term symmetric difference refers to the elements in two sets that are in either the first or second set, but not in both."
|
||||
],
|
||||
"challengeSeed": "function sym(args) {\n return arguments;\r\n}\n\nsym([1, 2, 3], [5, 2, 1, 4]);",
|
||||
"challengeSeed": [
|
||||
"function sym(args) {",
|
||||
" return arguments;",
|
||||
"}",
|
||||
"",
|
||||
"sym([1, 2, 3], [5, 2, 1, 4]);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(sym([1, 2, 3], [5, 2, 1, 4])).to.eqls([3, 5, 4])",
|
||||
"assert.deepEqual(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5], 'should return the symmetric difference of the given arrays');",
|
||||
@ -755,7 +1039,26 @@
|
||||
"description": [
|
||||
"Design a cash register drawer function that accepts purchase price as the first argument, payment as the second argument, and cash-in-drawer (cid) as the third argument.", "cid is a 2d array listing available currency.", "Return the string \"Insufficient Funds\" if cash-in-drawer is less than the change due. Return the string \"Closed\" if cash-in-drawer is equal to the change due.", "Otherwise, return change in coin and bills, sorted in highest to lowest order."
|
||||
],
|
||||
"challengeSeed": "function drawer(price, cash, cid) {\n var change;\r\n // Here is your change, ma'am.\r\n return change;\r\n}\r\n\r\n// Example cash-in-drawer array:\r\n// [['PENNY', 1.01],\r\n// ['NICKEL', 2.05],\r\n// ['DIME', 3.10],\r\n// ['QUARTER', 4.25],\r\n// ['ONE', 90.00],\r\n// ['FIVE', 55.00],\r\n// ['TEN', 20.00],\r\n// ['TWENTY', 60.00],\r\n// ['ONE HUNDRED', 100.00]]\n\ndrawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);",
|
||||
"challengeSeed": [
|
||||
"function drawer(price, cash, cid) {",
|
||||
" var change;",
|
||||
" // Here is your change, ma'am.",
|
||||
" return change;",
|
||||
"}",
|
||||
"",
|
||||
"// Example cash-in-drawer array:",
|
||||
"// [['PENNY', 1.01],",
|
||||
"// ['NICKEL', 2.05],",
|
||||
"// ['DIME', 3.10],",
|
||||
"// ['QUARTER', 4.25],",
|
||||
"// ['ONE', 90.00],",
|
||||
"// ['FIVE', 55.00],",
|
||||
"// ['TEN', 20.00],",
|
||||
"// ['TWENTY', 60.00],",
|
||||
"// ['ONE HUNDRED', 100.00]]",
|
||||
"",
|
||||
"drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]])).to.be.a('array');",
|
||||
"expect(drawer(19.50, 20.00, [['PENNY', 0.01], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]])).to.be.a('string');",
|
||||
@ -774,7 +1077,29 @@
|
||||
"description": [
|
||||
"Compare and update inventory stored in a 2d array against a second 2d array of a fresh delivery. Update current inventory item quantity, and if an item cannot be found, add the new item and quantity into the inventory array in alphabetical order."
|
||||
],
|
||||
"challengeSeed": "function inventory(arr1, arr2) {\n // All inventory must be accounted for or you're fired!\r\n return arr1;\r\n}\n\n// Example inventory lists\r\nvar curInv = [\r\n [21, 'Bowling Ball'],\r\n [2, 'Dirty Sock'],\r\n [1, 'Hair Pin'],\r\n [5, 'Microphone']\r\n];\r\n\r\nvar newInv = [\r\n [2, 'Hair Pin'],\r\n [3, 'Half-Eaten Apple'],\r\n [67, 'Bowling Ball'],\r\n [7, 'Toothpaste']\r\n];\r\n\r\ninventory(curInv, newInv);",
|
||||
"challengeSeed": [
|
||||
"function inventory(arr1, arr2) {",
|
||||
" // All inventory must be accounted for or you're fired!",
|
||||
" return arr1;",
|
||||
"}",
|
||||
"",
|
||||
"// Example inventory lists",
|
||||
"var curInv = [",
|
||||
" [21, 'Bowling Ball'],",
|
||||
" [2, 'Dirty Sock'],",
|
||||
" [1, 'Hair Pin'],",
|
||||
" [5, 'Microphone']",
|
||||
"];",
|
||||
"",
|
||||
"var newInv = [",
|
||||
" [2, 'Hair Pin'],",
|
||||
" [3, 'Half-Eaten Apple'],",
|
||||
" [67, 'Bowling Ball'],",
|
||||
" [7, 'Toothpaste']",
|
||||
"];",
|
||||
"",
|
||||
"inventory(curInv, newInv);"
|
||||
],
|
||||
"tests": [
|
||||
"expect(inventory([[21, 'Bowling Ball'], [2, 'Dirty Sock'], [1, 'Hair Pin'], [5, 'Microphone']], [[2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [67, 'Bowling Ball'], [7, 'Toothpaste']])).to.be.a('array');",
|
||||
"assert.equal(inventory([[21, 'Bowling Ball'], [2, 'Dirty Sock'], [1, 'Hair Pin'], [5, 'Microphone']], [[2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [67, 'Bowling Ball'], [7, 'Toothpaste']]).length, 6);",
|
||||
@ -793,7 +1118,13 @@
|
||||
"Return the number of total permutations of the provided string that don't have repeated consecutive letters.",
|
||||
"For example, 'aab' should return 2 because it has 6 total permutations, but only 2 of them don't have the same letter (in this case 'a') repeating."
|
||||
],
|
||||
"challengeSeed": "function permAlone(str) {\n return str;\n}\n\npermAlone('aab');",
|
||||
"challengeSeed": [
|
||||
"function permAlone(str) {",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"permAlone('aab');"
|
||||
],
|
||||
"tests": [
|
||||
"expect(permAlone('aab')).to.be.a.number;",
|
||||
"expect(permAlone('aab')).to.equal(2);",
|
||||
@ -816,7 +1147,13 @@
|
||||
"Secondly, if the starting year is the current year, and the ending year can be inferred by the reader, the year should be omitted.",
|
||||
"Input date is formatted as YYYY-MM-DD"
|
||||
],
|
||||
"challengeSeed": "function friendly(str) {\n return str;\n}\n\nfriendly(['2015-07-01', '2015-07-04']);",
|
||||
"challengeSeed": [
|
||||
"function friendly(str) {",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"friendly(['2015-07-01', '2015-07-04']);"
|
||||
],
|
||||
"tests": [
|
||||
"assert.deepEqual(friendly(['2015-07-01', '2015-07-04']), ['July 1st','4th'], 'ending month should be omitted since it is already mentioned');",
|
||||
"assert.deepEqual(friendly(['2015-12-01', '2016-02-03']), ['December 1st','February 3rd'], 'one month apart can be inferred it is the next year');",
|
||||
|
1
seed_data/challenges.json
Normal file
1
seed_data/challenges.json
Normal file
@ -0,0 +1 @@
|
||||
["./challenges/prepwork.json", "./challenges/basics.json"]
|
176
seed_data/challenges/basejumps.json
Normal file
176
seed_data/challenges/basejumps.json
Normal file
@ -0,0 +1,176 @@
|
||||
{
|
||||
"name": "Basejumps",
|
||||
"order" : 0.010,
|
||||
"challenges": [
|
||||
{
|
||||
"_id": "bd7158d8c443eddfaeb5bcef",
|
||||
"name": "Get Set for Basejumps",
|
||||
"difficulty": 2.00,
|
||||
"challengeSeed": "126433451",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Get the MEAN stack running on Cloud 9, push your code to GitHub, and deploy it to Heroku.",
|
||||
"We'll build our Basejumps on Cloud 9, a powerful online code editor with a full Ubuntu Linux workspace, all running in the cloud.",
|
||||
"If you don't already have Cloud 9 account, create one now at <a href='http://c9.io' target='_blank'>http://c9.io</a>.",
|
||||
"Now let's get your development environment ready for a new Angular-Fullstack application provided by Yeoman.",
|
||||
"Open up <a href='http://c9.io' target='_blank'>http://c9.io</a> and sign in to your account.",
|
||||
"Click on Create New Workspace at the top right of the c9.io page, then click on the \"Create a new workspace\" popup that appears below it the button after you click on it.",
|
||||
"Give your workspace a name.",
|
||||
"Choose Node.js in the selection area below the name field.",
|
||||
"Click the Create button.",
|
||||
"Wait for the workspace to finish processing and select it on the left sidebar, below the Create New Workspace button.",
|
||||
"Click the \"Start Editing\" button.",
|
||||
"In the lower right hand corner you should see a terminal window. In this window use the following commands. You don't need to know what these mean at this point.",
|
||||
"Never run this command on your local machine. But in your Cloud 9 terminal window, run: <code>rm -rf * && echo \"export NODE_PATH=$NODE_PATH:/home/ubuntu/.nvm/v0.10.35/lib/node_modules\" >> ~/.bashrc && source ~/.bashrc && npm install -g yo grunt grunt-cli generator-angular-fullstack && yo angular-fullstack</code>",
|
||||
"Yeoman will prompt you to answer some questions. Answer them like this:",
|
||||
"What would you like to write scripts with? <span class='text-success'>JavaScript</span>",
|
||||
"What would you like to write markup with? <span class='text-success'>HTML</span>",
|
||||
"What would you like to write stylesheets with? <span class='text-success'>CSS</span>",
|
||||
"What Angular router would you like to use? <span class='text-success'>ngRoute</span>",
|
||||
"Would you like to include Bootstrap? <span class='text-success'>Yes</span>",
|
||||
"Would you like to include UI Bootstrap? <span class='text-success'>Yes</span>",
|
||||
"Would you like to use MongoDB with Mongoose for data modeling? <span class='text-success'>Yes</span>",
|
||||
"Would you scaffold out an authentication boilerplate? <span class='text-success'>Yes</span>",
|
||||
"Would you like to include additional oAuth strategies? <span class='text-success'>Twitter</span>",
|
||||
"Would you like to use socket.io? <span class='text-success'>No</span>",
|
||||
"May bower anonymously report usage statistics to improve the tool over time? (Y/n) <span class='text-success'>Y</span>",
|
||||
"You may get an error similar to <code> ERR! EEXIST, open ‘/home/ubuntu/.npm</code>. This is caused when Cloud9 runs out of memory and kills an install. If you get this, simply re-run this process with the command <code>yo angular-fullstack</code>. You will then be asked a few questions regarding the re-install. Answer them as follows:",
|
||||
"Existing .yo-rc configuration found, would you like to use it? (Y/n) <span class='text-success'>Y</span>",
|
||||
"Overwrite client/favicon.ico? (Ynaxdh) <span class='text-success'>Y</span>",
|
||||
"To finish the installation run the commands: <code>bower install && npm install</code>",
|
||||
"To start MongoDB, run the following commands in your terminal: <code>mkdir data && echo 'mongod --bind_ip=$IP --dbpath=data --nojournal --rest \"$@\"' > mongod && chmod a+x mongod && ./mongod</code>",
|
||||
"You will want to open up a new terminal to work from by clicking on the + icon and select New Terminal",
|
||||
"Start the application by running the following command in your new terminal window: <code>grunt serve</code>",
|
||||
"Wait for the following message to appear: <code>xdg-open: no method available for opening 'http://localhost:8080' </code>. Now you can open the internal Cloud9 browser. To launch the browser select Preview in the toolbar then select the dropdown option Preview Running Application.",
|
||||
"Turn the folder in which your application is running into a Git repository by running the following commands: <code>git init && git add . && git commit -am 'initial commit'</code>.",
|
||||
"Create a new Github repository by signing in to <a href='http://github.com' target='_blank'>http://github.com</a> and clicking on the + button next to your username in the upper-right hand side of your screen, then selecting \"New Repository\".",
|
||||
"Enter a project name, then click the \"Create Repository\" button.",
|
||||
"Find the \"...or push an existing repository from the command line\" section and click the Copy to Clipboard button beside it.",
|
||||
"Paste the commands from your clipboard into the Cloud9 terminal prompt. This will push your changes to your repository on Cloud 9 up to Github.",
|
||||
"Check back on your Github profile to verify the changes were successfully pushed up to Github.",
|
||||
"Now let's push your code to Heroku. If you don't already have a Heroku account, create one at <a href='http://heroku.com' target='_blank'>http://heroku.com</a>. You shouldn't be charged for anything, but you will need to add your credit card information to your Heroku before you will be able to use Heroku's free MongoLab add on.",
|
||||
"Before you publish to Heroku, you should free up as much memory as possible on Cloud9. In each of the Cloud9 terminal prompt tabs where MongoDB and Grunt are running, press the <code>control + c</code> hotkey to shut down these processes.",
|
||||
"Run the following command in a Cloud9 terminal prompt tab: <code>npm install grunt-contrib-imagemin --save-dev && npm install --save-dev && heroku login</code>. At this point, the terminal will prompt you to log in to Heroku from the command line.",
|
||||
"Now run <code>yo angular-fullstack:heroku</code>. You can choose a name for your Heroku project, or Heroku will create a random one for you. You can choose whether you want to deploy to servers the US or the EU.",
|
||||
"Set the config flag for your Heroku environment and add MongoLab for your MongoDB instance by running the following command: <code>cd ~/workspace/dist && heroku config:set NODE_ENV=production && heroku addons:add mongolab</code>.",
|
||||
"As you build your app, you should frequently commit changes to your codebase. Make sure you're in the <code>~/workspace</code> directory by running <code>cd ~/workspace</code>. Then you can this code to stage the changes to your changes and commit them: <code>git commit -am \"your commit message\"</code>. Note that you should replace \"your commit message\" with a short summary of the changes you made to your code, such as \"added a records controller and corresponding routes\".",
|
||||
"You can push these new commits to Github by running <code>git push origin master</code>, and to Heroku by running <code>grunt --force && grunt buildcontrol:heroku</code>.",
|
||||
"Now you're ready to move on to your first Basejump. Click the \"I've completed this challenge\" button and enter the URLs for both your Github repository and your live app running on Heroku. If you pair programmed with a friend, enter his or her Free Code Camp username as well so that you both get credit for completing it."
|
||||
],
|
||||
"challengeType": 4,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c443eddfaeb5bdef",
|
||||
"name": "Basejump: Build a Voting App",
|
||||
"difficulty": 2.01,
|
||||
"challengeSeed": "123488494",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a full stack JavaScript app that successfully reverse-engineers this: <a href='http://voteplex.herokuapp.com/' target='_blank'>http://voteplex.herokuapp.com/</a> and deploy it to Heroku.",
|
||||
"Note that for each Basejump, you should create a new GitHub repository and a new Heroku project. If you can't remember how to do this, revisit <a href='/challenges/get-set-for-basejumps'>http://freecodecamp.com/challenges/get-set-for-basejumps</a>.",
|
||||
"As you build your app, you should frequently commit changes to your codebase. You can do this by running <code>git commit -am \"your commit message\"</code>. Note that you should replace \"your commit message\" with a brief summary of the changes you made to your code.",
|
||||
"You can push these new commits to Github by running <code>git push origin master</code>, and to Heroku by running <code>grunt --force && grunt buildcontrol:heroku</code>.",
|
||||
"Here are the specific User Stories you should implement for this Basejump:",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can keep my polls and come back later to access them.",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can share my polls with my friends.",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can see the aggregate results of my polls.",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can delete polls that I decide I don't want anymore.",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can create a poll with any number of possible items.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As an unauthenticated user, I can see everyone's polls, but I can't vote on anything.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As an unauthenticated or authenticated user, I can see the results of polls in chart form. (This could be implemented using Chart.js or Google Charts.)",
|
||||
"<span class='text-info'>Bonus User Story:</span> As an authenticated user, if I don't like the options on a poll, I can create a new option.",
|
||||
"Once you've finished implementing these user stories, click the \"I've completed this challenge\" button and enter the URLs for both your Github repository and your live app running on Heroku. If you pair programmed with a friend, enter his or her Free Code Camp username as well so that you both get credit for completing it.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your Heroku project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 4,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c443eddfaeb5bdff",
|
||||
"name": "Basejump: Build a Nightlife Coordination App",
|
||||
"difficulty": 2.02,
|
||||
"challengeSeed": "123488494",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a full stack JavaScript app that successfully reverse-engineers this: <a href='http://sociallife.herokuapp.com/' target='_blank'>http://sociallife.herokuapp.com/</a> and deploy it to Heroku.",
|
||||
"Note that for each Basejump, you should create a new GitHub repository and a new Heroku project. If you can't remember how to do this, revisit <a href='/challenges/get-set-for-basejumps'>http://freecodecamp.com/challenges/get-set-for-basejumps</a>.",
|
||||
"As you build your app, you should frequently commit changes to your codebase. You can do this by running <code>git commit -am \"your commit message\"</code>. Note that you should replace \"your commit message\" with a brief summary of the changes you made to your code.",
|
||||
"You can push these new commits to Github by running <code>git push origin master</code>, and to Heroku by running <code>grunt --force && grunt buildcontrol:heroku</code>.",
|
||||
"Here are the specific User Stories you should implement for this Basejump:",
|
||||
"<span class='text-info'>User Story:</span> As an unauthenticated user, I can view all bars in my area.",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can add myself to a bar to indicate I am going there tonight.",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can remove myself from a bar if I no longer want to go there.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As an unauthenticated user, when I login I should not have to search again.",
|
||||
"Once you've finished implementing these user stories, click the \"I've completed this challenge\" button and enter the URLs for both your Github repository and your live app running on Heroku. If you pair programmed with a friend, enter his or her Free Code Camp username as well so that you both get credit for completing it.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your Heroku project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 4,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c443eddfaeb5bd0e",
|
||||
"name": "Basejump: Chart the Stock Market",
|
||||
"difficulty": 2.03,
|
||||
"challengeSeed": "123488494",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a full stack JavaScript app that successfully reverse-engineers this: <a href='http://stockjump.herokuapp.com/' target='_blank'>http://stockjump.herokuapp.com/</a> and deploy it to Heroku.",
|
||||
"Note that for each Basejump, you should create a new GitHub repository and a new Heroku project. If you can't remember how to do this, revisit <a href='/challenges/get-set-for-basejumps'>http://freecodecamp.com/challenges/get-set-for-basejumps</a>.",
|
||||
"As you build your app, you should frequently commit changes to your codebase. You can do this by running <code>git commit -am \"your commit message\"</code>. Note that you should replace \"your commit message\" with a brief summary of the changes you made to your code.",
|
||||
"You can push these new commits to Github by running <code>git push origin master</code>, and to Heroku by running <code>grunt --force && grunt buildcontrol:heroku</code>.",
|
||||
"Here are the specific User Stories you should implement for this Basejump:",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can view a graph displaying the recent trend lines for each added stock.",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can add new stocks by their symbol name.",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can remove stocks.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, I can see changes in real-time when any other user adds or removes a stock.",
|
||||
"Once you've finished implementing these user stories, click the \"I've completed this challenge\" button and enter the URLs for both your Github repository and your live app running on Heroku. If you pair programmed with a friend, enter his or her Free Code Camp username as well so that you both get credit for completing it.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your Heroku project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 4,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c443eddfaeb5bd0f",
|
||||
"name": "Basejump: Manage a Book Trading Club",
|
||||
"difficulty": 2.04,
|
||||
"challengeSeed": "123488494",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a full stack JavaScript app that successfully reverse-engineers this: <a href='http://bookoutpost.herokuapp.com/' target='_blank'>http://bookoutpost.herokuapp.com/</a> and deploy it to Heroku.",
|
||||
"Note that for each Basejump, you should create a new GitHub repository and a new Heroku project. If you can't remember how to do this, revisit <a href='/challenges/get-set-for-basejumps'>http://freecodecamp.com/challenges/get-set-for-basejumps</a>.",
|
||||
"As you build your app, you should frequently commit changes to your codebase. You can do this by running <code>git commit -am \"your commit message\"</code>. Note that you should replace \"your commit message\" with a brief summary of the changes you made to your code.",
|
||||
"You can push these new commits to Github by running <code>git push origin master</code>, and to Heroku by running <code>grunt --force && grunt buildcontrol:heroku</code>.",
|
||||
"Here are the specific User Stories you should implement for this Basejump:",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can view all books posted by every user.",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can add a new book.",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can update my settings to store my full name, city, and state.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As an authenticated user, I can propose a trade and wait for the other user to accept the trade.",
|
||||
"Once you've finished implementing these user stories, click the \"I've completed this challenge\" button and enter the URLs for both your Github repository and your live app running on Heroku. If you pair programmed with a friend, enter his or her Free Code Camp username as well so that you both get credit for completing it.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your Heroku project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 4,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c443eddfaeb5bdee",
|
||||
"name": "Basejump: Build a Pinterest Clone",
|
||||
"difficulty": 2.05,
|
||||
"challengeSeed": "123488494",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a full stack JavaScript app that successfully reverse-engineers this: <a href='http://linkterest.herokuapp.com/' target='_blank'>http://linkterest.herokuapp.com/</a> and deploy it to Heroku.",
|
||||
"Note that for each Basejump, you should create a new GitHub repository and a new Heroku project. If you can't remember how to do this, revisit <a href='/challenges/get-set-for-basejumps'>http://freecodecamp.com/challenges/get-set-for-basejumps</a>.",
|
||||
"As you build your app, you should frequently commit changes to your codebase. You can do this by running <code>git commit -am \"your commit message\"</code>. Note that you should replace \"your commit message\" with a brief summary of the changes you made to your code.",
|
||||
"You can push these new commits to Github by running <code>git push origin master</code>, and to Heroku by running <code>grunt --force && grunt buildcontrol:heroku</code>.",
|
||||
"Here are the specific User Stories you should implement for this Basejump:",
|
||||
"<span class='text-info'>User Story:</span> As an unauthenticated user, I can login with Twitter.",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can link to images.",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can delete images that I've linked to.",
|
||||
"<span class='text-info'>User Story:</span> As an authenticated user, I can see a Pinterest-style wall of all the images I've linked to.",
|
||||
"<span class='text-info'>User Story:</span> As an unauthenticated user, I can browse other users' walls of images.",
|
||||
"<span class='text-info'>User Story:</span> As an unauthenticated user, I can see everyone's polls, but not be able to vote.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As an authenticated user, if I upload an image that is broken, it will be replaced by a placeholder image. (can use jQuery broken image detection)",
|
||||
"<span class='text-info'>Hint:</span> <a href='http://masonry.desandro.com/' target='_blank'>Masonry.js</a> is a library that allows for Pinterest-style image grids.",
|
||||
"Once you've finished implementing these user stories, click the \"I've completed this challenge\" button and enter the URLs for both your Github repository and your live app running on Heroku. If you pair programmed with a friend, enter his or her Free Code Camp username as well so that you both get credit for completing it.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your Heroku project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 4,
|
||||
"tests": []
|
||||
}
|
||||
]
|
||||
}
|
1663
seed_data/challenges/basic-html5-and-css.json
Normal file
1663
seed_data/challenges/basic-html5-and-css.json
Normal file
File diff suppressed because it is too large
Load Diff
167
seed_data/challenges/basic-javascript.json
Normal file
167
seed_data/challenges/basic-javascript.json
Normal file
@ -0,0 +1,167 @@
|
||||
{
|
||||
"name": "Basic JavaScript",
|
||||
"order" : 0.006,
|
||||
"challenges": [
|
||||
{
|
||||
"_id": "bd7129d8c441eddfaeb5bdef",
|
||||
"name": "Build an Adventure Game",
|
||||
"difficulty": 0.24,
|
||||
"challengeSeed": "114604814",
|
||||
"description": [
|
||||
"Now that you understand some Computer Science fundamentals, let's focus on programming JavaScript!",
|
||||
"We're going to work through Codecademy's famous interactive JavaScript course.",
|
||||
"This course will teach us some JavaScript fundamentals while guiding us through the process of building interesting web apps, all within Codecademy's learner-friendly environment!",
|
||||
"Go to <a href='http://www.codecademy.com/courses/getting-started-v2/0/1' target='_blank'>http://www.codecademy.com/courses/getting-started-v2/0/1</a> and complete the section.",
|
||||
"Be sure to also complete this section: <a href='http://www.codecademy.com/courses/javascript-beginner-en-x9DnD/0/1' target='_blank'>http://www.codecademy.com/courses/javascript-beginner-en-x9DnD/0/1</a>."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7130d8c441eddfaeb5bdef",
|
||||
"name": "Build Rock Paper Scissors",
|
||||
"difficulty": 0.25,
|
||||
"challengeSeed": "114604815",
|
||||
"description": [
|
||||
"Now we'll learn how JavaScript functions work, and use them to build a simple Rock Paper Scissors game.",
|
||||
"Go to <a href='http://www.codecademy.com/courses/javascript-beginner-en-6LzGd/0/1' target='_blank'>http://www.codecademy.com/courses/javascript-beginner-en-6LzGd/0/1</a> and complete the section.",
|
||||
"Be sure to also complete this section: <a href='http://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/0/1' target='_blank'>http://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/0/1</a>."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7131d8c441eddfaeb5bdef",
|
||||
"name": "Learn JavaScript For Loops",
|
||||
"difficulty": 0.26,
|
||||
"challengeSeed": "114614220",
|
||||
"description": [
|
||||
"Let's learn more about the loops that make virtually all programs possible - the \"For Loop\" and \"While Loop\". First, we'll learn the For Loop.",
|
||||
"Go to <a href='http://www.codecademy.com/courses/javascript-beginner-en-NhsaT/0/1' target='_blank'>http://www.codecademy.com/courses/javascript-beginner-en-NhsaT/0/1web</a> and complete both the both For and While loop section.",
|
||||
"Be sure to also complete this section: <a href='http://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/1' target='_blank'>http://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/1</a>."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7132d8c441eddfaeb5bdef",
|
||||
"name": "Learn JavaScript While Loops",
|
||||
"difficulty": 0.27,
|
||||
"challengeSeed": "114612889",
|
||||
"description": [
|
||||
"Go to <a href='http://www.codecademy.com/courses/javascript-beginner-en-ASGIv/0/1' target='_blank'>http://www.codecademy.com/courses/javascript-beginner-en-ASGIv/0/1</a> and complete the section.",
|
||||
"Be sure to also complete this section: <a href='http://www.codecademy.com/courses/javascript-beginner-en-mrTNH-6VIZ9/0/1' target='_blank'>http://www.codecademy.com/courses/javascript-beginner-en-mrTNH-6VIZ9/0/1</a>."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7133d8c441eddfaeb5bdef",
|
||||
"name": "Learn Control Flow",
|
||||
"difficulty": 0.28,
|
||||
"challengeSeed": "114612888",
|
||||
"description": [
|
||||
"Much of human reasoning can be broken down into what we call Boolean Logic. Lucky for us, computers can think the same way! Let's learn how to instruct our computers by writing \"If Statements\" and \"Else Statements\".",
|
||||
"We'll also learn some advanced \"Control Flow\" principals, such as ways we can exit loops early.",
|
||||
"Go to <a href='http://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/1' target='_blank'>http://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/1</a> and complete the section.",
|
||||
"Be sure to also complete this section: <a href='http://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/1' target='_blank'>http://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/1</a>."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7134d8c441eddfaeb5bdef",
|
||||
"name": "Build a Contact List",
|
||||
"difficulty": 0.29,
|
||||
"challengeSeed": "114612887",
|
||||
"description": [
|
||||
"Up to this point, you've been working mostly with strings and numbers. Now we're going to learn more complicated data structures, like \"Arrays\" and \"Objects\".",
|
||||
"Go to <a href='http://www.codecademy.com/courses/javascript-beginner-en-9Sgpi/0/1' target='_blank'>http://www.codecademy.com/courses/javascript-beginner-en-9Sgpi/0/1</a> and complete the section.",
|
||||
"Be sure to also complete this section: <a href='http://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/1' target='_blank'>http://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/1</a>."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7135d8c441eddfaeb5bdef",
|
||||
"name": "Build an Address Book",
|
||||
"difficulty": 0.30,
|
||||
"challengeSeed": "114612885",
|
||||
"description": [
|
||||
"Let's learn more about objects.",
|
||||
"Go to <a href='http://www.codecademy.com/courses/spencer-sandbox/0/1' target='_blank'>http://www.codecademy.com/courses/spencer-sandbox/0/1</a> and complete the section.",
|
||||
"Be sure to also complete this section: <a href='http://www.codecademy.com/courses/building-an-address-book/0/1?curriculum_id=506324b3a7dffd00020bf661' target='_blank'>http://www.codecademy.com/courses/building-an-address-book/0/1?curriculum_id=506324b3a7dffd00020bf661</a>."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7136d8c441eddfaeb5bdef",
|
||||
"name": "Build a Cash Register",
|
||||
"difficulty": 0.31,
|
||||
"challengeSeed": "114612882",
|
||||
"description": [
|
||||
"In this final Codecademy section, we'll learn even more about JavaScript objects.",
|
||||
"Go to <a href='http://www.codecademy.com/courses/objects-ii/0/1' target='_blank'>http://www.codecademy.com/courses/objects-ii/0/1</a> and complete this section.",
|
||||
"Be sure to also complete the final section: <a href='http://www.codecademy.com/courses/close-the-super-makert/0/1' target='_blank'>http://www.codecademy.com/courses/close-the-super-makert/0/1</a>."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7118d8c441eddfaeb5bdef",
|
||||
"name": "Discover Chrome's DevTools",
|
||||
"difficulty": 0.32,
|
||||
"challengeSeed": "110752743",
|
||||
"description": [
|
||||
"It's time to learn the most powerful tool your browser has - the Development Tools!",
|
||||
"If you aren't already using Chrome, you'll want to download it here: <a href='http://www.google.com/chrome/' target='_blank'>http://www.google.com/chrome/</a>. While it's true that Firefox has a tool called Firebug that is very similar to Chrome's DevTools, we will use Chrome for this challenge.",
|
||||
"Note that this course, jointly produced by Google and Code School, is technologically impressive, but occasionally buggy. If you encounter a bug, just ignore it and keep going.",
|
||||
"Go to <a href='http://discover-devtools.codeschool.com' target='_blank'>http://discover-devtools.codeschool.com</a> and complete this short course."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7138d8c441eddfaeb5bdef",
|
||||
"name": "Learn Regular Expressions",
|
||||
"difficulty": 0.33,
|
||||
"challengeSeed": "112547802",
|
||||
"description": [
|
||||
"You can use a Regular Expression, or \"Regex\", to select specific types of characters in text.",
|
||||
"Check out <a href='http://www.regexr.com' target='_blank'>http://www.regexr.com</a>. It's a Regular Expression Sandbox.",
|
||||
"Now go to <a href='http://www.regexone.com' target='_blank'>http://www.regexone.com</a> and complete the tutorial and exercises 1 - 6.",
|
||||
"Note that you can click \"continue\" to move on to the next step as soon as all the tasks have green check marks beside them. You can often do this just by using the wildcard \"dot\" operator, but try to use the techniques that each lesson recommends."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7139d8c441eddfaeb5bdef",
|
||||
"name": "Pair Program on Bonfires",
|
||||
"difficulty": 0.44,
|
||||
"challengeSeed": "119657641",
|
||||
"description": [
|
||||
"OK, we're finally ready to start pair programming!",
|
||||
"Pair Programming is where two people code together on the same computer. It is an efficient way to collaborate, and widely practiced at software companies. Pair Programming is one of the core concepts of \"Agile\" Software Development, which you will hear more about later.",
|
||||
"Many people use Skype or Google Hangouts to pair program, but if you talk with professional software engineers, they will tell you that it's not really pair programming unless both people have the ability to use the keyboard and mouse.",
|
||||
"The most popular tool for pair programming is Screen Hero. You can download Screen Hero for <a href='http://links.screenhero.com/e/c/eyJlbWFpbF9pZCI6Ik1qQTNNem9XQkNJQ1pBQUNjd0FYQVZrVEdnRkxNamtfX0JWZEdGVEpSZkVCWlRwbFpXRTBNamM0WVMxaE56SmlMVEV4WlRRdE9HUXpZUzFpWXpVNE1HRTJNalkxTldNNk1UUTJNVEEyQUE9PSIsInBvc2l0aW9uIjowLCJocmVmIjoiaHR0cDovL2RsLnNjcmVlbmhlcm8uY29tL3NtYXJ0ZG93bmxvYWQvZklYQU1UUUJBTEtQQkhQTC9TY3JlZW5oZXJvLnppcD9zb3VyY2U9d2ViIn0=' target='_blank'>Mac</a> or <a href='http://links.screenhero.com/e/c/eyJlbWFpbF9pZCI6Ik1qQTNNem9XQkNJQ1pBQUNjd0FYQVZrVEdnRkxNamtfX0JWZEdGVEpSZkVCWlRwbFpXRTBNamM0WVMxaE56SmlMVEV4WlRRdE9HUXpZUzFpWXpVNE1HRTJNalkxTldNNk1UUTJNVEEyQUE9PSIsInBvc2l0aW9uIjoxLCJocmVmIjoiaHR0cDovL2RsLnNjcmVlbmhlcm8uY29tL3NtYXJ0ZG93bmxvYWQvZklYQU1UUUJBTEtQQkhQTC9TY3JlZW5oZXJvLXNldHVwLmV4ZSJ9' target='_blank'>Windows</a>. Create your new user account from within the app.",
|
||||
"We have a special chat room for people ready to pair program. Go to our Slack chatroom and navigate to the #letspair channel and type \"Hello Pair Programmers!\"",
|
||||
"If someone is available, they will be your \"pair\" - the person you pair programming with.",
|
||||
"If no one gets back to you in the first few minutes, don't worry. There will be lots of opportunities to pair program in the future.",
|
||||
"If someone does get back to you, private message them and ask for the email address they used to register Screen Hero.",
|
||||
"Add them as a new contact in Screen Hero, then click the monitor-looking button to attempt to share your screen with them.",
|
||||
"Once the Screen Hero session starts, your screen's margins will glow orange. You are now sharing your screen.",
|
||||
"Your pair will have their own cursor, and will be able to type text on his or her and keyboard.",
|
||||
"Now it's time to tackle our Bonfires.",
|
||||
"Go to <a href='http://freecodecamp.com/bonfires' target='_blank'>http://freecodecamp.com/bonfires</a> and start working through our Bonfire challenges.",
|
||||
"Once you you finish pair programming, end the session in Screen Hero session.",
|
||||
"Congratulations! You have completed your first pair programming session.",
|
||||
"Pair program as much as possible with different campers until you've completed all the Bonfire challenges. This is a big time investment, but the JavaScript practice you get will be well worth it!",
|
||||
"Mark this challenge as complete and move on to the Bonfires."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
}
|
||||
]
|
||||
}
|
1208
seed_data/challenges/bonfires.json
Normal file
1208
seed_data/challenges/bonfires.json
Normal file
File diff suppressed because it is too large
Load Diff
1575
seed_data/challenges/bootstrap.json
Normal file
1575
seed_data/challenges/bootstrap.json
Normal file
File diff suppressed because it is too large
Load Diff
86
seed_data/challenges/computer-science.json
Normal file
86
seed_data/challenges/computer-science.json
Normal file
@ -0,0 +1,86 @@
|
||||
{
|
||||
"name": "Computer Science",
|
||||
"order" : 0.005,
|
||||
"challenges": [
|
||||
{
|
||||
"_id": "bd7123d8c441eddfaeb5bdef",
|
||||
"name": "Learn Basic Computer Science",
|
||||
"difficulty": 0.90,
|
||||
"challengeSeed": "114628241",
|
||||
"description": [
|
||||
"Stanford has an excellent free online Computer Science curriculum. This interactive course uses a modified version of JavaScript. It will cover a lot of concepts quickly.",
|
||||
"Note that Harvard also has an excellent introduction to computer science course called CS50, but it takes more than 100 hours to complete, and doesn't use JavaScript.",
|
||||
"Despite being completely self-paced, Stanford's CS101 course is broken up into weeks. Each of the following challenges will address one of those weeks.",
|
||||
"Go to <a href='https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z54/z1/' target='_blank'>https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z54/z1/</a> and complete the first week's course work."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd8124d8c441eddfaeb5bdef",
|
||||
"name": "Learn Loops",
|
||||
"difficulty": 0.19,
|
||||
"challengeSeed": "114597348",
|
||||
"description": [
|
||||
"Now let's tackle week 2 of Stanford's Intro to Computer Science course.",
|
||||
"This will introduce us to loops, a fundamental feature of every programming language.",
|
||||
"Go to <a href='https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z100/a7a70ce6e4724c58862ee6007284face/' target='_blank'>https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z100/a7a70ce6e4724c58862ee6007284face/</a> and complete Week 2."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd8125d8c441eddfaeb5bdef",
|
||||
"name": "Learn Computer Hardware",
|
||||
"difficulty": 0.20,
|
||||
"challengeSeed": "114597347",
|
||||
"description": [
|
||||
"Week 3 of Stanford's Intro to Computer Science covers computer hardware and explains Moore's law of exponential growth in the price-performance of processors.",
|
||||
"This challenge will also give you an understanding of how bits and bytes work.",
|
||||
"Go to <a href='https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z143/z101/' target='_blank'>https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z143/z101/</a> and complete Week 3."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd8126d8c441eddfaeb5bdef",
|
||||
"name": "Learn Computer Networking",
|
||||
"difficulty": 0.21,
|
||||
"challengeSeed": "114604811",
|
||||
"description": [
|
||||
"Now that you've learned about computer hardware, it's time to learn about the software that runs on top of it.",
|
||||
"Particularly important, you will learn about networks and TCP/IP - the protocol that powers the internet.",
|
||||
"Go to <a href='https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z187/z144/' target='_blank'>https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z187/z144/</a> and complete Week 4."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd8127d8c441eddfaeb5bdef",
|
||||
"name": "Learn Boolean Logic",
|
||||
"difficulty": 0.22,
|
||||
"challengeSeed": "114604812",
|
||||
"description": [
|
||||
"Now we'll do some more table exercises and learn boolean logic.",
|
||||
"We'll also learn the difference between digital data and analog data.",
|
||||
"Go to <a href='https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z208/z188/' target='_blank'>https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z208/z188/</a> and complete Week 5."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd8128d8c441eddfaeb5bdef",
|
||||
"name": "Learn Computer Security",
|
||||
"difficulty": 0.23,
|
||||
"challengeSeed": "114604813",
|
||||
"description": [
|
||||
"We're almost done with Stanford's Introduction to Computer Science course!",
|
||||
"We'll learn about one of the most important inventions of the 20th century - spreadsheets.",
|
||||
"We'll also learn about Computer Security and some of the more common vulnerabilities software systems have.",
|
||||
"Go to <a href='https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z229/z213/' target='_blank'>https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z229/z213/</a> and complete Week 6, the final week of the course."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
}
|
||||
]
|
||||
}
|
155
seed_data/challenges/full-stack-javascript.json
Normal file
155
seed_data/challenges/full-stack-javascript.json
Normal file
@ -0,0 +1,155 @@
|
||||
{
|
||||
"name": "Full Stack JavaScript",
|
||||
"order" : 0.008,
|
||||
"challenges": [
|
||||
{
|
||||
"_id": "bd7154d8c441eddfaeb5bdef",
|
||||
"name": "Get Started with Angular.js",
|
||||
"difficulty": 0.34,
|
||||
"challengeSeed": "114684726",
|
||||
"description": [
|
||||
"Code School has a short, free Angular.js course. This will give us a quick tour of Angular.js's mechanics and features.",
|
||||
"In this course, we'll build a virtual shop entirely in Angular.js.",
|
||||
"Go to <a href='http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/1/section/1/video/1' target='_blank'>http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/1/section/1/video/1</a> and complete the section."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7155d8c441eddfaeb5bdef",
|
||||
"name": "Apply Angular.js Directives",
|
||||
"difficulty": 0.35,
|
||||
"challengeSeed": "114684727",
|
||||
"description": [
|
||||
"Directives serve as markers in your HTML. When Angular.js compiles your HTML, it will can alter the behavior of DOM elements based on the directives you've used.",
|
||||
"Let's learn how these powerful directives work, and how to use them to make your web apps more dynamic",
|
||||
"Go to <a href='http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/2/section/1/video/1' target='_blank'>http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/2/section/1/video/1</a> and complete the section."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7156d8c441eddfaeb5bdef",
|
||||
"name": "Power Forms with Angular.js",
|
||||
"difficulty": 0.36,
|
||||
"challengeSeed": "114684729",
|
||||
"description": [
|
||||
"One area where Angular.js really shines is its powerful web forms.",
|
||||
"Learn how to create reactive Angular.js forms, including real-time form validation.",
|
||||
"Go to <a href='http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/3/section/1/video/1' target='_blank'>http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/3/section/1/video/1</a> and complete the section."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7157d8c441eddfaeb5bdef",
|
||||
"name": "Customize Angular.js Directives",
|
||||
"difficulty": 0.37,
|
||||
"challengeSeed": "114685062",
|
||||
"description": [
|
||||
"Now we'll learn how to modify existing Angular.js directives, and even build directives of your own.",
|
||||
"Go to <a href='http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/4/section/1/video/1' target='_blank'>http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/4/section/1/video/1</a> and complete the section."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c441eddfaeb5bdef",
|
||||
"name": "Create Angular.js Services",
|
||||
"difficulty": 0.38,
|
||||
"challengeSeed": "114685060",
|
||||
"description": [
|
||||
"Services are functions that you can use and reuse throughout your Angular.js app to get things done.",
|
||||
"We'll learn how to use services in this final Code School Angular.js challenge.",
|
||||
"Go to <a href='http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/5/section/1/video/1' target='_blank'>http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/5/section/1/video/1</a> and complete the section."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7153d8c441eddfaeb5bd0f",
|
||||
"name": "Manage Packages with NPM",
|
||||
"difficulty": 0.39,
|
||||
"challengeSeed": "126433450",
|
||||
"description": [
|
||||
"We'll build this Waypoint on Cloud 9, a powerful online code editor with a full Ubuntu Linux workspace, all running in the cloud.",
|
||||
"If you don't already have Cloud 9 account, create one now at <a href='http://c9.io' target='_blank'>http://c9.io</a>.",
|
||||
"Open up <a href='http://c9.io' target='_blank'>http://c9.io</a> and sign in to your account.",
|
||||
"Click on Create New Workspace at the top right of the c9.io page, then click on the \"Create a new workspace\" popup that appears below it the button after you click on it.",
|
||||
"Give your workspace a name.",
|
||||
"Choose Node.js in the selection area below the name field",
|
||||
"Click the Create button",
|
||||
"Wait for the workspace to finish processing and select it on the left sidebar, below the Create New Workspace button",
|
||||
"Click the \"Start Editing\" button.",
|
||||
"In the lower right hand corner you should see a terminal window. In this window use the following commands. You don't need to know what these mean at this point.",
|
||||
"Run this command: <code>sudo npm install how-to-npm -g</code>",
|
||||
"Now start this tutorial by running <code>how-to-npm</code>",
|
||||
"Note that you can resize the c9.io's windows by dragging their borders.",
|
||||
"Follow the directions and work through all of the the tutorial's steps before moving on."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7153d8c441eddfaeb5bdff",
|
||||
"name": "Start a Node.js Server",
|
||||
"difficulty": 0.40,
|
||||
"challengeSeed": "126411561",
|
||||
"description": [
|
||||
"We'll build this Waypoint on Cloud 9, a powerful online code editor with a full Ubuntu Linux workspace, all running in the cloud.",
|
||||
"If you don't already have Cloud 9 account, create one now at <a href='http://c9.io' target='_blank'>http://c9.io</a>.",
|
||||
"Open up <a href='http://c9.io' target='_blank'>http://c9.io</a> and sign in to your account.",
|
||||
"Click on Create New Workspace at the top right of the c9.io page, then click on the \"Create a new workspace\" popup that appears below it the button after you click on it.",
|
||||
"Give your workspace a name.",
|
||||
"Choose Node.js in the selection area below the name field",
|
||||
"Click the Create button",
|
||||
"Wait for the workspace to finish processing and select it on the left sidebar, below the Create New Workspace button",
|
||||
"Click the \"Start Editing\" button.",
|
||||
"In the lower right hand corner you should see a terminal window. In this window use the following commands. You don't need to know what these mean at this point.",
|
||||
"Run this command: <code>sudo npm install learnyounode -g</code>",
|
||||
"Now start this tutorial by running <code>learnyounode</code>",
|
||||
"Note that you can resize the c9.io's windows by dragging their borders.",
|
||||
"Follow the directions and work through all of the the tutorial's steps before moving on."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7153d8c441eddfaeb5bd1f",
|
||||
"name": "Build Web Apps with Express.js",
|
||||
"difficulty": 0.41,
|
||||
"challengeSeed": "126411559",
|
||||
"description": [
|
||||
"We'll build this Waypoint on Cloud 9, a powerful online code editor with a full Ubuntu Linux workspace, all running in the cloud.",
|
||||
"If you don't already have Cloud 9 account, create one now at <a href='http://c9.io' target='_blank'>http://c9.io</a>.",
|
||||
"Open up <a href='http://c9.io' target='_blank'>http://c9.io</a> and sign in to your account.",
|
||||
"Click on Create New Workspace at the top right of the c9.io page, then click on the \"Create a new workspace\" popup that appears below it the button after you click on it.",
|
||||
"Give your workspace a name.",
|
||||
"Choose Node.js in the selection area below the name field",
|
||||
"Click the Create button",
|
||||
"Wait for the workspace to finish processing and select it on the left sidebar, below the Create New Workspace button",
|
||||
"Click the \"Start Editing\" button.",
|
||||
"In the lower right hand corner you should see a terminal window. In this window use the following commands. You don't need to know what these mean at this point.",
|
||||
"Run this command: <code>git clone http://github.com/reddock/fcc_express && chmod 744 fcc_express/setup.sh && fcc_express/setup.sh && source ~/.profile</code>",
|
||||
"Now start this tutorial by running <code>expressworks</code>",
|
||||
"Note that you can resize the c9.io's windows by dragging their borders.",
|
||||
"Follow the directions and work through all of the the tutorial's steps before moving on."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7140d8c441eddfaeb5bdef",
|
||||
"name": "Manage Source Code with Git",
|
||||
"difficulty": 0.43,
|
||||
"challengeSeed": "114635309",
|
||||
"description": [
|
||||
"Version Control Systems like Git ensure that, no matter how you experiment with your code, you can always roll back your app to a stable previous state.",
|
||||
"Git is also a great way to share and contribute to open source software.",
|
||||
"Go to <a href='https://www.codeschool.com/courses/try-git' target='_blank'>https://www.codeschool.com/courses/try-git</a> and complete this short interactive course."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
}
|
||||
]
|
||||
}
|
146
seed_data/challenges/getting-set-for-free-code-camp.json
Normal file
146
seed_data/challenges/getting-set-for-free-code-camp.json
Normal file
@ -0,0 +1,146 @@
|
||||
{
|
||||
"name": "Getting Set for Free Code Camp",
|
||||
"order" : 0.001,
|
||||
"challenges": [
|
||||
{
|
||||
"_id": "bd7124d8c441eddfaeb5bdef",
|
||||
"name": "Learn how Free Code Camp Works",
|
||||
"difficulty": 0.001,
|
||||
"challengeSeed": "125407438",
|
||||
"description": [
|
||||
"Watch this 1-minute video, or simply read this summary:",
|
||||
"Welcome to Free Code Camp. We're a community of busy people learning to code by building projects for nonprofits.",
|
||||
"We built this community because learning to code is hard. But anyone who can stay motivated can learn to code. And to stay motivated, you just need to: <ol><li>make friends with people who code</li><li>code a little every day</li><ol>",
|
||||
"All our challenges are <ol><li>free</li><li>self-paced</li><li>browser-based</li></ol>",
|
||||
"We'll spend <ol><li>200 hours learning tools like HTML, CSS, JavaScript, Node.js and databases</li><li>600 hours building practice projects</li><li>800 hours building full stack solutions for nonprofits</li></ol>",
|
||||
"By the end, we'll <ol><li>be good at coding</li><li>have the portfolio of apps with happy users to prove it</li></ol>",
|
||||
"Once you make it through Free Code Camp, you will be able to get a coding job. There are far more job openings out there than there are qualified coders to fill them.",
|
||||
"Now it's time to join our chat room. Click the \"I've completed this challenge\" button to move on to your next challenge."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7125d8c441eddfaeb5bd0f",
|
||||
"name": "Join Our Chat Room",
|
||||
"difficulty": 0.002,
|
||||
"challengeSeed": "124555254",
|
||||
"description": [
|
||||
"Now we're going to join the Free Code Camp chat room. You can come here any time of day to hang out, ask questions, or find another camper to pair program with.",
|
||||
"Make sure your Free Code Camp account includes your email address. Please note that the email address you use will be invisible to the public, but Slack will make it visible to other campers in our slack chat rooms. You can do this here: <a href='/account' target='_blank'>http://freecodecamp.com/account</a>.",
|
||||
"Click this link, which will email you an invite to Free Code Camp's Slack chat rooms: <a href='/api/slack' target='_blank'>http://freecodecamp.com/api/slack</a>.",
|
||||
"Now check your email and click the link in the email from Slack.",
|
||||
"Complete the sign up process, then update your biographical information and upload an image. A picture of your face works best. This is how people will see you in our chat rooms, so put your best foot forward.",
|
||||
"Now enter the General chat room and introduce yourself to our chat room by typing: \"Hello world!\".",
|
||||
"Tell your fellow campers how you found Free Code Camp. Also tell us why you want to learn to code.",
|
||||
"Keep the chat room open while you work through the other challenges. That way you ask for help if you get stuck on a challenge. You can also socialize when you feel like taking a break.",
|
||||
"You can also access this chat room by clicking the \"Chat\" button in the upper right hand corner.",
|
||||
"In order to keep our community a friendly and positive place to learn to code, please read and follow our Code of Conduct: <a href='/field-guide/what-is-the-free-code-camp-code-of-conduct?' target='_blank'>http://freecodecamp.com/field-guide/what-is-the-free-code-camp-code-of-conduct?</a>"
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7125d8c441eddfaeb5bdff",
|
||||
"name": "Preview our Challenge Map",
|
||||
"difficulty": 0.003,
|
||||
"challengeSeed": "125407437",
|
||||
"description": [
|
||||
"Before you start learning how to code, we'd like to introduce you to a few things.",
|
||||
"Let's look at our Challenge Map. Click on the \"Map\" button in the upper right hand corner. This map shows all the challenges that will teach you how to code.",
|
||||
"You should complete all these challenges in order.",
|
||||
"Once you finish these Waypoint challenges, you'll move on to Bonfires (algorithm practice), then Ziplines (front end development practice) and finally Basejumps (full stack development practice). After that, you'll start building projects for nonprofits.",
|
||||
"This challenge map is just for your reference. When you return to FreeCodeCamp.com, we'll automatically redirect you to the next challenge that you should be doing."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7125d8c441eddfaeb5bd1f",
|
||||
"name": "Browse our Field Guide",
|
||||
"difficulty": 0.004,
|
||||
"challengeSeed": "125407435",
|
||||
"description": [
|
||||
"Free Code Camp has an up-to-date field guide that will answer your many questions.",
|
||||
"Click the \"Field Guide\" button in the upper right hand corner.",
|
||||
"You can browse the field guide at your convenience. Most of its articles take less than 1 minute to read.",
|
||||
"When you click the Field Guide button, it will always take you back to whichever article you were last reading.",
|
||||
"Read a few field guide articles, then move on to your next challenge."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7125d8c441eddfaeb5bd2f",
|
||||
"name": "Customize your Portfolio Page",
|
||||
"difficulty": 0.005,
|
||||
"challengeSeed": "125407433",
|
||||
"description": [
|
||||
"You and all your fellow campers have portfolio pages.",
|
||||
"To see your portfolio page, click your picture in the upper right hand corner.",
|
||||
"Your portfolio page will automatically show off your progress through Free Code Camp.",
|
||||
"Click the \"Update my portfolio page or manage my account\" button",
|
||||
"You can link to your Github, Twitter and LinkedIn accounts. If you've already built some websites, you can link to them here as well.",
|
||||
"Be sure to click the \"Update my Bio\" or \"Update my Social Links\" button to save this new information to your portfolio page.",
|
||||
"Once you're happy with your portfolio page, you can move on to your next challenge."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7126d8c441eddfaeb5bd3f",
|
||||
"name": "Try Camper News",
|
||||
"difficulty": 0.006,
|
||||
"challengeSeed": "124553410",
|
||||
"description": [
|
||||
"Camper News is the best place for our campers to share and discuss helpful links.",
|
||||
"Click \"News\" in the upper right hand corner.",
|
||||
"You'll see a variety of links that have been submitted. Click on the \"Discuss\" button under one of them.",
|
||||
"You can upvote links. This will push the link up the rankings of hot links.",
|
||||
"You an also comment on a link. If someone responds to your comment, you'll get an email notification so you can come back and respond to them.",
|
||||
"You can also submit links. You can modify the link's headline and also leave an initial comment about the link.",
|
||||
"You can view the portfolio pages of any camper who has posted links or comments on Camper News. Just click on their photo.",
|
||||
"When you submit a link, you'll get a point. You will also get a point each time someone upvotes your link.",
|
||||
"Now that you've learned how to use Camper News, let's move on to your next challenge."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7126d8c441eddfaeb5bd3e",
|
||||
"name": "Meet Other Campers in your City",
|
||||
"difficulty": 0.007,
|
||||
"challengeSeed": "127358841",
|
||||
"description": [
|
||||
"One of the best ways to stay motivated when learning to code is to hang out with other campers.",
|
||||
"Slack and Camper News are great ways to communicate with other campers, but there's no substitute for meeting people in-person.",
|
||||
"The easiest way to meet other campers in your city is to join your city's Facebook Group. Click <a href='/field-guide/how-can-i-find-other-free-code-camp-campers-in-my-city' target='_blank'>here</a> to view our growing list of local groups.",
|
||||
"Click the link to your city, then, once Facebook loads, click \"Join group\".",
|
||||
"Our local groups are new, so if you don't see your city on this list, you should follow the directions to create a Facebook group for your city.",
|
||||
"If you don't have a Facebook account, we strongly recommend you create one, even if it's just for the purpose of coordinating with campers in your city through this group.",
|
||||
"Our groups allow you to create events, coordinate those events, and share photos from the events afterward.",
|
||||
"Whether you're hosting a study group, pair programming at your local library, or going to a weekend hackathon, your city's group will help you make it happen."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7137d8c441eddfaeb5bdef",
|
||||
"name": "Get Help the Hacker Way with RSAP",
|
||||
"difficulty": 0.008,
|
||||
"challengeSeed": "125407432",
|
||||
"description": [
|
||||
"Let's cover one last thing before you start working through our lessons: how to get help.",
|
||||
"Any time you get stuck or don't know what to do next, follow this simple algorithm (procedure): RSAP (Read, Search, Ask, Post).",
|
||||
"First, R - Read the documentation or error message. A key skill that good coders have is the ability to interpret and then follow instructions.",
|
||||
"Next, S - Search Google. Good Google queries take a lot of practice. When you search Google, you usually want to include the language or framework you're using. You also want to limit the results to a recent period.",
|
||||
"Then, if you still haven't found an answer to your question, A - Ask your friends. If you have trouble, you can ask your fellow campers. We have a special chat room specifically for getting help with tools you learn through these Free Code Camp Challenges. Go to <a href='https://freecode.slack.com/messages/help/' target='_blank'>https://freecode.slack.com/messages/help/</a>. Keep this chat open while you work on the remaining challenges.",
|
||||
"Finally, P - Post on Stack Overflow. Before you attempt to do this, read Stack Overflow's guide to asking good questions: <a href='http://stackoverflow.com/help/how-to-ask'>http://stackoverflow.com/help/how-to-ask</a>.",
|
||||
"Here's our detailed field guide on getting help: <a href='/field-guide/how-do-i-get-help-when-i-get-stuck' target='_blank'>http://freecodecamp.com/field-guide/how-do-i-get-help-when-i-get-stuck</a>.",
|
||||
"Now you have a clear algorithm to follow when you need help! Let's start coding! Move on to your next challenge."
|
||||
],
|
||||
"challengeType": 2,
|
||||
"tests": []
|
||||
}
|
||||
]
|
||||
}
|
283
seed_data/challenges/jquery-ajax-and-json.json
Normal file
283
seed_data/challenges/jquery-ajax-and-json.json
Normal file
@ -0,0 +1,283 @@
|
||||
{
|
||||
"name": "jQuery Ajax and JSON",
|
||||
"order" : 0.004,
|
||||
"challenges": [
|
||||
{
|
||||
"_id": "bad87fee1348bd9acdd08826",
|
||||
"name": "Learn how Script Tags and Document Ready Work",
|
||||
"difficulty": 0.072,
|
||||
"description": [
|
||||
"Test"
|
||||
],
|
||||
"tests": [
|
||||
"assert($('#target').hasClass('disabled'), 'The button with the ID of \"target\" should continue to have the \"disabled\" class.')",
|
||||
"assert(!!$('#target[disabled]'), 'Enable the button with the ID of \"target\" by using jQuery.')",
|
||||
"expect($('#target')).to.exist()"
|
||||
],
|
||||
"challengeSeed": [
|
||||
"fccss",
|
||||
" $(document).ready(function() {",
|
||||
" $('#target').attr('disabled', true)",
|
||||
" });",
|
||||
"fcces",
|
||||
"<button id='target' class='btn btn-primary btn-block'>Enable this button with jQuery</button>"
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedc08826",
|
||||
"name": "Target Elements by Selectors Using jQuery",
|
||||
"difficulty": 0.073,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedb08826",
|
||||
"name": "Target Elements by Class Using jQuery",
|
||||
"difficulty": 0.074,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aeda08826",
|
||||
"name": "Target an element by ID Using jQuery",
|
||||
"difficulty": 0.075,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aed908826",
|
||||
"name": "Change the CSS of an Element Using jQuery",
|
||||
"difficulty": 0.076,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aed808826",
|
||||
"name": "Disable an Element Using jQuery",
|
||||
"difficulty": 0.077,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aed708826",
|
||||
"name": "Remove an Element Using jQuery",
|
||||
"difficulty": 0.078,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aed608826",
|
||||
"name": "Move an Element Using jQuery",
|
||||
"difficulty": 0.079,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aed508826",
|
||||
"name": "Clone an Element Using jQuery",
|
||||
"difficulty": 0.080,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aed408826",
|
||||
"name": "Animate an Element Using jQuery",
|
||||
"difficulty": 0.081,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aed308826",
|
||||
"name": "Target the Parent of an Element Using jQuery",
|
||||
"difficulty": 0.082,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aed208826",
|
||||
"name": "Target the Children of an Element Using jQuery",
|
||||
"difficulty": 0.083,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aed108826",
|
||||
"name": "Target a Specific Child of an Element Using jQuery",
|
||||
"difficulty": 0.084,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aed008826",
|
||||
"name": "Target Even Numbered Elements Using jQuery",
|
||||
"difficulty": 0.085,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aecc08826",
|
||||
"name": "Read Data from an Element Using jQuery",
|
||||
"difficulty": 0.086,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9aebc08826",
|
||||
"name": "Get Data from an URL Using jQuery",
|
||||
"difficulty": 0.087,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9ae9c08826",
|
||||
"name": "Loop through JSON Data Using jQuery",
|
||||
"difficulty": 0.089,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "bad87fee1348bd9ae8c08826",
|
||||
"name": "Setup Click Events Using jQuery",
|
||||
"difficulty": 0.089,
|
||||
"description": [
|
||||
|
||||
],
|
||||
"tests": [
|
||||
|
||||
],
|
||||
"challengeSeed": [
|
||||
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
197
seed_data/challenges/ziplines.json
Normal file
197
seed_data/challenges/ziplines.json
Normal file
@ -0,0 +1,197 @@
|
||||
{
|
||||
"name": "Ziplines",
|
||||
"order" : 0.009,
|
||||
"challenges": [
|
||||
{
|
||||
"_id": "bd7158d8c442eddfbeb5bd1f",
|
||||
"name": "Get Set for Ziplines",
|
||||
"difficulty": 1.00,
|
||||
"challengeSeed": "125658022",
|
||||
"description": [
|
||||
"Now you're ready to start our Zipline challenges. These front-end development challenges will give you many opportunities to apply the HTML, CSS, jQuery and JavaScript you've learned to build static (database-less) applications.",
|
||||
"For many of these challenges, you will be using JSON data from external API endpoints, such as Twitch.tv and Twitter. Note that you don't need to have a database to use these data.",
|
||||
"The easiest way to manipulate these data is with <a href='http://api.jquery.com/jquery.getjson/' target='_blank'>jQuery $.getJSON()</a>.",
|
||||
"Whatever you do, don't get discouraged! Remember to use <a href='/field-guide/how-do-i-get-help-when-I-get-stuck'>RSAP</a> if you get stuck.",
|
||||
"We'll build these challenges using CodePen, a popular tool for creating, sharing, and discovering static web applications.",
|
||||
"Go to <a href='http://codepen.io' target='_blank'>http://codepen.io</a> and create an account.",
|
||||
"Click your user image in the top right corner, then click the \"New pen\" button that drops down.",
|
||||
"Drag the windows around and press the buttons in the lower-right hand corner to change the orientation to suit your preference.",
|
||||
"Click the gear next to CSS. Then in the \"External CSS File or Another Pen\" text field, type \"bootstrap\" and scroll down until you see the latest version of Bootstrap. Click it.",
|
||||
"Verify that bootstrap is active by adding the following code to your HTML: <code><h1 class='text-primary'>Hello CodePen!</h1></code>. The text's color should be Bootstrap blue.",
|
||||
"Click the gear next the JavaScript. Click the \"Latest version of...\" select box and choose jQuery.",
|
||||
"Now add the following code to your JavaScript: <code>$(document).ready(function() { $('.text-primary').text('Hi CodePen!') });</code>. Click the \"Save\" button at the top. Your \"Hello CodePen!\" should change to \"Hi CodePen!\". This means that jQuery is working.",
|
||||
"Now you're ready for your first Zipline. Click the \"I've completed this challenge\" button and include a link to your CodePen. If you pair programmed, you should also include the Free Code Camp username of your pair."
|
||||
],
|
||||
"challengeType": 3,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c442eddfaeb5bd1f",
|
||||
"name": "Zipline: Use the Twitch.tv JSON API",
|
||||
"difficulty": 1.01,
|
||||
"challengeSeed": "126411564",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a <a href='http://codepen.io' target='_blank'>CodePen.io</a> that successfully reverse-engineers this: <a href='http://codepen.io/GeoffStorbeck/full/GJKRxZ' target='_blank'>http://codepen.io/GeoffStorbeck/full/GJKRxZ</a>.",
|
||||
"<span class='text-info'>Rule #1:</span> Don't look at the example project's code. Figure it out for yourself.",
|
||||
"<span class='text-info'>Rule #2:</span> You may use whichever libraries or APIs you need.",
|
||||
"<span class='text-info'>Rule #3:</span> Reverse engineer the example project's functionality, and also feel free to personalize it.",
|
||||
"Here are the <a href='http://en.wikipedia.org/wiki/User_story' target='_blank'>user stories</a> you must enable, and optional bonus user stories:",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can see whether Free Code Camp is currently streaming on Twitch.tv.",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can click the status output and be sent directly to the Free Code Camp's Twitch.tv channel.",
|
||||
"<span class='text-info'>User Story:</span> As a user, if Free Code Camp is streaming, I can see additional details about what they are streaming.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, I can search through the streams listed.",
|
||||
"<span class='text-info'>Hint:</span> Here's an example call to Twitch.tv's JSON API: <code>https://api.twitch.tv/kraken/streams/freecodecamp</code>.",
|
||||
"<span class='text-info'>Hint:</span> The relevant documentation about this API call is here: <a href='https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamschannel' target='_blank'>https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamschannel</a>.",
|
||||
"<span class='text-info'>Hint:</span> Here's an array of the Twitch.tv usernames of people who regularly stream coding: <code>[\"freecodecamp\", \"storbeck\", \"terakilobyte\", \"habathcx\",\"RobotCaleb\",\"comster404\",\"brunofin\",\"thomasballinger\",\"noobs2ninjas\",\"beohoff\"]</code>",
|
||||
"When you are finished, click the \"I've completed this challenge\" button and include a link to your CodePen. If you pair programmed, you should also include the Free Code Camp username of your pair.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your CodePen project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 3,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c442eddfaeb5bd13",
|
||||
"name": "Zipline: Build a Random Quote Machine",
|
||||
"difficulty": 1.02,
|
||||
"challengeSeed": "126415122",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a <a href='http://codepen.io' target='_blank'>CodePen.io</a> that successfully reverse-engineers this: <a href='http://codepen.io/AdventureBear/full/vEoVMw' target='_blank'>http://codepen.io/AdventureBear/full/vEoVMw</a>.",
|
||||
"<span class='text-info'>Rule #1:</span> Don't look at the example project's code. Figure it out for yourself.",
|
||||
"<span class='text-info'>Rule #2:</span> You may use whichever libraries or APIs you need.",
|
||||
"<span class='text-info'>Rule #3:</span> Reverse engineer the example project's functionality, and also feel free to personalize it.",
|
||||
"Here are the <a href='http://en.wikipedia.org/wiki/User_story' target='_blank'>user stories</a> you must enable, and optional bonus user stories:",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can click a button to show me a new random quote.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, I can press a button to tweet out a quote.",
|
||||
"When you are finished, click the \"I've completed this challenge\" button and include a link to your CodePen. If you pair programmed, you should also include the Free Code Camp username of your pair.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your CodePen project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 3,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c442eddfaeb5bd10",
|
||||
"name": "Zipline: Show the Local Weather",
|
||||
"difficulty": 1.03,
|
||||
"challengeSeed": "126415127",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a <a href='http://codepen.io' target='_blank'>CodePen.io</a> that successfully reverse-engineers this: <a href='http://codepen.io/AdventureBear/full/yNBJRj' target='_blank'>http://codepen.io/AdventureBear/full/yNBJRj</a>.",
|
||||
"<span class='text-info'>Rule #1:</span> Don't look at the example project's code. Figure it out for yourself.",
|
||||
"<span class='text-info'>Rule #2:</span> You may use whichever libraries or APIs you need.",
|
||||
"<span class='text-info'>Rule #3:</span> Reverse engineer the example project's functionality, and also feel free to personalize it.",
|
||||
"Here are the <a href='http://en.wikipedia.org/wiki/User_story' target='_blank'>user stories</a> you must enable, and optional bonus user stories:",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can see the weather in my current location.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, I can see an icon depending on the temperature..",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, I see a different background image depending on the temperature (e.g. snowy mountain, hot desert).",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, I can push a button to toggle between Fahrenheit and Celsius.",
|
||||
"When you are finished, click the \"I've completed this challenge\" button and include a link to your CodePen. If you pair programmed, you should also include the Free Code Camp username of your pair.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your CodePen project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 3,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c442eddfaeb5bd18",
|
||||
"name": "Zipline: Stylize Stories on Camper News",
|
||||
"difficulty": 1.04,
|
||||
"challengeSeed": "126415129",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a <a href='http://codepen.io' target='_blank'>CodePen.io</a> that successfully reverse-engineers this: <a href='http://codepen.io/GeoffStorbeck/full/Wveezv' target='_blank'>http://codepen.io/GeoffStorbeck/full/Wveezv</a>.",
|
||||
"<span class='text-info'>Rule #1:</span> Don't look at the example project's code. Figure it out for yourself.",
|
||||
"<span class='text-info'>Rule #2:</span> You may use whichever libraries or APIs you need.",
|
||||
"<span class='text-info'>Rule #3:</span> Reverse engineer the example project's functionality, and also feel free to personalize it.",
|
||||
"Here are the <a href='http://en.wikipedia.org/wiki/User_story' target='_blank'>user stories</a> you must enable, and optional bonus user stories:",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can browse recent posts from Camper News.",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can click on a post to be taken to the story's original URL.",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can click a link to go directly to the post's discussion page.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, I can see how many upvotes each story has.",
|
||||
"<span class='text-info'>Hint:</span> Here's the Camper News Hot Stories API endpoint: <code>http://www.freecodecamp.com/stories/hotStories</code>.",
|
||||
"When you are finished, click the \"I've completed this challenge\" button and include a link to your CodePen. If you pair programmed, you should also include the Free Code Camp username of your pair.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your CodePen project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 3,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c442eddfaeb5bd19",
|
||||
"name": "Zipline: Wikipedia Viewer",
|
||||
"difficulty": 1.05,
|
||||
"challengeSeed": "126415131",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a <a href='http://codepen.io' target='_blank'>CodePen.io</a> that successfully reverse-engineers this: <a href='http://codepen.io/GeoffStorbeck/full/MwgQea' target='_blank'>http://codepen.io/GeoffStorbeck/full/MwgQea</a>.",
|
||||
"<span class='text-info'>Rule #1:</span> Don't look at the example project's code. Figure it out for yourself.",
|
||||
"<span class='text-info'>Rule #2:</span> You may use whichever libraries or APIs you need.",
|
||||
"<span class='text-info'>Rule #3:</span> Reverse engineer the example project's functionality, and also feel free to personalize it.",
|
||||
"Here are the <a href='http://en.wikipedia.org/wiki/User_story' target='_blank'>user stories</a> you must enable, and optional bonus user stories:",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can search Wikipedia entries in a search box and see the resulting Wikipedia entries.",
|
||||
"<span class='text-info'>Bonus User Story:</span>As a user, I can click a button to see a random Wikipedia entry.",
|
||||
"<span class='text-info'>Bonus User Story:</span>As a user, when I type in the search box, I can see a dropdown menu with autocomplete options for matching Wikipedia entries.",
|
||||
"<span class='text-info'>Hint:</span> Here's an entry on using Wikipedia's API: <code>http://www.mediawiki.org/wiki/API:Main_page</code>.",
|
||||
"When you are finished, click the \"I've completed this challenge\" button and include a link to your CodePen. If you pair programmed, you should also include the Free Code Camp username of your pair.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your CodePen project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 3,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c442eddfaeb5bd0f",
|
||||
"name": "Zipline: Build a Pomodoro Clock",
|
||||
"difficulty": 1.06,
|
||||
"challengeSeed": "126411567",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a <a href='http://codepen.io' target='_blank'>CodePen.io</a> that successfully reverse-engineers this: <a href='http://codepen.io/GeoffStorbeck/full/RPbGxZ/' target='_blank'>http://codepen.io/GeoffStorbeck/full/RPbGxZ/</a>.",
|
||||
"<span class='text-info'>Rule #1:</span> Don't look at the example project's code. Figure it out for yourself.",
|
||||
"<span class='text-info'>Rule #2:</span> You may use whichever libraries or APIs you need.",
|
||||
"<span class='text-info'>Rule #3:</span> Reverse engineer the example project's functionality, and also feel free to personalize it.",
|
||||
"Here are the <a href='http://en.wikipedia.org/wiki/User_story' target='_blank'>user stories</a> you must enable, and optional bonus user stories:",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can start a 25 minute pomodoro, and the timer will go off once 25 minutes has elapsed.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, I can reset the clock for my next pomodoro.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, I can customize the length of each pomodoro.",
|
||||
"When you are finished, click the \"I've completed this challenge\" button and include a link to your CodePen. If you pair programmed, you should also include the Free Code Camp username of your pair.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your CodePen project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 3,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c442eddfaeb5bd17",
|
||||
"name": "Zipline: Build a JavaScript Calculator",
|
||||
"difficulty": 1.07,
|
||||
"challengeSeed": "126411565",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a <a href='http://codepen.io' target='_blank'>CodePen.io</a> that successfully reverse-engineers this: <a href='http://codepen.io/GeoffStorbeck/full/zxgaqw' target='_blank'>http://codepen.io/GeoffStorbeck/full/zxgaqw</a>.",
|
||||
"<span class='text-info'>Rule #1:</span> Don't look at the example project's code. Figure it out for yourself.",
|
||||
"<span class='text-info'>Rule #2:</span> You may use whichever libraries or APIs you need.",
|
||||
"<span class='text-info'>Rule #3:</span> Reverse engineer the example project's functionality, and also feel free to personalize it.",
|
||||
"Here are the <a href='http://en.wikipedia.org/wiki/User_story' target='_blank'>user stories</a> you must enable, and optional bonus user stories:",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can add, subtract, multiply and divide two numbers.",
|
||||
"<span class='text-info'>Bonus User Story:</span> I can clear the input field with a clear button.",
|
||||
"<span class='text-info'>Bonus User Story:</span> I can keep chaining mathematical operations together until I hit the clear button, and the calculator will tell me the correct output.",
|
||||
"When you are finished, click the \"I've completed this challenge\" button and include a link to your CodePen. If you pair programmed, you should also include the Free Code Camp username of your pair.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your CodePen project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 3,
|
||||
"tests": []
|
||||
},
|
||||
{
|
||||
"_id": "bd7158d8c442eddfaeb5bd1c",
|
||||
"name": "Zipline: Build a Tic Tac Toe Game",
|
||||
"difficulty": 1.08,
|
||||
"challengeSeed": "126415123",
|
||||
"description": [
|
||||
"<span class='text-info'>Objective:</span> Build a <a href='http://codepen.io' target='_blank'>CodePen.io</a> that successfully reverse-engineers this: <a href='http://codepen.io/alex-dixon/full/JogOpQ/' target='_blank'>http://codepen.io/alex-dixon/full/JogOpQ/</a>.",
|
||||
"<span class='text-info'>Rule #1:</span> Don't look at the example project's code. Figure it out for yourself.",
|
||||
"<span class='text-info'>Rule #2:</span> You may use whichever libraries or APIs you need.",
|
||||
"<span class='text-info'>Rule #3:</span> Reverse engineer the example project's functionality, and also feel free to personalize it.",
|
||||
"Here are the <a href='http://en.wikipedia.org/wiki/User_story' target='_blank'>user stories</a> you must enable, and optional bonus user stories:",
|
||||
"<span class='text-info'>User Story:</span> As a user, I can play a game of Tic Tac Toe with the computer.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, I can never actually win against the computer - at best I can tie.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, my game will reset as soon as it's over so I can play again.",
|
||||
"<span class='text-info'>Bonus User Story:</span> As a user, I can choose whether I want to play as X or O.",
|
||||
"When you are finished, click the \"I've completed this challenge\" button and include a link to your CodePen. If you pair programmed, you should also include the Free Code Camp username of your pair.",
|
||||
"If you'd like immediate feedback on your project, click this button and paste in a link to your CodePen project. Otherwise, we'll review it before you start your nonprofit projects.<br><br><a class='btn btn-primary btn-block' href='https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20%0A%20%23LearnToCode%20%23JavaScript' target='_blank'>Click here then add your link to your tweet's text</a>"
|
||||
],
|
||||
"challengeType": 3,
|
||||
"tests": []
|
||||
}
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,19 +1,18 @@
|
||||
require('dotenv').load();
|
||||
var Bonfire = require('../models/Bonfire.js'),
|
||||
Courseware = require('../models/Courseware.js'),
|
||||
var Challenge = require('../models/Challenge.js'),
|
||||
FieldGuide = require('../models/FieldGuide.js'),
|
||||
Nonprofit = require('../models/Nonprofit.js'),
|
||||
mongoose = require('mongoose'),
|
||||
secrets = require('../config/secrets'),
|
||||
coursewares = require('./coursewares.json'),
|
||||
fieldGuides = require('./field-guides.json'),
|
||||
nonprofits = require('./nonprofits.json'),
|
||||
bonfires = require('./bonfires.json');
|
||||
fs = require('fs');
|
||||
|
||||
mongoose.connect(secrets.db);
|
||||
var challenges = fs.readdirSync(__dirname + '/challenges');
|
||||
|
||||
var counter = 0;
|
||||
var offerings = 4;
|
||||
var offerings = 2 + challenges.length;
|
||||
|
||||
var CompletionMonitor = function() {
|
||||
counter++;
|
||||
@ -26,41 +25,23 @@ var CompletionMonitor = function() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Bonfire.remove({}, function(err, data) {
|
||||
Challenge.remove({}, function(err, data) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
console.err(err);
|
||||
} else {
|
||||
console.log('Deleted ', data);
|
||||
}
|
||||
Bonfire.create(bonfires, function(err, data) {
|
||||
challenges.forEach(function (file) {
|
||||
Challenge.create(require('./challenges/' + file).challenges, function (err, data) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log('Saved ', data);
|
||||
}
|
||||
console.log('Successfully parsed %s', file);
|
||||
CompletionMonitor();
|
||||
});
|
||||
console.log('bonfires');
|
||||
});
|
||||
|
||||
Courseware.remove({}, function(err, data) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
} else {
|
||||
console.log('Deleted ', data);
|
||||
}
|
||||
Courseware.create(coursewares, function(err, data) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log('Saved ', data);
|
||||
}
|
||||
CompletionMonitor();
|
||||
});
|
||||
console.log('coursewares');
|
||||
});
|
||||
|
||||
});
|
||||
FieldGuide.remove({}, function(err, data) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*eslint-disable block-scoped-var */
|
||||
require('dotenv').load();
|
||||
var mongodb = require('mongodb'),
|
||||
User = require('../models/User.js'),
|
||||
newChallenges = require('./challengeMapping.json'),
|
||||
secrets = require('../config/secrets');
|
||||
mongoose = require('mongoose');
|
||||
var User = require('../models/User.js'),
|
||||
secrets = require('../config/secrets'),
|
||||
mongoose = require('mongoose'),
|
||||
R = require('ramda');
|
||||
|
||||
mongoose.connect(secrets.db);
|
||||
|
||||
@ -57,6 +57,7 @@ function userModelMigration(cb) {
|
||||
|
||||
stream.on('data', function (user) {
|
||||
console.log(i++);
|
||||
/*
|
||||
if (user.challengesHash) {
|
||||
this.pause();
|
||||
user.needsMigration = false;
|
||||
@ -88,6 +89,25 @@ function userModelMigration(cb) {
|
||||
user.progressTimestamps.push(bonfire.completedDate);
|
||||
});
|
||||
}
|
||||
*/
|
||||
user.needsMigration = false;
|
||||
user.completedChallenges = R.filter(function(elem) {
|
||||
return elem; // getting rid of undefined
|
||||
}, R.concat(
|
||||
user.completedCoursewares,
|
||||
user.completedBonfires.map(function(bonfire) {
|
||||
return ({
|
||||
completedDate: bonfire.completedDate,
|
||||
_id: bonfire._id,
|
||||
name: bonfire.name,
|
||||
completedWith: bonfire.completedWith,
|
||||
solution: bonfire.solution,
|
||||
githubLink: '',
|
||||
verified: false,
|
||||
challengeType: 5
|
||||
});
|
||||
})
|
||||
));
|
||||
|
||||
var self = this;
|
||||
user.save(function (err) {
|
||||
|
@ -117,7 +117,7 @@ block content
|
||||
span.ion-close-circled
|
||||
| Your name must be fewer than 15 characters.
|
||||
.form-group
|
||||
label.col-sm-3.col-sm-offset-2.control-label(for='email') Github
|
||||
label.col-sm-3.col-sm-offset-2.control-label(for='email') GitHub
|
||||
.col-sm-4
|
||||
input.form-control(type='url', name='githubProfile', id='githubProfile', autocomplete="off", ng-model='user.profile.githubProfile', placeholder='http://')
|
||||
.col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.githubProfile.$error.url && !profileForm.githubProfile.$pristine")
|
||||
|
@ -164,7 +164,7 @@ block content
|
||||
for bonfire in bonfires
|
||||
tr
|
||||
td.col-xs-4
|
||||
a(href='/bonfires/' + bonfire.name)= bonfire.name
|
||||
a(href='/challenges/' + bonfire.name)= bonfire.name
|
||||
td.col-xs-2= moment(bonfire.completedDate, 'x').format("MMM DD, YYYY")
|
||||
td.col-xs-6
|
||||
pre.wrappable= bonfire.solution
|
||||
|
@ -1,45 +0,0 @@
|
||||
extends ../layout-wide
|
||||
block content
|
||||
script(src='/js/lib/codemirror/lib/codemirror.js')
|
||||
script(src='/js/lib/codemirror/addon/edit/closebrackets.js')
|
||||
script(src='/js/lib/codemirror/addon/edit/matchbrackets.js')
|
||||
script(src='/js/lib/codemirror/addon/lint/lint.js')
|
||||
script(src='/js/lib/codemirror/addon/lint/javascript-lint.js')
|
||||
script(src='//ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js')
|
||||
script(src='/js/lib/chai/chai.js')
|
||||
link(rel='stylesheet', href='/js/lib/codemirror/lib/codemirror.css')
|
||||
link(rel='stylesheet', href='/js/lib/codemirror/addon/lint/lint.css')
|
||||
link(rel='stylesheet', href='/js/lib/codemirror/theme/monokai.css')
|
||||
link(rel="stylesheet", href="http://fonts.googleapis.com/css?family=Ubuntu+Mono")
|
||||
script(src='/js/lib/codemirror/mode/javascript/javascript.js')
|
||||
script(src='/js/lib/jailed/jailed.js')
|
||||
script(src='/js/lib/bonfire/bonfireInit.js')
|
||||
.row
|
||||
script(type="text/javascript").
|
||||
var tests = !{JSON.stringify(tests)};
|
||||
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
||||
var challengeEntryPoint = !{JSON.stringify(challengeEntryPoint)};
|
||||
var title = !{JSON.stringify(title)};
|
||||
|
||||
#mainEditorPanel.col-sm-12.col-md-7.col-xs-12
|
||||
.panel.panel-primary.panel-bonfire
|
||||
.panel-heading.text-center Playground
|
||||
.panel.panel-body
|
||||
form.code
|
||||
.form-group.codeMirrorView
|
||||
textarea#codeEditor(autofocus=true)
|
||||
|
||||
|
||||
#testCreatePanel.col-sm-12.col-md-5.col-xs-12
|
||||
.panel.panel-primary.panel-bonfire
|
||||
.panel-heading.text-center Output
|
||||
.panel.panel-body
|
||||
#submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter)
|
||||
br
|
||||
form.code
|
||||
.form-group.codeMirrorView
|
||||
textarea#codeOutput
|
||||
br
|
||||
ul#testSuite.list-group
|
||||
br
|
||||
script(src='/js/lib/bonfire/bonfireFramework_v0.1.2.js')
|
@ -1,45 +0,0 @@
|
||||
extends ../layout
|
||||
block content
|
||||
.row
|
||||
.col-md-offset-2.col-md-8.col-lg-offset-2.col-lg-8.text-center
|
||||
|
||||
h1 JSON generator for bonfire challenges - just fill the form out and get the correct format back
|
||||
.col-xs-12.col-sm-12.col-md-offset-1.col-md-10.col-lg-offset-1-col-lg-10
|
||||
.panel
|
||||
form.form-horizontal(method="POST", action="/bonfire-json-generator", name="bonfireInfo")
|
||||
.form-group
|
||||
label.col-sm-2.control-label(for='name') name:
|
||||
.col-sm-10
|
||||
input#name.form-control(type='text', placeholder='name', name="name")
|
||||
.form-group
|
||||
label.col-sm-2.control-label(for='difficultyField') difficulty:
|
||||
.col-sm-10
|
||||
label.radio-inline 1
|
||||
input#inlineRadio1(type='radio', name='difficulty', value='1')
|
||||
label.radio-inline 2
|
||||
input#inlineRadio2(type='radio', name='difficulty', value='2')
|
||||
label.radio-inline 3
|
||||
input#inlineRadio3(type='radio', name='difficulty', value='3')
|
||||
label.radio-inline 4
|
||||
input#inlineRadio4(type='radio', name='difficulty', value='4')
|
||||
label.radio-inline 5
|
||||
input#inlineRadio5(type='radio', name='difficulty', value='5')
|
||||
.form-group
|
||||
label.col-sm-2.control-label.wrappable(for='description') description:
|
||||
.col-sm-10
|
||||
textarea#description.form-control(name="description", rows=5, placeholder="Each \"paragraph\" needs to be separated by a line break(return key).")
|
||||
.form-group
|
||||
label.col-sm-2.control-label.wrappable(for='challengeSeed') challengeSeed:
|
||||
.col-sm-10
|
||||
textarea#challengeSeed.form-control(name="challengeSeed", rows=5)
|
||||
.form-group
|
||||
label.col-sm-2.control-label.wrappable(for='challengeEntryPoint') challenge entrypoint:
|
||||
.col-sm-10
|
||||
textarea#name.form-control(name="challengeEntryPoint", rows=1, type='text', placeholder="palindrome(\"eye\");")
|
||||
.form-group
|
||||
label.col-sm-2.control-label.wrappable(for='tests') tests:
|
||||
.col-sm-10
|
||||
textarea#tests.form-control(name="tests", rows=5, placeholder="Separate tests by a newline.")
|
||||
.form-group
|
||||
.col-sm-offset-2.col-sm-10
|
||||
input.btn.btn-default(type='submit', value="submit")
|
@ -1,44 +0,0 @@
|
||||
extends ../layout
|
||||
block content
|
||||
.row
|
||||
.col-md-offset-2.col-md-8.col-lg-offset-2.col-lg-8.text-center
|
||||
h1 Welcome to the challenge generator. Test your ideas out and see them live in bonfire!
|
||||
.col-xs-12.col-sm-12.col-md-offset-1.col-md-10.col-lg-offset-1-col-lg-10
|
||||
.panel
|
||||
form.form-horizontal(method="POST", action="/bonfire-challenge-generator", name="bonfireInfo")
|
||||
.form-group
|
||||
label.col-sm-2.control-label(for='name') name:
|
||||
.col-sm-10
|
||||
input#name.form-control(type='text', placeholder='name', name="name")
|
||||
.form-group
|
||||
label.col-sm-2.control-label(for='difficultyField') difficulty:
|
||||
.col-sm-10
|
||||
label.radio-inline 1
|
||||
input#inlineRadio1(type='radio', name='difficulty', value='1')
|
||||
label.radio-inline 2
|
||||
input#inlineRadio2(type='radio', name='difficulty', value='2')
|
||||
label.radio-inline 3
|
||||
input#inlineRadio3(type='radio', name='difficulty', value='3')
|
||||
label.radio-inline 4
|
||||
input#inlineRadio4(type='radio', name='difficulty', value='4')
|
||||
label.radio-inline 5
|
||||
input#inlineRadio5(type='radio', name='difficulty', value='5')
|
||||
.form-group
|
||||
label.col-sm-2.control-label.wrappable(for='description') description:
|
||||
.col-sm-10
|
||||
textarea#description.form-control(name="description", rows=5, placeholder="Each \"paragraph\" needs to be separated by a line break(return key).")
|
||||
.form-group
|
||||
label.col-sm-2.control-label.wrappable(for='challengeSeed') challengeSeed:
|
||||
.col-sm-10
|
||||
textarea#challengeSeed.form-control(name="challengeSeed", rows=5)
|
||||
.form-group
|
||||
label.col-sm-2.control-label.wrappable(for='challengeEntryPoint') challenge entrypoint:
|
||||
.col-sm-10
|
||||
textarea#name.form-control(name="challengeEntryPoint", rows=1, type='text', placeholder="palindrome(\"eye\");")
|
||||
.form-group
|
||||
label.col-sm-2.control-label.wrappable(for='tests') tests:
|
||||
.col-sm-10
|
||||
textarea#tests.form-control(name="tests", rows=5, placeholder="Separate tests by a newline.")
|
||||
.form-group
|
||||
.col-sm-offset-2.col-sm-10
|
||||
input.btn.btn-default(type='submit', value="submit")
|
@ -1,5 +1,11 @@
|
||||
extends ../layout
|
||||
block content
|
||||
script.
|
||||
var bonfireList = !{JSON.stringify(bonfires)};
|
||||
var waypointList = !{JSON.stringify(waypoints)};
|
||||
var ziplineList = !{JSON.stringify(ziplines)};
|
||||
var basejumpList = !{JSON.stringify(basejumps)};
|
||||
var completedChallenges = !{JSON.stringify(completedChallengeList)};
|
||||
.panel.panel-info
|
||||
.panel-heading.text-center
|
||||
h1 Challenge Map
|
||||
@ -24,7 +30,7 @@ block content
|
||||
h3.negative-15
|
||||
ol
|
||||
for waypoint in waypoints
|
||||
if completedCoursewareList.indexOf(waypoint._id) > -1
|
||||
if completedChallengeList.indexOf(waypoint._id) > -1
|
||||
.row
|
||||
.hidden-xs.col-sm-3.col-md-2.text-primary.ion-checkmark-circled.padded-ionic-icon.text-center
|
||||
.col-xs-12.col-sm-9.col-md-10
|
||||
@ -45,19 +51,19 @@ block content
|
||||
h3.negative-15
|
||||
ol
|
||||
for bonfire in bonfires
|
||||
if completedBonfireList.indexOf(bonfire._id) > -1
|
||||
if completedChallengeList.indexOf(bonfire._id) > -1
|
||||
.row
|
||||
.hidden-xs.col-sm-3.col-md-2.text-primary.ion-checkmark-circled.padded-ionic-icon.text-center
|
||||
.col-xs-12.col-sm-9.col-md-10
|
||||
li.faded
|
||||
a(href="/bonfires/#{bonfire.name}")= bonfire.name
|
||||
a(href="/challenges/#{bonfire.name}")= bonfire.name
|
||||
else
|
||||
.row
|
||||
.hidden-xs.col-sm-3.col-md-2
|
||||
span
|
||||
.col-xs-12.col-sm-9.col-md-10
|
||||
li
|
||||
a(href="/bonfires/#{bonfire.name}")= bonfire.name
|
||||
a(href="/challenges/#{bonfire.name}")= bonfire.name
|
||||
h2
|
||||
span.fa.fa-angle-double-right
|
||||
| Ziplines (200 hours of front end development)
|
||||
@ -65,7 +71,7 @@ block content
|
||||
h3.negative-15
|
||||
ol
|
||||
for zipline in ziplines
|
||||
if completedCoursewareList.indexOf(zipline._id) > -1
|
||||
if completedChallengeList.indexOf(zipline._id) > -1
|
||||
.row
|
||||
.hidden-xs.col-sm-3.col-md-2.text-primary.ion-checkmark-circled.padded-ionic-icon.text-center
|
||||
.col-xs-12.col-sm-9.col-md-10
|
||||
@ -85,7 +91,7 @@ block content
|
||||
h3.negative-15
|
||||
ol
|
||||
for basejump in basejumps
|
||||
if completedCoursewareList.indexOf(basejump._id) > -1
|
||||
if completedChallengeList.indexOf(basejump._id) > -1
|
||||
.row
|
||||
.hidden-xs.col-sm-3.col-md-2.text-primary.ion-checkmark-circled.padded-ionic-icon.text-center
|
||||
.col-xs-12.col-sm-9.col-md-10
|
||||
|
9
views/coursewares/getstuff.jade
Normal file
9
views/coursewares/getstuff.jade
Normal file
@ -0,0 +1,9 @@
|
||||
//
|
||||
Created by nathanleniz on 5/19/15.
|
||||
|
||||
extends ../layout-wide
|
||||
block content
|
||||
script.
|
||||
var stuff = !{JSON.stringify(stuff)};
|
||||
var challengeMapWithIds = !{JSON.stringify(stuffWithIds)};
|
||||
|
@ -6,7 +6,7 @@ block content
|
||||
script(type='text/javascript', src='/js/lib/codemirror/addon/edit/matchbrackets.js')
|
||||
script(type='text/javascript', src='/js/lib/codemirror/addon/lint/lint.js')
|
||||
script(type='text/javascript', src='/js/lib/codemirror/addon/lint/javascript-lint.js')
|
||||
script(type='text/javascript', src='//ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js')
|
||||
script(type='text/javascript', src='/bower_components/jshint/dist/jshint.js')
|
||||
script(type='text/javascript', src='/js/lib/chai/chai.js')
|
||||
link(rel='stylesheet', href='/js/lib/codemirror/lib/codemirror.css')
|
||||
link(rel='stylesheet', href='/js/lib/codemirror/addon/lint/lint.css')
|
||||
@ -14,7 +14,7 @@ block content
|
||||
link(rel="stylesheet", href="http://fonts.googleapis.com/css?family=Ubuntu+Mono")
|
||||
script(type='text/javascript', src='/js/lib/codemirror/mode/javascript/javascript.js')
|
||||
script(type='text/javascript', src='/js/lib/jailed/jailed.js')
|
||||
script(type='text/javascript', src='/js/lib/bonfire/bonfireInit.js')
|
||||
script(type='text/javascript', src='/js/lib/coursewares/sandbox.js')
|
||||
|
||||
.row
|
||||
.col-xs-12.col-sm-12.col-md-4.bonfire-top
|
||||
@ -93,9 +93,10 @@ block content
|
||||
script(type="text/javascript").
|
||||
var tests = !{JSON.stringify(tests)};
|
||||
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
||||
var passedBonfireHash = !{JSON.stringify(bonfireHash)};
|
||||
var challengeName = !{JSON.stringify(name)};
|
||||
var challenge_Id = !{JSON.stringify(challengeId)};
|
||||
var challenge_Name = !{JSON.stringify(name)};
|
||||
var started = Math.floor(Date.now());
|
||||
var challengeType = !{JSON.stringify(challengeType)};
|
||||
var _ = R;
|
||||
var dashed = !{JSON.stringify(dashedName)};
|
||||
|
||||
@ -104,11 +105,11 @@ block content
|
||||
form.code
|
||||
.form-group.codeMirrorView
|
||||
textarea#codeEditor(autofocus=true, style='display: none;')
|
||||
script(src='/js/lib/bonfire/bonfireFramework_v0.1.3.js')
|
||||
script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.2.js')
|
||||
|
||||
|
||||
|
||||
#complete-bonfire-dialog.modal(tabindex='-1')
|
||||
#complete-courseware-dialog.modal(tabindex='-1')
|
||||
.modal-dialog.animated.zoomIn.fast-animation
|
||||
.modal-content
|
||||
.modal-header.challenge-list-header= compliment
|
||||
@ -129,11 +130,11 @@ block content
|
||||
span.ion-close-circled
|
||||
| Username not found
|
||||
|
||||
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block.next-bonfire-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid && existingUser.length > 0') Go to my next bonfire (ctrl + enter)
|
||||
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid && existingUser.length > 0') Go to my next bonfire (ctrl + enter)
|
||||
|
||||
|
||||
- if (user.progressTimestamps.length > 2)
|
||||
a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(target="_blank", href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/bonfires/#{dashedName}&hashtags=LearnToCode, JavaScript")
|
||||
a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(target="_blank", href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{dashedName}&hashtags=LearnToCode, JavaScript")
|
||||
i.fa.fa-twitter  
|
||||
= phrase
|
||||
- else
|
@ -5,7 +5,7 @@ block content
|
||||
script(src='/js/lib/codemirror/addon/edit/matchbrackets.js')
|
||||
script(src='/js/lib/codemirror/addon/lint/lint.js')
|
||||
script(src='/js/lib/codemirror/addon/lint/javascript-lint.js')
|
||||
script(src='//ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js')
|
||||
script(src='/bower_components/jshint/dist/jshint.js')
|
||||
script(src='/js/lib/chai/chai.js')
|
||||
script(src='/js/lib/chai/chai-jquery.js')
|
||||
link(rel='stylesheet', href='/js/lib/codemirror/lib/codemirror.css')
|
||||
@ -14,7 +14,7 @@ block content
|
||||
link(rel="stylesheet", href="http://fonts.googleapis.com/css?family=Ubuntu+Mono")
|
||||
script(src='/js/lib/codemirror/mode/javascript/javascript.js')
|
||||
script(src='/js/lib/jailed/jailed.js')
|
||||
script(src='/js/lib/bonfire/bonfireInit.js')
|
||||
script(src='/js/lib/bonfire/sandbox.js')
|
||||
script(src='/js/lib/codemirror/mode/xml/xml.js')
|
||||
script(src='/js/lib/codemirror/mode/css/css.js')
|
||||
script(src='/js/lib/codemirror/mode/htmlmixed/htmlmixed.js')
|
||||
@ -56,9 +56,8 @@ block content
|
||||
$('#next-courseware-button').attr('disabled', 'disabled');
|
||||
var tests = !{JSON.stringify(tests)};
|
||||
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
||||
var challengeName = !{JSON.stringify(name)};
|
||||
var passedCoursewareName = challengeName;
|
||||
var challenge_Id = !{JSON.stringify(challengeId)};
|
||||
var challenge_Name = !{JSON.stringify(name)};
|
||||
var prodOrDev = !{JSON.stringify(environment)};
|
||||
var challengeType = !{JSON.stringify(challengeType)};
|
||||
var started = Math.floor(Date.now());
|
||||
|
@ -5,7 +5,7 @@ block content
|
||||
script(src='/js/lib/codemirror/addon/edit/matchbrackets.js')
|
||||
script(src='/js/lib/codemirror/addon/lint/lint.js')
|
||||
script(src='/js/lib/codemirror/addon/lint/javascript-lint.js')
|
||||
script(src='//ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js')
|
||||
script(src='/bower_components/jshint/dist/jshint.js')
|
||||
script(src='/js/lib/chai/chai.js')
|
||||
link(rel='stylesheet', href='/js/lib/codemirror/lib/codemirror.css')
|
||||
link(rel='stylesheet', href='/js/lib/codemirror/addon/lint/lint.css')
|
||||
@ -13,7 +13,7 @@ block content
|
||||
link(rel="stylesheet", href="http://fonts.googleapis.com/css?family=Ubuntu+Mono")
|
||||
script(src='/js/lib/codemirror/mode/javascript/javascript.js')
|
||||
script(src='/js/lib/jailed/jailed.js')
|
||||
script(src='/js/lib/bonfire/bonfireInit.js')
|
||||
script(src='/js/lib/coursewares/sandbox.js')
|
||||
.row
|
||||
.col-xs-12.col-sm-12.col-md-4.bonfire-top
|
||||
#testCreatePanel
|
||||
@ -45,10 +45,9 @@ block content
|
||||
script(type="text/javascript").
|
||||
var tests = !{JSON.stringify(tests)};
|
||||
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
||||
var challengeName = !{JSON.stringify(name)};
|
||||
var challenge_Id = !{JSON.stringify(challengeId)};
|
||||
var challenge_Name = !{JSON.stringify(name)};
|
||||
var challengeType = !{JSON.stringify(challengeType)};
|
||||
var passedCoursewareName = challengeName;
|
||||
var started = Math.floor(Date.now());
|
||||
|
||||
.col-xs-12.col-sm-12.col-md-8
|
||||
@ -56,7 +55,7 @@ block content
|
||||
form.code
|
||||
.form-group.codeMirrorView
|
||||
textarea#codeEditor(autofocus=true, style='display: none;')
|
||||
script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.1.js')
|
||||
script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.2.js')
|
||||
#complete-courseware-dialog.modal(tabindex='-1')
|
||||
.modal-dialog.animated.zoomIn.fast-animation
|
||||
.modal-content
|
||||
|
@ -28,12 +28,7 @@ block content
|
||||
br
|
||||
.button-spacer
|
||||
script(type="text/javascript").
|
||||
var tests = !{JSON.stringify(tests)};
|
||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
||||
var challengeName = !{JSON.stringify(name)};
|
||||
var passedCoursewareName = challengeName;
|
||||
var started = Math.floor(Date.now());
|
||||
var challengeType = !{JSON.stringify(challengeType)};
|
||||
|
||||
var controlEnterHandler = function(e) {
|
||||
$('body').unbind('keypress');
|
||||
if (e.ctrlKey && e.keyCode == 13) {
|
||||
@ -76,3 +71,7 @@ block content
|
||||
h1 #{name}
|
||||
script.
|
||||
$('body').bind('keypress', controlEnterHandler);
|
||||
script.
|
||||
var challenge_Id = !{JSON.stringify(challengeId)};
|
||||
var challenge_Name = !{JSON.stringify(name)};
|
||||
var challengeType = !{JSON.stringify(challengeType)};
|
@ -3,6 +3,11 @@ block content
|
||||
.row
|
||||
.col-xs-12.col-sm-12.col-md-4.bonfire-top
|
||||
h1.text-center= name
|
||||
p.text-center Tips: Use 
|
||||
a(href='/field-guide/how-do-i-get-help-when-I-get-stuck' target='_blank') RSAP
|
||||
| . Try using  
|
||||
a(href='http://api.jquery.com/jquery.each/' target='_blank') jQuery's $.getJSON()
|
||||
|  to consume APIs.
|
||||
.well
|
||||
h4
|
||||
ol
|
||||
@ -27,9 +32,8 @@ block content
|
||||
var userLoggedIn = false;
|
||||
br
|
||||
script(type="text/javascript").
|
||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
||||
var challengeName = !{JSON.stringify(name)};
|
||||
var passedCoursewareName = challengeName;
|
||||
var challenge_Id = !{JSON.stringify(challengeId)};
|
||||
var challenge_Name = !{JSON.stringify(name)};
|
||||
var started = Math.floor(Date.now());
|
||||
var challengeType = !{JSON.stringify(challengeType)};
|
||||
var controlEnterHandler = function (e) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
.fcc-footer
|
||||
.col-xs-12.hidden-xs.hidden-sm
|
||||
a.ion-speakerphone(href='http://blog.freecodecamp.com', target='_blank') Blog
|
||||
a.ion-social-github(href="http://github.com/freecodecamp", target='_blank') Github
|
||||
a.ion-social-github(href="http://github.com/freecodecamp", target='_blank') GitHub
|
||||
a.ion-social-twitch-outline(href="/twitch")  Twitch
|
||||
a.ion-social-facebook(href="/field-guide/how-can-i-find-other-free-code-camp-campers-in-my-city") Facebook
|
||||
a.ion-social-twitter(href="http://twitter.com/freecodecamp", target='_blank') Twitter
|
||||
|
@ -31,7 +31,7 @@ script(src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js")
|
||||
script.
|
||||
window.moment || document.write('<script src="/bower_components/moment/min/moment.min.js"><\/script>');
|
||||
|
||||
// Leave alone below
|
||||
// Leave the below lines alone!
|
||||
script(src="/js/main.js")
|
||||
|
||||
script(src="/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js")
|
||||
@ -45,6 +45,7 @@ link(rel="stylesheet" type="text/css" href="/bower_components/cal-heatmap/cal-he
|
||||
link(rel='stylesheet', href='/bower_components/font-awesome/css/font-awesome.min.css')
|
||||
|
||||
link(rel='stylesheet', href='/css/main.css')
|
||||
// End **REQUIRED** includes
|
||||
|
||||
include meta
|
||||
title #{title} | Free Code Camp
|
||||
|
@ -39,13 +39,6 @@ urlset(xmlns="http://www.sitemaps.org/schemas/sitemap/0.9")
|
||||
changefreq daily
|
||||
priority= 0.5
|
||||
|
||||
each bonfire in bonfires
|
||||
url
|
||||
loc #{appUrl}/bonfires/#{bonfire.replace(/\s/g, '-')}
|
||||
lastmod= now
|
||||
changefreq weekly
|
||||
priority= 0.5
|
||||
|
||||
each challenge in challenges
|
||||
url
|
||||
loc #{appUrl}/challenges/#{challenge.replace(/\s/g, '-')}
|
||||
|
Reference in New Issue
Block a user