Stocke la totalité des historiques et affiche la dernière page vue
This commit is contained in:
parent
4db14b5da6
commit
59d7a8e5c3
@ -499,7 +499,10 @@ class core extends common
|
|||||||
|| $this->getUser('id') !== $this->getData(['course', self::$siteContent, 'author'])
|
|| $this->getUser('id') !== $this->getData(['course', self::$siteContent, 'author'])
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
$this->setData(['enrolment', self::$siteContent, $this->getUser('id'), 'history', $this->getUrl(0), time()]);
|
$data = is_array($this->getData(['enrolment', self::$siteContent, $this->getUser('id'), 'history', $this->getUrl(0)]))
|
||||||
|
? array_merge([time()], $this->getData(['enrolment', self::$siteContent, $this->getUser('id'), 'history', $this->getUrl(0)]))
|
||||||
|
: [time()];
|
||||||
|
$this->setData(['enrolment', self::$siteContent, $this->getUser('id'), 'history', $this->getUrl(0), $data]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Journalisation
|
// Journalisation
|
||||||
|
@ -282,8 +282,8 @@ class course extends common
|
|||||||
$courseId = $this->getUrl(2);
|
$courseId = $this->getUrl(2);
|
||||||
if (
|
if (
|
||||||
($this->getUser('permission', __CLASS__, __FUNCTION__) !== true
|
($this->getUser('permission', __CLASS__, __FUNCTION__) !== true
|
||||||
// Le contenu n'existe pas
|
// Le contenu n'existe pas
|
||||||
|| $this->getData(['course', $courseId]) === null)
|
|| $this->getData(['course', $courseId]) === null)
|
||||||
) {
|
) {
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
@ -484,11 +484,25 @@ class course extends common
|
|||||||
ksort($users);
|
ksort($users);
|
||||||
|
|
||||||
foreach ($users as $userId => $userValue) {
|
foreach ($users as $userId => $userValue) {
|
||||||
$history = $userValue['history'];
|
|
||||||
|
|
||||||
if (!empty($history)) {
|
// Date et heure de la dernière page vue
|
||||||
$maxTime = max($history);
|
$history = $userValue['history'];
|
||||||
$pageId = array_search($maxTime, $history);
|
$maxTime = 0;
|
||||||
|
foreach ($userValue['history'] as $pageId => $times) {
|
||||||
|
if (is_array($times)) {
|
||||||
|
foreach ($times as $time) {
|
||||||
|
if ($time > $maxTime) {
|
||||||
|
$maxTime = $time;
|
||||||
|
$lastPageId = $pageId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Compatibilité anciennes versions
|
||||||
|
if ($times > $maxTime) {
|
||||||
|
$maxTime = $times;
|
||||||
|
$lastPageId = $pageId;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compte les rôles valides
|
// Compte les rôles valides
|
||||||
@ -529,7 +543,7 @@ class course extends common
|
|||||||
self::$courseUsers[] = [
|
self::$courseUsers[] = [
|
||||||
$userId,
|
$userId,
|
||||||
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
|
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
|
||||||
!empty($history) ? $pages[$pageId] : '-',
|
!empty($history) ? $pages[$lastPageId] : '-',
|
||||||
!empty($history) ? helper::dateUTF8('%d %B %Y - %H:%M', $maxTime) : '-',
|
!empty($history) ? helper::dateUTF8('%d %B %Y - %H:%M', $maxTime) : '-',
|
||||||
$this->getData(['user', $userId, 'tags']),
|
$this->getData(['user', $userId, 'tags']),
|
||||||
template::button('userHistory' . $userId, [
|
template::button('userHistory' . $userId, [
|
||||||
|
Loading…
Reference in New Issue
Block a user