Fixed bonfire to allow users to enter contractions
This commit is contained in:
3
app.js
3
app.js
@ -260,6 +260,9 @@ app.get(
|
|||||||
'/bonfires/:bonfireNumber',
|
'/bonfires/:bonfireNumber',
|
||||||
bonfireController.returnIndividualBonfire
|
bonfireController.returnIndividualBonfire
|
||||||
);
|
);
|
||||||
|
app.get('/bonfire', function(req, res) {
|
||||||
|
res.redirect(301, '/playground');
|
||||||
|
});
|
||||||
app.get('/bonfires', bonfireController.returnBonfire);
|
app.get('/bonfires', bonfireController.returnBonfire);
|
||||||
app.get('/bonfire/generator', bonfireController.returnGenerator);
|
app.get('/bonfire/generator', bonfireController.returnGenerator);
|
||||||
app.post('/bonfire/generator', bonfireController.generateChallenge);
|
app.post('/bonfire/generator', bonfireController.generateChallenge);
|
||||||
|
@ -12,7 +12,23 @@ var highestBonfireNumber = 2;
|
|||||||
|
|
||||||
exports.index = function(req, res) {
|
exports.index = function(req, res) {
|
||||||
res.render('bonfire/bonfire.jade', {
|
res.render('bonfire/bonfire.jade', {
|
||||||
title: 'Learn to code with Bonfire'
|
title: 'Learn to code with Bonfire',
|
||||||
|
completedWith: null,
|
||||||
|
title: null,
|
||||||
|
difficulty: null,
|
||||||
|
brief: null,
|
||||||
|
details: null,
|
||||||
|
tests: null,
|
||||||
|
challengeSeed: null,
|
||||||
|
challengeEntryPoint: null,
|
||||||
|
cc: req.user ? req.user.bonfiresHash : undefined,
|
||||||
|
points: req.user ? req.user.points : undefined,
|
||||||
|
verb: resources.randomVerb(),
|
||||||
|
phrase: resources.randomPhrase(),
|
||||||
|
compliment: resources.randomCompliment(),
|
||||||
|
bonfires: [],
|
||||||
|
bonfireHash: "test"
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Bonfire.find({}, null, { sort: { difficulty: 1 } }, function(err, c) {
|
Bonfire.find({}, null, { sort: { difficulty: 1 } }, function(err, c) {
|
||||||
|
@ -123,11 +123,6 @@ function bonfireExecute() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var replaceQuotesInTests = function() {
|
|
||||||
userTests.forEach(function(elt, ix, arr) {
|
|
||||||
arr[ix].text = arr[ix].text.replace(/\"/g,'\'');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var userTests;
|
var userTests;
|
||||||
var testSalt = Math.random();
|
var testSalt = Math.random();
|
||||||
@ -145,9 +140,7 @@ var scrapeTests = function(userJavaScript) {
|
|||||||
var match = regex.exec(userJavaScript);
|
var match = regex.exec(userJavaScript);
|
||||||
while (match != null) {
|
while (match != null) {
|
||||||
var replacement = '//' + counter + testSalt;
|
var replacement = '//' + counter + testSalt;
|
||||||
userJavaScript = userJavaScript.substring(0, match.index)
|
userJavaScript = userJavaScript.substring(0, match.index) + replacement + userJavaScript.substring(match.index + match[0].length);
|
||||||
+ replacement
|
|
||||||
+ userJavaScript.substring(match.index + match[0].length);
|
|
||||||
|
|
||||||
if (!userTests) {
|
if (!userTests) {
|
||||||
userTests= [];
|
userTests= [];
|
||||||
@ -157,9 +150,6 @@ var scrapeTests = function(userJavaScript) {
|
|||||||
match = regex.exec(userJavaScript);
|
match = regex.exec(userJavaScript);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userTests) {
|
|
||||||
replaceQuotesInTests();
|
|
||||||
}
|
|
||||||
return userJavaScript;
|
return userJavaScript;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -170,7 +160,6 @@ function removeComments(userJavaScript) {
|
|||||||
|
|
||||||
function removeLogs(userJavaScript) {
|
function removeLogs(userJavaScript) {
|
||||||
return userJavaScript.replace(/(console\.[\w]+\s*\(.*\;)/g, '');
|
return userJavaScript.replace(/(console\.[\w]+\s*\(.*\;)/g, '');
|
||||||
return userJavaScript;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var pushed = false;
|
var pushed = false;
|
||||||
@ -210,14 +199,13 @@ var runTests = function(err, data) {
|
|||||||
userTests= [{text:"Program Execution Failure", err: "No user tests were run."}];
|
userTests= [{text:"Program Execution Failure", err: "No user tests were run."}];
|
||||||
createTestDisplay();
|
createTestDisplay();
|
||||||
} else if (userTests) {
|
} else if (userTests) {
|
||||||
|
|
||||||
userTests.push(false);
|
userTests.push(false);
|
||||||
pushed = true;
|
pushed = true;
|
||||||
userTests.forEach(function(test, ix, arr){
|
userTests.forEach(function(test, ix, arr){
|
||||||
try {
|
try {
|
||||||
if (test) {
|
if (test) {
|
||||||
var test = JSON.stringify(reassembleTest(test, data));
|
console.log();
|
||||||
var output = eval(test);
|
var output = eval(reassembleTest(test, data));
|
||||||
}
|
}
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
allTestsPassed = false;
|
allTestsPassed = false;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
"expect(meetBonfire(\"test\")).to.be.true;"
|
"expect(meetBonfire(\"test\")).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\nreturn false;\n}\n\n",
|
"challengeSeed": "function meetBonfire(argument) {\n // Good luck!\n console.log(\"you can read this function's argument in the developer tools\", argument);\n\nreturn false;\n}\n\n",
|
||||||
"challengeEntryPoint": "meetBonfire(\"You can do this!\");",
|
"challengeEntryPoint": "meetBonfire(\"You can do this!\");"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : "aaa48de84e1ecc7c742e1124",
|
"_id" : "aaa48de84e1ecc7c742e1124",
|
||||||
@ -37,7 +37,7 @@
|
|||||||
"assert.deepEqual(palindrome(\"nope\"), false);"
|
"assert.deepEqual(palindrome(\"nope\"), false);"
|
||||||
],
|
],
|
||||||
"challengeSeed": "function palindrome(str) {\n // Good luck!\n return true;\n}\n\n",
|
"challengeSeed": "function palindrome(str) {\n // Good luck!\n return true;\n}\n\n",
|
||||||
"challengeEntryPoint": "palindrome(\"eye\");",
|
"challengeEntryPoint": "palindrome(\"eye\");"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : "ff0395860f5d3034dc0bfc94",
|
"_id" : "ff0395860f5d3034dc0bfc94",
|
||||||
@ -74,7 +74,7 @@
|
|||||||
"assert.deepEqual(telephoneCheck(\"2(757)622-7382\"), false);"
|
"assert.deepEqual(telephoneCheck(\"2(757)622-7382\"), false);"
|
||||||
],
|
],
|
||||||
"challengeSeed": "function telephoneCheck(str) {\n // Good luck!\n return true;\n}\n\n",
|
"challengeSeed": "function telephoneCheck(str) {\n // Good luck!\n return true;\n}\n\n",
|
||||||
"challengeEntryPoint": "telephoneCheck(\"555-555-5555\");",
|
"challengeEntryPoint": "telephoneCheck(\"555-555-5555\");"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id": "202eed8fc186c8434cb6d618",
|
"_id": "202eed8fc186c8434cb6d618",
|
||||||
@ -92,7 +92,7 @@
|
|||||||
"Your result must be a string."
|
"Your result must be a string."
|
||||||
],
|
],
|
||||||
"challengeEntryPoint": "reverseString('hello');",
|
"challengeEntryPoint": "reverseString('hello');",
|
||||||
"challengeSeed": "function reverseString(str) {\n return str;\r\n}",
|
"challengeSeed": "function reverseString(str) {\n return str;\r\n}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id": "302f7aae1aa3152a5b413bca",
|
"_id": "302f7aae1aa3152a5b413bca",
|
||||||
|
@ -23,7 +23,7 @@ block content
|
|||||||
.col-xs-12.col-sm-12.col-md-3
|
.col-xs-12.col-sm-12.col-md-3
|
||||||
#testCreatePanel
|
#testCreatePanel
|
||||||
h2.text-center #{name}
|
h2.text-center #{name}
|
||||||
Difficulty:
|
Difficulty
|
||||||
if (difficulty == "0")
|
if (difficulty == "0")
|
||||||
i.ion-ios-flame-outline
|
i.ion-ios-flame-outline
|
||||||
i.ion-ios-flame-outline
|
i.ion-ios-flame-outline
|
||||||
|
Reference in New Issue
Block a user