Updated to show how json should be modeled, fleshed out resources to load new challengeMap stub

pull/466/head
terakilobyte 2015-05-18 22:03:27 -04:00
parent e6851b22d8
commit ba29f0533a
9 changed files with 186 additions and 1592 deletions

View File

@ -1,29 +0,0 @@
var mongoose = require('mongoose'),
debug = require('debug')('freecc:config:boot'),
secrets = require('./secrets'),
courses = require('../seed_data/courses.json'),
Course = require('./../models/Course'),
challenges = require('../seed_data/challenges.json'),
Challenge = require('./../models/Challenge');
mongoose.connect(secrets.db);
mongoose.connection.on('error', function() {
console.error('MongoDB Connection Error. Make sure MongoDB is running.');
});
Course.create(courses, function(err, data) {
if (err) {
debug(err);
} else {
debug('Saved ', data);
}
});
Challenge.create(challenges, function(err, data) {
if (err) {
console.log(err);
} else {
console.log('Saved ', data);
}
});

View File

@ -20,7 +20,8 @@ var async = require('async'),
cheerio = require('cheerio'),
request = require('request'),
R = require('ramda'),
_ = require('lodash');
_ = require('lodash'),
fs = require('fs');
/**
* Cached values
@ -46,7 +47,20 @@ Array.zip = function(left, right, combinerFunction) {
};
buildChallengeMap = function() {
challengeMap = {};
fs.readdir(__dirname + '../seed_data/challenges', function(err, files) {
if (err) {
debug(err);
} else {
var keyCounter = 0;
files = files.sort(function(a, b) {
return a.order < b.order ? a : b;
});
files.forEach(function(file) {
challengeMap[keyCounter++] = file;
});
}
});
};
module.exports = {

View File

@ -0,0 +1 @@
["./challenges/prepwork.json", "./challenges/basics.json"]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,59 @@
{
"name": "basics",
"order" : 0.001,
"challenges": [
{
"_id": "bd7126d8c441eddfaeb5bd3e",
"name": "Meet Other Campers in your City",
"difficulty": 0.065,
"challengeSeed": "127358841",
"description": [
"One of the best ways to stay motivated when learning to code is to hang out with other campers.",
"Slack and Camper News are great ways to communicate with other campers, but there's no substitute for meeting people in-person.",
"The easiest way to meet other campers in your city is to join your city's Facebook Group. Click <a href='/field-guide/how-can-i-find-other-free-code-camp-campers-in-my-city' target='_blank'>here</a> to view our growing list of local groups.",
"Click the link to your city, then, once Facebook loads, click \"Join group\".",
"Our local groups are new, so if you don't see your city on this list, you should follow the directions to create a Facebook group for your city.",
"If you don't have a Facebook account, we strongly recommend you create one, even if it's just for the purpose of coordinating with campers in your city through this group.",
"Our groups allow you to create events, coordinate those events, and share photos from the events afterward.",
"Whether you're hosting a study group, pair programming at your local library, or going to a weekend hackathon, your city's group will help you make it happen."
],
"challengeType": 2,
"tests": []
},
{
"_id": "bd7137d8c441eddfaeb5bdef",
"name": "Get Help the Hacker Way with RSAP",
"difficulty": 0.07,
"challengeSeed": "125407432",
"description": [
"Let's cover one last thing before you start working through our lessons: how to get help.",
"Any time you get stuck or don't know what to do next, follow this simple algorithm (procedure): RSAP (Read, Search, Ask, Post).",
"First, R - Read the documentation or error message. A key skill that good coders have is the ability to interpret and then follow instructions.",
"Next, S - Search Google. Good Google queries take a lot of practice. When you search Google, you usually want to include the language or framework you're using. You also want to limit the results to a recent period.",
"Then, if you still haven't found an answer to your question, A - Ask your friends. If you have trouble, you can ask your fellow campers. We have a special chat room specifically for getting help with tools you learn through these Free Code Camp Challenges. Go to <a href='https://freecode.slack.com/messages/help/' target='_blank'>https://freecode.slack.com/messages/help/</a>. Keep this chat open while you work on the remaining challenges.",
"Finally, P - Post on Stack Overflow. Before you attempt to do this, read Stack Overflow's guide to asking good questions: <a href='http://stackoverflow.com/help/how-to-ask'>http://stackoverflow.com/help/how-to-ask</a>.",
"Here's our detailed field guide on getting help: <a href='/field-guide/how-do-i-get-help-when-i-get-stuck' target='_blank'>http://freecodecamp.com/field-guide/how-do-i-get-help-when-i-get-stuck</a>.",
"Now you have a clear algorithm to follow when you need help! Let's start coding! Move on to your next challenge."
],
"challengeType": 2,
"tests": []
},
{
"_id": "bd7127d8c441eddfaeb5bdef",
"name": "Build a Landing Page with HTML",
"difficulty": 0.08,
"challengeSeed": "125671867",
"description": [
"Now it's time for us to start our actual coding lessons. We've curated a series of free, self-paced, browser-based lessons from providers like Codecademy and Stanford University.",
"These lessons will cover a lot of ground quickly, and will hold your hand throughout the process. Don't try to memorize everything - you'll spend more than a thousand hours practicing these later, and you can always look things up. Just keep moving.",
"If you've learned HTML and CSS before, these next few Waypoints will be a valuable review. If you haven't learned HTML or CSS before, you're in for a treat!",
"This Codecademy will quickly cover HTML, CSS and even Responsive Design with Bootstrap.",
"If you don't already have a Codecademy account, create one here: <a href='http://www.codecademy.com' target='_blank'>http://www.codecademy.com</a>.",
"Go to <a href='http://www.codecademy.com/en/skills/make-a-website/topics/html-elements' target='_blank'>http://www.codecademy.com/en/skills/make-a-website/topics/html-elements</a> and complete the section.",
"Once you're done, mark this Waypoint complete and move on the next Waypoint."
],
"challengeType": 2,
"tests": []
}
]
}

View File

@ -0,0 +1,55 @@
[
{
"_id": "bd7124d8c441eddfaeb5bdef",
"name": "Learn how Free Code Camp Works",
"difficulty": 0.01,
"challengeSeed": "125407438",
"description": [
"Watch this 1-minute video, or simply read this summary:",
"Welcome to Free Code Camp. We're a community of busy people learning to code by building projects for nonprofits.",
"We built this community because learning to code is hard. But anyone who can stay motivated can learn to code. And to stay motivated, you just need to: <ol><li>make friends with people who code</li><li>code a little every day</li><ol>",
"All our challenges are <ol><li>free</li><li>self-paced</li><li>browser-based</li></ol>",
"We'll spend <ol><li>200 hours learning tools like HTML, CSS, JavaScript, Node.js and databases</li><li>600 hours building practice projects</li><li>800 hours building full stack solutions for nonprofits</li></ol>",
"By the end, we'll <ol><li>be good at coding</li><li>have the portfolio of apps with happy users to prove it</li></ol>",
"Once you make it through Free Code Camp, you will be able to get a coding job. There are far more job openings out there than there are qualified coders to fill them.",
"Now it's time to join our chat room. Click the \"I've completed this challenge\" button to move on to your next challenge."
],
"challengeType": 2,
"tests": []
},
{
"_id": "bd7125d8c441eddfaeb5bd0f",
"name": "Join Our Chat Room",
"difficulty": 0.02,
"challengeSeed": "124555254",
"description": [
"Now we're going to join the Free Code Camp chat room. You can come here any time of day to hang out, ask questions, or find another camper to pair program with.",
"Make sure your Free Code Camp account includes your email address. You can do this here: <a href='/account' target='_blank'>http://freecodecamp.com/account</a>.",
"Click this link, which will email you an invite to Free Code Camp's Slack chat room: <a href='/api/slack' target='_blank'>http://freecodecamp.com/api/slack</a>.",
"Now check your email and click the link in the email from Slack",
"Complete the sign up process, then update your biographical information and upload an image. A picture of your face works best. This is how people will see you in the chat room, so put your best foot forward.",
"Now enter the general chat room and introduce yourself to our chat room by typing: \"hello world!\".",
"Note that you're expected to follow our Code of Conduct: <a href='/field-guide/what-is-the-free-code-camp-code-of-conduct?' target='_blank'>http://freecodecamp.com/field-guide/what-is-the-free-code-camp-code-of-conduct?</a>",
"Tell your fellow campers how you found Free Code Camp. Also tell us why you want to learn to code.",
"Keep the chat room open while you work through the other challenges. That way you ask for help if you get stuck on a challenge. You can also socialize when you feel like taking a break.",
"You can also access this chat room by clicking the \"Chat\" button in the upper right hand corner."
],
"challengeType": 2,
"tests": []
},
{
"_id": "bd7125d8c441eddfaeb5bdff",
"name": "Preview our Challenge Map",
"difficulty": 0.03,
"challengeSeed": "125407437",
"description": [
"Before you start learning how to code, we'd like to introduce you to a few things.",
"Let's look at our Challenge Map. Click on the \"Map\" button in the upper right hand corner. This map shows all the challenges that will teach you how to code.",
"You should complete all these challenges in order.",
"Once you finish these Waypoint challenges, you'll move on to Bonfires (algorithm practice), then Ziplines (front end development practice) and finally Basejumps (full stack development practice). After that, you'll start building projects for nonprofits.",
"This challenge map is just for your reference. When you return to FreeCodeCamp.com, we'll automatically redirect you to the next challenge that you should be doing."
],
"challengeType": 2,
"tests": []
}
]

View File

@ -1,96 +1,78 @@
require('dotenv').load();
var Bonfire = require('../models/Bonfire.js'),
Courseware = require('../models/Courseware.js'),
FieldGuide = require('../models/FieldGuide.js'),
Nonprofit = require('../models/Nonprofit.js'),
mongoose = require('mongoose'),
secrets = require('../config/secrets'),
coursewares = require('./coursewares.json'),
fieldGuides = require('./field-guides.json'),
nonprofits = require('./nonprofits.json'),
bonfires = require('./bonfires.json');
var Challenge = require('../models/Challenge.js'),
FieldGuide = require('../models/FieldGuide.js'),
Nonprofit = require('../models/Nonprofit.js'),
mongoose = require('mongoose'),
secrets = require('../config/secrets'),
fieldGuides = require('./field-guides.json'),
nonprofits = require('./nonprofits.json'),
fs = require('fs');
mongoose.connect(secrets.db);
var challenges = fs.readdirSync(__dirname + '/challenges');
var counter = 0;
var offerings = 4;
var offerings = 3;
var CompletionMonitor = function() {
counter++;
console.log('call ' + counter);
counter++;
console.log('call ' + counter);
if (counter < offerings) {
return;
} else {
process.exit(0);
}
if (counter < offerings) {
return;
} else {
process.exit(0);
}
};
Bonfire.remove({}, function(err, data) {
if (err) {
console.error(err);
} else {
console.log('Deleted ', data);
}
Bonfire.create(bonfires, function(err, data) {
if (err) {
console.log(err);
} else {
console.log('Saved ', data);
}
CompletionMonitor();
Challenge.remove({}, function(err, data) {
if (err) {
console.err(err);
} else {
console.log('Deleted ', data);
}
challenges.forEach(function (file) {
Challenge.create(require('./challenges/' + file), function (err, data) {
if (err) {
console.log(err);
} else {
console.log('Successfully parsed %s', file);
}
});
console.log('bonfires');
});
});
Courseware.remove({}, function(err, data) {
if (err) {
console.error(err);
} else {
console.log('Deleted ', data);
}
Courseware.create(coursewares, function(err, data) {
if (err) {
console.log(err);
} else {
console.log('Saved ', data);
}
CompletionMonitor();
});
console.log('coursewares');
});
/*
FieldGuide.remove({}, function(err, data) {
if (err) {
console.error(err);
} else {
console.log('Deleted ', data);
}
FieldGuide.create(fieldGuides, function(err, data) {
if (err) {
console.error(err);
console.log(err);
} else {
console.log('Deleted ', data);
console.log('Saved ', data);
}
FieldGuide.create(fieldGuides, function(err, data) {
if (err) {
console.log(err);
} else {
console.log('Saved ', data);
}
CompletionMonitor();
});
console.log('field guides');
CompletionMonitor();
});
console.log('field guides');
});
Nonprofit.remove({}, function(err, data) {
if (err) {
console.error(err);
} else {
console.log('Deleted ', data);
}
Nonprofit.create(nonprofits, function(err, data) {
if (err) {
console.error(err);
console.log(err);
} else {
console.log('Deleted ', data);
console.log('Saved ', data);
}
Nonprofit.create(nonprofits, function(err, data) {
if (err) {
console.log(err);
} else {
console.log('Saved ', data);
}
CompletionMonitor();
});
console.log('nonprofits');
CompletionMonitor();
});
console.log('nonprofits');
});
*/