forked from ZwiiCMS-Team/ZwiiCampus
Empty storage on submit
This commit is contained in:
parent
4d535369cc
commit
4ed8198321
@ -488,8 +488,10 @@ class course extends common
|
||||
foreach ($users as $userId => $userValue) {
|
||||
$history = $userValue['history'];
|
||||
|
||||
$maxTime = max($history);
|
||||
$pageId = array_search($maxTime, $history);
|
||||
if (!empty($history)) {
|
||||
$maxTime = max($history);
|
||||
$pageId = array_search($maxTime, $history);
|
||||
}
|
||||
|
||||
// Compte les rôles
|
||||
$profils[$this->getData(['user', $userId, 'group']) . $this->getData(['user', $userId, 'profil'])]++;
|
||||
@ -527,11 +529,12 @@ class course extends common
|
||||
self::$courseUsers[] = [
|
||||
$userId,
|
||||
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
|
||||
$pages[$pageId],
|
||||
helper::dateUTF8('%d %B %Y - %H:%M', $maxTime),
|
||||
!empty($history) ? $pages[$pageId] : '-',
|
||||
!empty($history) ? helper::dateUTF8('%d %B %Y - %H:%M', $maxTime) : '-',
|
||||
template::button('userHistory' . $userId, [
|
||||
'href' => helper::baseUrl() . 'course/userHistory/' . $courseId . '/' . $userId,
|
||||
'value' => round(($viewPages * 100) / $sumPages, 1) . ' %'
|
||||
'value' => !empty($history) ? round(($viewPages * 100) / $sumPages, 1) . ' %' : '0%',
|
||||
'disable' => empty($history)
|
||||
]),
|
||||
template::button('userDelete' . $userId, [
|
||||
'class' => 'userDelete buttonRed',
|
||||
@ -571,7 +574,8 @@ class course extends common
|
||||
) {
|
||||
foreach ($_POST as $keyPost => $valuePost) {
|
||||
// Exclure les variables post qui ne sont pas des userId et ne traiter que les non inscrits
|
||||
if ($this->getData(['user', $keyPost]) !== null
|
||||
if (
|
||||
$this->getData(['user', $keyPost]) !== null
|
||||
&& $this->getData(['enrolment', $courseId, $keyPost]) === null
|
||||
) {
|
||||
$this->setData(['enrolment', $courseId, $keyPost, 'history', array()]);
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
$(document).ready((function () {
|
||||
|
||||
|
||||
$("#courseFilterGroup, #courseFilterFirstName, #courseFilterLastName").change(function () {
|
||||
saveCheckboxState();
|
||||
$("#courseUsersAddForm").submit();
|
||||
@ -45,6 +44,10 @@ $(document).ready((function () {
|
||||
restoreCheckboxState();
|
||||
});
|
||||
|
||||
// Empty local storage after submit
|
||||
$("#courseUsersAddSubmit").on("click", function () {
|
||||
localStorage.setItem('checkboxState', JSON.stringify({}));
|
||||
});
|
||||
|
||||
// Restore checkbox state on page load
|
||||
restoreCheckboxState();
|
||||
@ -53,7 +56,6 @@ $(document).ready((function () {
|
||||
|
||||
// Récupérer d'abord les données existantes dans le localStorage
|
||||
var existingData = JSON.parse(localStorage.getItem('checkboxState')) || {};
|
||||
console.log(existingData);
|
||||
|
||||
// Ajouter ou mettre à jour les données actuelles
|
||||
$('.checkboxSelect').each(function () {
|
||||
|
Loading…
Reference in New Issue
Block a user