From 2dd222a441d043c294be05f4af9b477be81d3d4f Mon Sep 17 00:00:00 2001 From: Brett Guillory Date: Sat, 13 Jun 2015 20:54:43 -0500 Subject: [PATCH 1/5] Fixed a word --- seed_data/challenges/basic-bonfires.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed_data/challenges/basic-bonfires.json b/seed_data/challenges/basic-bonfires.json index 3773c4da22..67e3ef965e 100644 --- a/seed_data/challenges/basic-bonfires.json +++ b/seed_data/challenges/basic-bonfires.json @@ -832,7 +832,7 @@ "difficulty": "2.03", "description": [ "Perform a search and replace on the sentence using the arguments provided and return the new sentence.", - "First argument is the sentence the perform the search and replace on.", + "First argument is the sentence to perform the search and replace on.", "Second argument is the word that you will be replacing (before).", "Third argument is what you will be replacing the second argument with (after).", "NOTE: Preserve the case of the original word when you are replacing it. For example if you mean to replace the word 'Book' with the word 'dog', it should be replaced as 'Dog'", From e9aa4b27a78ccc3e490743c876dee82bcc5e7acc Mon Sep 17 00:00:00 2001 From: Brett Guillory Date: Sat, 13 Jun 2015 23:28:33 -0500 Subject: [PATCH 2/5] Added missing MDN Link This bonfire "Missing letters"seems to be missing an important MDN link to "String.fromCharCode()", which is needed to get the missing character to return for the test. Since the missing character is obviously not in the string supplied, you cannot get the character code for it from the string. --- seed_data/challenges/basic-bonfires.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seed_data/challenges/basic-bonfires.json b/seed_data/challenges/basic-bonfires.json index 3773c4da22..e65268b535 100644 --- a/seed_data/challenges/basic-bonfires.json +++ b/seed_data/challenges/basic-bonfires.json @@ -966,7 +966,8 @@ "expect(fearNotLetter('yz')).to.be.undefined;" ], "MDNlinks": [ - "String.charCodeAt()" + "String.charCodeAt()", + "String.fromCharCode()" ], "challengeType": 5, "nameCn": "", From a53114e7b617bb96a735eb481555467aa81066a2 Mon Sep 17 00:00:00 2001 From: Andrew Cay Date: Mon, 15 Jun 2015 22:47:17 -0700 Subject: [PATCH 3/5] Update and rename coursewaresJSFramework_0.0.5.js to coursewaresJSFramework_0.0.6.js Added auto save(to local storage) for any progress. It will set the IDE text to whatever the user last saw within 24 hours. The auto save happens every 1.5 seconds _after_ someone lifts a key. --- ...0.5.js => coursewaresJSFramework_0.0.6.js} | 66 ++++++++++++++++++- 1 file changed, 63 insertions(+), 3 deletions(-) rename public/js/lib/coursewares/{coursewaresJSFramework_0.0.5.js => coursewaresJSFramework_0.0.6.js} (77%) diff --git a/public/js/lib/coursewares/coursewaresJSFramework_0.0.5.js b/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js similarity index 77% rename from public/js/lib/coursewares/coursewaresJSFramework_0.0.5.js rename to public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js index 5e6de0e413..a339037b0e 100644 --- a/public/js/lib/coursewares/coursewaresJSFramework_0.0.5.js +++ b/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js @@ -40,6 +40,66 @@ editor.setOption("extraKeys", { }); +/* + Local Storage Update System By Andrew Cay(Resto) + localBonfire: singleton object that contains properties and methods related to + dealing with the localStorage system. + The keys work off of the variable challenge_name to make unique identifiers per bonfire + + Two extra functionalities: + Added anonymous version checking system incase of future updates to the system + Added keyup listener to editor(myCodeMirror) so the last update has been saved to storage +*/ +var localBonfire = { + version: 0.01, + keyVersion:"saveVersion", + keyStamp: challenge_Name + 'Stamp', + keyValue: challenge_Name + 'Val', + stampExpireTime: (1000 *60) *60 *24, + updateWait: 1500,// 1.5 seconds + updateTimeoutId: null +}; +localBonfire.getEditorValue = function(){ + return localStorage.getItem(localBonfire.keyValue); +}; +localBonfire.getStampTime = function(){ + //localstorage always saves as strings. + return Number.parseInt( localStorage.getItem(localBonfire.keyStamp) ); +}; +localBonfire.isAlive = function(){// returns true if IDE was edited within expire time + return ( Date.now() - localBonfire.getStampTime() < localBonfire.stampExpireTime ); +}; +localBonfire.updateStorage = function(){ + if(typeof(Storage) !== undefined) { + var stamp = Date.now(), + value = editor.getValue(); + localStorage.setItem(localBonfire.keyValue, value); + localStorage.setItem(localBonfire.keyStamp, stamp); + } else { + if( debugging ){ + console.log('no web storage'); + } + } + localBonfire.updateTimeoutId = null; + console.log('updated!'); +}; +// ANONYMOUS 1 TIME UPDATE VERSION +(function(){ + var savedVersion = localStorage.getItem('saveVersion'); + if( savedVersion === null ){ + localStorage.setItem(localBonfire.keyVersion, localBonfire.version);//just write current version + }else{ + //do checking if not current version + if( savedVersion !== localBonfire.version ){ + //update version + } + } +})(); + +editor.on('keyup', function(codMir, event){ + window.clearTimeout(localBonfire.updateTimeoutId); + localBonfire.updateTimeoutId = window.setTimeout(localBonfire.updateStorage, localBonfire.updateWait); +}); var attempts = 0; if (attempts) { @@ -71,15 +131,15 @@ var editorValue; var challengeSeed = challengeSeed || null; var tests = tests || []; + var allSeeds = ''; (function() { challengeSeed.forEach(function(elem) { - allSeeds += elem + '\n'; + allSeeds += elem + '\n'; }); })(); -editorValue = allSeeds; - +editorValue = (localBonfire.isAlive())? localBonfire.getEditorValue() : allSeeds; myCodeMirror.setValue(editorValue); From 0ceb5e0685a1e39da63c492976d7e7109af8dd5e Mon Sep 17 00:00:00 2001 From: Andrew Cay Date: Tue, 16 Jun 2015 16:52:32 -0700 Subject: [PATCH 4/5] Inserted reset button with button spacer below Run --- views/coursewares/showBonfire.jade | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/views/coursewares/showBonfire.jade b/views/coursewares/showBonfire.jade index 4270e5975a..1b84856e43 100644 --- a/views/coursewares/showBonfire.jade +++ b/views/coursewares/showBonfire.jade @@ -90,7 +90,10 @@ block content alert(type='danger') span.ion-close-circled | Username not found - #submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter) + #submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter) + .button-spacer + #resetButton.btn.btn-danger.btn-big.btn-block(data-toggle='modal', data-target='#reset-modal', data-backdrop='true') + | Reset Code if (user && user.sentSlackInvite) .button-spacer .btn-group.input-group.btn-group-justified From 687750809f0c1fad5d66f4a202440dc1205027b2 Mon Sep 17 00:00:00 2001 From: Andrew Cay Date: Tue, 16 Jun 2015 16:56:50 -0700 Subject: [PATCH 5/5] Reset button inserted beneath Run Also inserted a button spacer in appropriate place. --- views/coursewares/showBonfire.jade | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/views/coursewares/showBonfire.jade b/views/coursewares/showBonfire.jade index 1b84856e43..4fd79ffc88 100644 --- a/views/coursewares/showBonfire.jade +++ b/views/coursewares/showBonfire.jade @@ -90,10 +90,10 @@ block content alert(type='danger') span.ion-close-circled | Username not found - #submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter) - .button-spacer - #resetButton.btn.btn-danger.btn-big.btn-block(data-toggle='modal', data-target='#reset-modal', data-backdrop='true') - | Reset Code + #submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter) + .button-spacer + #resetButton.btn.btn-danger.btn-big.btn-block(data-toggle='modal', data-target='#reset-modal', data-backdrop='true') + | Reset Code if (user && user.sentSlackInvite) .button-spacer .btn-group.input-group.btn-group-justified