From d6e6a7ad00f416629bedb7e00b35958c0c77124f Mon Sep 17 00:00:00 2001
From: Myriam Delaruelle <myriam.delaruelle@univ-lorraine.fr>
Date: Thu, 14 Mar 2024 15:30:33 +0100
Subject: [PATCH] added option to disable activity links to bubbles in the
 student progress dashboard

---
 classes/output/courseformat/content.php |  6 +++++-
 lang/en/format_iena.php                 |  4 +++-
 lang/fr/format_iena.php                 |  4 +++-
 lib.php                                 | 11 +++++++++++
 styles.css                              |  2 +-
 templates/courseformat/content.mustache |  8 ++++++++
 6 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/classes/output/courseformat/content.php b/classes/output/courseformat/content.php
index 4054776..e14b553 100644
--- a/classes/output/courseformat/content.php
+++ b/classes/output/courseformat/content.php
@@ -80,6 +80,9 @@ class content extends content_base {
         $course_data=[];
         $course_data['student']=false;
         //if user is a student
+        $format = course_get_format($COURSE);
+        $formatoptions = $format->get_format_options();
+
         if(!has_capability('course/iena:suivi', $context = \context_course::instance($COURSE->id), $USER->id) &&$infos["progress"]){
             $course_data['progress_total']=$infos['progress']->total;
             
@@ -103,8 +106,9 @@ class content extends content_base {
             }
             $course_data['student']=true;
         }
-
+    
         $course_data['summary']=$COURSE->summary;
+        $course_data['enableclickicons']=$formatoptions['enableclickicons'];
 
         return $course_data;
     }
diff --git a/lang/en/format_iena.php b/lang/en/format_iena.php
index 2afd5a2..40e747c 100644
--- a/lang/en/format_iena.php
+++ b/lang/en/format_iena.php
@@ -108,4 +108,6 @@ $string['display_status']="Enable status \"Waiting for an evaluation from me\"";
 $string['display_groups_help']="Add a column to the table which display the student's group";
 $string['display_custom_help']="This option enables the table customization and allows you to add colors to certain activities (just for you), or to define milestones (for all teachers in the course)";
 $string['display_details_help']="this option allows you to have the details of an assessment on click: grade, date of evaluation, evaluator, etc.";
-$string['display_status_help']="This option adds a new status \"Waiting for an evaluation from me\" which allows you to identify which activities have been completed by the student and require action from the teacher";
\ No newline at end of file
+$string['display_status_help']="This option adds a new status \"Waiting for an evaluation from me\" which allows you to identify which activities have been completed by the student and require action from the teacher";
+$string['enable_icon_click']="Enable clicks on student progress";
+$string['enable_icon_click_help']="By default, students can access directly their activies by clicking on their bubbles in their progress dashboard. You can disable these links so they can't have access to them out of context.";
\ No newline at end of file
diff --git a/lang/fr/format_iena.php b/lang/fr/format_iena.php
index 736030a..7bf6592 100644
--- a/lang/fr/format_iena.php
+++ b/lang/fr/format_iena.php
@@ -108,4 +108,6 @@ $string['display_status']="Activer le statut \"En attente d'évaluation de ma pa
 $string['display_groups_help']="Cette option ajoute une colonne dans le tableau contenant le nom du groupe de l'étudiant.";
 $string['display_custom_help']="Cette option active la personnalisation du tableau et permet d'ajouter des couleurs à certaines activités (personnel), ou de définir des jalons (pour tous les enseignants du cours)";
 $string['display_details_help']="Cette option permet à l'enseignant d'avoir les détails d'une évaluation au clic : note, date de l'évaluation, évaluateur...";
-$string['display_status_help']="Cette option ajoute un statut 'En attente d'évaluation de ma part qui permet de repérer quelles activités ont été complétées par l'étudiant et nécessite une action de la part de l'enseignant";
\ No newline at end of file
+$string['display_status_help']="Cette option ajoute un statut 'En attente d'évaluation de ma part qui permet de repérer quelles activités ont été complétées par l'étudiant et nécessite une action de la part de l'enseignant";
+$string['enable_icon_click']="Activer les pastilles cliquables";
+$string['enable_icon_click_help']="Par défaut, les étudiants peuvent accéder directement aux activités en cliquant sur leur pastille dans leur interface de progression. Vous pouvez désactiver ces liens pour que les étudiants ne puissent pas accéder aux ressources en dehors d'un certain contexte.";
\ No newline at end of file
diff --git a/lib.php b/lib.php
index 64a7111..97d31bf 100644
--- a/lib.php
+++ b/lib.php
@@ -44,6 +44,10 @@ class format_iena extends format_topics {
                 'default' => 1,
                 'type' => PARAM_INT,
             );
+            $courseformatoptions['enableclickicons'] = array(
+                'default'=> 1,
+                'type' => PARAM_INT,
+            );
         }
         if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) {
             $choicetab = array();
@@ -59,6 +63,13 @@ class format_iena extends format_topics {
                 'element_type' => 'select',
                 'element_attributes' => array($choicetab),
             );
+            $courseformatoptions['enableclickicons'] = array(
+                'label' => get_string('enable_icon_click', 'format_iena'),
+                'element_type' => 'select',
+                'element_attributes' => array($choicetab),
+                'help'=> 'enable_icon_click',
+                'help_component'=>'format_iena',
+            );
             $courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit);
         }
         return $courseformatoptions;
diff --git a/styles.css b/styles.css
index f5b1cf0..7d758a0 100644
--- a/styles.css
+++ b/styles.css
@@ -809,7 +809,7 @@ th.th-rotate > div > span {
 }
 .section-progress span.icon-progress::after, .iena-progress-legend span.icon-progress::after{
 	font-size: small;
-	line-height: 17px!important;
+	line-height: 16px!important;
 }
 
 
diff --git a/templates/courseformat/content.mustache b/templates/courseformat/content.mustache
index 3c35596..1b5c3d5 100644
--- a/templates/courseformat/content.mustache
+++ b/templates/courseformat/content.mustache
@@ -205,10 +205,18 @@
                                     <div class="iena-prog-bubble iena-h-prog-mod-item state-{{completion}}">
                                         
                                         <span class="icon-progress"></span>
+                                        {{#enableclickicons}}
                                         <a href="{{url}}" class="iena-prog-link">
                                             
                                             <span class="popover-module">{{name}}</span>
                                         </a>
+                                        {{/enableclickicons}}
+                                        {{^enableclickicons}}
+                                        <div class="iena-prog-link">
+                                            
+                                            <span class="popover-module">{{name}}</span>
+                                        </div>
+                                        {{/enableclickicons}}
                                     </div>
                                 {{/modules}}
                                 </div>
-- 
GitLab