1.4.23 User History modifié
This commit is contained in:
parent
b8123b0534
commit
023ba99c0b
@ -1121,17 +1121,23 @@ 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']);
|
$h = $this->getData(['enrolment', $courseId, $userId, 'history']);
|
||||||
|
|
||||||
|
// Inversion des clés et des valeurs
|
||||||
|
$history = array();
|
||||||
|
foreach ($h as $key => $values) {
|
||||||
|
foreach ($values as $value) {
|
||||||
|
$history[$value] = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ksort($history);
|
||||||
|
|
||||||
// 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);
|
$p = json_decode(file_get_contents(self::DATA_DIR . $courseId . '/page.json'), true);
|
||||||
$data = $data['page'];
|
foreach ($p['page'] as $pageId => $pageData) {
|
||||||
$count = 0;
|
|
||||||
foreach ($data as $pageId => $pageData) {
|
|
||||||
if ($pageData['position'] > 0) {
|
if ($pageData['position'] > 0) {
|
||||||
$count++;
|
|
||||||
$pages[$pageId] = [
|
$pages[$pageId] = [
|
||||||
'number' => $count,
|
|
||||||
'title' => $pageData['title'],
|
'title' => $pageData['title'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -1139,37 +1145,33 @@ class course extends common
|
|||||||
|
|
||||||
$floorTime = 99999999999;
|
$floorTime = 99999999999;
|
||||||
$topTime = 0;
|
$topTime = 0;
|
||||||
|
$lastView = 0;
|
||||||
|
|
||||||
foreach ($history as $pageId => $times) {
|
foreach ($history as $time => $pageId) {
|
||||||
// Dates de consultation de la page
|
if (isset($pages[$pageId]['title'])) {
|
||||||
if (is_array($times)) {
|
$lastView = ($lastView === 0) ? $time : $lastView;
|
||||||
$d = array();
|
$diff = $time - $lastView;
|
||||||
foreach ($times as $time) {
|
self::$userHistory[] = [
|
||||||
if (isset($pages[$pageId]['number'])) {
|
html_entity_decode($pages[$pageId]['title']),
|
||||||
self::$userHistory[] = [
|
$time,
|
||||||
$pages[$pageId]['number'],
|
($diff < 1800) ? sprintf("%d' %d''", floor($diff / 60), $diff % 60) : "Non significatif",
|
||||||
html_entity_decode($pages[$pageId]['title']),
|
];
|
||||||
helper::dateUTF8('%d/%m/%Y', $time),
|
$lastView = $time;
|
||||||
helper::dateUTF8('%H:%M', $time)
|
$floorTime = isset($floorTime) && $floorTime < $time ? $floorTime : $time;
|
||||||
];
|
$topTime = isset($topTime) && $topTime > $time ? $topTime : $time;
|
||||||
$floorTime = isset($floorTime) && $floorTime < $time ? $floorTime : $time;
|
|
||||||
$topTime = isset($topTime) && $topTime > $time ? $topTime : $time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isset($pages[$pageId]['number'])) {
|
|
||||||
self::$userHistory[] = [
|
|
||||||
$pages[$pageId]['number'],
|
|
||||||
html_entity_decode($pages[$pageId]['title']),
|
|
||||||
helper::dateUTF8('%d/%m/%Y', $times),
|
|
||||||
helper::dateUTF8('%H:%M', $times)
|
|
||||||
];
|
|
||||||
$floorTime = isset($floorTime) && $floorTime < $times ? $floorTime : $times;
|
|
||||||
$topTime = isset($topTime) && $topTime > $times ? $topTime : $times;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Décale les temps de consultation
|
||||||
|
for ($i = 0; $i < count(self::$userHistory) - 1; $i++) {
|
||||||
|
self::$userHistory[$i][2] = self::$userHistory[$i + 1][2];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formate le timestamp
|
||||||
|
array_walk(self::$userHistory, function (&$item) {
|
||||||
|
$item[1] = helper::dateUTF8('%d/%m/%Y %H:%M:%S', $item[1]);
|
||||||
|
});
|
||||||
|
|
||||||
self::$userStat['floor'] = helper::dateUTF8('%d %B %Y %H:%M', $floorTime);
|
self::$userStat['floor'] = helper::dateUTF8('%d %B %Y %H:%M', $floorTime);
|
||||||
self::$userStat['top'] = helper::dateUTF8('%d %B %Y %H:%M', $topTime);
|
self::$userStat['top'] = helper::dateUTF8('%d %B %Y %H:%M', $topTime);
|
||||||
$d = $topTime - $floorTime;
|
$d = $topTime - $floorTime;
|
||||||
@ -1184,10 +1186,7 @@ class course extends common
|
|||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'title' => helper::translate('Historique ') . $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
|
'title' => helper::translate('Historique ') . $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
|
||||||
'view' => 'userHistory',
|
'view' => 'userHistory'
|
||||||
'vendor' => [
|
|
||||||
'datatables'
|
|
||||||
]
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1293,50 +1292,60 @@ 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']);
|
|
||||||
self::$userHistory = [
|
// Traitement de l'historique
|
||||||
0 => ['Ordre', 'PageId', 'Page Titre', 'Consultation Date', 'Consultation Heure']
|
$h = $this->getData(['enrolment', $courseId, $userId, 'history']);
|
||||||
];
|
|
||||||
|
// Inversion des clés et des valeurs
|
||||||
|
$history = array();
|
||||||
|
foreach ($h as $key => $values) {
|
||||||
|
foreach ($values as $value) {
|
||||||
|
$history[$value] = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ksort($history);
|
||||||
|
|
||||||
// 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);
|
$p = json_decode(file_get_contents(self::DATA_DIR . $courseId . '/page.json'), true);
|
||||||
$data = $data['page'];
|
foreach ($p['page'] as $pageId => $pageData) {
|
||||||
$count = 0;
|
|
||||||
foreach ($data as $pageId => $pageData) {
|
|
||||||
if ($pageData['position'] > 0) {
|
if ($pageData['position'] > 0) {
|
||||||
$count++;
|
|
||||||
$pages[$pageId] = [
|
$pages[$pageId] = [
|
||||||
'number' => $count,
|
|
||||||
'title' => $pageData['title'],
|
'title' => $pageData['title'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($history as $pageId => $times) {
|
$lastView = 0;
|
||||||
// Dates de consultation de la page
|
|
||||||
if (is_array($times)) {
|
|
||||||
$d = array();
|
|
||||||
foreach ($times as $time) {
|
|
||||||
self::$userHistory[] = [
|
|
||||||
$pages[$pageId]['number'],
|
|
||||||
$pageId,
|
|
||||||
html_entity_decode($pages[$pageId]['title']),
|
|
||||||
helper::dateUTF8('%d/%d/%Y', $time),
|
|
||||||
helper::dateUTF8('%H:%M:%S', $time),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
|
foreach ($history as $time => $pageId) {
|
||||||
|
if (isset($pages[$pageId]['title'])) {
|
||||||
|
$lastView = ($lastView === 0) ? $time : $lastView;
|
||||||
|
$diff = $time - $lastView;
|
||||||
self::$userHistory[] = [
|
self::$userHistory[] = [
|
||||||
$pages[$pageId]['number'],
|
|
||||||
$pageId,
|
$pageId,
|
||||||
html_entity_decode($pages[$pageId]['title']),
|
html_entity_decode($pages[$pageId]['title']),
|
||||||
helper::dateUTF8('%d/%d/%Y', $times),
|
$time,
|
||||||
helper::dateUTF8('%H:%M:%S', $time),
|
($diff < 1800) ? sprintf("%d' %d''", floor($diff / 60), $diff % 60) : "Non significatif",
|
||||||
];
|
];
|
||||||
|
$lastView = $time;
|
||||||
|
$floorTime = isset($floorTime) && $floorTime < $time ? $floorTime : $time;
|
||||||
|
$topTime = isset($topTime) && $topTime > $time ? $topTime : $time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Décale les temps de consultation
|
||||||
|
for ($i = 0; $i < count(self::$userHistory) - 1; $i++) {
|
||||||
|
self::$userHistory[$i][3] = self::$userHistory[$i + 1][3];
|
||||||
|
}
|
||||||
|
// Formate le timestamp
|
||||||
|
array_walk(self::$userHistory, function (&$item) {
|
||||||
|
$item[2] = helper::dateUTF8('%d/%m/%Y %H:%M:%S', $item[2]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ajoute les entêtes
|
||||||
|
self::$userHistory = array_merge([0 => ['PageId', 'Page Titre', 'Consultation Date', 'Temps Consultation']], self::$userHistory);
|
||||||
|
|
||||||
// Dossier d'export
|
// Dossier d'export
|
||||||
if (is_dir(self::FILE_DIR . 'source/' . $courseId) === false) {
|
if (is_dir(self::FILE_DIR . 'source/' . $courseId) === false) {
|
||||||
mkdir(self::FILE_DIR . 'source/' . $courseId);
|
mkdir(self::FILE_DIR . 'source/' . $courseId);
|
||||||
|
@ -15,4 +15,8 @@
|
|||||||
|
|
||||||
/** NE PAS EFFACER
|
/** NE PAS EFFACER
|
||||||
* admin.css
|
* admin.css
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
table td {
|
||||||
|
text-align: left;
|
||||||
|
}
|
@ -12,15 +12,5 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$(document).ready((function () {
|
$(document).ready((function () {
|
||||||
$.fn.dataTable.moment( 'DD/MM/YYYY' );
|
|
||||||
$('#dataTables').DataTable({
|
|
||||||
language: {
|
|
||||||
url: "core/vendor/datatables/french.json"
|
|
||||||
},
|
|
||||||
locale: 'fr',
|
|
||||||
searching: false,
|
|
||||||
pageLength: 100,
|
|
||||||
lengthChange: false,
|
|
||||||
paging: false
|
|
||||||
});
|
|
||||||
}));
|
}));
|
@ -19,7 +19,7 @@
|
|||||||
<div class="col4 offset2">
|
<div class="col4 offset2">
|
||||||
<?php if ($this->getData(['course', $this->getUrl(2), 'access']) === self::COURSE_ACCESS_DATE): ?>
|
<?php if ($this->getData(['course', $this->getUrl(2), 'access']) === self::COURSE_ACCESS_DATE): ?>
|
||||||
<p>Espace ouvert le :
|
<p>Espace ouvert le :
|
||||||
<?php echo helper::dateUTF8('%d %B %Y %H:%M', $this->getData(['course', $this->getUrl(2), 'openingDate'])); ?></p
|
<?php echo helper::dateUTF8('%d %B %Y %H:%M', $this->getData(['course', $this->getUrl(2), 'openingDate'])); ?></p>
|
||||||
<p>Espace fermé le :
|
<p>Espace fermé le :
|
||||||
<?php echo helper::dateUTF8('%d %B %Y %H:%M', $this->getData(['course', $this->getUrl(2), 'closingDate'])); ?></p>
|
<?php echo helper::dateUTF8('%d %B %Y %H:%M', $this->getData(['course', $this->getUrl(2), 'closingDate'])); ?></p>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row textAlignCenter">
|
<div class="row textAlignCenter">
|
||||||
<div class="col8">
|
<div class="col8">
|
||||||
<?php echo template::table([1, 5, 3, 3], $module::$userHistory, ['#', 'Page', 'Date Consultation', 'Heure'], ['id' => 'dataTables']);?>
|
<?php echo template::table([6, 3, 3], $module::$userHistory, ['Page', 'Début de Consultation', 'Temps consultation']);?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user