Format CSV Export et format progreesion export

This commit is contained in:
Fred Tempez 2023-12-09 22:45:20 +01:00
parent 86e9322afc
commit bce93cecba
2 changed files with 38 additions and 13 deletions

View File

@ -533,10 +533,11 @@ class course extends common
continue; continue;
} }
// Taux de parcours // Progression
$viewPages = $this->getData(['enrolment', $courseId, $userId, 'history']) !== null ? $viewPages = $this->getData(['enrolment', $courseId, $userId, 'history']) !== null ?
count(array_keys($this->getData(['enrolment', $courseId, $userId, 'history']))) : count(array_keys($this->getData(['enrolment', $courseId, $userId, 'history']))) :
0; 0;
// Construction du tableau // Construction du tableau
self::$courseUsers[] = [ self::$courseUsers[] = [
$userId, $userId,
@ -1014,6 +1015,10 @@ class course extends common
$courseId = $this->getUrl(2); $courseId = $this->getUrl(2);
self::$courseUsers = [
0 => ['UserId', 'Prénom', 'Nom', 'Page Titre', 'Consultation Date', 'Consultation Heure', 'Progression']
];
// Statistiques du contenu sélectionné calcul du nombre de pages // Statistiques du contenu sélectionné calcul du nombre de pages
$sumPages = 0; $sumPages = 0;
$data = json_decode(file_get_contents(self::DATA_DIR . $courseId . '/page.json'), true); $data = json_decode(file_get_contents(self::DATA_DIR . $courseId . '/page.json'), true);
@ -1043,21 +1048,35 @@ class course extends common
$filename = $path . $courseId . '/synthèse' . helper::dateUTF8('%Y%m%d', time()) . '.csv'; $filename = $path . $courseId . '/synthèse' . helper::dateUTF8('%Y%m%d', time()) . '.csv';
foreach ($users as $userId => $userValue) { foreach ($users as $userId => $userValue) {
$history = $userValue['history'];
$maxTime = max($history); // Date et heure de la dernière page vue
$pageId = array_search($maxTime, $history); // Compatibilité anciennes versions
if (
$this->getData(['enrolment', $courseId, $userId, 'lastPageView']) === null
or $this->getData(['enrolment', $courseId, $userId, 'datePageView']) === null
) {
if (!empty($userValue['history'])) {
$maxTime = max($userValue['history']);
$lastPageId = array_search($maxTime, $userValue['history']);
$this->setData(['enrolment', $courseId, $userId, 'lastPageView', $lastPageId]);
$this->setData(['enrolment', $courseId, $userId, 'datePageView', $maxTime]);
}
}
// Taux de parcours // Progression
$viewPages = count($this->getData(['enrolment', $courseId, $userId, 'history'])); $viewPages = $this->getData(['enrolment', $courseId, $userId, 'history']) !== null ?
count(array_keys($this->getData(['enrolment', $courseId, $userId, 'history']))) :
0;
// Construction du tableau // Construction du tableau
self::$courseUsers[] = [ self::$courseUsers[] = [
$userId, $userId,
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']), $this->getData(['user', $userId, 'firstname']),
$pages[$pageId], $this->getData(['user', $userId, 'lastname']),
helper::dateUTF8('%d %B %Y - %H:%M', $maxTime), $pages[$this->getData(['enrolment', $courseId, $userId, 'lastPageView'])],
round(($viewPages * 100) / $sumPages, 1) helper::dateUTF8('%d/%d/%Y', $this->getData(['enrolment', $courseId, $userId, 'datePageView'])),
helper::dateUTF8('%H:%M', $this->getData(['enrolment', $courseId, $userId, 'datePageView'])),
number_format(round(($viewPages * 100) / $sumPages, 1) / 100, 2, ',')
]; ];
// Synthèse des historiques // Synthèse des historiques
@ -1092,6 +1111,9 @@ class course extends common
$courseId = $this->getUrl(2); $courseId = $this->getUrl(2);
$userId = $this->getUrl(3); $userId = $this->getUrl(3);
$history = $this->getData(['enrolment', $courseId, $userId, 'history']); $history = $this->getData(['enrolment', $courseId, $userId, 'history']);
self::$userHistory= [
0 => ['Ordre', 'PageId', 'Page Titre', 'Consultation Date', 'Consultation Heure']
];
// Liste des pages contenues dans cet espace et exclure les barres et les pages masquées // Liste des pages contenues dans cet espace et exclure les barres et les pages masquées
$data = json_decode(file_get_contents(self::DATA_DIR . $courseId . '/page.json'), true); $data = json_decode(file_get_contents(self::DATA_DIR . $courseId . '/page.json'), true);
@ -1116,15 +1138,18 @@ class course extends common
$pages[$pageId]['number'], $pages[$pageId]['number'],
$pageId, $pageId,
html_entity_decode($pages[$pageId]['title']), html_entity_decode($pages[$pageId]['title']),
helper::dateUTF8('%d %B %Y %H:%M:%S', $time) helper::dateUTF8('%d/%d/%Y', $time),
helper::dateUTF8('%H:%M:%S', $time),
]; ];
} }
} else { } else {
self::$userHistory[] = [ self::$userHistory[] = [
$pages[$pageId]['number'], $pages[$pageId]['number'],
$pageId, $pageId,
html_entity_decode($pages[$pageId]['title']), html_entity_decode($pages[$pageId]['title']),
helper::dateUTF8('%d %B %Y %H:%M:%S', $times) helper::dateUTF8('%d/%d/%Y', $times),
helper::dateUTF8('%H:%M:%S', $time),
]; ];
} }
} }

View File

@ -17,7 +17,7 @@
<?php if ($module::$userHistory): ?> <?php if ($module::$userHistory): ?>
<div class="row textAlignCenter"> <div class="row textAlignCenter">
<div class="col8"> <div class="col8">
<?php echo template::table([1, 6, 5], $module::$userHistory, ['Ordre', 'Titre de la page', 'Consultations'], ['id' => 'dataTables']); ?> <?php echo template::table([1, 6, 5], $module::$userHistory, ['Ordre', 'Page', 'Consultation'], ['id' => 'dataTables']); ?>
</div> </div>
</div> </div>
<?php else: ?> <?php else: ?>