README
A set of utilities that make it easy to interact with LOReS. There is two components: RegistryService and RegistryUtilities. RegistryService contains a set of APIs to call LOReS that return a promise which will be fulfilled when the request is complete. The service calls use 'superagent-d2l-promise-queue' which allows queuing requests in order to perform sequential writes.It also provides the ability to retry requests which have failed due to a connection error. Calls that perform updates or writes will use the queue. Get calls will be performed without a queue. Each RegistryService API call returns a promise. RegistryUtilities contains helper functions to perform actions on the registry and the objectives contained within the registry.
Usage
import { RegistryService, RegistryUtilities } from 'lores-util';
var registryService = RegistryService( serviceEndPoint );
registryService.getRegistryAsync( 1 )
.then( registry => {
RegistryUtilities.cacheStructure( registry );
return registry;
});
RegistryService API
Use LOReS API which can be found here: http://docs.objectivelistservice.apiary.io
additionalAuthorization: Object: (OPTIONAL) Additional Authorization data in JSON format
getManyRegistriesAsync( registryIds, additionalAuthorization )
getManyRegistriesCachedAsync( registryIds, additionalAuthorization )
registryIds: Array: List of registryIds to fetch
Cached version of call returns array of registries with cache structure applied to each registry
getRegistryAsync( registryId, additionalAuthorization )
getRegistryCachedAsync( registryId, additionalAuthorization )
registryId: Int: Id of registry to fetch
Cached version of call returns cacheStructure applied to registry
updateRegistriesBulkAsync( registries, additionalAuthorization )
registries: Array: List of registries to update
updateRegistryAsync( registry, registryId, additionalAuthorization )
Update registry
createRegistryAsync( owner, additionalAuthorization )
Create registry
owner: String: consumer stack
deleteRegistryAsync( registryId )
registryId: Int: Id of registry
createAuthoredObjectiveAsync( owner, notation, description, groupId, type, additionalAuthorization )
Create authored objective first and then perform a bulk create to create objective mapping
owner: String: consumer stack
notation: String: Objective notation
description: String: Description of objective
groupId: Int: Group which objective will belong to
type: String: Type of objective: 'CLO' or 'PLO'
updateAuthoredObjectiveAsync( notation, description, groupId, type, objectiveId )
objectiveId: Int: Source Id of objective
Uses the same parameters as in createAuthoredObjectiveAsync
createObjectiveGroupAsync( owner, additionalAuthorization )
Create objective group for authored objectives to be mapped to
owner: String: consumer stack
bulkCreateObjectivesAsync( owner, sources, additionalAuthorization )
owner: String: consumer stack
sources: Array: List of sources to create
sources = [{
source_id: 2,
source_type: 'lores'
}]
RegistryUtilities API
cacheStructure( registry )
Create a cache structure for objectives and appends it to the registry object. Leaves hash and list will contain PLO Leaves and not CLO leaves.
RegistryUtilities.cache( registry );
registry.cache.leaves // Array of plo leaves
registry.cache.leavesMap // objectiveIdToObjectiveHash of plo leaves
registry.cache.objectives // Array of objectives
registry.cache.objectivesMap // objectiveIdToObjectiveHash of all objectives
//Ancestor cache found in each objective in above hashMap or Array
registry.cache.leaves[0].cache.ancestorIdsHashSet // ancestor Hash
registry.cache.leaves[0].cache.ancestorIds // List of ancestor Ids. Found
sortCLOs( plo, cloId, afterCloId )
Sorts clos within a plo
removeCLO( plo, cloId )
Removes a CLO from a PLO
createUpdatedRegistryPayload( registry )
Will create the payload registry to attach when updating a registry. Will remove objectives that contain the property isTempOutcome
.
Ex. Objective with Id: 3 will not be included in the registry payload
{
id: 1
objectives: [
{ id: 2, children: [] },
{ id: 3, children: [], isTempOutcome: true }
]
}