From 869a4f5f972f7198ad6a252cf0f8cbda12d2cfac Mon Sep 17 00:00:00 2001 From: Myriam Delaruelle <myriam.delaruelle@univ-lorraine.fr> Date: Thu, 30 Mar 2023 10:32:06 +0200 Subject: [PATCH] retractable sections --- classes/output/courseformat/content.php | 46 ++ .../courseformat/content/section/header.php | 168 +++++ classes/output/renderer.php | 74 ++ entity/course_format_iena_completion.php | 97 ++- format.php | 39 +- renderer.php | 688 ------------------ styles.css | 64 +- templates/courseformat/content.mustache | 207 ++++++ .../courseformat/content/section.mustache | 109 +++ .../content/section/content.mustache | 160 ++++ .../content/section/header.mustache | 105 +++ version.php | 2 +- 12 files changed, 1049 insertions(+), 710 deletions(-) create mode 100644 classes/output/courseformat/content.php create mode 100644 classes/output/courseformat/content/section/header.php create mode 100644 classes/output/renderer.php create mode 100644 templates/courseformat/content.mustache create mode 100644 templates/courseformat/content/section.mustache create mode 100644 templates/courseformat/content/section/content.mustache create mode 100644 templates/courseformat/content/section/header.mustache diff --git a/classes/output/courseformat/content.php b/classes/output/courseformat/content.php new file mode 100644 index 0000000..c8d69c0 --- /dev/null +++ b/classes/output/courseformat/content.php @@ -0,0 +1,46 @@ +<?php +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see <http://www.gnu.org/licenses/>. + +/** + * Contains the default content output class. + * + * @package format_topics + * @copyright 2020 Ferran Recio <ferran@moodle.com> + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace format_iena\output\courseformat; + +use core_courseformat\output\local\content as content_base; + +/** + * Base class to render a course content. + * + * @package format_topics + * @copyright 2020 Ferran Recio <ferran@moodle.com> + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class content extends content_base { + + /** + * @var bool Topic format has add section after each topic. + * + * The responsible for the buttons is core_courseformat\output\local\content\section. + */ + protected $hasaddsection = false; + + +} diff --git a/classes/output/courseformat/content/section/header.php b/classes/output/courseformat/content/section/header.php new file mode 100644 index 0000000..19ac53e --- /dev/null +++ b/classes/output/courseformat/content/section/header.php @@ -0,0 +1,168 @@ +<?php + +namespace format_iena\output\courseformat\content\section; + +use core_courseformat\output\local\content\section\header as header_base; +use format_iena\entity\course_format_iena_completion; +use context_course; + +class header extends header_base{ + + /** + * Export this data so it can be used as the context for a mustache template. + * + * @param renderer_base $output typically, the renderer that's calling this function + * @return array data context for a mustache template + */ + + public function export_for_template(\renderer_base $output): \stdClass { + global $USER; + $format = $this->format; + $section = $this->section; + $course = $format->get_course(); + + $data = (object)[ + 'num' => $section->section, + 'id' => $section->id, + ]; + $data->title = $output->section_title_without_link($section, $course); + + $coursedisplay = $format->get_course_display(); + $data->headerdisplaymultipage = false; + if ($coursedisplay == COURSE_DISPLAY_MULTIPAGE) { + $data->headerdisplaymultipage = true; + $data->title = $output->section_title($section, $course); + } + + if ($section->section > $format->get_last_section_number()) { + // Stealth sections (orphaned) has special title. + $data->title = get_string('orphanedactivitiesinsectionno', '', $section->section); + } + + if (!$section->visible) { + $data->ishidden = true; + } + + if ($course->id == SITEID) { + $data->sitehome = true; + } + + $data->editing = $format->show_editor(); + + if (!$format->show_editor() && $coursedisplay == COURSE_DISPLAY_MULTIPAGE && empty($data->issinglesection)) { + if ($section->uservisible) { + $data->url = course_get_url($course, $section->section); + } + } + $data->name = get_section_name($course, $section); + $param_section = (object)$format->get_format_options($section); + $data->mode=$this->get_header_mode($param_section); + $data->date=$this->get_header_date($param_section, $data->mode); + if (has_capability('course/iena:suivi', $context = context_course::instance($course->id), $USER->id)) { + $data->link_suivi=$this->get_suivi_link($course->id, $section); + } + else{ + $data->progress=$this->get_progress_student($course->id, $section, $course); + } + return $data; + } + + + + public function get_header_mode($param_section){ + $data=(object)[]; + //Ajouté par le plugin + if ($param_section !== false) { + + if (isset($param_section->presence)) { + if ($param_section->presence == 1) { + $data->presence = true; + $data->distance =false; + + } else if ($param_section->presence == 2) { + $data->presence = false; + $data->distance =true; + } + else{ + $data->presence = false; + $data->distance =false; + } + } + + + } + return $data; + } + + public function get_header_date($param_section, $mode){ + $string_date=false; + if (isset($param_section->daterendu) && $param_section->daterendu != 0) { + $date=date("j/m H:i", $param_section->daterendu); + $date_jour = date("j/m", $param_section->daterendu); + $date_heure = date("H:i", $param_section->daterendu); + if($mode->distance==true){ + $string_date_presence="Pour le "; + } + else{ + $string_date_presence="Le "; + } + //if($string_date_presence){ + $string_date=$string_date_presence.$date_jour." à ".$date_heure; + /*} + else{ + $string_date="Le ".$date_jour." à ".$date_heure; + }*/ + } + return $string_date; + } + + public function get_suivi_link($courseid, $section){ + global $USER, $CFG; + + $display_button=false; + $link_suivi=false; + foreach ($section->modinfo->cms as $cm) { + if($cm->completion>0 && $cm->section==$section->id){ + $display_button=true; + break; + } + } + $context = context_course::instance($courseid); + $groups=groups_get_all_groups($courseid); + //$nb_modules = count($modules); + if($display_button){ + //si trop d'étudiants on va afficher le premier groupe dans le suivi + if($this->count_students($context)>299 && count($groups)>0){ + $link_suivi = $CFG->wwwroot . "/course/format/iena/suivi_unit.php?courseid=" . $courseid . "§ionid=" . $section->id . "&groupid=".reset($groups)->id; + } + else{ + $link_suivi = $CFG->wwwroot . "/course/format/iena/suivi_unit.php?courseid=" . $courseid . "§ionid=" . $section->id . "&groupid=0"; + } + + } + + + + return $link_suivi; + } + + public function get_progress_student($courseid, $section,$course){ + global $USER; + $section_progress=false; + + //On va chercher la progression pour la section + $completion_entity = new course_format_iena_completion(); + $section_progress=$completion_entity->get_completion_by_section($section, $section->modinfo->cms, $course); + + + //var_dump($section_progress); + return $section_progress; + } + + private function count_students($context){ + $count = count_enrolled_users($context); + return $count; + } + +} +?> \ No newline at end of file diff --git a/classes/output/renderer.php b/classes/output/renderer.php new file mode 100644 index 0000000..a8e8955 --- /dev/null +++ b/classes/output/renderer.php @@ -0,0 +1,74 @@ +<?php +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see <http://www.gnu.org/licenses/>. + +namespace format_iena\output; + +use core_courseformat\output\section_renderer; + + +class renderer extends section_renderer { + + /** + * Displays the activities list in cases when course view page is not + * redirected to the activity page. + * + * @param stdClass $course record from table course + * @param bool $orphaned if false displays the main activity (if present) + * if true displays all other activities + */ + /** + * Renders the provided widget and returns the HTML to display it. + * + * Course format templates uses a similar subfolder structure to the renderable classes. + * This method find out the specific template for a course widget. That's the reason why + * this render method is different from the normal plugin renderer one. + * + * course format templatables can be rendered using the core_course/local/* templates. + * Format plugins are free to override the default template location using render_xxx methods as usual. + * + * @param \renderable $widget instance with renderable interface + * @return string the widget HTML + */ + public function render(\renderable $widget) { + global $CFG; + $fullpath = str_replace('\\', '/', get_class($widget)); + $classparts = explode('/', $fullpath); + // Strip namespaces. + $classname = array_pop($classparts); + // Remove _renderable suffixes. + $classname = preg_replace('/_renderable$/', '', $classname); + + $rendermethod = 'render_' . $classname; + if (method_exists($this, $rendermethod)) { + return $this->$rendermethod($widget); + } + // Check for special course format templatables. + if ($widget instanceof \templatable) { + // Templatables from both core_courseformat\output\xxx_format\* and format_xxx\output\xxx_format\* + // use core_crouseformat/local/xxx_format templates by default. + $corepath = 'core_courseformat\/output\/local'; + $pluginpath = 'format_.+\/output\/courseformat'; + $specialrenderers = '/^(?<componentpath>' /*. $corepath . '|'*/ . $pluginpath . ')\/(?<template>.+)$/'; // CHANGED. + $matches = null; + if (preg_match($specialrenderers, $fullpath, $matches)) { + $data = $widget->export_for_template($this); + return $this->render_from_template('format_iena/courseformat/' . $matches['template'], $data); // CHANGED. + } + } + // If nothing works, let the parent class decide. + return parent::render($widget); + } +} diff --git a/entity/course_format_iena_completion.php b/entity/course_format_iena_completion.php index 08d6cce..cb23070 100644 --- a/entity/course_format_iena_completion.php +++ b/entity/course_format_iena_completion.php @@ -23,6 +23,8 @@ * @author Thomas Fradet * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +namespace format_iena\entity; + class course_format_iena_completion { /** @@ -31,7 +33,7 @@ class course_format_iena_completion { * @param array $idsection * @return type */ - public static function get_completion_by_section($sectionnames, $idsection) { + public static function get_completion_by_sections($sectionnames, $idsection) { global $COURSE, $USER, $DB, $CFG; @@ -101,6 +103,99 @@ class course_format_iena_completion { return $progress; } + +public static function get_completion_by_section($section, $cms, $course) { + + global $USER, $DB, $CFG; + + $completion = new \completion_info($course); + if ($completion->is_enabled_for_site() == false + || $completion->has_activities() == false || $completion->is_enabled() == 0) { + return false; + } + + $sections = []; + + ///$course = course_get_format($COURSE)->get_course();// + $fastmodinfo = get_fast_modinfo($course->id); + $modinfoscms = $fastmodinfo->get_cms(); + + $hiddenbutavailable = $course->allmodulesbreadcrum == 1; + $modules = []; + //Il récupère les modules qui ne sont pas en cours de suppression, qui ont l'achèvement d'activité, qui sont visibles pour l'user, et qui dépend du paramètre "caché mais disponible" + foreach ($cms as $cm) { + if ($cm->section == $section->id) { + $module = $completion->get_data($cm, true, $USER->id); + $module->url = "$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id"; + $module->section = $cm->section; + if ( $cm->deletioninprogress == 0 && $cm->completion != 0 && $cm->uservisible && ($cm->visibleoncoursepage==1 || $hiddenbutavailable)) { + $module->name = $cm->name; + $module->url = "$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id"; + $modules[] = $module; + } + } + + } + + $totalcompleted = 0; + $totalmodules = 0; + + + $innermodules = []; + $innercompleted = 0; + foreach ($modules as $module) { + + if ($module->completionstate == 1 || $module->completionstate == 2) { + $innercompleted++; + } + $innermodules[] = $module; + + } + /*if (count($innermodules) == 0) { + $section->completion = 0; + } else { + $section->completion = number_format(100 * $innercompleted / count($innermodules), 0); + }*/ + $totalcompleted += $innercompleted; + $totalmodules += count($innermodules); + + /*foreach ($idsection as $i => $sectionid) { + $section = new StdClass(); + $section->id = $i; + $section->name = $sectionnames[$i]; + $innermodules = []; + $innercompleted = 0; + foreach ($modules as $module) { + if ($module->section == $sectionid) { + $mod = new StdClass(); + $mod->coursemoduleid = $module->coursemoduleid; + $mod->completion = $module->completionstate; + $mod->name = $module->name; + $mod->url = $module->url; + if ($mod->completion == 1 || $mod->completion == 2) { + $innercompleted++; + } + $innermodules[] = $mod; + } + } + $section->modules = $innermodules; + if (count($innermodules) == 0) { + $section->completion = 0; + } else { + $section->completion = number_format(100 * $innercompleted / count($innermodules), 0); + } + $totalcompleted += $innercompleted; + $totalmodules += count($innermodules); + array_push($sections, $section); + }*/ + if ($totalmodules == 0) { + return false; + } + + $progress = number_format(100 * $totalcompleted / $totalmodules, 0); + //$progress->sections = $sections; + return $progress; + } public static function get_completion_by_section_old() { global $COURSE, $DB, $USER; diff --git a/format.php b/format.php index fa756d7..4a23a59 100644 --- a/format.php +++ b/format.php @@ -41,7 +41,7 @@ require_once($CFG->libdir . '/completionlib.php'); $PAGE->requires->js('/course/format/iena/js/jquery.min.js'); $PAGE->requires->js('/course/format/iena/format.js'); -if ($topic = optional_param('topic', 0, PARAM_INT)) { +/*if ($topic = optional_param('topic', 0, PARAM_INT)) { $url = $PAGE->url; $url->param('section', $topic); debugging('Outdated topic param passed to course/view.php', DEBUG_DEVELOPER); @@ -60,5 +60,42 @@ if (!empty($displaysection)) { $renderer->print_single_section_page($course, null, null, null, null, $displaysection); } else { $renderer->switch_mode($course); +}*/ + + + + +// Horrible backwards compatible parameter aliasing. +if ($topic = optional_param('topic', 0, PARAM_INT)) { + $url = $PAGE->url; + $url->param('section', $topic); + debugging('Outdated topic param passed to course/view.php', DEBUG_DEVELOPER); + redirect($url); +} +// End backwards-compatible aliasing. + +// Retrieve course format option fields and add them to the $course object. +$format = course_get_format($course); + +$course = $format->get_course(); +$context = context_course::instance($course->id); + +if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) { + $course->marker = $marker; + course_set_marker($course->id, $marker); } +// Make sure section 0 is created. +course_create_sections_if_missing($course, 0); + +$renderer = $PAGE->get_renderer('format_iena'); +if (!empty($displaysection)) { + $format->set_section_number($displaysection); +} +$outputclass = $format->get_output_classname('content'); +$widget = new $outputclass($format); +echo $renderer->render($widget); + +// Include course format js module. + + diff --git a/renderer.php b/renderer.php index 6f188d9..88ac995 100644 --- a/renderer.php +++ b/renderer.php @@ -24,8 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot . '/course/format/topics/renderer.php'); -require_once($CFG->dirroot . '/course/format/iena/view/view_course_header.php'); /** * format_iena_renderer @@ -35,689 +33,3 @@ require_once($CFG->dirroot . '/course/format/iena/view/view_course_header.php'); * @author vrignaud camille * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class format_iena_renderer extends format_topics_renderer { - - /** - * start_section_list - * - * @return string - */ - // Bientôt useless. - protected function start_section_list() { - return html_writer::start_tag('ul', ['class' => 'iena-editing']); - } - - /** - * section_header - * - * @param stdclass $section - * @param stdclass $course - * @param bool $onsectionpage - * @param int $sectionreturn - * @return string - */ - // Bientôt useless. - protected function section_header($section, $course, $onsectionpage, $sectionreturn = null, $iena = false) { - global $PAGE, $CFG; - $o = ''; - $currenttext = ''; - $sectionstyle = ''; - if ($section->section != 0) { - if (!$section->visible) { - $sectionstyle = ' hidden'; - } else if (course_get_format($course)->is_section_current($section)) { - $sectionstyle = ' current'; - } - } - - if ($PAGE->user_is_editing()) { - $o .= html_writer::start_tag('li', ['id' => 'section-' . $section->section, - 'class' => 'section main clearfix' . $sectionstyle, - 'role' => 'region', 'aria-label' => get_section_name($course, $section)]); - } - - $o .= html_writer::tag('span', $this->section_title($section, $course), ['class' => 'hidden sectionname']); - - // This is were the editing menu is generated. - if ($PAGE->user_is_editing()) { - $leftcontent = $this->section_left_content($section, $course, $onsectionpage); - $o .= html_writer::tag('div', $leftcontent, ['class' => 'left side']); - $rightcontent = $this->section_right_content($section, $course, $onsectionpage); - $o .= html_writer::tag('div', $rightcontent, ['class' => 'right side']); - } - - $hasnamenotsecpg = (!$onsectionpage && ($section->section != 0 || !is_null($section->name))); - $hasnamesecpg = ($onsectionpage && ($section->section == 0 && !is_null($section->name))); - $classes = ' accesshide'; - if ($hasnamenotsecpg || $hasnamesecpg) { - $classes = ''; - } - $sectionname = html_writer::tag('span', $this->section_title($section, $course)); - if ($PAGE->user_is_editing()) { - $o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes); - } - - $context = context_course::instance($course->id); - - // Résumé de section. - if ( $section->summary != "" ) { - $o .= html_writer::start_tag('div', ['class' => 'iena-description']); - $o .= html_writer::start_tag('div', ['class' => 'small']); - - $o .= html_writer::start_tag('div', ['class' => 'iena-summary']); - $o .= $this->format_summary_text($section); - $o .= html_writer::end_tag('div'); - - $o .= html_writer::end_tag('div'); - $o .= html_writer::end_tag('div'); - $o .= html_writer::tag('a', 'Voir la description complète', ['href' => '#', 'class' => 'voir-plus']); - } - - $o .= $this->section_availability_message($section, has_capability('moodle/course:viewhiddensections', $context)); - - return $o; - } - - /** - * Add style attributes, classes (useless?), format section summary and add the hidden/restricted message - * @param StdClass $section - * @param StdClass $course - * @param bool $onsectionpage - * @param type|null $sectionreturn - * @param type|bool $iena - * @param type $groups - * @return type - */ - protected function get_section_header($section, $course, $onsectionpage, $mods, - $sectionreturn = null, $iena = false, $groups=false) { - global $PAGE, $CFG, $COURSE, $USER; - $completionentity = new course_format_iena_completion(); - $o = ''; - $currenttext = ''; - $sectionstyle = ''; - if ($section->section != 0) { - if (!$section->visible) { - $section->sectionstyle = ' hidden'; - } else if (course_get_format($course)->is_section_current($section)) { - $section->sectionstyle = ' current'; - } - } - - $section->edit = $this->section_title_without_link($section, $course); - - $hasnamenotsecpg = (!$onsectionpage && ($section->section != 0 || !is_null($section->name))); - $hasnamesecpg = ($onsectionpage && ($section->section == 0 && !is_null($section->name))); - $section->classes = ' accesshide'; - if ($hasnamenotsecpg || $hasnamesecpg) { - $section->classes = ''; - } - $section->sectionname = get_section_name($course, $section); - - $context = context_course::instance($course->id); - if ($section->summary != "") { - $section->summary = $this->format_summary_text($section); - } - - $section->messageavailability = $this->section_availability_message($section, - has_capability('moodle/course:viewhiddensections', $context)); - - // Paramètres. - $presence = ""; - $format = course_get_format($course); - - $paramsection = (object)$format->get_format_options($section); - if ($paramsection !== false) { - if (isset($paramsection->presence)) { - if ($paramsection->presence == 1) { - $section->presence = true; - $section->distance = false; - $stringdatepresence = "Le "; - } else if ($paramsection->presence == 2) { - $section->presence = false; - $section->distance = true; - $stringdatepresence = "Pour le "; - } else { - $stringdatepresence = "Le "; - $section->presence = false; - $section->distance = false; - } - } - - if (isset($paramsection->daterendu) && $paramsection->daterendu != 0) { - $section->date = date("j/m H:i", $paramsection->daterendu); - $section->date_jour = date("j/m", $paramsection->daterendu); - $section->date_heure = date("H:i", $paramsection->daterendu); - - if ($stringdatepresence) { - $section->string_date = $stringdatepresence.$section->date_jour." à ".$section->date_heure; - } else { - $section->string_date = "Le ".$section->date_jour." à ".$section->date_heure; - } - } else { - $section->date = ""; - } - } else { - $section->date = ""; - } - - // Bouton de suivi dans chaque section : si pas d'activités suivies on n'affiche pas le bouton. - if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id)) { - $ressourcesentity = new course_format_iena_section_ressources(); - $displaybutton = false; - foreach ($mods->get_cms() as $cm) { - if ($cm->completion > 0 && $cm->section == $section->id) { - $displaybutton = true; - break; - } - } - if ($displaybutton) { - // Si trop d'étudiants on va afficher le premier groupe dans le suivi. - if ($this->count_students($context) > 299 && count($groups) > 0) { - $section->link_suivi = $CFG->wwwroot . "/course/format/iena/suivi_unit.php?courseid=" . - $COURSE->id . "§ionid=" . $section->id . - "&groupid=".reset($groups)->id; - } else { - $section->link_suivi = $CFG->wwwroot . "/course/format/iena/suivi_unit.php?courseid=" - . $COURSE->id . "§ionid=" . $section->id . "&groupid=0"; - } - - } - } else { - // On va chercher la progression pour la section. - $sectionprogress = $completionentity->get_completion_by_section([$section->name], [$section->id]); - if ($sectionprogress) { - $section->progress_exists = true; - $section->section_progress = $sectionprogress->total; - } - } - return $section; - } - - // Bientôt useless. - public function get_view_iena($course, $htmlsection, $namesection, $introsection, $idsection) { - global $CFG, $COURSE, $USER; - $sectionentity = new course_format_iena_sections(); - - // Nouvelle génération du header. - $view = ""; - - require_once($CFG->dirroot . '/course/format/iena/entity/course_format_iena_completion.php'); - // Return false if completion disabled (site or course). - $cpl = course_format_iena_completion::get_completion_by_section($namesection, $idsection); - - // Passer le calcul de complétion de la classe course_format_iena_completion à part à la vue - // qui fait le header permet de ne pas récupérer deux fois les mêmes informations. - $header = new view_course_header($namesection, $idsection, $course, $cpl); - $view .= $header->get_content(); - - $i = 0; - $link = $CFG->wwwroot . "/course/format/iena/suivi_unit.php?courseid=" . $COURSE->id; - $view .= "<!-- <script defer src=\"https://use.fontawesome.com/releases/v5.0.8/js/all.js\"></script> --> - <style> - - /* - style for clean page - */ - - /* [BOOST] : course header */ - #page-header .card { - border: none; - } - #page-header .card-body { - padding-left: 0; - } - /* [BOOST] : left nav */ - #nav-drawer, - [data-region='drawer'] { - background-color: #fff; - } - #nav-drawer .list-group-item { - border: 1px solid #ffffff; - } - #nav-drawer .list-group-item:hover { - background-color: #e7e9ea; - } - #nav-drawer .list-group-item.active:hover { - color: #000000; - } - - /* [BOOST] : blocks */ - #block-region-side-pre section.block { - border: none; - } - #block-region-side-pre section.block .card-body { - padding-top: 0; - } - - /* [BOOST] : margin for ul, because ul is used to list sections */ - - ul, ul ul { - padding-left: 2.5rem; - margin-bottom: 0.5rem !important; - } - - /* style for ? */ - - #completionprogressid { - display: none; - } - - #region-main > .card { - border: none; - overflow-x: visible !important; - overflow-y: visible; - } - - #region-main > .card > .card-body { - border: none; - padding: 0; - } - - .centered { - display:flex;justify-content:center;align-items:center; - } - .contenu { - min-width: 15rem; - } - ul.bulle { - list-style: none; - padding:5%; - } - - .bulle { - list-style: none; - } - - .bulle > li { - list-style: none; - font-weight: normal; - font-size: 0.8rem; - line-height: 1rem; - padding-top: 5%; - } - </style>"; - foreach ($htmlsection as $section) { - $presence = ""; - if (!$section) { - continue; - } - $paramsection = $sectionentity->get_section_settings_by_id_section($idsection[$i]); - // Dates, modality and notification section parameters : false if not set. - if ($paramsection !== false) { - if ($paramsection->presence && $i != 0) { - if ($paramsection->presence == 1) { - $presence = "En présence"; - } else if ($paramsection->presence == 2) { - $presence = "A distance"; - } - } - - if ($paramsection->date_rendu) { - $dateup = date_create($paramsection->date_rendu); - $date = $dateup->format("j/m H:i"); - $datejour = $dateup->format("j/m"); - $dateheure = $dateup->format("H:i"); - $dateup = $dateup->getTimestamp(); - } else { - $date = ""; - } - } else { - $date = ""; - } - - $titre = $namesection[$i]; - $sectionintro = isset($introsection[$i]) ? $introsection[$i] : ''; - // If section is hidden continue. - if ($titre == null && !(has_capability('moodle/course:update', - $context = context_course::instance($COURSE->id), $USER->id))) { - $i++; - continue; - } - $view .= "<section class=\"section iena-section\" id=\"section-$i\"> - <div class=\"card card_block\"> - <div class=\"heading-iena set_height\">"; - - if ($cpl != false && count($cpl->sections[$i]->modules) > 0 - && !has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id)) { - $view .= "<div class='iena-percent set_height'>" . $cpl->sections[$i]->completion . "%</div>"; - } - - if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) { - $coursegroups = groups_get_all_groups($COURSE->id); - - $groupindicateur = 0; - - $view .= "<a href='$link§ionid=".$idsection[$i]."style='color : white'>"; - $view .= "<div onclick='change_grouplink(this)' style='display:block' class='nb_pers set_height id_groupe0'>"; - $view .= "Suivi étudiants"; - $view .= "</div>"; - $view .= "</a>"; - } - - $view .= "<div class=\"titre_section set_height\"> - <p>$titre</p> - </div> - <div class=\"right_info\"> - "; - - if ($date) { - $linkdate = $CFG->wwwroot . "/calendar/view.php?view=month&time=" . $dateup . "&course=" . $COURSE->id; - if ($presence && $presence == "A distance") { - $view .= " - <div class=\"label_item sect-date\"> - À distance - </div> - <div class=\"label_item sect-date\"> - Pour le $datejour à $dateheure - </div>"; - } else if ($presence && $presence == "En présence") { - $view .= " - <div class=\"label_item sect-date\"> - En présence - </div> - <div class=\"label_item sect-date\"> - Le $datejour à $dateheure - </div>"; - } else { - $view .= " - <div class=\"label_item sect-date\"> - Le $datejour à $dateheure - </div>"; - } - } else { - if ($presence && $presence == "A distance") { - $view .= " - <div class=\"label_item sect-date\"> - À distance - </div>"; - } else if ($presence && $presence == "En présence") { - $view .= " - <div class=\"label_item sect-date\"> - En présence - </div>"; - } - } - - $cpt = ""; - if ($cpt != "") { - $view .= " - <div class=\"titre_section set_height\"> - - "; - $view .= $cpt; - $view .= "</div> - "; - } - - $linkparam = $CFG->wwwroot . "/course/format/iena/param_section.php?courseid=" . $COURSE->id . - "§ionid=" . $idsection[$i]; - if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) { - $view .= "<div class=\"titre_section set_height\"> - <a href='$linkparam' style=\"color : white\"> - <i class=\"fa fa-cog \" aria-hidden=\"true\" ></i> - </a> - </div>"; - } - $view .= "</div> - - </div> - "; - $view .= "<div class=\"wrapper section\">"; - $view .= $sectionintro; - - $view .= "<div class=\"wrapper\"> - $section - </div > - - </div> - - </section>"; - $i++; - } - - return $view; - } - - /** - * Render le template du header avec les infos nécessaires : le progrès - * @param StdObject $course - * @param array<string> $nameSections - * @param array<int> $idSections - * @return type - */ - public function get_view_iena_new($course, $namesections, $idsections) { - global $CFG, $COURSE, $USER; - $sectionentity = new course_format_iena_sections(); - require_once($CFG->dirroot . '/course/format/iena/entity/course_format_iena_completion.php'); - // Return false if completion disabled (site or course). - $cpl = course_format_iena_completion::get_completion_by_section($namesections, $idsections); - - // Passer le calcul de complétion de la classe course_format_iena_completion à part à la vue - // qui fait le header permet de ne pas récupérer deux fois les mêmes informations. - $header = new view_course_header($namesections, $idsections, $course, $cpl); - $courseinfos = $header->create_view($cpl); - - echo $this->render_from_template('format_iena/course-header', $courseinfos); - } - - public function count_students($context) { - $count = count_enrolled_users($context); - return $count; - } - - // Seulement en mode édition - - // bientôt useless. - public function print_iena_section_pages($course) { - global $PAGE, $USER; - - $context = context_course::instance($course->id); - $course = course_get_format($course)->get_course(); - $completion = new \completion_info($course); - - $modinfo = get_fast_modinfo($course); - - if (isset($_COOKIE['sectionvisible_' . $course->id])) { - $sectionvisible = $_COOKIE['sectionvisible_' . $course->id]; - } else if ($course->marker > 0) { - $sectionvisible = $course->marker; - } else { - $sectionvisible = 1; - } - $htmlsection = false; - $namesection = []; - $idsection = false; - $introsection = false; - - // On récupère toutes les infos des sections. - foreach ($modinfo->get_section_info_all() as $section => $thissection) { - - // Nom de la section. - $htmlsection[$section] = ''; - - $numsections = course_get_format($course)->get_last_section_number(); - - // If is not editing verify the rules to display the sections. - if (!$PAGE->user_is_editing() && (!has_capability('moodle/course:viewhiddensections', - $context = context_course::instance($course->id), $USER->id))) { - - // Si la section est cachée. - if (isset($course->hiddensections) && !(int)$thissection->visible) { - continue; - } - - // Si la section n'est pas disponible. - if (!$thissection->available && !empty($thissection->availableinfo)) { - $htmlsection[$section] .= $this->section_header($thissection, $course, false, 0); - continue; - } - - if (!$thissection->uservisible || !$thissection->visible) { - $htmlsection[$section] .= $this->section_hidden($section, $course->id); - continue; - } - } - - // Affiche le nom de la section en mode propre sans lien. - $idsection[$section] = $thissection->id; - $namesection[$section] = $this->section_title_without_link($thissection, $course); - if ($PAGE->user_is_editing()) { - $htmlsection[$section] .= $this->section_header($thissection, $course, false, 0); - } - $introsection[$section] = $this->section_header($thissection, $course, false, 0, true); - if ($thissection->uservisible) { - // Ne pas enlever sinon le activity chooser ne fonctionne pas en JS. - $htmlsection[$section] .= "<div class='content'>"; - // Renvoie le lien du cours avec icone. - $htmlsection[$section] .= $this->courserenderer->course_section_cm_list($course, $thissection, 0); - $htmlsection[$section] .= $this->courserenderer->course_section_add_cm_control($course, $section, 0); - $htmlsection[$section] .= "</div>"; - } - - // Pas de footer car on ne commence par la structure par une div non fermée et que ce footer ferme par une div. - - } - - echo $this->output->heading($this->page_title(), 2, 'accesshide'); - echo $this->course_activity_clipboard($course, 0); - echo $this->start_section_list(); - - // A ce stade on à toutes les activité déja prête en HTML par contre il manque le nom des sections. - // Il se trouve dans : $thissection->name. - - // Here all activities are displayed - // If we are in edition mode then we display the "BASE" page Otherwise our model. - if (!$PAGE->user_is_editing()) { - echo $this->get_view_iena($course, $htmlsection, $namesection, $introsection, $idsection); - } else { - foreach ($htmlsection as $current) { - echo $current; - } - } - - // At this stage nothing is yet displayed except the icon: Your progress. - - // Add the + and - at the end of the page to see which part of the code to really keep. - if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) { - foreach ($modinfo->get_section_info_all() as $section => $thissection) { - if ($section <= $numsections or empty($modinfo->sections[$section])) { - continue; - } - echo $this->stealth_section_header($section); - echo $this->courserenderer->course_section_cm_list($course, $thissection, 0); - echo $this->stealth_section_footer(); - } - echo $this->end_section_list(); - echo html_writer::start_tag('div', ['id' => 'changenumsections', 'class' => 'mdl-right']); - $straddsection = get_string('addsections'); - $url = $url = new moodle_url('/course/changenumsections.php', - ['courseid' => $course->id, 'insertsection' => 0, 'increase' => false, - 'sesskey' => sesskey(), 'sectionreturn' => 0]); - $icon = $this->output->pix_icon('t/switch_plus', $straddsection); - echo html_writer::link($url, $icon . $straddsection, ['class' => 'increase-sections']); - - echo html_writer::end_tag('div'); - } else { - echo $this->end_section_list(); - } - echo html_writer::tag('style', '.course-content ul.iena #section-' . $sectionvisible . ' { display: block; }'); - } - - /** - * Fetch the course sections with infos - * @param StdObject $course - * @param bool $onsectionpage - * @return templates - */ - public function get_iena_sections($course, $editing, $onsectionpage=false) { - global $PAGE, $USER; - - $context = context_course::instance($course->id); - - $completion = new \completion_info($course); - $groups = groups_get_all_groups($course->id); - $modinfo = get_fast_modinfo($course); - - if (isset($_COOKIE['sectionvisible_' . $course->id])) { - $sectionvisible = $_COOKIE['sectionvisible_' . $course->id]; - } else if ($course->marker > 0) { - $sectionvisible = $course->marker; - } else { - $sectionvisible = 1; - } - $htmlsection = false; - $namesections = []; - $idsections = []; - $introsection = false; - - $sections = ['sections' => []]; - - foreach ($modinfo->get_section_info_all() as $section => $thissection) { - if (!$PAGE->user_is_editing() && (!has_capability('moodle/course:viewhiddensections', - $context = context_course::instance($course->id), $USER->id))) { - if (isset($course->hiddensections) && !(int)$thissection->visible) { - continue; - } - if (!$thissection->available && !empty($thissection->availableinfo)) { - $thissection = $this->get_section_header($thissection, $course, false, $modinfo, 0, $groups); - - continue; - } - if (!$thissection->uservisible || !$thissection->visible) { - $htmlsection = $this->section_hidden($section, $course->id); - - continue; - } - } - $thissection = $this->get_section_header($thissection, $course, false, $modinfo, 0, true, $groups); - - if ($thissection->uservisible) { - $thissection->resources = $this->courserenderer->course_section_cm_list($course, - $thissection, 0); - if ($editing) { - $thissection->addresources = - $this->courserenderer->course_section_add_cm_control($course, $thissection->section, 0); - $thissection->leftcontent = - $this->section_left_content($thissection, $course, $onsectionpage); - $thissection->rightcontent = - $this->section_right_content($thissection, $course, $onsectionpage); - } - } - - array_push($sections['sections'], $thissection); - array_push($namesections, $thissection->name); - array_push($idsections, $thissection->id); - } - if ($editing) { - $sections['link_add_sections'] = new moodle_url('/course/changenumsections.php', - ['courseid' => $course->id, 'insertsection' => 0, 'increase' => false, - 'sesskey' => sesskey(), 'sectionreturn' => 0]); - } - - echo $this->get_view_iena_new($course, $namesections, $idsections); - echo $this->render_from_template('format_iena/sections', $sections); - } - - // If edit mode, we use the old code that generates HTML, else we use the templates - bientôt useless. - public function switch_mode($course) { - global $PAGE, $CFG; - $context = context_course::instance($course->id); - $course = course_get_format($course)->get_course(); - if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) { - $this->get_iena_sections($course, true); - } else { - $this->get_iena_sections($course, false); - } - } - - public function display_completion($data) { - echo $this->render_from_template('format_iena/suivi', $data); - } - - public function display_table_completion($data) { - echo $this->render_from_template('format_iena/suivi-table', $data); - } - - public function display_message($data) { - echo $this->render_from_template('format_iena/send-message', $data); - } -} diff --git a/styles.css b/styles.css index c2715bd..2ece14b 100644 --- a/styles.css +++ b/styles.css @@ -106,8 +106,7 @@ ul.nav.navbar-nav.ml-auto { .set_height { /*min-height: 3rem;*/ - line-height: 2.4rem; -} + } .heading-iena { background: #D6D6D6; @@ -161,13 +160,19 @@ ul.nav.navbar-nav.ml-auto { } .titre_section { - float: left; - + display: flex; + align-items: center; + margin-left: -40px; /*padding-left: 0.8rem;*/ - padding-right: 1rem; + /*padding-right: 1rem;*/ font-size: 1.4rem; color: #1a1a1a; font-weight: 100; + /* border: 2px solid; */ + background: #2a657d; + border-radius: 50px; + margin-left: -44px; + margin-right: 4px; /*font-weight: bold;*/ } @@ -187,13 +192,12 @@ ul.nav.navbar-nav.ml-auto { background: #009186; float: right; min-width: 4rem; - padding: .6rem .6rem; - font-size: 14px ; - border-radius: 5px; + padding: 7px 20px; + font-size: 14px; + border-radius: 10px; margin-top: 0.35rem; - line-height: 0.5rem; - margin-right: .4rem; - margin-left: .4rem; + /* line-height: 0.9rem; */ + margin: 0; } .nb_pers a { color: white; @@ -204,24 +208,32 @@ ul.nav.navbar-nav.ml-auto { } .right_info { - float: right; + margin-left: auto; } -.label_item.sect-date { +.label_item.sect-date, .label_item.sect-mode { /* color: #fafafa; */ /* border: 1px solid #fafafa; */ - border-right: 1px solid white; - border-left: 1px solid white; - /* margin: .9rem .2rem .9rem .2rem; */ padding: .05rem .6rem; float: left; font-weight: 700; /* background-color: #666; */ font-size: .85rem; - line-height: 2.4rem; + /*line-height: 2.4rem;*/ color: #666; font-weight: 400; + border: 1px solid lightgrey; + border-radius: 50px; +} + +.label_item.sect-mode{ + background: #2a657d; + padding-top: 7px; + padding-bottom: 2px; + display: flex; + align-items: center; + border:none; } .label_item.sect-date.prog{ @@ -854,14 +866,14 @@ tbody th{ .iena-icon-presence::after{ content: "\f0c0"; font-family: FontAwesome; width: 100%; display: inline-block;text-align: center; - color: black; + color: white; font-size: large; } .iena-icon-distance::after{ content: "\f108"; font-family: FontAwesome; width: 100%; display: inline-block;text-align: center; - color: black; + color: white; font-size: large; } @@ -900,4 +912,18 @@ th.first-column-iena, th.second-column-iena, th.actions-column-iena, th.third-co .iena-message{ margin-top: 20px; +} + +.course-content ul.iena li.section{ + padding-top: 1rem; + padding-bottom: 1rem; +} + +.course-content ul.iena{ + padding: 0; + margin: 0; + list-style: none; +} +.course-section-header.d-flex{ + align-items: center; } \ No newline at end of file diff --git a/templates/courseformat/content.mustache b/templates/courseformat/content.mustache new file mode 100644 index 0000000..f9de5bb --- /dev/null +++ b/templates/courseformat/content.mustache @@ -0,0 +1,207 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see <http://www.gnu.org/licenses/>. +}} +{{! + @template core_courseformat/local/content + + Displays the complete course format. + + Example context (json): + { + "initialsection": { + "num": 0, + "id": 34, + "cmlist": { + "cms": [ + { + "cmitem": { + "cmformat": { + "cmname": "<a class=\"aalink\" href=\"#\"><span class=\"instancename\">Forum example</span></a>", + "hasname": "true" + }, + "id": 3, + "module": "forum", + "extraclasses": "newmessages" + } + } + ], + "hascms": true + }, + "iscurrent": true, + "summary": { + "summarytext": "Summary text!" + } + }, + "sections": [ + { + "num": 1, + "id": 35, + "header": { + "name": "Section title", + "url": "#" + }, + "cmlist": { + "cms": [ + { + "cmitem": { + "cmformat": { + "cmname": "<a class=\"aalink\" href=\"#\"><span class=\"instancename\">Another forum</span></a>", + "hasname": "true" + }, + "id": 3, + "module": "forum", + "extraclasses": "newmessages" + } + } + ], + "hascms": true + }, + "iscurrent": true, + "summary": { + "summarytext": "Summary text!" + } + }, + { + "num": 4, + "id": 36, + "header": { + "name": "Section 2 title", + "url": "#" + }, + "cmlist": { + "cms": [ + { + "cmitem": { + "cmformat": { + "cmname": "<a class=\"aalink\" href=\"#\"><span class=\"instancename\">Forum example</span></a>", + "hasname": "true" + }, + "id": 5, + "module": "forum", + "extraclasses": "newmessages" + } + } + ], + "hascms": true + }, + "iscurrent": true, + "summary": { + "summarytext": "Summary text!" + } + } + ], + "format": "topics", + "title": "Course title example", + "hasnavigation": true, + "sectionnavigation": { + "hasprevious": true, + "previousurl": "#", + "larrow": "◄", + "previousname": "Section 3", + "hasnext": true, + "rarrow": "►", + "nexturl": "#", + "nextname": "Section 5" + }, + "sectionselector": { + "hasprevious": true, + "previousurl": "#", + "larrow": "◄", + "previousname": "Section 3", + "hasnext": true, + "rarrow": "►", + "nexturl": "#", + "nextname": "Section 5", + "selector": "<select><option>Section 4</option></select>" + }, + "sectionreturn": 1, + "singlesection": { + "num": 1, + "id": 35, + "header": { + "name": "Single Section Example", + "url": "#" + }, + "cmlist": { + "cms": [ + { + "cmitem": { + "cmformat": { + "cmname": "<a class=\"aalink\" href=\"#\"><span class=\"instancename\">Assign example</span></a>", + "hasname": "true" + }, + "id": 4, + "module": "assign", + "extraclasses": "" + } + } + ], + "hascms": true + }, + "iscurrent": true, + "summary": { + "summarytext": "Summary text!" + } + } + } +}} +<div id="{{uniqid}}-course-format"> + <h2 class="accesshide">{{{title}}}</h2> + {{{completionhelp}}} + <ul class="{{format}}" data-for="course_sectionlist"> + {{#initialsection}} + {{$ format_iena/courseformat/content/section }} + {{> format_iena/courseformat/content/section }} + {{/ format_iena/courseformat/content/section }} + {{/initialsection}} + {{#sections}} + {{$ format_iena/courseformat/content/section }} + {{> format_iena/courseformat/content/section }} + {{/ format_iena/courseformat/content/section }} + {{/sections}} + </ul> + {{#hasnavigation}} + <div class="single-section"> + {{#sectionnavigation}} + {{$ core_courseformat/local/content/sectionnavigation }} + {{> core_courseformat/local/content/sectionnavigation }} + {{/ core_courseformat/local/content/sectionnavigation }} + {{/sectionnavigation}} + <ul class="{{format}}"> + {{#singlesection}} + {{$ format_iena/content/section }} + {{> format_iena/content/section }} + {{/ format_iena/content/section }} + {{/singlesection}} + </ul> + {{#sectionselector}} + {{$ core_courseformat/local/content/sectionselector }} + {{> core_courseformat/local/content/sectionselector }} + {{/ core_courseformat/local/content/sectionselector }} + {{/sectionselector}} + </div> + {{/hasnavigation}} + {{#numsections}} + {{$ core_courseformat/local/content/addsection}} + {{> core_courseformat/local/content/addsection}} + {{/ core_courseformat/local/content/addsection}} + {{/numsections}} +</div> +{{#js}} +require(['core_courseformat/local/content'], function(component) { + component.init('{{uniqid}}-course-format', {}, {{sectionreturn}}); +}); +{{/js}} diff --git a/templates/courseformat/content/section.mustache b/templates/courseformat/content/section.mustache new file mode 100644 index 0000000..8570759 --- /dev/null +++ b/templates/courseformat/content/section.mustache @@ -0,0 +1,109 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see <http://www.gnu.org/licenses/>. +}} +{{! + @template core_courseformat/local/content/section + + Displays a course section. + + Note: This template is a wrapper around the section/content template to allow course formats and theme designers to + modify parts of the wrapper without having to copy/paste the entire template. + + Example context (json): + { + "num": 3, + "id": 35, + "controlmenu": "[tools menu]", + "header": { + "name": "Section title", + "title": "<a href=\"http://moodle/course/view.php?id=5#section-0\">Section title</a>", + "url": "#", + "ishidden": true + }, + "cmlist": { + "cms": [ + { + "cmitem": { + "cmformat": { + "cmname": "<a class=\"aalink\" href=\"#\"><span class=\"instancename\">Forum example</span></a>", + "hasname": "true" + }, + "id": 3, + "module": "forum", + "anchor": "activity-3", + "extraclasses": "newmessages" + } + }, + { + "cmitem": { + "cmformat": { + "cmname": "<a class=\"aalink\" href=\"#\"><span class=\"instancename\">Assign example</span></a>", + "hasname": "true" + }, + "id": 4, + "anchor": "activity-4", + "module": "assign", + "extraclasses": "" + } + } + ], + "hascms": true + }, + "ishidden": false, + "iscurrent": true, + "currentlink": "<span class=\"accesshide\">This topic</span>", + "availability": { + "info": "<span class=\"badge badge-info\">Hidden from students</span>", + "hasavailability": true + }, + "summary": { + "summarytext": "Summary text!" + }, + "controlmenu": { + "menu": "<a href=\"#\" class=\"d-inline-block dropdown-toggle icon-no-margin\">Edit<b class=\"caret\"></b></a>", + "hasmenu": true + }, + "cmcontrols": "[Add an activity or resource]", + "iscoursedisplaymultipage": true, + "sectionreturnid": 0, + "contentcollapsed": false, + "insertafter": true, + "numsections": 42, + "sitehome": false, + "highlightedlabel" : "Highlighted" + } +}} +<li id="section-{{num}}" + class="section course-section main {{#onlysummary}} section-summary {{/onlysummary}} clearfix + {{#ishidden}} hidden {{/ishidden}} {{#iscurrent}} current {{/iscurrent}} + {{#isstealth}} orphaned {{/isstealth}}" + data-sectionid="{{num}}" + data-sectionreturnid="{{sectionreturnid}}" + data-for="section" + data-id="{{id}}" + data-number="{{num}}" +> + + <div class="course-section-header d-flex" + data-for="section_title" + data-id="{{id}}" + data-number="{{num}}" + > + {{$ format_iena/courseformat/content/section/content }} + {{> format_iena/courseformat/content/section/content }} + {{/ format_iena/courseformat/content/section/content }} + </div> +</li> diff --git a/templates/courseformat/content/section/content.mustache b/templates/courseformat/content/section/content.mustache new file mode 100644 index 0000000..2df530d --- /dev/null +++ b/templates/courseformat/content/section/content.mustache @@ -0,0 +1,160 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see <http://www.gnu.org/licenses/>. +}} +{{! + @template core_courseformat/local/content/section/content + + The internal content of a section. + + Example context (json): + { + "num": 3, + "id": 35, + "controlmenu": "[tools menu]", + "header": { + "name": "Section title", + "title": "<a href=\"http://moodle/course/view.php?id=5#section-0\">Section title</a>", + "url": "#", + "ishidden": true + }, + "cmlist": { + "cms": [ + { + "cmitem": { + "cmformat": { + "cmname": "<a class=\"aalink\" href=\"#\"><span class=\"instancename\">Forum example</span></a>", + "hasname": "true" + }, + "id": 3, + "module": "forum", + "anchor": "activity-3", + "extraclasses": "newmessages" + } + }, + { + "cmitem": { + "cmformat": { + "cmname": "<a class=\"aalink\" href=\"#\"><span class=\"instancename\">Assign example</span></a>", + "hasname": "true" + }, + "id": 4, + "anchor": "activity-4", + "module": "assign", + "extraclasses": "" + } + } + ], + "hascms": true + }, + "ishidden": false, + "iscurrent": true, + "currentlink": "<span class=\"accesshide\">This topic</span>", + "availability": { + "info": "<span class=\"badge badge-info\">Hidden from students</span>", + "hasavailability": true + }, + "summary": { + "summarytext": "Summary text!" + }, + "controlmenu": { + "menu": "<a href=\"#\" class=\"d-inline-block dropdown-toggle icon-no-margin\">Edit<b class=\"caret\"></b></a>", + "hasmenu": true + }, + "cmcontrols": "[Add an activity or resource]", + "iscoursedisplaymultipage": true, + "sectionreturnid": 0, + "contentcollapsed": false, + "insertafter": true, + "numsections": 42, + "sitehome": false, + "highlightedlabel" : "Highlighted" + } +}} +{{#singleheader}} +{{$ format_iena/courseformat/content/section/header }} + {{> format_iena/courseformat/content/section/header }} +{{/ format_iena/courseformat/content/section/header }} +{{/singleheader}} +{{#header}} +{{$ format_iena/courseformat/content/section/header }} + {{> format_iena/courseformat/content/section/header }} +{{/ format_iena/courseformat/content/section/header }} +{{/header}} +{{#restrictionlock}} + <div class="align-self-center ml-2"> + {{#pix}}t/unlock, core{{/pix}} + </div> +{{/restrictionlock}} +<div data-region="sectionbadges" class="sectionbadges d-flex align-items-center"> + {{$ core_courseformat/local/content/section/badges }} + {{> core_courseformat/local/content/section/badges }} + {{/ core_courseformat/local/content/section/badges }} +</div> +{{#collapsemenu}} +<div class="flex-fill d-flex justify-content-end mr-2 align-self-start mt-2"> + <a + id="collapsesections" + class="section-collapsemenu" + href="#" + aria-expanded="true" + role="button" + data-toggle="toggleall" + > + <span class="collapseall text-nowrap">{{#str}}collapseall{{/str}}</span> + <span class="expandall text-nowrap">{{#str}}expandall{{/str}}</span> + </a> + </div> +{{/collapsemenu}} +{{#controlmenu}} + {{$ core_courseformat/local/content/section/controlmenu }} + {{> core_courseformat/local/content/section/controlmenu }} + {{/ core_courseformat/local/content/section/controlmenu }} +{{/controlmenu}} +</div> +<div id="coursecontentcollapse{{num}}" + class="content {{^iscoursedisplaymultipage}} + {{^sitehome}}course-content-item-content collapse {{^contentcollapsed}}show{{/contentcollapsed}}{{/sitehome}} + {{/iscoursedisplaymultipage}}"> + <div class="{{#hasavailability}}description{{/hasavailability}} my-3" data-for="sectioninfo"> + {{#summary}} + {{$ core_courseformat/local/content/section/summary }} + {{> core_courseformat/local/content/section/summary }} + {{/ core_courseformat/local/content/section/summary }} + {{/summary}} + {{#availability}} + {{$ core_courseformat/local/content/section/availability }} + {{> core_courseformat/local/content/section/availability }} + {{/ core_courseformat/local/content/section/availability }} + {{/availability}} +</div> +{{#cmsummary}} + {{$ core_courseformat/local/content/section/cmsummary }} + {{> core_courseformat/local/content/section/cmsummary }} + {{/ core_courseformat/local/content/section/cmsummary }} +{{/cmsummary}} +{{#cmlist}} + {{$ core_courseformat/local/content/section/cmlist }} + {{> core_courseformat/local/content/section/cmlist }} + {{/ core_courseformat/local/content/section/cmlist }} +{{/cmlist}} +{{{cmcontrols}}} +{{#insertafter}} + {{#numsections}} + {{$ core_courseformat/local/content/addsection}} + {{> core_courseformat/local/content/addsection}} + {{/ core_courseformat/local/content/addsection}} + {{/numsections}} +{{/insertafter}} diff --git a/templates/courseformat/content/section/header.mustache b/templates/courseformat/content/section/header.mustache new file mode 100644 index 0000000..bd6780b --- /dev/null +++ b/templates/courseformat/content/section/header.mustache @@ -0,0 +1,105 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see <http://www.gnu.org/licenses/>. +}} +{{! + @template core_courseformat/local/content/section/header + + Displays a course section header. + + Example context (json): + { + "id": 123, + "name": "Section title", + "title": "<a href=\"http://moodle/course/view.php?id=5#section-0\">Section title</a>", + "url": "#", + "headerdisplaymultipage": true, + "editing": 0 + } +}} +{{#headerdisplaymultipage}} + <h3 id="sectionid-{{id}}-title" class="sectionname"> + {{{title}}} + </h3> +{{/headerdisplaymultipage}} +{{^headerdisplaymultipage}} + {{#sitehome}} + <h2 id="sectionid-{{id}}-title" class="sectionname"> + {{{title}}} + </h2> + {{/sitehome}} + {{^sitehome}} + {{#mode}} + + {{#presence}} + <div class="titre_section set_height"> + <div class="label_item sect-mode"> + <span class="iena-icon-presence" data-toggle="tooltip" data-placement="top" title="{{#str}} in_presence, format_iena {{/str}}"></span> + </div> + </div> + {{/presence}} + {{#distance}} + <div class="titre_section set_height"> + <div class="label_item sect-mode"> + <span class="iena-icon-distance" data-toggle="tooltip" data-placement="top" title="{{#str}} not_presence, format_iena {{/str}}"></span> + </div> + </div> + {{/distance}} + {{/mode}} + <div class="d-flex align-items-start position-relative"> + <a role="button" data-toggle="collapse" + href="#coursecontentcollapse{{num}}" + id="collapssesection{{num}}" + aria-expanded="{{^contentcollapsed}}true{{/contentcollapsed}}{{#contentcollapsed}}false{{/contentcollapsed}}" + aria-controls="coursecontentcollapse{{num}}" + class="btn btn-icon mr-1 icons-collapse-expand justify-content-center + {{^editing}} stretched-link {{/editing}} + {{#contentcollapsed}} collapsed {{/contentcollapsed}}" + aria-label="{{name}}"> + <span class="expanded-icon icon-no-margin p-2" title="{{#str}} collapse, core {{/str}}"> + {{#pix}} t/expandedchevron, core {{/pix}} + </span> + <span class="collapsed-icon icon-no-margin p-2" title="{{#str}} expand, core {{/str}}"> + <span class="dir-rtl-hide">{{#pix}} t/collapsedchevron, core {{/pix}}</span> + <span class="dir-ltr-hide">{{#pix}} t/collapsedchevron_rtl, core {{/pix}}</span> + </span> + </a> + <h3 class="sectionname course-content-item d-flex align-self-stretch align-items-center mb-0" + id="sectionid-{{id}}-title" data-for="section_title" data-id="{{id}}" data-number="{{num}}"> + {{{title}}} + </h3> + </div> + + + <div class="right_info"> + + {{#date}} + <div class="label_item sect-date"> + {{date}} + </div> + {{/date}} + + {{#link_suivi}} + <a href='{{link_suivi}}' style='color : white'> + <div style="display:block;" class="nb_pers set_height id_groupe0">Suivi étudiant</div> + + </a> + {{/link_suivi}} + {{#progress}} + <div class="label_item sect-date prog" >{{progress}}%</div> + {{/progress}} + </div> + {{/sitehome}} +{{/headerdisplaymultipage}} diff --git a/version.php b/version.php index 946ae9d..79762e5 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022000001; +$plugin->version = 2023000001; $plugin->requires = 2014111000; $plugin->component = 'format_iena'; $plugin->release = "1.0"; -- GitLab