From 65b39f116f5aa576beff9857c0df7309d0a8dad1 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 8 Sep 2023 22:09:25 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20d'un=20cours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.php | 2 + core/module/course/course.php | 74 +++++++++++++++++-- core/module/course/view/add/add.css | 18 +++++ core/module/course/view/add/add.php | 72 ++++++++++++++++++ core/module/course/view/index/index.css | 18 +++++ core/module/course/view/index/index.php | 16 ++++ core/module/install/ressource/defaultdata.php | 6 +- notes.txt | 15 ++-- 8 files changed, 207 insertions(+), 14 deletions(-) create mode 100644 core/module/course/view/add/add.css create mode 100644 core/module/course/view/add/add.php create mode 100644 core/module/course/view/index/index.css create mode 100644 core/module/course/view/index/index.php diff --git a/core/core.php b/core/core.php index a4519e3..b74b453 100644 --- a/core/core.php +++ b/core/core.php @@ -197,6 +197,7 @@ class common 'blacklist' => '', 'config' => '', 'core' => '', + 'course' => '', 'font' => '', 'module' => '', 'page' => '', @@ -210,6 +211,7 @@ class common 'admin' => '', 'blacklist' => '', 'config' => '', + 'course' => '', 'core' => '', 'font' => '', 'theme' => '', diff --git a/core/module/course/course.php b/core/module/course/course.php index 0b165a7..f9fae05 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -13,17 +13,81 @@ * @link http://zwiicms.fr/ */ -class dashboard extends common +class course extends common { 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() { - + // 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' + ]); + } + } \ No newline at end of file diff --git a/core/module/course/view/add/add.css b/core/module/course/view/add/add.css new file mode 100644 index 0000000..ec84629 --- /dev/null +++ b/core/module/course/view/add/add.css @@ -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 + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @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 +*/ \ No newline at end of file diff --git a/core/module/course/view/add/add.php b/core/module/course/view/add/add.php new file mode 100644 index 0000000..8a19361 --- /dev/null +++ b/core/module/course/view/add/add.php @@ -0,0 +1,72 @@ + +
+
+ 'buttonGrey', + 'href' => helper::baseUrl() . 'course', + 'value' => template::ico('left') + ]); ?> +
+
+ +
+
+
+
+
+

+ +

+
+
+ 'Titre' + ]); ?> +
+
+ 'Mentor' + ]); ?> +
+
+
+
+ 'Description' + ]); ?> +
+
+
+
+ 'Accès' + ]); ?> +
+
+ 'date', + 'label' => 'Ouverture', + ]); ?> +
+
+ 'date', + 'label' => 'Fermeture', + ]); ?> +
+
+
+
+ 'Inscription' + ]); ?> +
+
+ 'Clé' + ]); ?> +
+
+
+
+ \ No newline at end of file diff --git a/core/module/course/view/index/index.css b/core/module/course/view/index/index.css new file mode 100644 index 0000000..ec84629 --- /dev/null +++ b/core/module/course/view/index/index.css @@ -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 + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @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 +*/ \ No newline at end of file diff --git a/core/module/course/view/index/index.php b/core/module/course/view/index/index.php new file mode 100644 index 0000000..77ef37f --- /dev/null +++ b/core/module/course/view/index/index.php @@ -0,0 +1,16 @@ +
+
+ 'buttonGrey', + 'href' => helper::baseUrl() . $this->getUrl(2), + 'value' => template::ico('left') + ]); ?> +
+
+ 'buttonGreen', + 'href' => helper::baseUrl() . 'course/add', + 'value' => template::ico('plus') + ]); ?> +
+
\ No newline at end of file diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index 5ab45c4..541070b 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -666,7 +666,8 @@ class init extends common 'permanent' => true, 'comment' => 'Contrôle total', ] - ] + ], + 'course' => [] ]; public static $siteTemplate = [ 'page' => [ @@ -877,9 +878,6 @@ class init extends common ] ] ], - 'course' => [], - 'enrolment' => [], - ]; public static $siteContent = [ diff --git a/notes.txt b/notes.txt index f49475e..c5696b3 100644 --- a/notes.txt +++ b/notes.txt @@ -5,16 +5,21 @@ userid, page, TS début, TS fin course/course.json BDD contenant les informations sur le cours - courseId identifiant du cours +- title +- mentor enseignant responsable +- description - access - 0 le cours est ouvert - - 1 le cours est fermé - - 2 le cours est ouvert entre les dates + - 1 le cours est ouvert entre les dates + - 2 le cours est fermé + - openingDate - closingDate - enrolment - - 0 l'accès est libre - - 1 l'accès s'effectue avec une clé d'inscription - - 2 l'accès se fait avec inscription par un enseignant + - 0 accès est anonyme + - 1 accès libre + - 2 accès avec clé + - 3 manuel, le prof inscrits - enrolmentKey clé d'inscription, si non vide course/enrolment.json