Skip to content
This repository was archived by the owner on Dec 14, 2020. It is now read-only.

Commit 87bba42

Browse files
lydiamrossryasmi
authored andcommitted
feat: Adds planned face-to-face statement creator (#1)
1 parent b6c669b commit 87bba42

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

src/examples/plannedFaceToFace.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import plannedFaceToFace from '../statementCreators/plannedFaceToFace';
2+
3+
const statement = plannedFaceToFace({
4+
actionDate: new Date(),
5+
activityUrl: 'https://demo.example.org/courses/demo-course',
6+
siteUrl: 'https://demo.example.org',
7+
siteName: 'Demo Example Site',
8+
platformUrl: 'https://example.org',
9+
platformName: 'Example Platform',
10+
userId: '123',
11+
userIdProviderUrl: 'https://demo.example.org',
12+
userEmail: 'demo@example.org',
13+
userDisplayName: 'Demo User',
14+
});
15+
16+
export default statement;

src/statementConstants/activityTypes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export const document = 'http://id.tincanapi.com/activitytype/document';
6060
*/
6161
export const event = 'http://activitystrea.ms/schema/1.0/event';
6262

63+
/**
64+
* Represents a face to face meeting or appointment
65+
*/
66+
export const faceToFace = 'https://w3id.org/xapi/acrossx/activities/face-to-face-discussion';
67+
6368
/**
6469
* Represents a graphical image.
6570
* https://registry.tincanapi.com/#uri/activityType/65

src/statementConstants/verbs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const liked = createVerb('https://w3id.org/xapi/acrossx/verbs/liked', 'li
3030
export const loggedIn = createVerb('https://w3id.org/xapi/adl/verbs/logged-in', 'logged into');
3131
export const loggedOut = createVerb('https://w3id.org/xapi/adl/verbs/logged-out', 'logged out of');
3232
export const opened = createVerb('http://activitystrea.ms/schema/1.0/open', 'opened');
33+
export const planned = createVerb('https://w3id.org/xapi/dod-isd/verbs/planned', 'planned');
3334
export const posted = createVerb('https://w3id.org/xapi/acrossx/verbs/posted', 'posted');
3435
export const registered = createVerb('http://adlnet.gov/expapi/verbs/registered', 'registered to');
3536
export const replied = createVerb('http://id.tincanapi.com/verb/replied', 'replied');
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import UserSiteAction from '../actionUtils/UserSiteAction';
2+
import { faceToFace, site, source } from '../statementConstants/activityTypes';
3+
import { planned } from '../statementConstants/verbs';
4+
import createActivity from '../statementUtils/createActivity';
5+
import createAgent from '../statementUtils/createAgent';
6+
import createTimestamp from '../statementUtils/createTimestamp';
7+
import { Extensions, Statement } from '../statementUtils/types';
8+
9+
export interface PlannedFaceToFaceAction extends UserSiteAction {
10+
/** The URL where the activity can be accessed. */
11+
readonly activityUrl: string;
12+
13+
/** The human readable name for the activity. */
14+
readonly activityName?: string;
15+
16+
/** Additional properties of the activity. */
17+
readonly activityExtensions?: Extensions;
18+
}
19+
20+
/**
21+
* Creates an xAPI Statement to represent a user planning a face-to-face meeting.
22+
*/
23+
export default function plannedFaceToFace(action: PlannedFaceToFaceAction): Statement {
24+
return {
25+
timestamp: createTimestamp(action.actionDate),
26+
actor: createAgent({
27+
displayName: action.userDisplayName,
28+
id: action.userId,
29+
idProviderUrl: action.userIdProviderUrl,
30+
email: action.userEmail,
31+
}),
32+
verb: planned,
33+
object: createActivity({
34+
type: faceToFace,
35+
url: action.siteUrl,
36+
name: action.activityName,
37+
extensions: action.activityExtensions,
38+
}),
39+
context: {
40+
platform: action.platformName,
41+
language: 'en',
42+
extensions: action.contextExtensions,
43+
contextActivities: {
44+
grouping: [createActivity({
45+
type: site,
46+
url: action.siteUrl,
47+
name: action.siteName,
48+
})],
49+
category: [createActivity({
50+
type: source,
51+
url: action.platformUrl,
52+
name: action.platformName,
53+
})],
54+
},
55+
},
56+
};
57+
}

0 commit comments

Comments
 (0)