From 238d9e84ac6d92e322b3f1d03fffdf9d12702327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Mon, 3 Oct 2016 13:04:49 +0200 Subject: [PATCH] Version 16.8 --- swad_action.c | 9 +++-- swad_action.h | 9 +++-- swad_changelog.h | 8 +++- swad_date.c | 42 +++++++++++++++++++++ swad_date.h | 3 ++ swad_menu.c | 2 +- swad_report.c | 97 +++++++++++++++++++++++++++--------------------- swad_report.h | 5 +-- swad_text.c | 25 ++++++++++++- 9 files changed, 141 insertions(+), 59 deletions(-) diff --git a/swad_action.c b/swad_action.c index ab24762ee..76eda4078 100644 --- a/swad_action.c +++ b/swad_action.c @@ -1285,7 +1285,7 @@ Statistics: 1100. ActSeePhoDeg Show a class photo with the average photos of the students of each degree 1101. ActReqStaCrs Request statistics of courses 1102. ActReqAccGbl Request query of clicks to the complete platform - NEW. ActSeeMyUsgRep Show my usage report + NEW. ActReqMyUsgRep Request my usage report 1103. ActSeeOneSvy Show one survey 1104. ActAnsSvy Answer a survey @@ -1310,6 +1310,7 @@ Statistics: 1123. ActReqAccCrs Request query of clicks in the course 1124. ActSeeAccCrs Query clicks to current course 1125. ActSeeAllStaCrs Show statistics of courses + NEW. ActSeeMyUsgRep Show my usage report NEW. ActPrnMyUsgRep Print my usage report Profile: 1126. ActFrmLogIn Show landing page (forms to log in and to create a new account) @@ -2710,7 +2711,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActSeePhoDeg */{ 447, 2,TabSta,ActSeePhoDeg ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Pho_ShowPhotoDegree ,"classphoto64x64.gif" }, /* ActReqStaCrs */{ 767, 3,TabSta,ActReqStaCrs ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ind_ReqIndicatorsCourses ,"tablestats64x64.gif" }, /* ActReqAccGbl */{ 591, 4,TabSta,ActReqAccGbl ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Sta_SetIniEndDates ,Sta_AskShowGblHits ,"stats64x64.gif" }, - /* ActSeeMyUsgRep */{1582, 5,TabSta,ActSeeMyUsgRep ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rep_ShowMyUsageReport ,"report64x64.png" }, + /* ActReqMyUsgRep */{1586, 5,TabSta,ActReqMyUsgRep ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rep_ReqMyUsageReport ,"report64x64.png" }, // Actions not in menu: /* ActSeeOneSvy */{ 982,-1,TabSta,ActSeeAllSvy ,0x1F8,0x1F8,0x1F8,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Svy_SeeOneSurvey ,NULL}, @@ -2740,7 +2741,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActSeeAccCrs */{ 119,-1,TabSta,ActReqAccGbl ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Sta_SeeCrsAccesses ,NULL}, /* ActSeeAllStaCrs */{ 768,-1,TabSta,ActReqAccGbl ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Ind_ShowIndicatorsCourses ,NULL}, - /* ActPrnMyUsgRep */{1583, 5,TabSta,ActSeeMyUsgRep ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Rep_PrintMyUsageReport ,NULL}, + /* ActSeeMyUsgRep */{1582,-1,TabSta,ActReqMyUsgRep ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rep_ShowMyUsageReport ,NULL}, + /* ActPrnMyUsgRep */{1583, 5,TabSta,ActReqMyUsgRep ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Rep_PrintMyUsageReport ,NULL}, // TabPrf ****************************************************************** // Actions in menu: @@ -4442,6 +4444,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActPrnMyUsgRep, // #1583 ActChkUsrAcc, // #1584 ActAutUsrNew, // #1585 + ActReqMyUsgRep, // #1586 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index 97ffccc66..eb78692f6 100644 --- a/swad_action.h +++ b/swad_action.h @@ -72,9 +72,9 @@ typedef enum typedef int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action -#define Act_NUM_ACTIONS (1+9+51+15+90+70+67+246+186+156+172+36+30+87) +#define Act_NUM_ACTIONS (1+9+51+15+90+70+67+246+186+156+172+36+31+87) -#define Act_MAX_ACTION_COD 1585 +#define Act_MAX_ACTION_COD 1586 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20 @@ -1335,7 +1335,7 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica #define ActSeePhoDeg (ActUnbUsrLst+ 3) #define ActReqStaCrs (ActUnbUsrLst+ 4) #define ActReqAccGbl (ActUnbUsrLst+ 5) -#define ActSeeMyUsgRep (ActUnbUsrLst+ 6) +#define ActReqMyUsgRep (ActUnbUsrLst+ 6) // Secondary actions #define ActSeeOneSvy (ActUnbUsrLst+ 7) @@ -1363,7 +1363,8 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica #define ActSeeAccCrs (ActUnbUsrLst+ 28) #define ActSeeAllStaCrs (ActUnbUsrLst+ 29) -#define ActPrnMyUsgRep (ActUnbUsrLst+ 30) +#define ActSeeMyUsgRep (ActUnbUsrLst+ 30) +#define ActPrnMyUsgRep (ActUnbUsrLst+ 31) /*****************************************************************************/ /******************************** Profile tab ********************************/ diff --git a/swad_changelog.h b/swad_changelog.h index d0c52b3a7..ce40847cb 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -143,14 +143,18 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.7.9 (2016-10-03)" +#define Log_PLATFORM_VERSION "SWAD 16.8 (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.7.9: Oct 03, 2016 Code refactoring in user's usage report. (? lines) + Version 16.8: Oct 03, 2016 New option to view user's usage report. (205720 lines) + 1 change necessary in database: +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1586','es','N','Solicitar mi informe de uso'); + + Version 16.7.9: Oct 03, 2016 Code refactoring in user's usage report. (205650 lines) Version 16.7.8: Oct 03, 2016 Code refactoring in user's usage report. (205632 lines) Version 16.7.7: Oct 03, 2016 Code refactoring in user's usage report. (205609 lines) Version 16.7.6: Oct 03, 2016 Code refactoring in user's usage report. (205591 lines) diff --git a/swad_date.c b/swad_date.c index e7c00fedb..bb304c9e6 100644 --- a/swad_date.c +++ b/swad_date.c @@ -103,6 +103,48 @@ void Dat_GetAndConvertCurrentDateTime (void) Dat_GetDateBefore (&Gbl.Now.Date,&Gbl.Yesterday); } +/*****************************************************************************/ +/********************* Get current date and time in UTC **********************/ +/*****************************************************************************/ +/* +char StrCurrentDateUTC[10+1]; // Example: 2016-10-02 + // 1234567890 +char StrCurrentTimeUTC[8+1]; // Example: 19:03:49 + // 12345678 +*/ +void Dat_GetCurrentDateTimeUTC (char StrCurrentDateUTC[10+1], + char StrCurrentTimeUTC[8+1]) + { + time_t CurrentTime; + struct tm tm_CurrentTime; + + if (StrCurrentDateUTC && + StrCurrentDateUTC) // If both pointers are not NULL + { + /***** Initialize to empty strings *****/ + if (StrCurrentDateUTC) + StrCurrentDateUTC[0] = '\0'; + if (StrCurrentTimeUTC) + StrCurrentTimeUTC[0] = '\0'; + + /***** Get current time UTC *****/ + time (&CurrentTime); + if ((gmtime_r (&CurrentTime,&tm_CurrentTime)) != NULL) + { + if (StrCurrentDateUTC) // If not NULL + sprintf (StrCurrentDateUTC,"%04d-%02d-%02d", + 1900 + tm_CurrentTime.tm_year, // year + 1 + tm_CurrentTime.tm_mon, // month + tm_CurrentTime.tm_mday); // day of the month + if (StrCurrentTimeUTC) // If not NULL + sprintf (StrCurrentTimeUTC,"%02d:%02d:%02d", + tm_CurrentTime.tm_hour, // hours + tm_CurrentTime.tm_min, // minutes + tm_CurrentTime.tm_sec); // seconds + } + } + } + /*****************************************************************************/ /************ Get UNIX time (seconds since 1970 UTC) from string *************/ /*****************************************************************************/ diff --git a/swad_date.h b/swad_date.h index 54b3ead76..67cd207a3 100644 --- a/swad_date.h +++ b/swad_date.h @@ -76,6 +76,9 @@ struct DateTime void Dat_GetStartExecutionTimeUTC (void); void Dat_GetAndConvertCurrentDateTime (void); +void Dat_GetCurrentDateTimeUTC (char StrCurrentDateUTC[10+1], + char StrCurrentTimeUTC[8+1]); + time_t Dat_GetUNIXTimeFromStr (const char *Str); bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDDString); diff --git a/swad_menu.c b/swad_menu.c index 55fad97d6..a1ecf207a 100644 --- a/swad_menu.c +++ b/swad_menu.c @@ -177,7 +177,7 @@ const Act_Action_t Mnu_MenuActions[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB ActSeePhoDeg, ActReqStaCrs, ActReqAccGbl, - ActSeeMyUsgRep, + ActReqMyUsgRep, }, // TabPrf ********** { diff --git a/swad_report.c b/swad_report.c index 8f4dc61fb..7b395cf62 100644 --- a/swad_report.c +++ b/swad_report.c @@ -77,18 +77,18 @@ extern struct Globals Gbl; static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint); static void Rep_PutIconToPrintMyUsageReport (void); -static void Rep_WriteHeader (const char *StrCurrentDate); +static void Rep_WriteHeader (const char *StrCurrentDateUTC); static void Rep_WriteSectionPlatform (void); static void Rep_WriteSectionUsrInfo (void); static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures, struct tm *tm_FirstClickTime, - const char *StrCurrentDate, - const char *StrCurrentTime); + const char *StrCurrentDateUTC, + const char *StrCurrentTimeUTC); static void Rep_WriteSectionGlobalHits (struct UsrFigures *UsrFigures, struct tm *tm_FirstClickTime); static void Rep_WriteSectionCurrentCourses (struct UsrFigures *UsrFigures, struct tm *tm_FirstClickTime, - const char *StrCurrentDate, + const char *StrCurrentDateUTC, unsigned long MaxHitsPerYear); static void Rep_WriteSectionHistoricCourses (struct UsrFigures *UsrFigures, struct tm *tm_FirstClickTime, @@ -119,6 +119,34 @@ static void Rep_DrawBarNumHits (float HitsNum,float HitsMax, /********* Show my usage report (report on my use of the platform) ***********/ /*****************************************************************************/ +void Rep_ReqMyUsageReport (void) + { + extern const char *Txt_Report; + extern const char *Txt_Generate_report; + char StrCurrentDateUTC[10+1]; // Example: 2016-10-02 + // 1234567890 + char StrCurrentTimeUTC[8+1]; // Example: 19:03:49 + // 12345678 + + /***** Get current date-time *****/ + Dat_GetCurrentDateTimeUTC (StrCurrentDateUTC,StrCurrentTimeUTC); + + /***** Form to show my usage report *****/ + Act_FormStart (ActSeeMyUsgRep); + + /***** Start frame *****/ + Lay_StartRoundFrame (NULL,Txt_Report,NULL); + + /***** Header *****/ + Rep_WriteHeader (StrCurrentDateUTC); + + /***** Send button and end frame *****/ + Lay_EndRoundFrameWithButton (Lay_CONFIRM_BUTTON,Txt_Generate_report); + + /***** End of form *****/ + Act_FormEnd (); + } + void Rep_ShowMyUsageReport (void) { Rep_ShowOrPrintMyUsageReport (false); @@ -133,33 +161,16 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint) { extern const char *Txt_Report; struct UsrFigures UsrFigures; - time_t CurrentTime; - struct tm tm_CurrentTime; + struct tm tm_FirstClickTime; - char StrCurrentDate[10+1]; // Example: 2016-10-02 - // 1234567890 - char StrCurrentTime[8+1]; // Example: 19:03:49 - // 12345678 + char StrCurrentDateUTC[10+1]; // Example: 2016-10-02 + // 1234567890 + char StrCurrentTimeUTC[8+1]; // Example: 19:03:49 + // 12345678 unsigned long MaxHitsPerYear; /***** Get current date-time *****/ - time (&CurrentTime); - if ((gmtime_r (&CurrentTime,&tm_CurrentTime)) != NULL) - { - sprintf (StrCurrentDate,"%04d-%02d-%02d", - 1900 + tm_CurrentTime.tm_year, // year - 1 + tm_CurrentTime.tm_mon, // month - tm_CurrentTime.tm_mday); // day of the month - sprintf (StrCurrentTime,"%02d:%02d:%02d", - tm_CurrentTime.tm_hour, // hours - tm_CurrentTime.tm_min, // minutes - tm_CurrentTime.tm_sec); // seconds - } - else - { - StrCurrentDate[0] = '\0'; - StrCurrentTime[0] = '\0'; - } + Dat_GetCurrentDateTimeUTC (StrCurrentDateUTC,StrCurrentTimeUTC); /***** Start frame *****/ if (SeeOrPrint == Rep_SEE) @@ -167,8 +178,8 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint) Rep_PutIconToPrintMyUsageReport); fprintf (Gbl.F.Out,"
\n"); - /***** Head *****/ - Rep_WriteHeader (StrCurrentDate); + /***** Header *****/ + Rep_WriteHeader (StrCurrentDateUTC); /***** Platform *****/ Rep_WriteSectionPlatform (); @@ -181,7 +192,7 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint) if (UsrFigures.FirstClickTimeUTC) gmtime_r (&UsrFigures.FirstClickTimeUTC,&tm_FirstClickTime); Rep_WriteSectionUsrFigures (&UsrFigures,&tm_FirstClickTime, - StrCurrentDate,StrCurrentTime); + StrCurrentDateUTC,StrCurrentTimeUTC); /***** Global hits *****/ Rep_WriteSectionGlobalHits (&UsrFigures,&tm_FirstClickTime); @@ -189,7 +200,7 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint) /***** Current courses *****/ MaxHitsPerYear = Rep_GetMaxHitsPerYear (UsrFigures.FirstClickTimeUTC); Rep_WriteSectionCurrentCourses (&UsrFigures,&tm_FirstClickTime, - StrCurrentDate,MaxHitsPerYear); + StrCurrentDateUTC,MaxHitsPerYear); /***** Historic courses *****/ Rep_WriteSectionHistoricCourses (&UsrFigures,&tm_FirstClickTime, @@ -219,7 +230,7 @@ static void Rep_PutIconToPrintMyUsageReport (void) /******************** Write header of user's usage report ********************/ /*****************************************************************************/ -static void Rep_WriteHeader (const char *StrCurrentDate) +static void Rep_WriteHeader (const char *StrCurrentDateUTC) { extern const char *Txt_Report_of_use_of_PLATFORM; @@ -232,8 +243,8 @@ static void Rep_WriteHeader (const char *StrCurrentDate) /***** Subtitle *****/ fprintf (Gbl.F.Out,"

