Move code to another class - refs BT#18671

pull/3859/head
Angel Fernando Quiroz Campos 4 years ago
parent a5f46bcec0
commit 1a051738fa
  1. 46
      main/inc/lib/StudentFollowPage.php
  2. 44
      main/inc/lib/tracking.lib.php
  3. 2
      main/mySpace/myStudents.php

@ -2,6 +2,8 @@
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CItemProperty;
/**
* Class StudentFollowPage.
*/
@ -9,6 +11,50 @@ class StudentFollowPage
{
const VARIABLE_ACQUISITION = 'acquisition';
public static function getLpSubscription(
array $lpInfo,
int $studentId,
int $courseId,
int $sessionId = 0
): string {
$em = Database::getManager();
if ($lpInfo['subscribe_users']) {
$itemRepo = $em->getRepository(CItemProperty::class);
$itemProperty = $itemRepo->findByUserSuscribedToItem(
'learnpath',
$lpInfo['iid'],
api_get_user_entity($studentId),
api_get_course_entity($courseId),
api_get_session_entity($sessionId)
);
if (null === $itemProperty) {
return '-';
}
return "{$itemProperty->getInsertUser()->getCompleteName()}<br>"
.Display::tag(
'small',
api_convert_and_format_date($itemProperty->getInsertDate(), DATE_TIME_FORMAT_LONG)
);
}
$subscriptionEvent = Event::findUserSubscriptionToCourse($studentId, $courseId, $sessionId);
if (empty($subscriptionEvent)) {
return '-';
}
$creator = api_get_user_entity($subscriptionEvent['default_user_id']);
return "{$creator->getCompleteName()}<br>"
.Display::tag(
'small',
api_convert_and_format_date($subscriptionEvent['default_date'], DATE_TIME_FORMAT_LONG)
);
}
public static function getLpAcquisition(
array $lpInfo,
int $studentId,

@ -7716,50 +7716,6 @@ class Tracking
}
}
}
public static function getStudentFollowPageLpSubscription(
array $lpInfo,
int $studentId,
int $courseId,
int $sessionId = 0
) {
$em = Database::getManager();
if ($lpInfo['subscribe_users']) {
$itemRepo = $em->getRepository(CItemProperty::class);
$itemProperty = $itemRepo->findByUserSuscribedToItem(
'learnpath',
$lpInfo['iid'],
api_get_user_entity($studentId),
api_get_course_entity($courseId),
api_get_session_entity($sessionId)
);
if (null === $itemProperty) {
return '-';
}
return "{$itemProperty->getInsertUser()->getCompleteName()}<br>"
.Display::tag(
'small',
api_convert_and_format_date($itemProperty->getInsertDate(), DATE_TIME_FORMAT_LONG)
);
}
$subscriptionEvent = Event::findUserSubscriptionToCourse($studentId, $courseId, $sessionId);
if (empty($subscriptionEvent)) {
return '-';
}
$creator = api_get_user_entity($subscriptionEvent['default_user_id']);
return "{$creator->getCompleteName()}<br>"
.Display::tag(
'small',
api_convert_and_format_date($subscriptionEvent['default_date'], DATE_TIME_FORMAT_LONG)
);
}
}
/**

@ -1581,7 +1581,7 @@ if (empty($details)) {
if (in_array('student_follow_page_add_LP_subscription_info', $columnHeadersKeys)) {
echo Display::tag(
'td',
Tracking::getStudentFollowPageLpSubscription(
StudentFollowPage::getLpSubscription(
$learnpath,
$student_id,
$courseInfo['real_id'],

Loading…
Cancel
Save