diff --git a/swad_changelog.h b/swad_changelog.h index d04e67f4b..25e40721a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -233,13 +233,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.220.2 (2017-05-21)" +#define Log_PLATFORM_VERSION "SWAD 16.220.3 (2017-05-21)" #define CSS_FILE "swad16.209.3.css" #define JS_FILE "swad16.206.3.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.220.3: May 21, 2017 Changes related with new role. Not finished. (219327 lines) Version 16.220.2: May 21, 2017 Changes related with new role. Not finished. (219319 lines) Version 16.220.1: May 20, 2017 Changes related with new role. Not finished. (219332 lines) Version 16.220: May 19, 2017 Changes permission of actions after creating new role. Not finished. (219227 lines) diff --git a/swad_course.c b/swad_course.c index 7c674306b..921eb5f9b 100644 --- a/swad_course.c +++ b/swad_course.c @@ -1285,13 +1285,16 @@ static bool Crs_ListCoursesOfAYearForSeeing (unsigned Year) fprintf (Gbl.F.Out,"" "%u" "", - TxtClassNormal,BgColor,Crs->NumUsrs[Rol_TCH]); + TxtClassNormal,BgColor, + Crs->NumUsrs[Rol_TCH] + + Crs->NumUsrs[Rol_NED_TCH]); /* Current number of students in this course */ fprintf (Gbl.F.Out,"" "%u" "", - TxtClassNormal,BgColor,Crs->NumUsrs[Rol_STD]); + TxtClassNormal,BgColor, + Crs->NumUsrs[Rol_STD]); /* Course status */ StatusTxt = Crs_GetStatusTxtFromStatusBits (Crs->Status); @@ -1509,7 +1512,8 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) fprintf (Gbl.F.Out,"" "%u" "", - Crs->NumUsrs[Rol_TCH]); + Crs->NumUsrs[Rol_TCH] + + Crs->NumUsrs[Rol_NED_TCH]); /* Current number of students in this course */ fprintf (Gbl.F.Out,"" @@ -1987,9 +1991,10 @@ bool Crs_GetDataOfCourseByCod (struct Course *Crs) Crs->RequesterUsrCod = -1L; Crs->ShrtName[0] = '\0'; Crs->FullName[0] = '\0'; - Crs->NumUsrs[Rol_UNK] = 0; - Crs->NumUsrs[Rol_STD] = 0; - Crs->NumUsrs[Rol_TCH] = 0; + Crs->NumUsrs[Rol_UNK ] = + Crs->NumUsrs[Rol_STD ] = + Crs->NumUsrs[Rol_NED_TCH] = + Crs->NumUsrs[Rol_TCH ] = 0; /***** Check if course code is correct *****/ if (Crs->CrsCod > 0) @@ -2050,15 +2055,13 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row) Str_Copy (Crs->FullName,row[7], Hie_MAX_BYTES_FULL_NAME); - /***** Get number of students *****/ - Crs->NumUsrs[Rol_STD] = Usr_GetNumUsrsInCrs (Rol_STD,Crs->CrsCod); - - /***** Get number of teachers *****/ - Crs->NumUsrs[Rol_TCH] = Usr_GetNumUsrsInCrs (Rol_TCH,Crs->CrsCod); - - /***** Compute total of users in course *****/ - Crs->NumUsrs[Rol_UNK] = Crs->NumUsrs[Rol_STD] + - Crs->NumUsrs[Rol_TCH]; + /***** Get number of users *****/ + Crs->NumUsrs[Rol_STD ] = Usr_GetNumUsrsInCrs (Rol_STD ,Crs->CrsCod); + Crs->NumUsrs[Rol_NED_TCH] = Usr_GetNumUsrsInCrs (Rol_NED_TCH,Crs->CrsCod); + Crs->NumUsrs[Rol_TCH ] = Usr_GetNumUsrsInCrs (Rol_TCH ,Crs->CrsCod); + Crs->NumUsrs[Rol_UNK ] = Crs->NumUsrs[Rol_STD ] + + Crs->NumUsrs[Rol_NED_TCH] + + Crs->NumUsrs[Rol_TCH ]; } /*****************************************************************************/ @@ -2783,6 +2786,7 @@ void Crs_ContEditAfterChgCrs (void) false); break; case Rol_STD: + case Rol_NED_TCH: case Rol_TCH: if (Gbl.Degs.EditingCrs.CrsCod != Gbl.CurrentCrs.Crs.CrsCod) PutButtonToRequestRegistration = !Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Me.UsrDat.UsrCod, @@ -3158,8 +3162,9 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA Lay_ShowErrorAndExit ("Wrong code of course."); /***** Get number of teachers and students in this course *****/ - NumTchs = Usr_GetNumUsrsInCrs (Rol_TCH,CrsCod); - NumStds = Usr_GetNumUsrsInCrs (Rol_STD,CrsCod); + NumTchs = Usr_GetNumUsrsInCrs (Rol_TCH ,CrsCod) + + Usr_GetNumUsrsInCrs (Rol_NED_TCH,CrsCod); + NumStds = Usr_GetNumUsrsInCrs (Rol_STD ,CrsCod); if (NumTchs + NumStds) { Style = "DAT_N"; @@ -3255,16 +3260,14 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA void Crs_UpdateCrsLast (void) { - char Query[256]; + char Query[128]; if (Gbl.CurrentCrs.Crs.CrsCod > 0 && Gbl.Usrs.Me.LoggedRole >= Rol_STD) { /***** Update my last access to current course *****/ - sprintf (Query,"REPLACE INTO crs_last" - " (CrsCod,LastTime)" - " VALUES" - " (%ld,NOW())", + sprintf (Query,"REPLACE INTO crs_last (CrsCod,LastTime)" + " VALUES (%ld,NOW())", Gbl.CurrentCrs.Crs.CrsCod); DB_QueryUPDATE (Query,"can not update last access to current course"); } diff --git a/swad_degree.c b/swad_degree.c index a479bcc28..51271120e 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -84,6 +84,7 @@ typedef enum static void Deg_Configuration (bool PrintView); static void Deg_PutIconsToPrintAndUpload (void); +static void Deg_ShowNumUsrsInCrssOfDeg (Rol_Role_t Role); static void Deg_ListDegreesForEdition (void); static bool Deg_CheckIfICanEditADegree (struct Degree *Deg); @@ -288,7 +289,6 @@ static void Deg_Configuration (bool PrintView) extern const char *Txt_Courses; extern const char *Txt_Courses_of_DEGREE_X; extern const char *Txt_QR_code; - extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; unsigned NumCtr; bool PutLink = !PrintView && Gbl.CurrentDeg.Deg.WWW[0]; @@ -514,31 +514,11 @@ static void Deg_Configuration (bool PrintView) fprintf (Gbl.F.Out,"" ""); - /***** Number of teachers *****/ - fprintf (Gbl.F.Out,"" - "" - "%s:" - "" - "" - "%u" - "" - "", - The_ClassForm[Gbl.Prefs.Theme], - Txt_ROLES_PLURAL_Abc[Rol_TCH][Usr_SEX_UNKNOWN], - Usr_GetNumUsrsInCrssOfDeg (Rol_TCH,Gbl.CurrentDeg.Deg.DegCod)); - - /***** Number of students *****/ - fprintf (Gbl.F.Out,"" - "" - "%s:" - "" - "" - "%u" - "" - "", - The_ClassForm[Gbl.Prefs.Theme], - Txt_ROLES_PLURAL_Abc[Rol_STD][Usr_SEX_UNKNOWN], - Usr_GetNumUsrsInCrssOfDeg (Rol_STD,Gbl.CurrentDeg.Deg.DegCod)); + /***** Number of users *****/ + Deg_ShowNumUsrsInCrssOfDeg (Rol_TCH); + Deg_ShowNumUsrsInCrssOfDeg (Rol_NED_TCH); + Deg_ShowNumUsrsInCrssOfDeg (Rol_STD); + Deg_ShowNumUsrsInCrssOfDeg (Rol_UNK); } /***** End table *****/ @@ -565,6 +545,30 @@ static void Deg_PutIconsToPrintAndUpload (void) Log_PutIconToChangeLogo (Sco_SCOPE_DEG); } +/*****************************************************************************/ +/***************** Number of users in courses of this degree *****************/ +/*****************************************************************************/ + +static void Deg_ShowNumUsrsInCrssOfDeg (Rol_Role_t Role) + { + extern const char *The_ClassForm[The_NUM_THEMES]; + extern const char *Txt_Users_in_courses; + extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; + + fprintf (Gbl.F.Out,"" + "" + "%s:" + "" + "" + "%u" + "" + "", + The_ClassForm[Gbl.Prefs.Theme], + (Role == Rol_UNK) ? Txt_Users_in_courses : + Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN], + Usr_GetNumUsrsInCrssOfDeg (Role,Gbl.CurrentDeg.Deg.DegCod)); + } + /*****************************************************************************/ /*************************** Write selector of degree ************************/ /*****************************************************************************/