diff --git a/entity/course_format_iena_sections.php b/entity/course_format_iena_sections.php index 47b5fac704f96121116f377800ec8b453ab488af..16432599bae9f5f190003a89510eade6947e02e8 100644 --- a/entity/course_format_iena_sections.php +++ b/entity/course_format_iena_sections.php @@ -33,14 +33,13 @@ public $name; /** @var int id of course */ public $id_course; - /** @var block_career_ressources array<Ressource> ressources */ - public $ressources; + /** @var block_career_resources array<Ressource> resources */ + public $resources; /** @var date */ public $date; /** @var string availability */ public $availability; - /** @var array section */ - public $sections; + public $visibility; /** @@ -195,19 +194,19 @@ /** * @return mixed */ - public function getRessources() + public function getResources() { - return $this->ressources; + return $this->resources; } /** - * @param mixed $ressources + * @param mixed $resources * * @return self */ - public function setRessources($ressources) + public function setResources($resources) { - $this->ressources = $ressources; + $this->resources = $resources; return $this; } @@ -252,23 +251,35 @@ return $this; } + + /** * @return mixed */ - public function getSections() + public function getVisibility() { - return $this->sections; + return $this->visibility; } /** - * @param mixed $sections + * @param mixed $visibility * * @return self */ - public function setSections($sections) + public function setVisibility($visibility) { - $this->sections = $sections; + $this->visibility = $visibility; return $this; } + + + public function toArray(){ + $vars = []; + foreach($this as $varName => $varValue) { + $vars[$varName] = $varValue; + } + + return $vars; + } } diff --git a/lib.php b/lib.php index ac15dea8d3c5672bf2a07a4ae124d4900fb0858d..a6a54f0d6ea488f8841b0daf5caa7d9ad54262d0 100644 --- a/lib.php +++ b/lib.php @@ -82,6 +82,131 @@ } return $courseformatoptions; } + + /** + * Definitions of the additional options that this course format uses for section + * + * See {@link format_base::course_format_options()} for return array definition. + * + * Additionally section format options may have property 'cache' set to true + * if this option needs to be cached in {@link get_fast_modinfo()}. The 'cache' property + * is recommended to be set only for fields used in {@link format_base::get_section_name()}, + * {@link format_base::extend_course_navigation()} and {@link format_base::get_view_url()} + * + * For better performance cached options are recommended to have 'cachedefault' property + * Unlike 'default', 'cachedefault' should be static and not access get_config(). + * + * Regardless of value of 'cache' all options are accessed in the code as + * $sectioninfo->OPTIONNAME + * where $sectioninfo is instance of section_info, returned by + * get_fast_modinfo($course)->get_section_info($sectionnum) + * or get_fast_modinfo($course)->get_section_info_all() + * + * All format options for particular section are returned by calling: + * $this->get_format_options($section); + * + * @param bool $foreditform + * @return array + */ + public function section_format_options($foreditform = false) { + global $CFG; + static $courseformatoptions = false; + + if ($courseformatoptions === false) { + $courseformatoptions = array( + + 'presence'=>array( + 'label'=>"Présence", + 'type'=>PARAM_INT + ) + ); + } + if ($foreditform) { + + + $courseformatoptionsedit = array( + /*'periodduration' => array( + 'label' => 'poury', + + 'element_attributes' => array( + + array(0=>'hello'), + array(1=>'hghgh') + ), + 'element_type' => 'advcheckbox', + ), + 'presence'=>array( + 'label' => 'Modalité', + 'element_type' => 'select', + 'element_attributes' => array ( + array ( + 0 => 'Aucune', + 1 => 'Présentiel', + 2 => 'À distance', + + ) + ))*/ + ); + $courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit); + } + return $courseformatoptions; + } + + + + /** + * Adds format options elements to the course/section edit form. + * + * This function is called from {@link course_edit_form::definition_after_data()}. + * + * @param MoodleQuickForm $mform form the elements are added to. + * @param bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form. + * @return array array of references to the added form elements. + */ + public function create_edit_form_elements(&$mform, $forsection = false) { + global $COURSE; + global $PAGE; + $elements = parent::create_edit_form_elements($mform, $forsection); + echo "\n hksddkh \n <br> <br> blabla <br>"; + if ($forsection) { + $mform->removeElement('presence', false); + $sectionclass = new stdClass(); + $sectionclass->id=optional_param('id', 0, PARAM_INT); + + $section_config=$this->get_format_options($sectionclass); + + $radioarray=array(); + $radioarray[] = $mform->createElement('radio', 'modalite', '', 'Distance', 2); + $radioarray[] = $mform->createElement('radio', 'modalite', '', 'Présentiel', 1); + $radioarray[] = $mform->createElement('radio', 'modalite', '', 'Aucune', 0); + $mform->addGroup($radioarray, 'Modalité', 'Modalité', array(' '), false); + + + if($section_config && $section_config['presence']){ + $mform->setDefault('modalite', $section_config['presence']); + } + + + //$mform->setType('numsections', PARAM_INT); + + //array_unshift($elements, $element); + } + + // Re-order things. + /*if ($forsection) { + $mform->insertElementBefore($mform->removeElement('automaticenddate', false), 'idnumber'); + $mform->disabledIf('enddate', 'automaticenddate', 'checked'); + foreach ($elements as $key => $element) { + if ($element->getName() == 'automaticenddate') { + unset($elements[$key]); + } + } + $elements = array_values($elements); + }*/ + + return $elements; + } + /** * get_view_url @@ -150,3 +275,5 @@ return course_get_format($section->course)->inplace_editable_update_section_name($section, $itemtype, $newvalue); } } + + diff --git a/renderer.php b/renderer.php index b8311e7f061ed47650c682830da470cd75c99534..f41649f1842135e56218bedad7bd6b0f99ce554b 100644 --- a/renderer.php +++ b/renderer.php @@ -126,9 +126,20 @@ class format_iena_renderer extends format_topics_renderer{ return $o; } + + /** + * Add style attributes, classes (useless?), format section summary and add the hidden/restricted message + * @param type $section + * @param type $course + * @param type $onsectionpage + * @param type|null $sectionreturn + * @param type|bool $iena + * @return type + */ protected function get_section_header($section, $course, $onsectionpage, $sectionreturn = null, $iena = false){ - echo "ON PASSE ICI"; - global $PAGE, $CFG; + + global $PAGE, $CFG, $COURSE, $USER; + $section_entity = new course_format_iena_sections(); $o = ''; $currenttext = ''; $sectionstyle = ''; @@ -156,6 +167,47 @@ class format_iena_renderer extends format_topics_renderer{ $section->messageavailability= $this->section_availability_message($section, has_capability('moodle/course:viewhiddensections', $context)); + + /* Paramètres */ + $presence = ""; + + $param_section = $section_entity->get_section_settings_by_id_section($section->id); + if ($param_section !== false) { + if ($param_section->presence) { + if ($param_section->presence == 1) { + $section->presence = "En présence"; + $string_date_presence="Pour le "; + } else if ($param_section->presence == 2) { + $section->presence = "À distance"; + $string_date_presence="Le "; + } + } + + if ($param_section->date_rendu) { + $section->dateUp = date_create($param_section->date_rendu); + $section->date = $section->dateUp->format("j/m H:i"); + $section->date_jour = $section->dateUp->format("j/m"); + $section->date_heure = $section->dateUp->format("H:i"); + $section->dateUp = $section->dateUp->getTimestamp(); + if($string_date_presence){ + $section->string_date=$string_date_presence.$section->date_jour." à ".$section->date_heure; + } + else{ + $section->string_date="Le ".$section->date_jour." à ".$section->date_heure; + } + } else { + $section->date = ""; + } + } else { + $section->date = ""; + } + + if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id)) { + $section->link_param = $CFG->wwwroot . "/course/format/iena/param_section.php?courseid=" . $COURSE->id . "§ionid=" . $section->id; + + } + + return $section; } @@ -808,7 +860,7 @@ class format_iena_renderer extends format_topics_renderer{ return $view; } - public function get_view_iena_new($course, $htmlsection, $nameSection, $introSection, $idSection) + public function get_view_iena_new($course,$nameSection, $idSection) { global $CFG, $COURSE, $USER; $section_entity = new course_format_iena_sections(); @@ -823,10 +875,17 @@ class format_iena_renderer extends format_topics_renderer{ /* 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(); + $course_infos= $header->create_view($cpl); + + + echo $this->render_from_template('format_iena/course-header', $course_infos); $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> @@ -911,146 +970,7 @@ class format_iena_renderer extends format_topics_renderer{ padding-top: 5%; } </style>"; - foreach ($htmlsection as $section) { - $presence = ""; - if (!$section) { - continue; - } - $param_section = $section_entity->get_section_settings_by_id_section($idSection[$i]); - // dates, modality and notification section parameters : false if not set. - if ($param_section !== false) { - if ($param_section->presence && $i != 0) { - if ($param_section->presence == 1) { - $presence = "En présence"; - } else if ($param_section->presence == 2) { - $presence = "A distance"; - } - } - - if ($param_section->date_rendu) { - $dateUp = date_create($param_section->date_rendu); - $date = $dateUp->format("j/m H:i"); - $date_jour = $dateUp->format("j/m"); - $date_heure = $dateUp->format("H:i"); - $dateUp = $dateUp->getTimestamp(); - } else { - $date = ""; - } - } else { - $date = ""; - } - - $titre = $nameSection[$i]; - $sectionIntro = $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) { - - - $course_groups = groups_get_all_groups($COURSE->id); - $group_indicateur = 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) { - $link_date = $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 $date_jour à $date_heure - </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 $date_jour à $date_heure - </div>"; - } else { - $view .= " - <div class=\"label_item sect-date\"> - Le $date_jour à $date_heure - </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 = $this->get_render_competences($idSection[$i]); - $cpt = ""; - if ($cpt != "") { - $view .= " - <div class=\"titre_section set_height\"> - - "; - $view .= $cpt; - $view .= "</div> - "; - } - - $link_param = $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='$link_param' 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; + } @@ -1231,19 +1151,19 @@ class format_iena_renderer extends format_topics_renderer{ $sectionvisible = 1; } $htmlsection = false; - $nameSection = []; - $idSection = false; + $nameSections = []; + $idSections = []; $introSection = false; - echo "hello byuddy"; + $sections=['sections'=>[]]; + //var_dump($modinfo->get_section_info_all()); 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; @@ -1255,7 +1175,7 @@ class format_iena_renderer extends format_topics_renderer{ continue; } if (!$thissection->uservisible || !$thissection->visible) { - $htmlsection[$section] .= $this->section_hidden($section, $course->id); + $htmlsection = $this->section_hidden($section, $course->id); continue; } @@ -1269,8 +1189,12 @@ class format_iena_renderer extends format_topics_renderer{ } array_push($sections['sections'], $thissection); + array_push($nameSections, $thissection->name); + array_push($idSections, $thissection->id); } + + echo $this->get_view_iena_new($course, $nameSections, $idSections); echo $this->render_from_template('format_iena/sections', $sections); //On récupère toutes les infos des sections /*foreach ($modinfo->get_section_info_all() as $section => $thissection) { diff --git a/styles.css b/styles.css index f67e2cde11217dd1d7cdf42d324b7acb4f6b58ac..d333cdcd3eac249a6b0599fa174f3e1b36e2bc80 100644 --- a/styles.css +++ b/styles.css @@ -102,7 +102,7 @@ ul.nav.navbar-nav.ml-auto { .set_height { /*min-height: 3rem;*/ - line-height: 0.7rem; + line-height: 2.4rem; } .heading-iena { @@ -152,8 +152,8 @@ ul.nav.navbar-nav.ml-auto { .titre_section { float: left; - padding-top: 1rem; - padding-left: 0.8rem; + + /*padding-left: 0.8rem;*/ padding-right: 1rem; font-size: 1.4rem; color: #1a1a1a; @@ -161,6 +161,17 @@ ul.nav.navbar-nav.ml-auto { /*font-weight: bold;*/ } +.titre_section p { + margin-bottom: 0; + display: inline-block; + padding-left: 0.5rem; +} + +.titre_section .label_item.sect-date{ + display: inline-block; + border-left: none; +} + .nb_pers { text-align: center; background: #009186; @@ -185,17 +196,20 @@ ul.nav.navbar-nav.ml-auto { } .label_item.sect-date { - color: #fafafa; - border: 1px solid #fafafa; - border-radius: .15rem; - /* margin: 0.9rem; */ - margin: 0.9rem 0.2rem 0.9rem 0.2rem; - /* margin-right: 0; */ - padding: .05rem .6rem; - float: left; - font-weight: 700; - background-color: #666; - font-size: 0.85rem; + /* color: #fafafa; */ + /* border: 1px solid #fafafa; */ + border-right: 1px solid white; + border-left: 1px solid white; + border-radius: .15rem; + /* margin: .9rem .2rem .9rem .2rem; */ + padding: .05rem .6rem; + float: left; + font-weight: 700; + /* background-color: #666; */ + font-size: .85rem; + line-height: 2.4rem; + color: #666; + font-weight: 400; } .iena-description { @@ -301,6 +315,25 @@ ul.nav.navbar-nav.ml-auto { /* Progress detail */ +.iean-progress-header .iena-progress-label, .iean-progress-header .progress-wrapper{ + display: inline-block; + +} + +.iean-progress-header .progress{ + width: 200px; +} + + + + +.iena-h-prog-sect{ + margin-left: 10px; + padding-left: 20px; + margin-top: 20px; + border-left: 1px solid lightgrey; +} + .iena-h-prog-sect h2 { margin-bottom: 1rem; } @@ -314,25 +347,31 @@ ul.nav.navbar-nav.ml-auto { /* Section progression name and % */ .btn-outline-success.iena-h-prog-name { color: #009085; - border-color: #009085; - border-radius: 0.15rem; - max-width: 300px; - overflow: hidden; - position: relative; - margin-bottom: 0.5rem; - float: left; - clear: left; - min-width: 300px; - text-align: left; + border-color: #009085; + border-radius: .15rem; + max-width: 300px; + display: block; + /* overflow: hidden; */ + /* position: relative; */ + /* margin-bottom: .5rem; */ + /* float: left; */ + /* clear: left; */ + min-width: 300px; + text-align: left; +} +.iena-h-prog-name{ + display: block; + font-size: large; } .btn-outline-success.iena-h-prog-name:before { - content:''; + /*content:''; width:100%; height:100%; position:absolute; left:0; top:0; background:linear-gradient(90deg, rgba(255, 255, 255, 0) 245px, rgba(255, 255, 255, 1) 289px); + */ } .btn-outline-success.iena-h-prog-name:hover, .btn-outline-success.iena-h-prog-name:active { @@ -350,15 +389,40 @@ ul.nav.navbar-nav.ml-auto { border-color: #009085 !important; } +.details-progress .section-progress{ + margin-bottom: 1rem; +} + + +.details-progress .section-progress .progress-wrapper{ + width: 300px; + display: inline-block; +} + +.details-progress .section-progress .progress-wrapper .progress{ + height: 0.5rem; +} + +.details-progress .section-progress .progress-wrapper .iena-prog-label{ + font-size: small; +} + /* Represent a course module link as a bullet */ .iena-h-prog-mod-item { border-radius: 1.5rem; - float: left; - min-width: 1.5rem; - min-height: 1.5rem; - position: relative; - margin-left: 0.25rem; - margin-top: 0.4rem; + display: inline-block; + line-height: 36px; + vertical-align: top; + /* float: left; */ + min-width: 1.5rem; + display: inline-block; + /* height: 24px; */ + /* width: 24px; */ + min-height: 1.5rem; + position: relative; + margin-left: .25rem; + margin: auto; + /* margin-top: .4rem; } /* .iena-h-prog-mod-item.iena-g-prog-done { background-color: #009085; @@ -423,6 +487,9 @@ ul.nav.navbar-nav.ml-auto { } + #title-summary-iena{ + padding-left: 0; + } #title-summary-iena #summary-collapse.collapse:not(.show) { display: block; diff --git a/templates/course-header.mustache b/templates/course-header.mustache index 0f6686d9f0ae4629b83caaeea040349f85467153..8b40b4999ff59029e4579005a5d2857acdca0d3d 100644 --- a/templates/course-header.mustache +++ b/templates/course-header.mustache @@ -1,3 +1,49 @@ <div class="iena-course-header"> - {{#student}}<div class="iena-course-header-bottom" id="iena-h-bottom" aria-expanded="false" style="display: none"></div> + {{#student}} + <!--<a href="#" class="btn btn-outline-primary iena-course-h-total" onclick="iena_toggle_course_header(event)">Ma progression : {{progress_total}}%</a>--> + <div class="iean-progress-header"> + <h5 class="iena-progress-label"> Ma progression dans le cours : </h5> + <div class="progress-wrapper"> + <div class="progress"> + <div class="progress-bar" role="progressbar" aria-valuenow="{{progress_total}}" style="width:{{progress_total}}%" aria-valuemin="0" aria-valuemax="100"> {{progress_total}}%</div> + + </div> + </div> + <a class="iena-progress-label" data-toggle="collapse" href="#progress-details" role="button" aria-expanded="false" aria-controls="progress-details"> <i class="fa fa-search-plus"></i> </a> + </div> + <div class="iena-course-header-bottom" id="iena-h-bottom" aria-expanded="false" style=""> + <div class="iena-h-prog-sect collapse" id="progress-details"> + <div class="details-progress"> + {{#progress_sections}} + <div class="section-progress"> + <a href="#section-{{id}}" class="iena-h-prog-name">{{name}}</a> + <div class="progress-wrapper"> + <div class="progress"> + <div class="progress-bar" role="progressbar" aria-valuenow="{{completion}}" style="width:{{completion}}%" aria-valuemin="0" aria-valuemax="100"></div> + + </div> + <div class="iena-prog-label">{{completion}}%</strong> terminé</div> + </div> + {{#modules}} + + <a href="{{url}}" class="iena-h-prog-mod-item iena-g-prog-{{completion}}"><span>{{name}}</span></a> + {{/modules}} + + </div> + {{/progress_sections}} + </div> + </div> + </div> + {{/student}} + + + <div class="iena-course-header-bottom" id="" aria-expanded="false"> + <div id="title-summary-iena" class="container"> + <h3> + {{# str }} aboutcourse, format_iena {{/ str}} + </h3> + <div class="collapse" id="summary-collapse" aria-expanded="false">{{{ summary }}}</div> + <a role="button" class="collapsed" data-toggle="collapse" href="#summary-collapse" aria-expanded="false" aria-controls="summary-collapse">Afficher / Masquer les infos du cours</a> + </div> + </div> </div> \ No newline at end of file diff --git a/templates/section.mustache b/templates/section.mustache index e76cddc6e0e8a2cf9c19b8e797c9bcd0dd62bbde..ed51bec279fbc36d9a9785c14378734409bf211c 100644 --- a/templates/section.mustache +++ b/templates/section.mustache @@ -1,8 +1,28 @@ <section class="section iena-section" id="{{section_cpt}}"> <div class="card card_block"> <div class="heading-iena set_height"> - <div class="titre_section set_height"><p>{{sectionname}}</p></div> - <div class="right-info"></div> + <div class="titre_section set_height"> + {{#presence}} + <div class="label_item sect-date"> + {{presence}} + </div> + {{/presence}} + <p>{{sectionname}}</p></div> + <div class="right_info"> + + {{#string_date}} + <div class="label_item sect-date"> + {{string_date}} + </div> + {{/string_date}} + {{#link_param}} + <div class="titre_section set_height"> + <a href={{link_param}} style="color : white"> + <i class="fa fa-cog " aria-hidden="true" ></i> + </a> + </div> + {{/link_param}} + </div> </div> <div class="wrapper section"> diff --git a/view/view_course_header.php b/view/view_course_header.php index 65a345dbe0e16234a9410d775f5ec357e56b8b67..c85fd8b7c37e8c27d6d0dc34ca95730400c38e92 100644 --- a/view/view_course_header.php +++ b/view/view_course_header.php @@ -12,10 +12,10 @@ class view_course_header { $this->idSection = $idSection; // $this->completion_total = $completion_total; $this->course = $course; - $this->create_view($progress); + //$this->create_view($progress); } - private function create_view($progress) { + public function create_view($progress) { // $this->get_progress_bis($this->section_names, $this->idSection, $this->course); @@ -28,7 +28,8 @@ class view_course_header { // 'attendance' => $this->get_attendance_link() ]; - $this->set_html($infos); + return $this->get_data($infos); + //$this->set_html($infos); } private function get_progress_bis($section_names, $idSection, $course) { @@ -40,19 +41,6 @@ class view_course_header { return false; } - // $modules = $DB->get_records_sql('SELECT cmc.id, cmc.coursemoduleid, cmc.userid, cmc.completionstate, cm.section - // FROM {course_modules_completion} as cmc - // inner join {course_modules} as cm on cm.id = cmc.coursemoduleid - // inner join {user} as u on u.id = cmc.userid - // inner join {modules} as m on m.id = cm.module - // where cm.course = ? and cm.deletioninprogress = 0 - // and cmc.userid = ? - // order by section, coursemoduleid asc', array($course->id, $USER->id)); - - // echo "<pre>"; - // var_dump($modules); - // echo "</pre>"; - $sections = []; $fast_modinfo = get_fast_modinfo($course->id); @@ -488,6 +476,46 @@ class view_course_header { $this->_content .= '</div>'; // end of : iena course header } + private function get_data($infos){ + global $CFG, $COURSE, $USER; + $course_data=[]; + $course_data['student']=false; + //if user is a student + if(!has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id)){ + $course_data['progress_total']=$infos['progress']->total; + + + + // PROGRESS TOTAL : total progression percentage + if ( $infos['progress'] !== false && $infos['progress']->total !== false ) { + + + $course_data['progress_sections']=[]; + // section progress total + foreach ($infos['progress']->sections as $section) { + if ( count($section->modules) > 0 ) { + array_push($course_data['progress_sections'], $section); + + /*foreach ($section->modules as $module) { + $this->_content .= '<a href="'.$module->url.'" class="iena-h-prog-mod-item iena-g-prog-'.$module->completion.'"><span>'.$module->name.'</span></a>'; + }*/ + } + } + + } + else { + + } + + $course_data['student']=true; + + } + + $course_data['summary']=$COURSE->summary; + + return $course_data; + } + public function get_content() { return $this->_content; }