Skip to content

Instantly share code, notes, and snippets.

@leebrandt
Created March 19, 2015 04:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leebrandt/97a10996827fd99d28af to your computer and use it in GitHub Desktop.
Save leebrandt/97a10996827fd99d28af to your computer and use it in GitHub Desktop.
var firstNames = ["Joe", "Dave", "Alice", "Bob", "Tom", "Doug", "Alex", "Stephanie", "Tracy", "Xander", "Zelda"];
var lastNames = ["Andersen", "Baldwin", "Crockett", "Davis", "Davidson", "Eastman", "Young", "Rogers", "McArty", "DeVito"];
for(i=0;i<1000;i++) {
var student = {
"student_id" : i,
"firstName" : firstNames[getRandomNumberUpTo(firstNames.length - 1)],
"lastName" : lastNames[getRandomNumberUpTo(lastNames.length - 1)],
activity: []
}
for (j=0;j<5;j++){
student.activity.push({
"type": "homework",
"score": getRandomNumberUpTo(100)
});
}
for (j=0;j<2;j++){
student.activity.push({
"type": "quiz",
"score": getRandomNumberUpTo(100)
});
}
student.activity.push({
"type": "exam",
"score": getRandomNumberUpTo(100)
});
db.students.insert(student);
}
function getRandomNumberUpTo(max){
return Math.round(Math.random() * max);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment