diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c7eedded6e27a47c4e49f1b4c89493416aebc1c..7c2f2aa700c114a24cbad08f93b1ad459fbee1ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ -# 19/02/19 +# Changelog +## 21/06/2019 + +Refonte de l'interface et mise en compatibilité avec Moodle 37. + +L'administration des parcours est modifiée pour être plus agréable et efficace. Pour l'ajout de coches sexy, crédit à : https://jalokim.graphics/playground/fancy-checkbox-radios + +L'apparence du bloc en lui-même est améliorée. + +L'apparence de la page présentant un parcours est refondue pour être plus agréable et claire. + +Amélioration de la sécurité. + +Correction de bugs divers, notamment dus au passage de version. diff --git a/block_career.php b/block_career.php index f839e5bc10237e4a1c1c9f34f2dfa9d787c50a1a..a17fbacc7423dfa1e6b5dc8a3a2fb3d8f7f0a1ad 100644 --- a/block_career.php +++ b/block_career.php @@ -44,7 +44,12 @@ class block_career extends block_base */ function instance_allow_config() { - + return true; + } + + function has_config() + { + return true; } /** @@ -52,9 +57,7 @@ class block_career extends block_base */ public function get_content() { - global $CFG; - global $COURSE; - global $DB; + global $CFG, $COURSE, $DB, $USER; if ($this->content !== null) { return $this->content; @@ -69,11 +72,11 @@ class block_career extends block_base $active = ""; $this->content = new stdClass; - $this->content->text .= '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $COURSE->id . '" class="btn btn-success btn-career-block mb-3">Accueil du cours</a>'; - - // $image = ""; - $this->content->text .= '<div class="list-group">'; + $this->content->text = ''; + $this->content->text .= '<div class="list-group career-list-group font-weight-light">'; + + $this->content->text .= '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $COURSE->id . '" class="list-group-item list-group-item-success list-group-item-action" style="border-top-left-radius: .15rem; border-top-right-radius: .15rem; border-top: none;">Accueil du cours</a>'; foreach ($request as $value) { @@ -87,19 +90,21 @@ class block_career extends block_base $active = ""; } - $this->content->text .= "<a href='" . $CFG->wwwroot . "/blocks/career/career_unit.php?career=" . $value->id . "' class='list-group-item $active'>$value->name</a>"; + $this->content->text .= "<a href='{$CFG->wwwroot}/blocks/career/career_unit.php?career={$value->id}&courseid={$COURSE->id}' class='list-group-item list-group-item-action {$active}'>{$value->name}</a>"; // $this->content->text .= "<a href='" . $CFG->wwwroot . "/blocks/career/career_unit.php?career=" . $value->id . "' class='full list-group-item list-group-item-action $active'><div class=' left img_center'>$image</div> //    $value->name</a><br>"; } + if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id)) { + $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/career/career_list.php?courseid=' . $COURSE->id . '" " class="list-group-item list-group-item-primary list-group-item-action" style="border-bottom-left-radius: .15rem; border-bottom-right-radius: .15rem; border-bottom: none;">Gérer les parcours</a>'; + } + $this->content->text .= '</div>'; if (empty($request)) { - $this->content->text .= "<p>" . get_string('any_carrer', 'block_career') . "</p>"; + $this->content->text .= "<p class='alert alert-secondary m-t-1'>" . get_string('any_carrer', 'block_career') . "</p>"; } - $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/career/career_list.php?course=' . $COURSE->id . '" type="button " class="btn btn-primary btn-career-block mt-3">Gérer les parcours</a>'; - // $this->content->text .= "<p></p>"; return $this->content; diff --git a/career_list.php b/career_list.php index 1617256211775f9c4a27f711a985dc6f7866864b..f90bc9b4383a08a8ee4c7e944ef888bdf28f7225 100644 --- a/career_list.php +++ b/career_list.php @@ -1,38 +1,36 @@ <?php - define('NO_OUTPUT_BUFFERING', true); - require_once('../../config.php'); - require_once('entity/block_career_ressource.php'); - require_once('entity/block_career_section.php'); - require_once('view/view_career_list.php'); - - global $COURSE; - global $USER; - global $DB; - global $CFG; - require_once($CFG->libdir . '/adminlib.php'); - - $id_course = required_param('course', PARAM_INT); - - $url = new moodle_url('/blocks/career/career_list.php', array('course' => $id_course)); + // define('NO_OUTPUT_BUFFERING', true); +require_once('../../config.php'); +require_once('entity/block_career_ressource.php'); +require_once('entity/block_career_section.php'); +require_once('view/view_career_list.php'); + +global $USER, $DB, $CFG; +require_once($CFG->libdir . '/adminlib.php'); + +$id_course = required_param('courseid', PARAM_INT); + +$url = new moodle_url('/blocks/career/career_list.php', array('courseid' => $id_course)); //Check if the user has capability to update course - if (!has_capability('moodle/course:update', $context = context_course::instance($id_course), $USER->id)) { - header("Location: {$_SERVER['HTTP_REFERER']}"); - exit; - } - - $PAGE->set_url($url); - $PAGE->set_pagelayout('admin'); - - $course = $DB->get_record('course', array('id' => $id_course), '*', MUST_EXIST); - require_login($course, false, NULL); - - $PAGE->set_title(get_string('title_plugin', 'block_career')); - $PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline')); - - $ressource = new block_career_ressource(); - $section = new block_career_section(); - echo $OUTPUT->header(); - echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">"; - $content = new view_career_list(); - echo $content->get_content(); - echo $OUTPUT->footer(); \ No newline at end of file +if (!has_capability('moodle/course:update', $context = context_course::instance($id_course), $USER->id)) { + $link = $CFG->wwwroot . '/course/view.php?id=' . $id_course; + header("Location: {$link}"); + exit; +} + +$PAGE->set_url($url); +$PAGE->set_pagelayout('admin'); + +$course = $DB->get_record('course', array('id' => $id_course), '*', MUST_EXIST); +require_login($course, false, NULL); + +$PAGE->set_title(get_string('title_plugin', 'block_career')); +$PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline')); + +// $ressource = new block_career_ressource(); +// $section = new block_career_section(); +echo $OUTPUT->header(); + // echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">"; +$content = new view_career_list(); +echo $content->get_content(); +echo $OUTPUT->footer(); \ No newline at end of file diff --git a/career_setting.php b/career_setting.php index d0bc22a5b06bf89285b46f195216a80a606a86d0..f2d1f62f7e266a36a005cd9ddf3b47d9cd14a01f 100644 --- a/career_setting.php +++ b/career_setting.php @@ -1,58 +1,65 @@ <?php - - ob_start(); - - require_once('../../config.php'); - global $COURSE, $DB, $CFG; - require_once("$CFG->libdir/formslib.php"); - require_once('entity/block_career_ressource.php'); - require_once('entity/block_career_section.php'); - require_once('view/view_career_setting.php'); - - $id_course = required_param('course', PARAM_INT); - $url = new moodle_url('/blocks/career/career_setting.php', array('course' => $id_course)); - - $PAGE->set_pagelayout('course'); - $PAGE->set_url($url); - - $course = $DB->get_record('course', array('id' => $id_course), '*', MUST_EXIST); - require_login($course, false, NULL); - - - $PAGE->set_title(get_string('title_plugin', 'block_career')); - $PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline')); - echo $OUTPUT->header(); - $PAGE->requires->js("/blocks/career/js/jquery.min.js"); - $PAGE->requires->js("/blocks/career/js/file.js"); + +ob_start(); + +require_once('../../config.php'); +global $COURSE, $DB, $CFG, $USER; +require_once("$CFG->libdir/formslib.php"); +require_once('entity/block_career_ressource.php'); +require_once('entity/block_career_section.php'); +require_once('view/view_career_setting.php'); + +$id_course = required_param('courseid', PARAM_INT); +$url = new moodle_url('/blocks/career/career_setting.php', array('courseid' => $id_course)); + +$PAGE->set_pagelayout('course'); +$PAGE->set_url($url); + +// $course = $DB->get_record('course', array('id' => $id_course), '*', MUST_EXIST); +require_login($id_course, false, NULL); + +// $COURSE is === "1" before require_login !!! + +if (!has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id)) { + $link = $CFG->wwwroot . '/course/view.php?id=' . $COURSE->id; + header("Location: {$link}"); + exit; +} + +$PAGE->set_title(get_string('title_plugin', 'block_career')); +$PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline')); +echo $OUTPUT->header(); +$PAGE->requires->js("/blocks/career/js/jquery.min.js"); +$PAGE->requires->js("/blocks/career/js/file.js"); // echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">"; - - $content = new view_career_setting(); - echo $content->get_content(); + +$content = new view_career_setting(); +echo $content->get_content(); // Delete career - if (isset($_GET["delete"]) && $_GET["delete"] == 1) { - $DB->execute("DELETE FROM {block_career} WHERE id = ?", array($_GET["id"])); - header("Location: $CFG->wwwroot/blocks/career/career_list.php?course=" . $_GET["course"]); - } - - if (!empty($_POST["careerName"])) { - - $ressourses = ""; - - foreach ($_POST["ressource"] as $value) { - if ($value === end($_POST["ressource"])) { - $ressourses .= "$value"; - } else { - $ressourses .= "$value,"; - } +if (isset($_GET["delete"]) && $_GET["delete"] == 1) { + $DB->execute("DELETE FROM {block_career} WHERE id = ?", array($_GET["id"])); + header("Location: $CFG->wwwroot/blocks/career/career_list.php?courseid=" . $_GET["courseid"]); +} + +if (!empty($_POST["careerName"])) { + + $ressourses = ""; + + foreach ($_POST["ressource"] as $value) { + if ($value === end($_POST["ressource"])) { + $ressourses .= "$value"; + } else { + $ressourses .= "$value,"; } - + } + //$record is use for insert/update in database - $record = new stdClass(); - $record->course = intval($_GET["course"]); - $record->name = $_POST["careerName"]; - $record->description = $_POST["descriptionName"]["text"]; - + $record = new stdClass(); + $record->course = intval($_GET["courseid"]); + $record->name = $_POST["careerName"]; + $record->description = $_POST["descriptionName"]["text"]; + // if (isset($_FILES['imageName']['tmp_name'])) { // $pathDir = "img/"; // $pathFile = $pathDir . basename($_FILES["imageName"]["name"]); @@ -61,22 +68,22 @@ // } else { // $record->image = $_POST["imagePath"]; // } - $record->image = ""; - - $record->ressources = $ressourses; - - if ($_POST["careerId"] != 0) { - $record->id = intval($_POST["careerId"]); - $lastinsertid = $DB->update_record('block_career', $record); - } else { - $lastinsertid = $DB->insert_record('block_career', $record); - } - - if ($lastinsertid != 0) { - header("Location: $CFG->wwwroot/blocks/career/career_list.php?course=" . $_GET["course"]); - } - + $record->image = ""; + + $record->ressources = $ressourses; + + if ($_POST["careerId"] != 0) { + $record->id = intval($_POST["careerId"]); + $lastinsertid = $DB->update_record('block_career', $record); + } else { + $lastinsertid = $DB->insert_record('block_career', $record); + } + + if ($lastinsertid != 0) { + header("Location: $CFG->wwwroot/blocks/career/career_list.php?courseid=" . $_GET["courseid"]); } - - - echo $OUTPUT->footer(); + +} + + +echo $OUTPUT->footer(); diff --git a/career_unit.php b/career_unit.php index ee633e52c03d94341dcb50e01f54a32335d788de..4118653bce044272504946acae46c6bdb4f108c8 100644 --- a/career_unit.php +++ b/career_unit.php @@ -1,30 +1,41 @@ <?php - - require_once('../../config.php'); - require_once('entity/block_career_ressource.php'); - require_once('entity/block_career_section.php'); - - global $COURSE, $DB; - - $careerId = required_param('career', PARAM_INT); - $url = new moodle_url('/blocks/career/career_unit.php', array('career' => $careerId)); - $requete = $DB->get_record_sql('SELECT course FROM {block_career} WHERE id = ?', array($careerId)); - - $PAGE->set_pagelayout('course'); - $PAGE->set_url($url); - - // Getting DB data for the course - $course = $DB->get_record('course', array('id' => $requete->course), '*', MUST_EXIST); - // Must be logged in - require_login($course, false, NULL); - + +require_once('../../config.php'); +require_once('entity/block_career_ressource.php'); +require_once('entity/block_career_section.php'); + +global $DB; + +$careerId = required_param('career', PARAM_INT); +$courseid = required_param('courseid', PARAM_INT); + +$url = new moodle_url('/blocks/career/career_unit.php', array('career' => $careerId, 'courseid' => $courseid)); + +$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); +require_login($course, false, NULL); + +$PAGE->set_context(context_course::instance($courseid)); +$PAGE->set_pagelayout('course'); +$PAGE->set_url($url); + +$requete = $DB->get_record_sql('SELECT * FROM {block_career} WHERE id = ?', array($careerId)); + +if ($requete == false) { + + $PAGE->set_title("Erreur"); + $PAGE->set_heading("Erreur"); + echo $OUTPUT->header(); + echo "<div class='alert alert-danger'>Le parcours demandé n'existe pas ou a été supprimé. </div>"; + echo $OUTPUT->footer(); + +} else { + $PAGE->set_title(get_string('title_plugin', 'block_career')); - $PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline')); + + $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); - $PAGE->requires->js("/blocks/career/js/jquery.min.js"); - $PAGE->requires->js("/blocks/career/js/file.js"); - echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">"; - + $PAGE->requires->js("/blocks/career/js/sect-descr.js"); require_once('view/view_career_unit.php'); - echo $OUTPUT->footer(); + +} \ No newline at end of file diff --git a/edit_form.php b/edit_form.php index e0a49d06598dac5ab48e56e1db690f399d58cc06..29a08b26e1b8a8b09a2393da2954399ae3a00c37 100644 --- a/edit_form.php +++ b/edit_form.php @@ -11,7 +11,7 @@ function specific_definition($mform) { // Adding an element to the form - $mform->addElement('header', 'configheader', get_string('blocksettings', 'block')); + // $mform->addElement('header', 'configheader', get_string('blocksettings', 'block')); } } diff --git a/entity/block_career_ressource.php b/entity/block_career_ressource.php index 3a206676de4d64b01415c30ab9d0fdd5fde9493d..773a7145b64f2a2a4dd7f3d6e5149cbc7ec97663 100644 --- a/entity/block_career_ressource.php +++ b/entity/block_career_ressource.php @@ -76,7 +76,7 @@ * * @return array<block_career_ressource> $ressources */ - public function get_ressources_by_id_section($id_section) + public static function get_ressources_by_id_section($id_section) { global $DB; $requete = $DB->get_records_sql('SELECT id FROM {course_modules} WHERE section = ? AND deletioninprogress = 0', array($id_section)); diff --git a/entity/block_career_section.php b/entity/block_career_section.php index a230abba0129e67beefe6bba5c84a15d57bcce2f..c0fc1b2e59d06ec0bd4ecb65b0bc4915b316c656 100644 --- a/entity/block_career_section.php +++ b/entity/block_career_section.php @@ -58,7 +58,7 @@ * * @return array<block_career_section> $sections */ - public function get_sections_by_id_course($id_course) + public static function get_sections_by_id_course($id_course) { global $DB; diff --git "a/img/Capture d\342\200\231\303\251cran 2018-06-19 \303\240 18.18.32.png" "b/img/Capture d\342\200\231\303\251cran 2018-06-19 \303\240 18.18.32.png" deleted file mode 100644 index 963a9293ae1d940adcd2134b65a095392119cc60..0000000000000000000000000000000000000000 Binary files "a/img/Capture d\342\200\231\303\251cran 2018-06-19 \303\240 18.18.32.png" and /dev/null differ diff --git a/img/file.txt b/img/file.txt deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/img/numoc-16-9-blanc.png b/img/numoc-16-9-blanc.png deleted file mode 100644 index e877fb5f7e5d52c439bdcf5882a2f1ce4c429d93..0000000000000000000000000000000000000000 Binary files a/img/numoc-16-9-blanc.png and /dev/null differ diff --git a/img/rose-rose.jpg b/img/rose-rose.jpg deleted file mode 100644 index 77b23e9704a58b1ec1c5399d56357d600c9b3546..0000000000000000000000000000000000000000 Binary files a/img/rose-rose.jpg and /dev/null differ diff --git a/js/sect-descr.js b/js/sect-descr.js new file mode 100644 index 0000000000000000000000000000000000000000..a86315390cd22d67cdbcb72d2f9fd3b2ff421985 --- /dev/null +++ b/js/sect-descr.js @@ -0,0 +1,36 @@ +;(function () { + + /* Descriptions */ + var descr_area = document.querySelectorAll('.career-descr-fold'); + /* Links to expand description if it has been folded */ + var descr_icons = document.querySelectorAll('.career-descr-fold-icon'); + + /* If > 175px (too big) => change to 150px + link to unfold to normal size. */ + for (var i = 0; i < descr_area.length; i++) { + var height = descr_area[i].offsetHeight + if (height > 175) { + descr_area[i].dataset.foldsize = "small" + } else { + var icon = descr_area[i].querySelector('.career-descr-fold-icon'); + icon.setAttribute('hidden', 'hidden'); + } + } + + /* onclick on link => target parent section descr and change the foldsize attribute to cause css changes (unfold & icon) */ + for (var i = 0; i < descr_icons.length; i++) { + descr_icons[i].onclick = function(e) { + e.preventDefault(); + var target = e.target; + while ( target ) { + if (target.getAttribute('class') != null){ + if (target.getAttribute('class').indexOf('career-descr career-descr-fold') > -1) { + break; + } + } + target = target.parentNode; + } + target.dataset.foldsize == "small" ? target.dataset.foldsize = 'full' : target.dataset.foldsize = 'small'; + } + } + +})(); \ No newline at end of file diff --git a/lang/en/block_career.php b/lang/en/block_career.php index cb348581760da999a5e2214abc256babab751365..20d5ecddd3f1e2bda33052a5655837e29eeddb02 100644 --- a/lang/en/block_career.php +++ b/lang/en/block_career.php @@ -10,9 +10,10 @@ $string['titleaddname_plugin'] = 'Name'; $string['titleadddesc_plugin'] = 'Description'; $string['titleaddimg_plugin'] = 'Course picture'; - $string['titleaddelem_plugin'] = 'Course elements'; - $string['titleaddelemdesc_plugin'] = 'Drag and drop the elements of the course you want to add to this course'; - $string['heading_plugin'] = 'The path allow you to group some course resources in a particular sequence.'; + $string['titleaddelem_plugin'] = 'Path content'; + $string['titleaddelemdesc_plugin'] = 'Select course ressources and activities you want in your path.'; + $string['heading_plugin'] = 'You can create a Path to group activities and ressources appart from the other inside a learning path. '; $string['add_path'] = 'Add a path'; - $string['any_carrer'] = 'No Path in this course'; + $string['any_carrer'] = 'No Path in this course.'; + $string['list_title'] = 'Edit path list'; ?> \ No newline at end of file diff --git a/lang/fr/block_career.php b/lang/fr/block_career.php index dc95db7f815a34b955df67f14f94c22b87383e5a..b7c93cce0444763b72f283e085650f68e41b2f8b 100644 --- a/lang/fr/block_career.php +++ b/lang/fr/block_career.php @@ -9,9 +9,10 @@ $string['titleaddname_plugin'] = 'Nom'; $string['titleadddesc_plugin'] = 'Description'; $string['titleaddimg_plugin'] = 'Image du parcours'; - $string['titleaddelem_plugin'] = 'Elements du parcours'; - $string['titleaddelemdesc_plugin'] = 'Glissez-déposez les élements du cours que vous souhaitez ajouter à ce parcours'; - $string['heading_plugin'] = 'Les parcours permettent de regrouper certaines ressources du cours dans un enchaînement particulier.'; + $string['titleaddelem_plugin'] = 'Contenu du parcours'; + $string['titleaddelemdesc_plugin'] = 'Sélectionnez des activités et ressources du cours que vous souhaitez ajouter au parcours.'; + $string['heading_plugin'] = 'Les parcours permettent de regrouper certaines ressources du cours dans un enchaînement particulier à part des autres.'; $string['add_path'] = 'Ajouter un parcours'; - $string['any_carrer'] = 'Pas de parcours'; + $string['any_carrer'] = 'Pas de parcours.'; + $string['list_title'] = 'Édition des parcours'; ?> \ No newline at end of file diff --git a/readme.md b/readme.md index f6614c0b26affd524f92259e08244365a4eb2430..0efb75de0ce220b5fa2ca25ea6e9f6a0e9d902a0 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # Bloc parcours -Plugin MOODLE de type bloc de cours qui permet d'afficher une liste de certaines activités existante du cours sur une page à part. P.ex. pour créer des parcours de niveaux, thématiques, etc. dans un cours volumineux. +Plugin MOODLE de type bloc de cours qui permet d'afficher une liste de certaines activités existante du cours sur une page à part. P.ex. pour créer des parcours de niveaux, thématiques, etc. dans un cours volumineux. Crée des parcours différents dans le cours. ## Auteurs @@ -10,9 +10,7 @@ Plugin MOODLE de type bloc de cours qui permet d'afficher une liste de certaines ## Compatibility -MOODLE 3.5 - -Stabilité : expérimental. +MOODLE 3.7 ## Contribution @@ -26,11 +24,15 @@ Pour tout autre question : <iena-contact@univ-lorraine.fr>. Other : <iena-contact@univ-lorraine.fr>. +## Installation + +You _have to rename_ the folder "career" at the path `/blocks/career`. + ## Fonctionnalités -L'enseignant ajoute un parcours en lui donnant un nom et en sélectionnant plusieurs ressources ou activités du cours. +L'enseignant ajoute un parcours en lui donnant un nom et en sélectionnant plusieurs ressources ou activités du cours à y inclure. -L'étudiant voit une liste des parcours dans le bloc. En cliquant sur le nom d'un parcours, il voit une page qui lui présente la liste des ressoures et activités du cours choisies par l'enseignant pour ce parcours. +L'étudiant voit une liste des parcours dans le bloc. En cliquant sur le nom de l'un des parcours, il voit une page qui lui présente la liste des ressoures et activités du cours choisies par l'enseignant pour ce parcours. --- @@ -38,12 +40,8 @@ Teacher add a path with name and ressources and activity subset / selection from Student see path list quand by clicking one of them, can access to the list of ressources and activity choosen by the teacher for this learning path. -## Problèmes connus - -- Affichage peu élégant de la liste des ressources et activités. -- Pas de possibilité de passer d'un élément à l'autre du parcours sans revenir à la page du parcours. - -## Amélioration à effectuer +## Roadmap -- Améliorer l'apparence de la liste des activités et ressources d'un parcours. -- Permettre de consulter les éléments d'un parcours avec un meilleur enchaînement. +[ ] Permettre de consulter les éléments d'un parcours avec un meilleur enchaînement. +[ ] Intégrer l'achèvement d'activité avec visualisation des activités achevées, et pourcentage de complétion du parcours dans la page du parcours et dans le bloc +[ ] Ajouter un tableau de bord de progression dans les parcours pour l'enseignant diff --git a/styles.css b/styles.css index aa8ed190279a9b5fa45b62942754a40bcba8d9a2..4b64581906290d81b60254ea5a048b4c86c3bfaf 100644 --- a/styles.css +++ b/styles.css @@ -1,260 +1,171 @@ -.btn-career-block { - width: 100%; +/* Path view */ +.career-section-title { + background-color: #008196; } -/*.left { - float: left; -}*/ - -/*.img_moodle_course { - max-width: 100%; - -webkit-border-radius: 50%; - -moz-border-radius: 50%; - border-radius: 50%; - display: block; - margin: -1px; - min-height: 64px; - min-width: 64px; -}*/ - -/*.padding_column { - padding: 2rem; -}*/ - -/*.align_center { - display: flex; - justify-content: center; - align-items: center; -}*/ - -/*.button { - box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2); -}*/ - -/*.img_center { - top: 1rem; - left: 1rem; -}*/ - -/*.img_moodle_list { - max-width: 100%; - -webkit-border-radius: 50%; - -moz-border-radius: 50%; - border-radius: 50%; - display: block; - margin: -1px; - height: 32px; - width: 32px; - -}*/ - -.left_course_elements, .right_course_elements { - width: 33%; - float: left; - padding: 1%; - color: white; - text-align: center; - -webkit-box-shadow: 0 1px 3px 0 #d4d4d5, 0 0 0 1px #d4d4d5; - box-shadow: 0 1px 3px 0 #d4d4d5, 0 0 0 1px #d4d4d5; +.career-section-title > h3 { + color: #fafafa; + padding: 0.6rem 1rem; + margin-bottom: 0; } -.left_course_elements { - background: #2d2d2d; +.career-descr { + padding: .75rem 1.25rem; + margin-bottom: 0; + border: 0 solid transparent; + border-color: #f1f3f5; + color: #6b6e71; + background-color: #f5f6f8; } -.right_course_elements { - background: #009186; - +.career-descr-fold { + position: relative; + overflow: hidden; } -/*.title { - font-size: 1.5rem; - color: white; - padding-bottom: 0.5rem -}*/ - -.middle_elements { - text-align: center; - width: 11%; - float: left; - padding: 1%; +.career-descr-fold[data-foldsize="small"] { + max-height: 150px; } -/*#outer-dropzone { - height: 140px; -}*/ - -/*#inner-dropzone { - height: 80px; -}*/ - -/*.dropzone { - background-color: #ccc; - border: dashed 4px transparent; - border-radius: 4px; - margin: 10px auto 30px; - padding: 10px; - width: 80%; - transition: background-color 0.3s; -}*/ - -/*.drop-active { - border-color: #aaa; -}*/ - -/*.drop-target { - background-color: #29e; - border-color: #fff; - border-style: solid; -}*/ - -/*.drag-drop { - display: inline-block; - min-width: 40px; - padding: 2em 0.5em; - - color: #fff; - background-color: #29e; - border: solid 2px #fff; +.career-descr-fold-icon { + position: absolute; + bottom: 0.25rem; + right: 1rem; +} - -webkit-transform: translate(0px, 0px); - transform: translate(0px, 0px); +.career-descr-fold-icon svg { + border-radius: 10em; + padding: 9px; + background-color: rgba(0, 129, 150, 0.7); + box-shadow: 0px 0px 2px 0px #d2d2d2; +} - transition: background-color 0.3s; -}*/ +.career-descr-fold-icon svg:hover { + background-color: rgba(0, 129, 150, 1); + box-shadow: 0px 0px 5px 1px #d2d2d2; +} -/*.drag-drop.can-drop { - color: #000; - background-color: #4e4; -}*/ +.career-descr-fold[data-foldsize="small"] .arraw_to_bottom { + display: initial; +} +.career-descr-fold[data-foldsize="small"] .arraw_to_top { + display: none; +} +.career-descr-fold[data-foldsize="full"] .arraw_to_bottom { + display: none; +} +.career-descr-fold[data-foldsize="full"] .arraw_to_top { + display: initial; +} -/*.textarea:not([rows]) { - max-height: 600px; - min-height: 120px; -}*/ +.career-module-header { + margin-bottom: 0; + color: #008196; +} -/*.textarea { - display: block; - max-width: 99%; - min-width: 99%; - padding: 0.625em; - resize: vertical; -}*/ +.career-module-item:hover .career-module-header { + text-decoration: underline; +} -/*.input, .textarea { - -moz-appearance: none; - -webkit-appearance: none; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - border: 1px solid transparent; - border-top-color: transparent; - border-right-color: transparent; - border-bottom-color: transparent; - border-left-color: transparent; - border-radius: 3px; - -webkit-box-shadow: none; - box-shadow: none; - display: -webkit-inline-box; - display: -ms-inline-flexbox; - display: inline-flex; - font-size: 1rem; - height: 2.25em; - -webkit-box-pack: start; - -ms-flex-pack: start; - justify-content: flex-start; - line-height: 1.5; - padding-bottom: calc(0.375em - 1px); - padding-left: calc(0.625em - 1px); - padding-right: calc(0.625em - 1px); - padding-top: calc(0.375em - 1px); - position: relative; - vertical-align: top; - background-color: white; - border-color: #dbdbdb; - color: #363636; - -webkit-box-shadow: inset 0 1px 2px rgba(10, 10, 10, 0.1); - box-shadow: inset 0 1px 2px rgba(10, 10, 10, 0.1); - margin: 0.5rem; - width: auto; - max-width: 90%; +/* Block itself */ -}*/ +.career-list-group .list-group-item { + border: none; + border-top: 1px solid rgba(0,0,0,.125); + border-bottom: 1px solid rgba(0,0,0,.125); +} -/*input[type='file'] { - margin-bottom: 1rem; - padding: 0rem; - background: none; - border: 0px; - box-shadow: none; -}*/ +/* Path settings */ -.subject-info-box-1, -.subject-info-box-2 { - float: left; - width: 100%; +ul.career-ul { + list-style-type: none; + margin-bottom: 0; } -.subject-info-box-1 select, -.subject-info-box-2 select { - height: 200px; - padding: 0; +.career-edit-list-title { + margin-top: 1rem; } -.subject-info-box-1 select option, -.subject-info-box-2 select option { - padding: 4px 10px 4px 10px; +@media screen and (min-width: 768px) { + .career-cols { + column-count: 2; + } } - -.subject-info-box-1 select option:hover, -.subject-info-box-2 select option:hover { - background: #EEEEEE; +@media screen and (min-width: 1200px) { + .career-cols { + column-count: 3; + } } -/*.subject-info-arrows { - float: left; - width: 50%; - margin-left: 25%; -}*/ - -/*.subject-info-arrows input { - width: 70%; - margin-bottom: 5px; -}*/ +/* Path settings radios */ +/* https://jalokim.graphics/playground/fancy-checkbox-radios */ -.path-list-edit-link { - position: absolute; - top: 0; - right: 0; +.fancy--holder { + position: relative; + overflow: hidden; + font-size: 0; + display: inline-block; + margin-bottom: 0; } - -.iena-btn-career-arrow { - padding: 0.5rem; +.fancy--holder input { + position: absolute; + top: -100%; + left: -200px; + opacity: 0; + height: 0; width: 0; +} +.fancy--holder.fancy--checkbox2 .fancy--input { + width: 40px; + height: 20px; + border-radius: 100px; + display: inline-block; + vertical-align: top; + position: relative; + cursor: pointer; + background-color: #454749; +} +.fancy--holder.fancy--checkbox2 .fancy--input:before { + content: ""; + width: 16px; + height: 16px; + border-radius: 100px; + background: #FFFFFF; + position: absolute; + top: 2px; + left: 2px; + transition: left 0.2s; +} +.fancy--holder.fancy--checkbox2.fancy--legend .fancy--input:after { + content: "off"; + font-size: 8px; + color: #fff; + width: 100%; + display: block; + text-align: right; + text-transform: uppercase; + padding: 0px 4px; + line-height: 20px ; +} +.fancy--holder.fancy--checkbox2 input:checked ~ .fancy--input { + background-color: rgba(67, 171, 33, 0.73); + transition: background-color 0.2s; +} +.fancy--holder.fancy--checkbox2 input:checked ~ .fancy--input:before { + left: 22px; + transition: left 0.2s; +} +.fancy--holder.fancy--checkbox2 input:checked ~ .fancy--input:after { + text-align: left; + content: "on"; +} +.fancy--holder.fancy--checkbox2 input:disabled ~ .fancy--input{ + opacity: 0.3; + cursor: not-allowed; +} +.fancy--holder .fancy--label { + cursor: pointer; + margin-left: 10px; + font-size: 13px; + color: black; + user-select: none; } - -/*.iena-career-description { - background: #EEE; - color: #323232; - padding: 1rem; - clear: both; - margin-bottom: 0, 5rem; -}*/ - -/*.iena-carrer-path-descr { - border: 1px solid #1587bc; - border-radius: 0.15rem; - background-color: white; - color: #333; - padding: 1rem; -} */ - -/*.iena-carrer-path-descr a { - color: #1587bc; - margin-top: 1rem; - display: block; -}*/ - -/*.iena-career-description p, -.iena-carrer-path-descr p { - font-size: initial !important; -}*/ diff --git a/version.php b/version.php index d9e46db20acd677ebd7c993280538e503df10f96..249eb00969878dc4d3ce4435b35b79ea3cb627d7 100644 --- a/version.php +++ b/version.php @@ -28,7 +28,7 @@ */ defined('MOODLE_INTERNAL') || die(); - $plugin->version = 2019021501; + $plugin->version = 2019062101; $plugin->requires = 2014051200; $plugin->component = 'block_career'; $plugin->release = 'v1.1'; diff --git a/view/view_career_list.php b/view/view_career_list.php index 1e04a0c70632e649de7c0f8a99097fd3f724ae5e..47549d028be23490ba48685062c3c3364232d0a4 100644 --- a/view/view_career_list.php +++ b/view/view_career_list.php @@ -1,55 +1,53 @@ <?php - - - class view_career_list - { - - /** - * @return string - */ - public function get_content() - { - global $DB, $CFG; - - $content = "<h2>" . get_string('title_plugin', 'block_career') . "</h2>"; - $content .= "<div class='alert alert-info'>" . get_string('heading_plugin', 'block_career') . "</div>"; - - $request = $DB->get_records_sql('SELECT * FROM {block_career} WHERE course = ?', array($_GET["course"])); - - // $image = ""; - - foreach ($request as $value) { - - // if (file_get_contents($value->image) != null) { - // $image = "<img src='$value->image' class='img_moodle_course'/>"; - // } - - $content .= "<div class='card card-block mb-3'> - <div class='card-body'> - <h2 class='card-title'>$value->name</h2> - <p class='card-text'>$value->description</p> - <a href='$CFG->wwwroot/blocks/career/career_setting.php?course=" . $_GET["course"] . "&id=$value->id' class='btn btn-primary btn-sm path-list-edit-link'>Modifier</a> - </div> - </div>"; - - // $content .= "<div class='card card_block'> - // <div class='row'> - // <div class='col-lg-1 col-md-1 padding_column align_center img_center' >$image</div> - // <div class='col-lg-10 col-md-10 padding_column'><h3>$value->name</h3>$value->description</div> - // <div class='col-lg-1 col-md-1 padding_column'><a style='color:black' href='$CFG->wwwroot/blocks/career/career_setting.php?course=" . $_GET["course"] . "&id=$value->id'><i class=\"fa fa-cog fa-2x\"></a></i></div> - // </div> - // </div>"; - } - - if (empty($request)) { - $content .= "<p>" . get_string('any_carrer', 'block_career') . "</p>"; - } + + +class view_career_list +{ + +/** + * @return string + */ +public function get_content() +{ + global $DB, $CFG, $COURSE, $USER; + + if (!has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id)) { + $link = $CFG->wwwroot . '/course/view.php?id=' . $COURSE->id; + header("Location: {$link}"); + exit; + } + + $content = "<h2>" . get_string('list_title', 'block_career') . "</h2>"; + $content .= "<div class='alert alert-info'>" . get_string('heading_plugin', 'block_career') . "</div>"; + + $request = $DB->get_records_sql('SELECT * FROM {block_career} WHERE course = ?', array($_GET["courseid"])); + + $content .= "<a href='$CFG->wwwroot/blocks/career/career_setting.php?courseid=" . $COURSE->id . "' class='btn btn-primary m-b-1'>" . get_string('add_path', 'block_career') . "</a>"; + + $content .= "<div class='list-group'>"; + + foreach ($request as $value) { + + $content .= " + <a class='list-group-item list-group-item-action' style='color: inherit;' href='$CFG->wwwroot/blocks/career/career_setting.php?courseid=" . $_GET["courseid"] . "&pathid=$value->id'> + <h2 class='' style='float: left;'>$value->name</h2> + <!--<a href='$CFG->wwwroot/blocks/career/career_setting.php?courseid=" . $_GET["courseid"] . "&pathid=$value->id' class='btn btn-primary btn-sm' style='float: right;'>Modifier</a>--> + <div class='' style='clear: both;'>$value->description</div> + </a> + "; + } + + $content .= "</div>"; + + if (empty($request)) { + $content .= "<p>" . get_string('any_carrer', 'block_career') . "</p>"; + } // Button for adding course to the list - $content .= "<a href='$CFG->wwwroot/blocks/career/career_setting.php?course=" . $_GET["course"] . "' class='btn btn-primary'>" . get_string('add_path', 'block_career') . "</a>"; - - - return $content; - - } - - } \ No newline at end of file + $content .= "<a href='$CFG->wwwroot/blocks/career/career_setting.php?courseid=" . $COURSE->id . "' class='btn btn-primary m-t-1'>" . get_string('add_path', 'block_career') . "</a>"; + + + return $content; + +} + +} \ No newline at end of file diff --git a/view/view_career_setting.php b/view/view_career_setting.php index 26d06de6f69085bbdd68a7170a29cc9a9fafa449..fe91e3414d0c6434b4295981b9492928ee2048ba 100644 --- a/view/view_career_setting.php +++ b/view/view_career_setting.php @@ -13,184 +13,137 @@ class view_career_setting extends moodleform { - public function definition() - { - // TODO: Implement definition() method. - global $CFG; - - $mform = $this->_form; // Don't forget the underscore! - - //Default value - } - - public function get_content() - { - global $DB, $CFG; - - $mform = $this->_form; - $careerId = optional_param('id', NULL, PARAM_INT); - $course = required_param('course', PARAM_INT); - - $name = ""; - $description = ""; - $ressourcesId = ""; - $contentButton = "Ajouter un parcours"; - // $imagePath = ""; - - if (isset($careerId) && !empty($careerId)) - { - $requete = $DB->get_record_sql('SELECT * FROM {block_career} WHERE id = ?', array($careerId)); - $name = $requete->name; - $description = $requete->description; - $ressourcesId = explode(",", $requete->ressources); - $contentButton = "Modifier le parcours"; - // $imagePath = $requete->image; - - } - - - $mform->addElement('text','careerName',get_string('titleaddname_plugin', 'block_career')); - $mform->addRule('careerName', get_string('error'), 'required', null, null, false, false); - $mform->setDefault('careerName',$name); - - $mform->addElement('editor', 'descriptionName', get_string('titleadddesc_plugin', 'block_career')); - $mform->setType('descriptionName', PARAM_RAW); - $mform->addRule('descriptionName', get_string('error'), 'required', null, null, false, false); - $mform->setDefault('descriptionName',array('text'=>$description)); - - //FilePicker IMAGE - //$mform->addElement('filepicker', 'imageName', get_string('titleaddimg_plugin', 'block_career'), null); - - - // $content = "<h1>" . get_string('title_plugin', 'block_career') . "</h1>"; - $content .= "<div class='alert alert-info'>" . get_string('heading_plugin', 'block_career') . "</div>"; - - $temp = $mform->toHtml(); - - - $temp = substr($temp,(strpos($temp,'>')+1)); - $temp = substr($temp,0, -7); - $content .= '<div class="row"><form class="col-12" action="career_setting.php?course=' . $course . '" method="post" enctype="multipart/form-data">'; - - $content .= $temp; - - // $content .= ' <section class="section"><h3>' . get_string('titleaddimg_plugin', 'block_career') . '</h3> - // <input type="file" class="input" name="imageName" accept="image/*" /></section>'; - - - $content .= ' <section class="section row"><div class="col-12"><h2>' . get_string('titleaddelem_plugin', 'block_career') . '</h2> - <div class="alert alert-info">' . get_string('titleaddelemdesc_plugin', 'block_career') . '</div> - <div class="left_course_elements"> - <div class="title">Cours</div> - <div class="subject-info-box-1"> - <select multiple="multiple" id="lstBox1" class="form-control">'; - - $sections = block_career_section::get_sections_by_id_course($course); - - // var_dump($sections); - - foreach ($sections as $section) - { - $section->ressources = block_career_ressource::get_ressources_by_id_section($section->id); - } - - foreach ($sections as $section) - { - $content .= '<optgroup label="'.$section->name.'" value="'.$section->id.'">'; - - foreach ($section->ressources as $ressource) - { - $content .= '<option label="'.$ressource->name.'" value ="'.$ressource->id.'" name="'.$ressource->id.'">'.$ressource->name.'</option>'; - } - $content .= '</optgroup>'; - } - - $content .='</select></div></div>'; - - $content .= '<div class="middle_elements"> - <div class="title">Actions</div> - <div class="subject-info-arrows text-center"> - <input type="button" id="btnAllRight" value=">>" class="btn btn-default iena-btn-career-arrow" /><br /> - <input type="button" id="btnRight" value=">" class="btn btn-default iena-btn-career-arrow" /><br /> - <input type="button" id="btnLeft" value="<" class="btn btn-default iena-btn-career-arrow" /><br /> - <input type="button" id="btnAllLeft" value="<<" class="btn btn-default iena-btn-career-arrow" /> - </div> - </div>'; - - $content .= '<div class="right_course_elements"> - <div class="title">Parcours</div> - <div class="subject-info-box-2"> - <select multiple="multiple" id="lstBox2" name="ressource[]" class="form-control" required>'; - - - foreach ($ressourcesId as $value) - { - $res = new block_career_ressource(); - $res->get_ressource_by_id($value); - - if ($careerId != 0) - $content .= '<option label="'.$res->name.'" value ="'.$res->id.'">'; - } - - - $content .= '</select> - </div> - <div class="clearfix"></div> - </div> - </div> - </section>'; - - $content .= '<script> - function selectAll(e) - { - // e.preventDefault(); - selectBox = document.getElementById("lstBox2"); - - var checkValue = 0; - - for (var i = 0; i < selectBox.options.length; i++) - { - selectBox.options[i].selected = true; - } - - $("#lstBox2 :selected").map(function(i, el) { - - if (checkValue == $(el).val()) - $(el).remove(); - - checkValue = $(el).val(); - }); - } - // console.log() - </script>'; - - if ($careerId != 0) { - $content .= '<input type="hidden" name="imagePath" value="'.$imagePath.'">'; - } - - $content .= ' - <div class="row mt-3"> - <div class="col"> - <input type="hidden" name="careerId" value="'.$careerId.'"> - <a href=' . $CFG->wwwroot . "/blocks/career/career_list.php?course=" . $course . ' class="btn btn-secondary">Annuler</a> '; - - - - if ($careerId != 0) { - $content .= "<a href='$CFG->wwwroot/blocks/career/career_setting.php?course=$course&delete=1&id=$careerId' class='btn btn-danger'>Supprimer</a> "; - } - - $content .= ' - <button type="submit" onclick="selectAll(event);" class="btn btn-primary">'.$contentButton.'</button> - </div> - </div> - '; - - - $content .= '</div></form>'; - - - return $content; - } - - } \ No newline at end of file + public function definition() + { + // TODO: Implement definition() method. + global $CFG; + + $mform = $this->_form; // Don't forget the underscore! + + //Default value + } + + public function get_content() + { + global $DB, $CFG; + + $mform = $this->_form; + $careerId = optional_param('pathid', NULL, PARAM_INT); + $course = required_param('courseid', PARAM_INT); + + $name = ""; + $description = ""; + $ressourcesId = ""; + $contentButton = "Ajouter un parcours"; + // $imagePath = ""; + + if (isset($careerId) && !empty($careerId)) + { + $requete = $DB->get_record_sql('SELECT * FROM {block_career} WHERE id = ?', array($careerId)); + $name = $requete->name; + $description = $requete->description; + $ressourcesId = explode(",", $requete->ressources); + $contentButton = "Modifier le parcours"; + // $imagePath = $requete->image; + + } + + + $mform->addElement('text','careerName',get_string('titleaddname_plugin', 'block_career')); + $mform->addRule('careerName', get_string('error'), 'required', null, null, false, false); + $mform->setDefault('careerName',$name); + + $mform->addElement('editor', 'descriptionName', get_string('titleadddesc_plugin', 'block_career')); + $mform->setType('descriptionName', PARAM_RAW); + $mform->addRule('descriptionName', get_string('error'), 'required', null, null, false, false); + $mform->setDefault('descriptionName',array('text'=>$description)); + + //FilePicker IMAGE + //$mform->addElement('filepicker', 'imageName', get_string('titleaddimg_plugin', 'block_career'), null); + + + // $content = "<h1>" . get_string('title_plugin', 'block_career') . "</h1>"; + $content = ""; + $content .= "<h2>Édition du parcours</h2>"; + $content .= "<div class='alert alert-info'>" . get_string('heading_plugin', 'block_career') . "</div>"; + + $temp = $mform->toHtml(); + + + $temp = substr($temp,(strpos($temp,'>')+1)); + $temp = substr($temp,0, -7); + + $sections = block_career_section::get_sections_by_id_course($course); + + $content .= '<div class="row"><form class="col-12" action="career_setting.php?courseid=' . $course . '" method="post" enctype="multipart/form-data">'; + + $content .= $temp; + + foreach ($sections as $section) { + $section->ressources = block_career_ressource::get_ressources_by_id_section($section->id); + } + + $content .= '<h2 style="margin-top: 1.5rem;">' . get_string('titleaddelem_plugin', 'block_career') . '</h2><div class="alert alert-info">' . get_string('titleaddelemdesc_plugin', 'block_career') . '</div>'; + + $content .= "<section class='career-cols'>"; + + foreach ($sections as $section) { + if ( count($section->ressources) > 0 ) { + $content .= '<div style="break-inside: avoid;"><h3 class="h4 career-edit-list-title">' . $section->name . '</h3>'; + $content .= '<ul class="career-ul">'; + foreach ($section->ressources as $ressource) { + $check = false; + if ($ressourcesId != "") { + foreach ($ressourcesId as $ress_id) { + if ( $ress_id == $ressource->id ) { + $check = true; + break; + } + } + } + if ( $check ) { + $content .= '<li> + <label class="fancy--holder fancy--checkbox2"> + <input type="checkbox" name="ressource[]" value="' . $ressource->id . '" label="'. $ressource->name .'" checked> + <span class="fancy--input"></span> + <span class="fancy--label">'. $ressource->name .'</span> + </label> + <li>'; + } else { + $content .= '<li> + <label class="fancy--holder fancy--checkbox2"> + <input type="checkbox" name="ressource[]" value="' . $ressource->id . '" label="'. $ressource->name .'"> + <span class="fancy--input"></span> + <span class="fancy--label">'. $ressource->name .'</span> + </label> + <li>'; + } + } + $content .= '</ul></div>'; + } + } + + $content .= "</section>"; + + $content .= ' + <div class="row mt-3"> + <div class="col"> + <input type="hidden" name="careerId" value="'.$careerId.'"> + <a href=' . $CFG->wwwroot . "/blocks/career/career_list.php?courseid=" . $course . ' class="btn btn-secondary">Annuler</a> '; + + if ($careerId != 0) { + $content .= "<a href='$CFG->wwwroot/blocks/career/career_setting.php?courseid=$course&delete=1&id=$careerId' class='btn btn-danger'>Supprimer</a> "; + } + + $content .= ' + <button type="submit" class="btn btn-primary">'.$contentButton.'</button> + </div> + </div> + '; + + $content .= '</div></form>'; + + return $content; + } + +} \ No newline at end of file diff --git a/view/view_career_unit.php b/view/view_career_unit.php index a67f07965921b3ecd3f1c0d632102e0a0292f2d2..d423f55c52d80c08ffb73bcebf68db16137d9038 100644 --- a/view/view_career_unit.php +++ b/view/view_career_unit.php @@ -1,8 +1,6 @@ <?php -$careerId = required_param("career", PARAM_INT); -global $DB; -$requete = $DB->get_record_sql('SELECT * FROM {block_career} WHERE id = ?', array($careerId)); +global $DB, $CFG, $COURSE, $USER; $percent = 70; $nb_pers = 5; @@ -19,88 +17,96 @@ $sections = array(); $ressources = array(); $i = 0; foreach ($elements as $value) { - $ressource = new block_career_ressource(); - $ressource->get_ressource_by_id($value); - $sections[$i] = $ressource->section; - $ressources[$i] = $ressource; - $i++; + $ressource = new block_career_ressource(); + $ressource->get_ressource_by_id($value); + $sections[$i] = $ressource->section; + $ressources[$i] = $ressource; + $i++; } //var_dump($sections); //Supprime les doublons for($i = 0; $i < count($sections);$i++) { - $temp = $i; - $temp++; + $temp = $i; + $temp++; - if ($temp != count($sections)) - { - if ($sections[$i]->id == $sections[$temp]->id) - { - unset($sections[$i]); - } - } + if ($temp != count($sections)) + { + if ($sections[$i]->id == $sections[$temp]->id) + { + unset($sections[$i]); + } + } } //Met dans l'orde $keys = array(); $i = 0; foreach ($sections as $value){ - $keys[$i] = $value->orde; - $i++; + $keys[$i] = $value->orde; + $i++; } $sections = array_combine($keys,$sections); ksort($sections); +$cours_url = $CFG->wwwroot . "/course/view.php?id=" . $COURSE->id; +$edit_url = $CFG->wwwroot . "/blocks/career/career_setting.php?courseid=" . $COURSE->id . "&pathid=" . $careerId; -?> +function is_not_empty_string($str) { + $str_copy = $str; + $to_delete = array('<p>', '</p>', '<br>', '</br>', ' '); + $str_copy = str_replace($to_delete, '', $str_copy); + $str_copy = preg_replace('/\s+/', '', $str_copy); + if ( $str_copy != "" ) { + return true; + } + return false; +} +?> <section class="section"> - <h2 class="display-3"><?=$titre;?></h2> - <div class="iena-carrer-path-descr wrapper"> - <div class="small"> - <?= $intro ;?> - </div> - <a href="#">Voir la description complète</a> - </div> - <?php foreach ($sections as $section) : ?> - <div style="margin-bottom: 0rem; margin-top: 1rem;"> - <div class="card card_block"> - <div class="heading-iena set_height" style="background-color: #009186 !important;"> - <div class="titre_section set_height"> - <h3><?php echo $section->name; ?></h3> - </div> - </div> - </div> - <div class="iena-career-description wrapper"> - <div class="small"> - <p><?= $section->intro ;?></p> - </div> - <a href="#">Voir la description complète</a> - - </div> - <div class="elements"> - <div class="list-group"> - <?php foreach ($ressources as $value) : ?> - <?php if($value->section->id == $section->id) : ?> - <div class="row" style="padding-bottom: 0.5rem;"> - <div class="col-md-12 col-sm-12 col-lg-12"> - <a href="<?php echo "$value->link&career=$careerId" ?>" class="list-group-item list-group-item-action flex-column align-items-start"> - <div class="d-flex w-100 justify-content-between"> - <h5 class="mb-1"><img class="" alt="" src="<?php echo $CFG->wwwroot ?>/theme/image.php/boost/<?php echo $value->type ?>/1/icon>"> - <?php echo $value->name;?></h5></div> - - <!--<div style="max-height:100px;overflow-y:auto;"><p class="mb-1"><?php echo $value->descrition;?></p></div>--></a> - </div> - </div> - <?php endif;?> - <?php endforeach;?> - </div> - </div></div> - <?php endforeach;?> - <!-- </ul> --> - <!-- </div> --> + <?php if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id)): ?> + <a class="btn btn-warning" style="float: right; margin-left: 0.25rem;" href="<?php echo $edit_url; ?>">Éditer</a> + <?php endif; ?> + <a class="btn btn-primary" style="float: right;" href="<?php echo $cours_url; ?>">Retour au cours</a> + <h2 class="display-4" style="clear: both;"><?php echo $titre; ?></h2> + <?php + if ( is_not_empty_string($intro) ) { + echo "<div class='career-descr career-descr-fold' data-foldsize='full'>" . $intro . "<a href='#' class='career-descr-fold-icon'><svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' class='arraw_to_bottom' x='0px' y='0px' width='35px' height='35px' viewBox='0 0 451.847 451.847' style='enable-background:new 0 0 451.847 451.847;' xml:space='preserve'><g><path fill='white' d='M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751 c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0 c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z'></path></g></svg><svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' class='arraw_to_top' x='0px' y='0px' width='35px' height='35px' viewBox='0 0 451.847 451.846' style='enable-background:new 0 0 451.847 451.846;' xml:space='preserve'><g><path fill='white' d='M248.292,106.406l194.281,194.29c12.365,12.359,12.365,32.391,0,44.744c-12.354,12.354-32.391,12.354-44.744,0 L225.923,173.529L54.018,345.44c-12.36,12.354-32.395,12.354-44.748,0c-12.359-12.354-12.359-32.391,0-44.75L203.554,106.4 c6.18-6.174,14.271-9.259,22.369-9.259C234.018,97.141,242.115,100.232,248.292,106.406z'/></g></svg></a></div>"; + } + ?> + <?php foreach ($sections as $section) : ?> + <div style="margin-bottom: 0rem; margin-top: 1rem;"> + <div class="career-section-title"> + <h3><?php echo $section->name; ?></h3> + </div> + <?php + if ( is_not_empty_string($section->intro) ) { + echo "<div class='career-descr career-descr-fold' data-foldsize='full'>" . $section->intro . "<a href='#' class='career-descr-fold-icon'><svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' class='arraw_to_bottom' x='0px' y='0px' width='35px' height='35px' viewBox='0 0 451.847 451.847' style='enable-background:new 0 0 451.847 451.847;' xml:space='preserve'><g><path fill='white' d='M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751 c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0 c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z'></path></g></svg><svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' class='arraw_to_top' x='0px' y='0px' width='35px' height='35px' viewBox='0 0 451.847 451.846' style='enable-background:new 0 0 451.847 451.846;' xml:space='preserve'><g><path fill='white' d='M248.292,106.406l194.281,194.29c12.365,12.359,12.365,32.391,0,44.744c-12.354,12.354-32.391,12.354-44.744,0 L225.923,173.529L54.018,345.44c-12.36,12.354-32.395,12.354-44.748,0c-12.359-12.354-12.359-32.391,0-44.75L203.554,106.4 c6.18-6.174,14.271-9.259,22.369-9.259C234.018,97.141,242.115,100.232,248.292,106.406z'/></g></svg></a></div>"; + }?> + <div class="list-group" style="margin-top: 1rem;"> + <?php foreach ($ressources as $value) : ?> + <?php if($value->section->id == $section->id) : ?> + <a href="<?php echo "$value->link&career=$careerId" ?>" class="list-group-item list-group-item-action flex-column align-items-start career-module-item"> + <div class="d-flex w-100 justify-content-between"> + <h5 class="career-module-header"> + <?php echo $value->name;?> + </h5> + <img class="" alt="" src="<?php echo $CFG->wwwroot ?>/theme/image.php/boost/<?php echo $value->type ?>/1/icon>"> + </div> + <?php + if ( is_not_empty_string($value->descrition) ) { + echo "<div style='margin-top: 0.25rem;'>" . $value->descrition . "</div>"; + } + ?> + </a> + <?php endif;?> + <?php endforeach;?> + </div> + </div> + <?php endforeach;?> - </section> +</section>