Merge pull request #5215 from christianbeeznest/displayorder-tools7

Session: Fix lp category creation error in session context
pull/5216/head
christianbeeznest 9 months ago committed by GitHub
commit b01b4531e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 19
      public/main/lp/learnpath.class.php

@ -7209,18 +7209,17 @@ class learnpath
return 0;
}
$table = Database::get_course_table(TABLE_LP_CATEGORY);
$id = (int) $id;
$sql = "SELECT session_id FROM $table WHERE iid = $id";
$result = Database::query($sql);
$result = Database::fetch_array($result, 'ASSOC');
$repo = Container::getLpCategoryRepository();
/** @var CLpCategory $category */
$category = $repo->find($id);
if ($result) {
return (int) $result['session_id'];
$sessionId = 0;
$link = $category->getFirstResourceLink();
if ($link && $link->getSession()) {
$sessionId = (int) $link->getSession()->getId();
}
return 0;
return $sessionId;
}
/**
@ -7259,7 +7258,7 @@ class learnpath
public static function getCategoryFromCourseIntoSelect($courseId, $addSelectOption = false)
{
$repo = Container::getLpCategoryRepository();
$qb = $repo->getResourcesByCourse(api_get_course_entity($courseId));
$qb = $repo->getResourcesByCourse(api_get_course_entity($courseId), api_get_session_entity());
$items = $qb->getQuery()->getResult();
$cats = [];

Loading…
Cancel
Save