Work on challenge flow from block to block, start refactoring the name courseware to challenges in main.js
This commit is contained in:
18
app.js
18
app.js
@ -44,6 +44,7 @@ var express = require('express'),
|
||||
coursewareController = require('./controllers/courseware'),
|
||||
fieldGuideController = require('./controllers/fieldGuide'),
|
||||
challengeMapController = require('./controllers/challengeMap'),
|
||||
challengeController = require('./controllers/challenge'),
|
||||
|
||||
/**
|
||||
* Stories
|
||||
@ -537,17 +538,24 @@ app.post('/completed-field-guide/', fieldGuideController.completedFieldGuide);
|
||||
* Courseware related routes
|
||||
*/
|
||||
|
||||
app.get('/challenges/', coursewareController.returnNextCourseware);
|
||||
app.get('/getstuff', challengeController.getStuff);
|
||||
|
||||
|
||||
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',
|
||||
|
@ -40,42 +40,107 @@ exports.showAllChallenges = function(req, res) {
|
||||
res.send(data);
|
||||
};
|
||||
|
||||
exports.getStuff = function(req, res, next) {
|
||||
res.send({withNames: challengeMapWithNames, withIds: challengeMapWithIds});
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
req.user.save();
|
||||
// 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 - 1
|
||||
// serve index + 1 challenge
|
||||
// otherwise increment block key and serve the first challenge in that block
|
||||
var nextChallengeName;
|
||||
var nextChallengeId;
|
||||
var nextChallengeBlock;
|
||||
|
||||
var challengeId = req.user.currentChallenge.challengeId;
|
||||
var challengeBlock = req.user.currentChallenge.challengeBlock;
|
||||
debug('this is the user challenge block', challengeBlock);
|
||||
var indexOfChallenge = challengeMapWithIds[challengeBlock]
|
||||
.indexOf(challengeId);
|
||||
|
||||
if (indexOfChallenge
|
||||
<= challengeMapWithIds[challengeBlock].length - 1) {
|
||||
debug('Logging first two challenge blocks for sanity', challengeMapWithIds[0], challengeMapWithIds[1]);
|
||||
|
||||
|
||||
debug('these are the damn keys on challengeMapWithIds...', Object.keys(challengeMapWithIds));
|
||||
if (indexOfChallenge + 1
|
||||
< challengeMapWithIds[challengeBlock].length) {
|
||||
debug('advancing to next challange in current block');
|
||||
nextChallengeName =
|
||||
challengeMapWithNames[challengeBlock][indexOfChallenge + 1];
|
||||
} else if (typeof challengeMapWithIds[challengeBlock + 1] !== 'undefined') {
|
||||
nextChallengeName = R.head(challengeMapWithNames[challengeBlock + 1]);
|
||||
nextChallengeId = challengeMapWithIds[challengeBlock][indexOfChallenge + 1];
|
||||
nextChallengeBlock = challengeBlock;
|
||||
} else if (typeof challengeMapWithIds[++challengeBlock] !== 'undefined') {
|
||||
debug('Advancing to next block');
|
||||
nextChallengeName = R.head(challengeMapWithNames[challengeBlock]);
|
||||
nextChallengeId = R.head(challengeMapWithNames[challengeBlock]);
|
||||
nextChallengeBlock = challengeBlock;
|
||||
} else {
|
||||
debug('completed all challenges');
|
||||
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);
|
||||
nextChallengeName = R.head(challengeMapWithNames[0].challenges);
|
||||
nextChallengeId = R.head(challengeMapWithNames[0].challenges);
|
||||
nextChallengeBlock = 0;
|
||||
}
|
||||
var nameString = nextChallengeName.toLowerCase().replace(/\s/g, '-');
|
||||
return res.redirect('../challenges' + nameString);
|
||||
req.user.currentChallenge = {
|
||||
challengeId: nextChallengeId,
|
||||
challengeName: nextChallengeName,
|
||||
challengeBlock: nextChallengeBlock
|
||||
};
|
||||
req.user.save();
|
||||
var nameString = nextChallengeName.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^\w\s]/g, '')
|
||||
.replace(/\s/g, '-')
|
||||
debug('this is the namestring we\'re going to look up', nameString);
|
||||
return res.redirect('../challenges/' + nameString);
|
||||
};
|
||||
|
||||
exports.returnCurrentChallenge = function(req, res, next) {
|
||||
debug('these are the damn keys on challengeMapWithIds...', Object.keys(challengeMapWithIds));
|
||||
debug('sanity check', challengeMapWithIds[0], challengeMapWithIds[1]);
|
||||
if (!req.user) {
|
||||
return res.redirect('../challenges/learn-how-free-code-camp-works');
|
||||
}
|
||||
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();
|
||||
return res.redirect('../challenges/learn-how-free-code-camp-works');
|
||||
}
|
||||
var nameString = req.user.currentChallenge.challengeName.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^\w\s]/g, '')
|
||||
.replace(/\s/g, '-');
|
||||
debug('this is the namestring we\'re going to look up', nameString);
|
||||
return res.redirect('../challenges/' + nameString);
|
||||
};
|
||||
|
||||
exports.returnIndividualChallenge = function(req, res, next) {
|
||||
var dashedName = req.params.challengeName;
|
||||
|
||||
var challengeName = dashedName.replace(/\-/g, ' ');
|
||||
debug('looking for %s', challengeName);
|
||||
|
||||
Challenge.find({'name': new RegExp(challengeName, 'i')},
|
||||
function(err, challengeFromMongo) {
|
||||
@ -84,6 +149,7 @@ exports.returnIndividualChallenge = function(req, res, next) {
|
||||
}
|
||||
// Handle not found
|
||||
if (challengeFromMongo.length < 1) {
|
||||
debug(challengeFromMongo);
|
||||
req.flash('errors', {
|
||||
msg: '404: We couldn\'t find a challenge with that name. ' +
|
||||
'Please double check the name.'
|
||||
@ -91,6 +157,7 @@ exports.returnIndividualChallenge = function(req, res, next) {
|
||||
return res.redirect('/challenges');
|
||||
}
|
||||
var challenge = challengeFromMongo.pop();
|
||||
debug(challenge);
|
||||
|
||||
// Redirect to full name if the user only entered a partial
|
||||
var dashedNameFull = challenge.name.toLowerCase().replace(/\s/g, '-');
|
||||
@ -186,6 +253,148 @@ exports.returnIndividualChallenge = function(req, res, next) {
|
||||
});
|
||||
};
|
||||
|
||||
exports.completedBonfire = function(req, res, next) {
|
||||
|
||||
};
|
||||
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
challengeBlock {
|
||||
0: {
|
||||
|
@ -28,7 +28,8 @@ var async = require('async'),
|
||||
*/
|
||||
var allBonfireIds, allBonfireNames, allCoursewareIds, allCoursewareNames,
|
||||
allFieldGuideIds, allFieldGuideNames, allNonprofitNames,
|
||||
allBonfireIndexesAndNames, challengeMap;
|
||||
allBonfireIndexesAndNames, challengeMap, challengeMapWithIds,
|
||||
challengeMapWithNames, allChallengeIds;
|
||||
|
||||
/**
|
||||
* GET /
|
||||
@ -46,55 +47,73 @@ Array.zip = function(left, right, combinerFunction) {
|
||||
return results;
|
||||
};
|
||||
|
||||
buildChallengeMap = function() {
|
||||
challengeMap = {};
|
||||
fs.readdir(__dirname + '../seed_data/challenges', function(err, files) {
|
||||
if (err) {
|
||||
debug(err);
|
||||
} else {
|
||||
(function() {
|
||||
if (!challengeMap) {
|
||||
var localChallengeMap = {};
|
||||
var files = fs.readdirSync(__dirname + '/../seed_data/challenges');
|
||||
var keyCounter = 0;
|
||||
files = files.sort(function(a, b) {
|
||||
return a.order < b.order ? a : b;
|
||||
files = files.map(function (file) {
|
||||
return require(__dirname +
|
||||
'/../seed_data/challenges/' + file);
|
||||
});
|
||||
files.forEach(function(file) {
|
||||
challengeMap[keyCounter++] = 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() {
|
||||
// TODO finish this
|
||||
if (challengeMap === null) {
|
||||
buildChallengeMap();
|
||||
}
|
||||
var challengeMapWithIds = {};
|
||||
Object.keys(challengeMap).
|
||||
forEach(function(key) {
|
||||
var onlyIds = challengeMap[key].challenges.map(function(elem) {
|
||||
return elem.challengeId;
|
||||
if (challengeMapWithIds) {
|
||||
return challengeMapWithIds;
|
||||
} else {
|
||||
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) {
|
||||
return allChallengeIds;
|
||||
} else {
|
||||
allChallengeIds = [];
|
||||
Object.keys(challengeMapWithIds).forEach(function(key) {
|
||||
allChallengeIds.push(challengeMapWithIds[key].challenges);
|
||||
});
|
||||
allChallengeIds = R.flatten(allChallengeIds);
|
||||
}
|
||||
return allChallengeIds;
|
||||
},
|
||||
|
||||
getChallengeMapWithNames: function() {
|
||||
var challengeMapWithNames = {};
|
||||
if (challengeMapWithNames) {
|
||||
return challengeMapWithNames;
|
||||
} else {
|
||||
challengeMapWithNames = {};
|
||||
Object.keys(challengeMap).
|
||||
forEach(function(key) {
|
||||
var onlyNames = challengeMap[key].challenges.map(function(elem) {
|
||||
return elem.challengeName;
|
||||
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');
|
||||
|
@ -150,7 +150,19 @@ var userSchema = new mongoose.Schema({
|
||||
finishedWaypoints: { type: Boolean, default: false },
|
||||
sendMonthlyEmail: { type: Boolean, default: true },
|
||||
challengesHash: {},
|
||||
currentChallenge: {}
|
||||
currentChallenge: {},
|
||||
completedChallenges: [
|
||||
{
|
||||
completedDate: Long,
|
||||
_id: String,
|
||||
name: String,
|
||||
completedWith: String,
|
||||
solution: String,
|
||||
githubLink: String,
|
||||
verified: Boolean
|
||||
}
|
||||
],
|
||||
uncompletedChallenges: Array
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -56,9 +56,9 @@ var codeOutput = CodeMirror.fromTextArea(document.getElementById("codeOutput"),
|
||||
});
|
||||
|
||||
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' +
|
||||
' */');
|
||||
' * 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;
|
||||
|
@ -127,16 +127,16 @@ $(document).ready(function() {
|
||||
case 1:
|
||||
case 2:
|
||||
$.post(
|
||||
'/completed-courseware/',
|
||||
'/completed-challenge/',
|
||||
{
|
||||
coursewareInfo: {
|
||||
coursewareHash: passedCoursewareHash,
|
||||
coursewareName: passedCoursewareName
|
||||
challengeInfo: {
|
||||
challengeId: challengeId,
|
||||
challengeName: challengeName
|
||||
}
|
||||
}).success(
|
||||
function(res) {
|
||||
if (res) {
|
||||
window.location.href = '/challenges';
|
||||
window.location.href = '/challenges/next-challenge';
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -147,16 +147,16 @@ $(document).ready(function() {
|
||||
$.post(
|
||||
'/completed-zipline-or-basejump/',
|
||||
{
|
||||
coursewareInfo: {
|
||||
coursewareHash: passedCoursewareHash,
|
||||
coursewareName: passedCoursewareName,
|
||||
challengeInfo: {
|
||||
challengeId: challengeId,
|
||||
challengeName: challengeName,
|
||||
completedWith: didCompleteWith,
|
||||
publicURL: publicURL,
|
||||
challengeType: challengeType
|
||||
}
|
||||
}).success(
|
||||
function() {
|
||||
window.location.href = '/challenges';
|
||||
window.location.href = '/challenges/next-challenge';
|
||||
}).fail(
|
||||
function() {
|
||||
window.location.href = '/challenges';
|
||||
@ -169,9 +169,9 @@ $(document).ready(function() {
|
||||
$.post(
|
||||
'/completed-zipline-or-basejump/',
|
||||
{
|
||||
coursewareInfo: {
|
||||
coursewareHash: passedCoursewareHash,
|
||||
coursewareName: passedCoursewareName,
|
||||
challengeInfo: {
|
||||
challengeId: challengeId,
|
||||
challengeName: challengeName,
|
||||
completedWith: didCompleteWith,
|
||||
publicURL: publicURL,
|
||||
githubURL: githubURL,
|
||||
@ -179,7 +179,7 @@ $(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);
|
||||
});
|
||||
|
@ -20,7 +20,8 @@
|
||||
],
|
||||
"challengeSeed": [
|
||||
"<h1>Hello</h1>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf0887a",
|
||||
@ -38,7 +39,8 @@
|
||||
],
|
||||
"challengeSeed": [
|
||||
"<h1>Hello World</h1>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08801",
|
||||
@ -55,7 +57,8 @@
|
||||
"challengeSeed": [
|
||||
"<h1>Hello World</h1>",
|
||||
"<h2>CatPhotoApp</h2>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aeaf08801",
|
||||
@ -74,7 +77,8 @@
|
||||
"<h1>Hello World</h1>",
|
||||
"<h2>CatPhotoApp</h2>",
|
||||
"<p>Hello Paragraph</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08802",
|
||||
@ -101,7 +105,8 @@
|
||||
"",
|
||||
"<p>Hello Paragraph</p>",
|
||||
"-->"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08804",
|
||||
@ -127,7 +132,8 @@
|
||||
"",
|
||||
"<p>Hello Paragraph</p>",
|
||||
"-->"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08833",
|
||||
@ -151,7 +157,8 @@
|
||||
"<br/>",
|
||||
"",
|
||||
"<p>Hello Paragraph</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fed1348bd9aedf08833",
|
||||
@ -176,7 +183,8 @@
|
||||
"<br/>",
|
||||
"",
|
||||
"<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08803",
|
||||
@ -195,7 +203,8 @@
|
||||
"<h2>CatPhotoApp</h2>",
|
||||
"",
|
||||
"<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08805",
|
||||
@ -218,7 +227,8 @@
|
||||
"<h2 style='color: red'>CatPhotoApp</h2>",
|
||||
"",
|
||||
"<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aecf08806",
|
||||
@ -248,7 +258,8 @@
|
||||
"<h2>CatPhotoApp</h2>",
|
||||
"",
|
||||
"<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aefe08806",
|
||||
@ -274,7 +285,8 @@
|
||||
"<h2 class='red-text'>CatPhotoApp</h2>",
|
||||
"",
|
||||
"<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08806",
|
||||
@ -300,7 +312,8 @@
|
||||
"<h2 class='red-text'>CatPhotoApp</h2>",
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aede08807",
|
||||
@ -329,7 +342,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08807",
|
||||
@ -361,7 +375,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08808",
|
||||
@ -399,7 +414,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08809",
|
||||
@ -440,7 +456,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -478,7 +495,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9acdf08812",
|
||||
@ -516,7 +534,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9bedf08813",
|
||||
@ -559,7 +578,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08814",
|
||||
@ -607,7 +627,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08815",
|
||||
@ -654,7 +675,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08816",
|
||||
@ -704,7 +726,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aede08817",
|
||||
@ -757,7 +780,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -809,7 +833,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08820",
|
||||
@ -861,7 +886,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"_id": "bad87fee1348bd9aedf08818",
|
||||
@ -913,7 +939,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -966,7 +993,8 @@
|
||||
"",
|
||||
"<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>",
|
||||
"<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -1025,7 +1053,8 @@
|
||||
" <li>laser pointers</li>",
|
||||
" <li>lasagna</li>",
|
||||
"</ul>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -1086,7 +1115,8 @@
|
||||
" <li>thunder</li>",
|
||||
" <li>other cats</li>",
|
||||
"</ol>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -1148,7 +1178,8 @@
|
||||
" <li>other cats</li>",
|
||||
"</ol>",
|
||||
"<input type='text'>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -1211,7 +1242,8 @@
|
||||
" <li>other cats</li>",
|
||||
"</ol>",
|
||||
"<input type='text' placeholder='cat photo URL'>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -1275,7 +1307,8 @@
|
||||
"<form action=\"/submit-cat-photo\">",
|
||||
" <input type='text' placeholder='cat photo URL'>",
|
||||
"</form>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -1411,7 +1444,8 @@
|
||||
" <input type='text' placeholder='cat photo URL' required>",
|
||||
" <button type='submit'>Submit</button>",
|
||||
"</form>"
|
||||
]
|
||||
],
|
||||
"challengeType": 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -1479,7 +1513,8 @@
|
||||
" <input type='text' placeholder='cat photo URL' required>",
|
||||
" <button type='submit'>Submit</button>",
|
||||
"</form>"
|
||||
]
|
||||
],
|
||||
"challengeType" : 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -1548,7 +1583,8 @@
|
||||
" <input type='text' placeholder='cat photo URL' required>",
|
||||
" <button type='submit'>Submit</button>",
|
||||
"</form>"
|
||||
]
|
||||
],
|
||||
"challengeType" : 0
|
||||
},
|
||||
|
||||
{
|
||||
@ -1620,7 +1656,8 @@
|
||||
" <input type='text' placeholder='cat photo URL' required>",
|
||||
" <button type='submit'>Submit</button>",
|
||||
"</form>"
|
||||
]
|
||||
],
|
||||
"challengeType" : 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -32,11 +32,12 @@ Challenge.remove({}, function(err, data) {
|
||||
console.log('Deleted ', data);
|
||||
}
|
||||
challenges.forEach(function (file) {
|
||||
Challenge.create(require('./challenges/' + file), function (err, data) {
|
||||
Challenge.create(require('./challenges/' + file).challenges, function (err, data) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log('Successfully parsed %s', file);
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -29,9 +29,8 @@ block content
|
||||
.button-spacer
|
||||
script(type="text/javascript").
|
||||
var tests = !{JSON.stringify(tests)};
|
||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
||||
var challengeId = !{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) {
|
||||
|
@ -15,7 +15,7 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height
|
||||
|
||||
if user
|
||||
li
|
||||
a(href='/challenges') Next Challenge
|
||||
a(href='/challenges') Current Challenge
|
||||
li
|
||||
a(href='/map') Map
|
||||
if (user && user.sentSlackInvite)
|
||||
|
Reference in New Issue
Block a user