Corrige :
 - tableau de stats vides affichant une erreur
 - correction relative au rapport d'un participant
Nouvelle fonctionnalité :
- Bouton de réinitialisation d'un espace, efface les historiques et les inscriptions, les désinscriptions des participants et par autorité ne suppriment plus les historiques.
This commit is contained in:
Fred Tempez 2024-04-17 10:33:00 +02:00
parent 37f77b3d50
commit 8c9bc40a02
8 changed files with 114 additions and 28 deletions

View File

@ -51,7 +51,7 @@ class common
const ACCESS_TIMER = 1800; const ACCESS_TIMER = 1800;
// Numéro de version // Numéro de version
const ZWII_VERSION = '1.8.00'; const ZWII_VERSION = '1.8.01';
// URL autoupdate // URL autoupdate
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/campus-update/raw/branch/master/'; const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/campus-update/raw/branch/master/';

View File

@ -32,6 +32,7 @@ class course extends common
'userReportExport' => self::GROUP_EDITOR, //Fait 'userReportExport' => self::GROUP_EDITOR, //Fait
'backup' => self::GROUP_EDITOR, // Fait 'backup' => self::GROUP_EDITOR, // Fait
'restore' => self::GROUP_EDITOR, //Fait 'restore' => self::GROUP_EDITOR, //Fait
'reset' => self::GROUP_EDITOR,
'clone' => self::GROUP_ADMIN, 'clone' => self::GROUP_ADMIN,
'add' => self::GROUP_ADMIN, 'add' => self::GROUP_ADMIN,
'delete' => self::GROUP_ADMIN, 'delete' => self::GROUP_ADMIN,
@ -690,13 +691,13 @@ class course extends common
self::$courseUsers[] = [ self::$courseUsers[] = [
//$userId, //$userId,
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']), $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
isset($pages[$userValue['lastPageView']]['title']) array_key_exists('lastPageView', $userValue) && isset($pages[$userValue['lastPageView']]['title'])
? $pages[$userValue['lastPageView']]['title'] ? $pages[$userValue['lastPageView']]['title']
: '', : '',
$userValue['datePageView'] array_key_exists('lastPageView', $userValue)
? helper::dateUTF8('%d/%m/%Y', $userValue['datePageView']) ? helper::dateUTF8('%d/%m/%Y', $userValue['datePageView'])
: '', : '',
$userValue['datePageView'] array_key_exists('datePageView', $userValue)
? helper::dateUTF8('%H:%M', $userValue['datePageView']) ? helper::dateUTF8('%H:%M', $userValue['datePageView'])
: '', : '',
$this->getData(['user', $userId, 'tags']), $this->getData(['user', $userId, 'tags']),
@ -903,6 +904,7 @@ class course extends common
/** /**
* Désinscription de tous les utilisateurs * Désinscription de tous les utilisateurs
* Les désinscriptions ne suppriment pas les historiques
*/ */
public function usersDelete() public function usersDelete()
{ {
@ -1038,6 +1040,47 @@ class course extends common
]); ]);
} }
/**
* Désincription de tous les utilisateurs hors les éditeurs
* Effacement des historiques
*/
public function reset()
{
// Contenu sélectionné
$courseId = $this->getUrl(2);
// Accès limité aux admins, à l'auteur ou éditeurs inscrits
if (
$this->permissionControl(__FUNCTION__, $courseId) === false
) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
}
// Active l'accueil
$_SESSION['ZWII_SITE_CONTENT'] = 'home';
// Efface les inscriptions
$success = $this->setData(['enrolment', $courseId, []]);
// Efface les rapports
if (file_exists(self::DATA_DIR . $courseId . '/report.csv')) {
unlink(self::DATA_DIR . $courseId . '/report.csv');
}
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'course',
'notification' => helper::translate('Espace réinitialisé'),
'state' => true
]);
}
/* /*
* Traitement du changement de langue * Traitement du changement de langue
*/ */
@ -1377,7 +1420,7 @@ class course extends common
} }
// Traitement de l'historique // Traitement de l'historique
$h = $this->getReport($courseId, $userId); $h = $this->getReport($courseId);
$h = $h[$userId]; $h = $h[$userId];
// Inversion des clés et des valeurs // Inversion des clés et des valeurs
@ -1541,6 +1584,7 @@ class course extends common
/** /**
* Désinscription d'un participant * Désinscription d'un participant
* La désinscription ne supprime pas les historiques,
*/ */
public function unsuscribe() public function unsuscribe()
{ {
@ -1890,34 +1934,38 @@ class course extends common
*/ */
private function getReport($courseId, $userId = null) private function getReport($courseId, $userId = null)
{ {
// Remplacez 'chemin/vers/votre/fichier.csv' par le chemin réel de votre fichier CSV
$file = fopen(self::DATA_DIR . $courseId . '/report.csv', "r");
$data = array(); $data = [];
if (file_exists(self::DATA_DIR . $courseId . '/report.csv')) {
// Remplacez 'chemin/vers/votre/fichier.csv' par le chemin réel de votre fichier CSV
$file = fopen(self::DATA_DIR . $courseId . '/report.csv', "r");
// Lire ligne par ligne $data = array();
while (($line = fgetcsv($file, 1000, ";")) !== false) {
$name = $line[0]; // Lire ligne par ligne
$pageId = $line[1]; while (($line = fgetcsv($file, 1000, ";")) !== false) {
$timestamp = $line[2]; $name = $line[0];
// Filtre userId $pageId = $line[1];
// if (!is_null($userId) && $name === $userId) { $timestamp = $line[2];
// Filtre userId
// if (!is_null($userId) && $name === $userId) {
// Initialiser le tableau si nécessaire // Initialiser le tableau si nécessaire
if (!isset($data[$name][$pageId])) { if (!isset($data[$name][$pageId])) {
$data[$name][$pageId] = array(); $data[$name][$pageId] = array();
} }
// Ajouter le timestamp // Ajouter le timestamp
$data[$name][$pageId][] = $timestamp; $data[$name][$pageId][] = $timestamp;
// } //}
} }
// Fermer le fichier // Fermer le fichier
fclose($file); fclose($file);
// Trier les timestamps // Trier les timestamps
foreach ($data as &$userData) { foreach ($data as &$userData) {
foreach ($userData as &$pageData) { foreach ($userData as &$pageData) {
sort($pageData); sort($pageData);
}
} }
} }

View File

@ -20,4 +20,15 @@ $(".courseDelete").on("click", function () {
return core.confirm(message, function () { return core.confirm(message, function () {
$(location).attr("href", _this.attr("href")); $(location).attr("href", _this.attr("href"));
}); });
});
/**
* Confirmation de suppression
*/
$(".courseReset").on("click", function () {
var _this = $(this);
var message = "<?php echo helper::translate('Réinitialiser cet espace ?'); ?>";
return core.confirm(message, function () {
$(location).attr("href", _this.attr("href"));
});
}); });

View File

@ -18,6 +18,16 @@
]); ?> ]); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if ($this->getUser('permission', 'course', 'reset') === true): ?>
<div class="col2 ">
<?php echo template::button('courseManageReset' . $this->getUrl(2), [
'class' => 'courseReset buttonRed',
'href' => helper::baseUrl() . 'course/reset/' . $this->getUrl(2),
'value' => 'Réinitaliser',
'ico' => 'cancel'
]); ?>
</div>
<?php endif; ?>
<?php if ($this->getUser('permission', 'course', 'backup') === true): ?> <?php if ($this->getUser('permission', 'course', 'backup') === true): ?>
<div class="col2"> <div class="col2">
<?php echo template::button('courseManageDownload' . $this->getUrl(2), [ <?php echo template::button('courseManageDownload' . $this->getUrl(2), [

View File

@ -252,7 +252,8 @@ class init extends common
'usersDelete' => false, 'usersDelete' => false,
'edit' => false, 'edit' => false,
'backup' => false, 'backup' => false,
'restore' => false 'restore' => false,
'reset' => false,
], ],
'folder' => [ 'folder' => [
'create' => false, 'create' => false,
@ -348,7 +349,8 @@ class init extends common
'usersDelete' => false, 'usersDelete' => false,
'edit' => false, 'edit' => false,
'backup' => false, 'backup' => false,
'restore' => false 'restore' => false,
'reset' => false,
], ],
'folder' => [ 'folder' => [
'create' => false, 'create' => false,
@ -449,7 +451,8 @@ class init extends common
'usersDelete' => false, 'usersDelete' => false,
'edit' => false, 'edit' => false,
'backup' => false, 'backup' => false,
'restore' => false 'restore' => false,
'reset' => false,
], ],
'folder' => [ 'folder' => [
'create' => false, 'create' => false,
@ -546,7 +549,8 @@ class init extends common
'usersDelete' => true, 'usersDelete' => true,
'edit' => true, 'edit' => true,
'backup' => true, 'backup' => true,
'restore' => true 'restore' => true,
'reset' => true,
], ],
'folder' => [ 'folder' => [
'create' => true, 'create' => true,

View File

@ -724,6 +724,7 @@ class user extends common
'edit' => $this->getInput('profilEditCourseEdit', helper::FILTER_BOOLEAN), 'edit' => $this->getInput('profilEditCourseEdit', helper::FILTER_BOOLEAN),
'backup' => $this->getInput('profilEditCourseBackup', helper::FILTER_BOOLEAN), 'backup' => $this->getInput('profilEditCourseBackup', helper::FILTER_BOOLEAN),
'restore' => $this->getInput('profilEditCourseRestore', helper::FILTER_BOOLEAN), 'restore' => $this->getInput('profilEditCourseRestore', helper::FILTER_BOOLEAN),
'reset' => $this->getInput('profilEditCourseReset', helper::FILTER_BOOLEAN),
] ]
]; ];
@ -905,7 +906,8 @@ class user extends common
|| $this->getInput('profilAddCourseUsersDelete', helper::FILTER_BOOLEAN) || $this->getInput('profilAddCourseUsersDelete', helper::FILTER_BOOLEAN)
|| $this->getInput('profilAddCourseEdit', helper::FILTER_BOOLEAN) || $this->getInput('profilAddCourseEdit', helper::FILTER_BOOLEAN)
|| $this->getInput('profilAddCourseBackup', helper::FILTER_BOOLEAN) || $this->getInput('profilAddCourseBackup', helper::FILTER_BOOLEAN)
|| $this->getInput('profilAddCourseRestore', helper::FILTER_BOOLEAN), || $this->getInput('profilAddCourseRestore', helper::FILTER_BOOLEAN)
|| $this->getInput('profilAddCourseReset', helper::FILTER_BOOLEAN),
// La suite // La suite
'users' => $this->getInput('profilAddCourseUsers', helper::FILTER_BOOLEAN), 'users' => $this->getInput('profilAddCourseUsers', helper::FILTER_BOOLEAN),
'userHistory' => $this->getInput('profilAddCourseUserHistory', helper::FILTER_BOOLEAN), 'userHistory' => $this->getInput('profilAddCourseUserHistory', helper::FILTER_BOOLEAN),
@ -917,6 +919,7 @@ class user extends common
'edit' => $this->getInput('profilAddCourseEdit', helper::FILTER_BOOLEAN), 'edit' => $this->getInput('profilAddCourseEdit', helper::FILTER_BOOLEAN),
'backup' => $this->getInput('profilAddCourseBackup', helper::FILTER_BOOLEAN), 'backup' => $this->getInput('profilAddCourseBackup', helper::FILTER_BOOLEAN),
'restore' => $this->getInput('profilAddCourseRestore', helper::FILTER_BOOLEAN), 'restore' => $this->getInput('profilAddCourseRestore', helper::FILTER_BOOLEAN),
'reset' => $this->getInput('profilAddCourseReset', helper::FILTER_BOOLEAN),
] ]
]; ];

View File

@ -205,6 +205,11 @@
<div class="col3"> <div class="col3">
<?php echo template::checkbox('profilAddCourseUsersDelete', true, 'Désinscrire en masse'); ?> <?php echo template::checkbox('profilAddCourseUsersDelete', true, 'Désinscrire en masse'); ?>
</div> </div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseReset', true, 'Réinitialiser un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'reset']),
]); ?>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -307,6 +307,11 @@
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersDelete']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersDelete']),
]); ?> ]); ?>
</div> </div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseReset', true, 'Réinitialiser un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'reset']),
]); ?>
</div>
</div> </div>
</div> </div>
</div> </div>