diff --git a/swad_changelog.h b/swad_changelog.h index b83d8e2a..5fb21d3d 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -497,7 +497,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.177 (2020-04-12)" +#define Log_PLATFORM_VERSION "SWAD 19.178 (2020-04-12)" #define CSS_FILE "swad19.146.css" #define JS_FILE "swad19.172.1.js" /* @@ -548,6 +548,7 @@ Funci // TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores // TODO: Integrar pull requests con traducciones del alemán del usuario eruedin en GitHub + Version 19.178: Apr 12, 2020 Code refactoring in statistics. (285569 lines) Version 19.177: Apr 12, 2020 Code refactoring in exam announcements. (285509 lines) Version 19.176: Apr 12, 2020 Code refactoring in agenda. (285419 lines) Version 19.175: Apr 12, 2020 Code refactoring in syllabus. (285345 lines) diff --git a/swad_course_config.c b/swad_course_config.c index 4b09c7d4..17dae3cb 100644 --- a/swad_course_config.c +++ b/swad_course_config.c @@ -448,13 +448,13 @@ static void CrsCfg_Indicators (void) { extern const char *Txt_Indicators; extern const char *Txt_of_PART_OF_A_TOTAL; - struct Ind_IndicatorsCrs Indicators; + struct Ind_IndicatorsCrs IndicatorsCrs; int NumIndicatorsFromDB = Ind_GetNumIndicatorsCrsFromDB (Gbl.Hierarchy.Crs.CrsCod); char *Title; /***** Compute indicators ******/ Ind_ComputeAndStoreIndicatorsCrs (Gbl.Hierarchy.Crs.CrsCod, - NumIndicatorsFromDB,&Indicators); + NumIndicatorsFromDB,&IndicatorsCrs); /***** Number of indicators *****/ HTM_TR_Begin (NULL); @@ -466,13 +466,13 @@ static void CrsCfg_Indicators (void) HTM_TD_Begin ("class=\"LB\""); Frm_StartForm (ActReqStaCrs); if (asprintf (&Title,"%u %s %u", - Indicators.NumIndicators, + IndicatorsCrs.NumIndicators, Txt_of_PART_OF_A_TOTAL,Ind_NUM_INDICATORS) < 0) Lay_NotEnoughMemoryExit (); HTM_BUTTON_SUBMIT_Begin (Title,"BT_LINK DAT",NULL); HTM_TxtF ("%s ",Title); - Ico_PutIcon ((Indicators.NumIndicators == Ind_NUM_INDICATORS) ? "check-circle.svg" : - "exclamation-triangle.svg", + Ico_PutIcon ((IndicatorsCrs.NumIndicators == Ind_NUM_INDICATORS) ? "check-circle.svg" : + "exclamation-triangle.svg", Title,"ICO16x16"); HTM_BUTTON_End (); free (Title); diff --git a/swad_degree_type.c b/swad_degree_type.c index f2ec984c..f813838b 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -103,7 +103,7 @@ static void DT_EditingDegreeTypeDestructor (void); /************** Show selector of degree types for statistics *****************/ /*****************************************************************************/ -void DT_WriteSelectorDegreeTypes (void) +void DT_WriteSelectorDegreeTypes (long SelectedDegTypCod) { extern const char *Txt_Any_type_of_degree; unsigned NumDegTyp; @@ -116,13 +116,13 @@ void DT_WriteSelectorDegreeTypes (void) HTM_SELECT_Begin (true, "id=\"OthDegTypCod\" name=\"OthDegTypCod\""); HTM_OPTION (HTM_Type_STRING,"-1", - Gbl.Stat.DegTypCod == -1L,false, + SelectedDegTypCod == -1L,false, "%s",Txt_Any_type_of_degree); for (NumDegTyp = 0; NumDegTyp < Gbl.DegTypes.Num; NumDegTyp++) HTM_OPTION (HTM_Type_LONG,&Gbl.DegTypes.Lst[NumDegTyp].DegTypCod, - Gbl.DegTypes.Lst[NumDegTyp].DegTypCod == Gbl.Stat.DegTypCod,false, + Gbl.DegTypes.Lst[NumDegTyp].DegTypCod == SelectedDegTypCod,false, "%s",Gbl.DegTypes.Lst[NumDegTyp].DegTypName); HTM_SELECT_End (); diff --git a/swad_degree_type.h b/swad_degree_type.h index c0425a5d..7e175853 100644 --- a/swad_degree_type.h +++ b/swad_degree_type.h @@ -58,7 +58,7 @@ typedef enum /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void DT_WriteSelectorDegreeTypes (void); +void DT_WriteSelectorDegreeTypes (long SelectedDegTypCod); void DT_SeeDegreeTypesInDegTab (void); void DT_SeeDegreeTypesInStaTab (void); diff --git a/swad_global.c b/swad_global.c index cbc9ba0f..5b575972 100644 --- a/swad_global.c +++ b/swad_global.c @@ -300,13 +300,6 @@ void Gbl_InitializeGlobals (void) Gbl.Usrs.ClassPhoto.AllGroups = true; Gbl.Usrs.ClassPhoto.Cols = Usr_CLASS_PHOTO_COLS_DEF; - /* Statistics */ - Gbl.Stat.ClicksGroupedBy = Sta_CLICKS_GROUPED_BY_DEFAULT; - Gbl.Stat.CountType = Sta_COUNT_TYPE_DEFAULT; - Gbl.Stat.Role = Sta_ROLE_DEFAULT; - Gbl.Stat.NumAction = Sta_NUM_ACTION_DEFAULT; - Gbl.Stat.RowsPerPage = Sta_DEF_ROWS_PER_PAGE; - Gbl.Scope.Current = Hie_CRS; Gbl.Usrs.Connected.TimeToRefreshInMs = Con_MAX_TIME_TO_REFRESH_CONNECTED_IN_MS; diff --git a/swad_global.h b/swad_global.h index dcb5c128..f424ee5c 100644 --- a/swad_global.h +++ b/swad_global.h @@ -486,7 +486,6 @@ struct Globals struct DateTime DateEnd; // TODO: Remove in future versions time_t TimeUTC[Dat_NUM_START_END_TIME]; } DateRange; - struct Sta_Stats Stat; /* Cache */ struct diff --git a/swad_indicator.c b/swad_indicator.c index 3f6a2f26..33ff5cca 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -59,6 +59,8 @@ typedef enum Ind_INDICATORS_FULL, } Ind_IndicatorsLayout_t; +struct Ind_Indicators Indicators; + /*****************************************************************************/ /***************************** Private prototypes ****************************/ /*****************************************************************************/ @@ -68,7 +70,7 @@ static void Ind_GetParamNumIndicators (void); static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res); static bool Ind_GetIfShowBigList (unsigned NumCrss); static void Ind_PutButtonToConfirmIWantToSeeBigList (unsigned NumCrss); -static void Ind_PutParamsConfirmIWantToSeeBigList (void *Stats); +static void Ind_PutParamsConfirmIWantToSeeBigList (void *Indicators); static void Ind_GetNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 + Ind_NUM_INDICATORS], unsigned NumCrss,MYSQL_RES *mysql_res); @@ -139,7 +141,7 @@ void Ind_ReqIndicatorsCourses (void) /* Data */ HTM_TD_Begin ("class=\"DAT LT\""); - DT_WriteSelectorDegreeTypes (); + DT_WriteSelectorDegreeTypes (Indicators.DegTypCod); HTM_Txt (" ("); HTM_TxtF (Txt_only_if_the_scope_is_X,Cfg_PLATFORM_SHORT_NAME); HTM_Txt (")"); @@ -156,7 +158,7 @@ void Ind_ReqIndicatorsCourses (void) /* Data */ HTM_TD_Begin ("class=\"LT\""); Dpt_WriteSelectorDepartment (Gbl.Hierarchy.Ins.InsCod, // Departments in current insitution - Gbl.Stat.DptCod, // Selected department + Indicators.DptCod, // Selected department "INDICATORS_INPUT", // Selector class -1L, // First option Txt_Any_department, // Text when no department selected @@ -167,9 +169,9 @@ void Ind_ReqIndicatorsCourses (void) /***** Get courses from database *****/ /* The result will contain courses with any number of indicators - If Gbl.Stat.NumIndicators < 0 ==> all courses in result will be listed - If Gbl.Stat.NumIndicators >= 0 ==> only those courses in result - with Gbl.Stat.NumIndicators set to yes + If Indicators.NumIndicators < 0 ==> all courses in result will be listed + If Indicators.NumIndicators >= 0 ==> only those courses in result + with Indicators.NumIndicators set to yes will be listed */ NumCrss = Ind_GetTableOfCourses (&mysql_res); @@ -197,7 +199,7 @@ void Ind_ReqIndicatorsCourses (void) for (Ind = 0, NumCrssToList = 0; Ind <= Ind_NUM_INDICATORS; Ind++) - if (Gbl.Stat.IndicatorsSelected[Ind]) + if (Indicators.IndicatorsSelected[Ind]) NumCrssToList += NumCrssWithIndicatorYes[Ind]; if (Ind_GetIfShowBigList (NumCrssToList)) { @@ -207,10 +209,10 @@ void Ind_ReqIndicatorsCourses (void) /* Button to show more details */ Frm_StartForm (ActSeeAllStaCrs); Sco_PutParamScope ("ScopeInd",Gbl.Scope.Current); - Par_PutHiddenParamLong (NULL,"OthDegTypCod",Gbl.Stat.DegTypCod); - Par_PutHiddenParamLong (NULL,Dpt_PARAM_DPT_COD_NAME,Gbl.Stat.DptCod); - if (Gbl.Stat.StrIndicatorsSelected[0]) - Par_PutHiddenParamString (NULL,"Indicators",Gbl.Stat.StrIndicatorsSelected); + Par_PutHiddenParamLong (NULL,"OthDegTypCod",Indicators.DegTypCod); + Par_PutHiddenParamLong (NULL,Dpt_PARAM_DPT_COD_NAME,Indicators.DptCod); + if (Indicators.StrIndicatorsSelected[0]) + Par_PutHiddenParamString (NULL,"Indicators",Indicators.StrIndicatorsSelected); Btn_PutConfirmButton (Txt_Show_more_details); Frm_EndForm (); } @@ -239,12 +241,12 @@ static void Ind_GetParamsIndicators (void) Sco_GetScope ("ScopeInd"); /***** Get degree type code *****/ - Gbl.Stat.DegTypCod = (Gbl.Scope.Current == Hie_SYS) ? + Indicators.DegTypCod = (Gbl.Scope.Current == Hie_SYS) ? DT_GetAndCheckParamOtherDegTypCod (-1L) : // -1L (any degree type) is allowed here -1L; /***** Get department code *****/ - Gbl.Stat.DptCod = Dpt_GetAndCheckParamDptCod (-1L); // -1L (any department) is allowed here + Indicators.DptCod = Dpt_GetAndCheckParamDptCod (-1L); // -1L (any department) is allowed here /***** Get number of indicators *****/ Ind_GetParamNumIndicators (); @@ -291,19 +293,19 @@ static void Ind_GetParamNumIndicators (void) long Indicator; /***** Get parameter multiple with list of indicators selected *****/ - Par_GetParMultiToText ("Indicators",Gbl.Stat.StrIndicatorsSelected,Ind_MAX_SIZE_INDICATORS_SELECTED); + Par_GetParMultiToText ("Indicators",Indicators.StrIndicatorsSelected,Ind_MAX_SIZE_INDICATORS_SELECTED); /***** Set which indicators have been selected (checkboxes on) *****/ - if (Gbl.Stat.StrIndicatorsSelected[0]) + if (Indicators.StrIndicatorsSelected[0]) { /* Reset all indicators */ for (Ind = 0; Ind <= Ind_NUM_INDICATORS; Ind++) - Gbl.Stat.IndicatorsSelected[Ind] = false; + Indicators.IndicatorsSelected[Ind] = false; /* Set indicators selected */ - for (Ptr = Gbl.Stat.StrIndicatorsSelected; + for (Ptr = Indicators.StrIndicatorsSelected; *Ptr; ) { @@ -316,7 +318,7 @@ static void Ind_GetParamNumIndicators (void) Ind <= Ind_NUM_INDICATORS; Ind++) if ((long) Ind == Indicator) - Gbl.Stat.IndicatorsSelected[Ind] = true; + Indicators.IndicatorsSelected[Ind] = true; } } else @@ -324,7 +326,7 @@ static void Ind_GetParamNumIndicators (void) for (Ind = 0; Ind <= Ind_NUM_INDICATORS; Ind++) - Gbl.Stat.IndicatorsSelected[Ind] = true; + Indicators.IndicatorsSelected[Ind] = true; } /*****************************************************************************/ @@ -339,9 +341,9 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) switch (Gbl.Scope.Current) { case Hie_SYS: - if (Gbl.Stat.DptCod >= 0) // 0 means another department + if (Indicators.DptCod >= 0) // 0 means another department { - if (Gbl.Stat.DegTypCod > 0) + if (Indicators.DegTypCod > 0) NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", "SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod" @@ -353,9 +355,9 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) " AND crs_usr.UsrCod=usr_data.UsrCod" " AND usr_data.DptCod=%ld" " ORDER BY degrees.FullName,courses.FullName", - Gbl.Stat.DegTypCod, + Indicators.DegTypCod, (unsigned) Rol_TCH, - Gbl.Stat.DptCod); + Indicators.DptCod); else NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -368,11 +370,11 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) " AND usr_data.DptCod=%ld" " ORDER BY degrees.FullName,courses.FullName", (unsigned) Rol_TCH, - Gbl.Stat.DptCod); + Indicators.DptCod); } else { - if (Gbl.Stat.DegTypCod > 0) + if (Indicators.DegTypCod > 0) NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", "SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod" @@ -380,7 +382,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) " WHERE degrees.DegTypCod=%ld" " AND degrees.DegCod=courses.DegCod" " ORDER BY degrees.FullName,courses.FullName", - Gbl.Stat.DegTypCod); + Indicators.DegTypCod); else NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -391,7 +393,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) } break; case Hie_CTY: - if (Gbl.Stat.DptCod >= 0) // 0 means another department + if (Indicators.DptCod >= 0) // 0 means another department NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", "SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod" @@ -407,7 +409,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) " ORDER BY degrees.FullName,courses.FullName", Gbl.Hierarchy.Cty.CtyCod, (unsigned) Rol_TCH, - Gbl.Stat.DptCod); + Indicators.DptCod); else NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -421,7 +423,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) Gbl.Hierarchy.Cty.CtyCod); break; case Hie_INS: - if (Gbl.Stat.DptCod >= 0) // 0 means another department + if (Indicators.DptCod >= 0) // 0 means another department NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", "SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod" @@ -436,7 +438,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) " ORDER BY degrees.FullName,courses.FullName", Gbl.Hierarchy.Ins.InsCod, (unsigned) Rol_TCH, - Gbl.Stat.DptCod); + Indicators.DptCod); else NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -449,7 +451,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) Gbl.Hierarchy.Ins.InsCod); break; case Hie_CTR: - if (Gbl.Stat.DptCod >= 0) // 0 means another department + if (Indicators.DptCod >= 0) // 0 means another department NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", "SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod" @@ -463,7 +465,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) " ORDER BY degrees.FullName,courses.FullName", Gbl.Hierarchy.Ctr.CtrCod, (unsigned) Rol_TCH, - Gbl.Stat.DptCod); + Indicators.DptCod); else NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -475,7 +477,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) Gbl.Hierarchy.Ctr.CtrCod); break; case Hie_DEG: - if (Gbl.Stat.DptCod >= 0) // 0 means another department + if (Indicators.DptCod >= 0) // 0 means another department NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", "SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod" @@ -489,7 +491,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) " ORDER BY degrees.FullName,courses.FullName", Gbl.Hierarchy.Deg.DegCod, (unsigned) Rol_TCH, - Gbl.Stat.DptCod); + Indicators.DptCod); else NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -501,7 +503,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) Gbl.Hierarchy.Deg.DegCod); break; case Hie_CRS: - if (Gbl.Stat.DptCod >= 0) // 0 means another department + if (Indicators.DptCod >= 0) // 0 means another department NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", "SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod" @@ -517,7 +519,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) Gbl.Hierarchy.Crs.CrsCod, Gbl.Hierarchy.Crs.CrsCod, (unsigned) Rol_TCH, - Gbl.Stat.DptCod); + Indicators.DptCod); else NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -566,21 +568,21 @@ static void Ind_PutButtonToConfirmIWantToSeeBigList (unsigned NumCrss) /***** Show alert and button to confirm that I want to see the big list *****/ Ale_ShowAlertAndButton (Gbl.Action.Act,NULL,NULL, - Ind_PutParamsConfirmIWantToSeeBigList,&Gbl.Stat, + Ind_PutParamsConfirmIWantToSeeBigList,&Indicators, Btn_CONFIRM_BUTTON,Txt_Show_anyway, Ale_WARNING,Txt_The_list_of_X_courses_is_too_large_to_be_displayed, NumCrss); } -static void Ind_PutParamsConfirmIWantToSeeBigList (void *Stats) +static void Ind_PutParamsConfirmIWantToSeeBigList (void *Indicators) { - if (Stats) + if (Indicators) { Sco_PutParamScope ("ScopeInd",Gbl.Scope.Current); - Par_PutHiddenParamLong (NULL,"OthDegTypCod",((struct Sta_Stats *) Stats)->DegTypCod); - Par_PutHiddenParamLong (NULL,Dpt_PARAM_DPT_COD_NAME,((struct Sta_Stats *) Stats)->DptCod); - if (((struct Sta_Stats *) Stats)->StrIndicatorsSelected[0]) - Par_PutHiddenParamString (NULL,"Indicators",((struct Sta_Stats *) Stats)->StrIndicatorsSelected); + Par_PutHiddenParamLong (NULL,"OthDegTypCod",((struct Ind_Indicators *) Indicators)->DegTypCod); + Par_PutHiddenParamLong (NULL,Dpt_PARAM_DPT_COD_NAME,((struct Ind_Indicators *) Indicators)->DptCod); + if (((struct Ind_Indicators *) Indicators)->StrIndicatorsSelected[0]) + Par_PutHiddenParamString (NULL,"Indicators",((struct Ind_Indicators *) Indicators)->StrIndicatorsSelected); Par_PutHiddenParamChar ("ShowBigList",'Y'); } } @@ -653,7 +655,7 @@ static void Ind_ShowNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 Ind <= Ind_NUM_INDICATORS; Ind++) { - Class = Gbl.Stat.IndicatorsSelected[Ind] ? ClassHighlight : + Class = Indicators.IndicatorsSelected[Ind] ? ClassHighlight : ClassNormal; HTM_TR_Begin (NULL); @@ -663,7 +665,7 @@ static void Ind_ShowNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 HTM_INPUT_CHECKBOX ("Indicators",HTM_SUBMIT_ON_CHANGE, "id=\"Indicators%u\" value=\"%u\"%s", Ind,Ind, - Gbl.Stat.IndicatorsSelected[Ind] ? " checked=\"checked\"" : ""); + Indicators.IndicatorsSelected[Ind] ? " checked=\"checked\"" : ""); HTM_TD_End (); } @@ -748,7 +750,7 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat unsigned NumTchs; unsigned NumStds; unsigned NumIndicators; - struct Ind_IndicatorsCrs Indicators; + struct Ind_IndicatorsCrs IndicatorsCrs; long ActCod; /***** Begin table *****/ @@ -883,13 +885,13 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat /* Get stored number of indicators of this course */ NumIndicators = Ind_GetAndUpdateNumIndicatorsCrs (CrsCod); - if (Gbl.Stat.IndicatorsSelected[NumIndicators]) + if (Indicators.IndicatorsSelected[NumIndicators]) { /* Compute and store indicators */ - Ind_ComputeAndStoreIndicatorsCrs (CrsCod,(int) NumIndicators,&Indicators); + Ind_ComputeAndStoreIndicatorsCrs (CrsCod,(int) NumIndicators,&IndicatorsCrs); /* The number of indicators may have changed */ - if (Gbl.Stat.IndicatorsSelected[Indicators.NumIndicators]) + if (Indicators.IndicatorsSelected[IndicatorsCrs.NumIndicators]) { ActCod = Act_GetActCod (ActReqStaCrs); @@ -900,25 +902,25 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat HTM_TR_Begin (NULL); HTM_TD_Begin ("class=\"%s LM COLOR%u\"", - Indicators.CourseAllOK ? "DAT_SMALL_GREEN" : - (Indicators.CoursePartiallyOK ? "DAT_SMALL" : - "DAT_SMALL_RED"), + IndicatorsCrs.CourseAllOK ? "DAT_SMALL_GREEN" : + (IndicatorsCrs.CoursePartiallyOK ? "DAT_SMALL" : + "DAT_SMALL_RED"), Gbl.RowEvenOdd); HTM_Txt (row[0]); HTM_TD_End (); HTM_TD_Begin ("class=\"%s LM COLOR%u\"", - Indicators.CourseAllOK ? "DAT_SMALL_GREEN" : - (Indicators.CoursePartiallyOK ? "DAT_SMALL" : - "DAT_SMALL_RED"), + IndicatorsCrs.CourseAllOK ? "DAT_SMALL_GREEN" : + (IndicatorsCrs.CoursePartiallyOK ? "DAT_SMALL" : + "DAT_SMALL_RED"), Gbl.RowEvenOdd); HTM_Txt (row[1]); HTM_TD_End (); HTM_TD_Begin ("class=\"%s LM COLOR%u\"", - Indicators.CourseAllOK ? "DAT_SMALL_GREEN" : - (Indicators.CoursePartiallyOK ? "DAT_SMALL" : - "DAT_SMALL_RED"), + IndicatorsCrs.CourseAllOK ? "DAT_SMALL_GREEN" : + (IndicatorsCrs.CoursePartiallyOK ? "DAT_SMALL" : + "DAT_SMALL_RED"), Gbl.RowEvenOdd); HTM_Txt (row[3]); HTM_TD_End (); @@ -932,70 +934,70 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat HTM_TD_End (); HTM_TD_Begin ("class=\"%s RM COLOR%u\"", - Indicators.CourseAllOK ? "DAT_SMALL_GREEN" : - (Indicators.CoursePartiallyOK ? "DAT_SMALL" : - "DAT_SMALL_RED"), + IndicatorsCrs.CourseAllOK ? "DAT_SMALL_GREEN" : + (IndicatorsCrs.CoursePartiallyOK ? "DAT_SMALL" : + "DAT_SMALL_RED"), Gbl.RowEvenOdd); - HTM_Unsigned (Indicators.NumIndicators); + HTM_Unsigned (IndicatorsCrs.NumIndicators); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_GREEN CM COLOR%u\"", Gbl.RowEvenOdd); - if (Indicators.ThereIsSyllabus) + if (IndicatorsCrs.ThereIsSyllabus) HTM_Txt (Txt_YES); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_RED CM COLOR%u\"", Gbl.RowEvenOdd); - if (!Indicators.ThereIsSyllabus) + if (!IndicatorsCrs.ThereIsSyllabus) HTM_Txt (Txt_NO); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_GREEN CM COLOR%u\"", Gbl.RowEvenOdd); - if (Indicators.ThereAreAssignments) + if (IndicatorsCrs.ThereAreAssignments) HTM_Txt (Txt_YES); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_RED CM COLOR%u\"", Gbl.RowEvenOdd); - if (!Indicators.ThereAreAssignments) + if (!IndicatorsCrs.ThereAreAssignments) HTM_Txt (Txt_NO); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_GREEN CM COLOR%u\"", Gbl.RowEvenOdd); - if (Indicators.ThereIsOnlineTutoring) + if (IndicatorsCrs.ThereIsOnlineTutoring) HTM_Txt (Txt_YES); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_RED CM COLOR%u\"", Gbl.RowEvenOdd); - if (!Indicators.ThereIsOnlineTutoring) + if (!IndicatorsCrs.ThereIsOnlineTutoring) HTM_Txt (Txt_NO); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_GREEN CM COLOR%u\"", Gbl.RowEvenOdd); - if (Indicators.ThereAreMaterials) + if (IndicatorsCrs.ThereAreMaterials) HTM_Txt (Txt_YES); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_RED CM COLOR%u\"", Gbl.RowEvenOdd); - if (!Indicators.ThereAreMaterials) + if (!IndicatorsCrs.ThereAreMaterials) HTM_Txt (Txt_NO); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_GREEN CM COLOR%u\"", Gbl.RowEvenOdd); - if (Indicators.ThereIsAssessment) + if (IndicatorsCrs.ThereIsAssessment) HTM_Txt (Txt_YES); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_RED CM COLOR%u\"", Gbl.RowEvenOdd); - if (!Indicators.ThereIsAssessment) + if (!IndicatorsCrs.ThereIsAssessment) HTM_Txt (Txt_NO); HTM_TD_End (); @@ -1012,25 +1014,25 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat HTM_TR_Begin (NULL); HTM_TD_Begin ("class=\"%s LM COLOR%u\"", - Indicators.CourseAllOK ? "DAT_SMALL_GREEN" : - (Indicators.CoursePartiallyOK ? "DAT_SMALL" : - "DAT_SMALL_RED"), + IndicatorsCrs.CourseAllOK ? "DAT_SMALL_GREEN" : + (IndicatorsCrs.CoursePartiallyOK ? "DAT_SMALL" : + "DAT_SMALL_RED"), Gbl.RowEvenOdd); HTM_Txt (row[0]); HTM_TD_End (); HTM_TD_Begin ("class=\"%s LM COLOR%u\"", - Indicators.CourseAllOK ? "DAT_SMALL_GREEN" : - (Indicators.CoursePartiallyOK ? "DAT_SMALL" : - "DAT_SMALL_RED"), + IndicatorsCrs.CourseAllOK ? "DAT_SMALL_GREEN" : + (IndicatorsCrs.CoursePartiallyOK ? "DAT_SMALL" : + "DAT_SMALL_RED"), Gbl.RowEvenOdd); HTM_Txt (row[1]); HTM_TD_End (); HTM_TD_Begin ("class=\"%s LM COLOR%u\"", - Indicators.CourseAllOK ? "DAT_SMALL_GREEN" : - (Indicators.CoursePartiallyOK ? "DAT_SMALL" : - "DAT_SMALL_RED"), + IndicatorsCrs.CourseAllOK ? "DAT_SMALL_GREEN" : + (IndicatorsCrs.CoursePartiallyOK ? "DAT_SMALL" : + "DAT_SMALL_RED"), Gbl.RowEvenOdd); HTM_Txt (row[3]); HTM_TD_End (); @@ -1058,162 +1060,162 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat HTM_TD_End (); HTM_TD_Begin ("class=\"%s RM COLOR%u\"", - Indicators.CourseAllOK ? "DAT_SMALL_GREEN" : - (Indicators.CoursePartiallyOK ? "DAT_SMALL" : - "DAT_SMALL_RED"), + IndicatorsCrs.CourseAllOK ? "DAT_SMALL_GREEN" : + (IndicatorsCrs.CoursePartiallyOK ? "DAT_SMALL" : + "DAT_SMALL_RED"), Gbl.RowEvenOdd); - HTM_Unsigned (Indicators.NumIndicators); + HTM_Unsigned (IndicatorsCrs.NumIndicators); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_GREEN CM COLOR%u\"", Gbl.RowEvenOdd); - if (Indicators.ThereIsSyllabus) + if (IndicatorsCrs.ThereIsSyllabus) HTM_Txt (Txt_YES); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_RED CM COLOR%u\"", Gbl.RowEvenOdd); - if (!Indicators.ThereIsSyllabus) + if (!IndicatorsCrs.ThereIsSyllabus) HTM_Txt (Txt_NO); HTM_TD_End (); HTM_TD_Begin ("class=\"%s LM COLOR%u\"", - (Indicators.SyllabusLecSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED", + (IndicatorsCrs.SyllabusLecSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED", Gbl.RowEvenOdd); - HTM_Txt (Txt_INFO_SRC_SHORT_TEXT[Indicators.SyllabusLecSrc]); + HTM_Txt (Txt_INFO_SRC_SHORT_TEXT[IndicatorsCrs.SyllabusLecSrc]); HTM_TD_End (); HTM_TD_Begin ("class=\"%s LM COLOR%u\"", - (Indicators.SyllabusPraSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED", + (IndicatorsCrs.SyllabusPraSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED", Gbl.RowEvenOdd); - HTM_Txt (Txt_INFO_SRC_SHORT_TEXT[Indicators.SyllabusPraSrc]); + HTM_Txt (Txt_INFO_SRC_SHORT_TEXT[IndicatorsCrs.SyllabusPraSrc]); HTM_TD_End (); HTM_TD_Begin ("class=\"%s LM COLOR%u\">", - (Indicators.TeachingGuideSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED", + (IndicatorsCrs.TeachingGuideSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED", Gbl.RowEvenOdd); - HTM_Txt (Txt_INFO_SRC_SHORT_TEXT[Indicators.TeachingGuideSrc]); + HTM_Txt (Txt_INFO_SRC_SHORT_TEXT[IndicatorsCrs.TeachingGuideSrc]); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_GREEN CM COLOR%u\"", Gbl.RowEvenOdd); - if (Indicators.ThereAreAssignments) + if (IndicatorsCrs.ThereAreAssignments) HTM_Txt (Txt_YES); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_RED CM COLOR%u\"", Gbl.RowEvenOdd); - if (!Indicators.ThereAreAssignments) + if (!IndicatorsCrs.ThereAreAssignments) HTM_Txt (Txt_NO); HTM_TD_End (); HTM_TD_Begin ("class=\"%s RM COLOR%u\"", - (Indicators.NumAssignments != 0) ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED", - Gbl.RowEvenOdd); - HTM_Unsigned (Indicators.NumAssignments); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"%s RM COLOR%u\"", - (Indicators.NumFilesAssignments != 0) ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED", - Gbl.RowEvenOdd); - HTM_UnsignedLong (Indicators.NumFilesAssignments); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"%s RM COLOR%u\"", - (Indicators.NumFilesWorks != 0) ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED", - Gbl.RowEvenOdd); - HTM_UnsignedLong (Indicators.NumFilesWorks); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_SMALL_GREEN CM COLOR%u\"", - Gbl.RowEvenOdd); - if (Indicators.ThereIsOnlineTutoring) - HTM_Txt (Txt_YES); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_SMALL_RED CM COLOR%u\"", - Gbl.RowEvenOdd); - if (!Indicators.ThereIsOnlineTutoring) - HTM_Txt (Txt_NO); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"%s RM COLOR%u\"", - (Indicators.NumThreads != 0) ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED", - Gbl.RowEvenOdd); - HTM_Unsigned (Indicators.NumThreads); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"%s RM COLOR%u\"", - (Indicators.NumPosts != 0) ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED", - Gbl.RowEvenOdd); - HTM_Unsigned (Indicators.NumPosts); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"%s RM COLOR%u\"", - (Indicators.NumMsgsSentByTchs != 0) ? "DAT_SMALL_GREEN" : + (IndicatorsCrs.NumAssignments != 0) ? "DAT_SMALL_GREEN" : "DAT_SMALL_RED", Gbl.RowEvenOdd); - HTM_Unsigned (Indicators.NumMsgsSentByTchs); + HTM_Unsigned (IndicatorsCrs.NumAssignments); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"%s RM COLOR%u\"", + (IndicatorsCrs.NumFilesAssignments != 0) ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED", + Gbl.RowEvenOdd); + HTM_UnsignedLong (IndicatorsCrs.NumFilesAssignments); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"%s RM COLOR%u\"", + (IndicatorsCrs.NumFilesWorks != 0) ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED", + Gbl.RowEvenOdd); + HTM_UnsignedLong (IndicatorsCrs.NumFilesWorks); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_GREEN CM COLOR%u\"", Gbl.RowEvenOdd); - if (Indicators.ThereAreMaterials) + if (IndicatorsCrs.ThereIsOnlineTutoring) HTM_Txt (Txt_YES); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_RED CM COLOR%u\"", Gbl.RowEvenOdd); - if (!Indicators.ThereAreMaterials) + if (!IndicatorsCrs.ThereIsOnlineTutoring) HTM_Txt (Txt_NO); HTM_TD_End (); HTM_TD_Begin ("class=\"%s RM COLOR%u\"", - (Indicators.NumFilesInDocumentZones != 0) ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED", + (IndicatorsCrs.NumThreads != 0) ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED", Gbl.RowEvenOdd); - HTM_UnsignedLong (Indicators.NumFilesInDocumentZones); + HTM_Unsigned (IndicatorsCrs.NumThreads); HTM_TD_End (); HTM_TD_Begin ("class=\"%s RM COLOR%u\"", - (Indicators.NumFilesInSharedZones != 0) ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED", + (IndicatorsCrs.NumPosts != 0) ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED", Gbl.RowEvenOdd); - HTM_UnsignedLong (Indicators.NumFilesInSharedZones); + HTM_Unsigned (IndicatorsCrs.NumPosts); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"%s RM COLOR%u\"", + (IndicatorsCrs.NumMsgsSentByTchs != 0) ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED", + Gbl.RowEvenOdd); + HTM_Unsigned (IndicatorsCrs.NumMsgsSentByTchs); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_GREEN CM COLOR%u\"", Gbl.RowEvenOdd); - if (Indicators.ThereIsAssessment) + if (IndicatorsCrs.ThereAreMaterials) HTM_Txt (Txt_YES); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT_SMALL_RED CM COLOR%u\"", Gbl.RowEvenOdd); - if (!Indicators.ThereIsAssessment) + if (!IndicatorsCrs.ThereAreMaterials) + HTM_Txt (Txt_NO); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"%s RM COLOR%u\"", + (IndicatorsCrs.NumFilesInDocumentZones != 0) ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED", + Gbl.RowEvenOdd); + HTM_UnsignedLong (IndicatorsCrs.NumFilesInDocumentZones); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"%s RM COLOR%u\"", + (IndicatorsCrs.NumFilesInSharedZones != 0) ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED", + Gbl.RowEvenOdd); + HTM_UnsignedLong (IndicatorsCrs.NumFilesInSharedZones); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT_SMALL_GREEN CM COLOR%u\"", + Gbl.RowEvenOdd); + if (IndicatorsCrs.ThereIsAssessment) + HTM_Txt (Txt_YES); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT_SMALL_RED CM COLOR%u\"", + Gbl.RowEvenOdd); + if (!IndicatorsCrs.ThereIsAssessment) HTM_Txt (Txt_NO); HTM_TD_End (); HTM_TD_Begin ("class=\"%s LM COLOR%u\"", - (Indicators.AssessmentSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED", - Gbl.RowEvenOdd); - HTM_Txt (Txt_INFO_SRC_SHORT_TEXT[Indicators.AssessmentSrc]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"%s LM COLOR%u\"", - (Indicators.TeachingGuideSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" : + (IndicatorsCrs.AssessmentSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" : "DAT_SMALL_RED", Gbl.RowEvenOdd); - HTM_Txt (Txt_INFO_SRC_SHORT_TEXT[Indicators.TeachingGuideSrc]); + HTM_Txt (Txt_INFO_SRC_SHORT_TEXT[IndicatorsCrs.AssessmentSrc]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"%s LM COLOR%u\"", + (IndicatorsCrs.TeachingGuideSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED", + Gbl.RowEvenOdd); + HTM_Txt (Txt_INFO_SRC_SHORT_TEXT[IndicatorsCrs.TeachingGuideSrc]); HTM_TD_End (); HTM_TR_End (); @@ -1235,7 +1237,7 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat static unsigned Ind_GetAndUpdateNumIndicatorsCrs (long CrsCod) { unsigned NumIndicators; - struct Ind_IndicatorsCrs Indicators; + struct Ind_IndicatorsCrs IndicatorsCrs; int NumIndicatorsFromDB = Ind_GetNumIndicatorsCrsFromDB (CrsCod); /***** If number of indicators is not already computed ==> compute it! *****/ @@ -1244,8 +1246,8 @@ static unsigned Ind_GetAndUpdateNumIndicatorsCrs (long CrsCod) else // Number of indicators is not already computed { /***** Compute and store number of indicators *****/ - Ind_ComputeAndStoreIndicatorsCrs (CrsCod,NumIndicatorsFromDB,&Indicators); - NumIndicators = Indicators.NumIndicators; + Ind_ComputeAndStoreIndicatorsCrs (CrsCod,NumIndicatorsFromDB,&IndicatorsCrs); + NumIndicators = IndicatorsCrs.NumIndicators; } return NumIndicators; } @@ -1302,67 +1304,67 @@ static void Ind_StoreIndicatorsCrsIntoDB (long CrsCod,unsigned NumIndicators) ==> update it into database */ void Ind_ComputeAndStoreIndicatorsCrs (long CrsCod,int NumIndicatorsFromDB, - struct Ind_IndicatorsCrs *Indicators) + struct Ind_IndicatorsCrs *IndicatorsCrs) { /***** Initialize number of indicators *****/ - Indicators->NumIndicators = 0; + IndicatorsCrs->NumIndicators = 0; /***** Get whether download zones are empty or not *****/ - Indicators->NumFilesInDocumentZones = Ind_GetNumFilesInDocumZonesOfCrsFromDB (CrsCod); - Indicators->NumFilesInSharedZones = Ind_GetNumFilesInShareZonesOfCrsFromDB (CrsCod); + IndicatorsCrs->NumFilesInDocumentZones = Ind_GetNumFilesInDocumZonesOfCrsFromDB (CrsCod); + IndicatorsCrs->NumFilesInSharedZones = Ind_GetNumFilesInShareZonesOfCrsFromDB (CrsCod); /***** Indicator #1: information about syllabus *****/ - Indicators->SyllabusLecSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_LECTURES); - Indicators->SyllabusPraSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_PRACTICALS); - Indicators->TeachingGuideSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_TEACHING_GUIDE); - Indicators->ThereIsSyllabus = (Indicators->SyllabusLecSrc != Inf_INFO_SRC_NONE) || - (Indicators->SyllabusPraSrc != Inf_INFO_SRC_NONE) || - (Indicators->TeachingGuideSrc != Inf_INFO_SRC_NONE); - if (Indicators->ThereIsSyllabus) - Indicators->NumIndicators++; + IndicatorsCrs->SyllabusLecSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_LECTURES); + IndicatorsCrs->SyllabusPraSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_PRACTICALS); + IndicatorsCrs->TeachingGuideSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_TEACHING_GUIDE); + IndicatorsCrs->ThereIsSyllabus = (IndicatorsCrs->SyllabusLecSrc != Inf_INFO_SRC_NONE) || + (IndicatorsCrs->SyllabusPraSrc != Inf_INFO_SRC_NONE) || + (IndicatorsCrs->TeachingGuideSrc != Inf_INFO_SRC_NONE); + if (IndicatorsCrs->ThereIsSyllabus) + IndicatorsCrs->NumIndicators++; /***** Indicator #2: information about assignments *****/ - Indicators->NumAssignments = Asg_GetNumAssignmentsInCrs (CrsCod); - Indicators->NumFilesAssignments = Ind_GetNumFilesInAssigZonesOfCrsFromDB (CrsCod); - Indicators->NumFilesWorks = Ind_GetNumFilesInWorksZonesOfCrsFromDB (CrsCod); - Indicators->ThereAreAssignments = (Indicators->NumAssignments != 0) || - (Indicators->NumFilesAssignments != 0) || - (Indicators->NumFilesWorks != 0); - if (Indicators->ThereAreAssignments) - Indicators->NumIndicators++; + IndicatorsCrs->NumAssignments = Asg_GetNumAssignmentsInCrs (CrsCod); + IndicatorsCrs->NumFilesAssignments = Ind_GetNumFilesInAssigZonesOfCrsFromDB (CrsCod); + IndicatorsCrs->NumFilesWorks = Ind_GetNumFilesInWorksZonesOfCrsFromDB (CrsCod); + IndicatorsCrs->ThereAreAssignments = (IndicatorsCrs->NumAssignments != 0) || + (IndicatorsCrs->NumFilesAssignments != 0) || + (IndicatorsCrs->NumFilesWorks != 0); + if (IndicatorsCrs->ThereAreAssignments) + IndicatorsCrs->NumIndicators++; /***** Indicator #3: information about online tutoring *****/ - Indicators->NumThreads = For_GetNumTotalThrsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod); - Indicators->NumPosts = For_GetNumTotalPstsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod,&(Indicators->NumUsrsToBeNotifiedByEMail)); - Indicators->NumMsgsSentByTchs = Msg_GetNumMsgsSentByTchsCrs (CrsCod); - Indicators->ThereIsOnlineTutoring = (Indicators->NumThreads != 0) || - (Indicators->NumPosts != 0) || - (Indicators->NumMsgsSentByTchs != 0); - if (Indicators->ThereIsOnlineTutoring) - Indicators->NumIndicators++; + IndicatorsCrs->NumThreads = For_GetNumTotalThrsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod); + IndicatorsCrs->NumPosts = For_GetNumTotalPstsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod,&(IndicatorsCrs->NumUsrsToBeNotifiedByEMail)); + IndicatorsCrs->NumMsgsSentByTchs = Msg_GetNumMsgsSentByTchsCrs (CrsCod); + IndicatorsCrs->ThereIsOnlineTutoring = (IndicatorsCrs->NumThreads != 0) || + (IndicatorsCrs->NumPosts != 0) || + (IndicatorsCrs->NumMsgsSentByTchs != 0); + if (IndicatorsCrs->ThereIsOnlineTutoring) + IndicatorsCrs->NumIndicators++; /***** Indicator #4: information about materials *****/ - Indicators->ThereAreMaterials = (Indicators->NumFilesInDocumentZones != 0) || - (Indicators->NumFilesInSharedZones != 0); - if (Indicators->ThereAreMaterials) - Indicators->NumIndicators++; + IndicatorsCrs->ThereAreMaterials = (IndicatorsCrs->NumFilesInDocumentZones != 0) || + (IndicatorsCrs->NumFilesInSharedZones != 0); + if (IndicatorsCrs->ThereAreMaterials) + IndicatorsCrs->NumIndicators++; /***** Indicator #5: information about assessment *****/ - Indicators->AssessmentSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_ASSESSMENT); - Indicators->ThereIsAssessment = (Indicators->AssessmentSrc != Inf_INFO_SRC_NONE) || - (Indicators->TeachingGuideSrc != Inf_INFO_SRC_NONE); - if (Indicators->ThereIsAssessment) - Indicators->NumIndicators++; + IndicatorsCrs->AssessmentSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_ASSESSMENT); + IndicatorsCrs->ThereIsAssessment = (IndicatorsCrs->AssessmentSrc != Inf_INFO_SRC_NONE) || + (IndicatorsCrs->TeachingGuideSrc != Inf_INFO_SRC_NONE); + if (IndicatorsCrs->ThereIsAssessment) + IndicatorsCrs->NumIndicators++; /***** All the indicators are OK? *****/ - Indicators->CoursePartiallyOK = Indicators->NumIndicators >= 1 && - Indicators->NumIndicators < Ind_NUM_INDICATORS; - Indicators->CourseAllOK = Indicators->NumIndicators == Ind_NUM_INDICATORS; + IndicatorsCrs->CoursePartiallyOK = IndicatorsCrs->NumIndicators >= 1 && + IndicatorsCrs->NumIndicators < Ind_NUM_INDICATORS; + IndicatorsCrs->CourseAllOK = IndicatorsCrs->NumIndicators == Ind_NUM_INDICATORS; /***** Update number of indicators into database if different to the stored one *****/ - if (NumIndicatorsFromDB != (int) Indicators->NumIndicators) - Ind_StoreIndicatorsCrsIntoDB (CrsCod,Indicators->NumIndicators); + if (NumIndicatorsFromDB != (int) IndicatorsCrs->NumIndicators) + Ind_StoreIndicatorsCrsIntoDB (CrsCod,IndicatorsCrs->NumIndicators); } /*****************************************************************************/ diff --git a/swad_indicator.h b/swad_indicator.h index c7835c21..659d90eb 100644 --- a/swad_indicator.h +++ b/swad_indicator.h @@ -59,6 +59,14 @@ struct Ind_IndicatorsCrs bool CourseAllOK; }; +struct Ind_Indicators + { + long DegTypCod; + long DptCod; + char StrIndicatorsSelected[Ind_MAX_SIZE_INDICATORS_SELECTED + 1]; + bool IndicatorsSelected[1 + Ind_NUM_INDICATORS]; + }; + /*****************************************************************************/ /***************************** Public prototypes *****************************/ /*****************************************************************************/ @@ -67,6 +75,6 @@ void Ind_ReqIndicatorsCourses (void); void Ind_ShowIndicatorsCourses (void); int Ind_GetNumIndicatorsCrsFromDB (long CrsCod); void Ind_ComputeAndStoreIndicatorsCrs (long CrsCod,int NumIndicatorsFromDB, - struct Ind_IndicatorsCrs *Indicators); + struct Ind_IndicatorsCrs *IndicatorsCrs); #endif diff --git a/swad_photo.c b/swad_photo.c index a9c838d0..33ff57e0 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -87,6 +87,8 @@ static const char *Pho_StrAvgPhotoPrograms[Pho_NUM_AVERAGE_PHOTO_TYPES] = /***************************** Private variables *****************************/ /*****************************************************************************/ +struct Pho_DegPhotos DegPhotos; + /*****************************************************************************/ /***************************** Private prototypes ****************************/ /*****************************************************************************/ @@ -1350,7 +1352,7 @@ void Pho_CalcPhotoDegree (void) long TotalTimeToComputeAvgPhotoInMicroseconds,PartialTimeToComputeAvgPhotoInMicroseconds; /***** Get type of average *****/ - Gbl.Stat.DegPhotos.TypeOfAverage = Pho_GetPhotoAvgTypeFromForm (); + DegPhotos.TypeOfAverage = Pho_GetPhotoAvgTypeFromForm (); /***** Create public directories for average photos if not exist *****/ Fil_CreateDirIfNotExists (Cfg_PATH_PHOTO_PUBLIC); @@ -1685,7 +1687,7 @@ static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,Rol_Role_t Role, void Pho_ShowPhotoDegree (void) { /***** Get type of average *****/ - Gbl.Stat.DegPhotos.TypeOfAverage = Pho_GetPhotoAvgTypeFromForm (); + DegPhotos.TypeOfAverage = Pho_GetPhotoAvgTypeFromForm (); Pho_ShowOrPrintPhotoDegree (Pho_DEGREES_SEE); } @@ -1697,7 +1699,7 @@ void Pho_ShowPhotoDegree (void) void Pho_PrintPhotoDegree (void) { /***** Get type of average *****/ - Gbl.Stat.DegPhotos.TypeOfAverage = Pho_GetPhotoAvgTypeFromForm (); + DegPhotos.TypeOfAverage = Pho_GetPhotoAvgTypeFromForm (); Pho_ShowOrPrintPhotoDegree (Pho_DEGREES_PRINT); } @@ -1712,10 +1714,10 @@ void Pho_ShowOrPrintPhotoDegree (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint) extern const char *Txt_Degrees; /***** Get photo size from form *****/ - Gbl.Stat.DegPhotos.HowComputePhotoSize = Pho_GetHowComputePhotoSizeFromForm (); + DegPhotos.HowComputePhotoSize = Pho_GetHowComputePhotoSizeFromForm (); /***** Get how to order degrees from form *****/ - Gbl.Stat.DegPhotos.HowOrderDegrees = Pho_GetHowOrderDegreesFromForm (); + DegPhotos.HowOrderDegrees = Pho_GetHowOrderDegreesFromForm (); /***** Get and update type of list, number of columns in class photo @@ -1819,7 +1821,7 @@ static void Pho_PutSelectorForTypeOfAvg (void) { TypeOfAvgUnsigned = (unsigned) TypeOfAvg; HTM_OPTION (HTM_Type_UNSIGNED,&TypeOfAvgUnsigned, - TypeOfAvg == Gbl.Stat.DegPhotos.TypeOfAverage,false, + TypeOfAvg == DegPhotos.TypeOfAverage,false, "%s",Txt_AVERAGE_PHOTO_TYPES[TypeOfAvg]); } HTM_SELECT_End (); @@ -1835,7 +1837,7 @@ static void Pho_PutSelectorForTypeOfAvg (void) void Pho_PutHiddenParamTypeOfAvg (void) { - Par_PutHiddenParamUnsigned (NULL,"AvgType",(unsigned) Gbl.Stat.DegPhotos.TypeOfAverage); + Par_PutHiddenParamUnsigned (NULL,"AvgType",(unsigned) DegPhotos.TypeOfAverage); } /*****************************************************************************/ @@ -1883,7 +1885,7 @@ static void Pho_PutSelectorForHowComputePhotoSize (void) { PhoSiUnsigned = (unsigned) PhoSi; HTM_OPTION (HTM_Type_UNSIGNED,&PhoSiUnsigned, - PhoSi == Gbl.Stat.DegPhotos.HowComputePhotoSize,false, + PhoSi == DegPhotos.HowComputePhotoSize,false, "%s",Txt_STAT_DEGREE_PHOTO_SIZE[PhoSi]); } HTM_SELECT_End (); @@ -1899,7 +1901,7 @@ static void Pho_PutSelectorForHowComputePhotoSize (void) void Pho_PutHiddenParamPhotoSize (void) { - Par_PutHiddenParamUnsigned (NULL,"PhotoSize",(unsigned) Gbl.Stat.DegPhotos.HowComputePhotoSize); + Par_PutHiddenParamUnsigned (NULL,"PhotoSize",(unsigned) DegPhotos.HowComputePhotoSize); } /*****************************************************************************/ @@ -1947,7 +1949,7 @@ static void Pho_PutSelectorForHowOrderDegrees (void) { OrderUnsigned = (unsigned) Order; HTM_OPTION (HTM_Type_UNSIGNED,&OrderUnsigned, - Order == Gbl.Stat.DegPhotos.HowOrderDegrees,false, + Order == DegPhotos.HowOrderDegrees,false, "%s",Txt_STAT_DEGREE_PHOTO_ORDER[Order]); } HTM_SELECT_End (); @@ -1963,7 +1965,7 @@ static void Pho_PutSelectorForHowOrderDegrees (void) void Pho_PutHiddenParamOrderDegrees (void) { - Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Gbl.Stat.DegPhotos.HowOrderDegrees); + Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) DegPhotos.HowOrderDegrees); } /*****************************************************************************/ @@ -2101,27 +2103,27 @@ static void Pho_GetMaxStdsPerDegree (void) row = mysql_fetch_row (mysql_res); if (row[0] == NULL) - Gbl.Stat.DegPhotos.MaxStds = -1; - else if (sscanf (row[0],"%d",&Gbl.Stat.DegPhotos.MaxStds) != 1) - Gbl.Stat.DegPhotos.MaxStds = -1; + DegPhotos.MaxStds = -1; + else if (sscanf (row[0],"%d",&DegPhotos.MaxStds) != 1) + DegPhotos.MaxStds = -1; if (row[1] == NULL) - Gbl.Stat.DegPhotos.MaxStdsWithPhoto = -1; - else if (sscanf (row[1],"%d",&Gbl.Stat.DegPhotos.MaxStdsWithPhoto) != 1) - Gbl.Stat.DegPhotos.MaxStdsWithPhoto = -1; + DegPhotos.MaxStdsWithPhoto = -1; + else if (sscanf (row[1],"%d",&DegPhotos.MaxStdsWithPhoto) != 1) + DegPhotos.MaxStdsWithPhoto = -1; if (row[2] == NULL) - Gbl.Stat.DegPhotos.MaxPercent = -1.0; - else if (sscanf (row[2],"%lf",&Gbl.Stat.DegPhotos.MaxPercent) != 1) - Gbl.Stat.DegPhotos.MaxPercent = -1.0; + DegPhotos.MaxPercent = -1.0; + else if (sscanf (row[2],"%lf",&DegPhotos.MaxPercent) != 1) + DegPhotos.MaxPercent = -1.0; /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); } else { - Gbl.Stat.DegPhotos.MaxStds = Gbl.Stat.DegPhotos.MaxStdsWithPhoto = -1; - Gbl.Stat.DegPhotos.MaxPercent = -1.0; + DegPhotos.MaxStds = DegPhotos.MaxStdsWithPhoto = -1; + DegPhotos.MaxPercent = -1.0; } } @@ -2314,7 +2316,7 @@ static unsigned long Pho_BuildQueryOfDegrees (MYSQL_RES **mysql_res) { unsigned long NumDegs = 0; // Initialized to avoid warning - switch (Gbl.Stat.DegPhotos.HowOrderDegrees) + switch (DegPhotos.HowOrderDegrees) { case Pho_NUMBER_OF_STUDENTS: NumDegs = DB_QuerySELECT (mysql_res,"can not get degrees", @@ -2485,14 +2487,14 @@ static void Pho_ShowDegreeAvgPhotoAndStat (struct Degree *Deg, snprintf (PathRelAvgPhoto,sizeof (PathRelAvgPhoto), "%s/%s/%ld_%s.jpg", Cfg_PATH_PHOTO_PUBLIC, - Pho_StrAvgPhotoDirs[Gbl.Stat.DegPhotos.TypeOfAverage], + Pho_StrAvgPhotoDirs[DegPhotos.TypeOfAverage], Deg->DegCod,Usr_StringsSexDB[Sex]); if (Fil_CheckIfPathExists (PathRelAvgPhoto)) { snprintf (PhotoURL,sizeof (PhotoURL), "%s/%s/%ld_%s.jpg", Cfg_URL_PHOTO_PUBLIC, - Pho_StrAvgPhotoDirs[Gbl.Stat.DegPhotos.TypeOfAverage], + Pho_StrAvgPhotoDirs[DegPhotos.TypeOfAverage], Deg->DegCod,Usr_StringsSexDB[Sex]); if (SeeOrPrint == Pho_DEGREES_SEE) { @@ -2572,26 +2574,26 @@ static void Pho_ComputePhotoSize (int NumStds,int NumStdsWithPhoto,unsigned *Pho { unsigned PhotoPixels = DEF_PIXELS_PHOTO; - switch (Gbl.Stat.DegPhotos.HowComputePhotoSize) + switch (DegPhotos.HowComputePhotoSize) { case Pho_PROPORTIONAL_TO_NUMBER_OF_STUDENTS: - if (Gbl.Stat.DegPhotos.MaxStds > 0) + if (DegPhotos.MaxStds > 0) PhotoPixels = (unsigned) (((double) (MAX_PIXELS_PHOTO - MIN_PIXELS_PHOTO) / - Gbl.Stat.DegPhotos.MaxStds) * NumStds + + DegPhotos.MaxStds) * NumStds + MIN_PIXELS_PHOTO + 0.5); break; case Pho_PROPORTIONAL_TO_NUMBER_OF_PHOTOS: - if (Gbl.Stat.DegPhotos.MaxStdsWithPhoto > 0) + if (DegPhotos.MaxStdsWithPhoto > 0) PhotoPixels = (unsigned) (((double) (MAX_PIXELS_PHOTO - MIN_PIXELS_PHOTO) / - Gbl.Stat.DegPhotos.MaxStdsWithPhoto) * NumStdsWithPhoto + + DegPhotos.MaxStdsWithPhoto) * NumStdsWithPhoto + MIN_PIXELS_PHOTO + 0.5); break; case Pho_PROPORTIONAL_TO_PERCENT: - if (Gbl.Stat.DegPhotos.MaxPercent > 0.0) + if (DegPhotos.MaxPercent > 0.0) { if (NumStds) PhotoPixels = (unsigned) (((double) (MAX_PIXELS_PHOTO - MIN_PIXELS_PHOTO) / - Gbl.Stat.DegPhotos.MaxPercent) * + DegPhotos.MaxPercent) * ((double) NumStdsWithPhoto / NumStds) + MIN_PIXELS_PHOTO + 0.5); else diff --git a/swad_photo.h b/swad_photo.h index 74fd8acd..b10f0fe8 100644 --- a/swad_photo.h +++ b/swad_photo.h @@ -79,6 +79,16 @@ typedef enum #define Pho_MAX_CLICKS_WITHOUT_PHOTO 50 +struct Pho_DegPhotos + { + Pho_AvgPhotoTypeOfAverage_t TypeOfAverage; + Pho_HowComputePhotoSize_t HowComputePhotoSize; + Pho_HowOrderDegrees_t HowOrderDegrees; + int MaxStds; + int MaxStdsWithPhoto; + double MaxPercent; + } DegPhotos; + /*****************************************************************************/ /***************************** Public prototypes *****************************/ /*****************************************************************************/ diff --git a/swad_statistic.c b/swad_statistic.c index 5e2fc9c1..e715dbda 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -100,25 +100,34 @@ typedef enum /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void Sta_WriteSelectorCountType (void); -static void Sta_WriteSelectorAction (void); +static void Sta_WriteSelectorCountType (const struct Sta_Stats *Stats); +static void Sta_WriteSelectorAction (const struct Sta_Stats *Stats); static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse); -static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql_res); +static void Sta_ShowDetailedAccessesList (const struct Sta_Stats *Stats, + unsigned long NumRows, + MYSQL_RES *mysql_res); static void Sta_WriteLogComments (long LogCod); -static void Sta_ShowNumHitsPerUsr (unsigned long NumRows,MYSQL_RES *mysql_res); -static void Sta_ShowNumHitsPerDay (unsigned long NumRows,MYSQL_RES *mysql_res); -static void Sta_ShowDistrAccessesPerDayAndHour (unsigned long NumRows,MYSQL_RES *mysql_res); +static void Sta_ShowNumHitsPerUsr (Sta_CountType_t CountType, + unsigned long NumRows,MYSQL_RES *mysql_res); +static void Sta_ShowNumHitsPerDay (Sta_CountType_t CountType, + unsigned long NumRows,MYSQL_RES *mysql_res); +static void Sta_ShowDistrAccessesPerDayAndHour (const struct Sta_Stats *Stats, + unsigned long NumRows, + MYSQL_RES *mysql_res); static void Sta_PutHiddenParamScopeSta (void); static Sta_ColorType_t Sta_GetStatColorType (void); static void Sta_DrawBarColors (Sta_ColorType_t ColorType,double HitsMax); static void Sta_DrawAccessesPerHourForADay (Sta_ColorType_t ColorType,double HitsNum[24],double HitsMax); static void Sta_SetColor (Sta_ColorType_t ColorType,double HitsNum,double HitsMax, unsigned *R,unsigned *G,unsigned *B); -static void Sta_ShowNumHitsPerWeek (unsigned long NumRows, +static void Sta_ShowNumHitsPerWeek (Sta_CountType_t CountType, + unsigned long NumRows, + MYSQL_RES *mysql_res); +static void Sta_ShowNumHitsPerMonth (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res); -static void Sta_ShowNumHitsPerMonth (unsigned long NumRows, - MYSQL_RES *mysql_res); -static void Sta_ShowNumHitsPerYear (unsigned long NumRows, +static void Sta_ShowNumHitsPerYear (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res); static void Sta_ShowNumHitsPerHour (unsigned long NumRows, MYSQL_RES *mysql_res); @@ -126,35 +135,58 @@ static void Sta_WriteAccessHour (unsigned Hour,struct Sta_Hits *Hits,unsigned Co static void Sta_ShowAverageAccessesPerMinute (unsigned long NumRows,MYSQL_RES *mysql_res); static void Sta_WriteLabelsXAxisAccMin (double IncX,const char *Format); static void Sta_WriteAccessMinute (unsigned Minute,double HitsNum,double MaxX); -static void Sta_ShowNumHitsPerAction (unsigned long NumRows, +static void Sta_ShowNumHitsPerAction (Sta_CountType_t CountTypes, + unsigned long NumRows, MYSQL_RES *mysql_res); -static void Sta_ShowNumHitsPerPlugin (unsigned long NumRows, +static void Sta_ShowNumHitsPerPlugin (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res); -static void Sta_ShowNumHitsPerWSFunction (unsigned long NumRows, +static void Sta_ShowNumHitsPerWSFunction (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res); -static void Sta_ShowNumHitsPerBanner (unsigned long NumRows, +static void Sta_ShowNumHitsPerBanner (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res); -static void Sta_ShowNumHitsPerCountry (unsigned long NumRows, +static void Sta_ShowNumHitsPerCountry (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res); static void Sta_WriteCountry (long CtyCod); -static void Sta_ShowNumHitsPerInstitution (unsigned long NumRows, +static void Sta_ShowNumHitsPerInstitution (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res); static void Sta_WriteInstit (long InsCod); -static void Sta_ShowNumHitsPerCentre (unsigned long NumRows, +static void Sta_ShowNumHitsPerCentre (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res); static void Sta_WriteCentre (long CtrCod); -static void Sta_ShowNumHitsPerDegree (unsigned long NumRows, +static void Sta_ShowNumHitsPerDegree (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res); static void Sta_WriteDegree (long DegCod); -static void Sta_ShowNumHitsPerCourse (unsigned long NumRows, +static void Sta_ShowNumHitsPerCourse (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res); static void Sta_DrawBarNumHits (char Color, double HitsNum,double HitsMax,double HitsTotal, unsigned MaxBarWidth); +/*****************************************************************************/ +/**************************** Reset stats context ****************************/ +/*****************************************************************************/ + +void Sta_ResetStats (struct Sta_Stats *Stats) + { + Stats->ClicksGroupedBy = Sta_CLICKS_GROUPED_BY_DEFAULT; + Stats->Role = Sta_ROLE_DEFAULT; + Stats->CountType = Sta_COUNT_TYPE_DEFAULT; + Stats->NumAction = Sta_NUM_ACTION_DEFAULT; + Stats->FirstRow = 0; + Stats->LastRow = 0; + Stats->RowsPerPage = Sta_DEF_ROWS_PER_PAGE; + } /*****************************************************************************/ -/*************** Read CGI environment variable REMOTE_ADDR *******************/ +/**************** Read CGI environment variable REMOTE_ADDR ******************/ /*****************************************************************************/ /* CGI Environment Variables: @@ -202,12 +234,16 @@ void Sta_AskShowCrsHits (void) Sta_MAX_ROWS_PER_PAGE, }; #define NUM_OPTIONS_ROWS_PER_PAGE (sizeof (RowsPerPage) / sizeof (RowsPerPage[0])) + struct Sta_Stats Stats; Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME]; unsigned NumTotalUsrs; Sta_ClicksGroupedBy_t ClicksGroupedBy; unsigned ClicksGroupedByUnsigned; size_t i; + /***** Reset stats context *****/ + Sta_ResetStats (&Stats); + /***** Contextual menu *****/ Mnu_ContextMenuBegin (); Sta_PutLinkToGlobalHits (); // Global hits @@ -296,7 +332,7 @@ void Sta_AskShowCrsHits (void) Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (SetHMS); /***** Selection of action *****/ - Sta_WriteSelectorAction (); + Sta_WriteSelectorAction (&Stats); /***** Option a) Listing of clicks distributed by some metric *****/ HTM_TR_Begin (NULL); @@ -307,18 +343,19 @@ void Sta_AskShowCrsHits (void) HTM_TD_Begin ("class=\"LM\""); - if ((Gbl.Stat.ClicksGroupedBy < Sta_CLICKS_CRS_PER_USR || - Gbl.Stat.ClicksGroupedBy > Sta_CLICKS_CRS_PER_ACTION) && - Gbl.Stat.ClicksGroupedBy != Sta_CLICKS_CRS_DETAILED_LIST) - Gbl.Stat.ClicksGroupedBy = Sta_CLICKS_GROUPED_BY_DEFAULT; + if ((Stats.ClicksGroupedBy < Sta_CLICKS_CRS_PER_USR || + Stats.ClicksGroupedBy > Sta_CLICKS_CRS_PER_ACTION) && + Stats.ClicksGroupedBy != Sta_CLICKS_CRS_DETAILED_LIST) + Stats.ClicksGroupedBy = Sta_CLICKS_GROUPED_BY_DEFAULT; HTM_INPUT_RADIO ("GroupedOrDetailed",false, "value=\"%u\"%s onclick=\"disableDetailedClicks();\"", (unsigned) Sta_CLICKS_GROUPED, - Gbl.Stat.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST ? "" : " checked=\"checked\""); + Stats.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST ? "" : + " checked=\"checked\""); /* Selection of count type (number of pages generated, accesses per user, etc.) */ - Sta_WriteSelectorCountType (); + Sta_WriteSelectorCountType (&Stats); HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); HTM_TxtF (" %s ",Txt_distributed_by); @@ -330,7 +367,7 @@ void Sta_AskShowCrsHits (void) { ClicksGroupedByUnsigned = (unsigned) ClicksGroupedBy; HTM_OPTION (HTM_Type_UNSIGNED,&ClicksGroupedByUnsigned, - ClicksGroupedBy == Gbl.Stat.ClicksGroupedBy,false, + ClicksGroupedBy == Stats.ClicksGroupedBy,false, "%s",Txt_STAT_CLICKS_GROUPED_BY[ClicksGroupedBy]); } HTM_SELECT_End (); @@ -344,7 +381,8 @@ void Sta_AskShowCrsHits (void) HTM_INPUT_RADIO ("GroupedOrDetailed",false, "value=\"%u\"%s onclick=\"enableDetailedClicks();\"", (unsigned) Sta_CLICKS_DETAILED, - Gbl.Stat.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST ? " checked=\"checked\"" : ""); + Stats.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST ? " checked=\"checked\"" : + ""); HTM_Txt (Txt_STAT_CLICKS_GROUPED_BY[Sta_CLICKS_CRS_DETAILED_LIST]); HTM_LABEL_End (); @@ -357,13 +395,13 @@ void Sta_AskShowCrsHits (void) HTM_TxtF ("(%s: ",Txt_results_per_page); HTM_SELECT_Begin (false, "id=\"RowsPage\" name=\"RowsPage\"%s", - Gbl.Stat.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST ? "" : - " disabled=\"disabled\""); + Stats.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST ? "" : + " disabled=\"disabled\""); for (i = 0; i < NUM_OPTIONS_ROWS_PER_PAGE; i++) HTM_OPTION (HTM_Type_UNSIGNED,&RowsPerPage[i], - RowsPerPage[i] == Gbl.Stat.RowsPerPage,false, + RowsPerPage[i] == Stats.RowsPerPage,false, "%u",RowsPerPage[i]); HTM_SELECT_End (); HTM_Txt (")"); @@ -417,12 +455,16 @@ void Sta_AskShowGblHits (void) extern const char *Txt_distributed_by; extern const char *Txt_STAT_CLICKS_GROUPED_BY[Sta_NUM_CLICKS_GROUPED_BY]; extern const char *Txt_Show_hits; + struct Sta_Stats Stats; Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME]; Sta_Role_t RoleStat; unsigned RoleStatUnsigned; Sta_ClicksGroupedBy_t ClicksGroupedBy; unsigned ClicksGroupedByUnsigned; + /***** Reset stats context *****/ + Sta_ResetStats (&Stats); + /***** Contextual menu *****/ Mnu_ContextMenuBegin (); Sta_PutLinkToCourseHits (); // Course hits @@ -466,7 +508,7 @@ void Sta_AskShowGblHits (void) { RoleStatUnsigned = (unsigned) RoleStat; HTM_OPTION (HTM_Type_UNSIGNED,&RoleStatUnsigned, - RoleStat == Gbl.Stat.Role,false, + RoleStat == Stats.Role,false, "%s",Txt_ROLE_STATS[RoleStat]); } HTM_SELECT_End (); @@ -475,7 +517,7 @@ void Sta_AskShowGblHits (void) HTM_TR_End (); /***** Selection of action *****/ - Sta_WriteSelectorAction (); + Sta_WriteSelectorAction (&Stats); /***** Clicks made from anywhere, current centre, current degree or current course *****/ HTM_TR_Begin (NULL); @@ -506,15 +548,15 @@ void Sta_AskShowGblHits (void) /* Data */ HTM_TD_Begin ("class=\"LT\""); - Sta_WriteSelectorCountType (); + Sta_WriteSelectorCountType (&Stats); /***** Type of statistic *****/ HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); HTM_TxtF (" %s ",Txt_distributed_by); - if (Gbl.Stat.ClicksGroupedBy < Sta_CLICKS_GBL_PER_DAY || - Gbl.Stat.ClicksGroupedBy > Sta_CLICKS_GBL_PER_COURSE) - Gbl.Stat.ClicksGroupedBy = Sta_CLICKS_GBL_PER_DAY; + if (Stats.ClicksGroupedBy < Sta_CLICKS_GBL_PER_DAY || + Stats.ClicksGroupedBy > Sta_CLICKS_GBL_PER_COURSE) + Stats.ClicksGroupedBy = Sta_CLICKS_GBL_PER_DAY; HTM_SELECT_Begin (false, "name=\"GroupedBy\""); @@ -524,7 +566,7 @@ void Sta_AskShowGblHits (void) { ClicksGroupedByUnsigned = (unsigned) ClicksGroupedBy; HTM_OPTION (HTM_Type_UNSIGNED,&ClicksGroupedByUnsigned, - ClicksGroupedBy == Gbl.Stat.ClicksGroupedBy,false, + ClicksGroupedBy == Stats.ClicksGroupedBy,false, "%s",Txt_STAT_CLICKS_GROUPED_BY[ClicksGroupedBy]); } HTM_SELECT_End (); @@ -588,7 +630,7 @@ void Sta_PutLinkToGlobalHits (void) /****** Put selectors for type of access count and for degree or course ******/ /*****************************************************************************/ -static void Sta_WriteSelectorCountType (void) +static void Sta_WriteSelectorCountType (const struct Sta_Stats *Stats) { extern const char *Txt_STAT_TYPE_COUNT_SMALL[Sta_NUM_COUNT_TYPES]; Sta_CountType_t StatCountType; @@ -603,7 +645,7 @@ static void Sta_WriteSelectorCountType (void) { StatCountTypeUnsigned = (unsigned) StatCountType; HTM_OPTION (HTM_Type_UNSIGNED,&StatCountTypeUnsigned, - StatCountType == Gbl.Stat.CountType,false, + StatCountType == Stats->CountType,false, "%s",Txt_STAT_TYPE_COUNT_SMALL[StatCountType]); } HTM_SELECT_End (); @@ -613,7 +655,7 @@ static void Sta_WriteSelectorCountType (void) /******************** Put selector for type of action ************************/ /*****************************************************************************/ -static void Sta_WriteSelectorAction (void) +static void Sta_WriteSelectorAction (const struct Sta_Stats *Stats) { extern const char *The_ClassFormInBox[The_NUM_THEMES]; extern const char *Txt_Action; @@ -632,7 +674,7 @@ static void Sta_WriteSelectorAction (void) HTM_TD_Begin ("class=\"LT\""); HTM_SELECT_Begin (false, "id=\"StatAct\" name=\"StatAct\" class=\"STAT_SEL\""); - HTM_OPTION (HTM_Type_STRING,"0",Gbl.Stat.NumAction == 0,false, + HTM_OPTION (HTM_Type_STRING,"0",Stats->NumAction == 0,false, "%s",Txt_Any_action); for (Action = (Act_Action_t) 1; Action <= (Act_Action_t) (Act_NUM_ACTIONS - 1); @@ -641,7 +683,7 @@ static void Sta_WriteSelectorAction (void) Tab = Act_GetTab (Act_GetSuperAction (Action)); ActionUnsigned = (unsigned) Action; HTM_OPTION (HTM_Type_UNSIGNED,&ActionUnsigned, - Action == Gbl.Stat.NumAction,false, + Action == Stats->NumAction,false, "%u: %s > %s", (unsigned) Action,Txt_TABS_TXT[Tab],Act_GetActionText (Action)); } @@ -693,6 +735,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) extern const char *Txt_List_of_detailed_clicks; extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; extern const char *Txt_Time_zone_used_in_the_calculation_of_these_statistics; + struct Sta_Stats Stats; char *Query = NULL; char QueryAux[512]; long LengthQuery; @@ -709,6 +752,9 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) unsigned NumDays; bool ICanQueryWholeRange; + /***** Reset stats context *****/ + Sta_ResetStats (&Stats); + /***** Get initial and ending dates *****/ Dat_GetIniEndDatesFromForm (); @@ -730,38 +776,38 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) (unsigned long) Sta_CLICKS_DETAILED_OR_GROUPED_DEFAULT); if (DetailedOrGrouped == Sta_CLICKS_DETAILED) - Gbl.Stat.ClicksGroupedBy = Sta_CLICKS_CRS_DETAILED_LIST; + Stats.ClicksGroupedBy = Sta_CLICKS_CRS_DETAILED_LIST; else // DetailedOrGrouped == Sta_CLICKS_GROUPED - Gbl.Stat.ClicksGroupedBy = (Sta_ClicksGroupedBy_t) - Par_GetParToUnsignedLong ("GroupedBy", - 0, - Sta_NUM_CLICKS_GROUPED_BY - 1, - (unsigned long) Sta_CLICKS_GROUPED_BY_DEFAULT); + Stats.ClicksGroupedBy = (Sta_ClicksGroupedBy_t) + Par_GetParToUnsignedLong ("GroupedBy", + 0, + Sta_NUM_CLICKS_GROUPED_BY - 1, + (unsigned long) Sta_CLICKS_GROUPED_BY_DEFAULT); /***** Get the type of count of clicks *****/ - if (Gbl.Stat.ClicksGroupedBy != Sta_CLICKS_CRS_DETAILED_LIST) - Gbl.Stat.CountType = (Sta_CountType_t) - Par_GetParToUnsignedLong ("CountType", - 0, - Sta_NUM_COUNT_TYPES - 1, - (unsigned long) Sta_COUNT_TYPE_DEFAULT); + if (Stats.ClicksGroupedBy != Sta_CLICKS_CRS_DETAILED_LIST) + Stats.CountType = (Sta_CountType_t) + Par_GetParToUnsignedLong ("CountType", + 0, + Sta_NUM_COUNT_TYPES - 1, + (unsigned long) Sta_COUNT_TYPE_DEFAULT); /***** Get action *****/ - Gbl.Stat.NumAction = (Act_Action_t) - Par_GetParToUnsignedLong ("StatAct", - 0, - Act_NUM_ACTIONS - 1, - (unsigned long) Sta_NUM_ACTION_DEFAULT); + Stats.NumAction = (Act_Action_t) + Par_GetParToUnsignedLong ("StatAct", + 0, + Act_NUM_ACTIONS - 1, + (unsigned long) Sta_NUM_ACTION_DEFAULT); switch (GlobalOrCourse) { case Sta_SHOW_GLOBAL_ACCESSES: /***** Get the type of user of clicks *****/ - Gbl.Stat.Role = (Sta_Role_t) - Par_GetParToUnsignedLong ("Role", - 0, - Sta_NUM_ROLES_STAT - 1, - (unsigned long) Sta_ROLE_DEFAULT); + Stats.Role = (Sta_Role_t) + Par_GetParToUnsignedLong ("Role", + 0, + Sta_NUM_ROLES_STAT - 1, + (unsigned long) Sta_ROLE_DEFAULT); /***** Get users range for access statistics *****/ Gbl.Scope.Allowed = 1 << Hie_SYS | @@ -780,10 +826,10 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) HTM_SECTION_Begin (Sta_STAT_RESULTS_SECTION_ID); /***** Check selection *****/ - if ((Gbl.Stat.Role == Sta_ROLE_ALL_USRS || - Gbl.Stat.Role == Sta_ROLE_UNKNOWN_USRS) && - (Gbl.Stat.CountType == Sta_DISTINCT_USRS || - Gbl.Stat.CountType == Sta_CLICKS_PER_USR)) // These types of query will never give a valid result + if ((Stats.Role == Sta_ROLE_ALL_USRS || + Stats.Role == Sta_ROLE_UNKNOWN_USRS) && + (Stats.CountType == Sta_DISTINCT_USRS || + Stats.CountType == Sta_CLICKS_PER_USR)) // These types of query will never give a valid result { /* Write warning message and abort */ Ale_ShowAlert (Ale_WARNING,Txt_There_is_no_knowing_how_many_users_not_logged_have_accessed); @@ -791,22 +837,22 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) } break; case Sta_SHOW_COURSE_ACCESSES: - if (Gbl.Stat.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST) + if (Stats.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST) { /****** Get the number of the first row to show ******/ - Gbl.Stat.FirstRow = Par_GetParToUnsignedLong ("FirstRow", - 1, - ULONG_MAX, - 0); + Stats.FirstRow = Par_GetParToUnsignedLong ("FirstRow", + 1, + ULONG_MAX, + 0); /****** Get the number of the last row to show ******/ - Gbl.Stat.LastRow = Par_GetParToUnsignedLong ("LastRow", - 1, - ULONG_MAX, - 0); + Stats.LastRow = Par_GetParToUnsignedLong ("LastRow", + 1, + ULONG_MAX, + 0); /****** Get the number of rows per page ******/ - Gbl.Stat.RowsPerPage = + Stats.RowsPerPage = (unsigned) Par_GetParToUnsignedLong ("RowsPage", Sta_MIN_ROWS_PER_PAGE, Sta_MAX_ROWS_PER_PAGE, @@ -856,7 +902,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) } /***** Query depending on the type of count *****/ - switch (Gbl.Stat.CountType) + switch (Stats.CountType) { case Sta_TOTAL_CLICKS: Str_Copy (StrQueryCountType,"COUNT(*)", @@ -882,7 +928,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) Lay_NotEnoughMemoryExit (); /* Start the query */ - switch (Gbl.Stat.ClicksGroupedBy) + switch (Stats.ClicksGroupedBy) { case Sta_CLICKS_CRS_DETAILED_LIST: snprintf (Query,Sta_MAX_BYTES_QUERY_ACCESS + 1, @@ -1078,14 +1124,14 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) } /* Type of users */ - switch (Gbl.Stat.Role) + switch (Stats.Role) { case Sta_ROLE_IDENTIFIED_USRS: sprintf (StrRole," AND %s.Role<>%u", LogTable,(unsigned) Rol_UNK); break; case Sta_ROLE_ALL_USRS: - switch (Gbl.Stat.CountType) + switch (Stats.CountType) { case Sta_TOTAL_CLICKS: case Sta_GENERATION_TIME: @@ -1143,7 +1189,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) Str_Concat (Query,StrRole, Sta_MAX_BYTES_QUERY_ACCESS); - switch (Gbl.Stat.ClicksGroupedBy) + switch (Stats.ClicksGroupedBy) { case Sta_CLICKS_GBL_PER_PLUGIN: case Sta_CLICKS_GBL_PER_API_FUNCTION: @@ -1202,16 +1248,16 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) } /* Select action */ - if (Gbl.Stat.NumAction != ActAll) + if (Stats.NumAction != ActAll) { sprintf (QueryAux," AND %s.ActCod=%ld", - LogTable,Act_GetActCod (Gbl.Stat.NumAction)); + LogTable,Act_GetActCod (Stats.NumAction)); Str_Concat (Query,QueryAux, Sta_MAX_BYTES_QUERY_ACCESS); } /* End the query */ - switch (Gbl.Stat.ClicksGroupedBy) + switch (Stats.ClicksGroupedBy) { case Sta_CLICKS_CRS_DETAILED_LIST: Str_Concat (Query," ORDER BY F", @@ -1317,43 +1363,43 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) else { /***** Put the table with the clicks *****/ - if (Gbl.Stat.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST) + if (Stats.ClicksGroupedBy == Sta_CLICKS_CRS_DETAILED_LIST) Box_BoxBegin ("100%",Txt_List_of_detailed_clicks, NULL,NULL, NULL,Box_NOT_CLOSABLE); else - Box_BoxBegin (NULL,Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType], + Box_BoxBegin (NULL,Txt_STAT_TYPE_COUNT_CAPS[Stats.CountType], NULL,NULL, NULL,Box_NOT_CLOSABLE); - HTM_TABLE_BeginPadding (Sta_CellPadding[Gbl.Stat.ClicksGroupedBy]); - switch (Gbl.Stat.ClicksGroupedBy) + HTM_TABLE_BeginPadding (Sta_CellPadding[Stats.ClicksGroupedBy]); + switch (Stats.ClicksGroupedBy) { case Sta_CLICKS_CRS_DETAILED_LIST: - Sta_ShowDetailedAccessesList (NumRows,mysql_res); + Sta_ShowDetailedAccessesList (&Stats,NumRows,mysql_res); break; case Sta_CLICKS_CRS_PER_USR: - Sta_ShowNumHitsPerUsr (NumRows,mysql_res); + Sta_ShowNumHitsPerUsr (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_CRS_PER_DAY: case Sta_CLICKS_GBL_PER_DAY: - Sta_ShowNumHitsPerDay (NumRows,mysql_res); + Sta_ShowNumHitsPerDay (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_CRS_PER_DAY_AND_HOUR: case Sta_CLICKS_GBL_PER_DAY_AND_HOUR: - Sta_ShowDistrAccessesPerDayAndHour (NumRows,mysql_res); + Sta_ShowDistrAccessesPerDayAndHour (&Stats,NumRows,mysql_res); break; case Sta_CLICKS_CRS_PER_WEEK: case Sta_CLICKS_GBL_PER_WEEK: - Sta_ShowNumHitsPerWeek (NumRows,mysql_res); + Sta_ShowNumHitsPerWeek (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_CRS_PER_MONTH: case Sta_CLICKS_GBL_PER_MONTH: - Sta_ShowNumHitsPerMonth (NumRows,mysql_res); + Sta_ShowNumHitsPerMonth (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_CRS_PER_YEAR: case Sta_CLICKS_GBL_PER_YEAR: - Sta_ShowNumHitsPerYear (NumRows,mysql_res); + Sta_ShowNumHitsPerYear (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_CRS_PER_HOUR: case Sta_CLICKS_GBL_PER_HOUR: @@ -1365,31 +1411,31 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) break; case Sta_CLICKS_CRS_PER_ACTION: case Sta_CLICKS_GBL_PER_ACTION: - Sta_ShowNumHitsPerAction (NumRows,mysql_res); + Sta_ShowNumHitsPerAction (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_GBL_PER_PLUGIN: - Sta_ShowNumHitsPerPlugin (NumRows,mysql_res); + Sta_ShowNumHitsPerPlugin (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_GBL_PER_API_FUNCTION: - Sta_ShowNumHitsPerWSFunction (NumRows,mysql_res); + Sta_ShowNumHitsPerWSFunction (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_GBL_PER_BANNER: - Sta_ShowNumHitsPerBanner (NumRows,mysql_res); + Sta_ShowNumHitsPerBanner (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_GBL_PER_COUNTRY: - Sta_ShowNumHitsPerCountry (NumRows,mysql_res); + Sta_ShowNumHitsPerCountry (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_GBL_PER_INSTITUTION: - Sta_ShowNumHitsPerInstitution (NumRows,mysql_res); + Sta_ShowNumHitsPerInstitution (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_GBL_PER_CENTRE: - Sta_ShowNumHitsPerCentre (NumRows,mysql_res); + Sta_ShowNumHitsPerCentre (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_GBL_PER_DEGREE: - Sta_ShowNumHitsPerDegree (NumRows,mysql_res); + Sta_ShowNumHitsPerDegree (Stats.CountType,NumRows,mysql_res); break; case Sta_CLICKS_GBL_PER_COURSE: - Sta_ShowNumHitsPerCourse (NumRows,mysql_res); + Sta_ShowNumHitsPerCourse (Stats.CountType,NumRows,mysql_res); break; } HTM_TABLE_End (); @@ -1407,7 +1453,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) Usr_FreeListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected); /***** Write time zone used in the calculation of these statistics *****/ - switch (Gbl.Stat.ClicksGroupedBy) + switch (Stats.ClicksGroupedBy) { case Sta_CLICKS_CRS_PER_DAY: case Sta_CLICKS_GBL_PER_DAY: @@ -1436,7 +1482,9 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) /******************* Show a listing of detailed clicks ***********************/ /*****************************************************************************/ -static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql_res) +static void Sta_ShowDetailedAccessesList (const struct Sta_Stats *Stats, + unsigned long NumRows, + MYSQL_RES *mysql_res) { extern Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD]; extern const char *Txt_Show_previous_X_clicks; @@ -1472,31 +1520,31 @@ static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql Usr_UsrDataConstructor (&UsrDat); /***** Compute the first and the last row to show *****/ - FirstRow = Gbl.Stat.FirstRow; - LastRow = Gbl.Stat.LastRow; + FirstRow = Stats->FirstRow; + LastRow = Stats->LastRow; if (FirstRow == 0 && LastRow == 0) // Call from main form { // Show last clicks - FirstRow = (NumRows / Gbl.Stat.RowsPerPage - 1) * Gbl.Stat.RowsPerPage + 1; - if ((FirstRow + Gbl.Stat.RowsPerPage - 1) < NumRows) - FirstRow += Gbl.Stat.RowsPerPage; + FirstRow = (NumRows / Stats->RowsPerPage - 1) * Stats->RowsPerPage + 1; + if ((FirstRow + Stats->RowsPerPage - 1) < NumRows) + FirstRow += Stats->RowsPerPage; LastRow = NumRows; } if (FirstRow < 1) // For security reasons; really it should never be less than 1 FirstRow = 1; if (LastRow > NumRows) LastRow = NumRows; - if ((LastRow - FirstRow) >= Gbl.Stat.RowsPerPage) // For if there have been clicks that have increased the number of rows - LastRow = FirstRow + Gbl.Stat.RowsPerPage - 1; + if ((LastRow - FirstRow) >= Stats->RowsPerPage) // For if there have been clicks that have increased the number of rows + LastRow = FirstRow + Stats->RowsPerPage - 1; /***** Compute the number total of pages *****/ /* Number of pages before the current one */ - NumPagesBefore = (FirstRow-1) / Gbl.Stat.RowsPerPage; - if (NumPagesBefore * Gbl.Stat.RowsPerPage < (FirstRow-1)) + NumPagesBefore = (FirstRow-1) / Stats->RowsPerPage; + if (NumPagesBefore * Stats->RowsPerPage < (FirstRow-1)) NumPagesBefore++; /* Number of pages after the current one */ - NumPagesAfter = (NumRows - LastRow) / Gbl.Stat.RowsPerPage; - if (NumPagesAfter * Gbl.Stat.RowsPerPage < (NumRows - LastRow)) + NumPagesAfter = (NumRows - LastRow) / Stats->RowsPerPage; + if (NumPagesAfter * Stats->RowsPerPage < (NumRows - LastRow)) NumPagesAfter++; /* Count the total number of pages */ NumPagsTotal = NumPagesBefore + 1 + NumPagesAfter; @@ -1514,17 +1562,17 @@ static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql Frm_StartFormAnchor (ActSeeAccCrs,Sta_STAT_RESULTS_SECTION_ID); Dat_WriteParamsIniEndDates (); Par_PutHiddenParamUnsigned (NULL,"GroupedBy",(unsigned) Sta_CLICKS_CRS_DETAILED_LIST); - Par_PutHiddenParamUnsigned (NULL,"StatAct" ,(unsigned) Gbl.Stat.NumAction); - Par_PutHiddenParamLong (NULL,"FirstRow",FirstRow - Gbl.Stat.RowsPerPage); + Par_PutHiddenParamUnsigned (NULL,"StatAct" ,(unsigned) Stats->NumAction); + Par_PutHiddenParamLong (NULL,"FirstRow",FirstRow - Stats->RowsPerPage); Par_PutHiddenParamLong (NULL,"LastRow" ,FirstRow - 1); - Par_PutHiddenParamUnsigned (NULL,"RowsPage",Gbl.Stat.RowsPerPage); + Par_PutHiddenParamUnsigned (NULL,"RowsPage",Stats->RowsPerPage); Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected); } HTM_TD_Begin ("class=\"LM\""); if (FirstRow > 1) { HTM_BUTTON_SUBMIT_Begin (Str_BuildStringLong (Txt_Show_previous_X_clicks, - (long) Gbl.Stat.RowsPerPage), + (long) Stats->RowsPerPage), "BT_LINK TIT_TBL",NULL); Str_FreeString (); HTM_STRONG_Begin (); @@ -1552,17 +1600,17 @@ static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql Frm_StartFormAnchor (ActSeeAccCrs,Sta_STAT_RESULTS_SECTION_ID); Dat_WriteParamsIniEndDates (); Par_PutHiddenParamUnsigned (NULL,"GroupedBy",(unsigned) Sta_CLICKS_CRS_DETAILED_LIST); - Par_PutHiddenParamUnsigned (NULL,"StatAct" ,(unsigned) Gbl.Stat.NumAction); + Par_PutHiddenParamUnsigned (NULL,"StatAct" ,(unsigned) Stats->NumAction); Par_PutHiddenParamUnsigned (NULL,"FirstRow" ,(unsigned) (LastRow + 1)); - Par_PutHiddenParamUnsigned (NULL,"LastRow" ,(unsigned) (LastRow + Gbl.Stat.RowsPerPage)); - Par_PutHiddenParamUnsigned (NULL,"RowsPage" ,(unsigned) Gbl.Stat.RowsPerPage); + Par_PutHiddenParamUnsigned (NULL,"LastRow" ,(unsigned) (LastRow + Stats->RowsPerPage)); + Par_PutHiddenParamUnsigned (NULL,"RowsPage" ,(unsigned) Stats->RowsPerPage); Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected); } HTM_TD_Begin ("class=\"RM\""); if (LastRow < NumRows) { HTM_BUTTON_SUBMIT_Begin (Str_BuildStringLong (Txt_Show_next_X_clicks, - (long) Gbl.Stat.RowsPerPage), + (long) Stats->RowsPerPage), "BT_LINK TIT_TBL",NULL); Str_FreeString (); HTM_STRONG_Begin (); @@ -1694,7 +1742,8 @@ static void Sta_WriteLogComments (long LogCod) /********* Show a listing of with the number of clicks of each user **********/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerUsr (unsigned long NumRows,MYSQL_RES *mysql_res) +static void Sta_ShowNumHitsPerUsr (Sta_CountType_t CountType, + unsigned long NumRows,MYSQL_RES *mysql_res) { extern const char *Txt_No_INDEX; extern const char *Txt_Photo; @@ -1722,7 +1771,7 @@ static void Sta_ShowNumHitsPerUsr (unsigned long NumRows,MYSQL_RES *mysql_res) HTM_TH (1,1,"LT",Txt_ID); HTM_TH (1,1,"LT",Txt_Name); HTM_TH (1,1,"CT",Txt_Role); - HTM_TH (1,2,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,2,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -1806,7 +1855,8 @@ static void Sta_ShowNumHitsPerUsr (unsigned long NumRows,MYSQL_RES *mysql_res) /********** Show a listing of with the number of clicks in each date *********/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerDay (unsigned long NumRows,MYSQL_RES *mysql_res) +static void Sta_ShowNumHitsPerDay (Sta_CountType_t CountType, + unsigned long NumRows,MYSQL_RES *mysql_res) { extern const char *Txt_Date; extern const char *Txt_Day; @@ -1831,7 +1881,7 @@ static void Sta_ShowNumHitsPerDay (unsigned long NumRows,MYSQL_RES *mysql_res) HTM_TH (1,1,"CT",Txt_Date); HTM_TH (1,1,"LT",Txt_Day); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -1936,7 +1986,9 @@ static void Sta_ShowNumHitsPerDay (unsigned long NumRows,MYSQL_RES *mysql_res) #define GRAPH_DISTRIBUTION_PER_HOUR_HOUR_WIDTH 25 #define GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH (GRAPH_DISTRIBUTION_PER_HOUR_HOUR_WIDTH * 24) -static void Sta_ShowDistrAccessesPerDayAndHour (unsigned long NumRows,MYSQL_RES *mysql_res) +static void Sta_ShowDistrAccessesPerDayAndHour (const struct Sta_Stats *Stats, + unsigned long NumRows, + MYSQL_RES *mysql_res) { extern const char *The_ClassFormInBox[The_NUM_THEMES]; extern const char *Txt_Color_of_the_graphic; @@ -1974,14 +2026,14 @@ static void Sta_ShowDistrAccessesPerDayAndHour (unsigned long NumRows,MYSQL_RES Frm_StartFormAnchor (Gbl.Action.Act,Sta_STAT_RESULTS_SECTION_ID); Dat_WriteParamsIniEndDates (); - Par_PutHiddenParamUnsigned (NULL,"GroupedBy",(unsigned) Gbl.Stat.ClicksGroupedBy); - Par_PutHiddenParamUnsigned (NULL,"CountType",(unsigned) Gbl.Stat.CountType); - Par_PutHiddenParamUnsigned (NULL,"StatAct" ,(unsigned) Gbl.Stat.NumAction); + Par_PutHiddenParamUnsigned (NULL,"GroupedBy",(unsigned) Stats->ClicksGroupedBy); + Par_PutHiddenParamUnsigned (NULL,"CountType",(unsigned) Stats->CountType); + Par_PutHiddenParamUnsigned (NULL,"StatAct" ,(unsigned) Stats->NumAction); if (Gbl.Action.Act == ActSeeAccCrs) Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected); else // Gbl.Action.Act == ActSeeAccGbl { - Par_PutHiddenParamUnsigned (NULL,"Role",(unsigned) Gbl.Stat.Role); + Par_PutHiddenParamUnsigned (NULL,"Role",(unsigned) Stats->Role); Sta_PutHiddenParamScopeSta (); } @@ -2021,7 +2073,7 @@ static void Sta_ShowDistrAccessesPerDayAndHour (unsigned long NumRows,MYSQL_RES HTM_TH (3,1,"CT",Txt_Date); HTM_TH (3,1,"LT",Txt_Day); - HTM_TH (1,24,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,24,"LT",Txt_STAT_TYPE_COUNT_CAPS[Stats->CountType]); HTM_TR_End (); @@ -2384,8 +2436,9 @@ static void Sta_SetColor (Sta_ColorType_t ColorType,double HitsNum,double HitsMa /********** Show listing with number of pages generated per week *************/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerWeek (unsigned long NumRows, - MYSQL_RES *mysql_res) +static void Sta_ShowNumHitsPerWeek (Sta_CountType_t CountType, + unsigned long NumRows, + MYSQL_RES *mysql_res) { extern const char *Txt_Week; extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; @@ -2406,7 +2459,7 @@ static void Sta_ShowNumHitsPerWeek (unsigned long NumRows, HTM_TR_Begin (NULL); HTM_TH (1,1,"LT",Txt_Week); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -2485,8 +2538,9 @@ static void Sta_ShowNumHitsPerWeek (unsigned long NumRows, /********** Show a graph with the number of clicks in each month *************/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerMonth (unsigned long NumRows, - MYSQL_RES *mysql_res) +static void Sta_ShowNumHitsPerMonth (Sta_CountType_t CountType, + unsigned long NumRows, + MYSQL_RES *mysql_res) { extern const char *Txt_Month; extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; @@ -2506,7 +2560,7 @@ static void Sta_ShowNumHitsPerMonth (unsigned long NumRows, HTM_TR_Begin (NULL); HTM_TH (1,1,"LT",Txt_Month); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -2585,7 +2639,8 @@ static void Sta_ShowNumHitsPerMonth (unsigned long NumRows, /*********** Show a graph with the number of clicks in each year *************/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerYear (unsigned long NumRows, +static void Sta_ShowNumHitsPerYear (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res) { extern const char *Txt_Year; @@ -2606,7 +2661,7 @@ static void Sta_ShowNumHitsPerYear (unsigned long NumRows, HTM_TR_Begin (NULL); HTM_TH (1,1,"LT",Txt_Year); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -3010,7 +3065,8 @@ static void Sta_WriteAccessMinute (unsigned Minute,double HitsNum,double MaxX) /**** Show a listing of accesses with the number of clicks a each action *****/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerAction (unsigned long NumRows, +static void Sta_ShowNumHitsPerAction (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res) { extern Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD]; @@ -3025,7 +3081,7 @@ static void Sta_ShowNumHitsPerAction (unsigned long NumRows, HTM_TR_Begin (NULL); HTM_TH (1,1,"RT",Txt_Action); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -3065,7 +3121,8 @@ static void Sta_ShowNumHitsPerAction (unsigned long NumRows, /*************** Show number of clicks distributed by plugin *****************/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerPlugin (unsigned long NumRows, +static void Sta_ShowNumHitsPerPlugin (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res) { extern const char *Txt_Plugin; @@ -3079,7 +3136,7 @@ static void Sta_ShowNumHitsPerPlugin (unsigned long NumRows, HTM_TR_Begin (NULL); HTM_TH (1,1,"RT",Txt_Plugin); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -3120,7 +3177,8 @@ static void Sta_ShowNumHitsPerPlugin (unsigned long NumRows, /******** Show number of clicks distributed by web service function **********/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerWSFunction (unsigned long NumRows, +static void Sta_ShowNumHitsPerWSFunction (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res) { extern const char *Txt_Function; @@ -3134,7 +3192,7 @@ static void Sta_ShowNumHitsPerWSFunction (unsigned long NumRows, HTM_TR_Begin (NULL); HTM_TH (1,1,"LT",Txt_Function); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -3172,7 +3230,8 @@ static void Sta_ShowNumHitsPerWSFunction (unsigned long NumRows, /******** Show number of clicks distributed by web service function **********/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerBanner (unsigned long NumRows, +static void Sta_ShowNumHitsPerBanner (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res) { extern const char *Txt_Banner; @@ -3188,7 +3247,7 @@ static void Sta_ShowNumHitsPerBanner (unsigned long NumRows, HTM_TR_Begin (NULL); HTM_TH (1,1,"CT",Txt_Banner); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -3241,7 +3300,8 @@ static void Sta_ShowNumHitsPerBanner (unsigned long NumRows, /******* Show a listing with the number of hits distributed by country *******/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerCountry (unsigned long NumRows, +static void Sta_ShowNumHitsPerCountry (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res) { extern const char *Txt_No_INDEX; @@ -3258,7 +3318,7 @@ static void Sta_ShowNumHitsPerCountry (unsigned long NumRows, HTM_TH (1,1,"CT",Txt_No_INDEX); HTM_TH (1,1,"CT",Txt_Country); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -3331,7 +3391,8 @@ static void Sta_WriteCountry (long CtyCod) /***** Show a listing with the number of hits distributed by institution *****/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerInstitution (unsigned long NumRows, +static void Sta_ShowNumHitsPerInstitution (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res) { extern const char *Txt_No_INDEX; @@ -3348,7 +3409,7 @@ static void Sta_ShowNumHitsPerInstitution (unsigned long NumRows, HTM_TH (1,1,"CT",Txt_No_INDEX); HTM_TH (1,1,"CT",Txt_Institution); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -3423,7 +3484,8 @@ static void Sta_WriteInstit (long InsCod) /******* Show a listing with the number of hits distributed by centre ********/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerCentre (unsigned long NumRows, +static void Sta_ShowNumHitsPerCentre (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res) { extern const char *Txt_No_INDEX; @@ -3440,7 +3502,7 @@ static void Sta_ShowNumHitsPerCentre (unsigned long NumRows, HTM_TH (1,1,"CT",Txt_No_INDEX); HTM_TH (1,1,"CT",Txt_Centre); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -3515,7 +3577,8 @@ static void Sta_WriteCentre (long CtrCod) /******* Show a listing with the number of hits distributed by degree ********/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerDegree (unsigned long NumRows, +static void Sta_ShowNumHitsPerDegree (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res) { extern const char *Txt_No_INDEX; @@ -3532,7 +3595,7 @@ static void Sta_ShowNumHitsPerDegree (unsigned long NumRows, HTM_TH (1,1,"CT",Txt_No_INDEX); HTM_TH (1,1,"CT",Txt_Degree); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); @@ -3607,7 +3670,8 @@ static void Sta_WriteDegree (long DegCod) /********* Show a listing with the number of clicks to each course ***********/ /*****************************************************************************/ -static void Sta_ShowNumHitsPerCourse (unsigned long NumRows, +static void Sta_ShowNumHitsPerCourse (Sta_CountType_t CountType, + unsigned long NumRows, MYSQL_RES *mysql_res) { extern const char *Txt_No_INDEX; @@ -3630,7 +3694,7 @@ static void Sta_ShowNumHitsPerCourse (unsigned long NumRows, HTM_TH (1,1,"CT",Txt_Degree); HTM_TH (1,1,"CT",Txt_Year_OF_A_DEGREE); HTM_TH (1,1,"CT",Txt_Course); - HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[Gbl.Stat.CountType]); + HTM_TH (1,1,"LT",Txt_STAT_TYPE_COUNT_CAPS[CountType]); HTM_TR_End (); diff --git a/swad_statistic.h b/swad_statistic.h index 8283e74c..dad3b655 100644 --- a/swad_statistic.h +++ b/swad_statistic.h @@ -137,26 +137,16 @@ struct Sta_Stats unsigned long FirstRow; unsigned long LastRow; unsigned RowsPerPage; - long DegTypCod; - long DptCod; - char StrIndicatorsSelected[Ind_MAX_SIZE_INDICATORS_SELECTED + 1]; - bool IndicatorsSelected[1 + Ind_NUM_INDICATORS]; - struct - { - Pho_AvgPhotoTypeOfAverage_t TypeOfAverage; - Pho_HowComputePhotoSize_t HowComputePhotoSize; - Pho_HowOrderDegrees_t HowOrderDegrees; - int MaxStds; - int MaxStdsWithPhoto; - double MaxPercent; - } DegPhotos; }; /*****************************************************************************/ /***************************** Public prototypes *****************************/ /*****************************************************************************/ +void Sta_ResetStats (struct Sta_Stats *Stats); + void Sta_GetRemoteAddr (void); + void Sta_AskShowCrsHits (void); void Sta_AskShowGblHits (void); void Sta_PutLinkToCourseHits (void);