Skip to content

Commit

Permalink
Add tags to deck related activities in lrs
Browse files Browse the repository at this point in the history
  • Loading branch information
stavmars committed Aug 8, 2018
1 parent 3b261cb commit 677ddc6
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 52 deletions.
4 changes: 2 additions & 2 deletions application/lib/transforms/add.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

const TinCan = require('tincanjs');
const transformUtil = require('./transformUtil');
const xapi = require('../xapiUtil');

module.exports = {

transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
let statementCfg = xapi.prepareStatement(activity);
statementCfg.verb = {
id: 'http://activitystrea.ms/schema/1.0/create',
display: {
Expand Down
4 changes: 2 additions & 2 deletions application/lib/transforms/comment.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

const TinCan = require('tincanjs');
const transformUtil = require('./transformUtil');
const xapi = require('../xapiUtil');

module.exports = {
transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
let statementCfg = xapi.prepareStatement(activity);
statementCfg.verb = {
id: 'http://adlnet.gov/expapi/verbs/commented',
display: {
Expand Down
4 changes: 2 additions & 2 deletions application/lib/transforms/download.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

const TinCan = require('tincanjs');
const transformUtil = require('./transformUtil');
const xapi = require('../xapiUtil');

module.exports = {
transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
let statementCfg = xapi.prepareStatement(activity);
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/downloaded',
display: {
Expand Down
4 changes: 2 additions & 2 deletions application/lib/transforms/edit.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

const TinCan = require('tincanjs');
const transformUtil = require('./transformUtil');
const xapi = require('../xapiUtil');

module.exports = {

transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
let statementCfg = xapi.prepareStatement(activity);
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/edited',
display: {
Expand Down
4 changes: 2 additions & 2 deletions application/lib/transforms/fork.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

const TinCan = require('tincanjs');
const transformUtil = require('./transformUtil');
const xapi = require('../xapiUtil');

module.exports = {

transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
let statementCfg = xapi.prepareStatement(activity);
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/forked',
display: {
Expand Down
4 changes: 2 additions & 2 deletions application/lib/transforms/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const boom = require('boom');

const TinCan = require('tincanjs');
const transformUtil = require('./transformUtil');
const xapi = require('../xapiUtil');

module.exports = {

Expand All @@ -13,7 +13,7 @@ module.exports = {
throw boom.badData(`Unsupported reaction type: ${activity.react_type}`);
}

let statementCfg = transformUtil.prepareStatement(activity);
let statementCfg = xapi.prepareStatement(activity);

statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/liked',
Expand Down
4 changes: 2 additions & 2 deletions application/lib/transforms/reply.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

const TinCan = require('tincanjs');
const transformUtil = require('./transformUtil');
const xapi = require('../xapiUtil');

module.exports = {

transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
let statementCfg = xapi.prepareStatement(activity);
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/replied',
display: {
Expand Down
4 changes: 2 additions & 2 deletions application/lib/transforms/share.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

const TinCan = require('tincanjs');
const transformUtil = require('./transformUtil');
const xapi = require('../xapiUtil');

module.exports = {

transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
let statementCfg = xapi.prepareStatement(activity);
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/shared',
display: {
Expand Down
31 changes: 0 additions & 31 deletions application/lib/transforms/transformUtil.js

This file was deleted.

4 changes: 2 additions & 2 deletions application/lib/transforms/use.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

const TinCan = require('tincanjs');
const transformUtil = require('./transformUtil');
const xapi = require('../xapiUtil');

module.exports = {

transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
let statementCfg = xapi.prepareStatement(activity);
statementCfg.verb = {
id: 'https://w3id.org/xapi/acrossx/verbs/used',
display: {
Expand Down
4 changes: 2 additions & 2 deletions application/lib/transforms/view.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

const TinCan = require('tincanjs');
const transformUtil = require('./transformUtil');
const xapi = require('../xapiUtil');

module.exports = {

transform: function (activity) {
let statementCfg = transformUtil.prepareStatement(activity);
let statementCfg = xapi.prepareStatement(activity);
statementCfg.verb = {
id: 'http://adlnet.gov/expapi/verbs/experienced',
display: {
Expand Down
42 changes: 41 additions & 1 deletion application/lib/xapiUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,47 @@

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

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

prepareStatement: function (activity) {
let statementCfg = {
actor: self.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,
},
type: activity.content_kind === 'deck' ? 'http://id.tincanapi.com/activitytype/slide-deck' : 'http://id.tincanapi.com/activitytype/slide',
},
},
context: {
language: activity.content.language,
},
};

let tags = activity.content.tags;
if (tags && tags.length > 0) {
let categories = tags.map((tag) => {
return {
id: `${Microservices.platform.uri}/deckfamily/${tag.tagName}`,
objectType: 'Activity',
definition: {
name: {
en: tag.defaultName
},
type: 'http://id.tincanapi.com/activitytype/tag',
},
};
});
statementCfg.context.contextActivities = {category: categories};
}

return statementCfg;
},

actor: function(user) {
return {
Expand Down

0 comments on commit 677ddc6

Please sign in to comment.