Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Composes cfg object trying to take values from GET params, using defaults if provided,
- * for most values. Others such as lesson description should not be passed through GET params, due to it's length.
- * @method configFromParams
- * @param {Object} [cfg] Default configuration
- * @param {String} [cfg.attemptIRI] Needs to be provided if this is a resume attempt action.
- * @param {String} [cfg.courserIRI] Obligatory if not provided in params.
- * @param {String} [cfg.courserTitle] Recommended if not provided in params.
- * @param {String} [cfg.courseDescription] Recommended if not provided in params.
- * @param {String} [cfg.endpoint] LRS endpoint URL
- * @param {String} [cfg.auth] Authorization token for the LRS, will be passed in the "Authorization" header.
- * @param {String} [cfg.lessonIRI] Obligatory if not provided in the params.
- * @param {String} cfg.lessonTitle
- * @param {String} cfg.lessonDescription Recommended if not provided in params.
- * @param {String} [cfg.entry] "ab-initio" or "resume"
- * @param {Object} [cfg.actor] Obligatory if not provided in params.
- * @param {Object} cfg.actor.account Recommended if not provided in params.
- * @param {String} cfg.actor.account.homePage User origin, usually location of the LMS.
- * @param {String} cfg.actor.account.name User identifier.
- * @return {Object} Config object with parameters fetched form the GET params.
- */
- xAPI.configFromParams = function(cfg){
- var params = getParams();
- cfg.attemptIRI = params.attemptIRI || cfg.attemptIRI;
- cfg.entry = params.entry || cfg.entry;
- cfg.courseIRI = params.courseIRI || cfg.courseIRI;
- cfg.courseTitle = params.courseTitle || cfg.courseTitle;
- cfg.courseDescription = params.courseDescription || cfg.courseDescription;
- cfg.endpoint = params.endpoint || cfg.endpoint;
- cfg.auth = params.auth || cfg.auth;
- cfg.lessonIRI = params.lessonIRI || cfg.lessonIRI;
- cfg.lessonDescription = params.lessonDescription || cfg.lessonDescription;
- cfg.username = params.username || cfg.username;
- cfg.password = params.password || cfg.password;
- var actor = params.actor;
- if (actor){
- cfg.actor = JSON.parse(actor);
- }
- return cfg;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement