diff --git a/swad_changelog.h b/swad_changelog.h index 69f5da2d4..a54070fdd 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -142,13 +142,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.3.2 (2016-09-28)" +#define Log_PLATFORM_VERSION "SWAD 16.4 (2016-09-29)" #define CSS_FILE "swad15.229.css" #define JS_FILE "swad15.238.1.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 /* + Version 16.4: Sep 29, 2016 Hits in current courses in user's usage report. (205299 lines) Version 16.3.2: Sep 28, 2016 Changes in behaviour of button to follow user. (205277 lines) Version 16.3.1: Sep 28, 2016 Two different messagesrelated to new account merged into one. Changes in form to create new account. (205271 lines) diff --git a/swad_report.c b/swad_report.c index d34743a8d..751d7b3c5 100644 --- a/swad_report.c +++ b/swad_report.c @@ -77,10 +77,16 @@ extern struct Globals Gbl; static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint); static void Rep_PutIconToPrintMyUsageReport (void); -static void Rep_GetAndWriteCrssOfAUsr (const struct UsrData *UsrDat,Rol_Role_t Role); -static void Rep_WriteRowCrsData (MYSQL_ROW row); +static void Rep_GetAndWriteCurrentCrssOfAUsr (const struct UsrData *UsrDat,Rol_Role_t Role, + time_t FirstClickTimeUTC, + struct tm *tm_FirstClickTime); +static void Rep_WriteRowCrsData (MYSQL_ROW row, + time_t FirstClickTimeUTC, + struct tm *tm_FirstClickTime); -static void Rep_ShowMyHitsPerYear (time_t FirstClickTimeUTC,struct tm *tm_FirstClickTime); +static void Rep_ShowMyHitsPerYear (long CrsCod, + time_t FirstClickTimeUTC, + struct tm *tm_FirstClickTime); // static void Rep_ShowMyHitsPerMonth (time_t FirstClickTimeUTC,struct tm *tm_FirstClickTime); static void Rep_DrawBarNumHits (float HitsNum,float HitsMax, unsigned MaxBarWidth); @@ -347,16 +353,17 @@ static void Rep_ShowOrPrintMyUsageReport (Rep_SeeOrPrint_t SeeOrPrint) Txt_students_ABBREVIATION); /* List my courses with this role */ - Rep_GetAndWriteCrssOfAUsr (&Gbl.Usrs.Me.UsrDat,Role); + Rep_GetAndWriteCurrentCrssOfAUsr (&Gbl.Usrs.Me.UsrDat,Role, + UsrFigures.FirstClickTimeUTC,&tm_FirstClickTime); } fprintf (Gbl.F.Out,""); } fprintf (Gbl.F.Out,""); - /***** Hits *****/ + /***** Global hits *****/ fprintf (Gbl.F.Out,"

%s

",Txt_Hits); - Rep_ShowMyHitsPerYear (UsrFigures.FirstClickTimeUTC,&tm_FirstClickTime); + Rep_ShowMyHitsPerYear (-1L,UsrFigures.FirstClickTimeUTC,&tm_FirstClickTime); // fprintf (Gbl.F.Out,"
"); // Rep_ShowMyHitsPerMonth (UsrFigures.FirstClickTimeUTC,&tm_FirstClickTime); @@ -384,7 +391,9 @@ static void Rep_PutIconToPrintMyUsageReport (void) /************************** Write courses of a user **************************/ /*****************************************************************************/ -static void Rep_GetAndWriteCrssOfAUsr (const struct UsrData *UsrDat,Rol_Role_t Role) +static void Rep_GetAndWriteCurrentCrssOfAUsr (const struct UsrData *UsrDat,Rol_Role_t Role, + time_t FirstClickTimeUTC, + struct tm *tm_FirstClickTime) { char Query[1024]; MYSQL_RES *mysql_res; @@ -424,7 +433,7 @@ static void Rep_GetAndWriteCrssOfAUsr (const struct UsrData *UsrDat,Rol_Role_t R row = mysql_fetch_row (mysql_res); /* Write data of this course */ - Rep_WriteRowCrsData (row); + Rep_WriteRowCrsData (row,FirstClickTimeUTC,tm_FirstClickTime); } /* End table */ @@ -439,7 +448,9 @@ static void Rep_GetAndWriteCrssOfAUsr (const struct UsrData *UsrDat,Rol_Role_t R /************** Write the data of a course (result of a query) ***************/ /*****************************************************************************/ -static void Rep_WriteRowCrsData (MYSQL_ROW row) +static void Rep_WriteRowCrsData (MYSQL_ROW row, + time_t FirstClickTimeUTC, + struct tm *tm_FirstClickTime) { extern const char *Txt_YEAR_OF_DEGREE[1+Deg_MAX_YEARS_PER_DEGREE]; extern const char *Txt_teachers_ABBREVIATION; @@ -486,20 +497,27 @@ static void Rep_WriteRowCrsData (MYSQL_ROW row) fprintf (Gbl.F.Out," %s",row[4]); /***** Write number of teachers / students in course *****/ - fprintf (Gbl.F.Out," (%u %s / %u %s)" - "", + fprintf (Gbl.F.Out," (%u %s / %u %s)
", NumTchs,Txt_teachers_ABBREVIATION, NumStds,Txt_students_ABBREVIATION); + + /***** Write hits per year for this course *****/ + Rep_ShowMyHitsPerYear (CrsCod,FirstClickTimeUTC,tm_FirstClickTime); + + fprintf (Gbl.F.Out,""); } /*****************************************************************************/ /********************** Write my hits grouped by years ***********************/ /*****************************************************************************/ -static void Rep_ShowMyHitsPerYear (time_t FirstClickTimeUTC,struct tm *tm_FirstClickTime) +static void Rep_ShowMyHitsPerYear (long CrsCod, + time_t FirstClickTimeUTC, + struct tm *tm_FirstClickTime) { char BrowserTimeZone[Dat_MAX_BYTES_TIME_ZONE+1]; char Query[1024]; + char SubQuery[128]; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned long NumRows; @@ -513,15 +531,20 @@ static void Rep_ShowMyHitsPerYear (time_t FirstClickTimeUTC,struct tm *tm_FirstC Dat_GetBrowserTimeZone (BrowserTimeZone); /***** Make the query *****/ + if (CrsCod > 0) + sprintf (SubQuery," AND CrsCod='%ld'",CrsCod); + else + SubQuery[0] = '\0'; sprintf (Query,"SELECT SQL_NO_CACHE " "YEAR(CONVERT_TZ(ClickTime,@@session.time_zone,'%s')) AS Year," "COUNT(*) FROM log_full" " WHERE ClickTime>=FROM_UNIXTIME('%ld')" - " AND UsrCod='%ld'" + " AND UsrCod='%ld'%s" " GROUP BY Year DESC", BrowserTimeZone, (long) FirstClickTimeUTC, - Gbl.Usrs.Me.UsrDat.UsrCod); + Gbl.Usrs.Me.UsrDat.UsrCod, + SubQuery); NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get clicks"); /***** Initialize first year *****/