aiccItem.class.php 6.2 KB

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