From 5982d12b93e7d44b9596e82022481106f7fc85d5 Mon Sep 17 00:00:00 2001
From: Myriam Delaruelle
 <Myriam Delaruelle@bdn-un-mdelarue.ad.univ-lorraine.fr>
Date: Fri, 13 Nov 2020 14:55:23 +0100
Subject: [PATCH] =?UTF-8?q?On=20enl=C3=A8ve=20le=20header=20pour=20les=20e?=
 =?UTF-8?q?nseignants?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 renderer.php                |   4 +-
 styles.css                  |  21 +++--
 view/view_course_header.php | 183 +++++++++++++++++++-----------------
 3 files changed, 111 insertions(+), 97 deletions(-)

diff --git a/renderer.php b/renderer.php
index f20219a..d24d8b6 100644
--- a/renderer.php
+++ b/renderer.php
@@ -543,7 +543,9 @@ foreach ($htmlsection as $section) {
 	<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) 
+	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>";
 	}
 
diff --git a/styles.css b/styles.css
index 7231081..34b2987 100644
--- a/styles.css
+++ b/styles.css
@@ -101,12 +101,12 @@ ul.nav.navbar-nav.ml-auto {
 }
 
 .set_height {
-	min-height: 3rem;
-	line-height: 1.7rem;
+	/*min-height: 3rem;*/
+	line-height: 0.7rem;
 }
 
 .heading-iena {
-	background: #666;
+	background: #D6D6D6;
 	padding: 0rem;
 	color: white;
 	float: left;
@@ -156,16 +156,21 @@ ul.nav.navbar-nav.ml-auto {
 	padding-left: 0.8rem;
 	padding-right: 1rem;
 	font-size: 1.4rem;
+	color: #1a1a1a;
+    font-weight: 100;
 	/*font-weight: bold;*/
 }
 
 .nb_pers {
 	text-align: center;
-	background: #d68d01;
-	float: left;
-	min-width: 4rem;
-	padding: 1rem 0.7rem;
-	font-size: 1rem;
+    background: #009186;
+    float: right;
+    min-width: 4rem;
+    padding: .6rem .6rem;
+    font-size: 1rem;
+    border-radius: 5px;
+    margin-top: 0.4rem;
+    margin-right: 0.4rem;
 }
 .nb_pers a {
 	color: white;
diff --git a/view/view_course_header.php b/view/view_course_header.php
index cf21465..3d177ae 100644
--- a/view/view_course_header.php
+++ b/view/view_course_header.php
@@ -308,102 +308,109 @@ class view_course_header {
 		// $css = file_get_contents( $CFG->wwwroot.'/course/format/iena/course-header.css' );
 		// $this->_content .= '<style>'.$css.'</style>';
 
-		$this->_content .= '<div class="iena-course-header">';
+	
+			$this->_content .= '<div class="iena-course-header">';
 
 
-		// begin of : top part (always visible)
-		$this->_content .= '<div class="iena-course-header-top">';
-
-		// PROGRESS TOTAL : total progression percentage
-		if ( $infos['progress'] !== false && $infos['progress']->total !== false ) {
-			$this->_content .= '<a href="#" class="btn btn-outline-primary iena-course-h-total" onclick="iena_toggle_course_header(event)">Ma progression : '.$infos['progress']->total.'%</a>';
-		}
-		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
-		if ( $infos['teachers'] !== false ) {
-			$this->_content .= '<div class="dropdown iena-course-h-message"><a class="btn btn-outline-primary dropdown-toggle" href="#" role="button" id="iena-course-h-message" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="sr-only">Contact : </span>Enseignants</a><div class="dropdown-menu dropdown-menu-right" aria-labelledby="iena-course-h-message">';
-			$my_group_teachers = [];
-			foreach ($infos['teachers'] as $teacher) {
-				// echo "<pre>";
-				// var_dump($teacher->id);
-				$teacher_groups = groups_get_user_groups($COURSE->id, $teacher->id)[0];
-				// var_dump($teacher_groups);
-				$user_groups = groups_get_user_groups($COURSE->id, $USER->id)[0];
-				// var_dump($user_groups);
-				$user_is_in_teacher_group = false;
-				foreach ($user_groups as $user_group) {
-					if ( in_array($user_group, $teacher_groups) ) {
-						$user_is_in_teacher_group = true;
-						$my_group_teachers[] = $teacher;
-						break;
-					}
+			// begin of : top part (always visible)
+			$this->_content .= '<div class="iena-course-header-top">';
+			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 ) {
+					$this->_content .= '<a href="#" class="btn btn-outline-primary iena-course-h-total" onclick="iena_toggle_course_header(event)">Ma progression : '.$infos['progress']->total.'%</a>';
 				}
-				// var_dump($user_is_in_teacher_group);
-				// echo "<hr>";
-				// echo "</pre>";
-			}
-			if ( count($my_group_teachers) > 0 ) {	
-				$this->_content .= '<span class="dropdown-header">Mon groupe</span>';
-				foreach ($my_group_teachers as $teacher) {
-					$this->_content .= '<a class="dropdown-item" target="_blank" href="'.$CFG->wwwroot.'/message/index.php?id='.$teacher->id.'"><span class="sr-only">Envoyer un message à (nouvel onglet) : </span>'.$teacher->firstname.' '.$teacher->lastname.'</a>';
+				else {
+					$this->_content .= '<div class="btn"></div>';
 				}
-				$this->_content .= '<span class="dropdown-header">Tous les groupes</span>';
-			}
-			foreach ($infos['teachers'] as $teacher) {
-				$this->_content .= '<a class="dropdown-item" target="_blank" href="'.$CFG->wwwroot.'/message/index.php?id='.$teacher->id.'"><span class="sr-only">Envoyer un message à (nouvel onglet) : </span>'.$teacher->firstname.' '.$teacher->lastname.'</a>';
-			}
-			$this->_content .= '</div></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
+				/*if ( $infos['teachers'] !== false ) {
+					$this->_content .= '<div class="dropdown iena-course-h-message"><a class="btn btn-outline-primary dropdown-toggle" href="#" role="button" id="iena-course-h-message" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="sr-only">Contact : </span>Enseignants</a><div class="dropdown-menu dropdown-menu-right" aria-labelledby="iena-course-h-message">';
+					$my_group_teachers = [];
+					foreach ($infos['teachers'] as $teacher) {
+						// echo "<pre>";
+						// var_dump($teacher->id);
+						$teacher_groups = groups_get_user_groups($COURSE->id, $teacher->id)[0];
+						// var_dump($teacher_groups);
+						$user_groups = groups_get_user_groups($COURSE->id, $USER->id)[0];
+						// var_dump($user_groups);
+						$user_is_in_teacher_group = false;
+						foreach ($user_groups as $user_group) {
+							if ( in_array($user_group, $teacher_groups) ) {
+								$user_is_in_teacher_group = true;
+								$my_group_teachers[] = $teacher;
+								break;
+							}
+						}
+						// var_dump($user_is_in_teacher_group);
+						// echo "<hr>";
+						// echo "</pre>";
+					}
+					if ( count($my_group_teachers) > 0 ) {	
+						$this->_content .= '<span class="dropdown-header">Mon groupe</span>';
+						foreach ($my_group_teachers as $teacher) {
+							$this->_content .= '<a class="dropdown-item" target="_blank" href="'.$CFG->wwwroot.'/message/index.php?id='.$teacher->id.'"><span class="sr-only">Envoyer un message à (nouvel onglet) : </span>'.$teacher->firstname.' '.$teacher->lastname.'</a>';
+						}
+						$this->_content .= '<span class="dropdown-header">Tous les groupes</span>';
+					}
+					foreach ($infos['teachers'] as $teacher) {
+						$this->_content .= '<a class="dropdown-item" target="_blank" href="'.$CFG->wwwroot.'/message/index.php?id='.$teacher->id.'"><span class="sr-only">Envoyer un message à (nouvel onglet) : </span>'.$teacher->firstname.' '.$teacher->lastname.'</a>';
+					}
+					$this->_content .= '</div></div>';
+				}*/
+
+				// ATTENDANCE : button to help with attendance mod if one
+				// if ( $infos['attendance'] !== false ) {
+				// 	$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>';
+					$this->_content .= '<script src="'.$CFG->wwwroot.'/course/format/iena/js/groups.js"></script>';
+					$this->_content .= '<script>function change_grouplink(obj) {
+						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>';
+					$this->_content .= '<span class="form-inline iena-course-h-group">
+					<div class="input-group-prepend">
+					<label class="input-group-text orange-bg" for="select-group">Groupe</label>
+					</div>
+					<select class="custom-select form-control" id="select-group">';
+					$this->_content .= '<option value="id_groupe0" selected>Tous les groupes</option>';
+					$this->_content .= '<optgroup label="Mes groupes">';
+					$user_groups = groups_get_user_groups($COURSE->id, $USER->id)[0];
+					foreach ($infos['groups'] as $group) {
+						if ( in_array($group['id'], $user_groups ) ) {
+							$this->_content .= '<option value="id_groupe'.$group['id'].'">'.$group['name'].'</option>';
+						}
+					}
+					$this->_content .= '</optgroup>';
 
-		// ATTENDANCE : button to help with attendance mod if one
-		// if ( $infos['attendance'] !== false ) {
-		// 	$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>';
-			$this->_content .= '<script src="'.$CFG->wwwroot.'/course/format/iena/js/groups.js"></script>';
-			$this->_content .= '<script>function change_grouplink(obj) {
-				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>';
-			$this->_content .= '<span class="form-inline iena-course-h-group">
-			<div class="input-group-prepend">
-			<label class="input-group-text orange-bg" for="select-group">Groupe</label>
-			</div>
-			<select class="custom-select form-control" id="select-group">';
-			$this->_content .= '<option value="id_groupe0" selected>Tous les groupes</option>';
-			$this->_content .= '<optgroup label="Mes groupes">';
-			$user_groups = groups_get_user_groups($COURSE->id, $USER->id)[0];
-			foreach ($infos['groups'] as $group) {
-				if ( in_array($group['id'], $user_groups ) ) {
-					$this->_content .= '<option value="id_groupe'.$group['id'].'">'.$group['name'].'</option>';
-				}
-			}
-			$this->_content .= '</optgroup>';
+					if (has_capability('course/iena:suivi_edit', $context = context_course::instance($COURSE->id), $USER->id)) {
+						$this->_content .= '<optgroup label="Tous les groupes">';
+						foreach ($infos['groups'] as $group) {
+							$this->_content .= '<option value="id_groupe'.$group['id'].'">'.$group['name'].'</option>';
+						}
+						$this->_content .= '</optgroup>';
+					}
 
-			if (has_capability('course/iena:suivi_edit', $context = context_course::instance($COURSE->id), $USER->id)) {
-				$this->_content .= '<optgroup label="Tous les groupes">';
-				foreach ($infos['groups'] as $group) {
-					$this->_content .= '<option value="id_groupe'.$group['id'].'">'.$group['name'].'</option>';
-				}
-				$this->_content .= '</optgroup>';
+					$this->_content .= '</select>
+					</span>';
+				}*/
 			}
 
-			$this->_content .= '</select>
-			</span>';
-		}
+		
+
+
+
 
 		$this->_content .= '</div><div class="iena-h-clear"></div>'; // end of : top
 
-- 
GitLab