-
Notifications
You must be signed in to change notification settings - Fork 2
ILS Library with graasp.epfl.ch
This javascript library provides APIs to developers, allowing apps to access info and data in the ILS they are running in.
An ILS contains by default five phases: Orientation, Conceptualisation, Investigation, Conclusion, Discussion, in addition to a Vault space, and an About space intended for ILS management by teachers. Each phase could contain a few apps, and the Vault is used for data exchange between apps. For instance, one app could save a data file in the Vault, and another app could read this file from the Vault. This library will allow apps to exchange data via the APIs.
#### getCurrentUser(callback: function(result: string): void): string Gets the nickname of the current student, and returns it in the callback.
callback: function(result: string):void a callback function to handle the returned result
result: a String object containing the nickname of the user of the user
Result example on success (for old and new Graasp):
"Mario"
Result example on failure:
{
"error": "cannot find the nickname"
}
Returns the parent space of the widget in the callback.
callback(result): a callback function to handle the returned result
result: a JSON object containing the parent space properties
Result example on success:
{
"description": "some text",
"displayName": "Orientation",
"id": "9563",
"metadata": {"type":"Orientation"},
"objectId": 9563,
"parentId": 9562,
"parentType": "@space",
"profileUrl": "http://localhost:3000/#item=space_9563",
"spacetype": "folder",
"updated": "2014-03-17T12:43:28+01:00",
"visibilityLevel": "public"
}
Result example on failure:
{
"error": "cannot get the parent"
}
Returns the current Ils in the callback.
callback(result): a callback function to handle the returned result
result: a JSON object containing the ILS space properties
Result example on success:
{
"description": "some text",
"displayName": "ils_example",
"id": "9562",
"metadata": "",
"objectId": 9562,
"parentId": 28,
"parentType": "@person",
"profileUrl": "http://localhost:3000/#item=space_9562",
"spacetype": "ils",
"updated": "2014-03-17T12:43:28+01:00",
"visibilityLevel": "public"
}
Result example on failure:
{
"error": "cannot get the Ils"
}
Returns the type of the current phase.
callback(result): a callback function to handle the returned result
result: a String object containing the name of the phase the app is running in
Result example on success (for both old and new Graasp):
"Orientation"
Result example on failure:
{
"error": "cannot get the parent inquiry phase"
}
Returns the Vault space of the current Ils in the callback.
callback(result): a callback function to handle the returned result
result: a JSON object containing the Vault space properties
Result example on success:
{
"description": "some text",
"displayName": "Vault",
"id": "9569",
"metadata": {"type":"Vault"},
"objectId": 9569,
"parentId": 9562,
"parentType": "@space",
"profileUrl": "http://localhost:3000/#item=space_9569",
"spacetype": "group",
"updated": "2014-03-17T12:43:28+01:00",
"visibilityLevel": "hidden"
}
Result example on failure:
{
"error": "cannot get the vault"
}
Returns all the resources in the Vault in the callback.
callback(result): a callback function to handle the returned result
result: an array of JSON objects, each JSON object containing properties of the respective resource in the Vault
Result example on success:
[
{
"id": 15312,
"displayName": "example",
"name": "example",
"objectId": 15312,
"parentId": "9569",
"parentType": "@space",
"profileUrl": "http://localhost:3000/#item=asset_15312",
"thumbnailUrl": "/asset/picture/15312/thumb/image-0.jpg",
"updated": "2014/03/26 13:26:51 +0100",
"mimeType": "txt",
"metadata": {"username": "Mario"},
"data": "",
"attachment": {}
},
{
"id": 15313,
"displayName": "example2",
"name": "example2",
"objectId": 15313,
"parentId": "9569",
"parentType": "@space",
"profileUrl": "http://localhost:3000/#item=asset_15313",
"thumbnailUrl": "/asset/picture/15313/thumb/image-0.jpg",
"updated": "2014/03/26 13:26:51 +0100",
"mimeType": "txt",
"metadata": {"username": "Luigi"},
"data": "",
"attachment": {}
}
]
Result example on failure:
{
"error": "cannot get the resources in the vault"
}
Returns the resource with the resourceId in the callback.
callback(result): a callback function to handle the returned result
result: a JSON object containing the properties of the resource references by resourceId
Result example on success:
{
"id": 15312,
"displayName": "example",
"name": "example",
"description": "some text",
"objectId": 15312,
"parentId": "9569",
"parentType": "@space",
"profileUrl": "http://localhost:3000/#item=asset_15312",
"thumbnailUrl": "/asset/picture/15312/thumb/image-0.jpg",
"updated": "2014/03/26 13:26:51 +0100",
"mimeType": "txt",
"metadata": {
actor: {
displayName: "Mario",
id: "Mario@9570",
objectType: "person"
},
generator: {
displayName: "test widget",
id: "http://graasp.epfl.ch/apps/6570",
objectType: "Widget",
url: "http://graasp.epfl.ch/ils/demo/vault_demo.xml"
},
provider: {
displayName: "test ILS",
id: "9570",
url: "http://graasp.epfl.ch/#item=space_9570"
},
target: {
displayName: "test resource",
id: "http://graasp.epfl.ch/assets/15357",
objectType: "Asset"
}
},
"content": {
"concepts": [
{
"x": 297,
"y": 188,
"content": "energy",
"id": "7f800d79-cd66-2167-724c-6c1cda7abc5e",
"type": "ut_tools_conceptmapper_conceptSelector",
"colorClass": "ut_tools_conceptmapper_blue"
},
{
"x": 652,
"y": 238,
"content": "thermodynamic temperature",
"id": "a1ad6ace-c722-ffa9-f58e-b4169acdb4e3",
"type": "ut_tools_conceptmapper_conceptSelector",
"colorClass": "ut_tools_conceptmapper_blue"
}
],
"relations": [
{
"source": "7f800d79-cd66-2167-724c-6c1cda7abc5e",
"target": "a1ad6ace-c722-ffa9-f58e-b4169acdb4e3",
"id": "con_71",
"content": "influences"
}
]
}
"data": "",
"attachment": {}
}
Result example on failure:
{
"error": "cannot get the resource"
}
createResource(resourceName: string, content: object, callback: function(result: object): void): object
Create a resource in the Vault, and returns the new resource just created.
resourceName example:
"example file"
content should be any JSON, see example below:
{
"concepts": [
{
"x": 297,
"y": 188,
"content": "energy",
"id": "7f800d79-cd66-2167-724c-6c1cda7abc5e",
"type": "ut_tools_conceptmapper_conceptSelector",
"colorClass": "ut_tools_conceptmapper_blue"
},
{
"x": 652,
"y": 238,
"content": "thermodynamic temperature",
"id": "a1ad6ace-c722-ffa9-f58e-b4169acdb4e3",
"type": "ut_tools_conceptmapper_conceptSelector",
"colorClass": "ut_tools_conceptmapper_blue"
}
],
"relations": [
{
"source": "7f800d79-cd66-2167-724c-6c1cda7abc5e",
"target": "a1ad6ace-c722-ffa9-f58e-b4169acdb4e3",
"id": "con_71",
"content": "influences"
}
]
}
callback(result): a callback function to handle the returned result
result: a JSON object representing the creating resource in the Vault
Result example on success:
{
"id": 15312,
"displayName": "example",
"name": "example",
"objectId": 15312,
"parentId": "9569",
"parentType": "@space",
"profileUrl": "http://localhost:3000/#item=asset_15312",
"thumbnailUrl": "/asset/picture/15312/thumb/image-0.jpg",
"updated": "2014/03/26 13:26:51 +0100",
"mimeType": "txt",
"data": "",
"attachment": {}
}
Result example on failure:
{
"error": "cannot create resource in the vault"
}
### How to Use This library relies on Jquery, so Jquery should be included in the widget headers before the use of this library. Below is an example of how to use the getIls API. For more information on how to use this library, please refer to the the demo widget: https://github.com/go-lab/ils/blob/master/demo/vault_demo.xml
//include jquery library in your widget source
<script type="text/javascript" src="http://graasp.epfl.ch/gadget/libs/jquery-1.8.0.min.js"></script>
//include the ILS library in your widget source
<script type="text/javascript" src="http://graasp.epfl.ch/ils_lib/main/ils.js"></script>
//example of calling the getCurrentUser api
ils.getCurrentUser(function(current_user){
// write your code here to use the current_user
// this line simply prints the current user's nickname
console.log(current_user);
});
//example of calling the getIls api
ils.getIls(function(ils_space){
// write your code here to use the ils_space
// this line simply prints the ILS space JSON representation
console.log(ils_space);
});
//example of calling readResource api
ils.readResource(15339, function(resource){
// write your code here to use the resource
// this line simply prints the returned resource's JSON representation
console.log(resource);
});
//example of calling createResource api
var example_content = {
"concepts": [
{
"x": 297,
"y": 188,
"content": "energy",
"id": "7f800d79-cd66-2167-724c-6c1cda7abc5e",
"type": "ut_tools_conceptmapper_conceptSelector",
"colorClass": "ut_tools_conceptmapper_blue"
},
{
"x": 652,
"y": 238,
"content": "thermodynamic temperature",
"id": "a1ad6ace-c722-ffa9-f58e-b4169acdb4e3",
"type": "ut_tools_conceptmapper_conceptSelector",
"colorClass": "ut_tools_conceptmapper_blue"
}
],
"relations": [
{
"source": "7f800d79-cd66-2167-724c-6c1cda7abc5e",
"target": "a1ad6ace-c722-ffa9-f58e-b4169acdb4e3",
"id": "con_71",
"content": "influences"
}
]
};
// create a resource in the Vault
ils.createResource("test", example_content, function(resource){
// write your code here to use the resource
// this line simply prints the created resource's JSON representation
console.log(resource);
});