diff --git a/swad_changelog.h b/swad_changelog.h
index 1af85d94..4b85b213 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -143,13 +143,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 16.8.1 (2016-10-03)"
+#define Log_PLATFORM_VERSION "SWAD 16.9 (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.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)
1 change necessary in database:
diff --git a/swad_config.h b/swad_config.h
index 10104e04..f80c0d74 100644
--- a/swad_config.h
+++ b/swad_config.h
@@ -398,6 +398,9 @@
/* Folder for temporary XML files received to import test questions, inside private swad directory */
#define Cfg_FOLDER_TEST "test" // Created automatically the first time it is accessed
+/* Folder for reports, inside private swad directory */
+#define Cfg_FOLDER_REP "rep" // Created automatically the first time it is accessed
+
/* Folder for compression of assignments and works into a zip files, inside private swad directory */
#define Cfg_FOLDER_ZIP "zip" // Created automatically the first time it is accessed
diff --git a/swad_file.c b/swad_file.c
index 6d4d132d..740e8857 100644
--- a/swad_file.c
+++ b/swad_file.c
@@ -522,6 +522,19 @@ void Fil_CloseXMLFile (void)
}
}
+/*****************************************************************************/
+/***************************** Close report file *****************************/
+/*****************************************************************************/
+
+void Fil_CloseReportFile (void)
+ {
+ if (Gbl.F.Rep)
+ {
+ fclose (Gbl.F.Rep);
+ Gbl.F.Rep = NULL; // To indicate that it is not open
+ }
+ }
+
/*****************************************************************************/
/********** Write a quantity of bytes as bytes, KiB, MiB, GiB or TiB *********/
/*****************************************************************************/
diff --git a/swad_file.h b/swad_file.h
index 7dc78235..c754b2c1 100644
--- a/swad_file.h
+++ b/swad_file.h
@@ -50,6 +50,7 @@ struct Files
FILE *Out; // File with the HTML output of this CGI
FILE *Tmp; // Temporary file to save stdin
FILE *XML; // XML file for syllabus, for directory tree
+ FILE *Rep; // Temporary file to save report
};
#define Fil_MAX_BYTES_FILE_SIZE_STRING 32
@@ -73,7 +74,9 @@ void Fil_CreateDirIfNotExists (const char *Path);
void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDirectory);
void Fil_FastCopyOfFiles (const char *PathSrc,const char *PathTgt);
void Fil_FastCopyOfOpenFiles (FILE *FileSrc,FILE *FileTgt);
+
void Fil_CloseXMLFile (void);
+void Fil_CloseReportFile (void);
void Fil_WriteFileSizeBrief (double SizeInBytes,
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING]);
diff --git a/swad_global.c b/swad_global.c
index 83a1f557..8661061b 100644
--- a/swad_global.c
+++ b/swad_global.c
@@ -116,6 +116,7 @@ void Gbl_InitializeGlobals (void)
Gbl.F.Out = stdout;
Gbl.F.Tmp = NULL;
Gbl.F.XML = NULL;
+ Gbl.F.Rep = NULL; // Report
Gbl.Form.Num = -1; // Number of form. It's increased by 1 at the begin of each form
Gbl.Form.Inside = false; // Set to true inside a form to avoid nested forms
@@ -473,5 +474,6 @@ void Gbl_Cleanup (void)
if (Gbl.F.Tmp)
fclose (Gbl.F.Tmp);
Fil_CloseXMLFile ();
+ Fil_CloseReportFile ();
Par_FreeParams ();
}
diff --git a/swad_profile.c b/swad_profile.c
index 67dfa2ca..a15ae0d5 100644
--- a/swad_profile.c
+++ b/swad_profile.c
@@ -481,7 +481,8 @@ void Prf_ShowDetailsUserProfile (const struct UsrData *UsrDat)
if (UsrFigures.NumDays > 0)
{
fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures.NumClicks /
+ Str_WriteFloatNum (Gbl.F.Out,
+ (float) UsrFigures.NumClicks /
(float) UsrFigures.NumDays);
fprintf (Gbl.F.Out,"/%s ",Txt_day);
Prf_ShowRanking (Prf_GetRankingNumClicksPerDay (UsrDat->UsrCod),
@@ -510,7 +511,8 @@ void Prf_ShowDetailsUserProfile (const struct UsrData *UsrDat)
if (UsrFigures.NumDays > 0)
{
fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures.NumFileViews /
+ Str_WriteFloatNum (Gbl.F.Out,
+ (float) UsrFigures.NumFileViews /
(float) UsrFigures.NumDays);
fprintf (Gbl.F.Out,"/%s)",Txt_day);
}
@@ -536,7 +538,8 @@ void Prf_ShowDetailsUserProfile (const struct UsrData *UsrDat)
if (UsrFigures.NumDays > 0)
{
fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures.NumForPst /
+ Str_WriteFloatNum (Gbl.F.Out,
+ (float) UsrFigures.NumForPst /
(float) UsrFigures.NumDays);
fprintf (Gbl.F.Out,"/%s)",Txt_day);
}
@@ -563,7 +566,8 @@ void Prf_ShowDetailsUserProfile (const struct UsrData *UsrDat)
if (UsrFigures.NumDays > 0)
{
fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures.NumMsgSnt /
+ Str_WriteFloatNum (Gbl.F.Out,
+ (float) UsrFigures.NumMsgSnt /
(float) UsrFigures.NumDays);
fprintf (Gbl.F.Out,"/%s)",Txt_day);
}
@@ -1460,7 +1464,7 @@ void Prf_GetAndShowRankingClicksPerDay (void)
fprintf (Gbl.F.Out,"
",
Gbl.RowEvenOdd);
- Str_WriteFloatNum (NumClicksPerDay);
+ Str_WriteFloatNum (Gbl.F.Out,NumClicksPerDay);
fprintf (Gbl.F.Out," | "
"");
}
diff --git a/swad_report.c b/swad_report.c
index 3fc1aad9..a466dfd8 100644
--- a/swad_report.c
+++ b/swad_report.c
@@ -28,6 +28,7 @@
// #include // For boolean type
// #include // For sprintf
// #include // For string functions
+#include // For unlink
#include "swad_database.h"
#include "swad_global.h"
@@ -79,7 +80,7 @@ extern struct Globals Gbl;
static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint);
static void Rep_PutIconToPrintMyUsageReport (void);
-static void Rep_WriteHeader (const char *StrCurrentDateUTC);
+static void Rep_WriteHeader (FILE *FileDst,const char *StrCurrentDateUTC);
static void Rep_WriteSectionPlatform (void);
static void Rep_WriteSectionUsrInfo (void);
static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures,
@@ -140,7 +141,7 @@ void Rep_ReqMyUsageReport (void)
Lay_StartRoundFrame (NULL,Txt_Report,NULL);
/***** Header *****/
- Rep_WriteHeader (StrCurrentDateUTC);
+ Rep_WriteHeader (Gbl.F.Out,StrCurrentDateUTC);
/***** Send button and end frame *****/
Lay_EndRoundFrameWithButton (Lay_CONFIRM_BUTTON,Txt_Generate_report);
@@ -163,7 +164,8 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint)
{
extern const char *Txt_Report;
struct UsrFigures UsrFigures;
-
+ char PathReports[PATH_MAX+1];
+ char PathFileReport[PATH_MAX+1];
struct tm tm_FirstClickTime;
char StrCurrentDateUTC[10+1]; // Example: 2016-10-02
// 1234567890
@@ -178,10 +180,23 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint)
if (SeeOrPrint == Rep_SEE)
Lay_StartRoundFrame (NULL,Txt_Report,
Rep_PutIconToPrintMyUsageReport);
- fprintf (Gbl.F.Out,"\n");
+
+ /***** Path for reports *****/
+ sprintf (PathReports,"%s/%s",Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_REP);
+ Fil_CreateDirIfNotExists (PathReports);
+
+ /***** Create a new empty syllabus *****/
+ /* Path of the private directory for the file with the report */
+ sprintf (PathFileReport,"%s/%s.html",
+ PathReports,Gbl.UniqueNameEncrypted);
+ if ((Gbl.F.Rep = fopen (PathFileReport,"wb")) == NULL)
+ Lay_ShowErrorAndExit ("Can not create report file.");
+
+ /***** Start file *****/
+ fprintf (Gbl.F.Rep,"
\n");
/***** Header *****/
- Rep_WriteHeader (StrCurrentDateUTC);
+ Rep_WriteHeader (Gbl.F.Rep,StrCurrentDateUTC);
/***** Platform *****/
Rep_WriteSectionPlatform ();
@@ -208,8 +223,21 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint)
Rep_WriteSectionHistoricCourses (&UsrFigures,&tm_FirstClickTime,
MaxHitsPerYear);
+ /***** End file *****/
+ fprintf (Gbl.F.Rep,"
\n");
+
+ /***** Open report file for reading *****/
+ if ((Gbl.F.Rep = fopen (PathFileReport,"rb")) == NULL)
+ Lay_ShowErrorAndExit ("Can not open report file.");
+
+ /***** Copy from report file to output file *****/
+ Fil_FastCopyOfOpenFiles (Gbl.F.Rep,Gbl.F.Out);
+
+ /***** Close and remove report file *****/
+ Fil_CloseReportFile ();
+ unlink (PathFileReport);
+
/***** End frame *****/
- fprintf (Gbl.F.Out,"
\n");
if (SeeOrPrint == Rep_SEE)
Lay_EndRoundFrame ();
}
@@ -232,25 +260,25 @@ static void Rep_PutIconToPrintMyUsageReport (void)
/******************** Write header of user's usage report ********************/
/*****************************************************************************/
-static void Rep_WriteHeader (const char *StrCurrentDateUTC)
+static void Rep_WriteHeader (FILE *FileDst,const char *StrCurrentDateUTC)
{
extern const char *Txt_Report_of_use_of_PLATFORM;
/***** Start of header *****/
- fprintf (Gbl.F.Out,"");
+ fprintf (FileDst,"");
/***** Main title *****/
sprintf (Gbl.Title,Txt_Report_of_use_of_PLATFORM,Cfg_PLATFORM_SHORT_NAME);
- fprintf (Gbl.F.Out,"%s
",Gbl.Title);
+ fprintf (FileDst,"%s
",Gbl.Title);
/***** Subtitle *****/
- fprintf (Gbl.F.Out,"%s",Gbl.Usrs.Me.UsrDat.FullName);
+ fprintf (FileDst,"%s",Gbl.Usrs.Me.UsrDat.FullName);
if (StrCurrentDateUTC[0])
- fprintf (Gbl.F.Out,", %s",StrCurrentDateUTC);
- fprintf (Gbl.F.Out,"
");
+ fprintf (FileDst,", %s",StrCurrentDateUTC);
+ fprintf (FileDst,"
");
/***** End of header *****/
- fprintf (Gbl.F.Out,"\n");
+ fprintf (FileDst,"\n");
}
/*****************************************************************************/
@@ -265,22 +293,22 @@ static void Rep_WriteSectionPlatform (void)
extern const char *Txt_URL;
/***** Start of section *****/
- fprintf (Gbl.F.Out,""
+ fprintf (Gbl.F.Rep,""
"%s
"
"",
Txt_Teaching_platform);
/***** Platform name *****/
- fprintf (Gbl.F.Out,"- %s: %s, %s
",
+ fprintf (Gbl.F.Rep,"- %s: %s, %s
",
Txt_Name,
Cfg_PLATFORM_FULL_NAME,Txt_TAGLINE);
/***** Server URL *****/
- fprintf (Gbl.F.Out,"- %s: %s
",
+ fprintf (Gbl.F.Rep,"- %s: %s
",
Txt_URL,Cfg_URL_SWAD_SERVER,Cfg_URL_SWAD_SERVER);
/***** End of section *****/
- fprintf (Gbl.F.Out,"
"
+ fprintf (Gbl.F.Rep,""
"\n");
}
@@ -299,36 +327,36 @@ static void Rep_WriteSectionUsrInfo (void)
struct Institution Ins;
/***** Start of section *****/
- fprintf (Gbl.F.Out,""
+ fprintf (Gbl.F.Rep,""
"%s
"
"",
Txt_Personal_information);
/***** User's name *****/
- fprintf (Gbl.F.Out,"- %s: %s
",
+ fprintf (Gbl.F.Rep,"- %s: %s
",
Txt_Name,
Gbl.Usrs.Me.UsrDat.FullName);
/***** User's e-mail *****/
- fprintf (Gbl.F.Out,"- %s: %s
",
+ fprintf (Gbl.F.Rep,"- %s: %s
",
Txt_Email,
Gbl.Usrs.Me.UsrDat.Email);
/***** User's country *****/
Cty_GetCountryName (Gbl.Usrs.Me.UsrDat.CtyCod,CtyName);
- fprintf (Gbl.F.Out,"- %s: %s
",
+ fprintf (Gbl.F.Rep,"- %s: %s
",
Txt_Country,
CtyName);
/***** User's institution *****/
Ins.InsCod = Gbl.Usrs.Me.UsrDat.InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
- fprintf (Gbl.F.Out,"- %s: %s
",
+ fprintf (Gbl.F.Rep,"- %s: %s
",
Txt_Institution,
Ins.FullName);
/***** End of section *****/
- fprintf (Gbl.F.Out,"
"
+ fprintf (Gbl.F.Rep,""
"\n");
}
@@ -364,18 +392,18 @@ static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures,
unsigned NumPublicFiles;
/***** Start of section *****/
- fprintf (Gbl.F.Out,""
+ fprintf (Gbl.F.Rep,""
"%s
"
"",
Txt_Figures);
/***** Time since first click until now *****/
- fprintf (Gbl.F.Out,"- %s ",Txt_TIME_Since);
+ fprintf (Gbl.F.Rep,"
- %s ",Txt_TIME_Since);
if (UsrFigures->FirstClickTimeUTC)
{
if (tm_FirstClickTime != NULL)
{
- fprintf (Gbl.F.Out,"%04d-%02d-%02d %02d:%02d:%02d UTC",
+ fprintf (Gbl.F.Rep,"%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
@@ -383,10 +411,10 @@ static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures,
tm_FirstClickTime->tm_min, // minutes
tm_FirstClickTime->tm_sec); // seconds
if (StrCurrentDateUTC[0])
- fprintf (Gbl.F.Out," %s %s %s UTC",
+ fprintf (Gbl.F.Rep," %s %s %s UTC",
Txt_TIME_until,StrCurrentDateUTC,StrCurrentTimeUTC);
if (UsrFigures->NumDays > 0)
- fprintf (Gbl.F.Out," (%d %s)",
+ fprintf (Gbl.F.Rep," (%d %s)",
UsrFigures->NumDays,
(UsrFigures->NumDays == 1) ? Txt_day :
Txt_days);
@@ -394,35 +422,36 @@ static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures,
}
else // Time of first click is unknown
{
- fprintf (Gbl.F.Out,"?");
+ fprintf (Gbl.F.Rep,"?");
if (StrCurrentDateUTC[0])
- fprintf (Gbl.F.Out," - %s %s UTC",StrCurrentDateUTC,StrCurrentTimeUTC);
+ fprintf (Gbl.F.Rep," - %s %s UTC",StrCurrentDateUTC,StrCurrentTimeUTC);
}
- fprintf (Gbl.F.Out,"
");
+ fprintf (Gbl.F.Rep,"");
/***** Number of clicks *****/
- fprintf (Gbl.F.Out,"- %s: ",Txt_Clicks);
+ fprintf (Gbl.F.Rep,"
- %s: ",Txt_Clicks);
if (UsrFigures->NumClicks >= 0)
{
- fprintf (Gbl.F.Out,"%ld",UsrFigures->NumClicks);
+ fprintf (Gbl.F.Rep,"%ld",UsrFigures->NumClicks);
if (UsrFigures->NumDays > 0)
{
- fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures->NumClicks /
+ fprintf (Gbl.F.Rep," (");
+ Str_WriteFloatNum (Gbl.F.Rep,
+ (float) UsrFigures->NumClicks /
(float) UsrFigures->NumDays);
- fprintf (Gbl.F.Out," / %s)",Txt_day);
+ fprintf (Gbl.F.Rep," / %s)",Txt_day);
}
}
else // Number of clicks is unknown
- fprintf (Gbl.F.Out,"?");
- fprintf (Gbl.F.Out,"
");
+ fprintf (Gbl.F.Rep,"?");
+ fprintf (Gbl.F.Rep,"");
/***** 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,"- "
+ fprintf (Gbl.F.Rep,"
- "
"%s: %u %s (%u %s)"
"
",
Txt_Files_uploaded,
@@ -432,67 +461,70 @@ static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures,
NumPublicFiles,Txt_public_FILES);
/***** Number of file views *****/
- fprintf (Gbl.F.Out,"- %s: ",Txt_Downloads);
+ fprintf (Gbl.F.Rep,"
- %s: ",Txt_Downloads);
if (UsrFigures->NumFileViews >= 0)
{
- fprintf (Gbl.F.Out,"%ld %s",
+ fprintf (Gbl.F.Rep,"%ld %s",
UsrFigures->NumFileViews,
(UsrFigures->NumFileViews == 1) ? Txt_download :
Txt_downloads);
if (UsrFigures->NumDays > 0)
{
- fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures->NumFileViews /
+ fprintf (Gbl.F.Rep," (");
+ Str_WriteFloatNum (Gbl.F.Rep,
+ (float) UsrFigures->NumFileViews /
(float) UsrFigures->NumDays);
- fprintf (Gbl.F.Out," / %s)",Txt_day);
+ fprintf (Gbl.F.Rep," / %s)",Txt_day);
}
}
else // Number of file views is unknown
- fprintf (Gbl.F.Out,"?");
- fprintf (Gbl.F.Out,"
");
+ fprintf (Gbl.F.Rep,"?");
+ fprintf (Gbl.F.Rep,"");
/***** Number of posts in forums *****/
- fprintf (Gbl.F.Out,"- %s: ",Txt_Forum_posts);
+ fprintf (Gbl.F.Rep,"
- %s: ",Txt_Forum_posts);
if (UsrFigures->NumForPst >= 0)
{
- fprintf (Gbl.F.Out,"%ld %s",
+ fprintf (Gbl.F.Rep,"%ld %s",
UsrFigures->NumForPst,
(UsrFigures->NumForPst == 1) ? Txt_post :
Txt_posts);
if (UsrFigures->NumDays > 0)
{
- fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures->NumForPst /
+ fprintf (Gbl.F.Rep," (");
+ Str_WriteFloatNum (Gbl.F.Rep,
+ (float) UsrFigures->NumForPst /
(float) UsrFigures->NumDays);
- fprintf (Gbl.F.Out," / %s)",Txt_day);
+ fprintf (Gbl.F.Rep," / %s)",Txt_day);
}
}
else // Number of forum posts is unknown
- fprintf (Gbl.F.Out,"?");
- fprintf (Gbl.F.Out,"
");
+ fprintf (Gbl.F.Rep,"?");
+ fprintf (Gbl.F.Rep,"");
/***** Number of messages sent *****/
- fprintf (Gbl.F.Out,"- %s: ",Txt_Messages_sent);
+ fprintf (Gbl.F.Rep,"
- %s: ",Txt_Messages_sent);
if (UsrFigures->NumMsgSnt >= 0)
{
- fprintf (Gbl.F.Out,"%ld %s",
+ fprintf (Gbl.F.Rep,"%ld %s",
UsrFigures->NumMsgSnt,
(UsrFigures->NumMsgSnt == 1) ? Txt_message :
Txt_messages);
if (UsrFigures->NumDays > 0)
{
- fprintf (Gbl.F.Out," (");
- Str_WriteFloatNum ((float) UsrFigures->NumMsgSnt /
+ fprintf (Gbl.F.Rep," (");
+ Str_WriteFloatNum (Gbl.F.Rep,
+ (float) UsrFigures->NumMsgSnt /
(float) UsrFigures->NumDays);
- fprintf (Gbl.F.Out," / %s)",Txt_day);
+ fprintf (Gbl.F.Rep," / %s)",Txt_day);
}
}
else // Number of messages sent is unknown
- fprintf (Gbl.F.Out,"?");
- fprintf (Gbl.F.Out,"
");
+ fprintf (Gbl.F.Rep,"?");
+ fprintf (Gbl.F.Rep,"");
/***** End of section *****/
- fprintf (Gbl.F.Out,"
"
+ fprintf (Gbl.F.Rep,""
"\n");
}
@@ -506,7 +538,7 @@ static void Rep_WriteSectionGlobalHits (struct UsrFigures *UsrFigures,
extern const char *Txt_Hits;
/***** Start of section *****/
- fprintf (Gbl.F.Out,""
+ fprintf (Gbl.F.Rep,""
"%s
",
Txt_Hits);
@@ -518,7 +550,7 @@ static void Rep_WriteSectionGlobalHits (struct UsrFigures *UsrFigures,
0); // MaxHitsPerYear not passed as an argument but computed inside the function
/***** End of section *****/
- fprintf (Gbl.F.Out,"\n");
+ fprintf (Gbl.F.Rep,"\n");
}
/*****************************************************************************/
@@ -534,12 +566,12 @@ static void Rep_WriteSectionCurrentCourses (struct UsrFigures *UsrFigures,
Rol_Role_t Role;
/***** Start of section *****/
- fprintf (Gbl.F.Out,""
+ fprintf (Gbl.F.Rep,""
"%s",
Txt_Courses);
if (StrCurrentDateUTC[0])
- fprintf (Gbl.F.Out," (%s)",StrCurrentDateUTC);
- fprintf (Gbl.F.Out,"
"
+ fprintf (Gbl.F.Rep," (%s)",StrCurrentDateUTC);
+ fprintf (Gbl.F.Rep,""
"");
/***** Number of courses in which the user is student/teacher *****/
@@ -552,7 +584,7 @@ static void Rep_WriteSectionCurrentCourses (struct UsrFigures *UsrFigures,
MaxHitsPerYear);
/***** End of section *****/
- fprintf (Gbl.F.Out,"
"
+ fprintf (Gbl.F.Rep,""
"\n");
}
@@ -570,12 +602,12 @@ static void Rep_WriteSectionHistoricCourses (struct UsrFigures *UsrFigures,
Rol_Role_t Role;
/***** Start of section *****/
- fprintf (Gbl.F.Out,""
+ fprintf (Gbl.F.Rep,""
"%s (%s)
",
Txt_Courses,Txt_historical_log);
- fprintf (Gbl.F.Out,Txt_Only_courses_with_more_than_X_clicks_are_shown,
+ fprintf (Gbl.F.Rep,Txt_Only_courses_with_more_than_X_clicks_are_shown,
Rep_MIN_CLICKS_CRS);
- fprintf (Gbl.F.Out,"");
+ fprintf (Gbl.F.Rep,"");
/***** Number of courses in which the user clicked as student/teacher *****/
for (Role = Rol_STUDENT;
@@ -587,7 +619,7 @@ static void Rep_WriteSectionHistoricCourses (struct UsrFigures *UsrFigures,
MaxHitsPerYear);
/***** End of section *****/
- fprintf (Gbl.F.Out,"
"
+ fprintf (Gbl.F.Rep,"
"
"\n");
}
@@ -652,14 +684,14 @@ static void Rep_GetAndWriteCurrentCrssOfAUsr (const struct UsrData *UsrDat,Rol_R
NumCrss = Usr_GetNumCrssOfUsrWithARole (UsrDat->UsrCod,Role);
sprintf (Gbl.Title,Txt_USER_in_COURSE,Txt_ROLES_SINGUL_Abc[Role][Gbl.Usrs.Me.UsrDat.Sex]);
- fprintf (Gbl.F.Out,"%s %u %s",
+ fprintf (Gbl.F.Rep,"%s %u %s",
Gbl.Title,
NumCrss,
NumCrss == 1 ? Txt_course :
Txt_courses);
if (NumCrss)
{
- fprintf (Gbl.F.Out," (%u %s / %u %s)",
+ fprintf (Gbl.F.Rep," (%u %s / %u %s)",
Usr_GetNumUsrsInCrssOfAUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Role,Rol_TEACHER),
Txt_teachers_ABBREVIATION,
Usr_GetNumUsrsInCrssOfAUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Role,Rol_STUDENT),
@@ -679,7 +711,7 @@ static void Rep_GetAndWriteCurrentCrssOfAUsr (const struct UsrData *UsrDat,Rol_R
if ((NumCrss = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get courses of a user")))
{
/* Heading row */
- fprintf (Gbl.F.Out,"");
+ fprintf (Gbl.F.Rep,"");
/* Write courses */
for (NumCrs = 1;
@@ -699,14 +731,14 @@ static void Rep_GetAndWriteCurrentCrssOfAUsr (const struct UsrData *UsrDat,Rol_R
}
/* End table */
- fprintf (Gbl.F.Out,"
");
+ fprintf (Gbl.F.Rep,"
");
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
- fprintf (Gbl.F.Out,"");
+ fprintf (Gbl.F.Rep,"");
}
/*****************************************************************************/
@@ -743,7 +775,7 @@ static void Rep_GetAndWriteHistoricCrssOfAUsr (const struct UsrData *UsrDat,Rol_
/* Heading row */
sprintf (Gbl.Title,Txt_Hits_as_a_USER,
Txt_ROLES_SINGUL_abc[Role][Gbl.Usrs.Me.UsrDat.Sex]);
- fprintf (Gbl.F.Out,"%s:"
+ fprintf (Gbl.F.Rep,"%s:"
"",
Gbl.Title);
@@ -765,7 +797,7 @@ static void Rep_GetAndWriteHistoricCrssOfAUsr (const struct UsrData *UsrDat,Rol_
}
/* End of list */
- fprintf (Gbl.F.Out,"
"
+ fprintf (Gbl.F.Rep,""
"");
}
@@ -799,40 +831,40 @@ static void Rep_WriteRowCrsData (long CrsCod,Rol_Role_t Role,
Deg_GetDataOfDegreeByCod (&Deg);
/***** Start row *****/
- fprintf (Gbl.F.Out,"");
+ fprintf (Gbl.F.Rep,"");
if (CrsCod > 0) // CrsCod > 0 in log ==> course selected
{
if (Crs.CrsCod > 0) // Course exists
{
/***** Write course full name *****/
- fprintf (Gbl.F.Out,"%s -",Crs.FullName);
+ fprintf (Gbl.F.Rep,"%s -",Crs.FullName);
/***** Write year *****/
if (Crs.Year)
- fprintf (Gbl.F.Out," %s",Txt_YEAR_OF_DEGREE[Crs.Year]);
+ fprintf (Gbl.F.Rep," %s",Txt_YEAR_OF_DEGREE[Crs.Year]);
/***** Write degree full name *****/
- fprintf (Gbl.F.Out," %s",Deg.FullName);
+ fprintf (Gbl.F.Rep," %s",Deg.FullName);
/***** Write number of teachers / students in course *****/
- fprintf (Gbl.F.Out," (%u %s / %u %s)",
+ fprintf (Gbl.F.Rep," (%u %s / %u %s)",
Usr_GetNumUsrsInCrs (Rol_TEACHER,Crs.CrsCod),Txt_teachers_ABBREVIATION,
Usr_GetNumUsrsInCrs (Rol_STUDENT,Crs.CrsCod),Txt_students_ABBREVIATION);
}
else
- fprintf (Gbl.F.Out,"(%s)",Txt_unknown_removed_course);
+ fprintf (Gbl.F.Rep,"(%s)",Txt_unknown_removed_course);
}
else // CrsCod <= 0 in log ==> no course selected
- fprintf (Gbl.F.Out,"(%s)",Txt_no_course_selected);
+ fprintf (Gbl.F.Rep,"(%s)",Txt_no_course_selected);
/***** Write hits per year for this course *****/
- fprintf (Gbl.F.Out,"
");
+ fprintf (Gbl.F.Rep,"
");
Rep_ShowMyHitsPerYear (false,CrsCod,Role,
FirstClickTimeUTC,tm_FirstClickTime,
MaxHitsPerYear);
- fprintf (Gbl.F.Out,"");
+ fprintf (Gbl.F.Rep,"");
}
/*****************************************************************************/
@@ -915,7 +947,7 @@ static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
Year--)
{
/* Write the year */
- fprintf (Gbl.F.Out,"%04u ",Year);
+ fprintf (Gbl.F.Rep,"%04u ",Year);
/* Draw bar proportional to number of hits */
Rep_DrawBarNumHits (Year == LastYear ? Hits.Num :
@@ -931,7 +963,7 @@ static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
Year--)
{
/* Write the year */
- fprintf (Gbl.F.Out,"%04u ",Year);
+ fprintf (Gbl.F.Rep,"%04u ",Year);
/* Draw bar proportional to number of hits */
Rep_DrawBarNumHits (0.0,Hits.Max,Rep_MAX_BAR_WIDTH);
@@ -955,15 +987,15 @@ static void Rep_DrawBarNumHits (float HitsNum,float HitsMax,
for (i = 0;
i < BarWidth;
i++)
- fprintf (Gbl.F.Out,Rep_BLOCK);
+ fprintf (Gbl.F.Rep,Rep_BLOCK);
/***** Write the number of hits *****/
- fprintf (Gbl.F.Out," ");
- Str_WriteFloatNum (HitsNum);
+ fprintf (Gbl.F.Rep," ");
+ Str_WriteFloatNum (Gbl.F.Rep,HitsNum);
}
else
/***** Write the number of clicks *****/
- fprintf (Gbl.F.Out,"0");
+ fprintf (Gbl.F.Rep,"0");
- fprintf (Gbl.F.Out,"
");
+ fprintf (Gbl.F.Rep,"
");
}
diff --git a/swad_statistic.c b/swad_statistic.c
index 86083ea5..dea9cb58 100644
--- a/swad_statistic.c
+++ b/swad_statistic.c
@@ -1856,7 +1856,7 @@ static void Sta_ShowNumHitsPerUsr (unsigned long NumRows,
UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ? 'c' :
'v',
BarWidth);
- Str_WriteFloatNum (Hits.Num);
+ Str_WriteFloatNum (Gbl.F.Out,Hits.Num);
fprintf (Gbl.F.Out," "
"");
}
@@ -2319,14 +2319,14 @@ static void Sta_DrawBarColors (Sta_ColorType_t ColorType,float HitsMax)
" style=\"width:%upx;\">",
GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH/5,
GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH/5);
- Str_WriteFloatNum ((float) Interval * HitsMax / 5.0);
+ Str_WriteFloatNum (Gbl.F.Out,(float) Interval * HitsMax / 5.0);
fprintf (Gbl.F.Out,"");
}
fprintf (Gbl.F.Out,"",
(GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH/5)/2,
(GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH/5)/2);
- Str_WriteFloatNum (HitsMax);
+ Str_WriteFloatNum (Gbl.F.Out,HitsMax);
fprintf (Gbl.F.Out," | "
""
"");
@@ -2365,7 +2365,7 @@ static void Sta_DrawAccessesPerHourForADay (Sta_ColorType_t ColorType,float Hits
{
Sta_SetColor (ColorType,HitsNum[Hour],HitsMax,&R,&G,&B);
fprintf (Gbl.F.Out,""
" | ",
@@ -2727,7 +2727,7 @@ static void Sta_WriteAccessHour (unsigned Hour,struct Sta_Hits *Hits,unsigned Co
fprintf (Gbl.F.Out,"%u%%
",
(unsigned) (((Hits->Num * 100.0) /
Hits->Total) + 0.5));
- Str_WriteFloatNum (Hits->Num);
+ Str_WriteFloatNum (Gbl.F.Out,Hits->Num);
fprintf (Gbl.F.Out,"
");
BarHeight = (unsigned) (((Hits->Num * 500.0) / Hits->Max) + 0.5);
if (BarHeight == 0)
@@ -3740,7 +3740,7 @@ static void Sta_DrawBarNumHits (char Color,float HitsNum,float HitsMax,float Hit
Gbl.Prefs.IconsURL,Color,BarWidth);
/***** Write the number of hits *****/
- Str_WriteFloatNum (HitsNum);
+ Str_WriteFloatNum (Gbl.F.Out,HitsNum);
fprintf (Gbl.F.Out," (%u",
(unsigned) (((HitsNum * 100.0) /
HitsTotal) + 0.5));
diff --git a/swad_string.c b/swad_string.c
index 3788919a..9394b471 100644
--- a/swad_string.c
+++ b/swad_string.c
@@ -813,7 +813,7 @@ char Str_ConvertToLowerLetter (char Ch)
/******** Write a number in floating point with the correct accuracy *********/
/*****************************************************************************/
-void Str_WriteFloatNum (float Number)
+void Str_WriteFloatNum (FILE *FileDst,float Number)
{
double IntegerPart;
double FractionaryPart;
@@ -822,7 +822,7 @@ void Str_WriteFloatNum (float Number)
FractionaryPart = modf ((double) Number,&IntegerPart);
if (FractionaryPart == 0.0)
- fprintf (Gbl.F.Out,"%.0f",IntegerPart);
+ fprintf (FileDst,"%.0f",IntegerPart);
else
{
if (IntegerPart != 0.0 || FractionaryPart >= 0.1)
@@ -839,7 +839,7 @@ void Str_WriteFloatNum (float Number)
Format = "%.7f";
else
Format = "%e";
- fprintf (Gbl.F.Out,Format,Number);
+ fprintf (FileDst,Format,Number);
}
}
diff --git a/swad_string.h b/swad_string.h
index 6b3845b9..0ef641c7 100644
--- a/swad_string.h
+++ b/swad_string.h
@@ -76,7 +76,7 @@ char *Str_ConvertToLowerText (char *Str);
char Str_ConvertToUpperLetter (char Ch);
char Str_ConvertToLowerLetter (char Ch);
-void Str_WriteFloatNum (float Number);
+void Str_WriteFloatNum (FILE *FileDst,float Number);
void Str_ConvertStrFloatCommaToStrFloatPoint (char *Str);
float Str_GetFloatNumFromStr (const char *Str);
void Str_SetDecimalPointToUS (void);
diff --git a/swad_text.c b/swad_text.c
index 07f959eb..de84a099 100644
--- a/swad_text.c
+++ b/swad_text.c
@@ -27046,7 +27046,7 @@ const char *Txt_Online_tutoring =
"Tutoria on-line";
#endif
-const char *Txt_Only_courses_with_more_than_X_clicks_are_shown =
+const char *Txt_Only_courses_with_more_than_X_clicks_are_shown = // Warning: it is very important to include %u in the following sentences
#if L==1
"Només es mostren les assignatures amb més de %u clics.";
#elif L==2