Enrolment OKAY

This commit is contained in:
Fred Tempez 2023-10-06 21:24:50 +02:00
parent 6b6ce19064
commit b5eff6f9b8
2 changed files with 33 additions and 20 deletions

View File

@ -368,7 +368,7 @@ class course extends common
$userId, $userId,
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']), $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
$userValue['lastPageId'], $userValue['lastPageId'],
helper::dateUTF8('%d %B %Y - %H:%M',$userValue['lastDateVisited']), helper::dateUTF8('%d %B %Y - %H:%M', $userValue['lastDateVisited']),
template::button('courseDelete' . $userId, [ template::button('courseDelete' . $userId, [
'class' => 'categoryDelete buttonRed', 'class' => 'categoryDelete buttonRed',
'href' => helper::baseUrl() . 'course/categoryDelete/' . $userId, 'href' => helper::baseUrl() . 'course/categoryDelete/' . $userId,
@ -456,7 +456,6 @@ class course extends common
break; break;
// Auto avec ou sans clé // Auto avec ou sans clé
case self::COURSE_ENROLMENT_SELF: case self::COURSE_ENROLMENT_SELF:
$_SESSION['ZWII_SITE_CONTENT'] = $courseId;
$redirect .= 'course/enrol/' . $courseId; $redirect .= 'course/enrol/' . $courseId;
$message = helper::translate('Veuillez vous inscrire'); $message = helper::translate('Veuillez vous inscrire');
break; break;
@ -508,17 +507,18 @@ class course extends common
switch ($this->getData(['course', $courseId, 'enrolment'])) { switch ($this->getData(['course', $courseId, 'enrolment'])) {
case self::COURSE_ENROLMENT_SELF: case self::COURSE_ENROLMENT_SELF:
$this->courseEnrolUser($courseId, $userId); $this->courseEnrolUser($courseId, $userId);
// Stocker la sélection
$_SESSION['ZWII_SITE_CONTENT'] = $courseId;
break; break;
case self::COURSE_ENROLMENT_SELF_KEY: case self::COURSE_ENROLMENT_SELF_KEY:
if ($this->getInput('courseSwapEnrolmentKey') === $this->getData(['course', $courseId, 'enrolmentKey'])) { if ($this->getInput('courseSwapEnrolmentKey') === $this->getData(['course', $courseId, 'enrolmentKey'])) {
$this->courseEnrolUser($courseId, $userId); $this->courseEnrolUser($courseId, $userId);
// Stocker la sélection
$_SESSION['ZWII_SITE_CONTENT'] = $courseId;
} }
break; break;
} }
// Stocker la sélection
$_SESSION['ZWII_SITE_CONTENT'] = $courseId;
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() 'redirect' => helper::baseUrl()
@ -526,22 +526,26 @@ class course extends common
} }
} }
// L'étudiant est-il inscrit // L'étudiant est-il inscrit
self::$swapMessage['submitLabel'] = 'Se connecter'; self::$swapMessage['submitLabel'] = helper::translate('M\'inscrire');
self::$swapMessage['enrolmentMessage'] = ''; self::$swapMessage['enrolmentMessage'] = '';
self::$swapMessage['enrolmentKey'] = ''; self::$swapMessage['enrolmentKey'] = '';
if ($this->courseIsUserEnroled($courseId) === false) { if ($this->courseIsUserEnroled($courseId) === false) {
switch ($this->getData(['course', $courseId, 'enrolment'])) { switch ($this->getData(['course', $courseId, 'enrolment'])) {
case self::COURSE_ENROLMENT_GUEST:
case self::COURSE_ENROLMENT_SELF: case self::COURSE_ENROLMENT_SELF:
self::$swapMessage['submitLabel'] = helper::translate('M\'inscrire'); if ($userId == '') {
self::$swapMessage['enrolmentMessage'] = helper::translate('Connectez-vous pour accéder à ce cours.');
self::$swapMessage['submitLabel'] = helper::translate('Connexion');
}
break; break;
case self::COURSE_ENROLMENT_SELF_KEY: case self::COURSE_ENROLMENT_SELF_KEY:
if ($userId) { if ($userId == '') {
self::$swapMessage['enrolmentMessage'] = helper::translate('Connectez-vous pour accéder à ce cours.');
self::$swapMessage['submitLabel'] = helper::translate('Connexion');
} else {
self::$swapMessage['submitLabel'] = helper::translate('Connexion');
self::$swapMessage['enrolmentKey'] = template::text('courseSwapEnrolmentKey', [ self::$swapMessage['enrolmentKey'] = template::text('courseSwapEnrolmentKey', [
'label' => helper::translate('Clé d\'inscription'), 'label' => helper::translate('Clé d\'inscription'),
]); ]);
} else {
self::$swapMessage['enrolmentMessage'] = helper::translate('Connectez-vous pour accéder à ce cours.');
} }
break; break;
case self::COURSE_ENROLMENT_MANUAL: case self::COURSE_ENROLMENT_MANUAL:

View File

@ -3,7 +3,7 @@
<div class="col12"> <div class="col12">
<?php echo "<h3>Auteur : " . $this->getData(['course', $this->getUrl(2), 'author']) . "</h3>"; ?> <?php echo "<h3>Auteur : " . $this->getData(['course', $this->getUrl(2), 'author']) . "</h3>"; ?>
<?php echo "<p>Description : " . $this->getData(['course', $this->getUrl(2), 'description']) . "</p>"; ?> <?php echo "<p>Description : " . $this->getData(['course', $this->getUrl(2), 'description']) . "</p>"; ?>
<?php echo "<p>Disponibilité : " . $module::$courseAccess[$this->getData(['course', $this->getUrl(2), 'access'])] ; ?> <?php echo "<p>Disponibilité : " . $module::$courseAccess[$this->getData(['course', $this->getUrl(2), 'access'])]; ?>
<?php if ($this->getData(['course', $this->getUrl(2), 'access']) === $module::COURSE_ACCESS_DATE): ?> <?php if ($this->getData(['course', $this->getUrl(2), 'access']) === $module::COURSE_ACCESS_DATE): ?>
<?php $from = helper::dateUTF8('%d %B %Y', $this->getData(['course', $this->getUrl(2), 'openingDate']), self::$i18nUI) . helper::translate(' à ') . helper::dateUTF8('%H:%M', $this->getData(['course', $this->getUrl(2), 'openingDate']), self::$i18nUI); ?> <?php $from = helper::dateUTF8('%d %B %Y', $this->getData(['course', $this->getUrl(2), 'openingDate']), self::$i18nUI) . helper::translate(' à ') . helper::dateUTF8('%H:%M', $this->getData(['course', $this->getUrl(2), 'openingDate']), self::$i18nUI); ?>
<?php $to = helper::dateUTF8('%d %B %Y', $this->getData(['course', $this->getUrl(2), 'closingDate']), self::$i18nUI) . helper::translate(' à ') . helper::dateUTF8('%H:%M', $this->getData(['course', $this->getUrl(2), 'closingDate']), self::$i18nUI); ?> <?php $to = helper::dateUTF8('%d %B %Y', $this->getData(['course', $this->getUrl(2), 'closingDate']), self::$i18nUI) . helper::translate(' à ') . helper::dateUTF8('%H:%M', $this->getData(['course', $this->getUrl(2), 'closingDate']), self::$i18nUI); ?>
@ -32,13 +32,22 @@
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<div class="col3 offset7"> <?php if ($module::$swapMessage['submitLabel'] === 'Connexion'): ?>
<?php echo template::submit('courseSwapSubmit', [ <div class="col2 offset8">
'value' => $module::$swapMessage['submitLabel'], <?php echo template::button('courseConnect', [
'disabled' => !$module->courseIsAvailable($this->getUrl(2)), 'href' => helper::baseUrl(true) . 'user/login',
'ico' => '' 'value' => template::ico('login'),
]); ?> 'help' => 'Connexion',
</div> ]); ?>
</div>
<?php else: ?>
<div class="col3 offset6">
<?php echo template::submit('courseSwapSubmit', [
'value' => $module::$swapMessage['submitLabel'],
'disabled' => !$module->courseIsAvailable($this->getUrl(2)),
'ico' => ''
]); ?>
</div>
<?php endif; ?>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>