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

Source for file learnpathList.class.php

Documentation is available at learnpathList.class.php

  1. <?php //$id:$
  2. /**
  3.  * File containing the declaration of the learnpathList class.
  4.  * @package    dokeos.learningpath
  5.  * @author    Yannick Warnier <ywarnier@beeznest.org>
  6.  */
  7. /**
  8.  * This class is only a learning path list container with several practical methods for sorting the list and
  9.  * provide links to specific paths
  10.  * @uses    Database.lib.php to use the database
  11.  * @uses    learnpath.class.php to generate learnpath objects to get in the list
  12.  */
  13. class learnpathList {
  14.     var $list = array()//holds a flat list of learnpaths data from the database
  15.     var $ref_list = array()//holds a list of references to the learnpaths objects (only filled by get_refs())
  16.     var $alpha_list = array()//holds a flat list of learnpaths sorted by alphabetical name order
  17.     var $course_code;
  18.     var $user_id;
  19.     var $refs_active = false;
  20.     
  21.     /**
  22.      * This method is the constructor for the learnpathList. It gets a list of available learning paths from
  23.      * the database and creates the learnpath objects. This list depends on the user that is connected
  24.      * (only displays) items if he has enough permissions to view them.
  25.      * @param    integer        User ID
  26.      * @param    string        Optional course code (otherwise we use api_get_course_id())
  27.      * @return    void 
  28.      */
  29.     function learnpathList($user_id,$course_code=''{
  30.         if(!empty($course_code)){
  31.             //proceed with course code given
  32.         }else{
  33.         $course_code api_get_course_id();
  34.         $lp_table Database::get_course_table('lp');
  35.         }
  36.         $this->course_code = $course_code;
  37.         $this->user_id = $user_id;
  38.         $sql "SELECT * FROM $lp_table ORDER BY display_order ASC, name ASC";
  39.         $res api_sql_query($sql);
  40.         $names array();
  41.         while ($row Database::fetch_array($res))
  42.         {
  43.             //check if published
  44.             $pub '';
  45.             $tbl_tool Database::get_course_table(TABLE_TOOL_LIST);
  46.             //use domesticate here instead of mysql_real_escape_string because
  47.             //it prevents ' to be slashed and the input (done by learnpath.class.php::toggle_visibility())
  48.             //is done using domesticate()
  49.             $myname domesticate($row['name']);
  50.             $mylink 'newscorm/lp_controller.php?action=view&lp_id='.$row['id'];
  51.             $sql2="SELECT * FROM $tbl_tool where (name='$myname' and image='scormbuilder.gif' and link LIKE '$mylink%')";
  52.             //error_log('New LP - learnpathList::learnpathList - getting visibility - '.$sql2,0);
  53.             $res2 api_sql_query($sql2,__FILE__,__LINE__);
  54.             if(Database::num_rows($res2)>0){
  55.                 $row2 Database::fetch_array($res2);
  56.                 $pub $row2['visibility'];
  57.             }else{
  58.                 $pub 'i';
  59.             }
  60.             //check if visible
  61.             $vis api_get_item_visibility(api_get_course_info($course_code),'learnpath',$row['id']);
  62.             
  63.             $this->list[$row['id']] array(
  64.                 'lp_type' => $row['lp_type'],
  65.                 'lp_name' => stripslashes($row['name']),
  66.                 'lp_desc' => stripslashes($row['description']),
  67.                 'lp_path' => $row['path'],
  68.                 'lp_view_mode' => $row['default_view_mod'],
  69.                 'lp_force_commit' => $row['force_commit'],
  70.                 'lp_maker'    => stripslashes($row['content_maker']),
  71.                 'lp_proximity' => $row['content_local'],
  72.                 'lp_encoding' => $row['default_encoding'],
  73.                 'lp_progress' => $row['progress'],
  74.                 'lp_visibility' => $vis,
  75.                 'lp_published'    => $pub,
  76.                 'lp_prevent_reinit' => $row['prevent_reinit'],
  77.                 'lp_scorm_debug' => $row['debug'],
  78.                 'lp_display_order' => $row['display_order'],
  79.                 );
  80.             $names[$row['name']]=$row['id'];
  81.            }
  82.            $this->alpha_list = asort($names);
  83.     }
  84.     /**
  85.      * Gets references to learnpaths for all learnpaths IDs kept in the local list.
  86.      * This applies a transformation internally on list and ref_list and returns a copy of the refs list
  87.      * @return    array    List of references to learnpath objects
  88.      */
  89.     function get_refs(){
  90.         foreach($this->list as $id => $dummy)
  91.         {
  92.             $this->ref_list[$idnew learnpath($this->course_code,$id,$this->user_id);
  93.         }
  94.         $this->refs_active = true;
  95.         return $this->ref_list;
  96.     }
  97.     /**
  98.      * Gets a table of the different learnpaths we have at the moment
  99.      * @return    array    Learnpath info as [lp_id] => ([lp_type]=> ..., [lp_name]=>...,[lp_desc]=>...,[lp_path]=>...)
  100.      */
  101.     function get_flat_list()
  102.     {
  103.         return $this->list;
  104.     }
  105. }
  106. ?>

Documentation generated on Thu, 12 Jun 2008 13:58:30 -0500 by phpDocumentor 1.4.1