diff --git a/swad_action.c b/swad_action.c index 76eda407..ecd1a683 100644 --- a/swad_action.c +++ b/swad_action.c @@ -2503,11 +2503,11 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActRemSocComGbl */{1508,-1,TabSoc,ActSeeSocPrf ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_RemoveSocialComUsr ,NULL}, /* ActSeePubPrf */{1402,-1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_GetUsrDatAndShowUserProfile,NULL}, - /* ActCal1stClkTim */{1405,-1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_CalculateFirstClickTime ,NULL}, - /* ActCalNumClk */{1406,-1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_CalculateNumClicks ,NULL}, - /* ActCalNumFilVie */{1409,-1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_CalculateNumFileViews ,NULL}, - /* ActCalNumForPst */{1408,-1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_CalculateNumForPst ,NULL}, - /* ActCalNumMsgSnt */{1407,-1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_CalculateNumMsgSnt ,NULL}, + /* ActCal1stClkTim */{1405,-1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_CalculateFigures ,NULL}, + /* ActCalNumClk */{1406,-1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_CalculateFigures ,NULL}, + /* ActCalNumFilVie */{1409,-1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_CalculateFigures ,NULL}, + /* ActCalNumForPst */{1408,-1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_CalculateFigures ,NULL}, + /* ActCalNumMsgSnt */{1407,-1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_CalculateFigures ,NULL}, /* ActFolUsr */{1410,-1,TabSoc,ActSeeSocPrf ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Fol_FollowUsr ,NULL}, /* ActUnfUsr */{1411,-1,TabSoc,ActSeeSocPrf ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Fol_UnfollowUsr ,NULL}, diff --git a/swad_changelog.h b/swad_changelog.h index 4b85b213..ef3fb847 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -143,13 +143,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.9 (2016-10-03)" +#define Log_PLATFORM_VERSION "SWAD 16.10 (2016-10-03)" #define CSS_FILE "swad15.229.css" #define JS_FILE "swad15.238.1.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 /* + Version 16.11: Oct 03, 2016 Created permalinks to report files. (? lines) + Version 16.10: Oct 03, 2016 All user's figures are calculated in one click. (205795 lines) Version 16.9: Oct 03, 2016 User's usage report is written into a temporary file. (205795 lines) Version 16.8.1: Oct 03, 2016 Do not show courses with a few clicks in user's usage report. (205747 lines) Version 16.8: Oct 03, 2016 New option to view user's usage report. (205720 lines) diff --git a/swad_profile.c b/swad_profile.c index a15ae0d5..0349e0fe 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -756,21 +756,67 @@ static void Prf_ShowRanking (unsigned long Rank,unsigned long NumUsrs) } /*****************************************************************************/ -/********* Calculate first click time and show user's profile again **********/ +/********** Calculate user's figures and show user's profile again ***********/ /*****************************************************************************/ -void Prf_CalculateFirstClickTime (void) +void Prf_CalculateFigures (void) { + struct UsrFigures UsrFigures; + /***** Get user's code *****/ Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Get first click time from log and store as user's figure *****/ - Prf_GetFirstClickFromLogAndStoreAsUsrFigure (Gbl.Usrs.Other.UsrDat.UsrCod); + Prf_GetUsrFigures (Gbl.Usrs.Other.UsrDat.UsrCod,&UsrFigures); + Prf_GetAndStoreAllUsrFigures (Gbl.Usrs.Other.UsrDat.UsrCod,&UsrFigures); /***** Show user's profile again *****/ Prf_GetUsrDatAndShowUserProfile (); } +/*****************************************************************************/ +/*** Calculate and store all figures in user's profile not yet calculated ****/ +/*****************************************************************************/ +// Return true if any figure has been calculated and stored + +bool Prf_GetAndStoreAllUsrFigures (long UsrCod,struct UsrFigures *UsrFigures) + { + bool UsrFiguresModified = false; + + if (!UsrFigures->FirstClickTimeUTC) + { + /***** Get first click time from log and store as user's figure *****/ + Prf_GetFirstClickFromLogAndStoreAsUsrFigure (UsrCod); + UsrFiguresModified = true; + } + if (UsrFigures->NumClicks < 0) + { + /***** Get number of clicks and store as user's figure *****/ + Prf_GetNumClicksAndStoreAsUsrFigure (UsrCod); + UsrFiguresModified = true; + } + if (UsrFigures->NumFileViews < 0) + { + /***** Get number of file views and store as user's figure *****/ + Prf_GetNumFileViewsAndStoreAsUsrFigure (UsrCod); + UsrFiguresModified = true; + } + if (UsrFigures->NumForPst < 0) + { + /***** Get number of forum posts and store as user's figure *****/ + Prf_GetNumForPstAndStoreAsUsrFigure (UsrCod); + UsrFiguresModified = true; + } + if (UsrFigures->NumMsgSnt < 0) + { + /***** Get number of messages sent and store as user's figure *****/ + Prf_GetNumMsgSntAndStoreAsUsrFigure (UsrCod); + UsrFiguresModified = true; + } + + return UsrFiguresModified; + } + /*****************************************************************************/ /*** Get first click of a user from log table and store in user's figures ****/ /*****************************************************************************/ @@ -818,22 +864,6 @@ static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod) } } -/*****************************************************************************/ -/********* Calculate number of clicks and show user's profile again **********/ -/*****************************************************************************/ - -void Prf_CalculateNumClicks (void) - { - /***** Get user's code *****/ - Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); - - /***** Get number of clicks and store as user's figure *****/ - Prf_GetNumClicksAndStoreAsUsrFigure (Gbl.Usrs.Other.UsrDat.UsrCod); - - /***** Show user's profile again *****/ - Prf_GetUsrDatAndShowUserProfile (); - } - /*****************************************************************************/ /* Get number of clicks of a user from log table and store in user's figures */ /*****************************************************************************/ @@ -866,22 +896,6 @@ static void Prf_GetNumClicksAndStoreAsUsrFigure (long UsrCod) } } -/*****************************************************************************/ -/******* Calculate number of file views and show user's profile again *******/ -/*****************************************************************************/ - -void Prf_CalculateNumFileViews (void) - { - /***** Get user's code *****/ - Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); - - /***** Get number of file views and store as user's figure *****/ - Prf_GetNumFileViewsAndStoreAsUsrFigure (Gbl.Usrs.Other.UsrDat.UsrCod); - - /***** Show user's profile again *****/ - Prf_GetUsrDatAndShowUserProfile (); - } - /*****************************************************************************/ /**** Get number of file views sent by a user and store in user's figures ****/ /*****************************************************************************/ @@ -912,22 +926,6 @@ static void Prf_GetNumFileViewsAndStoreAsUsrFigure (long UsrCod) } } -/*****************************************************************************/ -/******* Calculate number of forum posts and show user's profile again *******/ -/*****************************************************************************/ - -void Prf_CalculateNumForPst (void) - { - /***** Get user's code *****/ - Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); - - /***** Get number of forum posts and store as user's figure *****/ - Prf_GetNumForPstAndStoreAsUsrFigure (Gbl.Usrs.Other.UsrDat.UsrCod); - - /***** Show user's profile again *****/ - Prf_GetUsrDatAndShowUserProfile (); - } - /*****************************************************************************/ /**** Get number of forum posts sent by a user and store in user's figures ***/ /*****************************************************************************/ @@ -958,22 +956,6 @@ static void Prf_GetNumForPstAndStoreAsUsrFigure (long UsrCod) } } -/*****************************************************************************/ -/****** Calculate number of messages sent and show user's profile again ******/ -/*****************************************************************************/ - -void Prf_CalculateNumMsgSnt (void) - { - /***** Get user's code *****/ - Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); - - /***** Get number of messages sent and store as user's figure *****/ - Prf_GetNumMsgSntAndStoreAsUsrFigure (Gbl.Usrs.Other.UsrDat.UsrCod); - - /***** Show user's profile again *****/ - Prf_GetUsrDatAndShowUserProfile (); - } - /*****************************************************************************/ /***** Get number of messages sent by a user and store in user's figures *****/ /*****************************************************************************/ diff --git a/swad_profile.h b/swad_profile.h index c4b8c269..4154de0c 100644 --- a/swad_profile.h +++ b/swad_profile.h @@ -61,11 +61,8 @@ void Prf_ChangeProfileVisibility (void); void Prf_ShowDetailsUserProfile (const struct UsrData *UsrDat); void Prf_GetUsrFigures (long UsrCod,struct UsrFigures *UsrFigures); -void Prf_CalculateFirstClickTime (void); -void Prf_CalculateNumClicks (void); -void Prf_CalculateNumFileViews (void); -void Prf_CalculateNumForPst (void); -void Prf_CalculateNumMsgSnt (void); +void Prf_CalculateFigures (void); +bool Prf_GetAndStoreAllUsrFigures (long UsrCod,struct UsrFigures *UsrFigures); void Prf_CreateNewUsrFigures (long UsrCod); void Prf_RemoveUsrFigures (long UsrCod); diff --git a/swad_report.c b/swad_report.c index a466dfd8..71687d4c 100644 --- a/swad_report.c +++ b/swad_report.c @@ -124,7 +124,7 @@ static void Rep_DrawBarNumHits (float HitsNum,float HitsMax, void Rep_ReqMyUsageReport (void) { - extern const char *Txt_Report; + extern const char *Txt_Report_of_use_of_PLATFORM; extern const char *Txt_Generate_report; char StrCurrentDateUTC[10+1]; // Example: 2016-10-02 // 1234567890 @@ -138,10 +138,14 @@ void Rep_ReqMyUsageReport (void) Act_FormStart (ActSeeMyUsgRep); /***** Start frame *****/ - Lay_StartRoundFrame (NULL,Txt_Report,NULL); + sprintf (Gbl.Title,Txt_Report_of_use_of_PLATFORM,Cfg_PLATFORM_SHORT_NAME); + Lay_StartRoundFrame (NULL,Gbl.Title,NULL); /***** Header *****/ - Rep_WriteHeader (Gbl.F.Out,StrCurrentDateUTC); + fprintf (Gbl.F.Out,"
%s",Gbl.Usrs.Me.UsrDat.FullName); + if (StrCurrentDateUTC[0]) + fprintf (Gbl.F.Out,"
%s",StrCurrentDateUTC); + fprintf (Gbl.F.Out,"
"); /***** Send button and end frame *****/ Lay_EndRoundFrameWithButton (Lay_CONFIRM_BUTTON,Txt_Generate_report); @@ -171,6 +175,7 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint) // 1234567890 char StrCurrentTimeUTC[8+1]; // Example: 19:03:49 // 12345678 + bool GetUsrFiguresAgain; unsigned long MaxHitsPerYear; /***** Get current date-time *****/ @@ -206,6 +211,10 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint) /***** Figures *****/ Prf_GetUsrFigures (Gbl.Usrs.Me.UsrDat.UsrCod,&UsrFigures); + GetUsrFiguresAgain = Prf_GetAndStoreAllUsrFigures (Gbl.Usrs.Me.UsrDat.UsrCod,&UsrFigures); + if (GetUsrFiguresAgain) + Prf_GetUsrFigures (Gbl.Usrs.Me.UsrDat.UsrCod,&UsrFigures); + if (UsrFigures.FirstClickTimeUTC) gmtime_r (&UsrFigures.FirstClickTimeUTC,&tm_FirstClickTime); Rep_WriteSectionUsrFigures (&UsrFigures,&tm_FirstClickTime,