aiccItem.class.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class aiccItem
  5. * This class handles the elements from an AICC Descriptor file.
  6. * Container for the aiccItem class that deals with AICC Assignable Units (AUs).
  7. *
  8. * @package chamilo.learnpath
  9. *
  10. * @author Yannick Warnier <ywarnier@beeznest.org>
  11. * @license GNU/GPL
  12. *
  13. * @package chamilo.learnpath
  14. */
  15. class aiccItem extends learnpathItem
  16. {
  17. public $identifier = ''; // AICC AU's system_id
  18. public $identifierref = '';
  19. public $parameters = ''; // AICC AU's web_launch
  20. public $title = ''; // no AICC equivalent
  21. public $sub_items = []; // AICC elements (des)
  22. //public $prerequisites = ''; // defined in learnpathItem.class.php
  23. //public $max_score = ''; // defined in learnpathItem
  24. //public $path = ''; // defined in learnpathItem
  25. public $maxtimeallowed = '00:00:00'; // AICC AU's max_time_allowed
  26. public $timelimitaction = ''; // AICC AU's time_limit_action
  27. public $masteryscore = ''; // AICC AU's mastery_score
  28. public $core_vendor = ''; // AICC AU's core_vendor
  29. public $system_vendor = ''; // AICC AU's system_vendor
  30. public $au_type = ''; // AICC AU's type
  31. public $command_line = ''; // AICC AU's command_line
  32. public $debug = 0;
  33. /**
  34. * Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormItem
  35. * object from database records or from the array given as second parameter.
  36. *
  37. * @param string Type of construction needed ('db' or 'config', default = 'config')
  38. * @param mixed Depending on the type given, DB id for the lp_item or parameters array
  39. */
  40. public function __construct($type = 'config', $params = [], $course_id = null)
  41. {
  42. if (isset($params)) {
  43. switch ($type) {
  44. case 'db':
  45. parent::__construct($params, api_get_user_id(), $course_id);
  46. $this->aicc_contact = false;
  47. //TODO: Implement this way of metadata object creation.
  48. // no break
  49. case 'config': // Do the same as the default.
  50. default:
  51. foreach ($params as $a => $value) {
  52. switch ($a) {
  53. case 'system_id':
  54. $this->identifier = Database::escape_string(
  55. strtolower($value)
  56. );
  57. break;
  58. case 'type':
  59. $this->au_type = Database::escape_string($value);
  60. break;
  61. case 'command_line':
  62. $this->command_line = Database::escape_string(
  63. $value
  64. );
  65. break;
  66. case 'max_time_allowed':
  67. $this->maxtimeallowed = Database::escape_string(
  68. $value
  69. );
  70. break;
  71. case 'time_limit_action':
  72. $this->timelimitaction = Database::escape_string(
  73. $value
  74. );
  75. break;
  76. case 'max_score':
  77. $this->max_score = Database::escape_string($value);
  78. break;
  79. case 'core_vendor':
  80. $this->core_vendor = Database::escape_string(
  81. $value
  82. );
  83. break;
  84. case 'system_vendor':
  85. $this->system_vendor = Database::escape_string(
  86. $value
  87. );
  88. break;
  89. case 'file_name':
  90. $this->path = Database::escape_string($value);
  91. break;
  92. case 'mastery_score':
  93. $this->masteryscore = Database::escape_string(
  94. $value
  95. );
  96. break;
  97. case 'web_launch':
  98. $this->parameters = Database::escape_string($value);
  99. break;
  100. }
  101. }
  102. }
  103. }
  104. }
  105. /**
  106. * Builds a flat list with the current item and calls itself recursively on all children.
  107. *
  108. * @param array Reference to the array to complete with the current item
  109. * @param int Optional absolute order (pointer) of the item in this learning path
  110. * @param int Optional relative order of the item at this level
  111. * @param int Optional level. If not given, assumes it's level 0
  112. */
  113. public function get_flat_list(&$list, &$abs_order, $rel_order = 1, $level = 0)
  114. {
  115. $list[] = [
  116. 'au_type' => $this->au_type,
  117. 'command_line' => $this->command_line,
  118. 'core_vendor' => $this->core_vendor,
  119. 'identifier' => $this->identifier,
  120. 'identifierref' => $this->identifierref,
  121. 'masteryscore' => $this->masteryscore,
  122. 'maxtimeallowed' => $this->maxtimeallowed,
  123. 'level' => $level,
  124. 'parameters' => $this->parameters,
  125. 'prerequisites' => (!empty($this->prereq_string) ? $this->prereq_string : ''),
  126. 'timelimitaction' => $this->timelimitaction,
  127. ];
  128. $abs_order++;
  129. $i = 1;
  130. foreach ($this->sub_items as $id => $dummy) {
  131. $oSubitem = &$this->sub_items[$id];
  132. $oSubitem->get_flat_list($list, $abs_order, $i, $level + 1);
  133. $i++;
  134. }
  135. }
  136. /**
  137. * Save function. Uses the parent save function and adds a layer for AICC.
  138. *
  139. * @param bool Save from URL params (1) or from object attributes (0)
  140. */
  141. public function save($from_outside = true, $prereqs_complete = false)
  142. {
  143. parent::save($from_outside, $prereqs_complete = false);
  144. // Under certain conditions, the scorm_contact should not be set, because no scorm signal was sent.
  145. $this->aicc_contact = true;
  146. }
  147. }