%s",Gbl.Usrs.Me.UsrDat.FullName); - if (StrCurrentDate[0]) - fprintf (Gbl.F.Out,", %s",StrCurrentDate); + if (StrCurrentDateUTC[0]) + fprintf (Gbl.F.Out,", %s",StrCurrentDateUTC); fprintf (Gbl.F.Out,"

"); /***** End of header *****/ @@ -325,8 +336,8 @@ static void Rep_WriteSectionUsrInfo (void) static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures, struct tm *tm_FirstClickTime, - const char *StrCurrentDate, - const char *StrCurrentTime) + const char *StrCurrentDateUTC, + const char *StrCurrentTimeUTC) { extern const char *Txt_Figures; extern const char *Txt_TIME_Since; @@ -369,9 +380,9 @@ static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures, tm_FirstClickTime->tm_hour, // hours tm_FirstClickTime->tm_min, // minutes tm_FirstClickTime->tm_sec); // seconds - if (StrCurrentDate[0]) + if (StrCurrentDateUTC[0]) fprintf (Gbl.F.Out," %s %s %s UTC", - Txt_TIME_until,StrCurrentDate,StrCurrentTime); + Txt_TIME_until,StrCurrentDateUTC,StrCurrentTimeUTC); if (UsrFigures->NumDays > 0) fprintf (Gbl.F.Out," (%d %s)", UsrFigures->NumDays, @@ -382,8 +393,8 @@ static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures, else // Time of first click is unknown { fprintf (Gbl.F.Out,"?"); - if (StrCurrentDate[0]) - fprintf (Gbl.F.Out," - %s %s UTC",StrCurrentDate,StrCurrentTime); + if (StrCurrentDateUTC[0]) + fprintf (Gbl.F.Out," - %s %s UTC",StrCurrentDateUTC,StrCurrentTimeUTC); } fprintf (Gbl.F.Out,""); @@ -514,7 +525,7 @@ static void Rep_WriteSectionGlobalHits (struct UsrFigures *UsrFigures, static void Rep_WriteSectionCurrentCourses (struct UsrFigures *UsrFigures, struct tm *tm_FirstClickTime, - const char *StrCurrentDate, + const char *StrCurrentDateUTC, unsigned long MaxHitsPerYear) { extern const char *Txt_Courses; @@ -524,8 +535,8 @@ static void Rep_WriteSectionCurrentCourses (struct UsrFigures *UsrFigures, fprintf (Gbl.F.Out,"
" "

