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

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

View File

@ -32,13 +32,22 @@
'value' => template::ico('left')
]); ?>
</div>
<div class="col3 offset7">
<?php if ($module::$swapMessage['submitLabel'] === 'Connexion'): ?>
<div class="col2 offset8">
<?php echo template::button('courseConnect', [
'href' => helper::baseUrl(true) . 'user/login',
'value' => template::ico('login'),
'help' => 'Connexion',
]); ?>
</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>
<?php echo template::formClose(); ?>