Fixing complexity issue in AICC API
This commit is contained in:
83
src/AICC.js
83
src/AICC.js
@@ -1,52 +1,49 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import Scorm12API from './Scorm12API';
|
import Scorm12API from './Scorm12API';
|
||||||
import {
|
import {CMIEvaluationCommentsObject, CMITriesObject, NAV} from './cmi/aicc_cmi';
|
||||||
CMIInteractionsCorrectResponsesObject,
|
|
||||||
CMIInteractionsObject,
|
|
||||||
CMIInteractionsObjectivesObject,
|
|
||||||
CMIObjectivesObject
|
|
||||||
} from "./cmi/scorm12_cmi";
|
|
||||||
import {CMIEvaluationCommentsObject, CMITriesObject, NAV} from "./cmi/aicc_cmi";
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The AICC API class
|
||||||
|
*/
|
||||||
class AICC extends Scorm12API {
|
class AICC extends Scorm12API {
|
||||||
constructor() {
|
/**
|
||||||
super();
|
* Constructor to create AICC API object
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
this.nav = new NAV(this);
|
this.nav = new NAV(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets or builds a new child element to add to the array.
|
||||||
|
*
|
||||||
|
* @param {string} CMIElement
|
||||||
|
* @param {any} value
|
||||||
|
* @return {object}
|
||||||
|
*/
|
||||||
|
getChildElement(CMIElement, value) {
|
||||||
|
let newChild = super.getChildElement(CMIElement);
|
||||||
|
|
||||||
|
if (!newChild) {
|
||||||
|
if (this.stringContains(CMIElement, 'cmi.evaluation.comments')) {
|
||||||
|
newChild = new CMIEvaluationCommentsObject(this);
|
||||||
|
} else if (this.stringContains(CMIElement, 'cmi.student_data.tries')) {
|
||||||
|
newChild = new CMITriesObject(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
return newChild;
|
||||||
* Gets or builds a new child element to add to the array.
|
}
|
||||||
*
|
|
||||||
* @param CMIElement
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
getChildElement(CMIElement, value) {
|
|
||||||
let newChild;
|
|
||||||
|
|
||||||
if (this.stringContains(CMIElement, "cmi.objectives")) {
|
/**
|
||||||
newChild = new CMIObjectivesObject(this);
|
* Replace the whole API with another
|
||||||
} else if (this.stringContains(CMIElement, ".correct_responses")) {
|
*
|
||||||
newChild = new CMIInteractionsCorrectResponsesObject(this);
|
* @param {AICC} newAPI
|
||||||
} else if (this.stringContains(CMIElement, ".objectives")) {
|
*/
|
||||||
newChild = new CMIInteractionsObjectivesObject(this);
|
replaceWithAnotherScormAPI(newAPI) {
|
||||||
} else if (this.stringContains(CMIElement, "cmi.interactions")) {
|
// Data Model
|
||||||
newChild = new CMIInteractionsObject(this);
|
this.cmi = newAPI.cmi;
|
||||||
} else if (this.stringContains(CMIElement, "cmi.evaluation.comments")) {
|
this.nav = newAPI.nav;
|
||||||
newChild = new CMIEvaluationCommentsObject(this);
|
}
|
||||||
} else if (this.stringContains(CMIElement, "cmi.student_data.tries")) {
|
|
||||||
newChild = new CMITriesObject(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace the whole API with another
|
|
||||||
*/
|
|
||||||
replaceWithAnotherScormAPI(newAPI) {
|
|
||||||
// Data Model
|
|
||||||
this.cmi = newAPI.cmi;
|
|
||||||
this.nav = newAPI.nav;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,10 +112,11 @@ export default class Scorm12API extends BaseAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets or builds a new child element to add to the array.
|
* Gets or builds a new child element to add to the array.
|
||||||
*
|
*
|
||||||
* @param CMIElement
|
* @param CMIElement
|
||||||
*/
|
* @param value
|
||||||
|
*/
|
||||||
getChildElement(CMIElement, value) {
|
getChildElement(CMIElement, value) {
|
||||||
let newChild;
|
let newChild;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user