%s: %s
", Txt_Time_zone_used_in_the_calculation_of_these_statistics, BrowserTimeZone); break; default: break; } } /*****************************************************************************/ /******************* Show a listing of detailed clicks ***********************/ /*****************************************************************************/ static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql_res) { extern const char *Txt_Show_previous_X_clicks; extern const char *Txt_PAGES_Previous; extern const char *Txt_Clicks; extern const char *Txt_of_PART_OF_A_TOTAL; extern const char *Txt_page; extern const char *Txt_Show_next_X_clicks; extern const char *Txt_PAGES_Next; extern const char *Txt_No_INDEX; extern const char *Txt_User_ID; extern const char *Txt_Name; extern const char *Txt_Role; extern const char *Txt_Date; extern const char *Txt_Action; extern const char *Txt_LOG_More_info; extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_Today; unsigned long NumRow; unsigned long FirstRow; // First row to show unsigned long LastRow; // Last rows to show unsigned long NumPagesBefore; unsigned long NumPagesAfter; unsigned long NumPagsTotal; struct UsrData UsrDat; MYSQL_ROW row; long LogCod; Rol_Role_t RoleFromLog; unsigned UniqueId; long ActCod; char ActTxt[Act_MAX_BYTES_ACTION_TXT + 1]; /***** Initialize estructura of data of the user *****/ Usr_UsrDataConstructor (&UsrDat); /***** Compute the first and the last row to show *****/ FirstRow = Gbl.Stat.FirstRow; LastRow = Gbl.Stat.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; 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; /***** 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++; /* Number of pages after the current one */ NumPagesAfter = (NumRows - LastRow) / Gbl.Stat.RowsPerPage; if (NumPagesAfter * Gbl.Stat.RowsPerPage < (NumRows - LastRow)) NumPagesAfter++; /* Count the total number of pages */ NumPagsTotal = NumPagesBefore + 1 + NumPagesAfter; /***** Put heading with backward and forward buttons *****/ HTM_TR_Begin (NULL); HTM_TD_Begin ("colspan=\"7\" class=\"LM\""); HTM_TABLE_BeginWidePadding (2); HTM_TR_Begin (NULL); /* Put link to jump to previous page (older clicks) */ if (FirstRow > 1) { Frm_StartFormAnchor (ActSeeAccCrs,Sta_STAT_RESULTS_SECTION_ID); Dat_WriteParamsIniEndDates (); Par_PutHiddenParamUnsigned ("GroupedBy",(unsigned) Sta_CLICKS_CRS_DETAILED_LIST); Par_PutHiddenParamUnsigned ("StatAct" ,(unsigned) Gbl.Stat.NumAction); Par_PutHiddenParamLong ("FirstRow",FirstRow - Gbl.Stat.RowsPerPage); Par_PutHiddenParamLong ("LastRow" ,FirstRow - 1); Par_PutHiddenParamLong ("RowsPage",Gbl.Stat.RowsPerPage); Usr_PutHiddenParSelectedUsrsCods (); } HTM_TD_Begin ("class=\"LM\""); if (FirstRow > 1) { snprintf (Gbl.Title,sizeof (Gbl.Title), Txt_Show_previous_X_clicks, Gbl.Stat.RowsPerPage); Frm_LinkFormSubmit (Gbl.Title,"TIT_TBL",NULL); fprintf (Gbl.F.Out,"<%s", Txt_PAGES_Previous); } HTM_TD_End (); if (FirstRow > 1) Frm_EndForm (); /* Write number of current page */ HTM_TD_Begin ("class=\"DAT_N CM\""); fprintf (Gbl.F.Out,"" "%s %lu-%lu %s %lu (%s %ld %s %lu)" "", Txt_Clicks, FirstRow,LastRow,Txt_of_PART_OF_A_TOTAL,NumRows, Txt_page,NumPagesBefore + 1,Txt_of_PART_OF_A_TOTAL,NumPagsTotal); HTM_TD_End (); /* Put link to jump to next page (more recent clicks) */ if (LastRow < NumRows) { Frm_StartFormAnchor (ActSeeAccCrs,Sta_STAT_RESULTS_SECTION_ID); Dat_WriteParamsIniEndDates (); Par_PutHiddenParamUnsigned ("GroupedBy",(unsigned) Sta_CLICKS_CRS_DETAILED_LIST); Par_PutHiddenParamUnsigned ("StatAct" ,(unsigned) Gbl.Stat.NumAction); Par_PutHiddenParamUnsigned ("FirstRow" ,(unsigned) (LastRow + 1)); Par_PutHiddenParamUnsigned ("LastRow" ,(unsigned) (LastRow + Gbl.Stat.RowsPerPage)); Par_PutHiddenParamUnsigned ("RowsPage" ,(unsigned) Gbl.Stat.RowsPerPage); Usr_PutHiddenParSelectedUsrsCods (); } HTM_TD_Begin ("class=\"RM\""); if (LastRow < NumRows) { snprintf (Gbl.Title,sizeof (Gbl.Title), Txt_Show_next_X_clicks, Gbl.Stat.RowsPerPage); Frm_LinkFormSubmit (Gbl.Title,"TIT_TBL",NULL); fprintf (Gbl.F.Out,"%s>" "", Txt_PAGES_Next); } HTM_TD_End (); if (LastRow < NumRows) Frm_EndForm (); HTM_TR_End (); HTM_TABLE_End (); HTM_TD_End (); HTM_TR_End (); /***** Write heading *****/ HTM_TR_Begin (NULL); HTM_TH (1,1,"RT",Txt_No_INDEX); HTM_TH (1,1,"CT",Txt_User_ID); HTM_TH (1,1,"LT",Txt_Name); HTM_TH (1,1,"CT",Txt_Role); HTM_TH (1,1,"CT",Txt_Date); HTM_TH (1,1,"LT",Txt_Action); HTM_TH (1,1,"LT",Txt_LOG_More_info); HTM_TR_End (); /***** Write rows back *****/ for (NumRow = LastRow, UniqueId = 1, Gbl.RowEvenOdd = 0; NumRow >= FirstRow; NumRow--, UniqueId++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd) { mysql_data_seek (mysql_res,(my_ulonglong) (NumRow - 1)); row = mysql_fetch_row (mysql_res); /* Get log code */ LogCod = Str_ConvertStrCodToLongCod (row[0]); /* Get user's data of the database */ UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[1]); Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS); /* Get logged role */ if (sscanf (row[2],"%u",&RoleFromLog) != 1) Rol_WrongRoleExit (); HTM_TR_Begin (NULL); /* Write the number of row */ HTM_TD_Begin ("class=\"LOG RT COLOR%u\"",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"%ld ",NumRow); HTM_TD_End (); /* Write the user's ID if user is a student */ HTM_TD_Begin ("class=\"LOG CT COLOR%u\"",Gbl.RowEvenOdd); ID_WriteUsrIDs (&UsrDat,NULL); fprintf (Gbl.F.Out," "); HTM_TD_End (); /* Write the first name and the surnames */ HTM_TD_Begin ("class=\"LOG LT COLOR%u\"",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"%s ",UsrDat.FullName); HTM_TD_End (); /* Write the user's role */ HTM_TD_Begin ("class=\"LOG CT COLOR%u\"",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"%s ", RoleFromLog < Rol_NUM_ROLES ? Txt_ROLES_SINGUL_Abc[RoleFromLog][UsrDat.Sex] : "?"); HTM_TD_End (); /* Write the date-time (row[3]) */ HTM_TD_Begin ("id=\"log_date_%u\" class=\"LOG RT COLOR%u\"", UniqueId,Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"", UniqueId,(long) Dat_GetUNIXTimeFromStr (row[3]), (unsigned) Gbl.Prefs.DateFormat,Txt_Today); HTM_TD_End (); /* Write the action */ if (sscanf (row[4],"%ld",&ActCod) != 1) Lay_ShowErrorAndExit ("Wrong action code."); if (ActCod >= 0) { HTM_TD_Begin ("class=\"LOG LT COLOR%u\"",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"%s ",Act_GetActionTextFromDB (ActCod,ActTxt)); } else { HTM_TD_Begin ("class=\"LOG LT COLOR%u\"",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"? "); } HTM_TD_End (); /* Write the comments of the access */ HTM_TD_Begin ("class=\"LOG LT COLOR%u\"",Gbl.RowEvenOdd); Sta_WriteLogComments (LogCod); HTM_TD_End (); HTM_TR_End (); } /***** Free memory used by the data of the user *****/ Usr_UsrDataDestructor (&UsrDat); } /*****************************************************************************/ /******** Show a listing of with the number of clicks of each user ***********/ /*****************************************************************************/ static void Sta_WriteLogComments (long LogCod) { MYSQL_RES *mysql_res; MYSQL_ROW row; /***** Get log comments from database *****/ if (DB_QuerySELECT (&mysql_res,"can not get log comments", "SELECT Comments FROM log_comments WHERE LogCod=%ld", LogCod)) { /***** Get and write comments *****/ row = mysql_fetch_row (mysql_res); fprintf (Gbl.F.Out,"%s",row[0]); } /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); } /*****************************************************************************/ /********* Show a listing of with the number of clicks of each user **********/ /*****************************************************************************/ static void Sta_ShowNumHitsPerUsr (unsigned long NumRows,MYSQL_RES *mysql_res) { extern const char *Txt_No_INDEX; extern const char *Txt_Photo; extern const char *Txt_ID; extern const char *Txt_Name; extern const char *Txt_Role; extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; MYSQL_ROW row; unsigned long NumRow; struct Sta_Hits Hits; unsigned BarWidth; struct UsrData UsrDat; char PhotoURL[PATH_MAX + 1]; bool ShowPhoto; /***** Initialize user's data *****/ Usr_UsrDataConstructor (&UsrDat); /***** Write heading *****/ HTM_TR_Begin (NULL); HTM_TH (1,1,"RT",Txt_No_INDEX); HTM_TH (1,1,"CT",Txt_Photo); 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_TR_End (); /***** Write rows *****/ for (NumRow = 1, Hits.Max = 0.0, Gbl.RowEvenOdd = 0; NumRow <= NumRows; NumRow++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd) { row = mysql_fetch_row (mysql_res); /* Get user's data from the database */ UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]); Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS); // Get the data of the user from the database HTM_TR_Begin (NULL); /* Write the number of row */ HTM_TD_Begin ("class=\"LOG RT COLOR%u\"",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"%ld ",NumRow); HTM_TD_End (); /* Show the photo */ HTM_TD_Begin ("class=\"CT COLOR%u\"",Gbl.RowEvenOdd); ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : NULL, "PHOTO15x20",Pho_ZOOM,false); HTM_TD_End (); /* Write the user's ID if user is a student in current course */ HTM_TD_Begin ("class=\"LOG LT COLOR%u\"",Gbl.RowEvenOdd); ID_WriteUsrIDs (&UsrDat,NULL); fprintf (Gbl.F.Out," "); HTM_TD_End (); /* Write the name and the surnames */ HTM_TD_Begin ("class=\"LOG LT COLOR%u\"",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"%s ",UsrDat.FullName); HTM_TD_End (); /* Write user's role */ HTM_TD_Begin ("class=\"LOG CT COLOR%u\"",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"%s ", Txt_ROLES_SINGUL_Abc[UsrDat.Roles.InCurrentCrs.Role][UsrDat.Sex]); HTM_TD_End (); /* Write the number of clicks */ Hits.Num = Str_GetFloatNumFromStr (row[1]); if (NumRow == 1) Hits.Max = Hits.Num; if (Hits.Max > 0.0) { BarWidth = (unsigned) (((Hits.Num * 375.0) / Hits.Max) + 0.5); if (BarWidth == 0) BarWidth = 1; } else BarWidth = 0; HTM_TD_Begin ("class=\"LOG LT COLOR%u\"",Gbl.RowEvenOdd); if (BarWidth) fprintf (Gbl.F.Out,"