Línea 1367... |
Línea 1367... |
1367 |
|
1367 |
|
1368 |
// Initialize mappers
|
1368 |
// Initialize mappers
|
1369 |
$capsuleMapper = MicrolearningCapsuleMapper::getInstance($this->adapter);
|
1369 |
$capsuleMapper = MicrolearningCapsuleMapper::getInstance($this->adapter);
|
1370 |
$userProgressMapper = MicrolearningUserProgressMapper::getInstance($this->adapter);
|
1370 |
$userProgressMapper = MicrolearningUserProgressMapper::getInstance($this->adapter);
|
- |
|
1371 |
$capsuleCommentMapper = MicrolearningCapsuleCommentMapper::getInstance($this->adapter);
|
Línea -... |
Línea 1372... |
- |
|
1372 |
$topicCapsuleMapper = MicrolearningTopicCapsuleMapper::getInstance($this->adapter); // Added mapper
|
- |
|
1373 |
|
- |
|
1374 |
// Fetch access granted capsule IDs for the current user
|
1371 |
$capsuleCommentMapper = MicrolearningCapsuleCommentMapper::getInstance($this->adapter);
|
1375 |
$accessGrantedIds = $this->getAccessGranted();
|
- |
|
1376 |
|
- |
|
1377 |
// Fetch active topic-capsule relations for the given topic
|
1372 |
|
1378 |
// Assuming the 'true' in the original call implied active relations/capsules.
|
- |
|
1379 |
// We fetch active relations first.
|
- |
|
1380 |
$topicCapsuleRelations = $topicCapsuleMapper->fetchAllActiveByTopicId($topic->id);
|
- |
|
1381 |
|
- |
|
1382 |
$capsuleIdsToFetch = [];
|
- |
|
1383 |
if (!empty($topicCapsuleRelations)) {
|
- |
|
1384 |
foreach ($topicCapsuleRelations as $relation) {
|
- |
|
1385 |
// Ensure the user has access to this specific capsule ID from the relation
|
- |
|
1386 |
if (in_array($relation->capsule_id, $accessGrantedIds->capsules)) {
|
- |
|
1387 |
$capsuleIdsToFetch[] = $relation->capsule_id;
|
- |
|
1388 |
}
|
- |
|
1389 |
}
|
- |
|
1390 |
}
|
- |
|
1391 |
|
- |
|
1392 |
$capsules = []; // Initialize $capsules as an empty array
|
- |
|
1393 |
if (!empty($capsuleIdsToFetch)) {
|
- |
|
1394 |
// Fetch capsule details for the accessible and related capsule IDs
|
- |
|
1395 |
// Remove duplicates just in case, though relations should be unique per topic-capsule pair
|
Línea 1373... |
Línea 1396... |
1373 |
// Fetch all active capsules for the given topic ID
|
1396 |
$capsules = $capsuleMapper->fetchAllByIds(array_unique($capsuleIdsToFetch));
|
1374 |
$capsules = $capsuleMapper->fetchAllByTopicId($topic->id, true);
|
1397 |
}
|
1375 |
|
1398 |
|
1376 |
if(count($capsules) > 0) {
|
1399 |
if(count($capsules) > 0) {
|
Línea 1396... |
Línea 1419... |
1396 |
array_push($capsulesData, [
|
1419 |
array_push($capsulesData, [
|
1397 |
'uuid' => $capsule->uuid,
|
1420 |
'uuid' => $capsule->uuid,
|
1398 |
'name' => $capsule->name ? $capsule->name : '',
|
1421 |
'name' => $capsule->name ? $capsule->name : '',
|
1399 |
'description' => $capsule->description ? $capsule->description : '',
|
1422 |
'description' => $capsule->description ? $capsule->description : '',
|
1400 |
'image' => $capsule->image ? $storage->getGenericImage($pathCapsule, $capsule->uuid, $capsule->image) : '',
|
1423 |
'image' => $capsule->image ? $storage->getGenericImage($pathCapsule, $capsule->uuid, $capsule->image) : '',
|
1401 |
'link_comments' => $this->url()->fromRoute('microlearning/capsules-comments', ['capsule_id' => $capsule->uuid], ['force_canonical' => true]),
|
- |
|
1402 |
'link_comment_add' => $this->url()->fromRoute('microlearning/capsules-comments/add', ['capsule_id' => $capsule->uuid],['force_canonical' => true]),
|
- |
|
1403 |
'link_slides' => $this->url()->fromRoute('microlearning/slides', ['topic_id' => $topic->uuid, 'capsule_id' => $capsule->uuid], ['force_canonical' => true]),
|
- |
|
1404 |
'link_get' => $this->url()->fromRoute('microlearning/get-capsule', ['id' => $capsule->uuid], ['force_canonical' => true]),
|
- |
|
1405 |
'total_comments' => strval($dataCountAndRatingAverage['total_comments']),
|
1424 |
'total_comments' => strval($dataCountAndRatingAverage['total_comments']),
|
1406 |
'total_rating' => strval($dataCountAndRatingAverage['total_rating']),
|
1425 |
'total_rating' => strval($dataCountAndRatingAverage['total_rating']),
|
1407 |
'progress' => $capsuleProgress,
|
1426 |
'progress' => $capsuleProgress,
|
1408 |
'completed' => $capsuleCompleted,
|
1427 |
'completed' => $capsuleCompleted,
|
1409 |
'order' => $capsule->order,
|
1428 |
'order' => $capsule->order,
|