From f7f587194d77538046aeb3d9550e255ae8a9c073 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Sun, 6 Dec 2015 21:44:34 -0800 Subject: [PATCH] Add superblock ordering --- common/models/challenge.json | 4 ++++ .../gear-up-for-success.json | 0 .../basic-bonfires.json | 0 .../basic-javascript.json | 0 .../basic-ziplines.json | 0 .../bootstrap.json | 0 .../front-end-development-certificate.json | 0 .../html5-and-css.json | 0 .../intermediate-bonfires.json | 0 .../intermediate-ziplines.json | 0 .../jquery.json | 0 .../json-apis-and-ajax.json | 0 ...t-oriented-and-functional-programming.json | 0 .../data-visualization-certificate.json | 0 .../data-visualization-projects.json | 0 .../react-projects.json | 0 .../advanced-bonfires.json | 0 .../api-projects.json | 0 .../automated-testing-and-debugging.json | 0 .../back-end-development-certificate.json | 0 .../backend-heavy-web-apps.json | 0 .../git.json | 0 .../mongodb.json | 0 .../nodejs-and-expressjs.json | 0 .../upper-intermediate-bonfires.json | 0 seed/getChallenges.js | 24 +++++++++++++++++-- seed/index.js | 2 ++ server/boot/challenge.js | 1 + 28 files changed, 29 insertions(+), 2 deletions(-) rename seed/challenges/{getting-started => 00-getting-started}/gear-up-for-success.json (100%) rename seed/challenges/{front-end-development-certification => 01-front-end-development-certification}/basic-bonfires.json (100%) rename seed/challenges/{front-end-development-certification => 01-front-end-development-certification}/basic-javascript.json (100%) rename seed/challenges/{front-end-development-certification => 01-front-end-development-certification}/basic-ziplines.json (100%) rename seed/challenges/{front-end-development-certification => 01-front-end-development-certification}/bootstrap.json (100%) rename seed/challenges/{front-end-development-certification => 01-front-end-development-certification}/front-end-development-certificate.json (100%) rename seed/challenges/{front-end-development-certification => 01-front-end-development-certification}/html5-and-css.json (100%) rename seed/challenges/{front-end-development-certification => 01-front-end-development-certification}/intermediate-bonfires.json (100%) rename seed/challenges/{front-end-development-certification => 01-front-end-development-certification}/intermediate-ziplines.json (100%) rename seed/challenges/{front-end-development-certification => 01-front-end-development-certification}/jquery.json (100%) rename seed/challenges/{front-end-development-certification => 01-front-end-development-certification}/json-apis-and-ajax.json (100%) rename seed/challenges/{front-end-development-certification => 01-front-end-development-certification}/object-oriented-and-functional-programming.json (100%) rename seed/challenges/{data-visualization-certification => 02-data-visualization-certification}/data-visualization-certificate.json (100%) rename seed/challenges/{data-visualization-certification => 02-data-visualization-certification}/data-visualization-projects.json (100%) rename seed/challenges/{data-visualization-certification => 02-data-visualization-certification}/react-projects.json (100%) rename seed/challenges/{back-end-development-certification => 03-back-end-development-certification}/advanced-bonfires.json (100%) rename seed/challenges/{back-end-development-certification => 03-back-end-development-certification}/api-projects.json (100%) rename seed/challenges/{back-end-development-certification => 03-back-end-development-certification}/automated-testing-and-debugging.json (100%) rename seed/challenges/{back-end-development-certification => 03-back-end-development-certification}/back-end-development-certificate.json (100%) rename seed/challenges/{back-end-development-certification => 03-back-end-development-certification}/backend-heavy-web-apps.json (100%) rename seed/challenges/{back-end-development-certification => 03-back-end-development-certification}/git.json (100%) rename seed/challenges/{back-end-development-certification => 03-back-end-development-certification}/mongodb.json (100%) rename seed/challenges/{back-end-development-certification => 03-back-end-development-certification}/nodejs-and-expressjs.json (100%) rename seed/challenges/{back-end-development-certification => 03-back-end-development-certification}/upper-intermediate-bonfires.json (100%) diff --git a/common/models/challenge.json b/common/models/challenge.json index 7d9e3822d6..b5173202b0 100644 --- a/common/models/challenge.json +++ b/common/models/challenge.json @@ -36,6 +36,10 @@ "type": "string", "description": "Used for ordering challenge blocks in map" }, + "superBlockOrder": { + "type": "number", + "description": "Used to determine superBlock order, set by prepending two digit number to super block folder name" + }, "block": { "type": "string" }, diff --git a/seed/challenges/getting-started/gear-up-for-success.json b/seed/challenges/00-getting-started/gear-up-for-success.json similarity index 100% rename from seed/challenges/getting-started/gear-up-for-success.json rename to seed/challenges/00-getting-started/gear-up-for-success.json diff --git a/seed/challenges/front-end-development-certification/basic-bonfires.json b/seed/challenges/01-front-end-development-certification/basic-bonfires.json similarity index 100% rename from seed/challenges/front-end-development-certification/basic-bonfires.json rename to seed/challenges/01-front-end-development-certification/basic-bonfires.json diff --git a/seed/challenges/front-end-development-certification/basic-javascript.json b/seed/challenges/01-front-end-development-certification/basic-javascript.json similarity index 100% rename from seed/challenges/front-end-development-certification/basic-javascript.json rename to seed/challenges/01-front-end-development-certification/basic-javascript.json diff --git a/seed/challenges/front-end-development-certification/basic-ziplines.json b/seed/challenges/01-front-end-development-certification/basic-ziplines.json similarity index 100% rename from seed/challenges/front-end-development-certification/basic-ziplines.json rename to seed/challenges/01-front-end-development-certification/basic-ziplines.json diff --git a/seed/challenges/front-end-development-certification/bootstrap.json b/seed/challenges/01-front-end-development-certification/bootstrap.json similarity index 100% rename from seed/challenges/front-end-development-certification/bootstrap.json rename to seed/challenges/01-front-end-development-certification/bootstrap.json diff --git a/seed/challenges/front-end-development-certification/front-end-development-certificate.json b/seed/challenges/01-front-end-development-certification/front-end-development-certificate.json similarity index 100% rename from seed/challenges/front-end-development-certification/front-end-development-certificate.json rename to seed/challenges/01-front-end-development-certification/front-end-development-certificate.json diff --git a/seed/challenges/front-end-development-certification/html5-and-css.json b/seed/challenges/01-front-end-development-certification/html5-and-css.json similarity index 100% rename from seed/challenges/front-end-development-certification/html5-and-css.json rename to seed/challenges/01-front-end-development-certification/html5-and-css.json diff --git a/seed/challenges/front-end-development-certification/intermediate-bonfires.json b/seed/challenges/01-front-end-development-certification/intermediate-bonfires.json similarity index 100% rename from seed/challenges/front-end-development-certification/intermediate-bonfires.json rename to seed/challenges/01-front-end-development-certification/intermediate-bonfires.json diff --git a/seed/challenges/front-end-development-certification/intermediate-ziplines.json b/seed/challenges/01-front-end-development-certification/intermediate-ziplines.json similarity index 100% rename from seed/challenges/front-end-development-certification/intermediate-ziplines.json rename to seed/challenges/01-front-end-development-certification/intermediate-ziplines.json diff --git a/seed/challenges/front-end-development-certification/jquery.json b/seed/challenges/01-front-end-development-certification/jquery.json similarity index 100% rename from seed/challenges/front-end-development-certification/jquery.json rename to seed/challenges/01-front-end-development-certification/jquery.json diff --git a/seed/challenges/front-end-development-certification/json-apis-and-ajax.json b/seed/challenges/01-front-end-development-certification/json-apis-and-ajax.json similarity index 100% rename from seed/challenges/front-end-development-certification/json-apis-and-ajax.json rename to seed/challenges/01-front-end-development-certification/json-apis-and-ajax.json diff --git a/seed/challenges/front-end-development-certification/object-oriented-and-functional-programming.json b/seed/challenges/01-front-end-development-certification/object-oriented-and-functional-programming.json similarity index 100% rename from seed/challenges/front-end-development-certification/object-oriented-and-functional-programming.json rename to seed/challenges/01-front-end-development-certification/object-oriented-and-functional-programming.json diff --git a/seed/challenges/data-visualization-certification/data-visualization-certificate.json b/seed/challenges/02-data-visualization-certification/data-visualization-certificate.json similarity index 100% rename from seed/challenges/data-visualization-certification/data-visualization-certificate.json rename to seed/challenges/02-data-visualization-certification/data-visualization-certificate.json diff --git a/seed/challenges/data-visualization-certification/data-visualization-projects.json b/seed/challenges/02-data-visualization-certification/data-visualization-projects.json similarity index 100% rename from seed/challenges/data-visualization-certification/data-visualization-projects.json rename to seed/challenges/02-data-visualization-certification/data-visualization-projects.json diff --git a/seed/challenges/data-visualization-certification/react-projects.json b/seed/challenges/02-data-visualization-certification/react-projects.json similarity index 100% rename from seed/challenges/data-visualization-certification/react-projects.json rename to seed/challenges/02-data-visualization-certification/react-projects.json diff --git a/seed/challenges/back-end-development-certification/advanced-bonfires.json b/seed/challenges/03-back-end-development-certification/advanced-bonfires.json similarity index 100% rename from seed/challenges/back-end-development-certification/advanced-bonfires.json rename to seed/challenges/03-back-end-development-certification/advanced-bonfires.json diff --git a/seed/challenges/back-end-development-certification/api-projects.json b/seed/challenges/03-back-end-development-certification/api-projects.json similarity index 100% rename from seed/challenges/back-end-development-certification/api-projects.json rename to seed/challenges/03-back-end-development-certification/api-projects.json diff --git a/seed/challenges/back-end-development-certification/automated-testing-and-debugging.json b/seed/challenges/03-back-end-development-certification/automated-testing-and-debugging.json similarity index 100% rename from seed/challenges/back-end-development-certification/automated-testing-and-debugging.json rename to seed/challenges/03-back-end-development-certification/automated-testing-and-debugging.json diff --git a/seed/challenges/back-end-development-certification/back-end-development-certificate.json b/seed/challenges/03-back-end-development-certification/back-end-development-certificate.json similarity index 100% rename from seed/challenges/back-end-development-certification/back-end-development-certificate.json rename to seed/challenges/03-back-end-development-certification/back-end-development-certificate.json diff --git a/seed/challenges/back-end-development-certification/backend-heavy-web-apps.json b/seed/challenges/03-back-end-development-certification/backend-heavy-web-apps.json similarity index 100% rename from seed/challenges/back-end-development-certification/backend-heavy-web-apps.json rename to seed/challenges/03-back-end-development-certification/backend-heavy-web-apps.json diff --git a/seed/challenges/back-end-development-certification/git.json b/seed/challenges/03-back-end-development-certification/git.json similarity index 100% rename from seed/challenges/back-end-development-certification/git.json rename to seed/challenges/03-back-end-development-certification/git.json diff --git a/seed/challenges/back-end-development-certification/mongodb.json b/seed/challenges/03-back-end-development-certification/mongodb.json similarity index 100% rename from seed/challenges/back-end-development-certification/mongodb.json rename to seed/challenges/03-back-end-development-certification/mongodb.json diff --git a/seed/challenges/back-end-development-certification/nodejs-and-expressjs.json b/seed/challenges/03-back-end-development-certification/nodejs-and-expressjs.json similarity index 100% rename from seed/challenges/back-end-development-certification/nodejs-and-expressjs.json rename to seed/challenges/03-back-end-development-certification/nodejs-and-expressjs.json diff --git a/seed/challenges/back-end-development-certification/upper-intermediate-bonfires.json b/seed/challenges/03-back-end-development-certification/upper-intermediate-bonfires.json similarity index 100% rename from seed/challenges/back-end-development-certification/upper-intermediate-bonfires.json rename to seed/challenges/03-back-end-development-certification/upper-intermediate-bonfires.json diff --git a/seed/getChallenges.js b/seed/getChallenges.js index 982ddb3d6e..12ccc5927f 100644 --- a/seed/getChallenges.js +++ b/seed/getChallenges.js @@ -1,7 +1,7 @@ +/* eslint-disable no-self-compare */ var fs = require('fs'); var path = require('path'); - function getFilesFor(dir) { return fs.readdirSync(path.join(__dirname, '/' + dir)) .map(function(file) { @@ -27,13 +27,33 @@ function getFilesFor(dir) { }, []); } +function getSupOrder(filePath) { + var order = parseInt((filePath || '').split('-')[0], 10); + // check for NaN + if (order !== order) { + return 0; + } + return order; +} + +function getSupName(filePath) { + var order = parseInt((filePath || '').split('-')[0], 10); + // check for NaN + if (order !== order) { + return filePath; + } + + return (filePath || '').split('-').splice(1).join('-'); +} + module.exports = function getChallenges() { try { return getFilesFor('challenges') .map(function(data) { var challengeSpec = require('./challenges/' + data.file); challengeSpec.fileName = data.file; - challengeSpec.superBlock = data.superBlock; + challengeSpec.superBlock = getSupName(data.superBlock); + challengeSpec.superBlockOrder = getSupOrder(data.superBlock); return challengeSpec; }); diff --git a/seed/index.js b/seed/index.js index 6ca98c33bb..98dd3255ea 100644 --- a/seed/index.js +++ b/seed/index.js @@ -18,6 +18,7 @@ destroy() var order = challengeSpec.order; var block = challengeSpec.name; var superBlock = challengeSpec.superBlock; + var superBlockOrder = challengeSpec.superBlockOrder; var isBeta = !!challengeSpec.isBeta; var fileName = challengeSpec.fileName; console.log('parsed %s successfully', block); @@ -46,6 +47,7 @@ destroy() challenge.block = block; challenge.isBeta = challenge.isBeta || isBeta; challenge.time = challengeSpec.time; + challenge.superBlockOrder = superBlockOrder; challenge.superBlock = superBlock .split('-') .map(function(word) { diff --git a/server/boot/challenge.js b/server/boot/challenge.js index 063ea7a27b..076ee1240a 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -109,6 +109,7 @@ module.exports = function(app) { const challengesQuery = { order: [ + 'superOrder ASC', 'order ASC', 'suborder ASC' ]