Learnpath: Remove deprecated $course_id from learnpathItem::set_lp_view() + add types definitions to method - refs BT#19044

pull/4017/head
Yannick Warnier 4 years ago
parent 27bfe38826
commit a7bdeecfc5
  1. 11
      public/main/lp/learnpath.class.php
  2. 21
      public/main/lp/learnpathItem.class.php

@ -245,7 +245,7 @@ class learnpath
case CLp::AICC_TYPE:
$oItem = new aiccItem('db', $itemId, $course_id);
if (is_object($oItem)) {
$oItem->set_lp_view($this->lp_view_id, $course_id);
$oItem->set_lp_view($this->lp_view_id);
$oItem->set_prevent_reinit($this->prevent_reinit);
// Don't use reference here as the next loop will make the pointed object change.
$this->items[$itemId] = $oItem;
@ -255,7 +255,7 @@ class learnpath
case CLp::SCORM_TYPE:
$oItem = new scormItem('db', $itemId);
if (is_object($oItem)) {
$oItem->set_lp_view($this->lp_view_id, $course_id);
$oItem->set_lp_view($this->lp_view_id);
$oItem->set_prevent_reinit($this->prevent_reinit);
// Don't use reference here as the next loop will make the pointed object change.
$this->items[$itemId] = $oItem;
@ -284,7 +284,7 @@ class learnpath
// Setting the view in the item object.
if (isset($this->items[$itemId]) && is_object($this->items[$itemId])) {
$this->items[$itemId]->set_lp_view($this->lp_view_id, $course_id);
$this->items[$itemId]->set_lp_view($this->lp_view_id);
if (TOOL_HOTPOTATOES == $this->items[$itemId]->get_type()) {
$this->items[$itemId]->current_start_time = 0;
$this->items[$itemId]->current_stop_time = 0;
@ -345,8 +345,7 @@ class learnpath
Database::insert($itemViewTable, $params);
$this->items[$item_id]->set_lp_view(
$this->lp_view_id,
$course_id
$this->lp_view_id
);
}
}
@ -670,7 +669,7 @@ class learnpath
// If children was not set try to get the info
if (empty($childItem->db_item_view_id)) {
$childItem->set_lp_view($this->lp_view_id, $this->course_int_id);
$childItem->set_lp_view($this->lp_view_id);
}
// Check all his brothers (parent's children) for completion status.

@ -2915,21 +2915,10 @@ class learnpathItem
* Sets the lp_view id this item view is registered to.
*
* @param int $lp_view_id lp_view DB ID
* @param int $courseId
*
* @return bool
*
* @todo //todo insert into lp_item_view if lp_view not exists
*/
public function set_lp_view($lp_view_id, $courseId = null)
public function set_lp_view(int $lp_view_id): bool
{
$lp_view_id = (int) $lp_view_id;
$courseId = (int) $courseId;
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
$lpItemId = $this->get_id();
if (empty($lpItemId)) {
@ -2984,9 +2973,7 @@ class learnpathItem
// Now get the number of interactions for this little guy.
$table = Database::get_course_table(TABLE_LP_IV_INTERACTION);
$sql = "SELECT * FROM $table
WHERE
c_id = $courseId AND
lp_iv_id = '".$this->db_item_view_id."'";
WHERE lp_iv_id = ".$this->db_item_view_id;
$res = Database::query($sql);
if (false !== $res) {
@ -2997,9 +2984,7 @@ class learnpathItem
// Now get the number of objectives for this little guy.
$table = Database::get_course_table(TABLE_LP_IV_OBJECTIVE);
$sql = "SELECT * FROM $table
WHERE
c_id = $courseId AND
lp_iv_id = '".$this->db_item_view_id."'";
WHERE lp_iv_id = ".$this->db_item_view_id;
$this->objectives_count = 0;
$res = Database::query($sql);

Loading…
Cancel
Save