@@ -4580,19 +4580,32 @@ public static function show_user_progress(
45804580 ICON_SIZE_SMALL
45814581 ).' ' .get_lang ('MyCourses ' )
45824582 );
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+ }
45834597 $ html .= '<div class="table-responsive"> ' ;
45844598 $ 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> ' ;
45964609
45974610 foreach ($ courses as $ course_code => $ course_title ) {
45984611 $ courseInfo = api_get_course_info ($ course_code );
@@ -4648,7 +4661,6 @@ public static function show_user_progress(
46484661 }
46494662 $ bestScoreAverageNotInLP += $ best ;
46504663 }
4651-
46524664 $ bestScoreAverageNotInLP = round ($ bestScoreAverageNotInLP / count ($ exerciseList ) * 100 , 2 );
46534665 }
46544666
@@ -4673,44 +4685,53 @@ public static function show_user_progress(
46734685 }
46744686 $ url = api_get_course_url ($ course_code , $ session_id );
46754687 $ 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 = '' ;
46814689 if (empty ($ bestScore )) {
4682- $ html . = '- ' ;
4690+ $ bestScoreResult = '- ' ;
46834691 } else {
4684- $ html . = $ bestScore .'% ' ;
4692+ $ bestScoreResult = $ bestScore .'% ' ;
46854693 }
4686-
4687- $ html .= '</td> ' ;
4688-
4689-
4690- $ html .= '<td> ' ;
4691-
4694+ $ bestScoreNotInLP = '' ;
46924695 if (empty ($ bestScoreAverageNotInLP )) {
4693- $ html . = '- ' ;
4696+ $ bestScoreNotInLP = '- ' ;
46944697 } else {
4695- $ html . = $ bestScoreAverageNotInLP .'% ' ;
4698+ $ bestScoreNotInLP = $ bestScoreAverageNotInLP .'% ' ;
46964699 }
46974700
4698- $ html .= '</td> ' ;
4699-
4700- $ html .= '<td> ' .$ last_connection .'</td> ' ;
4701- $ html .= '<td> ' ;
4701+ $ detailsLink = '' ;
47024702 if (isset ($ _GET ['course ' ]) &&
47034703 $ course_code == $ _GET ['course ' ] &&
47044704 empty ($ _GET ['session_id ' ])
47054705 ) {
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> ' ;
47084709 } 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> ' ;
47114713 }
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> ' ;
47144735 }
47154736 $ html .= '</tbody></table> ' ;
47164737 $ html .= '</div> ' ;
0 commit comments