Fixed bonfire to allow users to enter contractions

This commit is contained in:
Nathan Leniz
2015-01-26 12:30:04 -05:00
parent c20aa1697c
commit ead9fe56d1
5 changed files with 28 additions and 21 deletions

3
app.js
View File

@ -260,6 +260,9 @@ app.get(
'/bonfires/:bonfireNumber',
bonfireController.returnIndividualBonfire
);
app.get('/bonfire', function(req, res) {
res.redirect(301, '/playground');
});
app.get('/bonfires', bonfireController.returnBonfire);
app.get('/bonfire/generator', bonfireController.returnGenerator);
app.post('/bonfire/generator', bonfireController.generateChallenge);

View File

@ -12,7 +12,23 @@ var highestBonfireNumber = 2;
exports.index = function(req, res) {
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) {

View File

@ -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 testSalt = Math.random();
@ -145,9 +140,7 @@ var scrapeTests = function(userJavaScript) {
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);
userJavaScript = userJavaScript.substring(0, match.index) + replacement + userJavaScript.substring(match.index + match[0].length);
if (!userTests) {
userTests= [];
@ -157,9 +150,6 @@ var scrapeTests = function(userJavaScript) {
match = regex.exec(userJavaScript);
}
if (userTests) {
replaceQuotesInTests();
}
return userJavaScript;
};
@ -170,7 +160,6 @@ function removeComments(userJavaScript) {
function removeLogs(userJavaScript) {
return userJavaScript.replace(/(console\.[\w]+\s*\(.*\;)/g, '');
return userJavaScript;
}
var pushed = false;
@ -210,14 +199,13 @@ var runTests = function(err, data) {
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 test = JSON.stringify(reassembleTest(test, data));
var output = eval(test);
console.log();
var output = eval(reassembleTest(test, data));
}
} catch(error) {
allTestsPassed = false;

View File

@ -14,7 +14,7 @@
"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",
"challengeEntryPoint": "meetBonfire(\"You can do this!\");",
"challengeEntryPoint": "meetBonfire(\"You can do this!\");"
},
{
"_id" : "aaa48de84e1ecc7c742e1124",
@ -37,7 +37,7 @@
"assert.deepEqual(palindrome(\"nope\"), false);"
],
"challengeSeed": "function palindrome(str) {\n // Good luck!\n return true;\n}\n\n",
"challengeEntryPoint": "palindrome(\"eye\");",
"challengeEntryPoint": "palindrome(\"eye\");"
},
{
"_id" : "ff0395860f5d3034dc0bfc94",
@ -74,7 +74,7 @@
"assert.deepEqual(telephoneCheck(\"2(757)622-7382\"), false);"
],
"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",
@ -92,7 +92,7 @@
"Your result must be a string."
],
"challengeEntryPoint": "reverseString('hello');",
"challengeSeed": "function reverseString(str) {\n return str;\r\n}",
"challengeSeed": "function reverseString(str) {\n return str;\r\n}"
},
{
"_id": "302f7aae1aa3152a5b413bca",

View File

@ -23,7 +23,7 @@ block content
.col-xs-12.col-sm-12.col-md-3
#testCreatePanel
h2.text-center #{name}
Difficulty:  
Difficulty
if (difficulty == "0")
i.ion-ios-flame-outline
i.ion-ios-flame-outline