Skip to content

Commit

Permalink
Add lang aqd content type to xapi statements
Browse files Browse the repository at this point in the history
  • Loading branch information
stavmars committed Aug 8, 2018
1 parent a1d7754 commit 3b261cb
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 295 deletions.
39 changes: 10 additions & 29 deletions application/lib/transforms/add.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
'use strict';

const TinCan = require('tincanjs');
const Microservices = require('../../configs/microservices');
const transformUtil = require('./transformUtil');

const xapi = require('../xapiUtil');
module.exports = {

const self = module.exports = {

transform: function(activity) {
let statement = new TinCan.Statement({

verb: {
id: 'http://activitystrea.ms/schema/1.0/create',
display: {
en: 'created',
},
transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
statementCfg.verb = {
id: 'http://activitystrea.ms/schema/1.0/create',
display: {
en: 'created',
},

actor: xapi.actor(activity.user),

object: {
id: `${Microservices.platform.uri}/${activity.content_kind}/${activity.content_id}`,
definition: {
name: {
en: activity.content.title,
},
description: {
en: activity.content.description || undefined,
},
},
},

});

};
let statement = new TinCan.Statement(statementCfg);
return statement;
},

Expand Down
42 changes: 11 additions & 31 deletions application/lib/transforms/comment.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
'use strict';

const TinCan = require('tincanjs');
const Microservices = require('../../configs/microservices');

const xapi = require('../xapiUtil');

const self = module.exports = {

transform: function(activity) {
let statement = new TinCan.Statement({

verb: {
id: 'http://adlnet.gov/expapi/verbs/commented',
display: {
en: 'commented',
},
const transformUtil = require('./transformUtil');

module.exports = {
transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
statementCfg.verb = {
id: 'http://adlnet.gov/expapi/verbs/commented',
display: {
en: 'commented',
},

actor: xapi.actor(activity.user),

object: {
id: `${Microservices.platform.uri}/${activity.content_kind}/${activity.content_id}`,
definition: {
name: {
en: activity.content.title,
},
description: {
en: activity.content.description || undefined,
},
},
},

});

};
let statement = new TinCan.Statement(statementCfg);
return statement;
},

Expand Down
8 changes: 6 additions & 2 deletions application/lib/transforms/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const Microservices = require('../../configs/microservices');

const xapi = require('../xapiUtil');

const self = module.exports = {
module.exports = {

transform: function(activity) {
transform: function (activity) {
let deleted = activity.delete_info;
let platformPath = deleted.content_kind === 'deck' ? 'deck' : 'slideview';

Expand All @@ -31,8 +31,12 @@ const self = module.exports = {
description: {
en: deleted.content_name,
},
type: deleted.content_kind === 'deck' ? 'http://id.tincanapi.com/activitytype/slide-deck' : 'http://id.tincanapi.com/activitytype/slide',
},
},
context: {
language: activity.content.language,
},

});

Expand Down
42 changes: 11 additions & 31 deletions application/lib/transforms/download.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
'use strict';

const TinCan = require('tincanjs');
const Microservices = require('../../configs/microservices');

const xapi = require('../xapiUtil');

const self = module.exports = {

transform: function(activity) {
let statement = new TinCan.Statement({

verb: {
id: 'https://w3id.org/xapi/acrossx/verbs/downloaded',
display: {
en: 'downloaded',
},
const transformUtil = require('./transformUtil');

module.exports = {
transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/downloaded',
display: {
en: 'downloaded',
},

actor: xapi.actor(activity.user),

object: {
id: `${Microservices.platform.uri}/${activity.content_kind}/${activity.content_id}`,
definition: {
name: {
en: activity.content.title,
},
description: {
en: activity.content.description || undefined,
},
},
},

});

};
let statement = new TinCan.Statement(statementCfg);
return statement;
},

Expand Down
39 changes: 10 additions & 29 deletions application/lib/transforms/edit.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
'use strict';

const TinCan = require('tincanjs');
const Microservices = require('../../configs/microservices');
const transformUtil = require('./transformUtil');

const xapi = require('../xapiUtil');
module.exports = {

const self = module.exports = {

transform: function(activity) {
let statement = new TinCan.Statement({

verb: {
id: 'https://w3id.org/xapi/acrossx/verbs/edited',
display: {
en: 'edited',
},
transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/edited',
display: {
en: 'edited',
},

actor: xapi.actor(activity.user),

object: {
id: `${Microservices.platform.uri}/${activity.content_kind}/${activity.content_id}`,
definition: {
name: {
en: activity.content.title,
},
description: {
en: activity.content.description || undefined,
},
},
},

});

};
let statement = new TinCan.Statement(statementCfg);
return statement;
},

Expand Down
39 changes: 10 additions & 29 deletions application/lib/transforms/fork.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
'use strict';

const TinCan = require('tincanjs');
const Microservices = require('../../configs/microservices');
const transformUtil = require('./transformUtil');

const xapi = require('../xapiUtil');
module.exports = {

const self = module.exports = {

transform: function(activity) {
let statement = new TinCan.Statement({

verb: {
id: 'https://w3id.org/xapi/acrossx/verbs/forked',
display: {
en: 'forked',
},
transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/forked',
display: {
en: 'forked',
},

actor: xapi.actor(activity.user),

object: {
id: `${Microservices.platform.uri}/${activity.content_kind}/${activity.content_id}`,
definition: {
name: {
en: activity.content.title,
},
description: {
en: activity.content.description || undefined,
},
},
},

});

};
let statement = new TinCan.Statement(statementCfg);
return statement;
},

Expand Down
38 changes: 11 additions & 27 deletions application/lib/transforms/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,28 @@
const boom = require('boom');

const TinCan = require('tincanjs');
const Microservices = require('../../configs/microservices');
const transformUtil = require('./transformUtil');

const xapi = require('../xapiUtil');
module.exports = {

const self = module.exports = {

transform: function(activity) {
transform: function (activity) {
// TODO support more reaction types ?
if (activity.react_type !== 'like') {
throw boom.badData(`Unsupported reaction type: ${activity.react_type}`);
}

let statement = new TinCan.Statement({

verb: {
id: 'https://w3id.org/xapi/acrossx/verbs/liked',
display: {
en: 'liked',
},
},
let statementCfg = transformUtil.prepareStatement(activity);

actor: xapi.actor(activity.user),

object: {
id: `${Microservices.platform.uri}/${activity.content_kind}/${activity.content_id}`,
definition: {
name: {
en: activity.content.title,
},
description: {
en: activity.content.description || undefined,
},
},
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/liked',
display: {
en: 'liked',
},
};

});

let statement = new TinCan.Statement(statementCfg);
return statement;

},

};
39 changes: 10 additions & 29 deletions application/lib/transforms/reply.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
'use strict';

const TinCan = require('tincanjs');
const Microservices = require('../../configs/microservices');
const transformUtil = require('./transformUtil');

const xapi = require('../xapiUtil');
module.exports = {

const self = module.exports = {

transform: function(activity) {
let statement = new TinCan.Statement({

verb: {
id: 'https://w3id.org/xapi/acrossx/verbs/replied',
display: {
en: 'replied',
},
transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/replied',
display: {
en: 'replied',
},

actor: xapi.actor(activity.user),

object: {
id: `${Microservices.platform.uri}/${activity.content_kind}/${activity.content_id}`,
definition: {
name: {
en: activity.content.title,
},
description: {
en: activity.content.description || undefined,
},
},
},

});

};
let statement = new TinCan.Statement(statementCfg);
return statement;
},

Expand Down

0 comments on commit 3b261cb

Please sign in to comment.