aiccItem.class.php 6.2 KB

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