Skip to content

Commit

Permalink
Udpated README and added comment to config obj
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrolds committed Mar 28, 2017
1 parent f763413 commit db51416
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 1 deletion.
95 changes: 94 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ var Config = function()
// conf["registration"] = ruuid();
// conf["grouping"] = {"id":"ctxact:default/grouping"};
// conf["activity_platform"] = "default platform";

// Behavior defaults
// conf["strictCallbacks"] = false; // Strict error-first callbacks
return conf
}();
```
Expand Down Expand Up @@ -407,6 +410,25 @@ ADL.XAPIWrapper.sendStatement(stmt, function(resp, obj){
>> [4edfe763-8b84-41f1-a355-78b7601a6fe8]: 200 - OK
```

###### Send Statement with strict error-first callback

Requires the config option `strictCallbacks` to be `true`.

```JavaScript
var stmt = {"actor" : {"mbox" : "mailto:[email protected]"},
"verb" : {"id" : "http://adlnet.gov/expapi/verbs/answered",
"display" : {"en-US" : "answered"}},
"object" : {"id" : "http://adlnet.gov/expapi/activities/question"}};
ADL.XAPIWrapper.sendStatement(stmt, function(err, res, body) {
if (err) {
// Handle error case
return;
}

ADL.XAPIWrapper.log("[" + body.id + "]: " + res.status + " - " + res.statusText);});
>> [4edfe763-8b84-41f1-a355-78b7601a6fe8]: 200 - OK
```

###### Send Statement with Attachments
The wrapper can construct a `multipart/mixed` POST for a single statement that includes attachments. Attachments should be
supplied as an array in the 3rd parameter to `sendStatement`. Attachments are optional. The attachments array should consist of
Expand Down Expand Up @@ -538,6 +560,29 @@ ADL.XAPIWrapper.sendStatements(stmts, function(r){ADL.XAPIWrapper.log(JSON.parse
>> ["2d819ea4-1a1e-11e3-a888-08002787eb49", "409c27de-1a1e-11e3-a888-08002787eb49"]
```

###### Send Statements with strict error-first callback

Requires the config option `strictCallbacks` to be `true`.

```JavaScript
var stmt = {"actor" : {"mbox" : "mailto:[email protected]"},
"verb" : ADL.verbs.answered,
"object" : {"id" : "http://adlnet.gov/expapi/activities/question/1"}};
var stmt2 = {"actor" : {"mbox" : "mailto:[email protected]"},
"verb" : ADL.verbs.answered,
"object" : {"id" : "http://adlnet.gov/expapi/activities/question/2"}};
var stmts = [stmt, stmt2];
ADL.XAPIWrapper.sendStatements(stmts, function(err, res, body) {
if (err) {
// Handle error case
return;
}

ADL.XAPIWrapper.log(body);
});
>> ["2d819ea4-1a1e-11e3-a888-08002787eb49", "409c27de-1a1e-11e3-a888-08002787eb49"]
```

##### Get Statements
`function getStatements(searchParams, more, callback)`
Get a single or collection of Statements based on
Expand All @@ -557,7 +602,6 @@ if (ret)
```

###### Get all Statements with callback

```JavaScript
ADL.XAPIWrapper.getStatements(null, null,
function(r){ADL.XAPIWrapper.log(JSON.parse(r.response).statements);});
Expand Down Expand Up @@ -594,6 +638,22 @@ ADL.XAPIWrapper.getStatements(null, null,
...
```

###### Get all Statements with with strict error-first callback

Requires the config option `strictCallbacks` to be `true`.

```JavaScript
ADL.XAPIWrapper.getStatements(null, null, function(err, res, body) {
if (err) {
// Handle error case
return;
}

ADL.XAPIWrapper.log(body.statements);
});
>> <Array of statements>
```

###### Get Statements based on search parameters
The Experience API provides search parameters to narrow down
the result of a Statement request. See the [Experience API Spec](https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#723-getstatements)
Expand Down Expand Up @@ -638,6 +698,23 @@ ADL.XAPIWrapper.getActivities("http://adlnet.gov/expapi/activities/question",
>> <Activity object>
```

###### Get Activity with strict error-first callback

Requires the config option `strictCallbacks` to be `true`.

```JavaScript
ADL.XAPIWrapper.getActivities("http://adlnet.gov/expapi/activities/question", function(err, res, body) {
if (err) {
// Handle error case
return;
}

ADL.XAPIWrapper.log(body);
});
>> <Activity object>
```


##### Activity State
`function sendState(activityid, agent, stateid, registration, statevalue, matchHash, noneMatchHash, callback)`
`function getState(activityid, agent, stateid, registration, since, callback)`
Expand Down Expand Up @@ -841,6 +918,22 @@ ADL.XAPIWrapper.getAgents({"mbox":"mailto:[email protected]"},
>> <Person object>
```

###### Get Agent with strict error-first callbacks

Requires the config option `strictCallbacks` to be `true`.

```JavaScript
ADL.XAPIWrapper.getAgents({"mbox":"mailto:[email protected]"}, function(err, res, body) {
if (err) {
// Handle error case
return;
}

ADL.XAPIWrapper.log(body);
});
>> <Person object>
```

##### Agent Profile
`function sendAgentProfile(agent, profileid, profilevalue, matchHash, noneMatchHash, callback)`
`function getAgentProfile(agent, profileid, since, callback)`
Expand Down
3 changes: 3 additions & 0 deletions src/xapiwrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ function isDate(date) {
// conf["registration"] = ruuid();
// conf["grouping"] = {"id":"ctxact:default/grouping"};
// conf["activity_platform"] = "default platform";

// Behavior defaults
// conf["strictCallbacks"] = false; // Strict error-first callbacks
return conf
}();

Expand Down

0 comments on commit db51416

Please sign in to comment.