|
|
@ -209,9 +209,9 @@ class learnpath |
|
|
|
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - NOT Found previous view', 0); |
|
|
|
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - NOT Found previous view', 0); |
|
|
|
} |
|
|
|
} |
|
|
|
$this->attempt = 1; |
|
|
|
$this->attempt = 1; |
|
|
|
$sql_ins = "INSERT INTO $lp_table (c_id, lp_id, user_id, view_count, session_id) |
|
|
|
$sql = "INSERT INTO $lp_table (c_id, lp_id, user_id, view_count, session_id) |
|
|
|
VALUES ($course_id, $lp_id, $user_id, 1, $session_id)"; |
|
|
|
VALUES ($course_id, $lp_id, $user_id, 1, $session_id)"; |
|
|
|
Database::query($sql_ins); |
|
|
|
Database::query($sql); |
|
|
|
$this->lp_view_id = Database::insert_id(); |
|
|
|
$this->lp_view_id = Database::insert_id(); |
|
|
|
if ($this->debug > 2) { |
|
|
|
if ($this->debug > 2) { |
|
|
|
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - inserting new lp_view: ' . $sql_ins, 0); |
|
|
|
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - inserting new lp_view: ' . $sql_ins, 0); |
|
|
@ -263,6 +263,7 @@ class learnpath |
|
|
|
// Don't use reference here as the next loop will make the pointed object change. |
|
|
|
// Don't use reference here as the next loop will make the pointed object change. |
|
|
|
|
|
|
|
|
|
|
|
$this->items[$my_item_id] = $oItem; |
|
|
|
$this->items[$my_item_id] = $oItem; |
|
|
|
|
|
|
|
|
|
|
|
$this->refs_list[$oItem->ref] = $my_item_id; |
|
|
|
$this->refs_list[$oItem->ref] = $my_item_id; |
|
|
|
if ($this->debug > 2) { |
|
|
|
if ($this->debug > 2) { |
|
|
|
error_log('New LP - object with id ' . $my_item_id . ' set in items[]', 0); |
|
|
|
error_log('New LP - object with id ' . $my_item_id . ' set in items[]', 0); |
|
|
@ -354,12 +355,13 @@ class learnpath |
|
|
|
$this->items[$item_id]->set_status($this->default_status); |
|
|
|
$this->items[$item_id]->set_status($this->default_status); |
|
|
|
} |
|
|
|
} |
|
|
|
// Add that row to the lp_item_view table so that we have something to show in the stats page. |
|
|
|
// Add that row to the lp_item_view table so that we have something to show in the stats page. |
|
|
|
$sql_ins = "INSERT INTO $lp_item_view_table (c_id, lp_item_id, lp_view_id, view_count, status) |
|
|
|
$sql = "INSERT INTO $lp_item_view_table (c_id, lp_item_id, lp_view_id, view_count, status) |
|
|
|
VALUES ($course_id, ".$item_id . "," . $this->lp_view_id . ", 1, 'not attempted')"; |
|
|
|
VALUES ($course_id, ".$item_id . "," . $this->lp_view_id . ", 1, 'not attempted')"; |
|
|
|
if ($this->debug > 2) { |
|
|
|
if ($this->debug > 2) { |
|
|
|
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - Inserting blank item_view : ' . $sql_ins, 0); |
|
|
|
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - Inserting blank item_view : ' . $sql, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
Database::query($sql_ins); |
|
|
|
$this->items[$item_id]->set_lp_view($this->lp_view_id, $course_id); |
|
|
|
|
|
|
|
Database::query($sql); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -454,16 +456,13 @@ class learnpath |
|
|
|
error_log('New LP - In learnpath::add_item(' . $parent . ',' . $previous . ',' . $type . ',' . $id . ',' . $title . ')', 0); |
|
|
|
error_log('New LP - In learnpath::add_item(' . $parent . ',' . $previous . ',' . $type . ',' . $id . ',' . $title . ')', 0); |
|
|
|
} |
|
|
|
} |
|
|
|
$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); |
|
|
|
$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); |
|
|
|
|
|
|
|
|
|
|
|
$parent = intval($parent); |
|
|
|
$parent = intval($parent); |
|
|
|
$previous = intval($previous); |
|
|
|
$previous = intval($previous); |
|
|
|
$id = intval($id); |
|
|
|
$id = intval($id); |
|
|
|
$max_time_allowed = Database::escape_string(htmlentities($max_time_allowed)); |
|
|
|
$max_time_allowed = htmlentities($max_time_allowed); |
|
|
|
if (empty($max_time_allowed)) { |
|
|
|
if (empty($max_time_allowed)) { |
|
|
|
$max_time_allowed = 0; |
|
|
|
$max_time_allowed = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
$title = Database::escape_string($title); |
|
|
|
|
|
|
|
$description = Database::escape_string($description); |
|
|
|
|
|
|
|
$sql_count = " SELECT COUNT(id) AS num |
|
|
|
$sql_count = " SELECT COUNT(id) AS num |
|
|
|
FROM $tbl_lp_item |
|
|
|
FROM $tbl_lp_item |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
@ -479,7 +478,8 @@ class learnpath |
|
|
|
if ($previous == 0) { |
|
|
|
if ($previous == 0) { |
|
|
|
$sql = "SELECT id, next_item_id, display_order |
|
|
|
$sql = "SELECT id, next_item_id, display_order |
|
|
|
FROM " . $tbl_lp_item . " |
|
|
|
FROM " . $tbl_lp_item . " |
|
|
|
WHERE c_id = $course_id AND |
|
|
|
WHERE |
|
|
|
|
|
|
|
c_id = $course_id AND |
|
|
|
lp_id = " . $this->get_id() . " AND |
|
|
|
lp_id = " . $this->get_id() . " AND |
|
|
|
parent_item_id = " . $parent . " AND |
|
|
|
parent_item_id = " . $parent . " AND |
|
|
|
previous_item_id = 0 OR |
|
|
|
previous_item_id = 0 OR |
|
|
@ -512,7 +512,6 @@ class learnpath |
|
|
|
$display_order = 0; |
|
|
|
$display_order = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$new_item_id = -1; |
|
|
|
|
|
|
|
$id = Database::escape_string($id); |
|
|
|
$id = Database::escape_string($id); |
|
|
|
$typeCleaned = Database::escape_string($type); |
|
|
|
$typeCleaned = Database::escape_string($type); |
|
|
|
if ($type == 'quiz') { |
|
|
|
if ($type == 'quiz') { |
|
|
@ -535,79 +534,34 @@ class learnpath |
|
|
|
$max_score = 100; |
|
|
|
$max_score = 100; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$params = array( |
|
|
|
|
|
|
|
"c_id" => $course_id, |
|
|
|
|
|
|
|
"lp_id" => $this->get_id(), |
|
|
|
|
|
|
|
"item_type" =>$typeCleaned , |
|
|
|
|
|
|
|
"ref" => '', |
|
|
|
|
|
|
|
"title" =>$title , |
|
|
|
|
|
|
|
"description" => $description, |
|
|
|
|
|
|
|
"path" => $id, |
|
|
|
|
|
|
|
"max_score" => $max_score, |
|
|
|
|
|
|
|
"parent_item_id" => $parent, |
|
|
|
|
|
|
|
"previous_item_id" => $previous, |
|
|
|
|
|
|
|
"next_item_id" => $next, |
|
|
|
|
|
|
|
"display_order" => $display_order +1, |
|
|
|
|
|
|
|
"prerequisite" => $prerequisites, |
|
|
|
|
|
|
|
"max_time_allowed" => $max_time_allowed |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if ($prerequisites != 0) { |
|
|
|
if ($prerequisites != 0) { |
|
|
|
$sql_ins = "INSERT INTO " . $tbl_lp_item . " ( |
|
|
|
$params['prerequisite'] = $prerequisites; |
|
|
|
c_id, |
|
|
|
|
|
|
|
lp_id, ". |
|
|
|
|
|
|
|
"item_type, ". |
|
|
|
|
|
|
|
"ref, ". |
|
|
|
|
|
|
|
"title, ". |
|
|
|
|
|
|
|
"description, ". |
|
|
|
|
|
|
|
"path, ". |
|
|
|
|
|
|
|
"max_score, ". |
|
|
|
|
|
|
|
"parent_item_id, ". |
|
|
|
|
|
|
|
"previous_item_id, ". |
|
|
|
|
|
|
|
"next_item_id, ". |
|
|
|
|
|
|
|
"display_order, ". |
|
|
|
|
|
|
|
"prerequisite, ". |
|
|
|
|
|
|
|
"max_time_allowed ". |
|
|
|
|
|
|
|
") VALUES ( |
|
|
|
|
|
|
|
$course_id , |
|
|
|
|
|
|
|
".$this->get_id() . ", ". |
|
|
|
|
|
|
|
"'" . $typeCleaned . "', ". |
|
|
|
|
|
|
|
"'', ". |
|
|
|
|
|
|
|
"'" . $title . "', ". |
|
|
|
|
|
|
|
"'" . $description . "', ". |
|
|
|
|
|
|
|
"'" . $id . "', ". |
|
|
|
|
|
|
|
"'" . $max_score . "', ". |
|
|
|
|
|
|
|
$parent . ", ". |
|
|
|
|
|
|
|
$previous . ", ". |
|
|
|
|
|
|
|
$next . ", ". |
|
|
|
|
|
|
|
($display_order +1) . ", ". |
|
|
|
|
|
|
|
$prerequisites . ", ". |
|
|
|
|
|
|
|
$max_time_allowed . |
|
|
|
|
|
|
|
")"; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// Insert new item. |
|
|
|
|
|
|
|
$sql_ins = "INSERT INTO " . $tbl_lp_item . " ( ". |
|
|
|
|
|
|
|
"c_id, ". |
|
|
|
|
|
|
|
"lp_id, ". |
|
|
|
|
|
|
|
"item_type, ". |
|
|
|
|
|
|
|
"ref, ". |
|
|
|
|
|
|
|
"title, ". |
|
|
|
|
|
|
|
"description, ". |
|
|
|
|
|
|
|
"path, ". |
|
|
|
|
|
|
|
"max_score, ". |
|
|
|
|
|
|
|
"parent_item_id, ". |
|
|
|
|
|
|
|
"previous_item_id, ". |
|
|
|
|
|
|
|
"next_item_id, ". |
|
|
|
|
|
|
|
"display_order, ". |
|
|
|
|
|
|
|
"max_time_allowed ". |
|
|
|
|
|
|
|
") VALUES (". |
|
|
|
|
|
|
|
$course_id. ",". |
|
|
|
|
|
|
|
$this->get_id() . ",". |
|
|
|
|
|
|
|
"'" . $typeCleaned . "',". |
|
|
|
|
|
|
|
"'',". |
|
|
|
|
|
|
|
"'" . $title . "',". |
|
|
|
|
|
|
|
"'" . $description . "',". |
|
|
|
|
|
|
|
"'" . $id . "',". |
|
|
|
|
|
|
|
"'" . $max_score . "',". |
|
|
|
|
|
|
|
$parent . ",". |
|
|
|
|
|
|
|
$previous . ",". |
|
|
|
|
|
|
|
$next . ",". |
|
|
|
|
|
|
|
($display_order +1) . ",". |
|
|
|
|
|
|
|
$max_time_allowed . |
|
|
|
|
|
|
|
")"; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$new_item_id = Database::insert($tbl_lp_item, $params); |
|
|
|
|
|
|
|
|
|
|
|
if ($this->debug > 2) { |
|
|
|
if ($this->debug > 2) { |
|
|
|
error_log('New LP - Inserting dokeos_chapter: ' . $sql_ins, 0); |
|
|
|
error_log('New LP - Inserting dokeos_chapter: ' . $new_item_id, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$res_ins = Database::query($sql_ins); |
|
|
|
if ($new_item_id) { |
|
|
|
|
|
|
|
|
|
|
|
if ($res_ins > 0) { |
|
|
|
|
|
|
|
$new_item_id = Database :: insert_id($res_ins); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update the item that should come after the new item. |
|
|
|
// Update the item that should come after the new item. |
|
|
|
$sql_update_next = " |
|
|
|
$sql_update_next = " |
|
|
@ -643,7 +597,6 @@ class learnpath |
|
|
|
SET ref = " . $new_item_id . " |
|
|
|
SET ref = " . $new_item_id . " |
|
|
|
WHERE c_id = $course_id AND id = " . $new_item_id; |
|
|
|
WHERE c_id = $course_id AND id = " . $new_item_id; |
|
|
|
Database::query($sql_update_ref); |
|
|
|
Database::query($sql_update_ref); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Upload audio. |
|
|
|
// Upload audio. |
|
|
|
if (!empty($_FILES['mp3']['name'])) { |
|
|
|
if (!empty($_FILES['mp3']['name'])) { |
|
|
@ -710,6 +663,7 @@ class learnpath |
|
|
|
WHERE id = '" . Database::escape_string($new_item_id) . "'"; |
|
|
|
WHERE id = '" . Database::escape_string($new_item_id) . "'"; |
|
|
|
Database::query($sql); |
|
|
|
Database::query($sql); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $new_item_id; |
|
|
|
return $new_item_id; |
|
|
|
} |
|
|
|
} |
|
|
@ -842,66 +796,96 @@ class learnpath |
|
|
|
public function autocomplete_parents($item) |
|
|
|
public function autocomplete_parents($item) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$debug = $this->debug; |
|
|
|
$debug = $this->debug; |
|
|
|
|
|
|
|
|
|
|
|
if ($debug) { |
|
|
|
if ($debug) { |
|
|
|
error_log('Learnpath::autocomplete_parents()', 0); |
|
|
|
error_log('Learnpath::autocomplete_parents()', 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (empty($item)) { |
|
|
|
if (empty($item)) { |
|
|
|
$item = $this->current; |
|
|
|
$item = $this->current; |
|
|
|
} |
|
|
|
} |
|
|
|
$parent_id = $this->items[$item]->get_parent(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($this->items[$item]) && is_object($this->items[$item]) and !empty($parent_id)) { |
|
|
|
$currentItem = $this->getItem($item); |
|
|
|
|
|
|
|
if ($currentItem) { |
|
|
|
|
|
|
|
$parent_id = $currentItem->get_parent(); |
|
|
|
|
|
|
|
$parent = $this->getItem($parent_id); |
|
|
|
|
|
|
|
if ($parent) { |
|
|
|
// if $item points to an object and there is a parent. |
|
|
|
// if $item points to an object and there is a parent. |
|
|
|
if ($debug) { |
|
|
|
if ($debug) { |
|
|
|
error_log('Autocompleting parent of item ' . $item . ' (item ' . $parent_id . ')', 0); |
|
|
|
error_log( |
|
|
|
|
|
|
|
'Autocompleting parent of item ' . $item . ' "'.$currentItem->get_title().'" (item ' . $parent_id . ' "'.$parent->get_title().'") ', |
|
|
|
|
|
|
|
0 |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
$current_item = $this->items[$item]; |
|
|
|
|
|
|
|
$parent = $this->items[$parent_id]; // Get the parent. |
|
|
|
|
|
|
|
// New experiment including failed and browsed in completed status. |
|
|
|
// New experiment including failed and browsed in completed status. |
|
|
|
$current_status = $current_item->get_status(); |
|
|
|
//$current_status = $currentItem->get_status(); |
|
|
|
//if ($current_item->is_done() || $current_status == 'browsed' || $current_status == 'failed') { |
|
|
|
//if ($currentItem->is_done() || $current_status == 'browsed' || $current_status == 'failed') { |
|
|
|
// Fixes chapter auto complete |
|
|
|
// Fixes chapter auto complete |
|
|
|
if (true) { |
|
|
|
if (true) { |
|
|
|
// If the current item is completed or passes or succeeded. |
|
|
|
// If the current item is completed or passes or succeeded. |
|
|
|
$completed = true; |
|
|
|
$updateParentStatus = true; |
|
|
|
if ($debug) { |
|
|
|
if ($debug) { |
|
|
|
error_log('Status of current item is alright', 0); |
|
|
|
error_log('Status of current item is alright', 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach ($parent->get_children() as $child) { |
|
|
|
foreach ($parent->get_children() as $childItemId) { |
|
|
|
|
|
|
|
$childItem = $this->getItem($childItemId); |
|
|
|
|
|
|
|
|
|
|
|
// Check all his brothers (parent's children) for completion status. |
|
|
|
// Check all his brothers (parent's children) for completion status. |
|
|
|
if ($child != $item) { |
|
|
|
if ($childItemId != $item) { |
|
|
|
if ($debug) { |
|
|
|
if ($debug) { |
|
|
|
error_log('Looking at brother with ID ' . $child . ', status is ' . $this->items[$child]->get_status(), 0); |
|
|
|
error_log( |
|
|
|
|
|
|
|
'Looking at brother #'.$childItemId . ' "' . $childItem->get_title() . '", status is ' . $childItem->get_status(), |
|
|
|
|
|
|
|
0 |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
//if($this->items[$child]->status_is(array('completed','passed','succeeded'))) |
|
|
|
|
|
|
|
// Trying completing parents of failed and browsed items as well. |
|
|
|
// Trying completing parents of failed and browsed items as well. |
|
|
|
if ($this->items[$child]->status_is(array( |
|
|
|
if ($childItem->status_is( |
|
|
|
|
|
|
|
array( |
|
|
|
'completed', |
|
|
|
'completed', |
|
|
|
'passed', |
|
|
|
'passed', |
|
|
|
'succeeded', |
|
|
|
'succeeded', |
|
|
|
'browsed', |
|
|
|
'browsed', |
|
|
|
'failed' |
|
|
|
'failed' |
|
|
|
))) { |
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) { |
|
|
|
// Keep completion status to true. |
|
|
|
// Keep completion status to true. |
|
|
|
|
|
|
|
continue; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if ($this->debug > 2) { |
|
|
|
if ($debug > 2) { |
|
|
|
error_log('Found one incomplete child of ' . $parent_id . ': ' . $child . ' is ' . $this->items[$child]->get_status(), 0); |
|
|
|
error_log( |
|
|
|
|
|
|
|
'Found one incomplete child of parent #' . $parent_id . ': child #'.$childItemId . ' "' . $childItem->get_title() . '", is ' . $childItem->get_status().' db_item_view_id:#'.$childItem->db_item_view_id, |
|
|
|
|
|
|
|
0 |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
$completed = false; |
|
|
|
$updateParentStatus = false; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($completed) { // If all the children were completed: |
|
|
|
if ($updateParentStatus) { |
|
|
|
|
|
|
|
// If all the children were completed: |
|
|
|
$parent->set_status('completed'); |
|
|
|
$parent->set_status('completed'); |
|
|
|
$parent->save(false, $this->prerequisites_match($parent->get_id())); |
|
|
|
$parent->save(false, $this->prerequisites_match($parent->get_id())); |
|
|
|
$this->update_queue[$parent->get_id()] = $parent->get_status(); |
|
|
|
//$this->update_queue[$parent->get_id()] = $parent->get_status(); |
|
|
|
|
|
|
|
$this->update_queue[$parent->get_id()] = 'completed'; |
|
|
|
if ($debug) { |
|
|
|
if ($debug) { |
|
|
|
error_log('Added parent to update queue ' . print_r($this->update_queue, true), 0); |
|
|
|
error_log( |
|
|
|
|
|
|
|
'Added parent #'.$parent->get_id().' "'.$parent->get_title().'" to update queue status: completed '. |
|
|
|
|
|
|
|
print_r($this->update_queue, 1), |
|
|
|
|
|
|
|
0 |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
$this->autocomplete_parents($parent->get_id()); // Recursive call. |
|
|
|
// Recursive call. |
|
|
|
|
|
|
|
$this->autocomplete_parents($parent->get_id()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if ($debug) { |
|
|
|
|
|
|
|
error_log("Parent #$parent_id does not exists"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -4012,49 +3996,61 @@ class learnpath |
|
|
|
* and the prerequisite string on error. |
|
|
|
* and the prerequisite string on error. |
|
|
|
* This function is based on the rules for aicc_script language as |
|
|
|
* This function is based on the rules for aicc_script language as |
|
|
|
* described in the SCORM 1.2 CAM documentation page 108. |
|
|
|
* described in the SCORM 1.2 CAM documentation page 108. |
|
|
|
* @param integer Optional item ID. If none given, uses the current open item. |
|
|
|
* @param integer $itemId Optional item ID. If none given, uses the current open item. |
|
|
|
* @return boolean True if prerequisites are matched, false otherwise - |
|
|
|
* @return boolean True if prerequisites are matched, false otherwise - |
|
|
|
* Empty string if true returned, prerequisites string otherwise. |
|
|
|
* Empty string if true returned, prerequisites string otherwise. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function prerequisites_match($item = null) |
|
|
|
public function prerequisites_match($itemId = null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ($this->debug > 0) { |
|
|
|
$debug = $this->debug; |
|
|
|
|
|
|
|
if ($debug > 0) { |
|
|
|
error_log('In learnpath::prerequisites_match()', 0); |
|
|
|
error_log('In learnpath::prerequisites_match()', 0); |
|
|
|
} |
|
|
|
} |
|
|
|
if (empty($item)) { |
|
|
|
|
|
|
|
$item = $this->current; |
|
|
|
if (empty($itemId)) { |
|
|
|
|
|
|
|
$itemId = $this->current; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isset($this->items[$item]) && is_object($this->items[$item])) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$currentItem = $this->getItem($itemId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($currentItem) { |
|
|
|
if ($this->type == 2) { |
|
|
|
if ($this->type == 2) { |
|
|
|
// Getting prereq from scorm |
|
|
|
// Getting prereq from scorm |
|
|
|
$prereq_string = $this->get_scorm_prereq_string($item); |
|
|
|
$prereq_string = $this->get_scorm_prereq_string($itemId); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$prereq_string = $this->items[$item]->get_prereq_string(); |
|
|
|
$prereq_string = $currentItem->get_prereq_string(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (empty($prereq_string)) { |
|
|
|
if (empty($prereq_string)) { |
|
|
|
|
|
|
|
if ($debug > 0) { |
|
|
|
|
|
|
|
error_log('Found prereq_string is empty return true'); |
|
|
|
|
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
// Clean spaces. |
|
|
|
// Clean spaces. |
|
|
|
$prereq_string = str_replace(' ', '', $prereq_string); |
|
|
|
$prereq_string = str_replace(' ', '', $prereq_string); |
|
|
|
if ($this->debug > 0) { |
|
|
|
if ($debug > 0) { |
|
|
|
error_log('Found prereq_string: ' . $prereq_string, 0); |
|
|
|
error_log('Found prereq_string: ' . $prereq_string, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
// Now send to the parse_prereq() function that will check this component's prerequisites. |
|
|
|
// Now send to the parse_prereq() function that will check this component's prerequisites. |
|
|
|
$result = $this->items[$item]->parse_prereq($prereq_string, $this->items, $this->refs_list, $this->get_user_id()); |
|
|
|
$result = $currentItem->parse_prereq( |
|
|
|
|
|
|
|
$prereq_string, |
|
|
|
|
|
|
|
$this->items, |
|
|
|
|
|
|
|
$this->refs_list, |
|
|
|
|
|
|
|
$this->get_user_id() |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if ($result === false) { |
|
|
|
if ($result === false) { |
|
|
|
$this->set_error_msg($this->items[$item]->prereq_alert); |
|
|
|
$this->set_error_msg($currentItem->prereq_alert); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$result = true; |
|
|
|
$result = true; |
|
|
|
if ($this->debug > 1) { |
|
|
|
if ($debug > 1) { |
|
|
|
error_log('$this->items[' . $item . '] was not an object', 0); |
|
|
|
error_log('$this->items[' . $itemId . '] was not an object', 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($this->debug > 1) { |
|
|
|
if ($debug > 1) { |
|
|
|
error_log('End of prerequisites_match(). Error message is now ' . $this->error, 0); |
|
|
|
error_log('End of prerequisites_match(). Error message is now ' . $this->error, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
return $result; |
|
|
|
return $result; |
|
|
@ -9839,6 +9835,19 @@ EOD; |
|
|
|
|
|
|
|
|
|
|
|
return $learnPath; |
|
|
|
return $learnPath; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param int $itemId |
|
|
|
|
|
|
|
* @return learnpathItem|false |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function getItem($itemId) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (isset($this->items[$itemId]) && is_object($this->items[$itemId])) { |
|
|
|
|
|
|
|
return $this->items[$itemId]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!function_exists('trim_value')) { |
|
|
|
if (!function_exists('trim_value')) { |
|
|
|