|
|
@ -77,6 +77,25 @@ class learnpath |
|
|
|
public $course_int_id; |
|
|
|
public $course_int_id; |
|
|
|
public $course_info = array(); |
|
|
|
public $course_info = array(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the depth level of LP item |
|
|
|
|
|
|
|
* @param $in_tab_items |
|
|
|
|
|
|
|
* @param $in_current_item_id |
|
|
|
|
|
|
|
* @return int |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static function get_level_for_item($in_tab_items, $in_current_item_id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$parent_item_id = $in_tab_items[$in_current_item_id]->parent; |
|
|
|
|
|
|
|
if ($parent_item_id == 0) { |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return learnpath::get_level_for_item($in_tab_items, $parent_item_id) + 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Class constructor. Needs a database handler, a course code and a learnpath id from the database. |
|
|
|
* Class constructor. Needs a database handler, a course code and a learnpath id from the database. |
|
|
|
* Also builds the list of items into $this->items. |
|
|
|
* Also builds the list of items into $this->items. |
|
|
@ -280,22 +299,10 @@ class learnpath |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Items is a list of pointers to all items, classified by DB ID, not SCO id. |
|
|
|
// Setting the object level with variable $this->items[$i][parent] |
|
|
|
if ($row['parent_item_id'] == 0 || empty ($this->items[$row['parent_item_id']])) { |
|
|
|
foreach ($this->items as $itemLPObject) { |
|
|
|
if (is_object($this->items[$row['id']])) { |
|
|
|
$level = learnpath::get_level_for_item($this->items, $itemLPObject->db_id); |
|
|
|
$this->items[$row['id']]->set_level(0); |
|
|
|
$itemLPObject->level = $level; |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$level = $this->items[$row['parent_item_id']]->get_level() + 1; |
|
|
|
|
|
|
|
$this->items[$row['id']]->set_level($level); |
|
|
|
|
|
|
|
if (is_object($this->items[$row['parent_item_id']])) { |
|
|
|
|
|
|
|
// Items is a list of pointers from item DB ids to item objects. |
|
|
|
|
|
|
|
$this->items[$row['parent_item_id']]->add_child($row['id']); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
|
|
|
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - The parent item (' . $row['parent_item_id'] . ') of item ' . $row['id'] . ' could not be found', 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Setting the view in the item object. |
|
|
|
// Setting the view in the item object. |
|
|
|