mirror of https://github.com/acanas/swad-core.git
Version 15.4.1
This commit is contained in:
parent
243ceaed42
commit
0b15e678c9
|
@ -98,11 +98,12 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.4 (2015/09/30)"
|
#define Log_PLATFORM_VERSION "SWAD 15.4.1 (2015/09/30)"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// 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
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 15.4.1: Sep 30, 2015 Code refactoring in global/course statistics. (184861 lines)
|
||||||
Version 15.4: Sep 30, 2015 Changes in global/course statistics forms. (184877 lines)
|
Version 15.4: Sep 30, 2015 Changes in global/course statistics forms. (184877 lines)
|
||||||
Version 15.3.3: Sep 30, 2015 Changes in layout of form to selected initial and final dates. (185152 lines)
|
Version 15.3.3: Sep 30, 2015 Changes in layout of form to selected initial and final dates. (185152 lines)
|
||||||
Version 15.3.2: Sep 30, 2015 Changes in layout of statistical figures. (185156 lines)
|
Version 15.3.2: Sep 30, 2015 Changes in layout of statistical figures. (185156 lines)
|
||||||
|
|
177
swad_statistic.c
177
swad_statistic.c
|
@ -88,6 +88,12 @@ struct Sta_StatsForum
|
||||||
unsigned NumUsrsToBeNotifiedByEMail;
|
unsigned NumUsrsToBeNotifiedByEMail;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
Sta_SHOW_GLOBAL_ACCESSES,
|
||||||
|
Sta_SHOW_COURSE_ACCESSES,
|
||||||
|
} Sta_GlobalOrCourseAccesses_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Internal prototypes ***************************/
|
/***************************** Internal prototypes ***************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -96,7 +102,7 @@ static void Sta_PutFormToRequestAccessesCrs (void);
|
||||||
|
|
||||||
static void Sta_WriteSelectorCountType (void);
|
static void Sta_WriteSelectorCountType (void);
|
||||||
static void Sta_WriteSelectorAction (void);
|
static void Sta_WriteSelectorAction (void);
|
||||||
static bool Sta_SeeAccesses (void);
|
static void Sta_SeeAccesses (Sta_GlobalOrCourseAccesses_t GlobalOrCourse);
|
||||||
static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql_res);
|
static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql_res);
|
||||||
static void Sta_WriteLogComments (long LogCod);
|
static void Sta_WriteLogComments (long LogCod);
|
||||||
static void Sta_ShowNumAccessesPerUsr (unsigned long NumRows,MYSQL_RES *mysql_res);
|
static void Sta_ShowNumAccessesPerUsr (unsigned long NumRows,MYSQL_RES *mysql_res);
|
||||||
|
@ -767,16 +773,14 @@ void Sta_SetIniEndDates (void)
|
||||||
/******************** Compute and show access statistics *********************/
|
/******************** Compute and show access statistics *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Sta_SeeCrsAccesses (void)
|
|
||||||
{
|
|
||||||
if (!Sta_SeeAccesses ())
|
|
||||||
Sta_AskSeeCrsAccesses ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sta_SeeGblAccesses (void)
|
void Sta_SeeGblAccesses (void)
|
||||||
{
|
{
|
||||||
if (!Sta_SeeAccesses ())
|
Sta_SeeAccesses (Sta_SHOW_GLOBAL_ACCESSES);
|
||||||
Sta_AskSeeGblAccesses ();
|
}
|
||||||
|
|
||||||
|
void Sta_SeeCrsAccesses (void)
|
||||||
|
{
|
||||||
|
Sta_SeeAccesses (Sta_SHOW_COURSE_ACCESSES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -787,7 +791,7 @@ void Sta_SeeGblAccesses (void)
|
||||||
|
|
||||||
// Returns false on error
|
// Returns false on error
|
||||||
|
|
||||||
static bool Sta_SeeAccesses (void)
|
static void Sta_SeeAccesses (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
{
|
{
|
||||||
extern const char *Txt_You_must_select_one_ore_more_users;
|
extern const char *Txt_You_must_select_one_ore_more_users;
|
||||||
extern const char *Txt_There_is_no_knowing_how_many_users_not_logged_have_accessed;
|
extern const char *Txt_There_is_no_knowing_how_many_users_not_logged_have_accessed;
|
||||||
|
@ -795,7 +799,6 @@ static bool Sta_SeeAccesses (void)
|
||||||
extern const char *Txt_There_are_no_accesses_with_the_selected_search_criteria;
|
extern const char *Txt_There_are_no_accesses_with_the_selected_search_criteria;
|
||||||
extern const char *Txt_List_of_detailed_clicks;
|
extern const char *Txt_List_of_detailed_clicks;
|
||||||
extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES];
|
extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES];
|
||||||
enum {STAT_GLOBAL,STAT_COURSE} StatsGlobalOrCourse;
|
|
||||||
char Query[MAX_LENGTH_QUERY_ACCESS+1];
|
char Query[MAX_LENGTH_QUERY_ACCESS+1];
|
||||||
char QueryAux[512];
|
char QueryAux[512];
|
||||||
long LengthQuery;
|
long LengthQuery;
|
||||||
|
@ -860,104 +863,86 @@ static bool Sta_SeeAccesses (void)
|
||||||
Lay_ShowErrorAndExit ("Action is missing.");
|
Lay_ShowErrorAndExit ("Action is missing.");
|
||||||
Gbl.Stat.NumAction = (Act_Action_t) UnsignedNum;
|
Gbl.Stat.NumAction = (Act_Action_t) UnsignedNum;
|
||||||
|
|
||||||
switch (Gbl.Stat.ClicksGroupedBy)
|
switch (GlobalOrCourse)
|
||||||
{
|
{
|
||||||
case Sta_CLICKS_GBL_PER_DAYS:
|
case Sta_SHOW_GLOBAL_ACCESSES:
|
||||||
case Sta_CLICKS_GBL_PER_DAYS_AND_HOUR:
|
/***** Get the type of user of clicks *****/
|
||||||
case Sta_CLICKS_GBL_PER_WEEKS:
|
Par_GetParToText ("Role",UnsignedStr,10);
|
||||||
case Sta_CLICKS_GBL_PER_MONTHS:
|
if (sscanf (UnsignedStr,"%u",&UnsignedNum) != 1)
|
||||||
case Sta_CLICKS_GBL_PER_HOUR:
|
Lay_ShowErrorAndExit ("Type of users is missing.");
|
||||||
case Sta_CLICKS_GBL_PER_MINUTE:
|
if (UnsignedNum >= Sta_NUM_ROLES_STAT)
|
||||||
case Sta_CLICKS_GBL_PER_ACTION:
|
Lay_ShowErrorAndExit ("Type of users is missing.");
|
||||||
case Sta_CLICKS_GBL_PER_PLUGIN:
|
Gbl.Stat.Role = (Sta_Role_t) UnsignedNum;
|
||||||
case Sta_CLICKS_GBL_PER_WEB_SERVICE_FUNCTION:
|
|
||||||
case Sta_CLICKS_GBL_PER_BANNER:
|
/***** Get users range for access statistics *****/
|
||||||
case Sta_CLICKS_GBL_PER_DEGREE:
|
Gbl.Scope.Allowed = 1 << Sco_SCOPE_SYS |
|
||||||
case Sta_CLICKS_GBL_PER_COURSE:
|
1 << Sco_SCOPE_CTY |
|
||||||
StatsGlobalOrCourse = STAT_GLOBAL;
|
1 << Sco_SCOPE_INS |
|
||||||
|
1 << Sco_SCOPE_CTR |
|
||||||
|
1 << Sco_SCOPE_DEG |
|
||||||
|
1 << Sco_SCOPE_CRS;
|
||||||
|
Gbl.Scope.Default = Sco_SCOPE_SYS;
|
||||||
|
Sco_GetScope ();
|
||||||
|
|
||||||
|
/***** Show form again *****/
|
||||||
|
Sta_AskSeeGblAccesses ();
|
||||||
|
|
||||||
|
/***** The following types of query will never give a valid result *****/
|
||||||
|
if ((Gbl.Stat.Role == Sta_ALL_USRS ||
|
||||||
|
Gbl.Stat.Role == Sta_UNKNOWN_USRS) &&
|
||||||
|
(Gbl.Stat.CountType == Sta_DISTINCT_USRS ||
|
||||||
|
Gbl.Stat.CountType == Sta_CLICKS_PER_USR))
|
||||||
|
{
|
||||||
|
Lay_ShowAlert (Lay_WARNING,Txt_There_is_no_knowing_how_many_users_not_logged_have_accessed);
|
||||||
|
Usr_UsrDataDestructor (&UsrDat);
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
case Sta_SHOW_COURSE_ACCESSES:
|
||||||
StatsGlobalOrCourse = STAT_COURSE;
|
if (Gbl.Stat.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST)
|
||||||
break;
|
{
|
||||||
}
|
/****** Get the number of the first row to show ******/
|
||||||
|
Par_GetParToText ("FirstRow",UnsignedStr,10);
|
||||||
|
if (sscanf (UnsignedStr,"%lu",&Gbl.Stat.FirstRow) != 1)
|
||||||
|
Lay_ShowErrorAndExit ("Number of start row is missing.");
|
||||||
|
|
||||||
if (Gbl.CurrentAct == ActSeeAccCrs)
|
/****** Get the number of the last row to show ******/
|
||||||
{
|
Par_GetParToText ("LastRow",UnsignedStr,10);
|
||||||
if (Gbl.Stat.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST)
|
if (sscanf (UnsignedStr,"%lu",&Gbl.Stat.LastRow) != 1)
|
||||||
{
|
Lay_ShowErrorAndExit ("Number of end row is missing.");
|
||||||
/****** Get the number of the first row to show ******/
|
|
||||||
Par_GetParToText ("FirstRow",UnsignedStr,10);
|
|
||||||
if (sscanf (UnsignedStr,"%lu",&Gbl.Stat.FirstRow) != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Number of start row is missing.");
|
|
||||||
|
|
||||||
/****** Get the number of the last row to show ******/
|
/****** Get the number of rows per page ******/
|
||||||
Par_GetParToText ("LastRow",UnsignedStr,10);
|
Par_GetParToText ("RowsPage",UnsignedStr,10);
|
||||||
if (sscanf (UnsignedStr,"%lu",&Gbl.Stat.LastRow) != 1)
|
if (sscanf (UnsignedStr,"%lu",&Gbl.Stat.RowsPerPage) != 1)
|
||||||
Lay_ShowErrorAndExit ("Number of end row is missing.");
|
Lay_ShowErrorAndExit ("Number of rows per page is missing.");
|
||||||
|
}
|
||||||
|
|
||||||
/****** Get the number of rows per page ******/
|
/***** Show form again *****/
|
||||||
Par_GetParToText ("RowsPage",UnsignedStr,10);
|
Sta_AskSeeCrsAccesses ();
|
||||||
if (sscanf (UnsignedStr,"%lu",&Gbl.Stat.RowsPerPage) != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Number of rows per page is missing.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Show form again *****/
|
/****** Get lists of selected users ******/
|
||||||
Sta_AskSeeCrsAccesses ();
|
Usr_GetListsSelectedUsrs ();
|
||||||
|
|
||||||
/****** Get lists of selected users ******/
|
/* Check the number of users whose clicks will be shown */
|
||||||
Usr_GetListsSelectedUsrs ();
|
if (!Usr_CountNumUsrsInListOfSelectedUsrs ()) // If there are no users selected...
|
||||||
|
{ // ...write warning message and show the form again
|
||||||
/* Check the number of users whose clicks will be shown */
|
Lay_ShowAlert (Lay_WARNING,Txt_You_must_select_one_ore_more_users);
|
||||||
if (!Usr_CountNumUsrsInListOfSelectedUsrs ()) // If there are no users selected...
|
return;
|
||||||
{ // ...write warning message and show the form again
|
}
|
||||||
Lay_ShowAlert (Lay_WARNING,Txt_You_must_select_one_ore_more_users);
|
break;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // Gbl.CurrentAct == ActSeeAccGbl
|
|
||||||
{
|
|
||||||
/***** Get the type of user of clicks *****/
|
|
||||||
Par_GetParToText ("Role",UnsignedStr,10);
|
|
||||||
if (sscanf (UnsignedStr,"%u",&UnsignedNum) != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Type of users is missing.");
|
|
||||||
if (UnsignedNum >= Sta_NUM_ROLES_STAT)
|
|
||||||
Lay_ShowErrorAndExit ("Type of users is missing.");
|
|
||||||
Gbl.Stat.Role = (Sta_Role_t) UnsignedNum;
|
|
||||||
/* The following types of query will never give a valid result */
|
|
||||||
if ((Gbl.Stat.Role == Sta_ALL_USRS ||
|
|
||||||
Gbl.Stat.Role == Sta_UNKNOWN_USRS) &&
|
|
||||||
(Gbl.Stat.CountType == Sta_DISTINCT_USRS ||
|
|
||||||
Gbl.Stat.CountType == Sta_CLICKS_PER_USR))
|
|
||||||
{
|
|
||||||
Lay_ShowAlert (Lay_WARNING,Txt_There_is_no_knowing_how_many_users_not_logged_have_accessed);
|
|
||||||
Usr_UsrDataDestructor (&UsrDat);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Get users range for access statistics *****/
|
|
||||||
Gbl.Scope.Allowed = 1 << Sco_SCOPE_SYS |
|
|
||||||
1 << Sco_SCOPE_CTY |
|
|
||||||
1 << Sco_SCOPE_INS |
|
|
||||||
1 << Sco_SCOPE_CTR |
|
|
||||||
1 << Sco_SCOPE_DEG |
|
|
||||||
1 << Sco_SCOPE_CRS;
|
|
||||||
Gbl.Scope.Default = Sco_SCOPE_SYS;
|
|
||||||
Sco_GetScope ();
|
|
||||||
|
|
||||||
/***** Show form again *****/
|
|
||||||
Sta_AskSeeGblAccesses ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Check if range of dates is forbidden for me *****/
|
/***** Check if range of dates is forbidden for me *****/
|
||||||
NumDays = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni,&Gbl.DateRange.DateEnd);
|
NumDays = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni,&Gbl.DateRange.DateEnd);
|
||||||
if (!(Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
|
if (!(Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
|
||||||
(Gbl.Usrs.Me.LoggedRole == Rol_TEACHER && StatsGlobalOrCourse == STAT_COURSE)))
|
(Gbl.Usrs.Me.LoggedRole == Rol_TEACHER && GlobalOrCourse == Sta_SHOW_COURSE_ACCESSES)))
|
||||||
|
// TODO: How long can query other admins?
|
||||||
if (NumDays > Cfg_DAYS_IN_RECENT_LOG)
|
if (NumDays > Cfg_DAYS_IN_RECENT_LOG)
|
||||||
{
|
{
|
||||||
sprintf (Gbl.Message,Txt_The_date_range_must_be_less_than_or_equal_to_X_days,
|
sprintf (Gbl.Message,Txt_The_date_range_must_be_less_than_or_equal_to_X_days,
|
||||||
Cfg_DAYS_IN_RECENT_LOG);
|
Cfg_DAYS_IN_RECENT_LOG);
|
||||||
Lay_ShowAlert (Lay_WARNING,Gbl.Message); // ...write warning message and show the form again
|
Lay_ShowAlert (Lay_WARNING,Gbl.Message); // ...write warning message and show the form again
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Query depending on the type of count *****/
|
/***** Query depending on the type of count *****/
|
||||||
|
@ -1062,9 +1047,9 @@ static bool Sta_SeeAccesses (void)
|
||||||
Gbl.DateRange.DateEnd.Day);
|
Gbl.DateRange.DateEnd.Day);
|
||||||
strcat (Query,QueryAux);
|
strcat (Query,QueryAux);
|
||||||
|
|
||||||
switch (StatsGlobalOrCourse)
|
switch (GlobalOrCourse)
|
||||||
{
|
{
|
||||||
case STAT_GLOBAL:
|
case Sta_SHOW_GLOBAL_ACCESSES:
|
||||||
/* Scope */
|
/* Scope */
|
||||||
if (Gbl.Scope.Current == Sco_SCOPE_INS &&
|
if (Gbl.Scope.Current == Sco_SCOPE_INS &&
|
||||||
Gbl.CurrentIns.Ins.InsCod > 0)
|
Gbl.CurrentIns.Ins.InsCod > 0)
|
||||||
|
@ -1180,7 +1165,7 @@ static bool Sta_SeeAccesses (void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STAT_COURSE:
|
case Sta_SHOW_COURSE_ACCESSES:
|
||||||
sprintf (QueryAux," AND %s.CrsCod='%ld'",
|
sprintf (QueryAux," AND %s.CrsCod='%ld'",
|
||||||
LogTable,Gbl.CurrentCrs.Crs.CrsCod);
|
LogTable,Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
strcat (Query,QueryAux);
|
strcat (Query,QueryAux);
|
||||||
|
@ -1359,8 +1344,6 @@ static bool Sta_SeeAccesses (void)
|
||||||
|
|
||||||
/***** Free memory used by the data of the user *****/
|
/***** Free memory used by the data of the user *****/
|
||||||
Usr_UsrDataDestructor (&UsrDat);
|
Usr_UsrDataDestructor (&UsrDat);
|
||||||
|
|
||||||
return true; // No error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -141,8 +141,8 @@ void Sta_RemoveOldEntriesRecentLog (void);
|
||||||
void Sta_AskSeeCrsAccesses (void);
|
void Sta_AskSeeCrsAccesses (void);
|
||||||
void Sta_AskSeeGblAccesses (void);
|
void Sta_AskSeeGblAccesses (void);
|
||||||
void Sta_SetIniEndDates (void);
|
void Sta_SetIniEndDates (void);
|
||||||
void Sta_SeeCrsAccesses (void);
|
|
||||||
void Sta_SeeGblAccesses (void);
|
void Sta_SeeGblAccesses (void);
|
||||||
|
void Sta_SeeCrsAccesses (void);
|
||||||
void Sta_ReqUseOfPlatform (void);
|
void Sta_ReqUseOfPlatform (void);
|
||||||
void Sta_ShowUseOfPlatform (void);
|
void Sta_ShowUseOfPlatform (void);
|
||||||
unsigned Sta_GetTotalNumberOfUsers (Sco_Scope_t Scope,Rol_Role_t Role);
|
unsigned Sta_GetTotalNumberOfUsers (Sco_Scope_t Scope,Rol_Role_t Role);
|
||||||
|
|
Loading…
Reference in New Issue