From 7884b0dbeb6b753cf10559449581e7be5dedaa44 Mon Sep 17 00:00:00 2001
From: Myriam Delaruelle <myriam.delaruelle@univ-lorraine.fr>
Date: Tue, 15 Oct 2024 16:12:52 +0200
Subject: [PATCH] fixed icon

---
 amd/build/header.js                             |  16 +++++++++++-----
 amd/build/suivi-table.js                        |   8 +++-----
 .../courseformat/content/section/header.php     |   6 ++++++
 pix/bar-progress.png                            | Bin 0 -> 1884 bytes
 pix/bar-progress_svg.svg                        |  12 ++++++++++++
 styles.css                                      |  16 ++++++++++++++++
 suivi_unit.php                                  |  10 +++++++---
 .../content/section/header.mustache             |   2 +-
 templates/suivi-table.mustache                  |   7 ++++++-
 9 files changed, 62 insertions(+), 15 deletions(-)
 create mode 100644 pix/bar-progress.png
 create mode 100644 pix/bar-progress_svg.svg

diff --git a/amd/build/header.js b/amd/build/header.js
index 26243b7..354768f 100644
--- a/amd/build/header.js
+++ b/amd/build/header.js
@@ -27,7 +27,6 @@ define(['jquery', 'core/ajax', 'core/str'],
        	return{
        		
        		registerHeader:function(){
-                console.log("par ici ?");
                 var heightWrapper= $("#summary-wrapper").css("height");
         
                 if(parseInt(heightWrapper, 10) >= 144){
@@ -62,10 +61,17 @@ define(['jquery', 'core/ajax', 'core/str'],
                     $("#button-collapse").hide();
                 }
                 var menu=$("#drawermenu .nav.navbar");
-                url=window.location.search;
-                console.log(url)
-                menu.append("<li class='nav-item'><a class='nav-link' href='"+url+"/course/format/iena/suivi_unit.php?courseid=3&sectionid=0&groupid=0'><i class='icon fa fa-table fa-fw' title='Notes'></i></a></li>");
-
+                url=window.location.origin+window.location.pathname;
+                split=url.split('/');
+                fullurl="";
+                for(var i=0; i<split.length-1; i++){
+                    fullurl+=split[i]+"/";
+                }
+                urlParams = new URLSearchParams(window.location.search);
+                course=urlParams.get('id');
+                fullurl+='format/iena/suivi_unit.php?courseid='+course+'&sectionid=0&groupid=0';
+                menu.append("<li class='nav-item'><a class='nav-link' href='"+fullurl+"'><i class='icon fa fa-tasks fa-fw' title='Suivi global'></i></a></li>");
+                $("#drawermenu .nav.navbar .nav-item .nav-link").css('padding', "0.5rem 0.8rem");
 	    		
 	    		
        		}
diff --git a/amd/build/suivi-table.js b/amd/build/suivi-table.js
index 15ba3a9..e43d9b4 100644
--- a/amd/build/suivi-table.js
+++ b/amd/build/suivi-table.js
@@ -41,13 +41,14 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
        		},
                 //Si l'option de détails au clic est activée, on register l'événement du clic
             registerDetailsClick:function(){
-                completeUrl="http://localhost/moodle4/moodle/course/format/iena/suivi_unit.php?courseid=3&sectionid=7&groupid=0&filter=%E2%89%A50";
+                completeUrl=window.location.href;
+                $(".pointer-help").addClass("hover-details");
                 $(".pointer-help").on("click", function(e){
                     e.stopPropagation();
                     idmodule=$(this).data("module");
                     idetudiant=$(this).parent().data("userid");
                     nometudiant=$(this).siblings('.third-column-iena')[0].innerHTML;
-                    console.log(nometudiant);
+                  
                     
                     //$('#myModal').modal('show');
                     //$('#myModal').modal('hide');
@@ -57,11 +58,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
                         type: 'post',
                         success: function(request) { 
                            parsedrequest=JSON.parse(request)
-                            console.log(parsedrequest);
                             parsedrequest["student"]=nometudiant;
                             
-                             //$("#modal-content").html(parsedrequest["completioninfos"]);
-                            //data=calcPercentage(JSON.parse(request));
                             //On récupère les détails, on va les donner à la modale
                             //
                             templates.render('format_iena/modal-details', parsedrequest)
diff --git a/classes/output/courseformat/content/section/header.php b/classes/output/courseformat/content/section/header.php
index 0b9cb23..8c70242 100644
--- a/classes/output/courseformat/content/section/header.php
+++ b/classes/output/courseformat/content/section/header.php
@@ -4,6 +4,7 @@ namespace format_iena\output\courseformat\content\section;
 
 use core_courseformat\output\local\content\section\header as header_base;
 use format_iena\entity\course_format_iena_completion;
+use pix_icon;
 use context_course;
 
 class header extends header_base{
@@ -64,6 +65,11 @@ class header extends header_base{
         else{
             $data->progress=$this->get_progress_student($course->id, $section, $course);
         }
+        $icon=new pix_icon('bar-progress', 'Progrès global', 'format_iena');
+        $data->iconglobalprogress=$icon->export_for_pix();
+        error_log("pddu");
+        error_log(print_r($data->iconglobalprogress, true));
+
         return $data;
     }
 
diff --git a/pix/bar-progress.png b/pix/bar-progress.png
new file mode 100644
index 0000000000000000000000000000000000000000..63c8d80467832d3d4291465a1eaf12bbf2f3adfc
GIT binary patch
literal 1884
zcmeAS@N?(olHy`uVBq!ia0y~yU}9ikU|7Jx#=yW(_4|q~0|NtRfk$L90|U1Z2s2)~
zTla^7ft}CO#WAE}&fB{e1Eo)ju|1H_x}T`*(03qZ!!F4Uf)VEqC>9tWknG@CXS_p+
z*}6$oP^YV*HY0_5ErViORm-p6t2DTs&(7KYxp>#|=P&;Kv#ZXU^Tg)l%fruAekQL-
zVo2aN=l_3h(i!=EX@{qL+Oyb}i{bH9{a(2S=c36%Ec;Y{+T~~-y}+0-CuPzTrIRNo
zv@$rTc27|-INNZ!QIY9D<|KX1-v4X9on=huzq5>`akWahX?~0`L(ilbwVxrc+ZaCd
z#Vr4Fva)yfRSt&bnkU^Jvo}l+<z%X5Z#X@raR1j@h8y>kp7uXKy)W-VID^FUHJK5Q
z*&FWOUG`???9$qYkJstXm=y6({;WL1y;nL*m&cXXKGaiZSUlyplwDb=Bg2E`@|yi;
z&+pz55iZ=&J*An~q@Ll$@#9nCsxKZrx{HHhvdaJN-a3X0+b2(%XI=Ta_1-QPgWlu6
z84@_IS2_z+oMuUoIxEl6_DOT8`1_RW3<kZ=_!*pUTe7?nVpw+Z4`V|78xf{BX$CbA
z`+m(S?eENc(u5zlo;v5ukYN9JW|7+Y?rppbi>IXX+rDCF_?<oRiA}VO*p|0K2exPY
zW7zQCZ_`tjgxL%QqUwJb4^)3NjNW7YV5w?D;VEwphKBD??JJ+@HtDlARPMRT&v0+?
z?J2f3(ze@K3M4`PUA=iq+`fy!!VQ6Mez7-v&zpGZ^80J`AFi-GFq&o0u%}$TGRgVD
zGR^}UC*y6!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+au^Ucv9#~a)s^ZY<7RH3~?V8zt
zH?Pyb^OPmws!posgZ&%L85rWSCth-Pf4T6d`d?p$u(@hGy*{mcFU@#>afjb0)swOF
z&0l6SZFr@ZTJury94|w|@|fjcPI*@4{qvm5d0^M&DJjOCwoD9L-kPPJzZ0ru@;B6(
zr6Kh36orC`Pf|`eF)WzmdMf$z<u6<I?eAU4d|=h*DGCODpN?->%HXg(FKE`^?JD=%
zb(h{)&afeG&ZggmUp`n0@-W=U2USl&^KQ;hKd}GP{LlO~hcvXT8#gI|Do;;WKbLh*
G2~7ZccJe_0

literal 0
HcmV?d00001

diff --git a/pix/bar-progress_svg.svg b/pix/bar-progress_svg.svg
new file mode 100644
index 0000000..289b3af
--- /dev/null
+++ b/pix/bar-progress_svg.svg
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg id="Calque_1" data-name="Calque 1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 512 512">
+  <defs>
+    <style>
+      .cls-1 {
+        fill: white;
+        stroke-width: 0px;
+      }
+    </style>
+  </defs>
+  <path class="cls-1" d="M448,245v32H192v-32h256ZM48,181c-26.5,0-48,21.5-48,48v64c0,26.5,21.5,48,48,48h416c26.5,0,48-21.5,48-48v-64c0-26.5-21.5-48-48-48H48Z"/>
+</svg>
\ No newline at end of file
diff --git a/styles.css b/styles.css
index 43b93a3..88f3289 100644
--- a/styles.css
+++ b/styles.css
@@ -228,6 +228,12 @@ ul.nav.navbar-nav.ml-auto {
   border-radius: 50px;
 }
 
+.iena-icon-suivi img{
+	margin-right: 0;
+	width: 13px;
+	height: 5px;
+}
+
 .right_info {
 	margin-left: auto;
     display: flex;
@@ -1200,6 +1206,16 @@ border-bottom: 1px solid #dee2e6;
 } 
 
 
+.activity-name:hover{
+	text-decoration: none;
+
+}
+
+.hover-details:hover{
+	cursor: pointer!important;
+	opacity: 0.8;
+
+}
 
 /******************************************************** Paramètres du tableau de suivi ******************************************/
 #iena-suivi-edit .form-inline{
diff --git a/suivi_unit.php b/suivi_unit.php
index 0c652b3..3deaa00 100644
--- a/suivi_unit.php
+++ b/suivi_unit.php
@@ -167,6 +167,10 @@ function get_activities($completion, $activesectionid) {
         $displayname = format_string($activity->name, true, array('context' => $activity->context));
         $module->displayname = strlen($displayname) > 50 ? mb_substr($displayname, 0, 49, 'UTF-8').'…' : $displayname;
         $module->section = $activity->section;
+        if($activity->get_url()){
+             $module->link=$activity->get_url()->out();
+        }
+       
         $modules[] = $module;
         if ($activity->section == $activesectionid || $activesectionid == 0 ) {
             $module->visible = true;
@@ -231,7 +235,7 @@ function set_filters($data, $filters, $symbols, $sections, $groups, $currentuser
 function set_data($data, $modules, $progress, $groups, $activegroupsids, $activesectionid, $listoptions) {
     global $COURSE, $USER, $CFG;
 
-    $data["modules"] = $modules;
+    $data["modules"] = $modules;;
     $countmodules = count($data["modules"]);
 
     $data["students"] = format_progress($progress, $modules, $groups, $activegroupsids, $activesectionid);
@@ -413,7 +417,6 @@ if (isset($_POST['action']) && $_POST['action'] == "details") {
        
         if($lastgradeobject){
             $lastgrade["lastgrade"]=$lastgradeobject->str_long_grade;
-            error_log($lastgrade["lastgrade"]);
             $lastgrade["datelastgrade"]=$lastgradeobject->dategraded;
         }
 
@@ -439,6 +442,7 @@ if (isset($_POST['action']) && $_POST['action'] == "details") {
     $data["completionstate"]=$completiondetails->get_overall_completion();
     $data["competiondetails"] = $completiondetails;
     $data["activityname"]=$cm->name;
+
   
     echo json_encode($data);
 } 
@@ -487,7 +491,7 @@ else if (isset($_POST['action']) && !empty($_POST['action'])) {
             $msg = $_GET["msg_success"];
             $data["msg_success"] = $msg;
         }
-
+        
       
 }
  
diff --git a/templates/courseformat/content/section/header.mustache b/templates/courseformat/content/section/header.mustache
index 44bd46d..2c624e6 100644
--- a/templates/courseformat/content/section/header.mustache
+++ b/templates/courseformat/content/section/header.mustache
@@ -122,7 +122,7 @@
                 <div class="nb_pers set_height mobile-bouton-suivi"><i class="fa fa-tasks"></i></div>
             </a>
             <a href='{{section}}' style='color : white'  data-toggle="tooltip" title="Suivi de la section">
-                <div style="display:block;" class="nb_pers set_height iena-icon-suivi"><i class="fa fa-table"></i></div>
+                <div style="display:block;" class="nb_pers set_height iena-icon-suivi">{{#pix}} bar-progress, format_iena, Progrès global{{/pix}}</div>
             </a>
           
                 
diff --git a/templates/suivi-table.mustache b/templates/suivi-table.mustache
index 718e82e..bad84ec 100644
--- a/templates/suivi-table.mustache
+++ b/templates/suivi-table.mustache
@@ -18,7 +18,12 @@
 							<th class="th-rotate" data-fullname="{{name}}" data-section="{{section}}">
 								<div>
 									<span>
-										{{displayname}}
+										{{#link}}
+											<a href="{{link}}" class="activity-name" target="_blank">{{displayname}}</a>
+										{{/link}}
+										{{^link}}
+											{{displayname}}
+										{{/link}}
 									</span>
 								</div>
 							</th>
-- 
GitLab