Version 16.8

This commit is contained in:
Antonio Cañas Vargas 2016-10-03 13:04:49 +02:00
parent ad1c7dbc94
commit 238d9e84ac
9 changed files with 141 additions and 59 deletions

View File

@ -1285,7 +1285,7 @@ Statistics:
1100. ActSeePhoDeg Show a class photo with the average photos of the students of each degree
1101. ActReqStaCrs Request statistics of courses
1102. ActReqAccGbl Request query of clicks to the complete platform
NEW. ActSeeMyUsgRep Show my usage report
NEW. ActReqMyUsgRep Request my usage report
1103. ActSeeOneSvy Show one survey
1104. ActAnsSvy Answer a survey
@ -1310,6 +1310,7 @@ Statistics:
1123. ActReqAccCrs Request query of clicks in the course
1124. ActSeeAccCrs Query clicks to current course
1125. ActSeeAllStaCrs Show statistics of courses
NEW. ActSeeMyUsgRep Show my usage report
NEW. ActPrnMyUsgRep Print my usage report
Profile:
1126. ActFrmLogIn Show landing page (forms to log in and to create a new account)
@ -2710,7 +2711,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActSeePhoDeg */{ 447, 2,TabSta,ActSeePhoDeg ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Pho_ShowPhotoDegree ,"classphoto64x64.gif" },
/* ActReqStaCrs */{ 767, 3,TabSta,ActReqStaCrs ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ind_ReqIndicatorsCourses ,"tablestats64x64.gif" },
/* ActReqAccGbl */{ 591, 4,TabSta,ActReqAccGbl ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Sta_SetIniEndDates ,Sta_AskShowGblHits ,"stats64x64.gif" },
/* ActSeeMyUsgRep */{1582, 5,TabSta,ActSeeMyUsgRep ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rep_ShowMyUsageReport ,"report64x64.png" },
/* ActReqMyUsgRep */{1586, 5,TabSta,ActReqMyUsgRep ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rep_ReqMyUsageReport ,"report64x64.png" },
// Actions not in menu:
/* ActSeeOneSvy */{ 982,-1,TabSta,ActSeeAllSvy ,0x1F8,0x1F8,0x1F8,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Svy_SeeOneSurvey ,NULL},
@ -2740,7 +2741,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActSeeAccCrs */{ 119,-1,TabSta,ActReqAccGbl ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Sta_SeeCrsAccesses ,NULL},
/* ActSeeAllStaCrs */{ 768,-1,TabSta,ActReqAccGbl ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Ind_ShowIndicatorsCourses ,NULL},
/* ActPrnMyUsgRep */{1583, 5,TabSta,ActSeeMyUsgRep ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Rep_PrintMyUsageReport ,NULL},
/* ActSeeMyUsgRep */{1582,-1,TabSta,ActReqMyUsgRep ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rep_ShowMyUsageReport ,NULL},
/* ActPrnMyUsgRep */{1583, 5,TabSta,ActReqMyUsgRep ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Rep_PrintMyUsageReport ,NULL},
// TabPrf ******************************************************************
// Actions in menu:
@ -4442,6 +4444,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq
ActPrnMyUsgRep, // #1583
ActChkUsrAcc, // #1584
ActAutUsrNew, // #1585
ActReqMyUsgRep, // #1586
};
/*****************************************************************************/

View File

@ -72,9 +72,9 @@ typedef enum
typedef int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action
#define Act_NUM_ACTIONS (1+9+51+15+90+70+67+246+186+156+172+36+30+87)
#define Act_NUM_ACTIONS (1+9+51+15+90+70+67+246+186+156+172+36+31+87)
#define Act_MAX_ACTION_COD 1585
#define Act_MAX_ACTION_COD 1586
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20
@ -1335,7 +1335,7 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica
#define ActSeePhoDeg (ActUnbUsrLst+ 3)
#define ActReqStaCrs (ActUnbUsrLst+ 4)
#define ActReqAccGbl (ActUnbUsrLst+ 5)
#define ActSeeMyUsgRep (ActUnbUsrLst+ 6)
#define ActReqMyUsgRep (ActUnbUsrLst+ 6)
// Secondary actions
#define ActSeeOneSvy (ActUnbUsrLst+ 7)
@ -1363,7 +1363,8 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica
#define ActSeeAccCrs (ActUnbUsrLst+ 28)
#define ActSeeAllStaCrs (ActUnbUsrLst+ 29)
#define ActPrnMyUsgRep (ActUnbUsrLst+ 30)
#define ActSeeMyUsgRep (ActUnbUsrLst+ 30)
#define ActPrnMyUsgRep (ActUnbUsrLst+ 31)
/*****************************************************************************/
/******************************** Profile tab ********************************/

