Création d'un cours

This commit is contained in:
Fred Tempez 2023-09-08 22:09:25 +02:00
parent 2ba4437ecf
commit 65b39f116f
8 changed files with 207 additions and 14 deletions

View File

@ -197,6 +197,7 @@ class common
'blacklist' => '', 'blacklist' => '',
'config' => '', 'config' => '',
'core' => '', 'core' => '',
'course' => '',
'font' => '', 'font' => '',
'module' => '', 'module' => '',
'page' => '', 'page' => '',
@ -210,6 +211,7 @@ class common
'admin' => '', 'admin' => '',
'blacklist' => '', 'blacklist' => '',
'config' => '', 'config' => '',
'course' => '',
'core' => '', 'core' => '',
'font' => '', 'font' => '',
'theme' => '', 'theme' => '',

View File

@ -13,17 +13,81 @@
* @link http://zwiicms.fr/ * @link http://zwiicms.fr/
*/ */
class dashboard extends common class course extends common
{ {
public static $actions = [ public static $actions = [
'index' => self::GROUP_ADMIN, 'index' => self::GROUP_TEACHER,
'add' => self::GROUP_ADMIN,
]; ];
public static $courseAccess = [
0 => 'Ouvert',
1 => 'Période d\'ouverture',
2 => 'Fermé',
];
public static $courseEnrolment = [
0 => 'Anonyme',
1 => 'Auto-inscrition',
2 => 'Auto-inscription avec clé',
3 => 'Manuelle'
];
public static $courseTeachers = [];
public function index() public function index()
{ {
// Valeurs en sortie
$this->addOutput([
'title' => helper::translate('Cours'),
'view' => 'index'
]);
}
public function add()
{
// Soumission du formulaire
if (
$this->getUser('permission', __CLASS__, __FUNCTION__) === true &&
$this->isPost()
) {
$this->setData([
'course',
uniqid(),
[
'title' => $this->getInput('courseAddTitle',helper::FILTER_STRING_SHORT, true),
'mentor' => $this->getInput('courseAddMentor'),
'description' => $this->getInput('courseAddDescription', helper::FILTER_STRING_SHORT, true),
'access' => $this->getInput('courseAddAccess'),
'openingDate' => $this->getInput('courseOpeningDate', helper::FILTER_DATETIME),
'closingDate' => $this->getInput('courseClosingDate', helper::FILTER_DATETIME),
'enrolment' => $this->getInput('courseAddEnrolment'),
'enrolmentKey' => $this->getInput('courseAddEnrolmentKey'),
]
]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'course',
'notification' => helper::translate('Cours créé'),
'state' => true
]);
}
$teachers = $this->getData(['user']);
foreach ($teachers as $teacherId => $teacherInfo) {
if ( $teacherInfo["group"] >= 2 ) {
self::$courseTeachers[$teacherId] = $teacherInfo["firstname"] . ' ' . $teacherInfo["lastname"];
}
}
// Valeurs en sortie
$this->addOutput([
'title' => helper::translate('Ajouter un cours'),
'view' => 'add'
]);
} }
} }

View File

@ -0,0 +1,18 @@
/**
* This file is part of Zwii.
*
* For full copyright and license information, please see the LICENSE
* file that was distributed with this source code.
*
* @author Rémi Jean <remi.jean@outlook.com>
* @copyright Copyright (C) 2008-2018, Rémi Jean
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2023, Frédéric Tempez
* @license CC Attribution-NonCommercial-NoDerivatives 4.0 International
* @link http://zwiicms.fr/
*/
/** NE PAS EFFACER
* admin.css
*/

View File

@ -0,0 +1,72 @@
<?php echo template::formOpen('courseAddForm'); ?>
<div class="row">
<div class="col1">
<?php echo template::button('courseAddBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'course',
'value' => template::ico('left')
]); ?>
</div>
<div class="col2 offset9">
<?php echo template::submit('courseAddSubmit'); ?>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo helper::translate('Paramètres'); ?>
</h4>
<div class="row">
<div class="col8">
<?php echo template::text('courseAddTitle', [
'label' => 'Titre'
]); ?>
</div>
<div class="col4">
<?php echo template::select('courseAddAccess', $module::$courseTeachers, [
'label' => 'Mentor'
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::textarea('courseAddDescription', [
'label' => 'Description'
]); ?>
</div>
</div>
<div class="row">
<div class="col4">
<?php echo template::select('courseAddAccess', $module::$courseAccess, [
'label' => 'Accès'
]); ?>
</div>
<div class="col4">
<?php echo template::date('courseOpeningDate', [
'type' => 'date',
'label' => 'Ouverture',
]); ?>
</div>
<div class="col4">
<?php echo template::date('courseClosingDate', [
'type' => 'date',
'label' => 'Fermeture',
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::select('courseAddEnrolment', $module::$courseEnrolment, [
'label' => 'Inscription'
]); ?>
</div>
<div class="col6">
<?php echo template::text('courseAddEnrolmentKey', [
'label' => 'Clé'
]); ?>
</div>
</div>
</div>
</div>
<?php echo template::formClose(); ?>

View File

@ -0,0 +1,18 @@
/**
* This file is part of Zwii.
*
* For full copyright and license information, please see the LICENSE
* file that was distributed with this source code.
*
* @author Rémi Jean <remi.jean@outlook.com>
* @copyright Copyright (C) 2008-2018, Rémi Jean
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2023, Frédéric Tempez
* @license CC Attribution-NonCommercial-NoDerivatives 4.0 International
* @link http://zwiicms.fr/
*/
/** NE PAS EFFACER
* admin.css
*/

View File

@ -0,0 +1,16 @@
<div class="row">
<div class="col1">
<?php echo template::button('courseModulesBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl() . $this->getUrl(2),
'value' => template::ico('left')
]); ?>
</div>
<div class="col1 offset10">
<?php echo template::button('courseModulesAdd', [
'class' => 'buttonGreen',
'href' => helper::baseUrl() . 'course/add',
'value' => template::ico('plus')
]); ?>
</div>
</div>

View File

@ -666,7 +666,8 @@ class init extends common
'permanent' => true, 'permanent' => true,
'comment' => 'Contrôle total', 'comment' => 'Contrôle total',
] ]
] ],
'course' => []
]; ];
public static $siteTemplate = [ public static $siteTemplate = [
'page' => [ 'page' => [
@ -877,9 +878,6 @@ class init extends common
] ]
] ]
], ],
'course' => [],
'enrolment' => [],
]; ];
public static $siteContent = [ public static $siteContent = [

View File

@ -5,16 +5,21 @@ userid, page, TS début, TS fin
course/course.json course/course.json
BDD contenant les informations sur le cours BDD contenant les informations sur le cours
- courseId identifiant du cours - courseId identifiant du cours
- title
- mentor enseignant responsable
- description
- access - access
- 0 le cours est ouvert - 0 le cours est ouvert
- 1 le cours est fermé - 1 le cours est ouvert entre les dates
- 2 le cours est ouvert entre les dates - 2 le cours est fermé
- openingDate - openingDate
- closingDate - closingDate
- enrolment - enrolment
- 0 l'accès est libre - 0 accès est anonyme
- 1 l'accès s'effectue avec une clé d'inscription - 1 accès libre
- 2 l'accès se fait avec inscription par un enseignant - 2 accès avec clé
- 3 manuel, le prof inscrits
- enrolmentKey clé d'inscription, si non vide - enrolmentKey clé d'inscription, si non vide
course/enrolment.json course/enrolment.json