Advertisement
Guest User

Untitled

a guest
Feb 6th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. /**
  2. * Composes cfg object trying to take values from GET params, using defaults if provided,
  3. * for most values. Others such as lesson description should not be passed through GET params, due to it's length.
  4. * @method configFromParams
  5. * @param {Object} [cfg] Default configuration
  6. * @param {String} [cfg.attemptIRI] Needs to be provided if this is a resume attempt action.
  7. * @param {String} [cfg.courserIRI] Obligatory if not provided in params.
  8. * @param {String} [cfg.courserTitle] Recommended if not provided in params.
  9. * @param {String} [cfg.courseDescription] Recommended if not provided in params.
  10. * @param {String} [cfg.endpoint] LRS endpoint URL
  11. * @param {String} [cfg.auth] Authorization token for the LRS, will be passed in the "Authorization" header.
  12. * @param {String} [cfg.lessonIRI] Obligatory if not provided in the params.
  13. * @param {String} cfg.lessonTitle
  14. * @param {String} cfg.lessonDescription Recommended if not provided in params.
  15. * @param {String} [cfg.entry] "ab-initio" or "resume"
  16. * @param {Object} [cfg.actor] Obligatory if not provided in params.
  17. * @param {Object} cfg.actor.account Recommended if not provided in params.
  18. * @param {String} cfg.actor.account.homePage User origin, usually location of the LMS.
  19. * @param {String} cfg.actor.account.name User identifier.
  20. * @return {Object} Config object with parameters fetched form the GET params.
  21. */
  22. xAPI.configFromParams = function(cfg){
  23. var params = getParams();
  24. cfg.attemptIRI = params.attemptIRI || cfg.attemptIRI;
  25. cfg.entry = params.entry || cfg.entry;
  26. cfg.courseIRI = params.courseIRI || cfg.courseIRI;
  27. cfg.courseTitle = params.courseTitle || cfg.courseTitle;
  28. cfg.courseDescription = params.courseDescription || cfg.courseDescription;
  29. cfg.endpoint = params.endpoint || cfg.endpoint;
  30. cfg.auth = params.auth || cfg.auth;
  31. cfg.lessonIRI = params.lessonIRI || cfg.lessonIRI;
  32. cfg.lessonDescription = params.lessonDescription || cfg.lessonDescription;
  33. cfg.username = params.username || cfg.username;
  34. cfg.password = params.password || cfg.password;
  35. var actor = params.actor;
  36. if (actor){
  37. cfg.actor = JSON.parse(actor);
  38. }
  39. return cfg;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement