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 $courses = [];
|
||||||
|
|
||||||
public static $swapMessage = '';
|
public static $swapMessage = [];
|
||||||
|
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
@ -264,7 +264,7 @@ class course extends common
|
|||||||
{
|
{
|
||||||
// Cours sélectionnée
|
// Cours sélectionnée
|
||||||
$courseId = $this->getUrl(2);
|
$courseId = $this->getUrl(2);
|
||||||
|
$userId = $this->getUser('id');
|
||||||
// Le cours est disponible ?
|
// Le cours est disponible ?
|
||||||
if ($courseId === 'home') {
|
if ($courseId === 'home') {
|
||||||
$_SESSION['ZWII_SITE_CONTENT'] = $courseId;
|
$_SESSION['ZWII_SITE_CONTENT'] = $courseId;
|
||||||
@ -291,6 +291,12 @@ class course extends common
|
|||||||
if (
|
if (
|
||||||
$this->isPost()
|
$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 (
|
if (
|
||||||
// Contrôle la validité du cours demandé
|
// Contrôle la validité du cours demandé
|
||||||
(is_dir(self::DATA_DIR . $courseId) &&
|
(is_dir(self::DATA_DIR . $courseId) &&
|
||||||
@ -306,15 +312,28 @@ class course extends common
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Génération du message d'inscription
|
// Génération du message d'inscription
|
||||||
$userId = $this->getUser('id');
|
|
||||||
// L'étudiant est-il inscrit
|
// 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) {
|
if ($this->courseUserEnrolment($courseId, $userId) === false) {
|
||||||
// Inscription libre
|
switch ($this->getData(['course', $courseId, 'enrolment'])) {
|
||||||
if ($this->getData(['course', $courseId, 'enrolment']) <= self::COURSE_ENROLMENT_SELF) {
|
case self::COURSE_ENROLMENT_GUEST:
|
||||||
self::$swapMessage = helper::translate('S\'inscrire');
|
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
|
// Valeurs en sortie
|
||||||
|
@ -1,23 +1,35 @@
|
|||||||
<?php echo template::formOpen('courseChangeForm'); ?>
|
<?php echo template::formOpen('courseSwapForm'); ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<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' ])] . "</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>";?>
|
<?php echo "<p> Inscription : " . $module::$courseEnrolment[$this->getData(['course', $this->getUrl(2), 'enrolment'])] . "</p>"; ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</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="row">
|
||||||
<div class="col2">
|
<div class="col2">
|
||||||
<?php echo template::button('courseChangeBack', [
|
<?php echo template::button('courseSwapBack', [
|
||||||
'href' => helper::baseUrl(),
|
'href' => helper::baseUrl(),
|
||||||
'value' => template::ico('left')
|
'value' => template::ico('left')
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col3 offset7">
|
<div class="col3 offset7">
|
||||||
<?php echo template::submit('courseChangeSubmit', [
|
<?php echo template::submit('courseSwapSubmit', [
|
||||||
'value' => $module::$swapMessage,
|
'value' => $module::$swapMessage['submitLabel'],
|
||||||
'disabled' => !$this->courseIsAvailable($this->getUrl(2)),
|
'disabled' => !$this->courseIsAvailable($this->getUrl(2)),
|
||||||
'ico' => ''
|
'ico' => ''
|
||||||
]); ?>
|
]); ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user