View File

@ -143,14 +143,18 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.7.9 (2016-10-03)"
#define Log_PLATFORM_VERSION "SWAD 16.8 (2016-10-03)"
#define CSS_FILE "swad15.229.css"
#define JS_FILE "swad15.238.1.js"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/*
Version 16.7.9: Oct 03, 2016 Code refactoring in user's usage report. (? lines)
Version 16.8: Oct 03, 2016 New option to view user's usage report. (205720 lines)
1 change necessary in database:
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1586','es','N','Solicitar mi informe de uso');
Version 16.7.9: Oct 03, 2016 Code refactoring in user's usage report. (205650 lines)
Version 16.7.8: Oct 03, 2016 Code refactoring in user's usage report. (205632 lines)
Version 16.7.7: Oct 03, 2016 Code refactoring in user's usage report. (205609 lines)
Version 16.7.6: Oct 03, 2016 Code refactoring in user's usage report. (205591 lines)

View File

@ -103,6 +103,48 @@ void Dat_GetAndConvertCurrentDateTime (void)
Dat_GetDateBefore (&Gbl.Now.Date,&Gbl.Yesterday);
}
/*****************************************************************************/
/********************* Get current date and time in UTC **********************/
/*****************************************************************************/
/*
char StrCurrentDateUTC[10+1]; // Example: 2016-10-02
// 1234567890
char StrCurrentTimeUTC[8+1]; // Example: 19:03:49
// 12345678
*/
void Dat_GetCurrentDateTimeUTC (char StrCurrentDateUTC[10+1],
char StrCurrentTimeUTC[8+1])
{
time_t CurrentTime;
struct tm tm_CurrentTime;
if (StrCurrentDateUTC &&
StrCurrentDateUTC) // If both pointers are not NULL
{
/***** Initialize to empty strings *****/
if (StrCurrentDateUTC)
StrCurrentDateUTC[0] = '\0';
if (StrCurrentTimeUTC)
StrCurrentTimeUTC[0] = '\0';
/***** Get current time UTC *****/
time (&CurrentTime);
if ((gmtime_r (&CurrentTime,&tm_CurrentTime)) != NULL)
{
if (StrCurrentDateUTC) // If not NULL
sprintf (StrCurrentDateUTC,"%04d-%02d-%02d",
1900 + tm_CurrentTime.tm_year, // year
1 + tm_CurrentTime.tm_mon, // month
tm_CurrentTime.tm_mday); // day of the month
if (StrCurrentTimeUTC) // If not NULL
sprintf (StrCurrentTimeUTC,"%02d:%02d:%02d",
tm_CurrentTime.tm_hour, // hours
tm_CurrentTime.tm_min, // minutes
tm_CurrentTime.tm_sec); // seconds
}
}
}
/*****************************************************************************/
/************ Get UNIX time (seconds since 1970 UTC) from string *************/
/*****************************************************************************/

View File

@ -76,6 +76,9 @@ struct DateTime
void Dat_GetStartExecutionTimeUTC (void);
void Dat_GetAndConvertCurrentDateTime (void);
void Dat_GetCurrentDateTimeUTC (char StrCurrentDateUTC[10+1],
char StrCurrentTimeUTC[8+1]);
time_t Dat_GetUNIXTimeFromStr (const char *Str);
bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDDString);

View File

