|
|
|
@ -104,296 +104,275 @@ class learnpath |
|
|
|
public $modified_on = ''; |
|
|
|
public $modified_on = ''; |
|
|
|
public $publicated_on = ''; |
|
|
|
public $publicated_on = ''; |
|
|
|
public $expired_on = ''; |
|
|
|
public $expired_on = ''; |
|
|
|
public $ref = null; |
|
|
|
public $ref; |
|
|
|
public $course_int_id; |
|
|
|
public $course_int_id; |
|
|
|
public $course_info = []; |
|
|
|
public $course_info = []; |
|
|
|
public $categoryId; |
|
|
|
public $categoryId; |
|
|
|
public $entity; |
|
|
|
public $scormUrl; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructor. |
|
|
|
* Constructor. |
|
|
|
* Needs a database handler, a course code and a learnpath id from the database. |
|
|
|
* 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. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param string $course Course code |
|
|
|
|
|
|
|
* @param int $lp_id c_lp.iid |
|
|
|
|
|
|
|
* @param int $user_id |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function __construct($course, $lp_id, $user_id) |
|
|
|
public function __construct(CLp $entity, $course_info, $user_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$debug = $this->debug; |
|
|
|
$debug = $this->debug; |
|
|
|
$this->encoding = api_get_system_encoding(); |
|
|
|
$this->encoding = api_get_system_encoding(); |
|
|
|
if (empty($course)) { |
|
|
|
$lp_id = (int) $entity->getIid(); |
|
|
|
$course = api_get_course_id(); |
|
|
|
$course_id = (int) $course_info['real_id']; |
|
|
|
} |
|
|
|
|
|
|
|
$course_info = api_get_course_info($course); |
|
|
|
|
|
|
|
if (!empty($course_info)) { |
|
|
|
|
|
|
|
$this->cc = $course_info['code']; |
|
|
|
|
|
|
|
$this->course_info = $course_info; |
|
|
|
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$this->error = 'Course code does not exist in database.'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$lp_id = (int) $lp_id; |
|
|
|
|
|
|
|
$course_id = (int) $course_id; |
|
|
|
|
|
|
|
$this->set_course_int_id($course_id); |
|
|
|
$this->set_course_int_id($course_id); |
|
|
|
// Check learnpath ID. |
|
|
|
|
|
|
|
if (empty($lp_id) || empty($course_id)) { |
|
|
|
if (empty($lp_id) || empty($course_id)) { |
|
|
|
$this->error = "Parameter is empty: LpId:'$lp_id', courseId: '$lp_id'"; |
|
|
|
$this->error = "Parameter is empty: LpId:'$lp_id', courseId: '$lp_id'"; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$repo = Container::getLpRepository(); |
|
|
|
$this->lp_id = $lp_id; |
|
|
|
/** @var CLp $entity */ |
|
|
|
$this->type = $entity->getLpType(); |
|
|
|
$entity = $repo->find($lp_id); |
|
|
|
$this->name = stripslashes($entity->getName()); |
|
|
|
if ($entity) { |
|
|
|
$this->proximity = $entity->getContentLocal(); |
|
|
|
$this->entity = $entity; |
|
|
|
$this->theme = $entity->getTheme(); |
|
|
|
$this->lp_id = $lp_id; |
|
|
|
$this->maker = $entity->getContentLocal(); |
|
|
|
$this->type = $entity->getLpType(); |
|
|
|
$this->prevent_reinit = $entity->getPreventReinit(); |
|
|
|
$this->name = stripslashes($entity->getName()); |
|
|
|
$this->seriousgame_mode = $entity->getSeriousgameMode(); |
|
|
|
$this->proximity = $entity->getContentLocal(); |
|
|
|
$this->license = $entity->getContentLicense(); |
|
|
|
$this->theme = $entity->getTheme(); |
|
|
|
$this->scorm_debug = $entity->getDebug(); |
|
|
|
$this->maker = $entity->getContentLocal(); |
|
|
|
$this->js_lib = $entity->getJsLib(); |
|
|
|
$this->prevent_reinit = $entity->getPreventReinit(); |
|
|
|
$this->path = $entity->getPath(); |
|
|
|
$this->seriousgame_mode = $entity->getSeriousgameMode(); |
|
|
|
$this->author = $entity->getAuthor(); |
|
|
|
$this->license = $entity->getContentLicense(); |
|
|
|
$this->hide_toc_frame = $entity->getHideTocFrame(); |
|
|
|
$this->scorm_debug = $entity->getDebug(); |
|
|
|
$this->lp_session_id = $entity->getSessionId(); |
|
|
|
$this->js_lib = $entity->getJsLib(); |
|
|
|
$this->use_max_score = $entity->getUseMaxScore(); |
|
|
|
$this->path = $entity->getPath(); |
|
|
|
$this->subscribeUsers = $entity->getSubscribeUsers(); |
|
|
|
$this->author = $entity->getAuthor(); |
|
|
|
$this->created_on = $entity->getCreatedOn()->format('Y-m-d H:i:s'); |
|
|
|
$this->hide_toc_frame = $entity->getHideTocFrame(); |
|
|
|
$this->modified_on = $entity->getModifiedOn()->format('Y-m-d H:i:s'); |
|
|
|
$this->lp_session_id = $entity->getSessionId(); |
|
|
|
$this->ref = $entity->getRef(); |
|
|
|
$this->use_max_score = $entity->getUseMaxScore(); |
|
|
|
$this->categoryId = 0; |
|
|
|
$this->subscribeUsers = $entity->getSubscribeUsers(); |
|
|
|
if ($entity->getCategory()) { |
|
|
|
$this->created_on = $entity->getCreatedOn()->format('Y-m-d H:i:s'); |
|
|
|
$this->categoryId = $entity->getCategory()->getIid(); |
|
|
|
$this->modified_on = $entity->getModifiedOn()->format('Y-m-d H:i:s'); |
|
|
|
} |
|
|
|
$this->ref = $entity->getRef(); |
|
|
|
|
|
|
|
$this->categoryId = 0; |
|
|
|
if ($entity->hasAsset()) { |
|
|
|
if ($entity->getCategory()) { |
|
|
|
$asset = $entity->getAsset(); |
|
|
|
$this->categoryId = $entity->getCategory()->getIid(); |
|
|
|
$this->scormUrl = Container::getAssetRepository()->getAssetUrl($asset).'/'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->accumulateScormTime = $entity->getAccumulateWorkTime(); |
|
|
|
$this->accumulateScormTime = $entity->getAccumulateWorkTime(); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($entity->getPublicatedOn())) { |
|
|
|
if (!empty($entity->getPublicatedOn())) { |
|
|
|
$this->publicated_on = $entity->getPublicatedOn()->format('Y-m-d H:i:s'); |
|
|
|
$this->publicated_on = $entity->getPublicatedOn()->format('Y-m-d H:i:s'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($entity->getExpiredOn())) { |
|
|
|
if (!empty($entity->getExpiredOn())) { |
|
|
|
$this->expired_on = $entity->getExpiredOn()->format('Y-m-d H:i:s'); |
|
|
|
$this->expired_on = $entity->getExpiredOn()->format('Y-m-d H:i:s'); |
|
|
|
} |
|
|
|
} |
|
|
|
if (2 == $this->type) { |
|
|
|
if (2 == $this->type) { |
|
|
|
if (1 == $entity->getForceCommit()) { |
|
|
|
if (1 == $entity->getForceCommit()) { |
|
|
|
$this->force_commit = true; |
|
|
|
$this->force_commit = true; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
$this->mode = $entity->getDefaultViewMod(); |
|
|
|
} |
|
|
|
|
|
|
|
$this->mode = $entity->getDefaultViewMod(); |
|
|
|
|
|
|
|
|
|
|
|
// Check user ID. |
|
|
|
// Check user ID. |
|
|
|
if (empty($user_id)) { |
|
|
|
if (empty($user_id)) { |
|
|
|
$this->error = 'User ID is empty'; |
|
|
|
$this->error = 'User ID is empty'; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$userInfo = api_get_user_info($user_id); |
|
|
|
|
|
|
|
if (!empty($userInfo)) { |
|
|
|
|
|
|
|
$this->user_id = $userInfo['user_id']; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$userInfo = api_get_user_info($user_id); |
|
|
|
$this->error = 'User ID does not exist in database #'.$user_id; |
|
|
|
if (!empty($userInfo)) { |
|
|
|
|
|
|
|
$this->user_id = $userInfo['user_id']; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$this->error = 'User ID does not exist in database #'.$user_id; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// End of variables checking. |
|
|
|
// End of variables checking. |
|
|
|
$session_id = api_get_session_id(); |
|
|
|
$session_id = api_get_session_id(); |
|
|
|
// Get the session condition for learning paths of the base + session. |
|
|
|
// Get the session condition for learning paths of the base + session. |
|
|
|
$session = api_get_session_condition($session_id); |
|
|
|
$session = api_get_session_condition($session_id); |
|
|
|
// Now get the latest attempt from this user on this LP, if available, otherwise create a new one. |
|
|
|
// Now get the latest attempt from this user on this LP, if available, otherwise create a new one. |
|
|
|
$lp_table = Database::get_course_table(TABLE_LP_VIEW); |
|
|
|
$lp_table = Database::get_course_table(TABLE_LP_VIEW); |
|
|
|
|
|
|
|
|
|
|
|
// Selecting by view_count descending allows to get the highest view_count first. |
|
|
|
// Selecting by view_count descending allows to get the highest view_count first. |
|
|
|
$sql = "SELECT * FROM $lp_table |
|
|
|
$sql = "SELECT * FROM $lp_table |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
c_id = $course_id AND |
|
|
|
c_id = $course_id AND |
|
|
|
lp_id = $lp_id AND |
|
|
|
lp_id = $lp_id AND |
|
|
|
user_id = $user_id |
|
|
|
user_id = $user_id |
|
|
|
$session |
|
|
|
$session |
|
|
|
ORDER BY view_count DESC"; |
|
|
|
ORDER BY view_count DESC"; |
|
|
|
$res = Database::query($sql); |
|
|
|
$res = Database::query($sql); |
|
|
|
|
|
|
|
|
|
|
|
if (Database::num_rows($res) > 0) { |
|
|
|
if (Database::num_rows($res) > 0) { |
|
|
|
$row = Database::fetch_array($res); |
|
|
|
$row = Database::fetch_array($res); |
|
|
|
$this->attempt = $row['view_count']; |
|
|
|
$this->attempt = $row['view_count']; |
|
|
|
$this->lp_view_id = $row['iid']; |
|
|
|
$this->lp_view_id = $row['iid']; |
|
|
|
$this->last_item_seen = $row['last_item']; |
|
|
|
$this->last_item_seen = $row['last_item']; |
|
|
|
$this->progress_db = $row['progress']; |
|
|
|
$this->progress_db = $row['progress']; |
|
|
|
$this->lp_view_session_id = $row['session_id']; |
|
|
|
$this->lp_view_session_id = $row['session_id']; |
|
|
|
} elseif (!api_is_invitee()) { |
|
|
|
} elseif (!api_is_invitee()) { |
|
|
|
$this->attempt = 1; |
|
|
|
$this->attempt = 1; |
|
|
|
$params = [ |
|
|
|
$params = [ |
|
|
|
'c_id' => $course_id, |
|
|
|
'c_id' => $course_id, |
|
|
|
'lp_id' => $lp_id, |
|
|
|
'lp_id' => $lp_id, |
|
|
|
'user_id' => $user_id, |
|
|
|
'user_id' => $user_id, |
|
|
|
'view_count' => 1, |
|
|
|
'view_count' => 1, |
|
|
|
'session_id' => $session_id, |
|
|
|
'session_id' => $session_id, |
|
|
|
'last_item' => 0, |
|
|
|
'last_item' => 0, |
|
|
|
]; |
|
|
|
]; |
|
|
|
$this->last_item_seen = 0; |
|
|
|
$this->last_item_seen = 0; |
|
|
|
$this->lp_view_session_id = $session_id; |
|
|
|
$this->lp_view_session_id = $session_id; |
|
|
|
$this->lp_view_id = Database::insert($lp_table, $params); |
|
|
|
$this->lp_view_id = Database::insert($lp_table, $params); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Initialise items. |
|
|
|
// Initialise items. |
|
|
|
$lp_item_table = Database::get_course_table(TABLE_LP_ITEM); |
|
|
|
$lp_item_table = Database::get_course_table(TABLE_LP_ITEM); |
|
|
|
$sql = "SELECT * FROM $lp_item_table |
|
|
|
$sql = "SELECT * FROM $lp_item_table |
|
|
|
WHERE c_id = $course_id AND lp_id = '".$this->lp_id."' |
|
|
|
WHERE c_id = $course_id AND lp_id = '".$this->lp_id."' |
|
|
|
ORDER BY parent_item_id, display_order"; |
|
|
|
ORDER BY parent_item_id, display_order"; |
|
|
|
$res = Database::query($sql); |
|
|
|
$res = Database::query($sql); |
|
|
|
|
|
|
|
|
|
|
|
$lp_item_id_list = []; |
|
|
|
$lp_item_id_list = []; |
|
|
|
while ($row = Database::fetch_array($res)) { |
|
|
|
while ($row = Database::fetch_array($res)) { |
|
|
|
$lp_item_id_list[] = $row['iid']; |
|
|
|
$lp_item_id_list[] = $row['iid']; |
|
|
|
switch ($this->type) { |
|
|
|
switch ($this->type) { |
|
|
|
case 3: //aicc |
|
|
|
case 3: //aicc |
|
|
|
$oItem = new aiccItem('db', $row['iid'], $course_id); |
|
|
|
$oItem = new aiccItem('db', $row['iid'], $course_id); |
|
|
|
if (is_object($oItem)) { |
|
|
|
if (is_object($oItem)) { |
|
|
|
$my_item_id = $oItem->get_id(); |
|
|
|
$my_item_id = $oItem->get_id(); |
|
|
|
$oItem->set_lp_view($this->lp_view_id, $course_id); |
|
|
|
$oItem->set_lp_view($this->lp_view_id, $course_id); |
|
|
|
$oItem->set_prevent_reinit($this->prevent_reinit); |
|
|
|
$oItem->set_prevent_reinit($this->prevent_reinit); |
|
|
|
// 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; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
$oItem = new scormItem('db', $row['iid'], $course_id); |
|
|
|
$oItem = new scormItem('db', $row['iid'], $course_id); |
|
|
|
if (is_object($oItem)) { |
|
|
|
if (is_object($oItem)) { |
|
|
|
$my_item_id = $oItem->get_id(); |
|
|
|
$my_item_id = $oItem->get_id(); |
|
|
|
$oItem->set_lp_view($this->lp_view_id, $course_id); |
|
|
|
$oItem->set_lp_view($this->lp_view_id, $course_id); |
|
|
|
$oItem->set_prevent_reinit($this->prevent_reinit); |
|
|
|
$oItem->set_prevent_reinit($this->prevent_reinit); |
|
|
|
// 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; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
default: |
|
|
|
default: |
|
|
|
$oItem = new learnpathItem($row['iid'], $user_id, $course_id, $row); |
|
|
|
$oItem = new learnpathItem($row['iid'], $user_id, $course_id, $row); |
|
|
|
if (is_object($oItem)) { |
|
|
|
if (is_object($oItem)) { |
|
|
|
$my_item_id = $oItem->get_id(); |
|
|
|
$my_item_id = $oItem->get_id(); |
|
|
|
// Moved down to when we are sure the item_view exists. |
|
|
|
// Moved down to when we are sure the item_view exists. |
|
|
|
//$oItem->set_lp_view($this->lp_view_id); |
|
|
|
//$oItem->set_lp_view($this->lp_view_id); |
|
|
|
$oItem->set_prevent_reinit($this->prevent_reinit); |
|
|
|
$oItem->set_prevent_reinit($this->prevent_reinit); |
|
|
|
// 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[$my_item_id] = $my_item_id; |
|
|
|
$this->refs_list[$my_item_id] = $my_item_id; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Setting the object level with variable $this->items[$i][parent] |
|
|
|
// Setting the object level with variable $this->items[$i][parent] |
|
|
|
foreach ($this->items as $itemLPObject) { |
|
|
|
foreach ($this->items as $itemLPObject) { |
|
|
|
$level = self::get_level_for_item( |
|
|
|
$level = self::get_level_for_item( |
|
|
|
$this->items, |
|
|
|
$this->items, |
|
|
|
$itemLPObject->db_id |
|
|
|
$itemLPObject->db_id |
|
|
|
); |
|
|
|
); |
|
|
|
$itemLPObject->level = $level; |
|
|
|
$itemLPObject->level = $level; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Setting the view in the item object. |
|
|
|
// Setting the view in the item object. |
|
|
|
if (is_object($this->items[$row['iid']])) { |
|
|
|
if (is_object($this->items[$row['iid']])) { |
|
|
|
$this->items[$row['iid']]->set_lp_view($this->lp_view_id, $course_id); |
|
|
|
$this->items[$row['iid']]->set_lp_view($this->lp_view_id, $course_id); |
|
|
|
if (TOOL_HOTPOTATOES == $this->items[$row['iid']]->get_type()) { |
|
|
|
if (TOOL_HOTPOTATOES == $this->items[$row['iid']]->get_type()) { |
|
|
|
$this->items[$row['iid']]->current_start_time = 0; |
|
|
|
$this->items[$row['iid']]->current_start_time = 0; |
|
|
|
$this->items[$row['iid']]->current_stop_time = 0; |
|
|
|
$this->items[$row['iid']]->current_stop_time = 0; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($lp_item_id_list)) { |
|
|
|
if (!empty($lp_item_id_list)) { |
|
|
|
$lp_item_id_list_to_string = implode("','", $lp_item_id_list); |
|
|
|
$lp_item_id_list_to_string = implode("','", $lp_item_id_list); |
|
|
|
if (!empty($lp_item_id_list_to_string)) { |
|
|
|
if (!empty($lp_item_id_list_to_string)) { |
|
|
|
// Get last viewing vars. |
|
|
|
// Get last viewing vars. |
|
|
|
$itemViewTable = Database::get_course_table(TABLE_LP_ITEM_VIEW); |
|
|
|
$itemViewTable = Database::get_course_table(TABLE_LP_ITEM_VIEW); |
|
|
|
// This query should only return one or zero result. |
|
|
|
// This query should only return one or zero result. |
|
|
|
$sql = "SELECT lp_item_id, status |
|
|
|
$sql = "SELECT lp_item_id, status |
|
|
|
FROM $itemViewTable |
|
|
|
FROM $itemViewTable |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
c_id = $course_id AND |
|
|
|
c_id = $course_id AND |
|
|
|
lp_view_id = ".$this->get_view_id()." AND |
|
|
|
lp_view_id = ".$this->get_view_id()." AND |
|
|
|
lp_item_id IN ('".$lp_item_id_list_to_string."') |
|
|
|
lp_item_id IN ('".$lp_item_id_list_to_string."') |
|
|
|
ORDER BY view_count DESC "; |
|
|
|
ORDER BY view_count DESC "; |
|
|
|
$status_list = []; |
|
|
|
$status_list = []; |
|
|
|
$res = Database::query($sql); |
|
|
|
$res = Database::query($sql); |
|
|
|
while ($row = Database:: fetch_array($res)) { |
|
|
|
while ($row = Database:: fetch_array($res)) { |
|
|
|
$status_list[$row['lp_item_id']] = $row['status']; |
|
|
|
$status_list[$row['lp_item_id']] = $row['status']; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach ($lp_item_id_list as $item_id) { |
|
|
|
foreach ($lp_item_id_list as $item_id) { |
|
|
|
if (isset($status_list[$item_id])) { |
|
|
|
if (isset($status_list[$item_id])) { |
|
|
|
$status = $status_list[$item_id]; |
|
|
|
$status = $status_list[$item_id]; |
|
|
|
|
|
|
|
if (is_object($this->items[$item_id])) { |
|
|
|
|
|
|
|
$this->items[$item_id]->set_status($status); |
|
|
|
|
|
|
|
if (empty($status)) { |
|
|
|
|
|
|
|
$this->items[$item_id]->set_status( |
|
|
|
|
|
|
|
$this->default_status |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (!api_is_invitee()) { |
|
|
|
if (is_object($this->items[$item_id])) { |
|
|
|
if (is_object($this->items[$item_id])) { |
|
|
|
$this->items[$item_id]->set_status($status); |
|
|
|
$this->items[$item_id]->set_status( |
|
|
|
if (empty($status)) { |
|
|
|
$this->default_status |
|
|
|
$this->items[$item_id]->set_status( |
|
|
|
); |
|
|
|
$this->default_status |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
if (!api_is_invitee()) { |
|
|
|
|
|
|
|
if (is_object($this->items[$item_id])) { |
|
|
|
|
|
|
|
$this->items[$item_id]->set_status( |
|
|
|
|
|
|
|
$this->default_status |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($this->lp_view_id)) { |
|
|
|
if (!empty($this->lp_view_id)) { |
|
|
|
// Add that row to the lp_item_view table so that |
|
|
|
// Add that row to the lp_item_view table so that |
|
|
|
// we have something to show in the stats page. |
|
|
|
// we have something to show in the stats page. |
|
|
|
$params = [ |
|
|
|
$params = [ |
|
|
|
'c_id' => $course_id, |
|
|
|
'c_id' => $course_id, |
|
|
|
'lp_item_id' => $item_id, |
|
|
|
'lp_item_id' => $item_id, |
|
|
|
'lp_view_id' => $this->lp_view_id, |
|
|
|
'lp_view_id' => $this->lp_view_id, |
|
|
|
'view_count' => 1, |
|
|
|
'view_count' => 1, |
|
|
|
'status' => 'not attempted', |
|
|
|
'status' => 'not attempted', |
|
|
|
'start_time' => time(), |
|
|
|
'start_time' => time(), |
|
|
|
'total_time' => 0, |
|
|
|
'total_time' => 0, |
|
|
|
'score' => 0, |
|
|
|
'score' => 0, |
|
|
|
]; |
|
|
|
]; |
|
|
|
Database::insert($itemViewTable, $params); |
|
|
|
Database::insert($itemViewTable, $params); |
|
|
|
|
|
|
|
|
|
|
|
$this->items[$item_id]->set_lp_view( |
|
|
|
$this->items[$item_id]->set_lp_view( |
|
|
|
$this->lp_view_id, |
|
|
|
$this->lp_view_id, |
|
|
|
$course_id |
|
|
|
$course_id |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->ordered_items = self::get_flat_ordered_items_list( |
|
|
|
$this->ordered_items = self::get_flat_ordered_items_list( |
|
|
|
$this->get_id(), |
|
|
|
$this->get_id(), |
|
|
|
0, |
|
|
|
0, |
|
|
|
$course_id |
|
|
|
$course_id |
|
|
|
); |
|
|
|
); |
|
|
|
$this->max_ordered_items = 0; |
|
|
|
$this->max_ordered_items = 0; |
|
|
|
foreach ($this->ordered_items as $index => $dummy) { |
|
|
|
foreach ($this->ordered_items as $index => $dummy) { |
|
|
|
if ($index > $this->max_ordered_items && !empty($dummy)) { |
|
|
|
if ($index > $this->max_ordered_items && !empty($dummy)) { |
|
|
|
$this->max_ordered_items = $index; |
|
|
|
$this->max_ordered_items = $index; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// TODO: Define the current item better. |
|
|
|
|
|
|
|
$this->first(); |
|
|
|
|
|
|
|
if ($debug) { |
|
|
|
|
|
|
|
error_log('lp_view_session_id '.$this->lp_view_session_id); |
|
|
|
|
|
|
|
error_log('End of learnpath constructor for learnpath '.$this->get_id()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: Define the current item better. |
|
|
|
|
|
|
|
$this->first(); |
|
|
|
|
|
|
|
if ($debug) { |
|
|
|
|
|
|
|
error_log('lp_view_session_id '.$this->lp_view_session_id); |
|
|
|
|
|
|
|
error_log('End of learnpath constructor for learnpath '.$this->get_id()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getEntity(): CLp |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $this->entity; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -3508,7 +3487,8 @@ class learnpath |
|
|
|
$linkProtocol = substr($file, 0, 5); |
|
|
|
$linkProtocol = substr($file, 0, 5); |
|
|
|
if ('http:' === $linkProtocol) { |
|
|
|
if ('http:' === $linkProtocol) { |
|
|
|
//this is the special intervention case |
|
|
|
//this is the special intervention case |
|
|
|
$file = api_get_path(WEB_CODE_PATH).'lp/embed.php?type=nonhttps&source='.urlencode($file); |
|
|
|
$file = api_get_path(WEB_CODE_PATH). |
|
|
|
|
|
|
|
'lp/embed.php?type=nonhttps&source='.urlencode($file); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -3531,7 +3511,7 @@ class learnpath |
|
|
|
|
|
|
|
|
|
|
|
$type_quiz = false; |
|
|
|
$type_quiz = false; |
|
|
|
foreach ($list as $toc) { |
|
|
|
foreach ($list as $toc) { |
|
|
|
if ($toc['id'] == $lp_item_id && 'quiz' == $toc['type']) { |
|
|
|
if ($toc['id'] == $lp_item_id && 'quiz' === $toc['type']) { |
|
|
|
$type_quiz = true; |
|
|
|
$type_quiz = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -3586,15 +3566,14 @@ class learnpath |
|
|
|
$lp_item_path = preg_replace('/%2F/', '/', $lp_item_path); |
|
|
|
$lp_item_path = preg_replace('/%2F/', '/', $lp_item_path); |
|
|
|
$lp_item_path = preg_replace('/%3A/', ':', $lp_item_path); |
|
|
|
$lp_item_path = preg_replace('/%3A/', ':', $lp_item_path); |
|
|
|
|
|
|
|
|
|
|
|
$asset = $this->getEntity()->getAsset(); |
|
|
|
/*$asset = $this->getEntity()->getAsset(); |
|
|
|
$folder = Container::getAssetRepository()->getFolder($asset); |
|
|
|
$folder = Container::getAssetRepository()->getFolder($asset); |
|
|
|
$hasFile = Container::getAssetRepository()->getFileSystem()->has($folder.$lp_item_path); |
|
|
|
$hasFile = Container::getAssetRepository()->getFileSystem()->has($folder.$lp_item_path); |
|
|
|
$file = null; |
|
|
|
$file = null; |
|
|
|
if ($hasFile) { |
|
|
|
if ($hasFile) { |
|
|
|
$file = Container::getAssetRepository()->getAssetUrl($asset).'/'.$lp_item_path; |
|
|
|
$file = Container::getAssetRepository()->getAssetUrl($asset).'/'.$lp_item_path; |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
$file = $this->scormUrl.$lp_item_path; |
|
|
|
error_log($file); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Prepare the path. |
|
|
|
// Prepare the path. |
|
|
|
/*$file = $course_path.'/scorm/'.$lp_path.'/'.$lp_item_path; |
|
|
|
/*$file = $course_path.'/scorm/'.$lp_path.'/'.$lp_item_path; |
|
|
|
@ -3604,7 +3583,7 @@ class learnpath |
|
|
|
if ('/' === substr($lp_path, -1)) { |
|
|
|
if ('/' === substr($lp_path, -1)) { |
|
|
|
$lp_path = substr($lp_path, 0, -1); |
|
|
|
$lp_path = substr($lp_path, 0, -1); |
|
|
|
}*/ |
|
|
|
}*/ |
|
|
|
if (!$hasFile) { |
|
|
|
/*if (!$hasFile) { |
|
|
|
// if file not found. |
|
|
|
// if file not found. |
|
|
|
$decoded = html_entity_decode($lp_item_path); |
|
|
|
$decoded = html_entity_decode($lp_item_path); |
|
|
|
[$decoded] = explode('?', $decoded); |
|
|
|
[$decoded] = explode('?', $decoded); |
|
|
|
@ -3629,7 +3608,7 @@ class learnpath |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$file = $course_path.'/scorm/'.$lp_path.'/'.$decoded; |
|
|
|
$file = $course_path.'/scorm/'.$lp_path.'/'.$decoded; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// We want to use parameters if they were defined in the imsmanifest |
|
|
|
// We want to use parameters if they were defined in the imsmanifest |
|
|
|
@ -3643,7 +3622,8 @@ class learnpath |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CLp::AICC_TYPE: |
|
|
|
case CLp::AICC_TYPE: |
|
|
|
// Formatting AICC HACP append URL. |
|
|
|
// Formatting AICC HACP append URL. |
|
|
|
$aicc_append = '?aicc_sid='.urlencode(session_id()).'&aicc_url='.urlencode(api_get_path(WEB_CODE_PATH).'lp/aicc_hacp.php').'&'; |
|
|
|
$aicc_append = '?aicc_sid='. |
|
|
|
|
|
|
|
urlencode(session_id()).'&aicc_url='.urlencode(api_get_path(WEB_CODE_PATH).'lp/aicc_hacp.php').'&'; |
|
|
|
if (!empty($lp_item_params)) { |
|
|
|
if (!empty($lp_item_params)) { |
|
|
|
$aicc_append .= $lp_item_params.'&'; |
|
|
|
$aicc_append .= $lp_item_params.'&'; |
|
|
|
} |
|
|
|
} |
|
|
|
|