%s", Txt_Courses); - if (StrCurrentDate[0]) - fprintf (Gbl.F.Out," (%s)",StrCurrentDate); + if (StrCurrentDateUTC[0]) + fprintf (Gbl.F.Out," (%s)",StrCurrentDateUTC); fprintf (Gbl.F.Out,"

" "
    "); diff --git a/swad_report.h b/swad_report.h index aa1fb18e2..19d5648f5 100644 --- a/swad_report.h +++ b/swad_report.h @@ -27,10 +27,6 @@ /********************************** Headers **********************************/ /*****************************************************************************/ -// #include // For malloc - -// #include "swad_user.h" - /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ @@ -43,6 +39,7 @@ /****************************** Public prototypes ****************************/ /*****************************************************************************/ +void Rep_ReqMyUsageReport (void); void Rep_ShowMyUsageReport (void); void Rep_PrintMyUsageReport (void); diff --git a/swad_text.c b/swad_text.c index cb218e381..fb02aeaf7 100644 --- a/swad_text.c +++ b/swad_text.c @@ -13321,6 +13321,27 @@ const char *Txt_Generate_exam = "Gerar teste"; #endif +const char *Txt_Generate_report = +#if L==1 + "Generar informe"; +#elif L==2 + "Generieren Nutzungsbericht"; +#elif L==3 + "Generate report"; +#elif L==4 + "Generar informe"; +#elif L==5 + "Générer le rapport"; +#elif L==6 + "Generar informe"; // Okoteve traducción +#elif L==7 + "Crea rapporto"; +#elif L==8 + "Wygeneruj raport"; +#elif L==9 + "Gerar relatório"; +#endif + const char *Txt_Get_a_new_password = #if L==1 "Rebre una nova contrasenya"; @@ -19027,7 +19048,7 @@ const char *Txt_MENU_TITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB] = "Visitas" #endif , - // ActSeeMyUsgRep + // ActReqMyUsgRep #if L==1 "Informe" #elif L==2 @@ -20900,7 +20921,7 @@ const char *Txt_MENU_SUBTITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB] = "Estatísticas de acesso à plataforma" #endif , - // ActSeeMyUsgRep + // ActReqMyUsgRep #if L==1 "Informe sobre el meu ús de la plataforma" #elif L==2