diff --git a/swad_changelog.h b/swad_changelog.h
index 351d4dae8..9008cdff2 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -143,13 +143,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 16.7.5 (2016-10-03)"
+#define Log_PLATFORM_VERSION "SWAD 16.7.6 (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.6: Oct 03, 2016 Code refactoring in user's usage report. (205591 lines)
Version 16.7.5: Oct 03, 2016 Code refactoring in user's usage report. (205570 lines)
Version 16.7.4: Oct 03, 2016 Code refactoring in user's usage report. (205557 lines)
Version 16.7.3: Oct 03, 2016 User's ID is removed from user's usage report. (205533 lines)
diff --git a/swad_report.c b/swad_report.c
index 6073bcea1..1c28fa0eb 100644
--- a/swad_report.c
+++ b/swad_report.c
@@ -80,6 +80,10 @@ static void Rep_PutIconToPrintMyUsageReport (void);
static void Rep_WriteHeader (const char *StrCurrentDate);
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);
static unsigned long Rep_GetMaxHitsPerYear (time_t FirstClickTimeUTC);
static void Rep_GetAndWriteCurrentCrssOfAUsr (const struct UsrData *UsrDat,Rol_Role_t Role,
@@ -119,25 +123,6 @@ void Rep_PrintMyUsageReport (void)
static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint)
{
extern const char *Txt_Report;
- extern const char *Txt_Figures;
- extern const char *Txt_TIME_Since;
- extern const char *Txt_TIME_until;
- extern const char *Txt_day;
- extern const char *Txt_days;
- extern const char *Txt_Clicks;
- extern const char *Txt_Files_uploaded;
- extern const char *Txt_file;
- extern const char *Txt_files;
- extern const char *Txt_public_FILES;
- extern const char *Txt_Downloads;
- extern const char *Txt_download;
- extern const char *Txt_downloads;
- extern const char *Txt_Forum_posts;
- extern const char *Txt_post;
- extern const char *Txt_posts;
- extern const char *Txt_Messages_sent;
- extern const char *Txt_message;
- extern const char *Txt_messages;
extern const char *Txt_Courses;
extern const char *Txt_historical_log;
extern const char *Txt_Hits;
@@ -149,8 +134,6 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint)
// 1234567890
char StrCurrentTime[8+1]; // Example: 19:03:49
// 12345678
- unsigned NumFiles;
- unsigned NumPublicFiles;
Rol_Role_t Role;
unsigned long MaxHitsPerYear;
@@ -190,136 +173,11 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint)
Rep_WriteSectionUsrInfo ();
/***** Figures *****/
- fprintf (Gbl.F.Out,"
%s
"
- "",
- Txt_Figures);
-
- /* Get figures */
Prf_GetUsrFigures (Gbl.Usrs.Me.UsrDat.UsrCod,&UsrFigures);
-
- /* Time since first click until now */
- fprintf (Gbl.F.Out,"- %s ",Txt_TIME_Since);
if (UsrFigures.FirstClickTimeUTC)
- {
- if ((gmtime_r (&UsrFigures.FirstClickTimeUTC,&tm_FirstClickTime)) != NULL)
- {
- fprintf (Gbl.F.Out,"%04d-%02d-%02d %02d:%02d:%02d UTC",
- 1900 + tm_FirstClickTime.tm_year, // year
- 1 + tm_FirstClickTime.tm_mon, // month
- tm_FirstClickTime.tm_mday, // day of the month
- tm_FirstClickTime.tm_hour, // hours
- tm_FirstClickTime.tm_min, // minutes
- tm_FirstClickTime.tm_sec); // seconds
- if (StrCurrentDate[0])
- fprintf (Gbl.F.Out," %s %s %s UTC",
- Txt_TIME_until,StrCurrentDate,StrCurrentTime);
- if (UsrFigures.NumDays > 0)
- fprintf (Gbl.F.Out," (%d %s)",
- UsrFigures.NumDays,
- (UsrFigures.NumDays == 1) ? Txt_day :
- Txt_days);
- }
- }
- else // Time of first click is unknown
- {
- fprintf (Gbl.F.Out,"?");
- if (StrCurrentDate[0])
- fprintf (Gbl.F.Out," - %s %s UTC",StrCurrentDate,StrCurrentTime);
- }
- fprintf (Gbl.F.Out,"
");
-
- /* Number of clicks */
- fprintf (Gbl.F.Out,"- %s: ",Txt_Clicks);
- if (UsrFigures.NumClicks >= 0)
- {
- fprintf (Gbl.F.Out,"%ld",UsrFigures.NumClicks);
- if (UsrFigures.NumDays > 0)
- {
- fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures.NumClicks /
- (float) UsrFigures.NumDays);
- fprintf (Gbl.F.Out," / %s)",Txt_day);
- }
- }
- else // Number of clicks is unknown
- fprintf (Gbl.F.Out,"?");
- fprintf (Gbl.F.Out,"
");
-
- /* Number of files currently published */
- if ((NumFiles = Brw_GetNumFilesUsr (Gbl.Usrs.Me.UsrDat.UsrCod)))
- NumPublicFiles = Brw_GetNumPublicFilesUsr (Gbl.Usrs.Me.UsrDat.UsrCod);
- else
- NumPublicFiles = 0;
- fprintf (Gbl.F.Out,"- "
- "%s: %u %s (%u %s)"
- "
",
- Txt_Files_uploaded,
- NumFiles,
- (NumFiles == 1) ? Txt_file :
- Txt_files,
- NumPublicFiles,Txt_public_FILES);
-
- /* Number of file views */
- fprintf (Gbl.F.Out,"- %s: ",Txt_Downloads);
- if (UsrFigures.NumFileViews >= 0)
- {
- fprintf (Gbl.F.Out,"%ld %s",
- UsrFigures.NumFileViews,
- (UsrFigures.NumFileViews == 1) ? Txt_download :
- Txt_downloads);
- if (UsrFigures.NumDays > 0)
- {
- fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures.NumFileViews /
- (float) UsrFigures.NumDays);
- fprintf (Gbl.F.Out," / %s)",Txt_day);
- }
- }
- else // Number of file views is unknown
- fprintf (Gbl.F.Out,"?");
- fprintf (Gbl.F.Out,"
");
-
- /* Number of posts in forums */
- fprintf (Gbl.F.Out,"- %s: ",Txt_Forum_posts);
- if (UsrFigures.NumForPst >= 0)
- {
- fprintf (Gbl.F.Out,"%ld %s",
- UsrFigures.NumForPst,
- (UsrFigures.NumForPst == 1) ? Txt_post :
- Txt_posts);
- if (UsrFigures.NumDays > 0)
- {
- fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures.NumForPst /
- (float) UsrFigures.NumDays);
- fprintf (Gbl.F.Out," / %s)",Txt_day);
- }
- }
- else // Number of forum posts is unknown
- fprintf (Gbl.F.Out,"?");
- fprintf (Gbl.F.Out,"
");
-
- /* Number of messages sent */
- fprintf (Gbl.F.Out,"- %s: ",Txt_Messages_sent);
- if (UsrFigures.NumMsgSnt >= 0)
- {
- fprintf (Gbl.F.Out,"%ld %s",
- UsrFigures.NumMsgSnt,
- (UsrFigures.NumMsgSnt == 1) ? Txt_message :
- Txt_messages);
- if (UsrFigures.NumDays > 0)
- {
- fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures.NumMsgSnt /
- (float) UsrFigures.NumDays);
- fprintf (Gbl.F.Out," / %s)",Txt_day);
- }
- }
- else // Number of messages sent is unknown
- fprintf (Gbl.F.Out,"?");
- fprintf (Gbl.F.Out,"
");
-
- fprintf (Gbl.F.Out,"
");
+ gmtime_r (&UsrFigures.FirstClickTimeUTC,&tm_FirstClickTime);
+ Rep_WriteSectionUsrFigures (&UsrFigures,&tm_FirstClickTime,
+ StrCurrentDate,StrCurrentTime);
/***** Global hits *****/
fprintf (Gbl.F.Out,"%s
",Txt_Hits);
@@ -487,6 +345,170 @@ static void Rep_WriteSectionUsrInfo (void)
"");
}
+/*****************************************************************************/
+/********* Write section for user's figures in user's usage report ***********/
+/*****************************************************************************/
+
+static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures,
+ struct tm *tm_FirstClickTime,
+ const char *StrCurrentDate,
+ const char *StrCurrentTime)
+ {
+ extern const char *Txt_Figures;
+ extern const char *Txt_TIME_Since;
+ extern const char *Txt_TIME_until;
+ extern const char *Txt_day;
+ extern const char *Txt_days;
+ extern const char *Txt_Clicks;
+ extern const char *Txt_Files_uploaded;
+ extern const char *Txt_file;
+ extern const char *Txt_files;
+ extern const char *Txt_public_FILES;
+ extern const char *Txt_Downloads;
+ extern const char *Txt_download;
+ extern const char *Txt_downloads;
+ extern const char *Txt_Forum_posts;
+ extern const char *Txt_post;
+ extern const char *Txt_posts;
+ extern const char *Txt_Messages_sent;
+ extern const char *Txt_message;
+ extern const char *Txt_messages;
+ unsigned NumFiles;
+ unsigned NumPublicFiles;
+
+ /***** Start of section *****/
+ fprintf (Gbl.F.Out,""
+ "%s
"
+ "",
+ Txt_Figures);
+
+ /***** Time since first click until now *****/
+ fprintf (Gbl.F.Out,"- %s ",Txt_TIME_Since);
+ if (UsrFigures->FirstClickTimeUTC)
+ {
+ if (tm_FirstClickTime != NULL)
+ {
+ fprintf (Gbl.F.Out,"%04d-%02d-%02d %02d:%02d:%02d UTC",
+ 1900 + tm_FirstClickTime->tm_year, // year
+ 1 + tm_FirstClickTime->tm_mon, // month
+ tm_FirstClickTime->tm_mday, // day of the month
+ tm_FirstClickTime->tm_hour, // hours
+ tm_FirstClickTime->tm_min, // minutes
+ tm_FirstClickTime->tm_sec); // seconds
+ if (StrCurrentDate[0])
+ fprintf (Gbl.F.Out," %s %s %s UTC",
+ Txt_TIME_until,StrCurrentDate,StrCurrentTime);
+ if (UsrFigures->NumDays > 0)
+ fprintf (Gbl.F.Out," (%d %s)",
+ UsrFigures->NumDays,
+ (UsrFigures->NumDays == 1) ? Txt_day :
+ Txt_days);
+ }
+ }
+ else // Time of first click is unknown
+ {
+ fprintf (Gbl.F.Out,"?");
+ if (StrCurrentDate[0])
+ fprintf (Gbl.F.Out," - %s %s UTC",StrCurrentDate,StrCurrentTime);
+ }
+ fprintf (Gbl.F.Out,"
");
+
+ /***** Number of clicks *****/
+ fprintf (Gbl.F.Out,"- %s: ",Txt_Clicks);
+ if (UsrFigures->NumClicks >= 0)
+ {
+ fprintf (Gbl.F.Out,"%ld",UsrFigures->NumClicks);
+ if (UsrFigures->NumDays > 0)
+ {
+ fprintf (Gbl.F.Out," (");
+ Str_WriteFloatNum ((float) UsrFigures->NumClicks /
+ (float) UsrFigures->NumDays);
+ fprintf (Gbl.F.Out," / %s)",Txt_day);
+ }
+ }
+ else // Number of clicks is unknown
+ fprintf (Gbl.F.Out,"?");
+ fprintf (Gbl.F.Out,"
");
+
+ /***** Number of files currently published *****/
+ if ((NumFiles = Brw_GetNumFilesUsr (Gbl.Usrs.Me.UsrDat.UsrCod)))
+ NumPublicFiles = Brw_GetNumPublicFilesUsr (Gbl.Usrs.Me.UsrDat.UsrCod);
+ else
+ NumPublicFiles = 0;
+ fprintf (Gbl.F.Out,"- "
+ "%s: %u %s (%u %s)"
+ "
",
+ Txt_Files_uploaded,
+ NumFiles,
+ (NumFiles == 1) ? Txt_file :
+ Txt_files,
+ NumPublicFiles,Txt_public_FILES);
+
+ /***** Number of file views *****/
+ fprintf (Gbl.F.Out,"- %s: ",Txt_Downloads);
+ if (UsrFigures->NumFileViews >= 0)
+ {
+ fprintf (Gbl.F.Out,"%ld %s",
+ UsrFigures->NumFileViews,
+ (UsrFigures->NumFileViews == 1) ? Txt_download :
+ Txt_downloads);
+ if (UsrFigures->NumDays > 0)
+ {
+ fprintf (Gbl.F.Out," (");
+ Str_WriteFloatNum ((float) UsrFigures->NumFileViews /
+ (float) UsrFigures->NumDays);
+ fprintf (Gbl.F.Out," / %s)",Txt_day);
+ }
+ }
+ else // Number of file views is unknown
+ fprintf (Gbl.F.Out,"?");
+ fprintf (Gbl.F.Out,"
");
+
+ /***** Number of posts in forums *****/
+ fprintf (Gbl.F.Out,"- %s: ",Txt_Forum_posts);
+ if (UsrFigures->NumForPst >= 0)
+ {
+ fprintf (Gbl.F.Out,"%ld %s",
+ UsrFigures->NumForPst,
+ (UsrFigures->NumForPst == 1) ? Txt_post :
+ Txt_posts);
+ if (UsrFigures->NumDays > 0)
+ {
+ fprintf (Gbl.F.Out," (");
+ Str_WriteFloatNum ((float) UsrFigures->NumForPst /
+ (float) UsrFigures->NumDays);
+ fprintf (Gbl.F.Out," / %s)",Txt_day);
+ }
+ }
+ else // Number of forum posts is unknown
+ fprintf (Gbl.F.Out,"?");
+ fprintf (Gbl.F.Out,"
");
+
+ /***** Number of messages sent *****/
+ fprintf (Gbl.F.Out,"- %s: ",Txt_Messages_sent);
+ if (UsrFigures->NumMsgSnt >= 0)
+ {
+ fprintf (Gbl.F.Out,"%ld %s",
+ UsrFigures->NumMsgSnt,
+ (UsrFigures->NumMsgSnt == 1) ? Txt_message :
+ Txt_messages);
+ if (UsrFigures->NumDays > 0)
+ {
+ fprintf (Gbl.F.Out," (");
+ Str_WriteFloatNum ((float) UsrFigures->NumMsgSnt /
+ (float) UsrFigures->NumDays);
+ fprintf (Gbl.F.Out," / %s)",Txt_day);
+ }
+ }
+ else // Number of messages sent is unknown
+ fprintf (Gbl.F.Out,"?");
+ fprintf (Gbl.F.Out,"
");
+
+ /***** End of section *****/
+ fprintf (Gbl.F.Out,"
"
+ "");
+ }
+
/*****************************************************************************/
/************ Get the maximum number of hits per course-year-role ************/
/*****************************************************************************/