forked from ZwiiCMS-Team/ZwiiCampus
fonction getReport ajoutée à tester
This commit is contained in:
parent
ab34cb1953
commit
13a603b1f9
@ -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' => [],
|
||||
]
|
||||
[]
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user