@@ -4580,19 +4580,32 @@ public static function show_user_progress(
4580
4580
ICON_SIZE_SMALL
4581
4581
).' ' .get_lang ('MyCourses ' )
4582
4582
);
4583
+
4584
+ $ columns = [
4585
+ 'course_title ' => get_lang ('Course ' ),
4586
+ 'time_spent ' => get_lang ('TimeSpentInTheCourse ' ),
4587
+ 'progress ' => get_lang ('Progress ' ),
4588
+ 'best_score_in_lp ' => get_lang ('BestScoreInLearningPath ' ),
4589
+ 'best_score_not_in_lp ' => get_lang ('BestScoreNotInLearningPath ' ),
4590
+ 'latest_login ' => get_lang ('LastConnexion ' ),
4591
+ 'details ' => get_lang ('Details ' )
4592
+ ];
4593
+ $ availableColumns = [];
4594
+ if (isset ($ trackingColumns ['my_progress_courses ' ])) {
4595
+ $ availableColumns = $ trackingColumns ['my_progress_courses ' ];
4596
+ }
4583
4597
$ html .= '<div class="table-responsive"> ' ;
4584
4598
$ html .= '<table class="table table-striped table-hover"> ' ;
4585
- $ html .= '<thead> ' ;
4586
- $ html .= '<tr>
4587
- ' .Display::tag ('th ' , get_lang ('Course ' ), array ('width ' =>'300px ' )).'
4588
- ' .Display::tag ('th ' , get_lang ('TimeSpentInTheCourse ' )).'
4589
- ' .Display::tag ('th ' , get_lang ('Progress ' )).'
4590
- ' .Display::tag ('th ' , get_lang ('BestScoreInLearningPath ' )).'
4591
- ' .Display::tag ('th ' , get_lang ('BestScoreNotInLearningPath ' )).'
4592
- ' .Display::tag ('th ' , get_lang ('LastConnexion ' )).'
4593
- ' .Display::tag ('th ' , get_lang ('Details ' )).'
4594
- </tr> ' ;
4595
- $ html .= '</thead><tbody> ' ;
4599
+ $ html .= '<thead><tr> ' ;
4600
+ foreach ($ columns as $ columnKey => $ name ) {
4601
+ if (!empty ($ availableColumns )) {
4602
+ if (isset ($ availableColumns [$ columnKey ]) && $ availableColumns [$ columnKey ] == false ) {
4603
+ continue ;
4604
+ }
4605
+ }
4606
+ $ html .= Display::tag ('th ' , $ name );
4607
+ }
4608
+ $ html .= '</tr></thead><tbody> ' ;
4596
4609
4597
4610
foreach ($ courses as $ course_code => $ course_title ) {
4598
4611
$ courseInfo = api_get_course_info ($ course_code );
@@ -4648,7 +4661,6 @@ public static function show_user_progress(
4648
4661
}
4649
4662
$ bestScoreAverageNotInLP += $ best ;
4650
4663
}
4651
-
4652
4664
$ bestScoreAverageNotInLP = round ($ bestScoreAverageNotInLP / count ($ exerciseList ) * 100 , 2 );
4653
4665
}
4654
4666
@@ -4673,44 +4685,53 @@ public static function show_user_progress(
4673
4685
}
4674
4686
$ url = api_get_course_url ($ course_code , $ session_id );
4675
4687
$ course_url = Display::url ($ course_title , $ url , array ('target ' => SESSION_LINK_TARGET ));
4676
- $ html .= '<td> ' .$ course_url .'</td> ' ;
4677
- $ html .= '<td> ' .$ time .'</td> ' ;
4678
- $ html .= '<td> ' .$ progress .'</td> ' ;
4679
- $ html .= '<td> ' ;
4680
-
4688
+ $ bestScoreResult = '' ;
4681
4689
if (empty ($ bestScore )) {
4682
- $ html . = '- ' ;
4690
+ $ bestScoreResult = '- ' ;
4683
4691
} else {
4684
- $ html . = $ bestScore .'% ' ;
4692
+ $ bestScoreResult = $ bestScore .'% ' ;
4685
4693
}
4686
-
4687
- $ html .= '</td> ' ;
4688
-
4689
-
4690
- $ html .= '<td> ' ;
4691
-
4694
+ $ bestScoreNotInLP = '' ;
4692
4695
if (empty ($ bestScoreAverageNotInLP )) {
4693
- $ html . = '- ' ;
4696
+ $ bestScoreNotInLP = '- ' ;
4694
4697
} else {
4695
- $ html . = $ bestScoreAverageNotInLP .'% ' ;
4698
+ $ bestScoreNotInLP = $ bestScoreAverageNotInLP .'% ' ;
4696
4699
}
4697
4700
4698
- $ html .= '</td> ' ;
4699
-
4700
- $ html .= '<td> ' .$ last_connection .'</td> ' ;
4701
- $ html .= '<td> ' ;
4701
+ $ detailsLink = '' ;
4702
4702
if (isset ($ _GET ['course ' ]) &&
4703
4703
$ course_code == $ _GET ['course ' ] &&
4704
4704
empty ($ _GET ['session_id ' ])
4705
4705
) {
4706
- $ html .= '<a href="#course_session_header"> ' ;
4707
- $ html .= Display::return_icon ('2rightarrow_na.png ' , get_lang ('Details ' ));
4706
+ $ detailsLink .= '<a href="#course_session_header"> ' ;
4707
+ $ detailsLink .= Display::return_icon ('2rightarrow_na.png ' , get_lang ('Details ' ));
4708
+ $ detailsLink .= '</a> ' ;
4708
4709
} else {
4709
- $ html .= '<a href=" ' .api_get_self ().'?course= ' .$ course_code .$ extra_params .'#course_session_header"> ' ;
4710
- $ html .= Display::return_icon ('2rightarrow.png ' , get_lang ('Details ' ));
4710
+ $ detailsLink .= '<a href=" ' .api_get_self ().'?course= ' .$ course_code .$ extra_params .'#course_session_header"> ' ;
4711
+ $ detailsLink .= Display::return_icon ('2rightarrow.png ' , get_lang ('Details ' ));
4712
+ $ detailsLink .= '</a> ' ;
4711
4713
}
4712
- $ html .= '</a> ' ;
4713
- $ html .= '</td></tr> ' ;
4714
+
4715
+ $ result = [
4716
+ 'course_title ' => $ course_url ,
4717
+ 'time_spent ' => $ time ,
4718
+ 'progress ' => $ progress ,
4719
+ 'best_score_in_lp ' => $ bestScoreResult ,
4720
+ 'best_score_not_in_lp ' => $ bestScoreNotInLP ,
4721
+ 'latest_login ' => $ last_connection ,
4722
+ 'details ' => $ detailsLink
4723
+ ];
4724
+
4725
+ foreach ($ result as $ columnKey => $ data ) {
4726
+ if (!empty ($ availableColumns )) {
4727
+ if (isset ($ availableColumns [$ columnKey ]) && $ availableColumns [$ columnKey ] == false ) {
4728
+ continue ;
4729
+ }
4730
+ }
4731
+ $ html .= '<td> ' .$ data .'</td> ' ;
4732
+ }
4733
+
4734
+ $ html .= '</tr> ' ;
4714
4735
}
4715
4736
$ html .= '</tbody></table> ' ;
4716
4737
$ html .= '</div> ' ;
0 commit comments