Adding ability to load initial data from flattened JSON object

This commit is contained in:
Jonathan Putney
2019-11-18 10:41:59 -05:00
parent 6131021d9c
commit 9fa9769f1d

View File

@@ -3,6 +3,7 @@ import {CMIArray} from './cmi/common';
import {ValidationError} from './exceptions';
import {scorm12_error_codes} from './constants/error_codes';
import {global_constants} from './constants/api_constants';
import {unflatten} from './utilities';
/**
* Base API class for AICC, SCORM 1.2, and SCORM 2004. Should be considered
@@ -766,6 +767,15 @@ export default class BaseAPI {
'The storeData method has not been implemented');
}
/**
* Load the CMI from a flattened JSON object
* @param {object} json
* @param {string} CMIElement
*/
loadFromFlattenedJSON(json, CMIElement) {
this.loadFromJSON(unflatten(json), CMIElement);
}
/**
* Loads CMI data from a JSON object.
*