Update views for new variable names. Get profile view working. Update challenge map.
This commit is contained in:
27
app.js
27
app.js
@ -494,35 +494,12 @@ app.get('/api/codepen/twitter/:screenName', resourcesController.codepenResources
|
|||||||
/**
|
/**
|
||||||
* Bonfire related routes
|
* Bonfire related routes
|
||||||
*/
|
*/
|
||||||
|
app.post('/completed-bonfire/', challengeController.completedBonfire);
|
||||||
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
|
* Field Guide related routes
|
||||||
*/
|
*/
|
||||||
|
app.get('/field-guide/getFieldGuideList', fieldGuideController.showAllFieldGuides);
|
||||||
|
|
||||||
|
|
||||||
app.get('/field-guide/:fieldGuideName',
|
app.get('/field-guide/:fieldGuideName',
|
||||||
|
@ -26,10 +26,23 @@ var debug = require('debug')('freecc:cntr:courseware'),
|
|||||||
var challengeMapWithNames = resources.getChallengeMapWithNames();
|
var challengeMapWithNames = resources.getChallengeMapWithNames();
|
||||||
var challengeMapWithIds = resources.getChallengeMapWithIds();
|
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, index) {
|
||||||
|
populatedLinks.push(MDNlinks[value]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return populatedLinks;
|
||||||
|
}
|
||||||
|
|
||||||
exports.showAllChallenges = function(req, res) {
|
exports.showAllChallenges = function(req, res) {
|
||||||
var completedList = [];
|
var completedList = [];
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
completedList = req.user.completedCoursewares.map(function (elem) {
|
completedList = req.user.completedChallenges.map(function (elem) {
|
||||||
return elem._id;
|
return elem._id;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -150,7 +163,6 @@ exports.returnIndividualChallenge = function(req, res, next) {
|
|||||||
return res.redirect('/challenges');
|
return res.redirect('/challenges');
|
||||||
}
|
}
|
||||||
var challenge = challengeFromMongo.pop();
|
var challenge = challengeFromMongo.pop();
|
||||||
|
|
||||||
// Redirect to full name if the user only entered a partial
|
// Redirect to full name if the user only entered a partial
|
||||||
var dashedNameFull = challenge.name.toLowerCase().replace(/\s/g, '-');
|
var dashedNameFull = challenge.name.toLowerCase().replace(/\s/g, '-');
|
||||||
if (dashedNameFull !== dashedName) {
|
if (dashedNameFull !== dashedName) {
|
||||||
@ -256,7 +268,25 @@ exports.returnIndividualChallenge = function(req, res, next) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
5: function() {
|
5: function() {
|
||||||
// bonfire
|
res.render('bonfire/show', {
|
||||||
|
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
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -265,8 +295,97 @@ exports.returnIndividualChallenge = function(req, res, next) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.completedBonfire = function(req, res, next) {
|
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);
|
||||||
|
debug('This is the index', index);
|
||||||
|
if (index > -1) {
|
||||||
|
req.user.progressTimestamps.push(Date.now() || 0);
|
||||||
|
req.user.uncompletedChallenges.splice(index, 1);
|
||||||
|
}
|
||||||
|
pairedWith = pairedWith.pop();
|
||||||
|
|
||||||
|
index = pairedWith.uncompletedChallenges.indexOf(challengeId);
|
||||||
|
debug('This is the index of the search for bonfire', index);
|
||||||
|
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);
|
||||||
|
debug('this is the challengeId we got', challengeId);
|
||||||
|
debug('This is the index of the search for bonfire', index);
|
||||||
|
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.send(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.completedChallenge = function (req, res, next) {
|
exports.completedChallenge = function (req, res, next) {
|
||||||
@ -274,7 +393,6 @@ exports.completedChallenge = function (req, res, next) {
|
|||||||
var isCompletedDate = Math.round(+new Date());
|
var isCompletedDate = Math.round(+new Date());
|
||||||
var challengeId = req.body.challengeInfo.challengeId;
|
var challengeId = req.body.challengeInfo.challengeId;
|
||||||
|
|
||||||
|
|
||||||
req.user.completedChallenges.push({
|
req.user.completedChallenges.push({
|
||||||
_id: challengeId,
|
_id: challengeId,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
@ -302,12 +420,12 @@ exports.completedChallenge = function (req, res, next) {
|
|||||||
|
|
||||||
exports.completedZiplineOrBasejump = function (req, res, next) {
|
exports.completedZiplineOrBasejump = function (req, res, next) {
|
||||||
|
|
||||||
var isCompletedWith = req.body.coursewareInfo.completedWith || false;
|
var isCompletedWith = req.body.challengeInfo.completedWith || false;
|
||||||
var isCompletedDate = Math.round(+new Date());
|
var isCompletedDate = Math.round(+new Date());
|
||||||
var coursewareHash = req.body.coursewareInfo.coursewareHash;
|
var challengeId = req.body.challengeInfo.challengeId;
|
||||||
var solutionLink = req.body.coursewareInfo.publicURL;
|
var solutionLink = req.body.challengeInfo.publicURL;
|
||||||
var githubLink = req.body.coursewareInfo.challengeType === '4'
|
var githubLink = req.body.challengeInfo.challengeType === '4'
|
||||||
? req.body.coursewareInfo.githubURL : true;
|
? req.body.challengeInfo.githubURL : true;
|
||||||
if (!solutionLink || !githubLink) {
|
if (!solutionLink || !githubLink) {
|
||||||
req.flash('errors', {
|
req.flash('errors', {
|
||||||
msg: 'You haven\'t supplied the necessary URLs for us to inspect ' +
|
msg: 'You haven\'t supplied the necessary URLs for us to inspect ' +
|
||||||
@ -322,16 +440,16 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
} else {
|
} else {
|
||||||
var index = req.user.uncompletedCoursewares.indexOf(coursewareHash);
|
var index = req.user.uncompletedChallenges.indexOf(challengeId);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
req.user.progressTimestamps.push(Date.now() || 0);
|
req.user.progressTimestamps.push(Date.now() || 0);
|
||||||
req.user.uncompletedCoursewares.splice(index, 1);
|
req.user.uncompletedChallenges.splice(index, 1);
|
||||||
}
|
}
|
||||||
var pairedWith = pairedWithFromMongo.pop();
|
var pairedWith = pairedWithFromMongo.pop();
|
||||||
|
|
||||||
req.user.completedCoursewares.push({
|
req.user.completedChallenges.push({
|
||||||
_id: coursewareHash,
|
_id: challengeId,
|
||||||
name: req.body.coursewareInfo.coursewareName,
|
name: req.body.challengeInfo.coursewareName,
|
||||||
completedWith: pairedWith._id,
|
completedWith: pairedWith._id,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: solutionLink,
|
solution: solutionLink,
|
||||||
@ -347,16 +465,16 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
if (req.user._id.toString() === pairedWith._id.toString()) {
|
if (req.user._id.toString() === pairedWith._id.toString()) {
|
||||||
return res.sendStatus(200);
|
return res.sendStatus(200);
|
||||||
}
|
}
|
||||||
index = pairedWith.uncompletedCoursewares.indexOf(coursewareHash);
|
index = pairedWith.uncompletedChallenges.indexOf(challengeId);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
pairedWith.progressTimestamps.push(Date.now() || 0);
|
pairedWith.progressTimestamps.push(Date.now() || 0);
|
||||||
pairedWith.uncompletedCoursewares.splice(index, 1);
|
pairedWith.uncompletedChallenges.splice(index, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pairedWith.completedCoursewares.push({
|
pairedWith.completedChallenges.push({
|
||||||
_id: coursewareHash,
|
_id: challengeId,
|
||||||
name: req.body.coursewareInfo.coursewareName,
|
name: req.body.challengeInfo.coursewareName,
|
||||||
completedWith: req.user._id,
|
completedWith: req.user._id,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: solutionLink,
|
solution: solutionLink,
|
||||||
@ -376,9 +494,9 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
req.user.completedCoursewares.push({
|
req.user.completedChallenges.push({
|
||||||
_id: coursewareHash,
|
_id: challengeId,
|
||||||
name: req.body.coursewareInfo.coursewareName,
|
name: req.body.challengeInfo.challengeName,
|
||||||
completedWith: null,
|
completedWith: null,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: solutionLink,
|
solution: solutionLink,
|
||||||
@ -386,10 +504,10 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
verified: false
|
verified: false
|
||||||
});
|
});
|
||||||
|
|
||||||
var index = req.user.uncompletedCoursewares.indexOf(coursewareHash);
|
var index = req.user.uncompletedChallenges.indexOf(challengeId);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
req.user.progressTimestamps.push(Date.now() || 0);
|
req.user.progressTimestamps.push(Date.now() || 0);
|
||||||
req.user.uncompletedCoursewares.splice(index, 1);
|
req.user.uncompletedChallenges.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
req.user.save(function (err, user) {
|
req.user.save(function (err, user) {
|
||||||
@ -402,23 +520,3 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
challengeBlock {
|
|
||||||
0: {
|
|
||||||
"name": "basic_html",
|
|
||||||
"challenges: []
|
|
||||||
},
|
|
||||||
1: {
|
|
||||||
"name": "basic_css",
|
|
||||||
"challenges": [],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
currentChallenge{
|
|
||||||
"challengeBlock": number,
|
|
||||||
"challengeId": _id,
|
|
||||||
"challengeName": string
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
@ -27,33 +27,15 @@ var challengeTypes = {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
challengeMap: function challengeMap(req, res) {
|
challengeMap: function challengeMap(req, res) {
|
||||||
var completedBonfires = [];
|
|
||||||
var completedList = [];
|
var completedList = [];
|
||||||
|
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
completedBonfires = req.user.completedChallenges
|
completedList = req.user.completedChallenges;
|
||||||
.filter(function (elem) {
|
|
||||||
return elem.challengeType === challengeTypes.BONFIRE;
|
|
||||||
})
|
|
||||||
.map(function(elem) {
|
|
||||||
return elem._id;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.user) {
|
|
||||||
completedList = req.user.completedChallenges
|
|
||||||
.filter(function (elem) {
|
|
||||||
return elem.challengeType !== challengeTypes.BONFIRE;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var noDuplicateBonfires = R.uniq(completedBonfires);
|
|
||||||
var noDuplicatedChallenges = R.uniq(completedList);
|
var noDuplicatedChallenges = R.uniq(completedList);
|
||||||
|
|
||||||
var completedBonfireList = noDuplicateBonfires
|
|
||||||
.map(function(bonfire) {
|
|
||||||
return bonfire._id;
|
|
||||||
});
|
|
||||||
var challengeList = resources.allChallenges();
|
var challengeList = resources.allChallenges();
|
||||||
var completedChallengeList = noDuplicatedChallenges
|
var completedChallengeList = noDuplicatedChallenges
|
||||||
.map(function(challenge) {
|
.map(function(challenge) {
|
||||||
@ -120,7 +102,6 @@ module.exports = {
|
|||||||
debug('User err: ', err);
|
debug('User err: ', err);
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
debug('Data for render is: ', completedBonfireList, completedChallengeList);
|
|
||||||
res.render('challengeMap/show', {
|
res.render('challengeMap/show', {
|
||||||
daysRunning: daysRunning,
|
daysRunning: daysRunning,
|
||||||
camperCount: numberWithCommas(camperCount),
|
camperCount: numberWithCommas(camperCount),
|
||||||
@ -129,7 +110,6 @@ module.exports = {
|
|||||||
waypoints: waypoints,
|
waypoints: waypoints,
|
||||||
ziplines: ziplines,
|
ziplines: ziplines,
|
||||||
basejumps: basejumps,
|
basejumps: basejumps,
|
||||||
completedBonfireList: completedBonfireList,
|
|
||||||
completedChallengeList: completedChallengeList
|
completedChallengeList: completedChallengeList
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -373,7 +373,9 @@ exports.returnUser = function(req, res, next) {
|
|||||||
website3Title: user.portfolio.website3Title,
|
website3Title: user.portfolio.website3Title,
|
||||||
website3Image: user.portfolio.website3Image,
|
website3Image: user.portfolio.website3Image,
|
||||||
challenges: challenges,
|
challenges: challenges,
|
||||||
bonfires: user.completedBonfires,
|
bonfires: user.completedChallenges.filter(function(challenge) {
|
||||||
|
return challenge.challengeType === 5;
|
||||||
|
}),
|
||||||
calender: data,
|
calender: data,
|
||||||
moment: moment,
|
moment: moment,
|
||||||
longestStreak: user.longestStreak + (user.longestStreak === 1 ? " day" : " days"),
|
longestStreak: user.longestStreak + (user.longestStreak === 1 ? " day" : " days"),
|
||||||
|
@ -124,7 +124,10 @@ var userSchema = new mongoose.Schema({
|
|||||||
uncompletedCoursewares: Array,
|
uncompletedCoursewares: Array,
|
||||||
completedCoursewares: [
|
completedCoursewares: [
|
||||||
{
|
{
|
||||||
completedDate: Long,
|
completedDate: {
|
||||||
|
type: Long,
|
||||||
|
default: Date.now()
|
||||||
|
},
|
||||||
_id: String,
|
_id: String,
|
||||||
name: String,
|
name: String,
|
||||||
completedWith: String,
|
completedWith: String,
|
||||||
@ -159,7 +162,11 @@ var userSchema = new mongoose.Schema({
|
|||||||
completedWith: String,
|
completedWith: String,
|
||||||
solution: String,
|
solution: String,
|
||||||
githubLink: String,
|
githubLink: String,
|
||||||
verified: Boolean
|
verified: Boolean,
|
||||||
|
challengeType: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
uncompletedChallenges: Array
|
uncompletedChallenges: Array
|
||||||
|
@ -64,18 +64,19 @@ var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local
|
|||||||
if (info.top + info.clientHeight < after)
|
if (info.top + info.clientHeight < after)
|
||||||
editor.scrollTo(null, after - info.clientHeight + 3);
|
editor.scrollTo(null, after - info.clientHeight + 3);
|
||||||
|
|
||||||
|
|
||||||
var editorValue;
|
var editorValue;
|
||||||
|
|
||||||
|
|
||||||
var challengeSeed = challengeSeed || null;
|
var challengeSeed = challengeSeed || null;
|
||||||
var tests = tests || [];
|
var tests = tests || [];
|
||||||
|
|
||||||
|
var allSeeds = '';
|
||||||
if (challengeSeed !== null) {
|
(function() {
|
||||||
editorValue = challengeSeed;
|
challengeSeed.forEach(function(elem) {
|
||||||
} else {
|
allSeeds += elem + '\n';
|
||||||
editorValue = nonChallengeValue;
|
});
|
||||||
}
|
})();
|
||||||
|
|
||||||
|
|
||||||
myCodeMirror.setValue(editorValue);
|
myCodeMirror.setValue(editorValue);
|
||||||
|
@ -139,7 +139,7 @@ function doLinting () {
|
|||||||
//$('#testSuite').empty();
|
//$('#testSuite').empty();
|
||||||
function showCompletion() {
|
function showCompletion() {
|
||||||
var time = Math.floor(Date.now()) - started;
|
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').removeAttr('disabled');
|
||||||
$('#next-courseware-button').addClass('animated tada');
|
$('#next-courseware-button').addClass('animated tada');
|
||||||
if (!userLoggedIn) {
|
if (!userLoggedIn) {
|
||||||
|
@ -112,7 +112,7 @@ $('#submitButton').on('click', function () {
|
|||||||
|
|
||||||
function bonfireExecute() {
|
function bonfireExecute() {
|
||||||
attempts++;
|
attempts++;
|
||||||
ga('send', 'event', 'Challenge', 'ran-code', challengeName);
|
ga('send', 'event', 'Challenge', 'ran-code', challenge_Name);
|
||||||
userTests= null;
|
userTests= null;
|
||||||
$('#codeOutput').empty();
|
$('#codeOutput').empty();
|
||||||
var userJavaScript = myCodeMirror.getValue();
|
var userJavaScript = myCodeMirror.getValue();
|
||||||
@ -193,6 +193,8 @@ var createTestDisplay = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var expect = chai.expect;
|
var expect = chai.expect;
|
||||||
|
var assert = chai.assert;
|
||||||
|
var should = chai.should;
|
||||||
|
|
||||||
|
|
||||||
var reassembleTest = function(test, data) {
|
var reassembleTest = function(test, data) {
|
||||||
@ -236,7 +238,7 @@ var runTests = function(err, data) {
|
|||||||
|
|
||||||
function showCompletion() {
|
function showCompletion() {
|
||||||
var time = Math.floor(Date.now()) - started;
|
var time = Math.floor(Date.now()) - started;
|
||||||
ga('send', 'event', 'Challenge', 'solved', challengeName + ', Time: ' + time +', Attempts: ' + attempts);
|
ga('send', 'event', 'Challenge', 'solved', challenge_Name + ', Time: ' + time +', Attempts: ' + attempts);
|
||||||
$('#complete-courseware-dialog').modal('show');
|
$('#complete-courseware-dialog').modal('show');
|
||||||
$('#complete-courseware-dialog').keydown(function(e) {
|
$('#complete-courseware-dialog').keydown(function(e) {
|
||||||
if (e.ctrlKey && e.keyCode == 13) {
|
if (e.ctrlKey && e.keyCode == 13) {
|
@ -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) {
|
function completedFieldGuide(fieldGuideId) {
|
||||||
if ($('.signup-btn-nav').length < 1) {
|
if ($('.signup-btn-nav').length < 1) {
|
||||||
$.post(
|
$.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() {
|
$('.next-field-guide-button').on('click', function() {
|
||||||
var fieldGuideId = $('#fieldGuideId').text();
|
var fieldGuideId = $('#fieldGuideId').text();
|
||||||
completedFieldGuide(fieldGuideId);
|
completedFieldGuide(fieldGuideId);
|
||||||
@ -112,26 +81,30 @@ $(document).ready(function() {
|
|||||||
$('#complete-zipline-or-basejump-dialog').modal('show');
|
$('#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() {
|
$('#complete-courseware-dialog').on('hidden.bs.modal', function() {
|
||||||
editor.focus();
|
editor.focus();
|
||||||
});
|
});
|
||||||
|
var challengeTypes = {
|
||||||
|
'HTML_CSS_JQ': 0,
|
||||||
|
'JAVASCRIPT': 1,
|
||||||
|
'VIDEO': 2,
|
||||||
|
'ZIPLINE': 3,
|
||||||
|
'BASEJUMP': 4,
|
||||||
|
'BONFIRE': 5
|
||||||
|
};
|
||||||
$('#next-courseware-button').on('click', function() {
|
$('#next-courseware-button').on('click', function() {
|
||||||
if ($('.signup-btn-nav').length < 1) {
|
if ($('.signup-btn-nav').length < 1) {
|
||||||
switch (challengeType) {
|
switch (challengeType) {
|
||||||
case 0:
|
case challengeTypes.HTML_CSS_JQ:
|
||||||
case 1:
|
case challengeTypes.JAVASCRIPT:
|
||||||
case 2:
|
case challengeTypes.VIDEO:
|
||||||
|
console.log(challenge_Id);
|
||||||
$.post(
|
$.post(
|
||||||
'/completed-challenge/',
|
'/completed-challenge/',
|
||||||
{
|
{
|
||||||
challengeInfo: {
|
challengeInfo: {
|
||||||
challengeId: challengeId,
|
challengeId: challenge_Id,
|
||||||
challengeName: challengeName
|
challengeName: challenge_Name
|
||||||
}
|
}
|
||||||
}).success(
|
}).success(
|
||||||
function(res) {
|
function(res) {
|
||||||
@ -141,15 +114,15 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case challengeTypes.ZIPLINE:
|
||||||
var didCompleteWith = $('#completed-with').val() || null;
|
var didCompleteWith = $('#completed-with').val() || null;
|
||||||
var publicURL = $('#public-url').val() || null;
|
var publicURL = $('#public-url').val() || null;
|
||||||
$.post(
|
$.post(
|
||||||
'/completed-zipline-or-basejump/',
|
'/completed-zipline-or-basejump/',
|
||||||
{
|
{
|
||||||
challengeInfo: {
|
challengeInfo: {
|
||||||
challengeId: challengeId,
|
challengeId: challenge_Id,
|
||||||
challengeName: challengeName,
|
challengeName: challenge_Name,
|
||||||
completedWith: didCompleteWith,
|
completedWith: didCompleteWith,
|
||||||
publicURL: publicURL,
|
publicURL: publicURL,
|
||||||
challengeType: challengeType
|
challengeType: challengeType
|
||||||
@ -162,7 +135,7 @@ $(document).ready(function() {
|
|||||||
window.location.href = '/challenges';
|
window.location.href = '/challenges';
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 4:
|
case challengeTypes.BASEJUMP:
|
||||||
var didCompleteWith = $('#completed-with').val() || null;
|
var didCompleteWith = $('#completed-with').val() || null;
|
||||||
var publicURL = $('#public-url').val() || null;
|
var publicURL = $('#public-url').val() || null;
|
||||||
var githubURL = $('#github-url').val() || null;
|
var githubURL = $('#github-url').val() || null;
|
||||||
@ -170,8 +143,8 @@ $(document).ready(function() {
|
|||||||
'/completed-zipline-or-basejump/',
|
'/completed-zipline-or-basejump/',
|
||||||
{
|
{
|
||||||
challengeInfo: {
|
challengeInfo: {
|
||||||
challengeId: challengeId,
|
challengeId: challenge_Id,
|
||||||
challengeName: challengeName,
|
challengeName: challenge_Name,
|
||||||
completedWith: didCompleteWith,
|
completedWith: didCompleteWith,
|
||||||
publicURL: publicURL,
|
publicURL: publicURL,
|
||||||
githubURL: githubURL,
|
githubURL: githubURL,
|
||||||
@ -184,6 +157,26 @@ $(document).ready(function() {
|
|||||||
window.location.replace(window.location.href);
|
window.location.replace(window.location.href);
|
||||||
});
|
});
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ block content
|
|||||||
for bonfire in bonfires
|
for bonfire in bonfires
|
||||||
tr
|
tr
|
||||||
td.col-xs-4
|
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-2= moment(bonfire.completedDate, 'x').format("MMM DD, YYYY")
|
||||||
td.col-xs-6
|
td.col-xs-6
|
||||||
pre.wrappable= bonfire.solution
|
pre.wrappable= bonfire.solution
|
||||||
|
@ -93,9 +93,10 @@ block content
|
|||||||
script(type="text/javascript").
|
script(type="text/javascript").
|
||||||
var tests = !{JSON.stringify(tests)};
|
var tests = !{JSON.stringify(tests)};
|
||||||
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
||||||
var passedBonfireHash = !{JSON.stringify(bonfireHash)};
|
var challenge_Id = !{JSON.stringify(challengeId)};
|
||||||
var challengeName = !{JSON.stringify(name)};
|
var challenge_Name = !{JSON.stringify(name)};
|
||||||
var started = Math.floor(Date.now());
|
var started = Math.floor(Date.now());
|
||||||
|
var challengeType = !{JSON.stringify(challengeType)};
|
||||||
var _ = R;
|
var _ = R;
|
||||||
var dashed = !{JSON.stringify(dashedName)};
|
var dashed = !{JSON.stringify(dashedName)};
|
||||||
|
|
||||||
@ -104,11 +105,11 @@ block content
|
|||||||
form.code
|
form.code
|
||||||
.form-group.codeMirrorView
|
.form-group.codeMirrorView
|
||||||
textarea#codeEditor(autofocus=true, style='display: none;')
|
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-dialog.animated.zoomIn.fast-animation
|
||||||
.modal-content
|
.modal-content
|
||||||
.modal-header.challenge-list-header= compliment
|
.modal-header.challenge-list-header= compliment
|
||||||
@ -129,11 +130,11 @@ block content
|
|||||||
span.ion-close-circled
|
span.ion-close-circled
|
||||||
| Username not found
|
| 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)
|
- 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  
|
i.fa.fa-twitter  
|
||||||
= phrase
|
= phrase
|
||||||
- else
|
- else
|
||||||
|
@ -5,7 +5,6 @@ block content
|
|||||||
var waypointList = !{JSON.stringify(waypoints)};
|
var waypointList = !{JSON.stringify(waypoints)};
|
||||||
var ziplineList = !{JSON.stringify(ziplines)};
|
var ziplineList = !{JSON.stringify(ziplines)};
|
||||||
var basejumpList = !{JSON.stringify(basejumps)};
|
var basejumpList = !{JSON.stringify(basejumps)};
|
||||||
var completedBonfires = !{JSON.stringify(completedBonfireList)};
|
|
||||||
var completedChallenges = !{JSON.stringify(completedChallengeList)};
|
var completedChallenges = !{JSON.stringify(completedChallengeList)};
|
||||||
.panel.panel-info
|
.panel.panel-info
|
||||||
.panel-heading.text-center
|
.panel-heading.text-center
|
||||||
@ -52,19 +51,19 @@ block content
|
|||||||
h3.negative-15
|
h3.negative-15
|
||||||
ol
|
ol
|
||||||
for bonfire in bonfires
|
for bonfire in bonfires
|
||||||
if completedBonfireList.indexOf(bonfire._id) > -1
|
if completedChallengeList.indexOf(bonfire._id) > -1
|
||||||
.row
|
.row
|
||||||
.hidden-xs.col-sm-3.col-md-2.text-primary.ion-checkmark-circled.padded-ionic-icon.text-center
|
.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
|
.col-xs-12.col-sm-9.col-md-10
|
||||||
li.faded
|
li.faded
|
||||||
a(href="/bonfires/#{bonfire.name}")= bonfire.name
|
a(href="/challenges/#{bonfire.name}")= bonfire.name
|
||||||
else
|
else
|
||||||
.row
|
.row
|
||||||
.hidden-xs.col-sm-3.col-md-2
|
.hidden-xs.col-sm-3.col-md-2
|
||||||
span
|
span
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
.col-xs-12.col-sm-9.col-md-10
|
||||||
li
|
li
|
||||||
a(href="/bonfires/#{bonfire.name}")= bonfire.name
|
a(href="/challenges/#{bonfire.name}")= bonfire.name
|
||||||
h2
|
h2
|
||||||
span.fa.fa-angle-double-right
|
span.fa.fa-angle-double-right
|
||||||
| Ziplines (200 hours of front end development)
|
| Ziplines (200 hours of front end development)
|
||||||
|
@ -56,8 +56,8 @@ block content
|
|||||||
$('#next-courseware-button').attr('disabled', 'disabled');
|
$('#next-courseware-button').attr('disabled', 'disabled');
|
||||||
var tests = !{JSON.stringify(tests)};
|
var tests = !{JSON.stringify(tests)};
|
||||||
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
||||||
var challengeId = !{JSON.stringify(challengeId)};
|
var challenge_Id = !{JSON.stringify(challengeId)};
|
||||||
var challengeName = !{JSON.stringify(name)};
|
var challenge_Name = !{JSON.stringify(name)};
|
||||||
var prodOrDev = !{JSON.stringify(environment)};
|
var prodOrDev = !{JSON.stringify(environment)};
|
||||||
var challengeType = !{JSON.stringify(challengeType)};
|
var challengeType = !{JSON.stringify(challengeType)};
|
||||||
var started = Math.floor(Date.now());
|
var started = Math.floor(Date.now());
|
||||||
|
@ -45,8 +45,8 @@ block content
|
|||||||
script(type="text/javascript").
|
script(type="text/javascript").
|
||||||
var tests = !{JSON.stringify(tests)};
|
var tests = !{JSON.stringify(tests)};
|
||||||
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
||||||
var challengeId = !{JSON.stringify(challengeId)};
|
var challenge_Id = !{JSON.stringify(challengeId)};
|
||||||
var challengeName = !{JSON.stringify(name)};
|
var challenge_Name = !{JSON.stringify(name)};
|
||||||
var challengeType = !{JSON.stringify(challengeType)};
|
var challengeType = !{JSON.stringify(challengeType)};
|
||||||
var started = Math.floor(Date.now());
|
var started = Math.floor(Date.now());
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ block content
|
|||||||
form.code
|
form.code
|
||||||
.form-group.codeMirrorView
|
.form-group.codeMirrorView
|
||||||
textarea#codeEditor(autofocus=true, style='display: none;')
|
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')
|
#complete-courseware-dialog.modal(tabindex='-1')
|
||||||
.modal-dialog.animated.zoomIn.fast-animation
|
.modal-dialog.animated.zoomIn.fast-animation
|
||||||
.modal-content
|
.modal-content
|
||||||
|
@ -28,11 +28,7 @@ block content
|
|||||||
br
|
br
|
||||||
.button-spacer
|
.button-spacer
|
||||||
script(type="text/javascript").
|
script(type="text/javascript").
|
||||||
var tests = !{JSON.stringify(tests)};
|
|
||||||
var challengeId = !{JSON.stringify(challengeId)};
|
|
||||||
var challengeName = !{JSON.stringify(name)};
|
|
||||||
var started = Math.floor(Date.now());
|
|
||||||
var challengeType = !{JSON.stringify(challengeType)};
|
|
||||||
var controlEnterHandler = function(e) {
|
var controlEnterHandler = function(e) {
|
||||||
$('body').unbind('keypress');
|
$('body').unbind('keypress');
|
||||||
if (e.ctrlKey && e.keyCode == 13) {
|
if (e.ctrlKey && e.keyCode == 13) {
|
||||||
@ -75,3 +71,7 @@ block content
|
|||||||
h1 #{name}
|
h1 #{name}
|
||||||
script.
|
script.
|
||||||
$('body').bind('keypress', controlEnterHandler);
|
$('body').bind('keypress', controlEnterHandler);
|
||||||
|
script.
|
||||||
|
var challenge_Id = !{JSON.stringify(challengeId)};
|
||||||
|
var challenge_Name = !{JSON.stringify(name)};
|
||||||
|
var challengeType = !{JSON.stringify(challengeType)};
|
@ -32,9 +32,8 @@ block content
|
|||||||
var userLoggedIn = false;
|
var userLoggedIn = false;
|
||||||
br
|
br
|
||||||
script(type="text/javascript").
|
script(type="text/javascript").
|
||||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
var challenge_Id = !{JSON.stringify(challengeId)};
|
||||||
var challengeName = !{JSON.stringify(name)};
|
var challenge_Name = !{JSON.stringify(name)};
|
||||||
var passedCoursewareName = challengeName;
|
|
||||||
var started = Math.floor(Date.now());
|
var started = Math.floor(Date.now());
|
||||||
var challengeType = !{JSON.stringify(challengeType)};
|
var challengeType = !{JSON.stringify(challengeType)};
|
||||||
var controlEnterHandler = function (e) {
|
var controlEnterHandler = function (e) {
|
||||||
|
@ -31,7 +31,7 @@ script(src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js")
|
|||||||
script.
|
script.
|
||||||
window.moment || document.write('<script src="/bower_components/moment/min/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="/js/main.js")
|
||||||
|
|
||||||
script(src="/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.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='/bower_components/font-awesome/css/font-awesome.min.css')
|
||||||
|
|
||||||
link(rel='stylesheet', href='/css/main.css')
|
link(rel='stylesheet', href='/css/main.css')
|
||||||
|
// End **REQUIRED** includes
|
||||||
|
|
||||||
include meta
|
include meta
|
||||||
title #{title} | Free Code Camp
|
title #{title} | Free Code Camp
|
||||||
|
Reference in New Issue
Block a user