@ -177,7 +177,7 @@ const Act_Action_t Mnu_MenuActions[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB
ActSeePhoDeg,
ActReqStaCrs,
ActReqAccGbl,
ActSeeMyUsgRep,
ActReqMyUsgRep,
},
// TabPrf **********
{

View File

@ -77,18 +77,18 @@ extern struct Globals Gbl;
static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint);
static void Rep_PutIconToPrintMyUsageReport (void);
static void Rep_WriteHeader (const char *StrCurrentDate);
static void Rep_WriteHeader (const char *StrCurrentDateUTC);
static void Rep_WriteSectionPlatform (void);
static void Rep_WriteSectionUsrInfo (void);
static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures,
struct tm *tm_FirstClickTime,
const char *StrCurrentDate,
const char *StrCurrentTime);
const char *StrCurrentDateUTC,
const char *StrCurrentTimeUTC);
static void Rep_WriteSectionGlobalHits (struct UsrFigures *UsrFigures,
struct tm *tm_FirstClickTime);
static void Rep_WriteSectionCurrentCourses (struct UsrFigures *UsrFigures,
struct tm *tm_FirstClickTime,
const char *StrCurrentDate,
const char *StrCurrentDateUTC,
unsigned long MaxHitsPerYear);
static void Rep_WriteSectionHistoricCourses (struct UsrFigures *UsrFigures,
struct tm *tm_FirstClickTime,
@ -119,6 +119,34 @@ static void Rep_DrawBarNumHits (float HitsNum,float HitsMax,
/********* Show my usage report (report on my use of the platform) ***********/
/*****************************************************************************/
void Rep_ReqMyUsageReport (void)
{
extern const char *Txt_Report;
extern const char *Txt_Generate_report;
char StrCurrentDateUTC[10+1]; // Example: 2016-10-02
// 1234567890
char StrCurrentTimeUTC[8+1]; // Example: 19:03:49
// 12345678
/***** Get current date-time *****/
Dat_GetCurrentDateTimeUTC (StrCurrentDateUTC,StrCurrentTimeUTC);
/***** Form to show my usage report *****/
Act_FormStart (ActSeeMyUsgRep);
/***** Start frame *****/
Lay_StartRoundFrame (NULL,Txt_Report,NULL);
/***** Header *****/
Rep_WriteHeader (StrCurrentDateUTC);
/***** Send button and end frame *****/
Lay_EndRoundFrameWithButton (Lay_CONFIRM_BUTTON,Txt_Generate_report);
/***** End of form *****/
Act_FormEnd ();
}
void Rep_ShowMyUsageReport (void)
{
Rep_ShowOrPrintMyUsageReport (false);
@ -133,33 +161,16 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint)
{
extern const char *Txt_Report;
struct UsrFigures UsrFigures;
time_t CurrentTime;
struct tm tm_CurrentTime;
struct tm tm_FirstClickTime;
char StrCurrentDate[10+1]; // Example: 2016-10-02
// 1234567890
char StrCurrentTime[8+1]; // Example: 19:03:49
// 12345678
char StrCurrentDateUTC[10+1]; // Example: 2016-10-02
// 1234567890
char StrCurrentTimeUTC[8+1]; // Example: 19:03:49
// 12345678
unsigned long MaxHitsPerYear;
/***** Get current date-time *****/
time (&CurrentTime);
if ((gmtime_r (&CurrentTime,&tm_CurrentTime)) != NULL)
{
sprintf (StrCurrentDate,"%04d-%02d-%02d",
1900 + tm_CurrentTime.tm_year, // year
1 + tm_CurrentTime.tm_mon, // month
tm_CurrentTime.tm_mday); // day of the month
sprintf (StrCurrentTime,"%02d:%02d:%02d",
tm_CurrentTime.tm_hour, // hours
tm_CurrentTime.tm_min, // minutes
tm_CurrentTime.tm_sec); // seconds
}
else
{
StrCurrentDate[0] = '\0';
StrCurrentTime[0] = '\0';
}
Dat_GetCurrentDateTimeUTC (StrCurrentDateUTC,StrCurrentTimeUTC);
/***** Start frame *****/
if (SeeOrPrint == Rep_SEE)
@ -167,8 +178,8 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint)
Rep_PutIconToPrintMyUsageReport);
fprintf (Gbl.F.Out,"<div style=\"margin:2em; text-align:left;\">\n");
/***** Head *****/
Rep_WriteHeader (StrCurrentDate);
/***** Header *****/
Rep_WriteHeader (StrCurrentDateUTC);
/***** Platform *****/
Rep_WriteSectionPlatform ();
@ -181,7 +192,7 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint)
if (UsrFigures.FirstClickTimeUTC)
gmtime_r (&UsrFigures.FirstClickTimeUTC,&tm_FirstClickTime);
Rep_WriteSectionUsrFigures (&UsrFigures,&tm_FirstClickTime,
StrCurrentDate,StrCurrentTime);
StrCurrentDateUTC,StrCurrentTimeUTC);
/***** Global hits *****/
Rep_WriteSectionGlobalHits (&UsrFigures,&tm_FirstClickTime);
@ -189,7 +200,7 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint)
/***** Current courses *****/
MaxHitsPerYear = Rep_GetMaxHitsPerYear (UsrFigures.FirstClickTimeUTC);
Rep_WriteSectionCurrentCourses (&UsrFigures,&tm_FirstClickTime,
StrCurrentDate,MaxHitsPerYear);
StrCurrentDateUTC,MaxHitsPerYear);
/***** Historic courses *****/
Rep_WriteSectionHistoricCourses (&UsrFigures,&tm_FirstClickTime,
@ -219,7 +230,7 @@ static void Rep_PutIconToPrintMyUsageReport (void)
/******************** Write header of user's usage report ********************/
/*****************************************************************************/
static void Rep_WriteHeader (const char *StrCurrentDate)
static void Rep_WriteHeader (const char *StrCurrentDateUTC)
{
extern const char *Txt_Report_of_use_of_PLATFORM;
@ -232,8 +243,8 @@ static void Rep_WriteHeader (const char *StrCurrentDate)
/***** Subtitle *****/
fprintf (Gbl.F.Out,"<h2>%s",Gbl.Usrs.Me.UsrDat.FullName);
if (StrCurrentDate[0])
fprintf (Gbl.F.Out,", %s",StrCurrentDate);
if (StrCurrentDateUTC[0])
fprintf (Gbl.F.Out,", %s",StrCurrentDateUTC);
fprintf (Gbl.F.Out,"</h2>");
/***** End of header *****/
@ -325,8 +336,8 @@ static void Rep_WriteSectionUsrInfo (void)
static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures,
struct tm *tm_FirstClickTime,
const char *StrCurrentDate,
const char *StrCurrentTime)
const char *StrCurrentDateUTC,
const char *StrCurrentTimeUTC)
{
extern const char *Txt_Figures;
extern const char *Txt_TIME_Since;
@ -369,9 +380,9 @@ static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures,
tm_FirstClickTime->tm_hour, // hours
tm_FirstClickTime->tm_min, // minutes
tm_FirstClickTime->tm_sec); // seconds
if (StrCurrentDate[0])
if (StrCurrentDateUTC[0])
fprintf (Gbl.F.Out," %s %s %s UTC",
Txt_TIME_until,StrCurrentDate,StrCurrentTime);
Txt_TIME_until,StrCurrentDateUTC,StrCurrentTimeUTC);
if (UsrFigures->NumDays > 0)
fprintf (Gbl.F.Out," (%d %s)",
UsrFigures->NumDays,
@ -382,8 +393,8 @@ static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures,
else // Time of first click is unknown
{
fprintf (Gbl.F.Out,"?");
if (StrCurrentDate[0])
fprintf (Gbl.F.Out," - %s %s UTC",StrCurrentDate,StrCurrentTime);
if (StrCurrentDateUTC[0])
fprintf (Gbl.F.Out," - %s %s UTC",StrCurrentDateUTC,StrCurrentTimeUTC);
}
fprintf (Gbl.F.Out,"</li>");
@ -514,7 +525,7 @@ static void Rep_WriteSectionGlobalHits (struct UsrFigures *UsrFigures,
static void Rep_WriteSectionCurrentCourses (struct UsrFigures *UsrFigures,
struct tm *tm_FirstClickTime,
const char *StrCurrentDate,
const char *StrCurrentDateUTC,
unsigned long MaxHitsPerYear)
{
extern const char *Txt_Courses;
@ -524,8 +535,8 @@ static void Rep_WriteSectionCurrentCourses (struct UsrFigures *UsrFigures,
fprintf (Gbl.F.Out,"<section>"
"<h3>%s",
Txt_Courses);
if (StrCurrentDate[0])
fprintf (Gbl.F.Out," (%s)",StrCurrentDate);
if (StrCurrentDateUTC[0])
fprintf (Gbl.F.Out," (%s)",StrCurrentDateUTC);
fprintf (Gbl.F.Out,"</h3>"
"<ul>");

View File

@ -27,10 +27,6 @@
/********************************** Headers **********************************/
/*****************************************************************************/
// #include <stdlib.h> // For malloc
// #include "swad_user.h"
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
@ -43,6 +39,7 @@
/****************************** Public prototypes ****************************/
/*****************************************************************************/
void Rep_ReqMyUsageReport (void);
void Rep_ShowMyUsageReport (void);
void Rep_PrintMyUsageReport (void);

View File

@ -13321,6 +13321,27 @@ const char *Txt_Generate_exam =
"Gerar teste";
#endif
const char *Txt_Generate_report =
#if L==1
"Generar informe";
#elif L==2
"Generieren Nutzungsbericht";
#elif L==3
"Generate report";
#elif L==4
"Generar informe";
#elif L==5
"G&eacute;n&eacute;rer le rapport";
#elif L==6
"Generar informe"; // Okoteve traducción
#elif L==7
"Crea rapporto";
#elif L==8
"Wygeneruj raport";
#elif L==9
"Gerar relat&oacute;rio";
#endif
const char *Txt_Get_a_new_password =
#if L==1
"Rebre una nova contrasenya";
@ -19027,7 +19048,7 @@ const char *Txt_MENU_TITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB] =
"Visitas"
#endif
,
// ActSeeMyUsgRep
// ActReqMyUsgRep
#if L==1
"Informe"
#elif L==2
@ -20900,7 +20921,7 @@ const char *Txt_MENU_SUBTITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB] =
"Estat&iacute;sticas de acesso &agrave; plataforma"
#endif
,
// ActSeeMyUsgRep
// ActReqMyUsgRep
#if L==1
"Informe sobre el meu &uacute;s de la plataforma"
#elif L==2