From 29db5f8b94d4e94a5f12ec95c8aff3dd0c692ae8 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Thu, 29 Jan 2015 00:17:49 -0500 Subject: [PATCH 1/3] Adding person challenge, need to inspect execution failure in testing. --- seed_data/bonfires.json | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/seed_data/bonfires.json b/seed_data/bonfires.json index 369ee60fd6..c78aa8cae3 100644 --- a/seed_data/bonfires.json +++ b/seed_data/bonfires.json @@ -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');" + ] } ] From c3926423af788a90fba778949d5f5246d549a057 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Tue, 3 Feb 2015 01:57:35 -0500 Subject: [PATCH 2/3] Adding analytics to bonfire --- public/js/lib/bonfire/bonfireFramework.js | 12 +++++++++++- public/js/main.js | 11 ++++++++++- views/bonfire/show.jade | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/public/js/lib/bonfire/bonfireFramework.js b/public/js/lib/bonfire/bonfireFramework.js index 83a8742b5c..965dca2968 100644 --- a/public/js/lib/bonfire/bonfireFramework.js +++ b/public/js/lib/bonfire/bonfireFramework.js @@ -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'); } \ No newline at end of file diff --git a/public/js/main.js b/public/js/main.js index 8c9b83aa31..7ba0af65d3 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -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'); @@ -91,6 +94,12 @@ $(document).ready(function() { $('#brief-instructions').show(); $('#long-instructions').hide(); }); + + // Bonfire analytics + $('#submitButton').on('click', function() { + attempts++; + ga('send', 'event', 'Bonfire', 'ran-code', bonfireName); + }) }); var profileValidation = angular.module('profileValidation',['ui.bootstrap']); diff --git a/views/bonfire/show.jade b/views/bonfire/show.jade index 259634d536..98d06ca127 100644 --- a/views/bonfire/show.jade +++ b/views/bonfire/show.jade @@ -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 From 040d687f20db42d50d875d3581d8d1935df0f735 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Tue, 3 Feb 2015 01:59:19 -0500 Subject: [PATCH 3/3] Removing duplicate analytics call --- public/js/main.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/public/js/main.js b/public/js/main.js index 7ba0af65d3..e31855baf9 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -94,12 +94,6 @@ $(document).ready(function() { $('#brief-instructions').show(); $('#long-instructions').hide(); }); - - // Bonfire analytics - $('#submitButton').on('click', function() { - attempts++; - ga('send', 'event', 'Bonfire', 'ran-code', bonfireName); - }) }); var profileValidation = angular.module('profileValidation',['ui.bootstrap']);