Michael Q Larson 2015-02-02 23:05:04 -08:00
commit dda901872e
4 changed files with 45 additions and 2 deletions

View File

@ -22,6 +22,11 @@ var editor = myCodeMirror;
editor.setSize("100%", "auto");
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' +
@ -100,15 +105,18 @@ $('#submitButton').on('click', function () {
});
function bonfireExecute() {
attempts++;
ga('send', 'event', 'Bonfire', 'ran-code', bonfireName);
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
if (challengeEntryPoint) {
if (challengeEntryPoint && challengeSeed) {
userJavaScript = challengeEntryPoint + ' ' + userJavaScript;
}
console.log(userJavaScript);
submit(userJavaScript, function(cls, message) {
if (cls) {
codeOutput.setValue(message.error);
@ -224,5 +232,7 @@ var runTests = function(err, data) {
};
function showCompletion() {
ga('send', 'event', 'Bonfire', 'solved', bonfireName + ', Time: ' + (Math.floor(Date.now() / 1000) - started) +', Attempts: ' + attempts);
$('#complete-bonfire-dialog').modal('show');
}

View File

@ -1,4 +1,7 @@
$(document).ready(function() {
if (bonfireName !== undefined) {
ga('send', 'event', 'Bonfire', 'load', bonfireName + ':' + Math.floor(Date.now() / 1000));
}
var CSRF_HEADER = 'X-CSRF-Token';
@ -61,7 +64,6 @@ $(document).ready(function() {
var bonfireSolution = myCodeMirror.getValue();
var thisBonfireHash = passedBonfireHash || null;
var didCompleteWith = $('#completed-with').val() || null;
completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash);
});
@ -83,6 +85,7 @@ $(document).ready(function() {
// Bonfire instructions functions
$('#more-info').on('click', function() {
ga('send', 'event', 'Bonfire', 'more-info', bonfireName);
$('#brief-instructions').hide();
$('#long-instructions').show().removeClass('hide');

View File

@ -255,6 +255,34 @@
"assert.deepEqual(inventory([], [[2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [67, 'Bowling Ball'], [7, 'Toothpaste']]), [[2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [67, 'Bowling Ball'], [7, 'Toothpaste']]);",
"assert.deepEqual(inventory([[0, 'Bowling Ball'], [0, 'Dirty Sock'], [0, 'Hair pin'], [0, 'Microphone']], [[1, 'Hair Pin'], [1, 'Half-Eaten Apple'], [1, 'Bowling Ball'], [1, 'Toothpaste']]), [[1, 'Bowling Ball'], [1, 'Dirty Sock'], [1, 'Hair pin'], [1, 'Half-Eaten Apple'], [1, 'Microphone'], [1, 'Toothpaste']]);"
]
},
{
"_id": "a2f1d72d9b908d0bd72bb9f6",
"name": "Make a Person",
"difficulty": "3.12",
"description": [
"Fill in the object constructor with the methods specified in the tests.",
"Those methods are getFirstName(), getLastName(), getFullName(), setFirstName(), setLastName(), and setFullName().",
"These methods must be the only available means for interacting with the object.",
"There will be some linting errors on the tests, you may safely ignore them. You should see undefined in the console output."
],
"challengeEntryPoint": "var bob = new Person('Bob Ross');",
"challengeSeed": "var Person = function(firstAndLast) {\n return firstAndLast;\r\n};",
"tests": [
"expect(Object.keys(bob).length).to.eql(6);",
"expect(bob instanceof Person).to.be.true;",
"expect(bob.firstName).to.be.undefined();",
"expect(bob.lastName).to.be.undefined();",
"expect(bob.getFirstName()).to.eql('Bob');",
"expect(bob.getLastName()).to.eql('Ross');",
"expect(bob.getFullName()).to.eql('Bob Ross');",
"bob.setFirstName('Happy');",
"expect(bob.getFirstName()).to.eql('Happy');",
"bob.setLastName('Trees');",
"expect(bob.getLastName()).to.eql('Trees');",
"bob.setFullName('George Carlin');",
"expect(bob.getFullName()).to.eql('George Carlin');"
]
}
]

View File

@ -90,6 +90,8 @@ block content
var challengeSeed = !{JSON.stringify(challengeSeed)};
var challengeEntryPoint = !{JSON.stringify(challengeEntryPoint)};
var passedBonfireHash = !{JSON.stringify(bonfireHash)};
var bonfireName = !{JSON.stringify(name)};
var started = Math.floor(Date.now() / 1000);
.col-xs-12.col-sm-12.col-md-8
#mainEditorPanel
form.code