forked from ZwiiCMS-Team/ZwiiCampus
Enrolment key WIP
This commit is contained in:
parent
033528c50b
commit
71e4bd5612
@ -41,7 +41,7 @@ class course extends common
|
||||
|
||||
public static $courses = [];
|
||||
|
||||
public static $swapMessage = '';
|
||||
public static $swapMessage = [];
|
||||
|
||||
|
||||
public function index()
|
||||
@ -264,7 +264,7 @@ class course extends common
|
||||
{
|
||||
// Cours sélectionnée
|
||||
$courseId = $this->getUrl(2);
|
||||
|
||||
$userId = $this->getUser('id');
|
||||
// Le cours est disponible ?
|
||||
if ($courseId === 'home') {
|
||||
$_SESSION['ZWII_SITE_CONTENT'] = $courseId;
|
||||
@ -291,6 +291,12 @@ class course extends common
|
||||
if (
|
||||
$this->isPost()
|
||||
) {
|
||||
$enrolKey = $this->getInput('courseSwapEnrolmentKey');
|
||||
if ($enrolKey) {
|
||||
$this->setData(['enrolment', $courseId, $userId]);
|
||||
}
|
||||
|
||||
// Vérifie la clé et inscrit l'utilisateur dans la base
|
||||
if (
|
||||
// Contrôle la validité du cours demandé
|
||||
(is_dir(self::DATA_DIR . $courseId) &&
|
||||
@ -306,15 +312,28 @@ class course extends common
|
||||
} else {
|
||||
|
||||
// Génération du message d'inscription
|
||||
$userId = $this->getUser('id');
|
||||
// L'étudiant est-il inscrit
|
||||
self::$swapMessage = 'Se connecter';
|
||||
self::$swapMessage['submitLabel'] = 'Se connecter';
|
||||
self::$swapMessage['enrolmentMessage'] = '';
|
||||
self::$swapMessage['enrolmentKey'] = '';
|
||||
if ($this->courseUserEnrolment($courseId, $userId) === false) {
|
||||
// Inscription libre
|
||||
if ($this->getData(['course', $courseId, 'enrolment']) <= self::COURSE_ENROLMENT_SELF) {
|
||||
self::$swapMessage = helper::translate('S\'inscrire');
|
||||
switch ($this->getData(['course', $courseId, 'enrolment'])) {
|
||||
case self::COURSE_ENROLMENT_GUEST:
|
||||
case self::COURSE_ENROLMENT_SELF:
|
||||
self::$swapMessage['submitLabel'] = helper::translate('M\'inscrire');
|
||||
break;
|
||||
case self::COURSE_ENROLMENT_SELF_KEY:
|
||||
if ($userId) {
|
||||
self::$swapMessage['enrolmentKey'] = template::text('courseSwapEnrolmentKey', [
|
||||
'label' => helper::translate('Clé d\'inscription'),
|
||||
]);
|
||||
}
|
||||
self::$swapMessage['enrolmentMessage'] = helper::translate('Connectez-vous pour accèder à ce cours.');
|
||||
break;
|
||||
case self::COURSE_ENROLMENT_MANUAL:
|
||||
self::$swapMessage['enrolmentMessage'] = helper::translate('L\'enseignant inscrit les étudiants dans le cours, vous ne pouvez pas vous inscrire vous-même.');
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Valeurs en sortie
|
||||
|
@ -1,23 +1,35 @@
|
||||
<?php echo template::formOpen('courseChangeForm'); ?>
|
||||
<?php echo template::formOpen('courseSwapForm'); ?>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<?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> Disponibilité : " . $module::$courseAccess[$this->getData(['course', $this->getUrl(2), 'access'])] . "</p>"; ?>
|
||||
<?php echo "<p> Inscription : " . $module::$courseEnrolment[$this->getData(['course', $this->getUrl(2), 'enrolment'])] . "</p>"; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<?php if ($module::$swapMessage['enrolmentKey']) {
|
||||
echo $module::$swapMessage['enrolmentKey'];
|
||||
}
|
||||
?>
|
||||
<?php if ($module::$swapMessage['enrolmentMessage']) {
|
||||
echo $module::$swapMessage['enrolmentMessage'];
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col2">
|
||||
<?php echo template::button('courseChangeBack', [
|
||||
<?php echo template::button('courseSwapBack', [
|
||||
'href' => helper::baseUrl(),
|
||||
'value' => template::ico('left')
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col3 offset7">
|
||||
<?php echo template::submit('courseChangeSubmit', [
|
||||
'value' => $module::$swapMessage,
|
||||
<?php echo template::submit('courseSwapSubmit', [
|
||||
'value' => $module::$swapMessage['submitLabel'],
|
||||
'disabled' => !$this->courseIsAvailable($this->getUrl(2)),
|
||||
'ico' => ''
|
||||
]); ?>
|
||||
|
Loading…
Reference in New Issue
Block a user