diff --git a/course-header.css b/course-header.css index 146852f40e2465e9cb71daf7fa527c451031455d..3f667a34c7a2b37a62c37cd1e39749570c0e3f7c 100644 --- a/course-header.css +++ b/course-header.css @@ -212,4 +212,3 @@ - diff --git a/entity/course_format_iena_sections.php b/entity/course_format_iena_sections.php index 1fa6c991d144da72862f842b248dcb113bd595cf..47b5fac704f96121116f377800ec8b453ab488af 100644 --- a/entity/course_format_iena_sections.php +++ b/entity/course_format_iena_sections.php @@ -35,6 +35,12 @@ public $id_course; /** @var block_career_ressources array<Ressource> ressources */ public $ressources; + /** @var date */ + public $date; + /** @var string availability */ + public $availability; + /** @var array section */ + public $sections; /** @@ -125,4 +131,144 @@ return $requete; } - } + + /** + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * @param mixed $id + * + * @return self + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * @return mixed + */ + public function getName() + { + return $this->name; + } + + /** + * @param mixed $name + * + * @return self + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * @return mixed + */ + public function getIdCourse() + { + return $this->id_course; + } + + /** + * @param mixed $id_course + * + * @return self + */ + public function setIdCourse($id_course) + { + $this->id_course = $id_course; + + return $this; + } + + /** + * @return mixed + */ + public function getRessources() + { + return $this->ressources; + } + + /** + * @param mixed $ressources + * + * @return self + */ + public function setRessources($ressources) + { + $this->ressources = $ressources; + + return $this; + } + + /** + * @return mixed + */ + public function getDate() + { + return $this->date; + } + + /** + * @param mixed $date + * + * @return self + */ + public function setDate($date) + { + $this->date = $date; + + return $this; + } + + /** + * @return mixed + */ + public function getAvailability() + { + return $this->availability; + } + + /** + * @param mixed $availability + * + * @return self + */ + public function setAvailability($availability) + { + $this->availability = $availability; + + return $this; + } + + /** + * @return mixed + */ + public function getSections() + { + return $this->sections; + } + + /** + * @param mixed $sections + * + * @return self + */ + public function setSections($sections) + { + $this->sections = $sections; + + return $this; + } +} diff --git a/format.php b/format.php index af89b14fd4ed8879b74242d3b4d96f838a0471a5..4c2c016bcbc6bb64357bcc98745ea42e609d9007 100644 --- a/format.php +++ b/format.php @@ -22,6 +22,8 @@ * @copyright 2018 Softia/Université lorraine * @author vrignaud camille * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * + * Point d'entrée du plugin */ defined('MOODLE_INTERNAL') || die(); @@ -61,9 +63,15 @@ course_create_sections_if_missing($course, 0); $renderer = $PAGE->get_renderer('format_iena'); if (!empty($displaysection)) { + echo "on passe là"; $renderer->print_single_section_page($course, null, null, null, null, $displaysection); } else { - $renderer->print_iena_section_pages($course); + echo "on passe plutôt là, section vide"; + + $renderer->switch_mode($course); + + + //$renderer->print_iena_section_pages($course); } // $PAGE->requires->js('/course/format/iena/js/jquery.min.js'); // $PAGE->requires->js('/course/format/iena/format.js'); diff --git a/js/groups.js b/js/groups.js index 5ee6b6c96b67ca93bdb2af3bdd6090266f8440f4..1e4f48dab6829ed35cf23a938de620ce1a9ea776 100644 --- a/js/groups.js +++ b/js/groups.js @@ -1,5 +1,6 @@ (function() { window.addEventListener('load', function() { + console.log("wtf ?") if ( typeof(Storage) !== "undefined" ) { var sel_group = document.getElementById('select-group'); var group = localStorage.getItem('iena-sel-group'); @@ -47,6 +48,7 @@ }) function set_indicateur_displays() { + console.log("display indicateur") $('.nb_pers').hide(); $('.' + $('#select-group').val()).show(); } diff --git a/lang/en/format_iena.php b/lang/en/format_iena.php index 6fee5644453c70df9a353fc09069e18ddd96ba8f..2bcfda3064113feeea69a466394689ca965c0af8 100644 --- a/lang/en/format_iena.php +++ b/lang/en/format_iena.php @@ -80,4 +80,5 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.'; $string['section'] = 'Section'; $string['hide_section'] = 'HIDE section '; $string['show_section'] = 'SHOW section '; + $string['aboutcourse'] = 'About this course'; diff --git a/lang/fr/format_iena.php b/lang/fr/format_iena.php index 3d63789aad9133ae328f8428a6deb00a44beedd3..4b7020fcac44edd2dfb787f0aff8ff9495b239ab 100644 --- a/lang/fr/format_iena.php +++ b/lang/fr/format_iena.php @@ -80,4 +80,5 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.'; $string['section'] = 'Section'; $string['hide_section'] = 'CACHER la section '; $string['show_section'] = 'MONTRER la section '; + $string['aboutcourse'] = 'À propos de ce cours'; diff --git a/renderer.php b/renderer.php index d24d8b6a7407fbc253e26e7a6d4a509885aa0764..b8311e7f061ed47650c682830da470cd75c99534 100644 --- a/renderer.php +++ b/renderer.php @@ -14,889 +14,1335 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * format_iena + * + * @package format_iena + * @category format + * @copyright 2018 Softia/Université lorraine + * @author vrignaud camille/Thomas Fradet + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +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 + * + * @package format_iena + * @category format + * @copyright 2018 Softia/Université lorraine + * @author vrignaud camille + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class format_iena_renderer extends format_topics_renderer{ + + /** - * format_iena + * start_section_list * - * @package format_iena - * @category format - * @copyright 2018 Softia/Université lorraine - * @author vrignaud camille/Thomas Fradet - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @return string */ - - 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'); - + protected function start_section_list() + { + return html_writer::start_tag('ul', ['class' => 'iena-editing']); + } + /** - * format_iena_renderer + * section_header * - * @package format_iena - * @category format - * @copyright 2018 Softia/Université lorraine - * @author vrignaud camille - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @param stdclass $section + * @param stdclass $course + * @param bool $onsectionpage + * @param int $sectionreturn + * @return string */ - class format_iena_renderer extends format_topics_renderer - { + 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'; + } elseif (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']); + 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']); + } - /** - * start_section_list - * - * @return string - */ - 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 - */ - 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'; - } elseif (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']); + $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); + } + // if ($course->showdefaultsectionname) { + // $o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes); + // } + // if (!$iena) { $o .= $sectionname; } - 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']); - } + $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)); - $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); + if ($PAGE->user_is_editing()) { + // $o .= html_writer::end_tag('li'); + } + + return $o; + } + protected function get_section_header($section, $course, $onsectionpage, $sectionreturn = null, $iena = false){ + echo "ON PASSE ICI"; + global $PAGE, $CFG; + $o = ''; + $currenttext = ''; + $sectionstyle = ''; + if ($section->section != 0) { + if (!$section->visible) { + $section->sectionstyle = ' hidden'; + } elseif (course_get_format($course)->is_section_current($section)) { + $section->sectionstyle = ' current'; } - // if ($course->showdefaultsectionname) { - // $o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes); - // } - // if (!$iena) { $o .= $sectionname; } + } + - $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']); + $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)); - $o .= html_writer::start_tag('div', ['class' => 'iena-summary']); - $o .= $this->format_summary_text($section); - $o .= html_writer::end_tag('div'); + return $section; + } - $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']); + protected function get_section_header_edit($section, $course, $onsectionpage, $sectionreturn = null, $iena = false){ + global $PAGE, $CFG; + $o = ''; + $currenttext = ''; + $sectionstyle = ''; + if ($section->section != 0) { + if (!$section->visible) { + $sectionstyle = ' hidden'; + } elseif (course_get_format($course)->is_section_current($section)) { + $sectionstyle = ' current'; } - - $o .= $this->section_availability_message($section, has_capability('moodle/course:viewhiddensections', $context)); + } + + $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']); - if ($PAGE->user_is_editing()) { - // $o .= html_writer::end_tag('li'); - } + + $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']); + - return $o; + $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)); + + $o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes); + + // if ($course->showdefaultsectionname) { + // $o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes); + // } + // if (!$iena) { $o .= $sectionname; } + + $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)); - public function get_completion_by_section($idSection) - { - global $COURSE, $USER; - $ressources_entity = new course_format_iena_section_ressources(); - $section_entity = new course_format_iena_sections(); - //$completions = $ressources_entity->get_completions_by_userid($USER->id, $COURSE->id); + if ($PAGE->user_is_editing()) { + // $o .= html_writer::end_tag('li'); + } - // list modules in a section - $modules = $ressources_entity->get_ressources_completion_on_by_id_section($idSection); - $nb_modules = count($modules); - if ($nb_modules == 0) { - return array($nb_modules, 999); - } + return $o; + } - $valueI = 100 / $nb_modules; - $valueTotal = 0; - foreach ($modules as $module) { - $complet = $ressources_entity->get_completions_by_module($USER->id, $COURSE->id, $module->id); - if ($complet->completionstate != 0) { - $valueTotal += $valueI; - } - } + public function get_completion_by_section($idSection) + { + global $COURSE, $USER; + $ressources_entity = new course_format_iena_section_ressources(); + $section_entity = new course_format_iena_sections(); + //$completions = $ressources_entity->get_completions_by_userid($USER->id, $COURSE->id); + + // list modules in a section + $modules = $ressources_entity->get_ressources_completion_on_by_id_section($idSection); + $nb_modules = count($modules); + if ($nb_modules == 0) { + return array($nb_modules, 999); + } - return array($modules, $valueTotal); + $valueI = 100 / $nb_modules; + $valueTotal = 0; + foreach ($modules as $module) { + $complet = $ressources_entity->get_completions_by_module($USER->id, $COURSE->id, $module->id); + if ($complet->completionstate != 0) { + $valueTotal += $valueI; + } } - public function is_student($userId) { - // do NOT trust this method - global $COURSE; - $course_ctx = context_course::instance($COURSE->id); - foreach (get_user_roles($course_ctx, $userId) as $role) { - if ($role->shortname == 'student') { - return true; - } + return array($modules, $valueTotal); + } + + public function is_student($userId) { + // do NOT trust this method + global $COURSE; + $course_ctx = context_course::instance($COURSE->id); + foreach (get_user_roles($course_ctx, $userId) as $role) { + if ($role->shortname == 'student') { + return true; } } + } - public function get_render_competences($diSection) - { - global $DB, $COURSE, $CFG, $USER; - $section_entity = new course_format_iena_section_ressources(); - $modules = $section_entity->get_ressources_by_id_section($diSection); - $id_competence = array(); - foreach ($modules as $module) { - $comp_module = $DB->get_records('competency_modulecomp', array('cmid' => $module->id)); - if ($comp_module) { - foreach ($comp_module as $comp){ - $id_competence[$comp->id] = $comp->competencyid; - } + public function get_render_competences($diSection){ + global $DB, $COURSE, $CFG, $USER; + $section_entity = new course_format_iena_section_ressources(); + $modules = $section_entity->get_ressources_by_id_section($diSection); + $id_competence = array(); + foreach ($modules as $module) { + $comp_module = $DB->get_records('competency_modulecomp', array('cmid' => $module->id)); + if ($comp_module) { + foreach ($comp_module as $comp){ + $id_competence[$comp->id] = $comp->competencyid; } } - $competences = array(); - foreach ($id_competence as $val) { - $req = $DB->get_record('competency', array('id' => $val)); - $competences[$val] = $req->shortname; - } - if (count($competences) == 0) { - return ""; - } - $render = false; - $render .= " - <div class=\"dropdown d-inline\"> - <a href=\"#\" class=\"dropdown-toggle\" id=\"dropdown-2\" title=\"Actions\" role=\"button\" data-toggle=\"dropdown\" - aria-haspopup=\"true\" aria-expanded=\"false\" style=\"color : white\"> - <i class=\"fa fa-lightbulb-o\" aria-hidden=\"true\"></i> - </a> - <div class=\"dropdown-menu dropdown- dropdown-menu-right menu align-tr-br\" id=\"action-menu-2-menu\" data-rel=\"menu-content\" - aria-labelledby=\"action-menu-toggle-2\" role=\"menu\" data-align=\"tr-br\"> - <div class=\"contenu\"> - <div class='centered'> - <h3>Compétences</h3> + } + $competences = array(); + foreach ($id_competence as $val) { + $req = $DB->get_record('competency', array('id' => $val)); + $competences[$val] = $req->shortname; + } + if (count($competences) == 0) { + return ""; + } + $render = false; + $render .= " + <div class=\"dropdown d-inline\"> + <a href=\"#\" class=\"dropdown-toggle\" id=\"dropdown-2\" title=\"Actions\" role=\"button\" data-toggle=\"dropdown\" + aria-haspopup=\"true\" aria-expanded=\"false\" style=\"color : white\"> + <i class=\"fa fa-lightbulb-o\" aria-hidden=\"true\"></i> + </a> + <div class=\"dropdown-menu dropdown- dropdown-menu-right menu align-tr-br\" id=\"action-menu-2-menu\" data-rel=\"menu-content\" + aria-labelledby=\"action-menu-toggle-2\" role=\"menu\" data-align=\"tr-br\"> + <div class=\"contenu\"> + <div class='centered'> + <h3>Compétences</h3> + + </div> + <ul class='bulle'> + "; + foreach ($competences as $key => $competence) { + $render .= "<li><a href='" . $CFG->wwwroot . "/admin/tool/lp/user_competency_in_course.php?courseid=" . $COURSE->id . + "&competencyid=" . $key . "&userid=" . $USER->id . "'> $competence </a></li>"; + } + $render .= " + </ul> + <div class='centered'> + <a href ='" . $CFG->wwwroot . "/admin/tool/lp/coursecompetencies.php?courseid=" . $COURSE->id . "'> + <button class='btn btn-sm btn_blue' >Compétence du cours</button></a> + </div> + + </div> + </div> + </div>"; - </div> - <ul class='bulle'> - "; - foreach ($competences as $key => $competence) { - $render .= "<li><a href='" . $CFG->wwwroot . "/admin/tool/lp/user_competency_in_course.php?courseid=" . $COURSE->id . - "&competencyid=" . $key . "&userid=" . $USER->id . "'> $competence </a></li>"; - } - $render .= " - </ul> - <div class='centered'> - <a href ='" . $CFG->wwwroot . "/admin/tool/lp/coursecompetencies.php?courseid=" . $COURSE->id . "'> - <button class='btn btn-sm btn_blue' >Compétence du cours</button></a> - </div> + return $render; + } - </div> - </div> - </div>"; - - return $render; - } - - public function get_view_iena($course, $htmlsection, $nameSection, $introSection, $idSection) - { - global $CFG, $COURSE, $USER; - $section_entity = new course_format_iena_sections(); - - //recommenté - // $course_sections_instance = new course_format_iena_section_ressources(); - - // $course_sections = new course_format_iena_sections(); - // $liste_sections = $course_sections->get_sections_by_id_course($COURSE->id); - - // $course_format_iena_groups_instance = new course_format_iena_groups(); - // $groups = $course_format_iena_groups_instance->get_groups_by_id_course($COURSE->id); - // fin recommenté - - // $groups = []; - // var_dump($groups); - //$students_group = $course_format_iena_groups_instance->get_students_group($course->id); - - - // COUPE ICI - - - - // $tab_group_indicateur = array(); - - // foreach($groups as $group) - // { - // $tab_student_completion = array(); - // $tab_section_indicateur = array(); - // foreach ($liste_sections as $section_ligne) - // { - // //get modules for one section - // $modules_states_section = $course_sections->get_hidden_modules_by_section($section_ligne->id); - - // // if rows is empty in BDD => check count modules of student - // // hide => cm (course module (activity) is linked to a section indicator) - // // $nb_modules => numbre of activities linked to this section indicator - // $nb_modules = 0; - // foreach ($modules_states_section as $mod) { - // if ($mod->hide == 1) { - // $nb_modules++; - // } - // } - - // // Count each student of group who as not all validate in section - // foreach ($group->list_userid as $student) - // { - // // si le user peut consulter le suivi, il n'est pas étudiant et ne doit pas y apparaître - // if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $student->userid)) { - // continue; - // } - // //retrieving the student's module completion chart for this course (then check if module in section) - // // $tab_student_completion = $course_sections_instance->get_completions_by_userid($student->userid, $COURSE->id); - // $tab_student_completion = NULL; - - - // // if no info completion of student is not in BDD - // if (empty($tab_student_completion)) { - // $indicateur = 1; - // } else { - // $compteur = 0; - // foreach ($modules_states_section as $mod) { - // if ($mod->hide == 1) { - // $break_one = 0; - // foreach ($tab_student_completion as $module_completion) { - // if ($module_completion->coursemoduleid == $mod->cmid) { - // $compteur++; - // if ($module_completion->completionstate == 0) { - // $indicateur = 1; - // $break_one = 1; - // break; - // } else { - // $indicateur = 0; - // } - // } - // } - // if ($break_one == 1) { - // break; - // } - // } - // } - // if ($compteur < $nb_modules) { - // if ($indicateur == 0) { - // $indicateur = 1; - // } - // } - // } - - // if ($this->is_student($student->userid) !== true) { - // $indicateur = 0; - // } - - // $tab_section_indicateur[$section_ligne->id] += $indicateur; - - // } - - // if ($nb_modules == 0) { - // $tab_section_indicateur[$section_ligne->id] = "<a href=\"$CFG->wwwroot/course/format/iena/param_indicateur.php?courseid=$COURSE->id§ionid=$section_ligne->id\">-</a>"; - // } else if ($tab_section_indicateur[$section_ligne->id] == NULL) { - // $tab_section_indicateur[$section_ligne->id] = 0; - // } - // } - // $tab_group_indicateur[$group->idnumber] = $tab_section_indicateur; + public function get_view_iena($course, $htmlsection, $nameSection, $introSection, $idSection) + { + global $CFG, $COURSE, $USER; + $section_entity = new course_format_iena_sections(); - // } + //recommenté + // $course_sections_instance = new course_format_iena_section_ressources(); - // $course_ctx = context_course::instance($COURSE->id); - // $students = get_enrolled_users($course_ctx, 'mod/assignment:submit', 0); - // $tab_student_completion = array(); - // $tab_section_indicateur = array(); - // foreach ($liste_sections as $section_ligne) { - // //retrieves modules for a section - // $modules_states_section = $course_sections->get_hidden_modules_by_section($section_ligne->id); - - // // if empty lines in the DB => check student module counter - // $nb_modules = 0; - // foreach ($modules_states_section as $mod) { - // if ($mod->hide == 1) { - // $nb_modules++; - // } - // } - - // // Count each student in the course who has not validated everything in the - // foreach ($students as $student) { - // // si le user peut consulter le suivi, il n'est pas étudiant et ne doit pas y apparaître - // if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $student->id)) { - // continue; - // } - // //retrieving the student's module completion chart for this course (then check if module in section) - // // $tab_student_completion = $course_sections_instance->get_completions_by_userid($student->id, $COURSE->id); - // $tab_student_completion = NULL; - - // // if no student completion information is in the database - // if (empty($tab_student_completion)) { - // $indicateur = 1; - // } else { - // $compteur = 0; - // foreach ($modules_states_section as $mod) { - // if ($mod->hide == 1) { - // $break_one = 0; - // foreach ($tab_student_completion as $module_completion) { - // if ($module_completion->coursemoduleid == $mod->cmid) { - // $compteur++; - // if ($module_completion->completionstate == 0) { - // $indicateur = 1; - // $break_one = 1; - // break; - // } else { - // $indicateur = 0; - // } - // } - // } - // if ($break_one == 1) { - // break; - // } - // } - // } - // if ($compteur < $nb_modules) { - // if ($indicateur == 0) { - // $indicateur = 1; - // } - // } - // } - // $tab_section_indicateur[$section_ligne->id] += $indicateur; - // } - // if ($nb_modules == 0) { - // $tab_section_indicateur[$section_ligne->id] = "<a href=\"$CFG->wwwroot/course/format/iena/param_indicateur.php?courseid=$COURSE->id§ionid=$section_ligne->id\">-</a>"; - // } else if ($tab_section_indicateur[$section_ligne->id] == NULL) { - // $tab_section_indicateur[$section_ligne->id] = 0; - // } - // // var_dump($tab_section_indicateur[$section_ligne->id]); - // } - // $tab_group_indicateur['id_groupe0']=$tab_section_indicateur; - // $view = ""; + // $course_sections = new course_format_iena_sections(); + // $liste_sections = $course_sections->get_sections_by_id_course($COURSE->id); + // $course_format_iena_groups_instance = new course_format_iena_groups(); + // $groups = $course_format_iena_groups_instance->get_groups_by_id_course($COURSE->id); + // fin recommenté + // $groups = []; + // var_dump($groups); + //$students_group = $course_format_iena_groups_instance->get_students_group($course->id); - // COUPE ICI - - // nouvelle génération du header + // COUPE ICI - $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(); + // $tab_group_indicateur = array(); - $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> + // foreach($groups as $group) + // { + // $tab_student_completion = array(); + // $tab_section_indicateur = array(); + // foreach ($liste_sections as $section_ligne) + // { + // //get modules for one section + // $modules_states_section = $course_sections->get_hidden_modules_by_section($section_ligne->id); - /* - style for clean page - */ + // // if rows is empty in BDD => check count modules of student + // // hide => cm (course module (activity) is linked to a section indicator) + // // $nb_modules => numbre of activities linked to this section indicator + // $nb_modules = 0; + // foreach ($modules_states_section as $mod) { + // if ($mod->hide == 1) { + // $nb_modules++; + // } + // } - /* [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; -} + // // Count each student of group who as not all validate in section + // foreach ($group->list_userid as $student) + // { + // // si le user peut consulter le suivi, il n'est pas étudiant et ne doit pas y apparaître + // if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $student->userid)) { + // continue; + // } + // //retrieving the student's module completion chart for this course (then check if module in section) + // // $tab_student_completion = $course_sections_instance->get_completions_by_userid($student->userid, $COURSE->id); + // $tab_student_completion = NULL; + + + // // if no info completion of student is not in BDD + // if (empty($tab_student_completion)) { + // $indicateur = 1; + // } else { + // $compteur = 0; + // foreach ($modules_states_section as $mod) { + // if ($mod->hide == 1) { + // $break_one = 0; + // foreach ($tab_student_completion as $module_completion) { + // if ($module_completion->coursemoduleid == $mod->cmid) { + // $compteur++; + // if ($module_completion->completionstate == 0) { + // $indicateur = 1; + // $break_one = 1; + // break; + // } else { + // $indicateur = 0; + // } + // } + // } + // if ($break_one == 1) { + // break; + // } + // } + // } + // if ($compteur < $nb_modules) { + // if ($indicateur == 0) { + // $indicateur = 1; + // } + // } + // } + + // if ($this->is_student($student->userid) !== true) { + // $indicateur = 0; + // } + + // $tab_section_indicateur[$section_ligne->id] += $indicateur; -/* [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 */ + // if ($nb_modules == 0) { + // $tab_section_indicateur[$section_ligne->id] = "<a href=\"$CFG->wwwroot/course/format/iena/param_indicateur.php?courseid=$COURSE->id§ionid=$section_ligne->id\">-</a>"; + // } else if ($tab_section_indicateur[$section_ligne->id] == NULL) { + // $tab_section_indicateur[$section_ligne->id] = 0; + // } + // } + // $tab_group_indicateur[$group->idnumber] = $tab_section_indicateur; -ul, ul ul { - padding-left: 2.5rem; - margin-bottom: 0.5rem !important; -} + // } -/* style for ? */ + // $course_ctx = context_course::instance($COURSE->id); + // $students = get_enrolled_users($course_ctx, 'mod/assignment:submit', 0); + // $tab_student_completion = array(); + // $tab_section_indicateur = array(); + // foreach ($liste_sections as $section_ligne) { + // //retrieves modules for a section + // $modules_states_section = $course_sections->get_hidden_modules_by_section($section_ligne->id); + + // // if empty lines in the DB => check student module counter + // $nb_modules = 0; + // foreach ($modules_states_section as $mod) { + // if ($mod->hide == 1) { + // $nb_modules++; + // } + // } - #completionprogressid { -display: none; -} + // // Count each student in the course who has not validated everything in the + // foreach ($students as $student) { + // // si le user peut consulter le suivi, il n'est pas étudiant et ne doit pas y apparaître + // if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $student->id)) { + // continue; + // } + // //retrieving the student's module completion chart for this course (then check if module in section) + // // $tab_student_completion = $course_sections_instance->get_completions_by_userid($student->id, $COURSE->id); + // $tab_student_completion = NULL; + + // // if no student completion information is in the database + // if (empty($tab_student_completion)) { + // $indicateur = 1; + // } else { + // $compteur = 0; + // foreach ($modules_states_section as $mod) { + // if ($mod->hide == 1) { + // $break_one = 0; + // foreach ($tab_student_completion as $module_completion) { + // if ($module_completion->coursemoduleid == $mod->cmid) { + // $compteur++; + // if ($module_completion->completionstate == 0) { + // $indicateur = 1; + // $break_one = 1; + // break; + // } else { + // $indicateur = 0; + // } + // } + // } + // if ($break_one == 1) { + // break; + // } + // } + // } + // if ($compteur < $nb_modules) { + // if ($indicateur == 0) { + // $indicateur = 1; + // } + // } + // } + // $tab_section_indicateur[$section_ligne->id] += $indicateur; + // } + // if ($nb_modules == 0) { + // $tab_section_indicateur[$section_ligne->id] = "<a href=\"$CFG->wwwroot/course/format/iena/param_indicateur.php?courseid=$COURSE->id§ionid=$section_ligne->id\">-</a>"; + // } else if ($tab_section_indicateur[$section_ligne->id] == NULL) { + // $tab_section_indicateur[$section_ligne->id] = 0; + // } + // // var_dump($tab_section_indicateur[$section_ligne->id]); + // } + // $tab_group_indicateur['id_groupe0']=$tab_section_indicateur; + // $view = ""; -#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%; -} + // COUPE ICI + -.bulle { - list-style: none; -} + // nouvelle génération du header -.bulle > li { - list-style: none; - font-weight: normal; - font-size: 0.8rem; - line-height: 1rem; - padding-top: 5%; -} -</style>"; + $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); -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 = ""; + /* 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; } - } 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\">"; + /* [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 */ - //&& !has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id) - 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>"; - } + 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; + } + $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 ($compl_by_section != 999 && $completion->is_enabled()) { - // $view .= "<div class=\"iena-percent set_height\"> - // " . floor($compl_by_section) . "% - // </div>"; - // } + //&& !has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id) + 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 ($compl_by_section != 999 && $completion->is_enabled()) { + // $view .= "<div class=\"iena-percent set_height\"> + // " . floor($compl_by_section) . "% + // </div>"; + // } - // if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) { - if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) { - - $course_groups = groups_get_all_groups($COURSE->id); - // var_dump($course_groups->id); - $group_indicateur = 0; - $view .= "<a href='$link§ionid=".$idSection[$i]."' style=\"color : white\">"; - $view .="<div onclick='change_grouplink(this)' style=\"display:none;\" class=\"nb_pers set_height id_groupe0\">"; - $view .= "Suivi étudiants"; - $view .= "</div>"; - foreach ($course_groups as $group) { - $view .="<div onclick='change_grouplink(this)' style=\"display:none;\" class=\"nb_pers set_height id_groupe".$group->id."\">"; - $view .= "Suivi étudiants"; - $view .= "</div>"; - } - $view .="</a>"; - - // if (has_capability('course/iena:suivi_edit', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) { - // $view .= "<a href=\"$CFG->wwwroot/course/format/iena/param_indicateur.php?courseid=$COURSE->id§ionid=$idSection[$i]\" class=\"set_height\" style=\"color: white;float: left;line-height: 4rem;margin-left: 1rem;\">Editer suivi</a>"; - // } - // id_groupeXXX - // var_dump($course_groups); + // if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) { + if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) { + - // var_dump($idSection[$i]); + $course_groups = groups_get_all_groups($COURSE->id); + // var_dump($course_groups->id); - // foreach($tab_group_indicateur as $group_indicateur => $val) { - // $view .="<div onclick='change_grouplink(this)' style=\"display:none;\" class=\"nb_pers set_height ".$group_indicateur."\">"; - // foreach ($val as $key => $value) { - // if ($idSection[$i] == $key) { - // $view .= $value; - // } - // } - // $view .= "</div>"; - // } + $group_indicateur = 0; - // $view .="</a>"; - } + $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 .= "<div class=\"titre_section set_height\"> - <p>$titre</p> - </div> - <div class=\"right_info\"> - "; - // if ($presence) { - // $view .= " - // <div class=\"label_item\"> - // $presence - // </div>"; + /*foreach ($course_groups as $group) { + $view .="<div onclick='change_grouplink(this)' style=\"display:none;\" class=\"nb_pers set_height id_groupe".$group->id."\">"; + $view .= "Suivi étudiants"; + $view .= "</div>"; + }*/ + $view .="</a>"; + + // if (has_capability('course/iena:suivi_edit', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) { + // $view .= "<a href=\"$CFG->wwwroot/course/format/iena/param_indicateur.php?courseid=$COURSE->id§ionid=$idSection[$i]\" class=\"set_height\" style=\"color: white;float: left;line-height: 4rem;margin-left: 1rem;\">Editer suivi</a>"; // } - 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 + + + // id_groupeXXX + + // var_dump($course_groups); + + // var_dump($idSection[$i]); + + // foreach($tab_group_indicateur as $group_indicateur => $val) { + // $view .="<div onclick='change_grouplink(this)' style=\"display:none;\" class=\"nb_pers set_height ".$group_indicateur."\">"; + // foreach ($val as $key => $value) { + // if ($idSection[$i] == $key) { + // $view .= $value; + // } + // } + // $view .= "</div>"; + // } + + // $view .="</a>"; + } + + + + $view .= "<div class=\"titre_section set_height\"> + <p>$titre</p> </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 class=\"right_info\"> + "; + // if ($presence) { + // $view .= " + // <div class=\"label_item\"> + // $presence + // </div>"; + // } + 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> - <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>"; + "; + $view .= "<div class=\"wrapper section\">"; + $view .= $sectionIntro; + // à présent géré au niveau de la génération du header de section par la méthode dédiée + // if (strpos($sectionIntro, "</p>")) { + // $view .= "<div class=\"iena-description\">"; + // $view .= " + // <div class=\"small\"> + // $sectionIntro + // </div> + // </div> + // <a href=\"#\">Voir la description complète</a> + // "; + // $view .= "</div>"; + // } + $view .= "<div class=\"wrapper\"> + $section + </div > + + </div> + + </section>"; + $i++; } + return $view; } - // $cpt = $this->get_render_competences($idSection[$i]); - $cpt = ""; - if ($cpt != "") { - $view .= " - <div class=\"titre_section set_height\"> - "; - $view .= $cpt; - $view .= "</div> - "; - } + public function get_view_iena_new($course, $htmlsection, $nameSection, $introSection, $idSection) + { + global $CFG, $COURSE, $USER; + $section_entity = new course_format_iena_sections(); - $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; - // à présent géré au niveau de la génération du header de section par la méthode dédiée - // if (strpos($sectionIntro, "</p>")) { - // $view .= "<div class=\"iena-description\">"; - // $view .= " - // <div class=\"small\"> - // $sectionIntro - // </div> - // </div> - // <a href=\"#\">Voir la description complète</a> - // "; - // $view .= "</div>"; - // } - $view .= "<div class=\"wrapper\"> - $section - </div > - - </div> - - </section>"; - $i++; -} + -return $view; -} + $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); -public function print_iena_section_pages($course) -{ - global $PAGE, $USER; + /* 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(); - //$courses = enrol_get_my_courses('*', 'fullname ASC'); - // $coursesprogress = []; + $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> - $context = context_course::instance($course->id); - $course = course_get_format($course)->get_course(); + /* + style for clean page + */ - $completion = new \completion_info($course); + /* [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; + } - // First, let's make sure completion is enabled. - // if (!$completion->is_enabled()) { - // continue; - // } + /* [BOOST] : blocks */ + #block-region-side-pre section.block { + border: none; + } + #block-region-side-pre section.block .card-body { + padding-top: 0; + } - // $proges = new \core_completion\progress(); - // $percentage = $proges->get_course_progress_percentage($course); + /* [BOOST] : margin for ul, because ul is used to list sections */ - // if (!is_null($percentage)) { - // $percentage = floor($percentage); - // } - // $coursesprogress[$course->id]['completed'] = $completion->is_course_complete($USER->id); - // $coursesprogress[$course->id]['progress'] = $percentage; + ul, ul ul { + padding-left: 2.5rem; + margin-bottom: 0.5rem !important; + } - // $completion_total = $coursesprogress[$course->id]["progress"]; + /* style for ? */ + #completionprogressid { + display: none; + } - $modinfo = get_fast_modinfo($course); - // $course = course_get_format($course)->get_course(); - $context = context_course::instance($course->id); - // $completioninfo = new completion_info($course); - if (isset($_COOKIE['sectionvisible_' . $course->id])) { - $sectionvisible = $_COOKIE['sectionvisible_' . $course->id]; - } elseif ($course->marker > 0) { - $sectionvisible = $course->marker; - } else { - $sectionvisible = 1; - } - $htmlsection = false; - $nameSection = []; - $idSection = false; - $introSection = false; - //var_dump($modinfo->get_section_info_all());die; - foreach ($modinfo->get_section_info_all() as $section => $thissection) { - - // var_dump($thissection); - //Nom de la section - - $htmlsection[$section] = ''; - /*if ($section == 0) { - //$section0 = $thissection; - //continue; - $nameSection[$section] = "Section 0"; - $idSection[$section] = $section; - }*/ - $numsections = course_get_format($course)->get_last_section_number(); + #region-main > .card { + border: none; + overflow-x: visible !important; + overflow-y: visible; + } - // var_dump($numsections); - // if ($section > $numsections) { - // // if ($section > $course->numsections) { - // // continue; - // } - /* 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))) { - if ($course->hiddensections && !(int)$thissection->visible) { - continue; - } - 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; + #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; + } + $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>"; - //Affiche le nom de la section en mode propre sans lien - $idSection[$section] = $thissection->id; - // $nameSection[$section] .= $this->section_title_without_link($thissection, $course); - $nameSection[$section] = $this->section_title_without_link($thissection, $course); - if ($PAGE->user_is_editing()) { + + } + + + + $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; + } + + + + public function count_students(){ + $count = count_enrolled_users($COURSE->id); + echo "on compte les étudiants"; + return $count; + } + + + 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); + // $course = course_get_format($course)->get_course(); + + // $completioninfo = new completion_info($course); + if (isset($_COOKIE['sectionvisible_' . $course->id])) { + $sectionvisible = $_COOKIE['sectionvisible_' . $course->id]; + } elseif ($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(); + + // var_dump($numsections); + // if ($section > $numsections) { + // // if ($section > $course->numsections) { + // // continue; + // } + /* 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; } - //$htmlsection[$section] .= $this->section_title($thissection,$course); - //$introSection[$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>"; + + if (!$thissection->uservisible || !$thissection->visible) { + $htmlsection[$section] .= $this->section_hidden($section, $course->id); + continue; } - /* pas de footer car on ne commence par la structure par une div non fermée et que ce footer ferme par une div */ - // $htmlsection[$section] .= $this->section_footer(); - - - } //ENDFOREACH + } - // echo $completioninfo->display_help_icon(); + + //Affiche le nom de la section en mode propre sans lien + $idSection[$section] = $thissection->id; + // $nameSection[$section] .= $this->section_title_without_link($thissection, $course); + $nameSection[$section] = $this->section_title_without_link($thissection, $course); + if ($PAGE->user_is_editing()) { + $htmlsection[$section] .= $this->section_header($thissection, $course, false, 0); + } + //$htmlsection[$section] .= $this->section_title($thissection,$course); + //$introSection[$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 */ + // $htmlsection[$section] .= $this->section_footer(); + + } //ENDFOREACH + + // echo $completioninfo->display_help_icon(); + + 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 + //var_dump($htmlsection); + //var_dump($htmlsection0); + if ($PAGE->user_is_editing()) { + // echo $completioninfo->display_help_icon(); echo $this->output->heading($this->page_title(), 2, 'accesshide'); echo $this->course_activity_clipboard($course, 0); echo $this->start_section_list(); - - //traitement section 0 - /*if ($section0->summary || !empty($modinfo->sections[0]) || $PAGE->user_is_editing()) { - $htmlsection0 = $this->section_header($section0, $course, false, 0); - $htmlsection0 .= $this->courserenderer->course_section_cm_list($course, $section0, 0); - $htmlsection0 .= $this->courserenderer->course_section_add_cm_control($course, 0, 0); - $htmlsection0 .= $this->section_footer(); - }*/ - //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 - //var_dump($htmlsection); - //var_dump($htmlsection0); - if ($PAGE->user_is_editing()) { - // echo $completioninfo->display_help_icon(); - echo $this->output->heading($this->page_title(), 2, 'accesshide'); - echo $this->course_activity_clipboard($course, 0); - echo $this->start_section_list(); - } + } + + + - // if ($course->sectionposition == 0 and isset($htmlsection0)) { - // if ($PAGE->user_is_editing()){ - // echo html_writer::tag('span', $htmlsection0, ['class' => 'above']); - // } - // } - //echo $this->get_button_section($course, $sectionvisible); //here all activities are displayed //If we are in etition 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; - } + 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 // if ($course->sectionposition == 1 and isset($htmlsection0)) { // if ($PAGE->user_is_editing()) // echo html_writer::tag('span', $htmlsection0, ['class' => 'below']); // } - + //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(); + 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->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']); - // if ($course->numsections > 0) { - // $strremovesection = get_string('reducesections', 'moodle'); - // $url = new moodle_url('/course/changenumsections.php', ['courseid' => $course->id, 'insertsection' => 0, 'increase' => false, 'sesskey' => sesskey(), 'sectionreturn' => 0]); - // // http://localhost:8888/moodle35/course/changenumsections.php?courseid=5&insertsection=0&sesskey=IYEFeaNxbo§ionreturn=0 - // $icon = $this->output->pix_icon('t/switch_minus', $strremovesection); - // echo html_writer::link( - // $url, - // $icon . get_accesshide($strremovesection), - // ['class' => 'reduce-sections'] - // ); - // } - echo html_writer::end_tag('div'); - } else { - echo $this->end_section_list(); + echo $this->stealth_section_header($section); + echo $this->courserenderer->course_section_cm_list($course, $thissection, 0); + echo $this->stealth_section_footer(); } - echo html_writer::tag('style', '.course-content ul.iena #section-' . $sectionvisible . ' { display: block; }'); - if (!$PAGE->user_is_editing()) { + 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; }'); + if (!$PAGE->user_is_editing()) { //$PAGE->requires->js_init_call('M.format_iena.init', [$course->numsections]); + } + + } + + public function get_iena_sections($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]; + } elseif ($course->marker > 0) { + $sectionvisible = $course->marker; + } else { + $sectionvisible = 1; + } + $htmlsection = false; + $nameSection = []; + $idSection = false; + $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; + } + if (!$thissection->available && !empty($thissection->availableinfo)) { + echo "par là"; + $thissection= $this->get_section_header($thissection, $course, false, 0); + + continue; + } + if (!$thissection->uservisible || !$thissection->visible) { + $htmlsection[$section] .= $this->section_hidden($section, $course->id); + + continue; + } + } + $thissection=$this->get_section_header($thissection, $course, false, 0, true); + if ($thissection->uservisible) { + + + $thissection->resources= $this->courserenderer->course_section_cm_list($course, $thissection, 0); + $thissection->addresources = $this->courserenderer->course_section_add_cm_control($course, $section, 0); + + } + array_push($sections['sections'], $thissection); + } + + 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) { + $htmlsection[$section] = ''; + + $numsections = course_get_format($course)->get_last_section_number(); + if (!$PAGE->user_is_editing() && (!has_capability('moodle/course:viewhiddensections', $context = context_course::instance($course->id), $USER->id))) { + if ($course->hiddensections && !(int)$thissection->visible) { + continue; + } + 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; + } + } + + + $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) { + $htmlsection[$section] .= "<div class='content'>"; + + $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>"; + } + + + } + + echo $this->output->heading($this->page_title(), 2, 'accesshide'); + echo $this->course_activity_clipboard($course, 0); + echo $this->start_section_list(); + + + + if (!$PAGE->user_is_editing()) { + echo $this->get_view_iena($course, $htmlsection, $nameSection, $introSection, $idSection); + } else { + foreach ($htmlsection as $current) { + echo $current; + } } + + + + + echo html_writer::tag('style', '.course-content ul.iena #section-' . $sectionvisible . ' { display: block; }'); + */ + } + + 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->print_iena_section_pages($course); + } + else{ + //$this->print_iena_section_pages($course); + $this->get_iena_sections($course); + } + } +} diff --git a/styles.css b/styles.css index 34b29873c55bfe2af1fc267fc9baa909880e6ba6..f67e2cde11217dd1d7cdf42d324b7acb4f6b58ac 100644 --- a/styles.css +++ b/styles.css @@ -424,4 +424,12 @@ ul.nav.navbar-nav.ml-auto { +#title-summary-iena #summary-collapse.collapse:not(.show) { + display: block; + height: 4rem; + overflow: hidden; +} +#title-summary-iena #summary-collapse.collapsing { + height: 4rem; +} \ No newline at end of file diff --git a/templates/course-header.mustache b/templates/course-header.mustache new file mode 100644 index 0000000000000000000000000000000000000000..0f6686d9f0ae4629b83caaeea040349f85467153 --- /dev/null +++ b/templates/course-header.mustache @@ -0,0 +1,3 @@ +<div class="iena-course-header"> + {{#student}}<div class="iena-course-header-bottom" id="iena-h-bottom" aria-expanded="false" style="display: none"></div> +</div> \ No newline at end of file diff --git a/templates/section.mustache b/templates/section.mustache new file mode 100644 index 0000000000000000000000000000000000000000..e76cddc6e0e8a2cf9c19b8e797c9bcd0dd62bbde --- /dev/null +++ b/templates/section.mustache @@ -0,0 +1,27 @@ +<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> + + <div class="wrapper section"> + {{#summary}} + <div class="iena-description"> + <div class="small"> + <div class="iena-summary">{{{summary}}}</div> + </div> + </div> + <a href="#" class="voir-plus">Voir la description complète</a> + {{/summary}} + {{{messageavailability}}} + <div class="wrapper"> + <div class="content"> + {{{resources}}} + {{{addresources}}} + </div> + </div> + </div> + </div> + +</section> \ No newline at end of file diff --git a/templates/sections.mustache b/templates/sections.mustache new file mode 100644 index 0000000000000000000000000000000000000000..dd7b6c0ad7ec5f34029fd85bee95ac4082ac05b7 --- /dev/null +++ b/templates/sections.mustache @@ -0,0 +1,7 @@ + +<ul class="iena-editing"> + <div class="iena-course-header"></div> + {{#sections}} + {{> format_iena/section}} + {{/sections}} +</ul> \ No newline at end of file diff --git a/view/view_course_header.php b/view/view_course_header.php index 3d177aecfe9110c8f644e4a3ec8f0c68f55439b4..65a345dbe0e16234a9410d775f5ec357e56b8b67 100644 --- a/view/view_course_header.php +++ b/view/view_course_header.php @@ -287,6 +287,12 @@ class view_course_header { return false; } + private function count_students(){ + $count = count_enrolled_users($COURSE->id); + echo "on compte les étudiants"; + return $count; + } + private function get_groupes() { global $COURSE, $USER; if ( ! $this->is_teacher($USER) ) { return false; } @@ -314,6 +320,8 @@ class view_course_header { // begin of : top part (always visible) $this->_content .= '<div class="iena-course-header-top">'; + + //if user is a student if(!has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id)){ // PROGRESS TOTAL : total progression percentage if ( $infos['progress'] !== false && $infos['progress']->total !== false ) { @@ -322,6 +330,11 @@ class view_course_header { else { $this->_content .= '<div class="btn"></div>'; } + + + + + // $this->_content .= '<a href="#" class="btn btn-outline-primary iena-course-h-total" onclick="iena_toggle_course_header(event)">Ma progression :%</a>'; // MESSAGES : button to send message to teachers @@ -365,6 +378,8 @@ class view_course_header { // $this->_content .= '<a href="'.$infos['attendance'].'" class="btn btn-outline-warning iena-course-h-attendance" id="iena-attendance-btn">Présences</a>'; // } + + // GROUP : teacher group select (input-group-lg if needed) /*if ( $infos['groups'] !== false ) { $this->_content .= '<script type=\"text/javascript\" charset=\"utf8\" src=\"https://code.jquery.com/jquery-3.3.1.min.js\"></script>'; @@ -407,6 +422,21 @@ class view_course_header { }*/ } + + + $this->_content .= '<script type=\"text/javascript\" charset=\"utf8\" src=\"https://code.jquery.com/jquery-3.3.1.min.js\"></script>'; + $this->_content .= '<script src="'.$CFG->wwwroot.'/course/format/iena/js/groups.js"></script>'; + $this->_content .= '<script>function change_grouplink(obj) { + console.log("change grouplink") + var classList = obj.classList; + var id_groupe = classList[2].split("id_groupe"); + id_group = id_groupe[1]; + var t = obj.parentNode; + var t_href = t.getAttribute("href"); + t_href += "&groupid=" + id_group; + t.setAttribute("href", t_href); + } + </script>'; @@ -443,16 +473,17 @@ class view_course_header { $summary_copy = str_replace($to_delete, '', $summary_copy); $summary_copy = preg_replace('/\s+/', '', $summary_copy); if ( $summary_copy != "" ) { - $this->_content .= '<hr><h2>À propos du cours</h2><div class="iena-h-summary">' . $COURSE->summary . '</div>'; + } $this->_content .= '</div>'; // end of : bottom part if ( $summary_copy != "" ) { - $this->_content .= '<div class="iena-course-header-toggler" id="iena-h-toggler"><hr><a href="#" onclick="iena_toggle_course_header(event)">Afficher / masquer les infos du cours</a></div>'; + $this->_content .= '<hr><div id="title-summary-iena" class="container"><h3>'.get_string('aboutcourse', 'format_iena').'</h3><div class="collapse" id="summary-collapse" aria-expanded="false">' . $COURSE->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>'; + //$this->_content .= '<div class="iena-course-header-toggler" id="iena-h-toggler"><hr><a href="#" onclick="iena_toggle_course_header(event)">Afficher / masquer les infos du cours</a></div>'; } - $this->_content .= '<script>function iena_toggle_course_header(event) { event.preventDefault(); var bottom = document.getElementById("iena-h-bottom"); if(bottom.style.display == "none") { bottom.style.display = ""; bottom.setAttribute("aria-expanded", true); } else { bottom.style.display = "none"; bottom.setAttribute("aria-expanded", false); } }</script>'; + //$this->_content .= '<script>function iena_toggle_course_header(event) { event.preventDefault(); var bottom = document.getElementById("iena-h-bottom"); if(bottom.style.display == "none") { bottom.style.display = ""; bottom.setAttribute("aria-expanded", true); } else { bottom.style.display = "none"; bottom.setAttribute("aria-expanded", false); } }</script>'; $this->_content .= '</div>'; // end of : iena course header }