Forum: Add icon for base course forums in lesson list- refs BT#21692

pull/5619/head
christianbeeznst 1 year ago
parent 2f6187355d
commit 36ece88108
  1. 2
      assets/css/scss/_lp.scss
  2. 33
      public/main/lp/learnpath.class.php
  3. 7
      public/main/lp/lp_list.php
  4. 13
      src/CourseBundle/Repository/CLpItemRepository.php

@ -65,7 +65,7 @@
}
#resource_tab {
margin-top: 15px;
margin: 0px 15px;
}
#resource_tab .nav-tabs {

@ -6816,12 +6816,6 @@ class learnpath
$return .= ' </a>';
$return .= Display::getMdiIcon('comment-quote', 'ch-tool-icon', null, 16, get_lang('Forum'));
$alertIcon = '';
if (!$isForumSession && $userRights) {
$tooltip = get_lang('This Learningpath includes a forum in the base course, so once users in a session will participate in this forum, it will start to appear in the forum tool in the session, whereas by default forums from the base course do not appear in the session.');
$alertIcon = Display::return_icon('warning.png', $tooltip, null, ICON_SIZE_SMALL);
}
$moveLink = Display::url(
$title,
api_get_self().'?'.
@ -6840,7 +6834,7 @@ class learnpath
id="forum_'.$forumId.'_opener" align="absbottom"
/>
</a>
'.$moveLink. ' '.$alertIcon;
'.$moveLink;
$return .= '</li>';
$return .= '<div style="display:none" id="forum_'.$forumId.'_content">';
@ -7977,6 +7971,31 @@ class learnpath
return $link;
}
/**
* Checks if any forum items in a given learning path are from the base course.
*/
public static function isForumFromBaseCourse(int $learningPathId): bool
{
$itemRepository = Container::getLpItemRepository();
$forumRepository = Container::getForumRepository();
$forums = $itemRepository->findItemsByLearningPathAndType($learningPathId, 'forum');
/* @var CLpItem $forumItem */
foreach ($forums as $forumItem) {
$forumId = (int) $forumItem->getPath();
$forum = $forumRepository->find($forumId);
if ($forum !== null) {
$forumSession = $forum->getFirstResourceLink()->getSession();
if ($forumSession === null) {
return true;
}
}
}
return false;
}
/**
* Gets the name of a resource (generally used in learnpath when no name is provided).
*

@ -815,10 +815,15 @@ foreach ($categories as $category) {
$user
);
$forumSessionIcon = '';
if (learnpath::isForumFromBaseCourse((int) $id)) {
$forumSessionIcon = Display::getMdiIcon('alert-circle', 'ch-tool-icon', '', 22, get_lang('This learning path has forums from the base course'));
}
$listData[] = [
'learnpath_icon' => $icon_learnpath,
'url_start' => $url_start_lp,
'title' => $my_title,
'title' => $my_title . $forumSessionIcon,
'session_image' => $sessionImage,
'extra' => $extra,
'start_time' => $start_time,

@ -37,4 +37,17 @@ final class CLpItemRepository extends ServiceEntityRepository
'lp' => $lpId,
]);
}
public function findItemsByLearningPathAndType(int $learningPathId, string $itemType): array
{
$qb = $this->createQueryBuilder('i')
->where('i.lp = :learningPathId')
->andWhere('i.itemType = :itemType')
->setParameter('learningPathId', $learningPathId)
->setParameter('itemType', $itemType);
$query = $qb->getQuery();
return $query->getResult();
}
}

Loading…
Cancel
Save