From 21663f526a082b24074cdd93f02f07bb50f5d880 Mon Sep 17 00:00:00 2001
From: Thomas Fradet <t.fradet8@gmail.com>
Date: Thu, 23 May 2019 18:48:37 +0200
Subject: [PATCH] bugs divers

---
 CHANGELOG.md                              | 77 +++++++++++++++++++++++
 entity/course_format_iena_cron_action.php |  4 +-
 format.php                                |  3 +-
 renderer.php                              | 21 ++++---
 4 files changed, 92 insertions(+), 13 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b2f441c..21f900e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -103,3 +103,80 @@ Lors de l'envoi d'un message à certains étudiants sélectionnés, si aucun des
 
 Correction du fait que le filtre affichait >=0 au lieu de >0. 
 
+# 23/05/2019
+
+__MAJ en 3.7__
+
+__Bugs__
+
+## 1
+
+NaN dans le tableau d'achèvement quand pas d'activité. Idée : buter le NaN définitivement avec si NaN alors "-" => fuck off
+
+__à tester__
+
+## 2
+
+Warning: include(../../lib.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/moodle37/course/format/iena/entity/course_format_iena_cron_action.php on line 37
+
+Warning: include(): Failed opening '../../lib.php' for inclusion (include_path='/Applications/MAMP/htdocs/moodle37/lib/pear:.:/Applications/MAMP/bin/php/php7.2.10/lib/php') in /Applications/MAMP/htdocs/moodle37/course/format/iena/entity/course_format_iena_cron_action.php on line 37
+
+Warning: include(../../../../config.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/moodle37/course/format/iena/entity/course_format_iena_cron_action.php on line 38
+
+Warning: include(): Failed opening '../../../../config.php' for inclusion (include_path='/Applications/MAMP/htdocs/moodle37/lib/pear:.:/Applications/MAMP/bin/php/php7.2.10/lib/php') in /Applications/MAMP/htdocs/moodle37/course/format/iena/entity/course_format_iena_cron_action.php on line 38
+
+Les fichiers ne sont plus inclus car ils le sont dans course/view.php qui devrait se charger d'inclure à son tout le reste. 
+
+[ ] tester si les crons fonctionnent toujours et si oui, classer le bug. 
+
+## __Bugs résolus__
+
+## 3
+
+Clef numsection manquante sur l'objet cours. Suppression de l'appel à cette clef car dans le format de cours topic ils utilisent 0 pour ne pas recréer de sections. Question : à quoi ça sert ?
+
+Test : créé un nouveau cours avec cette modification : OK
+Test : changer le nombre de sections avec cette modification : OK
+
+Avant : course_create_sections_if_missing($course, range(0, $course->numsections));
+Après : course_create_sections_if_missing($course, 0);
+
+[x] Solved. 
+
+## 4
+
+Typo numsections au lieu de $numsections dans une condition dont l'intérieur n'était pas utilisé. 
+
+La condition elle-même est commentée et le $ est ajouté. 
+
+[x] Solved. 
+
+## 5
+
+Notice: Undefined offset: 0 in /Applications/MAMP/htdocs/moodle37/course/format/iena/renderer.php on line 788
+
+Avant : $nameSection[$section] .= $this->section_title_without_link($thissection, $course);
+Après : $nameSection[$section] = $this->section_title_without_link($thissection, $course);
+
+[x] Solved. 
+
+ET 
+
+Notice: Undefined offset: 0 in /Applications/MAMP/htdocs/moodle37/course/format/iena/renderer.php on line 796
+
+Avant : $introSection[$section] .= $this->section_header($thissection, $course, false, 0, true);
+Après : $introSection[$section] = $this->section_header($thissection, $course, false, 0, true);
+
+[x] Solved. 
+
+## 6
+
+Notice: Undefined property: stdClass::$showdefaultsectionname in /Applications/MAMP/htdocs/moodle37/course/format/iena/renderer.php on line 102
+
+Commenté : sert à rien et la property n'existe pas. Pas présent dans le code de base du format topic. 
+
+[x] Solved. 
+
+
+
+
diff --git a/entity/course_format_iena_cron_action.php b/entity/course_format_iena_cron_action.php
index c177bb0..ffd2123 100644
--- a/entity/course_format_iena_cron_action.php
+++ b/entity/course_format_iena_cron_action.php
@@ -34,8 +34,8 @@
 	 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 	 */
 	
-	include('../../lib.php');
-	include('../../../../config.php');
+	// include('../../lib.php');
+	// include('../../../../config.php');
 	
 	
 	class course_format_iena_cron_action
diff --git a/format.php b/format.php
index db34f8d..af89b14 100644
--- a/format.php
+++ b/format.php
@@ -57,7 +57,8 @@
 		course_set_marker($course->id, $marker);
 	}
 	$course = course_get_format($course)->get_course();
-	course_create_sections_if_missing($course, range(0, $course->numsections));
+	// course_create_sections_if_missing($course, range(0, $course->numsections));
+	course_create_sections_if_missing($course, 0);
 	$renderer = $PAGE->get_renderer('format_iena');
 	if (!empty($displaysection)) {
 		$renderer->print_single_section_page($course, null, null, null, null, $displaysection);
diff --git a/renderer.php b/renderer.php
index 5306fa3..a62b52e 100644
--- a/renderer.php
+++ b/renderer.php
@@ -99,9 +99,9 @@
 			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 ($course->showdefaultsectionname) {
+			// 	$o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes);
+			// }
 			// if (!$iena) { $o .= $sectionname; }
 
 			$context = context_course::instance($course->id);
@@ -744,7 +744,7 @@ public function print_iena_section_pages($course)
 		$sectionvisible = 1;
 	}
 	$htmlsection = false;
-	$nameSection = false;
+	$nameSection = [];
 	$idSection = false;
 	$introSection = false;
 			//var_dump($modinfo->get_section_info_all());die;
@@ -763,10 +763,10 @@ public function print_iena_section_pages($course)
 				$numsections = course_get_format($course)->get_last_section_number();
 
 				// var_dump($numsections);
-				if ($section > numsections) {
-				// if ($section > $course->numsections) {
-					// continue;
-				}
+				// 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) {
@@ -785,13 +785,14 @@ public function print_iena_section_pages($course)
 				
 				//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);
+				$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);
+				$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'>";
-- 
GitLab