dokeos-learnpath
[ class tree: dokeos-learnpath ] [ index: dokeos-learnpath ] [ all elements ]

Source for file aiccItem.class.php

Documentation is available at aiccItem.class.php

  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.     /**
  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.     function aiccItem($type='config',$params{
  37.         if(isset($params))
  38.         {
  39.             switch($type){
  40.                 case 'db':
  41.                     parent::learnpathItem($params,api_get_user_id());
  42.                     $this->aicc_contact false;
  43.                     //TODO implement this way of metadata object creation
  44.                     return false;
  45.                 case 'config'//do the same as the default
  46.                 default:
  47.                      //if($first_item->type == XML_ELEMENT_NODE) this is already check prior to the call to this function
  48.                      foreach($params as $a => $value)
  49.                      {
  50.                          switch($a)
  51.                          {
  52.                             case 'system_id':
  53.                                 $this->identifier = mysql_real_escape_string(strtolower($value));
  54.                                 break;
  55.                             case 'type':
  56.                                 $this->au_type = mysql_real_escape_string($value);
  57.                                 break;
  58.                             case 'command_line':
  59.                                 $this->command_line = mysql_real_escape_string($value);
  60.                                 break;
  61.                             case 'max_time_allowed':
  62.                                 $this->maxtimeallowed = mysql_real_escape_string($value);
  63.                                 break;
  64.                             case 'time_limit_action':
  65.                                 $this->timelimitaction = mysql_real_escape_string($value);
  66.                                 break;
  67.                             case 'max_score':
  68.                                 $this->max_score = mysql_real_escape_string($value);
  69.                                 break;
  70.                             case 'core_vendor':
  71.                                 $this->core_vendor = mysql_real_escape_string($value);
  72.                                 break;
  73.                             case 'system_vendor':
  74.                                 $this->system_vendor = mysql_real_escape_string($value);
  75.                                 break;
  76.                             case 'file_name':
  77.                                 $this->path = mysql_real_escape_string($value);
  78.                                 break;
  79.                             case 'mastery_score':
  80.                                 $this->masteryscore = mysql_real_escape_string($value);
  81.                                 break;
  82.                             case 'web_launch':
  83.                                 $this->parameters = mysql_real_escape_string($value);
  84.                                 break;
  85.                          }
  86.                      }
  87.                     return true;
  88.             }
  89.         }
  90.         return false;
  91.     }
  92.     /**
  93.      * Builds a flat list with the current item and calls itself recursively on all children
  94.      * @param    array    Reference to the array to complete with the current item
  95.      * @param    integer    Optional absolute order (pointer) of the item in this learning path
  96.      * @param    integer    Optional relative order of the item at this level
  97.      * @param    integer    Optional level. If not given, assumes it's level 0
  98.      */
  99.     function get_flat_list(&$list,&$abs_order,$rel_order=1,$level=0)
  100.     {
  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.         {
  118.             $oSubitem =$this->sub_items[$id];
  119.             $oSubitem->get_flat_list($list,$abs_order,$i,$level+1);
  120.             $i++;
  121.         }
  122.     }
  123.     /**
  124.      * Save function. Uses the parent save function and adds a layer for AICC.
  125.      * @param    boolean    Save from URL params (1) or from object attributes (0)
  126.      */
  127.     function save($from_outside=true$prereqs_complete=false)
  128.     {
  129.         parent::save($from_outside$prereqs_complete=false);
  130.         //under certain conditions, the scorm_contact should not be set, because no scorm signal was sent
  131.         $this->aicc_contact true;
  132.         if(!$this->aicc_contact){
  133.             //error_log('New LP - was expecting SCORM message but none received',0);    
  134.         }
  135.     }
  136. }
  137. ?>

Documentation generated on Thu, 12 Jun 2008 12:57:14 -0500 by phpDocumentor 1.4.1