From d86ac2c531085c12396cf672241e3363620c1b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 5 May 2016 10:01:35 +0200 Subject: [PATCH] Version 15.208.4 --- swad_changelog.h | 5 ++- swad_config.h | 4 +-- swad_photo.c | 85 ++++++++++++++++++++++++++---------------------- swad_user.c | 4 ++- 4 files changed, 55 insertions(+), 43 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index aca5f3b78..e80ebe29d 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -132,18 +132,21 @@ // TODO: In listing of courses, teachers column is before than students column. In edition of courses, students column is before teachers column. // TODO: List exam announcement as a list, like assignments. When clicking on an announcement, it will be shown alone, as now. // TODO: Check value returned by setlocale in all calls +// TODO: Integrate "Configure" link in tests at top of window, near "Edit" icon. +// TODO: Write "Tab > Action" in title of text in most frequent actions /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.208.3 (2016-05-03)" +#define Log_PLATFORM_VERSION "SWAD 15.208.4 (2016-05-05)" #define CSS_FILE "swad15.204.1.css" #define JS_FILE "swad15.197.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 15.208.4: May 05, 2016 In Statistics > Degrees, show all degrees with students. (201458 lines) Version 15.208.3: May 03, 2016 Fixed bug in sessions database table when no social publishings available. (201446 lines) Version 15.208.2: May 01, 2016 Add default values in some database fields. (201439 lines) 1 change necessary in database: diff --git a/swad_config.h b/swad_config.h index cc2ea0af6..255ed5ff8 100644 --- a/swad_config.h +++ b/swad_config.h @@ -232,7 +232,7 @@ #define Cfg_PLATFORM_LOGO_SMALL_FILENAME "swad64x64.png" // Logo displayed in the top of the page #define Cfg_PLATFORM_LOGO_SMALL_WIDTH 40 #define Cfg_PLATFORM_LOGO_SMALL_HEIGHT 40 -#define Cfg_PLATFORM_LOGO_BIG_FILENAME "swad212x40.png" +#define Cfg_PLATFORM_LOGO_BIG_FILENAME "SWADberry212x40.png" #define Cfg_PLATFORM_LOGO_BIG_WIDTH 212 #define Cfg_PLATFORM_LOGO_BIG_HEIGHT 40 @@ -286,7 +286,7 @@ /* Users */ #define Cfg_MAX_USRS_IN_LIST 20000 // If the number of users in a list is greater than this, don't show the list #define Cfg_MIN_NUM_USERS_TO_CONFIRM_SHOW_BIG_LIST 500 // If the number of users in a list is greater than this, ask me for confirmation before showing the list -#define Cfg_MIN_PHOTOS_TO_COMPUTE_AVERAGE 10 // If the number of students with photo in a degree is less than this, don't show average photo of the degree +#define Cfg_MIN_PHOTOS_TO_SHOW_AVERAGE 10 // If the number of students with photo in a degree is less than this, don't show average photo of the degree #define Cfg_MAX_RECIPIENTS 250 // A student can not send a message to more than this number of recipients #define Cfg_MAX_CONNECTED_SHOWN 15 // Show (in right column) only these connected users with more recent activity diff --git a/swad_photo.c b/swad_photo.c index 68820664c..f9d035852 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -1426,47 +1426,46 @@ static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,struct ListUsers if (Fil_CheckIfPathExists (PathRelAvgPhoto)) // If file exists unlink (PathRelAvgPhoto); - if (LstUsrs->NumUsrs >= Cfg_MIN_PHOTOS_TO_COMPUTE_AVERAGE) + /***** Build names for text file with photo paths *****/ + sprintf (FileNamePhotoNames,"%s/%s/%s/%ld.txt", + Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP,DegCod); + if ((FilePhotoNames = fopen (FileNamePhotoNames,"wb")) == NULL) + Lay_ShowErrorAndExit ("Can not open file to compute average photo."); + + /***** Loop writing file names in text file *****/ + for (NumUsr = 0; + NumUsr < LstUsrs->NumUsrs; + NumUsr++) { - /***** Build names for text file with photo paths *****/ - sprintf (FileNamePhotoNames,"%s/%s/%s/%ld.txt", - Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP,DegCod); - if ((FilePhotoNames = fopen (FileNamePhotoNames,"wb")) == NULL) - Lay_ShowErrorAndExit ("Can not open file to compute average photo."); + Gbl.Usrs.Other.UsrDat.Sex = LstUsrs->Lst[NumUsr].Sex; + if (Sex == Usr_SEX_ALL || Sex == Gbl.Usrs.Other.UsrDat.Sex) + { + (*NumStds)++; - /***** Loop writing file names in text file *****/ - for (NumUsr = 0; - NumUsr < LstUsrs->NumUsrs; - NumUsr++) - { - Gbl.Usrs.Other.UsrDat.Sex = LstUsrs->Lst[NumUsr].Sex; - if (Sex == Usr_SEX_ALL || Sex == Gbl.Usrs.Other.UsrDat.Sex) - { - (*NumStds)++; + /***** Add photo to file for average face calculation *****/ + Gbl.Usrs.Other.UsrDat.UsrCod = LstUsrs->Lst[NumUsr].UsrCod; + if (Pho_CheckIfPrivPhotoExists (Gbl.Usrs.Other.UsrDat.UsrCod,PathPrivRelPhoto)) + { + (*NumStdsWithPhoto)++; + fprintf (FilePhotoNames,"%s\n",PathPrivRelPhoto); + } + } + } + fclose (FilePhotoNames); - /***** Add photo to file for average face calculation *****/ - Gbl.Usrs.Other.UsrDat.UsrCod = LstUsrs->Lst[NumUsr].UsrCod; - if (Pho_CheckIfPrivPhotoExists (Gbl.Usrs.Other.UsrDat.UsrCod,PathPrivRelPhoto)) - { - (*NumStdsWithPhoto)++; - fprintf (FilePhotoNames,"%s\n",PathPrivRelPhoto); - } - } - } - fclose (FilePhotoNames); + /***** Call to program to calculate average photo *****/ + if (*NumStdsWithPhoto) + { + sprintf (StrCallToProgram,"%s %s %s", + Pho_StrAvgPhotoPrograms[TypeOfAverage], + FileNamePhotoNames,PathRelAvgPhoto); + ReturnCode = system (StrCallToProgram); + if (ReturnCode == -1) + Lay_ShowErrorAndExit ("Error when running program that computes the average photo."); - /***** Call to program to calculate average photo *****/ - if (*NumStdsWithPhoto >= Cfg_MIN_PHOTOS_TO_COMPUTE_AVERAGE) - { - sprintf (StrCallToProgram,"%s %s %s",Pho_StrAvgPhotoPrograms[TypeOfAverage],FileNamePhotoNames,PathRelAvgPhoto); - ReturnCode = system (StrCallToProgram); - if (ReturnCode == -1) - Lay_ShowErrorAndExit ("Error when running program that computes the average photo."); - - /* Write message depending on the return code */ - if (WEXITSTATUS(ReturnCode)) - Lay_ShowErrorAndExit ("The average photo has not been computed successfully."); - } + /* Write message depending on the return code */ + if (WEXITSTATUS(ReturnCode)) + Lay_ShowErrorAndExit ("The average photo has not been computed successfully."); } /***** Time used to compute the stats of this degree *****/ @@ -1545,7 +1544,9 @@ void Pho_ShowOrPrintPhotoDegree (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint) Pho_PutLinkToCalculateDegreeStats (); } - /***** Get maximum number of students and maximum number of students with photo in all degrees *****/ + /***** Get maximum number of students + and maximum number of students with photo + in all degrees *****/ Pho_GetMaxStdsPerDegree (); /***** Draw the classphoto/list *****/ @@ -1925,6 +1926,7 @@ static void Pho_ShowOrPrintClassPhotoDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrin unsigned NumDegsNotEmpty; int NumStds; int NumStdsWithPhoto; + bool ShowDegPhoto; bool TRIsOpen = false; /***** Get degrees from database *****/ @@ -1960,8 +1962,13 @@ static void Pho_ShowOrPrintClassPhotoDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrin /* Get number of students and number of students with photo in this degree */ Pho_GetNumStdsInDegree (Deg.DegCod,Usr_SEX_ALL,&NumStds,&NumStdsWithPhoto); + if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) + ShowDegPhoto = (NumStds > 0); + else + ShowDegPhoto = (NumStds > 0 && + NumStdsWithPhoto >= Cfg_MIN_PHOTOS_TO_SHOW_AVERAGE); - if (NumStds > 0) + if (ShowDegPhoto) { if ((NumDegsNotEmpty % Gbl.Usrs.ClassPhoto.Cols) == 0) { diff --git a/swad_user.c b/swad_user.c index deb56d17f..72a87d5e2 100644 --- a/swad_user.c +++ b/swad_user.c @@ -4407,7 +4407,9 @@ void Usr_GetUnorderedStdsCodesInDeg (long DegCod) /***** Get the students in a degree from database *****/ sprintf (Query,"SELECT DISTINCT crs_usr.UsrCod,'N',usr_data.Sex" " FROM courses,crs_usr,usr_data" - " WHERE courses.DegCod='%ld' AND courses.CrsCod=crs_usr.CrsCod AND crs_usr.Role='%u'" + " WHERE courses.DegCod='%ld'" + " AND courses.CrsCod=crs_usr.CrsCod" + " AND crs_usr.Role='%u'" " AND crs_usr.UsrCod=usr_data.UsrCod", DegCod,(unsigned) Rol_STUDENT);