Skip to content

Commit

Permalink
Reverting abstractStatementModel.js
Browse files Browse the repository at this point in the history
Reverting accidental changes to abstractStatementModel.js
  • Loading branch information
joe-replin authored Sep 26, 2024
1 parent 504b37b commit 8ea5c9c
Showing 1 changed file with 121 additions and 121 deletions.
242 changes: 121 additions & 121 deletions js/statements/abstractStatementModel.js
Original file line number Diff line number Diff line change
@@ -1,176 +1,176 @@
import Adapt from "core/js/adapt";
import Utils from "../utils";
define([
'core/js/adapt',
'../utils'
], function(Adapt, Utils) {

export default class AbstractStatementModel extends Backbone.Model {
var AbstractStatementModel = Backbone.Model.extend({

defaults() {
return {
defaults: {
recipeLang: 'en',
lang: 'en',
activityId: null,
registration: null,
revision: null,
contentRelease: null,
actor: null,
contextActivities: {
grouping: []
}
};
}
},

getData(model, state) {
const statement = new ADL.XAPIStatement();
statement.id = ADL.ruuid();
statement.actor = new ADL.XAPIStatement.Agent(this.get('actor'));
statement.verb = this.getVerb(model);
statement.object = this.getObject(model);
statement.context = this.getContext(model, state);
statement.timestamp = Utils.getTimestamp();
getData: function(model, state) {
const statement = new ADL.XAPIStatement();
statement.id = ADL.ruuid();
statement.actor = new ADL.XAPIStatement.Agent(this.get('actor'));
statement.verb = this.getVerb(model);
statement.object = this.getObject(model);
statement.context = this.getContext(model, state);
statement.timestamp = Utils.getTimestamp();

return statement;
}
return statement;
},

getVerb(model) {
// intentionally empty to be overriden by subclass
}
getVerb: function(model) {
// intentionally empty to be overriden by subclass
},

getActivityType(model) {
// intentionally empty to be overriden by subclass
}
getActivityType: function(model) {
// intentionally empty to be overriden by subclass
},

getObject(model) {
const object = new ADL.XAPIStatement.Activity(this.getUniqueIri(model));
getObject: function(model) {
const object = new ADL.XAPIStatement.Activity(this.getUniqueIri(model));

const definition = {
type: this.getActivityType(model),
name: this.getName(model)
};
const definition = {
type: this.getActivityType(model),
name: this.getName(model)
};

const extensions = this.getObjectExtensions(model);
const extensions = this.getObjectExtensions(model);

if (!(_.isEmpty(extensions))) definition.extensions = extensions;
if (!(_.isEmpty(extensions))) definition.extensions = extensions;

object.definition = definition;
object.definition = definition;

return object;
}
return object;
},

getObjectExtensions(model) {
const extensions = {};
const type = model.get('_type');
getObjectExtensions: function(model) {
const extensions = {};
const type = model.get('_type');

if (type) extensions['https://adaptlearning.org/xapi/extension/model'] = type;
if (type) extensions['https://adaptlearning.org/xapi/extension/model'] = type;

return extensions;
}
return extensions;
},

getContext(model, state) {
const context = {
contextActivities: this.getContextActivities(model),
extensions: this.getContextExtensions(model, state),
language: this.get('lang')
};
getContext: function(model, state) {
const context = {
contextActivities: this.getContextActivities(model),
extensions: this.getContextExtensions(model, state),
language: this.get('lang')
};

const registration = this.get('registration');
if (registration) context.registration = registration;
const registration = this.get('registration');
if (registration) context.registration = registration;

const revision = this.get('revision');
if (revision) context.revision = revision;
const revision = this.get('revision');
if (revision) context.revision = revision;

return context;
}
return context;
},

getContextActivities(model) {
const contextActivities = _.clone(this.get('contextActivities'));
contextActivities.grouping = this.getContextActivitiesGrouping(model);
getContextActivities: function(model) {
const contextActivities = _.clone(this.get('contextActivities'));
contextActivities.grouping = this.getContextActivitiesGrouping(model);

return contextActivities;
}
return contextActivities;
},

getContextActivitiesGrouping(model) {
const grouping = this.get('contextActivities').grouping.slice();
getContextActivitiesGrouping: function(model) {
const grouping = this.get('contextActivities').grouping.slice();

grouping.push(this.getCourseContextActivity());
grouping.push(this.getCourseContextActivity());

const modelType = model.get('_type');
const modelType = model.get('_type');

if (modelType && modelType !== 'course') {
grouping.push.apply(grouping, this.getContentObjectsContextActivities(model));
}
if (modelType && modelType !== 'course') {
grouping.push.apply(grouping, this.getContentObjectsContextActivities(model));
}

return grouping;
}
return grouping;
},

getCourseContextActivity() {
const object = AbstractStatementModel.prototype.getObject.call(this, Adapt.course);
object.definition.type = ADL.activityTypes.course;
getCourseContextActivity: function() {
const object = AbstractStatementModel.prototype.getObject.call(this, Adapt.course);
object.definition.type = ADL.activityTypes.course;

return object;
}
return object;
},

getContentObjectsContextActivities(model) {
const contentObjects = model.getAncestorModels(true).filter(function(model) {
const modelType = model.get('_type');
const isContentObject = modelType === 'menu' || modelType === 'page';
getContentObjectsContextActivities: function(model) {
const contentObjects = model.getAncestorModels(true).filter(function(model) {
const modelType = model.get('_type');
const isContentObject = modelType === 'menu' || modelType === 'page';

if (isContentObject) return model;
});
if (isContentObject) return model;
});

contentObjects.reverse();
contentObjects.reverse();

const activities = [];
const activities = [];

contentObjects.forEach(function(model) {
activities.push(this.getContentObjectContextActivity(model));
}, this);
contentObjects.forEach(function(model) {
activities.push(this.getContentObjectContextActivity(model));
}, this);

return activities;
}
return activities;
},

getContentObjectContextActivity(model) {
const modelType = model.get('_type');
const isContentObject = modelType === 'menu' || modelType === 'page';
const contentObject = (isContentObject) ? model : model.findAncestor('contentObjects');
const object = AbstractStatementModel.prototype.getObject.call(this, contentObject);
object.definition.type = ADL.activityTypes.module;
getContentObjectContextActivity: function(model) {
const modelType = model.get('_type');
const isContentObject = modelType === 'menu' || modelType === 'page';
const contentObject = (isContentObject) ? model : model.findAncestor('contentObjects');
const object = AbstractStatementModel.prototype.getObject.call(this, contentObject);
object.definition.type = ADL.activityTypes.module;

return object;
},

return object;
}
getContextExtensions: function(model, state) {
const buildConfig = Adapt.build;
const frameworkVersion = (buildConfig) ? buildConfig.get('package').version : '<3.0.0';

getContextExtensions(model, state) {
const buildConfig = Adapt.build;
const frameworkVersion = (buildConfig) ? buildConfig.get('package').version : '<3.0.0';
const specificationRevision = this.get('revision');
const contentRelease = this.get('contentRelease');
const extensions = {
'https://adaptlearning.org/xapi/extension/framework': 'Adapt',
'https://adaptlearning.org/xapi/extension/framework_version': frameworkVersion
};

const extensions = {
'https://adaptlearning.org/xapi/extension/framework': 'Adapt',
'https://adaptlearning.org/xapi/extension/framework_version': frameworkVersion,
'https://adaptlearning.org/xapi/extension/specification_revision': specificationRevision,
'https://adaptlearning.org/xapi/extension/content_release': contentRelease
};
return extensions;
},

return extensions;
}
getName: function(model) {
const name = {};
name[this.get('lang')] = model.get('title') || model.get('displayTitle');

getName(model) {
const name = {};
name[this.get('lang')] = model.get('title') || model.get('displayTitle');
return name;
},

return name;
}
getUniqueIri: function(model) {
let iri = this.get('activityId');

getUniqueIri(model) {
let iri = this.get('activityId');
if (model && model.get('_type') !== 'course') {
iri += '/' + model.get('_id');
}

if (model && model.get('_type') !== 'course') {
iri += '/' + model.get('_id');
return iri;
},

getISO8601Duration: function(milliseconds) {
return Utils.getISO8601Duration(milliseconds);
}

return iri;
}
});

return AbstractStatementModel;

getISO8601Duration(milliseconds) {
return Utils.getISO8601Duration(milliseconds);
}
}
});

0 comments on commit 8ea5c9c

Please sign in to comment.