Catégories de cours

This commit is contained in:
Fred Tempez 2023-09-29 04:28:17 +02:00
parent 99e7cb9a99
commit e3286aee8e
5 changed files with 59 additions and 33 deletions

View File

@ -210,6 +210,7 @@ class common
'language' => '',
'profil' => '',
'enrolment' => '',
'categorie' => '',
];
private $configFiles = [
@ -224,6 +225,7 @@ class common
'language' => '',
'profil' => '',
'enrolment' => '',
'categorie' => '',
];
private $contentFiles = [

View File

@ -40,6 +40,8 @@ class course extends common
public static $courseTeachers = [];
public static $courseCategories = [];
public static $courses = [];
public static $swapMessage = [];
@ -142,38 +144,7 @@ class course extends common
]);
}
public function delete()
{
if (
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true ||
// Le cours n'existe pas
$this->getData(['course', $this->getUrl(2)]) === null
// Groupe insuffisant
and ($this->getUrl('group') < self::GROUP_EDITOR)
) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
// Suppression
} else {
$this->deleteData(['course', $this->getUrl(2)]);
$this->deleteData(['enrolment', $this->getUrl(2)]);
if (is_dir(self::DATA_DIR . $this->getUrl(2))) {
$this->deleteDir(self::DATA_DIR . $this->getUrl(2));
}
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'course',
'notification' => helper::translate('Cours supprimé'),
'state' => true
]);
}
}
/**
* Edite un cours
*/
@ -218,6 +189,7 @@ class course extends common
self::$courseTeachers[$teacherId] = $teacherInfo["firstname"] . ' ' . $teacherInfo["lastname"];
}
}
self::$courseCategories = $this->getData(['categorie']);
// Valeurs en sortie
$this->addOutput([
@ -226,6 +198,39 @@ class course extends common
]);
}
public function delete()
{
if (
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true ||
// Le cours n'existe pas
$this->getData(['course', $this->getUrl(2)]) === null
// Groupe insuffisant
and ($this->getUrl('group') < self::GROUP_EDITOR)
) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
// Suppression
} else {
$this->deleteData(['course', $this->getUrl(2)]);
$this->deleteData(['enrolment', $this->getUrl(2)]);
if (is_dir(self::DATA_DIR . $this->getUrl(2))) {
$this->deleteDir(self::DATA_DIR . $this->getUrl(2));
}
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'course',
'notification' => helper::translate('Cours supprimé'),
'state' => true
]);
}
}
/*
* Affiche un écran de connexion à un cours
*/

View File

@ -36,6 +36,14 @@
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::select('courseEditCategories', $module::$courseCategories, [
'label' => 'Catégorie',
'value' => $this->getdata(['course', $this->getUrl(2), 'category'])
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::textarea('courseAddDescription', [

View File

@ -39,6 +39,14 @@
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::select('courseEditCategories', $module::$courseCategories, [
'label' => 'Catégorie',
'value' => $this->getdata(['course', $this->getUrl(2), 'category'])
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::textarea('courseEditDescription', [

View File

@ -668,7 +668,10 @@ class init extends common
]
],
'course' => [],
'enrolment' => []
'enrolment' => [],
'categorie' => [
'Générale'
]
];
public static $siteTemplate = [