From 5be2a5d6ed0d6e18d620f7fa44062bfdc878d9ef Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Tue, 17 Oct 2023 19:17:04 +0200 Subject: [PATCH] =?UTF-8?q?v40=20D=C3=A9compte=20des=20r=C3=B4les?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.php | 2 +- core/module/course/course.php | 24 +++++++++++++++++-- core/module/install/ressource/defaultdata.php | 1 + 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/core/core.php b/core/core.php index 55d0b99..2fe8891 100644 --- a/core/core.php +++ b/core/core.php @@ -50,7 +50,7 @@ class common const ACCESS_TIMER = 1800; // Numéro de version - const ZWII_VERSION = '1.0.40'; + const ZWII_VERSION = '1.0.41'; // URL autoupdate const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/lms/'; diff --git a/core/module/course/course.php b/core/module/course/course.php index 172a818..4b3d095 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -390,12 +390,14 @@ class course extends common break; case "3": self::$courseGroups['30'] = 'Administrateur'; + $profils['30'] = 0; break; case "1": case "2": foreach ($groupValue as $profilId => $profilValue) { if ($profilId) { self::$courseGroups[$groupId . $profilId] = sprintf(helper::translate('Groupe %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); + $profils[$groupId . $profilId] = 0; } } } @@ -422,6 +424,7 @@ class course extends common $users = $this->getData(['enrolment', $courseId]); // Tri du tableau par défaut par $userId ksort($users); + foreach ($users as $userId => $userValue) { $history = $userValue['history']; @@ -455,7 +458,8 @@ class course extends common // Taux de parcours $viewPages = count($this->getData(['enrolment', $courseId, $userId, 'history'])); - // Construction tu tableau + + // Construction du tableau self::$courseUsers[] = [ $userId, $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']), @@ -469,12 +473,28 @@ class course extends common 'help' => 'Désinscrire' ]) ]; + + // Compte les rôles + $group = $this->getData(['user', $userId, 'group']) . $this->getData(['user', $userId, 'profil']); + $profils[$group]++; } + // Ajoute les effectifs aux profils du sélecteur + foreach (self::$courseGroups as $groupId => $groupValue) { + if($groupId === 'all') { + self::$courseGroups['all'] = self::$courseGroups['all'] . ' (' . array_sum($profils) . ')'; + } else { + self::$courseGroups[$groupId] = self::$courseGroups[$groupId] . ' ('.$profils[$groupId].')'; + } + } + // Message selon les effectifs + $message = count(self::$courseUsers) > 0 + ? sprintf(helper::translate('%s inscrits dans le cours %s'), count(self::$courseUsers), $this->getData(['course', $courseId, 'title'])) + : sprintf(helper::translate('Aucun inscrit dans le cours %s'), $this->getData(['course', $courseId, 'title'])); // Valeurs en sortie $this->addOutput([ - 'title' => sprintf(helper::translate('%s inscrits dans le cours %s'), count(self::$courseUsers), $this->getData(['course', $courseId, 'title'])), + 'title' => $message, 'view' => 'user', 'vendor' => [ 'datatables' diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index 14594c9..ff5a3de 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -554,6 +554,7 @@ class init extends common ], '3' => [ 'name' => 'Administrateur', + 'group' => 0, 'readonly' => true, 'permanent' => true, 'comment' => 'Contrôle total',