Small rollcall layer in JS. Smaller than Rollcall 1.0 but enough for our needs at Encore Lab
// first parameter is the base DrowsyDromedary url,
// the second is the database name
var rollcall = new Rollcall('http://drowsy.badger.encorelab.org', 'rollcall');
rollcall.usersWithTags(['foo', 'bar'])
.done(function (users) {
users.each(function (user) {
console.log(user.toJSON());
});
});
rollcall.usersWithClasses(['ec101', 'ec203'])
.done(function (users) {
users.each(function (user) {
console.log(user.toJSON());
});
});
rollcall.user('akrauss')
.done(function (user) {
console.log(user.toJSON());
});
rollcall.users({'tags':{'$size': 0}}) .done(function (users) { users.each(function (user) { console.log(user.toJSON()); }); });
rollcall.usersWithUserRole('teacher')
.done(function (users) {
users.each(function (user) {
console.log(user.toJSON());
});
});
rollcall.user('akrauss')
.done(function (user) {
user.set('favourite_colour', 'green');
user.save();
// note that .save() returns a promise, so if you want
// to wait for that save to finish, you would do something like this:
user.save()
.done(function () {
console.log("Save is done!");
})
});
rollcall.user('akrauss')
.done(function (user) {
user.addTag('mytag');
user.save();
});
rollcall.user('akrauss')
.done(function (user) {
user.removeTag('mytag');
user.save();
});
rollcall.user('akrauss')
.done(function (user) {
user.addClass('myNewClass');
user.save();
});
rollcall.user('akrauss')
.done(function (user) {
user.removeClass('myOldClass');
user.save();
});
rollcall.user('akrauss')
.done(function (user) {
console.log(user.isTeacher());
});
rollcall.user('akrauss')
.done(function (user) {
user.set('tags', ['alpha', 'beta']);
user.save();
});
var newUser = new rollcall.User({
username: "cmccann",
tags: ['foo', 'bar']
});
newUser.save();
rollcall.userExists('akrauss')
.done(function (exists) {
if (exists)
console.log('user exists!');
else
console.log('user DOES NOT exist!');
});
var newGroup = new rollcall.Group({...});
rollcall.groups({'users':{'$size': 0}})
.done(function (groups) {
groups.each(function (group) {
console.log(group.toJSON());
});
});
rollcall.group('leprechaun')
.done(function (group) {
console.log(group.toJSON());
});
This was classes but can't use that since class is a reserved word in JS
var newCohort = new rollcall.Cohort({
"name": "ec101",
"creator": "[email protected]",
"discussions": []
});
newCohort.save();
newCohort.addDiscussion("53e915cf7e59cb607d099999002");
newCohort.removeDiscussion("53e915cf7e59cb607d099999002");