2016-09-08 18:04:30 +02:00
|
|
|
|
// swad_report.c: report on my use of the platform
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2022-09-21 10:46:14 +02:00
|
|
|
|
Copyright (C) 1999-2022 Antonio Ca<EFBFBD>as Vargas
|
2016-09-08 18:04:30 +02:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General 3 License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************************** Headers *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-30 11:50:29 +01:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
|
|
|
|
#include <stdio.h> // For asprintf
|
2019-12-16 09:19:40 +01:00
|
|
|
|
#include <stdlib.h> // For free
|
2016-10-04 02:32:25 +02:00
|
|
|
|
#include <sys/stat.h> // For mkdir
|
|
|
|
|
#include <sys/types.h> // For mkdir
|
2016-09-08 18:04:30 +02:00
|
|
|
|
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2021-09-15 01:54:56 +02:00
|
|
|
|
#include "swad_browser_database.h"
|
2016-09-11 21:25:14 +02:00
|
|
|
|
#include "swad_database.h"
|
2021-11-03 21:31:16 +01:00
|
|
|
|
#include "swad_enrolment_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2016-09-08 19:21:25 +02:00
|
|
|
|
#include "swad_global.h"
|
2021-05-27 23:30:16 +02:00
|
|
|
|
#include "swad_hierarchy_level.h"
|
2019-10-23 20:07:56 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2016-09-11 12:46:52 +02:00
|
|
|
|
#include "swad_ID.h"
|
2021-10-13 14:38:51 +02:00
|
|
|
|
#include "swad_log_database.h"
|
2016-09-08 19:21:25 +02:00
|
|
|
|
#include "swad_profile.h"
|
2021-10-13 10:42:08 +02:00
|
|
|
|
#include "swad_report_database.h"
|
2016-10-08 20:25:26 +02:00
|
|
|
|
#include "swad_tab.h"
|
2016-09-08 18:04:30 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-04 17:21:21 +02:00
|
|
|
|
#define Rep_FILENAME_ROOT "report"
|
|
|
|
|
|
2016-10-03 13:29:05 +02:00
|
|
|
|
#define Rep_MIN_CLICKS_CRS 100 // Minimum number of clicks to show a course in historic log
|
2016-10-08 20:25:26 +02:00
|
|
|
|
#define Rep_MAX_ACTIONS 50 // Maximum number of actions in list of frequent actions
|
2016-10-04 01:16:52 +02:00
|
|
|
|
#define Rep_MAX_BAR_WIDTH 50 // Maximum width of graphic bar
|
2016-10-03 13:29:05 +02:00
|
|
|
|
|
2016-09-12 10:02:17 +02:00
|
|
|
|
// #define Rep_BLOCK "═" // HTML code for a block in graphic bar
|
|
|
|
|
// #define Rep_BLOCK "▒" // HTML code for a block in graphic bar
|
|
|
|
|
// #define Rep_BLOCK "█" // HTML code for a block in graphic bar
|
|
|
|
|
// #define Rep_BLOCK "≡" // HTML code for a block in graphic bar
|
|
|
|
|
// #define Rep_BLOCK "•" // HTML code for a block in graphic bar
|
2016-10-04 01:16:52 +02:00
|
|
|
|
// #define Rep_BLOCK "▪" // HTML code for a block in graphic bar
|
|
|
|
|
#define Rep_BLOCK "-"
|
2016-09-12 10:02:17 +02:00
|
|
|
|
|
2016-09-08 18:04:30 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-09-08 19:21:25 +02:00
|
|
|
|
extern struct Globals Gbl;
|
2016-09-08 18:04:30 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-08 21:49:04 +02:00
|
|
|
|
static void Rep_CreateMyUsageReport (struct Rep_Report *Report);
|
|
|
|
|
static void Rep_PutLinkToMyUsageReport (struct Rep_Report *Report);
|
2019-10-16 00:06:02 +02:00
|
|
|
|
static void Rep_TitleReport (struct Rep_CurrentTimeUTC *CurrentTimeUTC);
|
2016-10-04 00:22:59 +02:00
|
|
|
|
|
2016-10-08 23:47:20 +02:00
|
|
|
|
static void Rep_GetCurrentDateTimeUTC (struct Rep_Report *Report);
|
2016-10-04 17:21:21 +02:00
|
|
|
|
|
2016-10-08 23:50:01 +02:00
|
|
|
|
static void Rep_CreateNewReportFile (struct Rep_Report *Report);
|
2016-10-09 00:05:56 +02:00
|
|
|
|
static void Rep_WriteHeader (const struct Rep_Report *Report);
|
2016-10-03 09:40:10 +02:00
|
|
|
|
static void Rep_WriteSectionPlatform (void);
|
2016-10-03 09:44:32 +02:00
|
|
|
|
static void Rep_WriteSectionUsrInfo (void);
|
2016-10-09 00:20:03 +02:00
|
|
|
|
static void Rep_WriteSectionUsrFigures (const struct Rep_Report *Report);
|
2016-10-09 01:03:30 +02:00
|
|
|
|
static void Rep_WriteSectionHitsPerAction (struct Rep_Report *Report);
|
2016-10-09 00:49:23 +02:00
|
|
|
|
static void Rep_WriteSectionGlobalHits (struct Rep_Report *Report);
|
2016-10-09 01:03:30 +02:00
|
|
|
|
static void Rep_WriteSectionCurrentCourses (struct Rep_Report *Report);
|
|
|
|
|
static void Rep_WriteSectionHistoricCourses (struct Rep_Report *Report);
|
2016-10-03 09:40:10 +02:00
|
|
|
|
|
2016-10-09 01:03:30 +02:00
|
|
|
|
static void Rep_GetMaxHitsPerYear (struct Rep_Report *Report);
|
2016-10-07 02:23:24 +02:00
|
|
|
|
static void Rep_GetAndWriteMyCurrentCrss (Rol_Role_t Role,
|
2016-10-09 01:03:30 +02:00
|
|
|
|
struct Rep_Report *Report);
|
|
|
|
|
static void Rep_GetAndWriteMyHistoricClicsWithoutCrs (struct Rep_Report *Report);
|
2016-10-07 02:23:24 +02:00
|
|
|
|
static void Rep_GetAndWriteMyHistoricCrss (Rol_Role_t Role,
|
2016-10-09 01:03:30 +02:00
|
|
|
|
struct Rep_Report *Report);
|
2016-10-02 19:42:47 +02:00
|
|
|
|
static void Rep_WriteRowCrsData (long CrsCod,Rol_Role_t Role,
|
2016-10-09 01:03:30 +02:00
|
|
|
|
struct Rep_Report *Report,
|
2016-10-07 02:23:24 +02:00
|
|
|
|
bool WriteNumUsrs);
|
2016-10-02 17:56:05 +02:00
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
2016-10-09 01:03:30 +02:00
|
|
|
|
struct Rep_Report *Report);
|
2016-10-08 21:19:47 +02:00
|
|
|
|
static void Rep_ComputeMaxAndTotalHits (struct Rep_Hits *Hits,
|
2021-04-17 01:08:48 +02:00
|
|
|
|
unsigned NumHits,
|
2016-10-08 21:19:47 +02:00
|
|
|
|
MYSQL_RES *mysql_res,unsigned Field);
|
|
|
|
|
static void Rep_DrawBarNumHits (unsigned long HitsNum,unsigned long HitsMax,
|
2016-09-12 10:02:17 +02:00
|
|
|
|
unsigned MaxBarWidth);
|
2016-09-12 00:50:24 +02:00
|
|
|
|
|
2019-12-14 13:35:35 +01:00
|
|
|
|
static void Rep_WriteDouble (double Num);
|
|
|
|
|
|
2016-10-06 22:18:33 +02:00
|
|
|
|
static void Rep_RemoveUsrReportsFiles (long UsrCod);
|
|
|
|
|
|
2016-09-08 18:04:30 +02:00
|
|
|
|
/*****************************************************************************/
|
2016-10-04 00:22:59 +02:00
|
|
|
|
/******* Request my usage report (report on my use of the platform) **********/
|
2016-09-08 18:04:30 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-03 13:04:49 +02:00
|
|
|
|
void Rep_ReqMyUsageReport (void)
|
|
|
|
|
{
|
2017-12-19 18:41:19 +01:00
|
|
|
|
extern const char *Hlp_ANALYTICS_Report;
|
2016-10-03 18:16:05 +02:00
|
|
|
|
extern const char *Txt_Report_of_use_of_PLATFORM;
|
2016-10-03 13:04:49 +02:00
|
|
|
|
extern const char *Txt_Generate_report;
|
2021-12-30 11:50:29 +01:00
|
|
|
|
char *Title;
|
2016-10-03 13:04:49 +02:00
|
|
|
|
|
|
|
|
|
/***** Form to show my usage report *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActSeeMyUsgRep);
|
2016-10-03 13:04:49 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin box *****/
|
2021-12-30 11:50:29 +01:00
|
|
|
|
if (asprintf (&Title,Txt_Report_of_use_of_PLATFORM,Cfg_PLATFORM_SHORT_NAME) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
Box_BoxBegin (NULL,Title,NULL,NULL,Hlp_ANALYTICS_Report,Box_NOT_CLOSABLE);
|
|
|
|
|
free (Title);
|
2016-10-03 13:04:49 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Header *****/
|
|
|
|
|
Rep_TitleReport (NULL); // NULL means do not write date
|
2016-10-03 13:04:49 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Send button and end box *****/
|
|
|
|
|
Box_BoxWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Generate_report);
|
2016-10-03 13:04:49 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2016-10-03 13:04:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-04 00:22:59 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Show my usage report (report on my use of the platform) ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-09-08 18:04:30 +02:00
|
|
|
|
void Rep_ShowMyUsageReport (void)
|
2016-10-04 00:22:59 +02:00
|
|
|
|
{
|
2016-10-08 21:49:04 +02:00
|
|
|
|
struct Rep_Report Report;
|
2016-10-04 00:22:59 +02:00
|
|
|
|
|
|
|
|
|
/***** Create my usage report *****/
|
2016-10-08 21:49:04 +02:00
|
|
|
|
Rep_CreateMyUsageReport (&Report);
|
2016-10-04 00:22:59 +02:00
|
|
|
|
|
|
|
|
|
/***** Put link to my usage report *****/
|
2016-10-08 21:49:04 +02:00
|
|
|
|
Rep_PutLinkToMyUsageReport (&Report);
|
2016-10-04 00:22:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Create my usage report (report on my use of the platform) **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-08 21:49:04 +02:00
|
|
|
|
static void Rep_CreateMyUsageReport (struct Rep_Report *Report)
|
2016-09-09 00:36:44 +02:00
|
|
|
|
{
|
2016-10-03 18:16:05 +02:00
|
|
|
|
bool GetUsrFiguresAgain;
|
2016-10-02 17:56:05 +02:00
|
|
|
|
|
2016-10-02 21:14:07 +02:00
|
|
|
|
/***** Get current date-time *****/
|
2016-10-08 23:47:20 +02:00
|
|
|
|
Rep_GetCurrentDateTimeUTC (Report);
|
2016-10-02 21:14:07 +02:00
|
|
|
|
|
2016-10-06 20:35:10 +02:00
|
|
|
|
/***** Create a new report file *****/
|
2016-10-08 23:50:01 +02:00
|
|
|
|
Rep_CreateNewReportFile (Report);
|
2016-10-03 14:12:01 +02:00
|
|
|
|
|
2016-10-06 20:35:10 +02:00
|
|
|
|
/***** Store report entry into database *****/
|
2021-10-13 10:42:08 +02:00
|
|
|
|
Rep_DB_CreateNewReport (Gbl.Usrs.Me.UsrDat.UsrCod,Report,
|
|
|
|
|
Gbl.UniqueNameEncrypted);
|
2016-10-04 02:32:25 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin file *****/
|
|
|
|
|
Lay_BeginHTMLFile (Gbl.F.Rep,Report->FilenameReport);
|
2016-10-04 23:57:32 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<body style=\"margin:1em;"
|
|
|
|
|
" text-align:left;"
|
|
|
|
|
" font-family:Helvetica,Arial,sans-serif;\">\n");
|
2016-09-11 22:45:53 +02:00
|
|
|
|
|
2016-10-03 13:04:49 +02:00
|
|
|
|
/***** Header *****/
|
2016-10-09 00:05:56 +02:00
|
|
|
|
Rep_WriteHeader (Report);
|
2016-10-02 22:54:30 +02:00
|
|
|
|
|
|
|
|
|
/***** Platform *****/
|
2016-10-03 09:40:10 +02:00
|
|
|
|
Rep_WriteSectionPlatform ();
|
2016-10-02 21:14:07 +02:00
|
|
|
|
|
2016-09-11 22:45:53 +02:00
|
|
|
|
/***** Personal information *****/
|
2016-10-03 09:44:32 +02:00
|
|
|
|
Rep_WriteSectionUsrInfo ();
|
2016-09-11 22:45:53 +02:00
|
|
|
|
|
|
|
|
|
/***** Figures *****/
|
2016-10-08 21:49:04 +02:00
|
|
|
|
Prf_GetUsrFigures (Gbl.Usrs.Me.UsrDat.UsrCod,&Report->UsrFigures);
|
2016-10-09 01:03:30 +02:00
|
|
|
|
GetUsrFiguresAgain = Prf_GetAndStoreAllUsrFigures (Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
&Report->UsrFigures);
|
2016-10-03 18:16:05 +02:00
|
|
|
|
if (GetUsrFiguresAgain)
|
2016-10-08 21:49:04 +02:00
|
|
|
|
Prf_GetUsrFigures (Gbl.Usrs.Me.UsrDat.UsrCod,&Report->UsrFigures);
|
|
|
|
|
if (Report->UsrFigures.FirstClickTimeUTC)
|
2016-10-09 01:03:30 +02:00
|
|
|
|
gmtime_r (&Report->UsrFigures.FirstClickTimeUTC,
|
|
|
|
|
&Report->tm_FirstClickTime);
|
2016-10-09 00:20:03 +02:00
|
|
|
|
Rep_WriteSectionUsrFigures (Report);
|
2016-09-11 22:45:53 +02:00
|
|
|
|
|
2016-10-08 20:25:26 +02:00
|
|
|
|
/***** Global count of hits *****/
|
2016-10-09 00:34:47 +02:00
|
|
|
|
Rep_WriteSectionGlobalHits (Report);
|
2016-10-02 23:38:40 +02:00
|
|
|
|
|
2016-10-08 20:25:26 +02:00
|
|
|
|
/***** Global hits distributed by action *****/
|
2016-10-09 01:03:30 +02:00
|
|
|
|
Rep_WriteSectionHitsPerAction (Report);
|
2016-10-08 20:25:26 +02:00
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
/***** Current courses *****/
|
2016-10-09 01:03:30 +02:00
|
|
|
|
Rep_GetMaxHitsPerYear (Report);
|
2016-10-09 00:37:58 +02:00
|
|
|
|
Rep_WriteSectionCurrentCourses (Report);
|
2016-09-11 22:45:53 +02:00
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
/***** Historic courses *****/
|
2016-10-09 00:49:23 +02:00
|
|
|
|
Rep_WriteSectionHistoricCourses (Report);
|
2016-10-02 17:56:05 +02:00
|
|
|
|
|
2016-10-03 14:12:01 +02:00
|
|
|
|
/***** End file *****/
|
2016-10-04 01:16:52 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</body>\n"
|
2016-10-03 22:41:45 +02:00
|
|
|
|
"</html>\n");
|
2016-10-03 14:12:01 +02:00
|
|
|
|
|
2016-10-03 22:41:45 +02:00
|
|
|
|
/***** Close report file *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
Fil_CloseReportFile ();
|
2016-10-04 00:22:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******* Put link to my usage report (report on my use of the platform) ******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-08 21:49:04 +02:00
|
|
|
|
static void Rep_PutLinkToMyUsageReport (struct Rep_Report *Report)
|
2016-10-04 00:22:59 +02:00
|
|
|
|
{
|
2017-12-19 18:41:19 +01:00
|
|
|
|
extern const char *Hlp_ANALYTICS_Report;
|
2016-10-04 00:22:59 +02:00
|
|
|
|
extern const char *Txt_Report_of_use_of_PLATFORM;
|
|
|
|
|
extern const char *Txt_Report;
|
2016-10-06 23:15:14 +02:00
|
|
|
|
extern const char *Txt_This_link_will_remain_active_as_long_as_your_user_s_account_exists;
|
2021-12-30 11:50:29 +01:00
|
|
|
|
char *Title;
|
2016-10-03 14:12:01 +02:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2021-12-30 11:50:29 +01:00
|
|
|
|
if (asprintf (&Title,Txt_Report_of_use_of_PLATFORM,Cfg_PLATFORM_SHORT_NAME) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
Box_BoxBegin (NULL,Title,NULL,NULL,Hlp_ANALYTICS_Report,Box_NOT_CLOSABLE);
|
|
|
|
|
free (Title);
|
2016-09-09 00:36:44 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Header *****/
|
|
|
|
|
Rep_TitleReport (&Report->CurrentTimeUTC);
|
2019-10-24 00:04:40 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Put anchor and report filename *****/
|
2022-01-10 10:16:50 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"FILENAME_BIG CM\"");
|
|
|
|
|
HTM_A_Begin ("href=\"%s\" class=\"FILENAME_BIG\" title=\"%s\" target=\"_blank\"",
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Report->Permalink,
|
|
|
|
|
Txt_Report);
|
2021-12-22 00:20:06 +01:00
|
|
|
|
Ico_PutIcon ("file-alt.svg",Ico_BLACK,Txt_Report,"ICO64x64");
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_BR ();
|
|
|
|
|
HTM_Txt (Report->FilenameReport);
|
|
|
|
|
HTM_A_End ();
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"DAT_LIGHT_%s\"",The_GetSuffix ());
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_Txt (Txt_This_link_will_remain_active_as_long_as_your_user_s_account_exists);
|
|
|
|
|
HTM_DIV_End ();
|
2016-09-09 00:36:44 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2016-09-09 00:36:44 +02:00
|
|
|
|
}
|
2016-09-11 21:25:14 +02:00
|
|
|
|
|
2016-10-04 00:30:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Write title of user's usage report ********************/
|
|
|
|
|
/*****************************************************************************/
|
2016-10-06 21:31:51 +02:00
|
|
|
|
// CurrentTimeUTC == NULL ==> do not write date
|
2016-10-04 00:30:46 +02:00
|
|
|
|
|
2019-10-16 00:06:02 +02:00
|
|
|
|
static void Rep_TitleReport (struct Rep_CurrentTimeUTC *CurrentTimeUTC)
|
2016-10-04 00:30:46 +02:00
|
|
|
|
{
|
2016-10-04 23:57:32 +02:00
|
|
|
|
extern const char *Txt_User[Usr_NUM_SEXS];
|
|
|
|
|
extern const char *Txt_Date;
|
|
|
|
|
|
2022-03-26 21:08:25 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"TITLE_REPORT DAT_%s\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2016-10-04 23:57:32 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** User *****/
|
|
|
|
|
HTM_TxtColonNBSP (Txt_User[Gbl.Usrs.Me.UsrDat.Sex]);
|
2022-03-26 21:08:25 +01:00
|
|
|
|
HTM_SPAN_Begin ("class=\"DAT_STRONG_%s BOLD\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_Txt (Gbl.Usrs.Me.UsrDat.FullName);
|
2019-11-07 10:24:00 +01:00
|
|
|
|
HTM_SPAN_End ();
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
|
|
|
|
/***** Report date *****/
|
|
|
|
|
if (CurrentTimeUTC)
|
|
|
|
|
{
|
|
|
|
|
HTM_BR ();
|
|
|
|
|
HTM_TxtColonNBSP (Txt_Date);
|
2022-03-26 21:08:25 +01:00
|
|
|
|
HTM_SPAN_Begin ("class=\"DAT_STRONG_%s\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TxtF ("%s %s UTC",CurrentTimeUTC->StrDate,
|
|
|
|
|
CurrentTimeUTC->StrTime);
|
|
|
|
|
HTM_SPAN_End ();
|
|
|
|
|
}
|
2016-10-04 23:57:32 +02:00
|
|
|
|
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2016-10-04 00:30:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 09:40:10 +02:00
|
|
|
|
/*****************************************************************************/
|
2016-10-04 17:21:21 +02:00
|
|
|
|
/********************* Get current date and time in UTC **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-08 23:47:20 +02:00
|
|
|
|
static void Rep_GetCurrentDateTimeUTC (struct Rep_Report *Report)
|
2016-10-04 17:21:21 +02:00
|
|
|
|
{
|
|
|
|
|
time_t CurrentTime;
|
|
|
|
|
|
|
|
|
|
/***** Initialize to empty strings *****/
|
2016-10-08 23:47:20 +02:00
|
|
|
|
Report->CurrentTimeUTC.StrDate[0] = '\0';
|
|
|
|
|
Report->CurrentTimeUTC.StrTime[0] = '\0';
|
2016-10-04 17:21:21 +02:00
|
|
|
|
|
|
|
|
|
/***** Get current time UTC *****/
|
|
|
|
|
time (&CurrentTime);
|
2016-10-08 23:47:20 +02:00
|
|
|
|
if ((gmtime_r (&CurrentTime,&Report->tm_CurrentTime)) != NULL)
|
2016-10-04 17:21:21 +02:00
|
|
|
|
{
|
|
|
|
|
/* Date and time as strings */
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (Report->CurrentTimeUTC.StrDate,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Report->CurrentTimeUTC.StrDate),"%04d-%02d-%02d",
|
2018-10-18 02:02:32 +02:00
|
|
|
|
1900 + Report->tm_CurrentTime.tm_year, // year
|
|
|
|
|
1 + Report->tm_CurrentTime.tm_mon, // month
|
|
|
|
|
Report->tm_CurrentTime.tm_mday); // day of the month
|
|
|
|
|
snprintf (Report->CurrentTimeUTC.StrTime,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Report->CurrentTimeUTC.StrTime),"%02d:%02d:%02d",
|
2018-10-18 02:02:32 +02:00
|
|
|
|
Report->tm_CurrentTime.tm_hour, // hours
|
|
|
|
|
Report->tm_CurrentTime.tm_min, // minutes
|
|
|
|
|
Report->tm_CurrentTime.tm_sec); // seconds
|
2016-10-04 17:21:21 +02:00
|
|
|
|
|
|
|
|
|
/* Date and time as unsigned */
|
2016-10-08 23:47:20 +02:00
|
|
|
|
Report->CurrentTimeUTC.Date = (1900 + Report->tm_CurrentTime.tm_year) * 10000 +
|
|
|
|
|
(1 + Report->tm_CurrentTime.tm_mon) * 100 +
|
|
|
|
|
Report->tm_CurrentTime.tm_mday;
|
|
|
|
|
Report->CurrentTimeUTC.Time = Report->tm_CurrentTime.tm_hour * 10000 +
|
|
|
|
|
Report->tm_CurrentTime.tm_min * 100 +
|
|
|
|
|
Report->tm_CurrentTime.tm_sec;
|
2016-10-04 17:21:21 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-06 20:35:10 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Create a new file for user's usage report *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-08 23:50:01 +02:00
|
|
|
|
static void Rep_CreateNewReportFile (struct Rep_Report *Report)
|
2016-10-06 20:35:10 +02:00
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PathUniqueDirL[PATH_MAX + 1];
|
2019-12-19 01:42:24 +01:00
|
|
|
|
char PathUniqueDirR[PATH_MAX + 1 + Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1];
|
|
|
|
|
char PathFileReport[PATH_MAX + 1 + Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1 + NAME_MAX + 1];
|
2018-10-18 02:02:32 +02:00
|
|
|
|
char Permalink[128 +
|
|
|
|
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 +
|
|
|
|
|
NAME_MAX];
|
2016-10-06 20:35:10 +02:00
|
|
|
|
|
|
|
|
|
/***** Path for reports *****/
|
2019-03-20 01:36:36 +01:00
|
|
|
|
Fil_CreateDirIfNotExists (Cfg_PATH_REP_PUBLIC);
|
2016-10-06 20:35:10 +02:00
|
|
|
|
|
|
|
|
|
/***** Unique directory for the file with the report *****/
|
|
|
|
|
/* 1. Create a directory using the leftmost 2 chars of a unique name */
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (PathUniqueDirL,sizeof (PathUniqueDirL),"%s/%c%c",
|
2019-03-20 01:36:36 +01:00
|
|
|
|
Cfg_PATH_REP_PUBLIC,
|
2018-10-18 02:02:32 +02:00
|
|
|
|
Gbl.UniqueNameEncrypted[0],
|
|
|
|
|
Gbl.UniqueNameEncrypted[1]);
|
2016-10-06 20:35:10 +02:00
|
|
|
|
Fil_CreateDirIfNotExists (PathUniqueDirL);
|
|
|
|
|
|
|
|
|
|
/* 2. Create a directory using the rightmost 41 chars of a unique name */
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (PathUniqueDirR,sizeof (PathUniqueDirR),"%s/%s",
|
2018-10-18 02:02:32 +02:00
|
|
|
|
PathUniqueDirL,
|
|
|
|
|
&Gbl.UniqueNameEncrypted[2]);
|
2016-10-06 20:35:10 +02:00
|
|
|
|
if (mkdir (PathUniqueDirR,(mode_t) 0xFFF))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Can not create directory for report.");
|
2016-10-06 20:35:10 +02:00
|
|
|
|
|
|
|
|
|
/***** Path of the public file with the report */
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (Report->FilenameReport,sizeof (Report->FilenameReport),
|
|
|
|
|
"%s_%06u_%06u.html",
|
|
|
|
|
Rep_FILENAME_ROOT,Report->CurrentTimeUTC.Date,Report->CurrentTimeUTC.Time);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (PathFileReport,sizeof (PathFileReport),"%s/%s",
|
2018-10-18 02:02:32 +02:00
|
|
|
|
PathUniqueDirR,Report->FilenameReport);
|
2016-10-06 20:35:10 +02:00
|
|
|
|
if ((Gbl.F.Rep = fopen (PathFileReport,"wb")) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Can not create report file.");
|
2016-10-06 20:35:10 +02:00
|
|
|
|
|
|
|
|
|
/***** Permalink *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (Permalink,sizeof (Permalink),"%s/%c%c/%s/%s",
|
2019-03-20 01:36:36 +01:00
|
|
|
|
Cfg_URL_REP_PUBLIC,
|
2018-10-18 02:02:32 +02:00
|
|
|
|
Gbl.UniqueNameEncrypted[0],
|
|
|
|
|
Gbl.UniqueNameEncrypted[1],
|
|
|
|
|
&Gbl.UniqueNameEncrypted[2],
|
|
|
|
|
Report->FilenameReport);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Report->Permalink,Permalink,sizeof (Report->Permalink) - 1);
|
2016-10-06 20:35:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-04 17:21:21 +02:00
|
|
|
|
/*****************************************************************************/
|
2016-10-03 09:40:10 +02:00
|
|
|
|
/******************** Write header of user's usage report ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-09 00:05:56 +02:00
|
|
|
|
static void Rep_WriteHeader (const struct Rep_Report *Report)
|
2016-10-03 09:40:10 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Report_of_use_of_PLATFORM;
|
2016-10-04 02:32:25 +02:00
|
|
|
|
extern const char *Txt_User[Usr_NUM_SEXS];
|
|
|
|
|
extern const char *Txt_Date;
|
|
|
|
|
extern const char *Txt_Permalink;
|
2016-10-03 09:40:10 +02:00
|
|
|
|
|
2019-12-30 18:08:31 +01:00
|
|
|
|
/***** Begin header *****/
|
2021-10-13 14:38:51 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<header>"
|
|
|
|
|
"<h1>");
|
2019-12-30 18:08:31 +01:00
|
|
|
|
fprintf (Gbl.F.Rep,Txt_Report_of_use_of_PLATFORM,Cfg_PLATFORM_SHORT_NAME);
|
2021-10-13 14:38:51 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</h1>"
|
|
|
|
|
"<ul>");
|
2016-10-03 09:40:10 +02:00
|
|
|
|
|
2016-10-04 02:32:25 +02:00
|
|
|
|
/***** User *****/
|
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: <strong>%s</strong></li>",
|
|
|
|
|
Txt_User[Gbl.Usrs.Me.UsrDat.Sex],
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.FullName);
|
|
|
|
|
|
|
|
|
|
/***** Date-time *****/
|
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: %s %s UTC</li>",
|
|
|
|
|
Txt_Date,
|
2016-10-09 00:05:56 +02:00
|
|
|
|
Report->CurrentTimeUTC.StrDate,
|
|
|
|
|
Report->CurrentTimeUTC.StrTime);
|
2016-10-03 22:41:45 +02:00
|
|
|
|
|
|
|
|
|
/***** Permalink *****/
|
2016-10-04 23:57:32 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: "
|
|
|
|
|
"<a href=\"%s\" target=\"_blank\""
|
|
|
|
|
" style=\"text-decoration:none;\">"
|
|
|
|
|
"%s"
|
|
|
|
|
"</a>"
|
|
|
|
|
"</li>",
|
2016-10-04 02:32:25 +02:00
|
|
|
|
Txt_Permalink,
|
2016-10-09 00:05:56 +02:00
|
|
|
|
Report->Permalink,Report->Permalink);
|
2016-10-03 09:40:10 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End header *****/
|
2016-10-04 23:57:32 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</ul>"
|
|
|
|
|
"</header>\n");
|
2016-10-03 09:40:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Write section for platform in user's usage report *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Rep_WriteSectionPlatform (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Teaching_platform;
|
|
|
|
|
extern const char *Txt_Name;
|
|
|
|
|
extern const char *Txt_TAGLINE;
|
|
|
|
|
extern const char *Txt_URL;
|
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<section>"
|
2019-10-26 12:25:27 +02:00
|
|
|
|
"<h3>%s</h3>",
|
2016-10-03 09:40:10 +02:00
|
|
|
|
Txt_Teaching_platform);
|
2020-02-24 12:43:18 +01:00
|
|
|
|
fprintf (Gbl.F.Rep,"<ul>");
|
2016-10-03 09:40:10 +02:00
|
|
|
|
|
|
|
|
|
/***** Platform name *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: %s, %s</li>",
|
2016-10-03 09:40:10 +02:00
|
|
|
|
Txt_Name,
|
|
|
|
|
Cfg_PLATFORM_FULL_NAME,Txt_TAGLINE);
|
|
|
|
|
|
|
|
|
|
/***** Server URL *****/
|
2016-10-04 23:57:32 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: "
|
|
|
|
|
"<a href=\"%s\" target=\"_blank\""
|
|
|
|
|
" style=\"text-decoration:none;\">"
|
|
|
|
|
"%s"
|
|
|
|
|
"</a>"
|
|
|
|
|
"</li>",
|
2016-10-03 09:40:10 +02:00
|
|
|
|
Txt_URL,Cfg_URL_SWAD_SERVER,Cfg_URL_SWAD_SERVER);
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</ul>"
|
2016-10-03 10:18:48 +02:00
|
|
|
|
"</section>\n");
|
2016-10-03 09:40:10 +02:00
|
|
|
|
}
|
2016-10-02 19:42:47 +02:00
|
|
|
|
|
2016-10-03 09:44:32 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Write section for user's info in user's usage report ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Rep_WriteSectionUsrInfo (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Personal_information;
|
|
|
|
|
extern const char *Txt_Name;
|
|
|
|
|
extern const char *Txt_Email;
|
|
|
|
|
extern const char *Txt_Country;
|
|
|
|
|
extern const char *Txt_Institution;
|
2021-02-11 22:57:09 +01:00
|
|
|
|
char CtyName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1];
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Ins_Instit Ins;
|
2016-10-03 09:44:32 +02:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<section>"
|
2019-10-26 12:25:27 +02:00
|
|
|
|
"<h3>%s</h3>",
|
2016-10-03 09:44:32 +02:00
|
|
|
|
Txt_Personal_information);
|
2020-02-24 12:43:18 +01:00
|
|
|
|
fprintf (Gbl.F.Rep,"<ul>");
|
2016-10-03 09:44:32 +02:00
|
|
|
|
|
|
|
|
|
/***** User's name *****/
|
2016-10-04 02:32:25 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: %s</li>",
|
2016-10-03 09:44:32 +02:00
|
|
|
|
Txt_Name,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.FullName);
|
|
|
|
|
|
2016-11-16 23:19:52 +01:00
|
|
|
|
/***** User's email *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: %s</li>",
|
2016-10-03 09:44:32 +02:00
|
|
|
|
Txt_Email,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.Email);
|
|
|
|
|
|
|
|
|
|
/***** User's country *****/
|
2020-01-07 22:07:06 +01:00
|
|
|
|
Cty_GetCountryName (Gbl.Usrs.Me.UsrDat.CtyCod,Gbl.Prefs.Language,CtyName);
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: %s</li>",
|
2016-10-03 09:44:32 +02:00
|
|
|
|
Txt_Country,
|
|
|
|
|
CtyName);
|
|
|
|
|
|
|
|
|
|
/***** User's institution *****/
|
|
|
|
|
Ins.InsCod = Gbl.Usrs.Me.UsrDat.InsCod;
|
2021-10-01 18:54:12 +02:00
|
|
|
|
Ins_GetDataOfInstitByCod (&Ins);
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: %s</li>",
|
2016-10-03 09:44:32 +02:00
|
|
|
|
Txt_Institution,
|
|
|
|
|
Ins.FullName);
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</ul>"
|
2016-10-03 10:18:48 +02:00
|
|
|
|
"</section>\n");
|
2016-10-03 09:44:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 09:59:57 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Write section for user's figures in user's usage report ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-09 00:20:03 +02:00
|
|
|
|
static void Rep_WriteSectionUsrFigures (const struct Rep_Report *Report)
|
2016-10-03 09:59:57 +02:00
|
|
|
|
{
|
|
|
|
|
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;
|
2019-03-06 10:13:39 +01:00
|
|
|
|
extern const char *Txt_FORUM_post;
|
|
|
|
|
extern const char *Txt_FORUM_posts;
|
2016-10-03 09:59:57 +02:00
|
|
|
|
extern const char *Txt_Messages_sent;
|
|
|
|
|
extern const char *Txt_message;
|
|
|
|
|
extern const char *Txt_messages;
|
|
|
|
|
unsigned NumFiles;
|
|
|
|
|
unsigned NumPublicFiles;
|
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<section>"
|
2019-10-26 12:25:27 +02:00
|
|
|
|
"<h3>%s</h3>",
|
2016-10-03 09:59:57 +02:00
|
|
|
|
Txt_Figures);
|
2020-02-24 12:43:18 +01:00
|
|
|
|
fprintf (Gbl.F.Rep,"<ul>");
|
2016-10-03 09:59:57 +02:00
|
|
|
|
|
|
|
|
|
/***** Time since first click until now *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s ",Txt_TIME_Since);
|
2016-10-09 00:20:03 +02:00
|
|
|
|
if (Report->UsrFigures.FirstClickTimeUTC)
|
2016-10-03 09:59:57 +02:00
|
|
|
|
{
|
2016-10-09 00:20:03 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"%04d-%02d-%02d %02d:%02d:%02d UTC",
|
|
|
|
|
1900 + Report->tm_FirstClickTime.tm_year, // year
|
|
|
|
|
1 + Report->tm_FirstClickTime.tm_mon, // month
|
|
|
|
|
Report->tm_FirstClickTime.tm_mday, // day of the month
|
|
|
|
|
Report->tm_FirstClickTime.tm_hour, // hours
|
|
|
|
|
Report->tm_FirstClickTime.tm_min, // minutes
|
|
|
|
|
Report->tm_FirstClickTime.tm_sec); // seconds
|
|
|
|
|
if (Report->CurrentTimeUTC.StrDate[0])
|
|
|
|
|
fprintf (Gbl.F.Rep," %s %s %s UTC",
|
|
|
|
|
Txt_TIME_until,
|
|
|
|
|
Report->CurrentTimeUTC.StrDate,
|
|
|
|
|
Report->CurrentTimeUTC.StrTime);
|
|
|
|
|
if (Report->UsrFigures.NumDays > 0)
|
|
|
|
|
fprintf (Gbl.F.Rep," (%d %s)",
|
|
|
|
|
Report->UsrFigures.NumDays,
|
|
|
|
|
(Report->UsrFigures.NumDays == 1) ? Txt_day :
|
|
|
|
|
Txt_days);
|
2016-10-03 09:59:57 +02:00
|
|
|
|
}
|
|
|
|
|
else // Time of first click is unknown
|
|
|
|
|
{
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"?");
|
2016-10-09 00:20:03 +02:00
|
|
|
|
if (Report->CurrentTimeUTC.StrDate[0])
|
2016-10-04 00:22:59 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," - %s %s UTC",
|
2016-10-09 00:20:03 +02:00
|
|
|
|
Report->CurrentTimeUTC.StrDate,
|
|
|
|
|
Report->CurrentTimeUTC.StrTime);
|
2016-10-03 09:59:57 +02:00
|
|
|
|
}
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</li>");
|
2016-10-03 09:59:57 +02:00
|
|
|
|
|
|
|
|
|
/***** Number of clicks *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: ",Txt_Clicks);
|
2016-10-09 00:20:03 +02:00
|
|
|
|
if (Report->UsrFigures.NumClicks >= 0)
|
2016-10-03 09:59:57 +02:00
|
|
|
|
{
|
2021-04-17 01:08:48 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"%d",Report->UsrFigures.NumClicks);
|
2016-10-09 00:20:03 +02:00
|
|
|
|
if (Report->UsrFigures.NumDays > 0)
|
2016-10-03 09:59:57 +02:00
|
|
|
|
{
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," (");
|
2019-12-14 13:35:35 +01:00
|
|
|
|
Rep_WriteDouble ((double) Report->UsrFigures.NumClicks /
|
|
|
|
|
(double) Report->UsrFigures.NumDays);
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," / %s)",Txt_day);
|
2016-10-03 09:59:57 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Number of clicks is unknown
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"?");
|
|
|
|
|
fprintf (Gbl.F.Rep,"</li>");
|
2016-10-03 09:59:57 +02:00
|
|
|
|
|
|
|
|
|
/***** Number of files currently published *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
if ((NumFiles = Brw_DB_GetNumFilesUsr (Gbl.Usrs.Me.UsrDat.UsrCod)))
|
|
|
|
|
NumPublicFiles = Brw_DB_GetNumPublicFilesUsr (Gbl.Usrs.Me.UsrDat.UsrCod);
|
2016-10-03 09:59:57 +02:00
|
|
|
|
else
|
|
|
|
|
NumPublicFiles = 0;
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>"
|
2016-10-03 09:59:57 +02:00
|
|
|
|
"%s: %u %s (%u %s)"
|
|
|
|
|
"</li>",
|
|
|
|
|
Txt_Files_uploaded,
|
|
|
|
|
NumFiles,
|
|
|
|
|
(NumFiles == 1) ? Txt_file :
|
|
|
|
|
Txt_files,
|
|
|
|
|
NumPublicFiles,Txt_public_FILES);
|
|
|
|
|
|
|
|
|
|
/***** Number of file views *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: ",Txt_Downloads);
|
2016-10-09 00:20:03 +02:00
|
|
|
|
if (Report->UsrFigures.NumFileViews >= 0)
|
2016-10-03 09:59:57 +02:00
|
|
|
|
{
|
2021-04-17 01:08:48 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"%d %s",
|
2016-10-09 00:20:03 +02:00
|
|
|
|
Report->UsrFigures.NumFileViews,
|
|
|
|
|
(Report->UsrFigures.NumFileViews == 1) ? Txt_download :
|
2016-10-09 01:05:45 +02:00
|
|
|
|
Txt_downloads);
|
2016-10-09 00:20:03 +02:00
|
|
|
|
if (Report->UsrFigures.NumDays > 0)
|
2016-10-03 09:59:57 +02:00
|
|
|
|
{
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," (");
|
2019-12-14 13:35:35 +01:00
|
|
|
|
Rep_WriteDouble ((double) Report->UsrFigures.NumFileViews /
|
|
|
|
|
(double) Report->UsrFigures.NumDays);
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," / %s)",Txt_day);
|
2016-10-03 09:59:57 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Number of file views is unknown
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"?");
|
|
|
|
|
fprintf (Gbl.F.Rep,"</li>");
|
2016-10-03 09:59:57 +02:00
|
|
|
|
|
|
|
|
|
/***** Number of posts in forums *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: ",Txt_Forum_posts);
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (Report->UsrFigures.NumForumPosts >= 0)
|
2016-10-03 09:59:57 +02:00
|
|
|
|
{
|
2021-04-17 01:08:48 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"%d %s",
|
2021-10-07 01:21:23 +02:00
|
|
|
|
Report->UsrFigures.NumForumPosts,
|
|
|
|
|
(Report->UsrFigures.NumForumPosts == 1) ? Txt_FORUM_post :
|
2019-03-06 10:13:39 +01:00
|
|
|
|
Txt_FORUM_posts);
|
2016-10-09 00:20:03 +02:00
|
|
|
|
if (Report->UsrFigures.NumDays > 0)
|
2016-10-03 09:59:57 +02:00
|
|
|
|
{
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," (");
|
2021-10-07 01:21:23 +02:00
|
|
|
|
Rep_WriteDouble ((double) Report->UsrFigures.NumForumPosts /
|
2019-12-14 13:35:35 +01:00
|
|
|
|
(double) Report->UsrFigures.NumDays);
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," / %s)",Txt_day);
|
2016-10-03 09:59:57 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Number of forum posts is unknown
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"?");
|
|
|
|
|
fprintf (Gbl.F.Rep,"</li>");
|
2016-10-03 09:59:57 +02:00
|
|
|
|
|
|
|
|
|
/***** Number of messages sent *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s: ",Txt_Messages_sent);
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (Report->UsrFigures.NumMessagesSent >= 0)
|
2016-10-03 09:59:57 +02:00
|
|
|
|
{
|
2021-04-17 01:08:48 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"%d %s",
|
2021-10-07 01:21:23 +02:00
|
|
|
|
Report->UsrFigures.NumMessagesSent,
|
|
|
|
|
(Report->UsrFigures.NumMessagesSent == 1) ? Txt_message :
|
2016-10-09 00:20:03 +02:00
|
|
|
|
Txt_messages);
|
|
|
|
|
if (Report->UsrFigures.NumDays > 0)
|
2016-10-03 09:59:57 +02:00
|
|
|
|
{
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," (");
|
2021-10-07 01:21:23 +02:00
|
|
|
|
Rep_WriteDouble ((double) Report->UsrFigures.NumMessagesSent /
|
2019-12-14 13:35:35 +01:00
|
|
|
|
(double) Report->UsrFigures.NumDays);
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," / %s)",Txt_day);
|
2016-10-03 09:59:57 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Number of messages sent is unknown
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"?");
|
|
|
|
|
fprintf (Gbl.F.Rep,"</li>");
|
2016-10-03 09:59:57 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</ul>"
|
2016-10-03 10:18:48 +02:00
|
|
|
|
"</section>\n");
|
2016-10-03 09:59:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 10:07:49 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Write section for user's global hits in user's usage report ********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-09 00:49:23 +02:00
|
|
|
|
static void Rep_WriteSectionGlobalHits (struct Rep_Report *Report)
|
2016-10-03 10:07:49 +02:00
|
|
|
|
{
|
2016-10-08 20:37:01 +02:00
|
|
|
|
extern const char *Txt_Hits_per_year;
|
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<section>"
|
2016-10-04 23:57:32 +02:00
|
|
|
|
"<h3>%s</h3>",
|
2016-10-08 20:37:01 +02:00
|
|
|
|
Txt_Hits_per_year);
|
2016-10-03 10:07:49 +02:00
|
|
|
|
|
|
|
|
|
/***** Global (in any course) hits per year *****/
|
2016-10-09 00:49:23 +02:00
|
|
|
|
Report->MaxHitsPerYear = 0; // MaxHitsPerYear not passed as an argument but computed inside the function
|
2016-10-03 10:07:49 +02:00
|
|
|
|
Rep_ShowMyHitsPerYear (true,-1L, // Any course
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Rol_UNK, // Any role
|
2016-10-09 00:49:23 +02:00
|
|
|
|
Report);
|
2016-10-03 10:07:49 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</section>\n");
|
2016-10-03 10:18:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-08 20:25:26 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Write section for user's global hits in user's usage report ********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-09 01:03:30 +02:00
|
|
|
|
static void Rep_WriteSectionHitsPerAction (struct Rep_Report *Report)
|
2016-10-08 20:25:26 +02:00
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD];
|
2016-10-08 20:41:25 +02:00
|
|
|
|
extern const char *Txt_Hits_per_action;
|
2016-12-28 17:22:25 +01:00
|
|
|
|
extern const char *Txt_TABS_TXT[Tab_NUM_TABS];
|
2016-10-08 20:51:39 +02:00
|
|
|
|
extern const char *Txt_Other_actions;
|
2016-10-08 20:25:26 +02:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2021-04-17 01:08:48 +02:00
|
|
|
|
unsigned NumHits;
|
|
|
|
|
unsigned NumHit;
|
2016-10-08 20:25:26 +02:00
|
|
|
|
long ActCod;
|
2016-10-09 01:41:36 +02:00
|
|
|
|
Act_Action_t Action;
|
2016-10-12 14:02:56 +02:00
|
|
|
|
Tab_Tab_t Tab;
|
2016-10-08 21:19:47 +02:00
|
|
|
|
unsigned long NumClicks;
|
2016-10-08 20:25:26 +02:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin section *****/
|
2016-10-08 20:25:26 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<section>"
|
|
|
|
|
"<h3>%s</h3>",
|
2016-10-08 20:41:25 +02:00
|
|
|
|
Txt_Hits_per_action);
|
2016-10-08 20:25:26 +02:00
|
|
|
|
|
|
|
|
|
/***** Make the query *****/
|
2021-10-13 14:38:51 +02:00
|
|
|
|
NumHits = Log_DB_GetMyClicksGroupedByAction (&mysql_res,
|
|
|
|
|
Report->UsrFigures.FirstClickTimeUTC,
|
|
|
|
|
Rep_MAX_ACTIONS);
|
2016-10-08 20:25:26 +02:00
|
|
|
|
|
|
|
|
|
/***** Compute maximum number of hits per action *****/
|
2021-04-17 01:08:48 +02:00
|
|
|
|
Rep_ComputeMaxAndTotalHits (&Report->Hits,NumHits,mysql_res,1);
|
2016-10-08 20:25:26 +02:00
|
|
|
|
mysql_data_seek (mysql_res,0);
|
|
|
|
|
|
|
|
|
|
/***** Write rows *****/
|
2021-04-17 01:08:48 +02:00
|
|
|
|
for (NumHit = 1, NumClicks = 0;
|
|
|
|
|
NumHit <= NumHits;
|
|
|
|
|
NumHit++)
|
2016-10-08 20:25:26 +02:00
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get the action (row[0]) */
|
|
|
|
|
ActCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
2016-10-08 21:19:47 +02:00
|
|
|
|
/* Get number of hits (row[1]) */
|
2016-10-09 01:03:30 +02:00
|
|
|
|
if (sscanf (row[1],"%lu",&Report->Hits.Num) != 1)
|
|
|
|
|
Report->Hits.Num = 0;
|
|
|
|
|
NumClicks += Report->Hits.Num;
|
2016-10-08 20:25:26 +02:00
|
|
|
|
|
|
|
|
|
/* Draw bar proportional to number of hits */
|
2016-10-09 01:03:30 +02:00
|
|
|
|
Rep_DrawBarNumHits (Report->Hits.Num,Report->Hits.Max,Rep_MAX_BAR_WIDTH);
|
2016-10-08 20:25:26 +02:00
|
|
|
|
|
|
|
|
|
/* Write action text */
|
|
|
|
|
fprintf (Gbl.F.Rep," ");
|
|
|
|
|
if (ActCod >= 0)
|
|
|
|
|
{
|
2020-01-02 13:35:37 +01:00
|
|
|
|
if ((Action = Act_FromActCodToAction[ActCod]) >= 0)
|
2016-10-09 01:41:36 +02:00
|
|
|
|
{
|
2018-04-24 13:21:53 +02:00
|
|
|
|
Tab = Act_GetTab (Act_GetSuperAction (Action));
|
2016-12-28 17:22:25 +01:00
|
|
|
|
if (Txt_TABS_TXT[Tab])
|
|
|
|
|
fprintf (Gbl.F.Rep,"%s > ",Txt_TABS_TXT[Tab]);
|
2016-10-09 01:41:36 +02:00
|
|
|
|
}
|
2020-01-02 13:35:37 +01:00
|
|
|
|
|
2020-01-02 13:58:13 +01:00
|
|
|
|
fprintf (Gbl.F.Rep,"%s",Act_GetActionText (Action));
|
2016-10-08 20:25:26 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fprintf (Gbl.F.Rep,"?");
|
|
|
|
|
fprintf (Gbl.F.Rep,"<br />");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Draw bar for the rest of the clicks *****/
|
2016-10-09 01:03:30 +02:00
|
|
|
|
if ((unsigned long) Report->UsrFigures.NumClicks > NumClicks)
|
2019-11-09 21:03:02 +01:00
|
|
|
|
{
|
|
|
|
|
fprintf (Gbl.F.Rep,"%ld %s",
|
2016-10-09 01:03:30 +02:00
|
|
|
|
Report->UsrFigures.NumClicks - NumClicks,
|
2016-10-08 20:51:39 +02:00
|
|
|
|
Txt_Other_actions);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<br />");
|
2019-11-09 21:03:02 +01:00
|
|
|
|
}
|
2016-10-08 20:25:26 +02:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End section *****/
|
2016-10-08 20:25:26 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</section>\n");
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 10:18:48 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Write section for user's current courses in user's usage report ******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-09 01:03:30 +02:00
|
|
|
|
static void Rep_WriteSectionCurrentCourses (struct Rep_Report *Report)
|
2016-10-03 10:18:48 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Courses;
|
|
|
|
|
Rol_Role_t Role;
|
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<section>"
|
2016-10-04 23:57:32 +02:00
|
|
|
|
"<h3>%s",
|
2016-10-03 10:18:48 +02:00
|
|
|
|
Txt_Courses);
|
2016-10-09 00:37:58 +02:00
|
|
|
|
if (Report->CurrentTimeUTC.StrDate[0])
|
|
|
|
|
fprintf (Gbl.F.Rep," (%s)",Report->CurrentTimeUTC.StrDate);
|
2019-10-26 12:25:27 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</h3>");
|
2020-02-24 12:43:18 +01:00
|
|
|
|
fprintf (Gbl.F.Rep,"<ul>");
|
2016-10-03 10:18:48 +02:00
|
|
|
|
|
|
|
|
|
/***** Number of courses in which the user is student/teacher *****/
|
2017-05-18 19:13:41 +02:00
|
|
|
|
for (Role = Rol_STD;
|
|
|
|
|
Role <= Rol_TCH;
|
2016-10-03 10:18:48 +02:00
|
|
|
|
Role++)
|
|
|
|
|
/* List my courses with this role */
|
2016-10-09 00:41:09 +02:00
|
|
|
|
Rep_GetAndWriteMyCurrentCrss (Role,Report);
|
2016-10-03 10:18:48 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</ul>"
|
2016-10-03 10:18:48 +02:00
|
|
|
|
"</section>\n");
|
2016-10-03 10:07:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 11:38:13 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***** Write section for user's historic courses in user's usage report ******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-09 01:03:30 +02:00
|
|
|
|
static void Rep_WriteSectionHistoricCourses (struct Rep_Report *Report)
|
2016-10-03 11:38:13 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Courses;
|
|
|
|
|
extern const char *Txt_historical_log;
|
2016-10-03 13:29:05 +02:00
|
|
|
|
extern const char *Txt_Only_courses_with_more_than_X_clicks_are_shown;
|
2016-10-03 11:38:13 +02:00
|
|
|
|
Rol_Role_t Role;
|
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<section>"
|
2016-10-04 23:57:32 +02:00
|
|
|
|
"<h3>%s (%s)</h3>",
|
2016-10-03 11:38:13 +02:00
|
|
|
|
Txt_Courses,Txt_historical_log);
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,Txt_Only_courses_with_more_than_X_clicks_are_shown,
|
2016-10-03 13:29:05 +02:00
|
|
|
|
Rep_MIN_CLICKS_CRS);
|
2020-02-24 12:43:18 +01:00
|
|
|
|
fprintf (Gbl.F.Rep,"<ul>");
|
2016-10-03 11:38:13 +02:00
|
|
|
|
|
2016-10-07 02:23:24 +02:00
|
|
|
|
/********* Historic clicks of a user without course selected ***********/
|
2016-10-09 00:49:23 +02:00
|
|
|
|
Rep_GetAndWriteMyHistoricClicsWithoutCrs (Report);
|
2016-10-07 02:23:24 +02:00
|
|
|
|
|
|
|
|
|
/***** Historic courses in which the user clicked as student/teacher *****/
|
2017-05-18 19:13:41 +02:00
|
|
|
|
for (Role = Rol_STD;
|
|
|
|
|
Role <= Rol_TCH;
|
2016-10-03 11:38:13 +02:00
|
|
|
|
Role++)
|
|
|
|
|
/* List my courses with this role */
|
2016-10-09 00:49:23 +02:00
|
|
|
|
Rep_GetAndWriteMyHistoricCrss (Role,Report);
|
2016-10-03 11:38:13 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End section *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</ul>"
|
2016-10-03 11:38:13 +02:00
|
|
|
|
"</section>\n");
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Get the maximum number of hits per course-year-role ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-09 01:03:30 +02:00
|
|
|
|
static void Rep_GetMaxHitsPerYear (struct Rep_Report *Report)
|
2016-10-02 19:42:47 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
2016-10-09 01:03:30 +02:00
|
|
|
|
Report->MaxHitsPerYear = 0;
|
2021-10-13 14:38:51 +02:00
|
|
|
|
|
|
|
|
|
/***** Get the maximum number of hits per year *****/
|
|
|
|
|
if (Log_DB_GetMyMaxHitsPerYear (&mysql_res,Report->UsrFigures.FirstClickTimeUTC))
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (row[0]) // There are questions
|
|
|
|
|
if (sscanf (row[0],"%lu",&Report->MaxHitsPerYear) != 1)
|
|
|
|
|
Err_ShowErrorAndExit ("Error when getting maximum hits.");
|
|
|
|
|
}
|
2016-10-02 19:42:47 +02:00
|
|
|
|
|
2016-10-08 20:25:26 +02:00
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2016-10-02 19:42:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-11 21:25:14 +02:00
|
|
|
|
/*****************************************************************************/
|
2016-10-07 02:23:24 +02:00
|
|
|
|
/************************* Write my current courses **************************/
|
2016-09-11 21:25:14 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-07 02:23:24 +02:00
|
|
|
|
static void Rep_GetAndWriteMyCurrentCrss (Rol_Role_t Role,
|
2016-10-09 01:03:30 +02:00
|
|
|
|
struct Rep_Report *Report)
|
2016-09-11 21:25:14 +02:00
|
|
|
|
{
|
2016-10-02 19:42:47 +02:00
|
|
|
|
extern const char *Txt_USER_in_COURSE;
|
|
|
|
|
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
|
|
|
|
extern const char *Txt_course;
|
|
|
|
|
extern const char *Txt_courses;
|
|
|
|
|
extern const char *Txt_teachers_ABBREVIATION;
|
|
|
|
|
extern const char *Txt_students_ABBREVIATION;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumCrss;
|
|
|
|
|
unsigned NumCrs;
|
|
|
|
|
long CrsCod;
|
|
|
|
|
|
2021-11-03 21:31:16 +01:00
|
|
|
|
NumCrss = Enr_DB_GetNumCrssOfUsrWithARole (Gbl.Usrs.Me.UsrDat.UsrCod,Role);
|
2019-12-30 21:47:07 +01:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>");
|
|
|
|
|
fprintf (Gbl.F.Rep,Txt_USER_in_COURSE,
|
|
|
|
|
Txt_ROLES_SINGUL_Abc[Role][Gbl.Usrs.Me.UsrDat.Sex]);
|
|
|
|
|
fprintf (Gbl.F.Rep," %u %s",
|
2016-10-02 19:42:47 +02:00
|
|
|
|
NumCrss,
|
|
|
|
|
NumCrss == 1 ? Txt_course :
|
|
|
|
|
Txt_courses);
|
2019-12-30 14:55:25 +01:00
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
if (NumCrss)
|
|
|
|
|
{
|
2019-03-05 18:12:35 +01:00
|
|
|
|
fprintf (Gbl.F.Rep," (%u %s / %u %s):",
|
2021-11-03 21:31:16 +01:00
|
|
|
|
Enr_DB_GetNumUsrsInCrssOfAUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Role,
|
2019-03-05 18:12:35 +01:00
|
|
|
|
(1 << Rol_NET) |
|
|
|
|
|
(1 << Rol_TCH)),
|
2016-10-02 19:42:47 +02:00
|
|
|
|
Txt_teachers_ABBREVIATION,
|
2021-11-03 21:31:16 +01:00
|
|
|
|
Enr_DB_GetNumUsrsInCrssOfAUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Role,
|
2019-03-05 18:12:35 +01:00
|
|
|
|
(1 << Rol_STD)),
|
2016-10-02 19:42:47 +02:00
|
|
|
|
Txt_students_ABBREVIATION);
|
|
|
|
|
|
2021-10-13 14:38:51 +02:00
|
|
|
|
/***** Get and list my courses (one row per course) *****/
|
|
|
|
|
if ((NumCrss = Log_DB_GetMyCrssAndHitsPerCrs (&mysql_res,Role)))
|
2016-10-02 19:42:47 +02:00
|
|
|
|
{
|
|
|
|
|
/* Heading row */
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<ol>");
|
2016-10-02 19:42:47 +02:00
|
|
|
|
|
|
|
|
|
/* Write courses */
|
2021-10-13 14:38:51 +02:00
|
|
|
|
for (NumCrs = 1;
|
2016-10-02 19:42:47 +02:00
|
|
|
|
NumCrs <= NumCrss;
|
|
|
|
|
NumCrs++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next course */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get course code (row[0]) */
|
|
|
|
|
CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
|
|
|
|
/* Write data of this course */
|
2016-10-09 00:49:23 +02:00
|
|
|
|
Rep_WriteRowCrsData (CrsCod,Role,Report,
|
2016-10-07 02:23:24 +02:00
|
|
|
|
true); // Write number of users in course
|
2016-10-02 19:42:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* End table */
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</ol>");
|
2016-10-02 19:42:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</li>");
|
2016-10-02 19:42:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-10-07 02:23:24 +02:00
|
|
|
|
/************* Write my historic clicks without course selected **************/
|
2016-10-02 19:42:47 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-09 01:03:30 +02:00
|
|
|
|
static void Rep_GetAndWriteMyHistoricClicsWithoutCrs (struct Rep_Report *Report)
|
2016-10-07 02:23:24 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Hits_without_course_selected;
|
|
|
|
|
|
|
|
|
|
/***** Heading row *****/
|
|
|
|
|
fprintf (Gbl.F.Rep,"<li>%s:"
|
|
|
|
|
"<ol>",
|
|
|
|
|
Txt_Hits_without_course_selected);
|
|
|
|
|
|
|
|
|
|
/***** Historic clicks *****/
|
|
|
|
|
Rep_WriteRowCrsData (-1L,
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Rol_UNK, // Role does not matter
|
2016-10-09 00:49:23 +02:00
|
|
|
|
Report,
|
2016-10-07 02:23:24 +02:00
|
|
|
|
false); // Do not write number of users in course
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End list *****/
|
2016-10-07 02:23:24 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</ol>"
|
|
|
|
|
"</li>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Write historic courses of a user *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Rep_GetAndWriteMyHistoricCrss (Rol_Role_t Role,
|
2016-10-09 01:03:30 +02:00
|
|
|
|
struct Rep_Report *Report)
|
2016-10-02 19:42:47 +02:00
|
|
|
|
{
|
2016-10-02 22:54:30 +02:00
|
|
|
|
extern const char *Txt_Hits_as_a_USER;
|
2016-10-02 19:42:47 +02:00
|
|
|
|
extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
2016-09-11 21:25:14 +02:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumCrss;
|
|
|
|
|
unsigned NumCrs;
|
2016-10-02 19:42:47 +02:00
|
|
|
|
long CrsCod;
|
2016-09-11 21:25:14 +02:00
|
|
|
|
|
2021-10-13 14:38:51 +02:00
|
|
|
|
/***** Get and list historic courses of a user from log (one row per course) *****/
|
|
|
|
|
if ((NumCrss = Log_DB_GetMyHistoricCrss (&mysql_res,Role,Rep_MIN_CLICKS_CRS)))
|
2016-09-11 21:25:14 +02:00
|
|
|
|
{
|
|
|
|
|
/* Heading row */
|
2019-12-30 18:08:31 +01:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>");
|
|
|
|
|
fprintf (Gbl.F.Rep,Txt_Hits_as_a_USER,
|
|
|
|
|
Txt_ROLES_SINGUL_abc[Role][Gbl.Usrs.Me.UsrDat.Sex]);
|
|
|
|
|
fprintf (Gbl.F.Rep,":<ol>");
|
2016-09-11 21:25:14 +02:00
|
|
|
|
|
|
|
|
|
/* Write courses */
|
2021-10-13 14:38:51 +02:00
|
|
|
|
for (NumCrs = 1;
|
2016-09-11 21:25:14 +02:00
|
|
|
|
NumCrs <= NumCrss;
|
|
|
|
|
NumCrs++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next course */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
/* Get course code (row[0]) */
|
|
|
|
|
CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
2016-09-11 21:25:14 +02:00
|
|
|
|
/* Write data of this course */
|
2016-10-09 00:49:23 +02:00
|
|
|
|
Rep_WriteRowCrsData (CrsCod,Role,Report,
|
2016-10-07 02:23:24 +02:00
|
|
|
|
false); // Do not write number of users in course
|
|
|
|
|
}
|
2016-09-11 21:25:14 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/* End list */
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</ol>"
|
2016-10-02 19:42:47 +02:00
|
|
|
|
"</li>");
|
2016-09-11 21:25:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Write the data of a course (result of a query) ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
static void Rep_WriteRowCrsData (long CrsCod,Rol_Role_t Role,
|
2016-10-09 01:03:30 +02:00
|
|
|
|
struct Rep_Report *Report,
|
2016-10-07 02:23:24 +02:00
|
|
|
|
bool WriteNumUsrs)
|
2016-09-11 21:25:14 +02:00
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE];
|
2016-09-11 21:25:14 +02:00
|
|
|
|
extern const char *Txt_teachers_ABBREVIATION;
|
|
|
|
|
extern const char *Txt_students_ABBREVIATION;
|
2016-10-02 20:03:21 +02:00
|
|
|
|
extern const char *Txt_unknown_removed_course;
|
2016-10-02 19:55:12 +02:00
|
|
|
|
extern const char *Txt_no_course_selected;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Crs_Course Crs;
|
|
|
|
|
struct Deg_Degree Deg;
|
2016-10-02 19:42:47 +02:00
|
|
|
|
|
|
|
|
|
/***** Get course data *****/
|
|
|
|
|
Crs.CrsCod = CrsCod;
|
2020-01-05 14:09:28 +01:00
|
|
|
|
Crs_GetDataOfCourseByCod (&Crs);
|
2016-10-02 19:42:47 +02:00
|
|
|
|
|
|
|
|
|
/***** Get degree data *****/
|
|
|
|
|
Deg.DegCod = Crs.DegCod;
|
2020-01-05 12:52:03 +01:00
|
|
|
|
Deg_GetDataOfDegreeByCod (&Deg);
|
2016-09-11 21:25:14 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin row *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<li>");
|
2016-09-11 21:25:14 +02:00
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
if (CrsCod > 0) // CrsCod > 0 in log ==> course selected
|
|
|
|
|
{
|
|
|
|
|
if (Crs.CrsCod > 0) // Course exists
|
|
|
|
|
{
|
|
|
|
|
/***** Write course full name *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<strong>%s</strong> -",Crs.FullName);
|
2016-09-11 21:45:29 +02:00
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
/***** Write year *****/
|
|
|
|
|
if (Crs.Year)
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," %s",Txt_YEAR_OF_DEGREE[Crs.Year]);
|
2016-09-11 21:45:29 +02:00
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
/***** Write degree full name *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," %s",Deg.FullName);
|
2016-09-11 21:25:14 +02:00
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
/***** Write number of teachers / students in course *****/
|
2016-10-07 02:23:24 +02:00
|
|
|
|
if (WriteNumUsrs)
|
|
|
|
|
fprintf (Gbl.F.Rep," (%u %s / %u %s)",
|
2021-11-03 23:37:01 +01:00
|
|
|
|
Enr_GetCachedNumUsrsInCrss (HieLvl_CRS,Crs.CrsCod,
|
2020-05-09 18:18:04 +02:00
|
|
|
|
1 << Rol_NET |
|
|
|
|
|
1 << Rol_TCH),
|
2017-05-22 20:37:46 +02:00
|
|
|
|
Txt_teachers_ABBREVIATION,
|
2021-11-03 23:37:01 +01:00
|
|
|
|
Enr_GetCachedNumUsrsInCrss (HieLvl_CRS,Crs.CrsCod,
|
2020-05-09 18:18:04 +02:00
|
|
|
|
1 << Rol_STD),
|
2017-05-22 20:37:46 +02:00
|
|
|
|
Txt_students_ABBREVIATION);
|
2016-10-02 19:42:47 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"(%s)",Txt_unknown_removed_course);
|
2016-10-02 19:42:47 +02:00
|
|
|
|
}
|
|
|
|
|
else // CrsCod <= 0 in log ==> no course selected
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"(%s)",Txt_no_course_selected);
|
2016-09-29 01:34:17 +02:00
|
|
|
|
|
|
|
|
|
/***** Write hits per year for this course *****/
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<br />");
|
2016-10-09 00:49:23 +02:00
|
|
|
|
Rep_ShowMyHitsPerYear (false,CrsCod,Role,Report);
|
2016-09-29 01:34:17 +02:00
|
|
|
|
|
2016-10-03 14:12:01 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"</li>");
|
2016-09-11 21:25:14 +02:00
|
|
|
|
}
|
2016-09-12 00:50:24 +02:00
|
|
|
|
|
2016-10-02 17:56:05 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Write my hits grouped by years ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-02 19:42:47 +02:00
|
|
|
|
static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
2016-10-09 01:03:30 +02:00
|
|
|
|
struct Rep_Report *Report)
|
2016-10-02 17:56:05 +02:00
|
|
|
|
{
|
2016-09-12 17:43:23 +02:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2021-04-17 01:08:48 +02:00
|
|
|
|
unsigned NumHits;
|
|
|
|
|
unsigned NumHit;
|
2016-09-12 17:43:23 +02:00
|
|
|
|
unsigned ReadYear;
|
2020-04-12 22:52:01 +02:00
|
|
|
|
unsigned FirstYear;
|
2016-09-12 17:43:23 +02:00
|
|
|
|
unsigned LastYear;
|
|
|
|
|
unsigned Year;
|
|
|
|
|
|
|
|
|
|
/***** Make the query *****/
|
2021-10-13 15:37:14 +02:00
|
|
|
|
NumHits = Log_DB_GetMyHitsPerYear (&mysql_res,AnyCourse,CrsCod,Role,
|
|
|
|
|
Report->UsrFigures.FirstClickTimeUTC);
|
2016-09-12 17:43:23 +02:00
|
|
|
|
|
|
|
|
|
/***** Initialize first year *****/
|
2020-04-12 22:52:01 +02:00
|
|
|
|
FirstYear = 1900 + Report->tm_FirstClickTime.tm_year;
|
2016-09-12 17:43:23 +02:00
|
|
|
|
|
|
|
|
|
/***** Initialize LastYear *****/
|
|
|
|
|
LastYear = Gbl.Now.Date.Year;
|
|
|
|
|
|
2016-10-02 17:56:05 +02:00
|
|
|
|
/***** Set maximum number of hits per year *****/
|
2016-10-09 00:49:23 +02:00
|
|
|
|
if (Report->MaxHitsPerYear)
|
2016-10-02 17:56:05 +02:00
|
|
|
|
/* Set maximum number of hits per year from parameter */
|
2016-10-09 01:03:30 +02:00
|
|
|
|
Report->Hits.Max = Report->MaxHitsPerYear;
|
2016-09-29 01:48:52 +02:00
|
|
|
|
else
|
2016-10-02 17:56:05 +02:00
|
|
|
|
{
|
|
|
|
|
/* Compute maximum number of hits per year */
|
2021-04-17 01:08:48 +02:00
|
|
|
|
Rep_ComputeMaxAndTotalHits (&Report->Hits,NumHits,mysql_res,1);
|
2016-10-02 17:56:05 +02:00
|
|
|
|
mysql_data_seek (mysql_res,0);
|
|
|
|
|
}
|
2016-09-12 17:43:23 +02:00
|
|
|
|
|
|
|
|
|
/***** Write rows *****/
|
2021-10-13 15:37:14 +02:00
|
|
|
|
for (NumHit = 1;
|
2021-04-17 01:08:48 +02:00
|
|
|
|
NumHit <= NumHits;
|
|
|
|
|
NumHit++)
|
2016-09-12 17:43:23 +02:00
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get the year (in row[0] is the date in YYYY format) */
|
|
|
|
|
if (sscanf (row[0],"%04u",&ReadYear) != 1)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongDateExit ();
|
2016-09-12 17:43:23 +02:00
|
|
|
|
|
|
|
|
|
/* Get number hits (in row[1]) */
|
2016-10-09 01:03:30 +02:00
|
|
|
|
if (sscanf (row[1],"%lu",&Report->Hits.Num) != 1)
|
|
|
|
|
Report->Hits.Num = 0;
|
2016-09-12 17:43:23 +02:00
|
|
|
|
|
|
|
|
|
for (Year = LastYear;
|
|
|
|
|
Year >= ReadYear;
|
|
|
|
|
Year--)
|
|
|
|
|
{
|
|
|
|
|
/* Write the year */
|
2016-10-03 22:41:45 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"%04u ",Year);
|
2016-09-12 17:43:23 +02:00
|
|
|
|
|
|
|
|
|
/* Draw bar proportional to number of hits */
|
2016-11-14 10:30:33 +01:00
|
|
|
|
Rep_DrawBarNumHits (Year == ReadYear ? Report->Hits.Num :
|
2016-10-08 21:19:47 +02:00
|
|
|
|
0,
|
2016-10-09 01:03:30 +02:00
|
|
|
|
Report->Hits.Max,Rep_MAX_BAR_WIDTH);
|
2016-10-08 20:25:26 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<br />");
|
2016-09-12 17:43:23 +02:00
|
|
|
|
}
|
|
|
|
|
LastYear = Year;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-08 20:25:26 +02:00
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2016-09-12 17:43:23 +02:00
|
|
|
|
/***** Finally, show the oldest years without clicks *****/
|
2020-04-12 22:52:01 +02:00
|
|
|
|
for (Year = LastYear;
|
|
|
|
|
Year >= FirstYear;
|
2016-09-12 17:43:23 +02:00
|
|
|
|
Year--)
|
|
|
|
|
{
|
|
|
|
|
/* Write the year */
|
2016-10-03 22:41:45 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"%04u ",Year);
|
2016-09-12 17:43:23 +02:00
|
|
|
|
|
|
|
|
|
/* Draw bar proportional to number of hits */
|
2016-10-09 01:03:30 +02:00
|
|
|
|
Rep_DrawBarNumHits (0,Report->Hits.Max,Rep_MAX_BAR_WIDTH);
|
2016-10-08 20:25:26 +02:00
|
|
|
|
fprintf (Gbl.F.Rep,"<br />");
|
2016-09-12 17:43:23 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-08 21:19:47 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Compute maximum and total number of hits ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Rep_ComputeMaxAndTotalHits (struct Rep_Hits *Hits,
|
2021-04-17 01:08:48 +02:00
|
|
|
|
unsigned NumHits,
|
2016-10-08 21:19:47 +02:00
|
|
|
|
MYSQL_RES *mysql_res,unsigned Field)
|
|
|
|
|
{
|
2021-04-17 01:08:48 +02:00
|
|
|
|
unsigned NumHit;
|
2016-10-08 21:19:47 +02:00
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
|
|
|
|
/***** For each row... *****/
|
2021-10-13 15:37:14 +02:00
|
|
|
|
for (NumHit = 1, Hits->Max = 0;
|
2021-04-17 01:08:48 +02:00
|
|
|
|
NumHit <= NumHits;
|
|
|
|
|
NumHit++)
|
2016-10-08 21:19:47 +02:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get number of hits */
|
|
|
|
|
if (sscanf (row[Field],"%lu",&Hits->Num) != 1)
|
|
|
|
|
Hits->Num = 0;
|
|
|
|
|
|
|
|
|
|
/* Update maximum hits */
|
|
|
|
|
if (Hits->Num > Hits->Max)
|
|
|
|
|
Hits->Max = Hits->Num;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-12 01:06:36 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Draw a bar with the number of hits ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-08 21:19:47 +02:00
|
|
|
|
static void Rep_DrawBarNumHits (unsigned long HitsNum,unsigned long HitsMax,
|
2016-09-12 10:02:17 +02:00
|
|
|
|
unsigned MaxBarWidth)
|
2016-09-12 01:06:36 +02:00
|
|
|
|
{
|
|
|
|
|
unsigned BarWidth;
|
2016-09-12 10:02:17 +02:00
|
|
|
|
unsigned i;
|
2016-09-12 01:06:36 +02:00
|
|
|
|
|
2016-10-08 21:19:47 +02:00
|
|
|
|
if (HitsNum)
|
2016-09-12 01:06:36 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Draw bar with a with proportional to the number of hits *****/
|
2019-11-11 00:15:44 +01:00
|
|
|
|
BarWidth = (unsigned) ((((double) HitsNum * (double) MaxBarWidth) /
|
|
|
|
|
(double) HitsMax) + 0.5);
|
2016-10-04 01:16:52 +02:00
|
|
|
|
if (BarWidth)
|
|
|
|
|
{
|
|
|
|
|
fprintf (Gbl.F.Rep,"<strong>");
|
|
|
|
|
for (i = 0;
|
|
|
|
|
i < BarWidth;
|
|
|
|
|
i++)
|
|
|
|
|
fprintf (Gbl.F.Rep,Rep_BLOCK);
|
|
|
|
|
fprintf (Gbl.F.Rep,"</strong>");
|
|
|
|
|
}
|
2016-09-12 01:06:36 +02:00
|
|
|
|
|
|
|
|
|
/***** Write the number of hits *****/
|
2016-10-03 22:41:45 +02:00
|
|
|
|
fprintf (Gbl.F.Rep," ");
|
2019-12-14 13:35:35 +01:00
|
|
|
|
Rep_WriteDouble (HitsNum);
|
2016-09-12 01:06:36 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-06 22:18:33 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Remove all user's usage report of a user from database ***********/
|
2019-12-14 13:35:35 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Rep_WriteDouble (double Num)
|
|
|
|
|
{
|
|
|
|
|
char *Str;
|
|
|
|
|
|
|
|
|
|
/***** Write from floating point number to string
|
|
|
|
|
with the correct accuracy *****/
|
2020-01-11 15:22:02 +01:00
|
|
|
|
Str_DoubleNumToStrFewDigits (&Str,Num);
|
2019-12-14 13:35:35 +01:00
|
|
|
|
|
|
|
|
|
/***** Write number from string to file *****/
|
|
|
|
|
fputs (Str,Gbl.F.Rep);
|
|
|
|
|
|
|
|
|
|
/***** Free memory allocated for string *****/
|
|
|
|
|
free (Str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Remove all user's usage report of a user from database ***********/
|
2016-10-06 22:18:33 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Rep_RemoveUsrUsageReports (long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Remove all user's usage report files of a user *****/
|
|
|
|
|
Rep_RemoveUsrReportsFiles (UsrCod);
|
|
|
|
|
|
|
|
|
|
/***** Remove all user's usage reports of a user from database *****/
|
2021-05-10 21:10:06 +02:00
|
|
|
|
Rep_DB_RemoveUsrReports (UsrCod);
|
2016-10-06 22:18:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Remove all user's usage reports of a user from database **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Rep_RemoveUsrReportsFiles (long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumReports;
|
|
|
|
|
unsigned NumReport;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PathUniqueDirReport[PATH_MAX + 1];
|
2016-10-06 22:18:33 +02:00
|
|
|
|
|
|
|
|
|
/***** Get directories for the reports *****/
|
2021-10-13 15:37:14 +02:00
|
|
|
|
NumReports = Rep_DB_GetUsrReportsFiles (&mysql_res,UsrCod);
|
2016-10-06 22:18:33 +02:00
|
|
|
|
|
|
|
|
|
/***** Remove the reports *****/
|
|
|
|
|
for (NumReport = 0;
|
|
|
|
|
NumReport < NumReports;
|
|
|
|
|
NumReport++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next report */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Remove report directory and file */
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (PathUniqueDirReport,sizeof (PathUniqueDirReport),"%s/%s/%s",
|
2019-03-20 01:36:36 +01:00
|
|
|
|
Cfg_PATH_REP_PUBLIC,row[0],row[1]);
|
2016-10-06 22:18:33 +02:00
|
|
|
|
Fil_RemoveTree (PathUniqueDirReport);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|