How can I query for all available Open Badges? - javascript

I'm attempting to make a Challenge Board rails app, which is essentially a search engine for Open Badges.
I need to aggregate all of the Open Badges that are available to be earned.
I've been looking through the Open Badge code on Github, and I found this:
Badge.finders = {
email: function (value, callback) {
var query = "SELECT * FROM `badge` WHERE `user_id` = (SELECT `id` FROM `user` WHERE `email` = ?)";
mysql.client.query(query, [value], callback);
}
};
(located at https://github.com/mozilla/openbadges/blob/development/models/badge.js)
So, can I just play around with that query to get what I want? Maybe this is the wrong way to go about things. Does anyone know of a way to get all of the available Open Badges? I've looked through the Displayer API, but it looks to be just for displaying a particular user's public badges.
I've considered writing a bot that spams the email-to-Open-Badge converter, and then takes each valid email (one attached to a real user) and stores it's ID code. Then I could cycle through those IDs to JSON query like this: http://beta.openbadges.org/displayer/[id]/groups.json and then keep a hash of all the different badges. However, I don't want to make a bot. Additionally, that system wouldn't add badges that are available, but no one has earned yet.
Anyone know of a good solution for this?

There isn't an API for querying all the badges available in the Mozilla backpack, because the backpack is a place to put badges. It doesn't actually offer them. Mozilla is working on a badge directory service to aggregate available open badges from different badge issuers, but it's only in the prototype stage. We're hoping it's available in the next 6 months.

Related

DB structure to handle chat groups similar to Telegram/FB Messenger

Currently doing a chat app where a user could join multiple chat groups, something similar to what Telegram and Facebook Messenger has. Pretty straight forward. We're mainly using Firebase database for storing the chat groups and message details.
Sample DB structure:
To only get the chat groups a user has:
root/
users/
chatGroups/
$uid/
$chatGroupId: true
We then get the details of the chat group from a different node, same with the latest chat message in that group:
root/
chatGroups/
entries/
$groupId/
group details here...
messages/
$groupId/
$messageId/
message details here..
Everything above to get the data for a single group item that looks something like this:
All works fine. We initially get at most 5 chat groups at first, then just sort the list. The problem lies where we have to listen for updates for the chat groups -- group with the most recent chat message would go to top of the list.
The structure we have listens only to the list of groups the specific user has -- we could detect groups joined (onChildAdded) and left (onChildRemoved) by the user, but it doesn't contain the timestamp we need to sort the chat group list by the most recent changes timestamp.
Has anyone tried this similar behavior with Firebase before (we're doing a client for both Android and Web -- Javascript)? Any ideas or suggestions would be appreciated. Let me know if you need some relevant details to make things clearer.
Because there is no auto-created metadata in Firebase about when a child was added, updated or deleted and also because those operations doesn't contain the information you are searching for, you need to create your own mechanism by adding the local timestamp for each operation or by writing a server-side timestamp.
There is another approach in which you can use denormalization. Add those chats to a new created section named uxChats. The chats will need to contain only the text message and the timestamp. If you are using FirebaseUI then you can reverse the order just using this lines of code:
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(layoutManager)
Latest chat goes on top.
Hope it helps AL.

SharePoint # Edit without having edit permissions

I'm new on the SharePoint world and right now I'm facing a little adversity.
Right now I do have a list that represents a collection of books. I also created a button with JavaScript that will allow the users to order them for a temporary time.
For this matter when the user clicks on the button, it'll change some column values from that list item, such as: the status, order and return date, some counters... I tested with my account and everything was working fine until I remember that I do have the permissions to edit this list. However if it's a end user, he'll receive (correctly since they haven't permission to edit) the "Request failed. Access denied. You do not have permission to perform this action or access this resource" message and won't be able to order the book.
Well, I could give the permission to this users in order to edit the list, but that way they would be able to delete and edit some columns that they aren't suppose to.
Do anyone have any suggestion/solution?
Thanks in advance!
With this type of scenario, I would suggest using more than one list, so you can manage the books and orders separately. Also, create a workflow in SharePoint Designer that starts when an order is created. This workflow will perform the operations that you are doing in JavaScript.
Here's a basic implementation plan:
Book List - Give users read only permission to this list.
Book Order List - Give users Add permissions to this list. Add a lookup column to the Book List.
Book Order Workflow - Perform the management of the order and inventory statuses here. App Steps can be utilized to run specified actions in the workflow with elevated privileges.

Lotus Notes JavaScript Get user info

User visit web site on it's own PC and javaScript creates NotesSession.
var ns = new ActiveXObject("Lotus.NotesSession");
ns.Initialize(pass); // user password
I would like to get user info such as name and corporate phone number after successful session initialize. For message like "Hello %username%, your phone is %number%" I know way to get info about specific user from Domino server if I know name or something else, but in this case I'm stuck a bit.
If I try to use GetDatabase InternetExplorer hangs.
var db = ns.GetDatabase("", "names.nsf");
Get internet address will be good too
I'm wondering why you're doing this in JavaScript on the browser side instead of doing it on the server side, because this will only work for users who have a Notes client installed and configured correctly. However, if this is really the way you want to go...
The only information that you get automatically with the session is the user's name (in a few different formats). If you want anything else, you have to look up the user information on the server.
You can use
var nd = ns.getDirectory()
var userinfo = NotesDirectory.LookupNames("$Users",ns.UserName, fieldsArray)
to get more info.
Note that there are several phone number fields in the Domino Directory and depending on your organization's policy and procedures they may not all be filled in. You'll need to look up the item names (e.g., "OfficePhoneNumber", "PhoneNumber", "CellPhoneNumber" .. there are others) and put the ones that you want to retrieve into the fieldsArray that you pass to LookupNames. You'll get the result back as a NotesDirectoryNavigator object, and you can use that object's methods and properties to get the value.

How to Share session between different clients accessing a Meteor website? Collaborative ToDos?

I am learning web development and lately Meteor has caught my fancy.
I went through the starter tutorial of creating to-dos and use save button to commit the list to database. It allows everybody who opens the website to see the same to-dos list.
I added user log in system in to-dos so that people can login and see only their own to-do list.
Now, I'm trying to extend above example, for Collaborative to-dos.
Here is a sample use case:
My boss logs-in at do.com and starts creating his to-do list. While the Boss is logged in, I also happen to open do.com from my laptop and I see a message flashing - A session is already open. Do you want to collaborate with Boss? If I say 'Yes', Boss will be notified at his screen to allow me access to his list, and on granting access, I will be able to collaborate with Boss's to-do with both of our changes in the list reflecting on each other's screen but the final save/commit button remains frozen for me (because I came later) and remains active only for Boss. So, when Boss hits the save button, the list is committed to database with his and my changes.
If Boss chooses to not allow me to contribute, I get to see my own to-do.
On the other hand, if I choose NO, I get a fresh start at my to-do list with no bearing on already open sessions elsewhere.
The scenario should work other way round too. If I am the one who has an active session at do.com and Boss happens to open his own later, he should get the message whether he wants to collaborate with me and so on.
What would be the best way to implement this in Meteor? I came across this Persistent Session package which could be the solution but I am not able to adapt it to my use-case of allowing/denying another user via message/notification. Appreciate, any help on this. I'm a complete newbie here, pls excuse of any un-necessary verbiage, I wanted to explain my question well.
Thanks in advance.
Session is not the right tool for this, you want to use the server db (Collections) to mediate this collaboration.
Given that you created todo lists specific to users, I'm going to assume you have a publication somewhat like this:
Tasks = new Mongo.Collection("tasks");
if (Meteor.isServer) {
Meteor.publish("tasks", function () {
return Tasks.find({owner: this.userId});
});
}
So the next step is to change this so you can see your own tasks, and also those belonging to any user who shares their tasks with you. This could be created like this:
Tasks = new Mongo.Collection('tasks');
CanView = new Mongo.Collection('canView');
// CanView holds docs with this schema:
// {
// user: 'DzxiSdNxEhiHMaoi6',
// taskLists: ['DzxiSdNxEhiHMaoi6', '7X97ZhPxjX6J4eNWx']
// }
if (Meteor.isServer) {
Meteor.publish('tasks', function () {
var canView = CanView.findOne({user: this.userId}).taskLists;
return Tasks.find({owner: {$in: canView}});
});
}
On the client tasks could be displayed as one single list, or segregated by the owner property.
How you add and remove ids into the CanViews tasklist list will depend on the workflow for requesting access/offering to share, etc.
The other part of the workflow you mentioned is only the Boss being able to save the changes, but still have them reactively update on both screens. This would take more work as you would need to implement a 2 step process, with two collections on the server. i.e. Boss's (task owner's) saves are committed directly to the canonical Tasks collection, and other users saves to a second TaskUpdates Collection. Both published to the clients, which then have to overlay the data from TaskUpdates over the actual Tasks in a way that is clear and meaningful.

Parse master key cloud code following users

I'm building a simple social network app for iOS with parse and I'm currently working on the relationships, such as follower and following. I have follower and following column in my data browser saved as an array so I can save all the usernames. So this is what I'm having trouble with: Say the current user is viewing a user's profile and clicks follow I need to have the current user's name save in the follower array of the user he/she is viewing. Now as far as I know I can't o this on the client side, and it isn't a good idea anyway for security reasons to do ether. So I want to try to use the Master Key and cloud code to add each of the user's names to their appropriate array. I have never used cloud code before and I want to make sure that this is the best way to do this. I set up the Cloud Code I just don't know where to begin. Any suggestions would be appreciated!
I would start by creating a new function in main.js in your cloud code folder. Just insert the Parse.Cloud.useMasterKey(); part at the beginning. I would send up the object id of the user you are modifying, then in the function grab the array from that user, and add the current user to it. Then save and send back a success variable.
To call this from Xcode you would have something like this:
[PFCloud callFunctionInBackground:#"editFollowers" withParameters:#{#"user": Put objectId for user here}
block:^(NSString *response, NSError *error) {
if (!error) {
}
}];

Categories