From 0c8c9f89fde9608ac5c58b974ffd2f3d475144d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Thu, 5 Dec 2024 17:55:27 +0100 Subject: [PATCH] 1.14.09 Suivi de la progression dans enrolment en suspend. --- core/class/router.class.php | 4 ++-- core/core.php | 4 ++-- core/module/course/course.php | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/core/class/router.class.php b/core/class/router.class.php index eeb0bc5..c047398 100644 --- a/core/class/router.class.php +++ b/core/class/router.class.php @@ -532,8 +532,8 @@ class core extends common and $this->getData(['course', self::$siteContent, 'enrolment']) > 0 ) { $course = new course(); - self::$userProgress = $course->userProgress(self::$siteContent, $this->getUser('id')); - $this->setData(['enrolment', self::$siteContent, $this->getUser('id'), 'progress', self::$userProgress ]); + $userProgress = $course->userProgress(self::$siteContent, $this->getUser('id')); + $this->setData(['enrolment', self::$siteContent, $this->getUser('id'), 'progress', $userProgress ]); } } diff --git a/core/core.php b/core/core.php index bd1a5b6..6fdc7f2 100644 --- a/core/core.php +++ b/core/core.php @@ -51,7 +51,7 @@ class common const ACCESS_TIMER = 1800; // Numéro de version - const ZWII_VERSION = '1.14.08'; + const ZWII_VERSION = '1.14.09'; // URL autoupdate const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/campus-update/raw/branch/master/'; @@ -178,7 +178,7 @@ class common // Espace, contenu sélectionné public static $siteContent = 'home'; // Progression d'un participant - public static $userProgress = ''; + // public static $userProgress = ''; public static $languages = [ 'de' => 'Deutsch', diff --git a/core/module/course/course.php b/core/module/course/course.php index 0408d2e..d822e0e 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -738,11 +738,13 @@ class course extends common * Soit avec l'ancienne méthode qui consiste à recalculer la progression. * TRANSITOIRE A SUPPRIMER EN FIN D'ANNEE **/ + /* 'value' => array_key_exists('progress', $userValue) ? $userValue['progress'] : ($viewPages ? min(round(($viewPages * 100) / $sumPages, 1), 100) . ' %' : '0%'), 'disable' => empty($userValue['datePageView']), - //'value' => $viewPages ? min(round(($viewPages * 100) / $sumPages, 1), 100) . ' %' : '0%', + */ + 'value' => $viewPages ? min(round(($viewPages * 100) / $sumPages, 1), 100) . ' %' : '0%', //'disable' => empty($viewPages) ]), template::button('userDelete' . $userId, [ @@ -2062,7 +2064,7 @@ class course extends common return true; case self::COURSE_ACCESS_DATE: return ( - time() >= $this->getData(['course', $courseId, 'openingDate']) && + time() >= $this->getData(['course', $courseId, 'openingDate']) && time() <= $this->getData(['course', $courseId, 'closingDate']) ); case self::COURSE_ACCESS_CLOSE: @@ -2073,7 +2075,7 @@ class course extends common /** - * Méthode externe pour afficher la progression dans les espaces. + * Méthode externe pour calculer la progression dans les espaces et la stocker dans enrolment * * @param mixed $courseId * @param mixed $userId @@ -2091,10 +2093,14 @@ class course extends common 0; // Nombre de pages vues $sumPages = $this->countPages($this->getData(['page'])); - + // Calcule le ratio - $ratio = number_format(min(round(($viewPages * 100) / $sumPages, 1) / 100, 1), 2, ','); - + $ratio = ($viewPages *100) / $sumPages; + // Arrondi le ratio à deux décimales + $ratio = round($ratio, 2); + // Transforme le ratio en pourcentage + $ratio = number_format($ratio) . ' %'; + return $ratio; }