aiccItem.class.php 5.2 KB

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