Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
course and outcomes parsers
  • Loading branch information
gootyfer committed Jun 22, 2013
0 parents commit 06fc923
Show file tree
Hide file tree
Showing 280 changed files with 80,794 additions and 0 deletions.
11 changes: 11 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"server": {
"url": "127.0.0.1",
"port": 8000
},
"database":{
"name": "moocrank",
"url": "localhost",
"port": 27017
}
}
1 change: 1 addition & 0 deletions data/coursera.json

Large diffs are not rendered by default.

16,812 changes: 16,812 additions & 0 deletions data/outcomes.xml

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions models/courseManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
var Db = require('mongodb').Db;
var Connection = require('mongodb').Connection;
var Server = require('mongodb').Server;
var BSON = require('mongodb').BSON;
var ObjectID = require('mongodb').ObjectID;

CourseManager = function(host, port, dbName) {
//console.log(host+port+dbName);
this.db= new Db(dbName, new Server(host, port), {auto_reconnect: true, safe: true});
this.db.open(function(err, client){
if(err){
console.log("Error!:"+err);
}else{
console.log("open OK");
}
});
};

CourseManager.prototype.getCollection= function(callback) {
this.db.collection('courses', function(error, coursesCollection) {
if( error ) callback(error);
else callback(null, coursesCollection);
});
};

CourseManager.prototype.findAll = function(callback) {
this.getCollection(function(error, coursesCollection) {
if( error ) callback(error);
else {
coursesCollection.find().toArray(function(error, results) {
if( error ) callback(error);
else callback(null, results);
});
}
});
};


CourseManager.prototype.findById = function(id, callback) {
this.getCollection(function(error, coursesCollection) {
if( error ) callback(error);
else {
coursesCollection.findOne({_id: coursesCollection.db.bson_serializer.ObjectID.createFromHexString(id)}, function(error, result) {
if( error ) callback(error);
else callback(null, result);
});
}
});
};

CourseManager.prototype.save = function(courses, callback) {
this.getCollection(function(error, coursesCollection) {
if( error ) callback(error);
else {
if( typeof(courses.length)=="undefined")
courses = [courses];
coursesCollection.insert(courses, function(err) {
if(err) console.log("ERROR:"+err);
callback(null, courses);
});
}
});
};

CourseManager.prototype.close = function(){
this.db.close();
}

exports.CourseManager = CourseManager;
5 changes: 5 additions & 0 deletions node_modules/mongodb/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions node_modules/mongodb/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/mongodb/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 06fc923

Please sign in to comment.