forked from ZwiiCMS-Team/ZwiiCampus
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->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
|
||||
|
@ -484,11 +484,25 @@ class course extends common
|
||||
ksort($users);
|
||||
|
||||
foreach ($users as $userId => $userValue) {
|
||||
$history = $userValue['history'];
|
||||
|
||||
if (!empty($history)) {
|
||||
$maxTime = max($history);
|
||||
$pageId = array_search($maxTime, $history);
|
||||
// Date et heure de la dernière page vue
|
||||
$history = $userValue['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
|
||||
@ -529,7 +543,7 @@ class course extends common
|
||||
self::$courseUsers[] = [
|
||||
$userId,
|
||||
$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) : '-',
|
||||
$this->getData(['user', $userId, 'tags']),
|
||||
template::button('userHistory' . $userId, [
|
||||
|
Loading…
Reference in New Issue
Block a user