Skip to content

Commit

Permalink
Merge d92bba8 into a1d7754
Browse files Browse the repository at this point in the history
  • Loading branch information
stavmars committed Aug 9, 2018
2 parents a1d7754 + d92bba8 commit cfd2a78
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 285 deletions.
37 changes: 9 additions & 28 deletions application/lib/transforms/add.js
@@ -1,38 +1,19 @@
'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({
module.exports = {

verb: {
id: 'http://activitystrea.ms/schema/1.0/create',
display: {
en: 'created',
},
transform: function (activity) {
let statementCfg = xapi.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
38 changes: 9 additions & 29 deletions application/lib/transforms/comment.js
@@ -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',
},
},

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,
},
},
module.exports = {
transform: function (activity) {
let statementCfg = xapi.prepareStatement(activity);
statementCfg.verb = {
id: 'http://adlnet.gov/expapi/verbs/commented',
display: {
en: 'commented',
},

});

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

Expand Down
8 changes: 5 additions & 3 deletions application/lib/transforms/delete.js
Expand Up @@ -5,9 +5,10 @@ const Microservices = require('../../configs/microservices');

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

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

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

Expand All @@ -31,9 +32,10 @@ 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: xapi.context(activity),
});

return statement;
Expand Down
38 changes: 9 additions & 29 deletions application/lib/transforms/download.js
@@ -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',
},
},

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,
},
},
module.exports = {
transform: function (activity) {
let statementCfg = xapi.prepareStatement(activity);
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/downloaded',
display: {
en: 'downloaded',
},

});

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

Expand Down
37 changes: 9 additions & 28 deletions application/lib/transforms/edit.js
@@ -1,38 +1,19 @@
'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({
module.exports = {

verb: {
id: 'https://w3id.org/xapi/acrossx/verbs/edited',
display: {
en: 'edited',
},
transform: function (activity) {
let statementCfg = xapi.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
37 changes: 9 additions & 28 deletions application/lib/transforms/fork.js
@@ -1,38 +1,19 @@
'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({
module.exports = {

verb: {
id: 'https://w3id.org/xapi/acrossx/verbs/forked',
display: {
en: 'forked',
},
transform: function (activity) {
let statementCfg = xapi.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
36 changes: 10 additions & 26 deletions application/lib/transforms/react.js
Expand Up @@ -3,44 +3,28 @@
const boom = require('boom');

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

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

const self = module.exports = {
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 = xapi.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;

},

};
37 changes: 9 additions & 28 deletions application/lib/transforms/reply.js
@@ -1,38 +1,19 @@
'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({
module.exports = {

verb: {
id: 'https://w3id.org/xapi/acrossx/verbs/replied',
display: {
en: 'replied',
},
transform: function (activity) {
let statementCfg = xapi.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 cfd2a78

Please sign in to comment.