From 13a603b1f9f3d5b20e823460383e9990b3b23521 Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Thu, 4 Apr 2024 16:13:54 +0200 Subject: [PATCH] =?UTF-8?q?fonction=20getReport=20ajout=C3=A9e=20=C3=A0=20?= =?UTF-8?q?tester?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/course/course.php | 56 +++++++++-------------------------- core/module/page/page.php | 6 ++-- 2 files changed, 17 insertions(+), 45 deletions(-) diff --git a/core/module/course/course.php b/core/module/course/course.php index 04f12e8..fe0cbc0 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -641,27 +641,14 @@ class course extends common // Liste des inscrits dans le contenu sélectionné. $users = $this->getData(['enrolment', $courseId]); + // Récupère l'historique des participants + $reports = $this->getReport($courseId); if (is_array($users)) { // Tri du tableau par défaut par $userId ksort($users); foreach ($users as $userId => $userValue) { - // Date et heure de la dernière page vue - // 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]); - } - } - - // Compte les rôles valides if (isset ($profils[$this->getData(['user', $userId, 'group']) . $this->getData(['user', $userId, 'profil'])])) { $profils[$this->getData(['user', $userId, 'group']) . $this->getData(['user', $userId, 'profil'])]++; @@ -694,8 +681,8 @@ class course extends common } // Progression - $viewPages = $this->getData(['enrolment', $courseId, $userId, 'history']) !== null ? - count(array_keys($this->getData(['enrolment', $courseId, $userId, 'history']))) : + $viewPages = $this->getReport($courseId, $userId) !== null ? + count(array_keys($this->getReport($courseId, $userId))) : 0; // Construction du tableau @@ -714,8 +701,8 @@ class course extends common $this->getData(['user', $userId, 'tags']), template::button('userReport' . $userId, [ 'href' => helper::baseUrl() . 'course/userReport/' . $courseId . '/' . $userId, - 'value' => !empty ($userValue['history']) ? min(round(($viewPages * 100) / $sumPages, 1), 100) . ' %' : '0%', - 'disable' => empty ($userValue['history']) + 'value' => !empty ($reports[$userId]) ? min(round(($viewPages * 100) / $sumPages, 1), 100) . ' %' : '0%', + 'disable' => empty ($reports[$userId]) ]), template::button('userDelete' . $userId, [ 'class' => 'userDelete buttonRed', @@ -773,7 +760,7 @@ class course extends common $this->getData(['user', $keyPost]) !== null && $this->getData(['enrolment', $courseId, $keyPost]) === null ) { - $this->setData(['enrolment', $courseId, $keyPost, 'history', array()]); + $this->setData(['enrolment', $courseId, $keyPost, array()]); } } } @@ -1181,7 +1168,7 @@ class course extends common } $userId = $this->getUrl(3); - $h = $this->getData(['enrolment', $courseId, $userId, 'history']); + $h = $this->getReport($courseId, $userId); // Inversion des clés et des valeurs $history = array(); @@ -1310,27 +1297,14 @@ class course extends common mkdir(self::FILE_DIR . 'source/' . $courseId . '/export/'); } $filename = self::FILE_DIR . 'source/' . $courseId . '/export/' . '/synthèse' . helper::dateUTF8('%Y%m%d', time()) . '.csv'; + $reports = $this->getReport($courseId); foreach ($users as $userId => $userValue) { - // Date et heure de la dernière page vue - // 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]); - } - } - // Progression - $viewPages = $this->getData(['enrolment', $courseId, $userId, 'history']) !== null ? - count(array_keys($this->getData(['enrolment', $courseId, $userId, 'history']))) : - 0; + $viewPages = $reports[$userId] != null + ? count($reports[$userId]) + : 0; // Construction du tableau self::$courseUsers[] = [ @@ -1388,7 +1362,7 @@ class course extends common } // Traitement de l'historique - $h = $this->getData(['enrolment', $courseId, $userId, 'history']); + $h = $this->getReport($courseId, $userId); // Inversion des clés et des valeurs $history = array(); @@ -1857,9 +1831,7 @@ class course extends common 'enrolment', $courseId, $userId, - [ - 'history' => [], - ] + [] ]); } diff --git a/core/module/page/page.php b/core/module/page/page.php index 01b1948..b9a2599 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -367,9 +367,9 @@ class page extends common && array_key_exists($userId, $userData) ) { // Remplacer l'ancienne ID par la nouvelle - $datas = $this->getReport(self::$siteContent, [ $userId, $this->getUrl(2)]); - $this->setReport(self::$siteContent, [$userId, $pageId, $datas]); - $this->deleteReport(self::$siteContent, [$userId,$this->getUrl(2)]); + $datas = $this->getReport(self::$siteContent, $userId, $this->getUrl(2)); + $this->setReport(self::$siteContent, $userId, $pageId, $datas); + $this->deleteReport(self::$siteContent, $userId, $this->getUrl(2)); } // Mettre à jour la dernière page vue si nécessaire if ($this->getData(['enrolment', self::$siteContent, $userId, 'lastPageView']) === $this->getUrl(2)) {