Skip to content

Commit

Permalink
Studen follow page: Allow show subscription info for groups - refs BT…
Browse files Browse the repository at this point in the history
…#18671
  • Loading branch information
AngelFQC committed Apr 27, 2021
1 parent b902067 commit 24c4568
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 11 deletions.
24 changes: 21 additions & 3 deletions main/inc/lib/StudentFollowPage.php
Expand Up @@ -25,11 +25,29 @@ public static function getLpSubscription(
$itemProperty = $itemRepo->findByUserSuscribedToItem(
'learnpath',
$lpInfo['iid'],
api_get_user_entity($studentId),
api_get_course_entity($courseId),
api_get_session_entity($sessionId)
$studentId,
$courseId,
$sessionId
);

if (null === $itemProperty) {
$userGroups = GroupManager::getAllGroupPerUserSubscription($studentId, $courseId);

foreach ($userGroups as $groupInfo) {
$itemProperty = $itemRepo->findByGroupSuscribedToLp(
'learnpath',
$lpInfo['iid'],
$groupInfo['iid'],
$courseId,
$sessionId
);

if (null !== $itemProperty) {
break;
}
}
}

if (null === $itemProperty) {
return '-';
}
Expand Down
Expand Up @@ -47,19 +47,38 @@ public function getUsersSubscribedToItem(
public function findByUserSuscribedToItem(
$tool,
$itemId,
User $user,
Course $course,
Session $session = null,
Group $group = null
int $userId,
int $courseId,
int $sessionId = null
): ?CItemProperty {
$criteria = [
'tool' => $tool,
'lasteditType' => 'LearnpathSubscription',
'ref' => $itemId,
'toUser' => $user,
'course' => $course,
'session' => $session,
'group' => $group,
'toUser' => $userId,
'course' => $courseId,
'session' => $sessionId ?: null,
'group' => null,
];

return $this->findOneBy($criteria);
}

public function findByGroupSuscribedToLp(
$tool,
$lpId,
int $groupId,
int $courseId,
int $sessionId = 0
): ?CItemProperty {
$criteria = [
'tool' => $tool,
'lasteditType' => 'LearnpathSubscription',
'ref' => $lpId,
'toUser' => null,
'course' => $courseId,
'session' => $sessionId ?: null,
'group' => $groupId,
];

return $this->findOneBy($criteria);
Expand Down

0 comments on commit 24c4568

Please sign in to comment.