diff --git a/swad_action.c b/swad_action.c
index 2fdd2dbf..134541cb 100644
--- a/swad_action.c
+++ b/swad_action.c
@@ -5186,7 +5186,7 @@ void Act_AdjustCurrentAction (void)
/* If there are some group types with mandatory enrolment and groups in this course,
and I don't belong to any of those groups,
the the only action possible is show a form to register in groups */
- if (Grp_NumGrpTypesMandatIDontBelong ()) // To do: if this query is too slow ==> put it only when login.
+ if (Grp_NumGrpTypesMandatIDontBelongAsStd ()) // To do: if this query is too slow ==> put it only when login.
{
Gbl.Action.Act = ActReqSelGrp;
Tab_SetCurrentTab ();
diff --git a/swad_centre.c b/swad_centre.c
index 757d6244..6d06cbd8 100644
--- a/swad_centre.c
+++ b/swad_centre.c
@@ -2518,8 +2518,7 @@ static void Ctr_PutHeadCentresForSeeing (bool OrderSelectable)
extern const char *Txt_Place;
extern const char *Txt_Degrees_ABBREVIATION;
extern const char *Txt_Courses_ABBREVIATION;
- extern const char *Txt_Teachers_ABBREVIATION;
- extern const char *Txt_Students_ABBREVIATION;
+ extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
Ctr_Order_t Order;
fprintf (Gbl.F.Out,"
",
- Txt_Type_BR_of_group,
- Txt_Group_name,Txt_eg_A_B,
- Txt_Max_BR_students,
- Txt_Students_ABBREVIATION);
+ Txt_Max_BR_students);
}
/*****************************************************************************/
@@ -1857,7 +1865,7 @@ static bool Grp_ListGrpsForChange (struct GroupType *GrpTyp,
if (Grp->Open) // If group is open
{
if (IBelongToThisGroup || // I belong to group
- Grp->NumStudents < Grp->MaxStudents) // Group is not full
+ Grp->NumUsrs[Rol_STD] < Grp->MaxStudents) // Group is not full
ICanChangeMySelection = true; // I can register/unregister in this group
else // I don't belong to group and it's full
fprintf (Gbl.F.Out," disabled=\"disabled\""); // I can not register in this group
@@ -1990,12 +1998,13 @@ static void Grp_ListGrpsToAddOrRemUsrs (struct GroupType *GrpTyp,long UsrCod)
static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp)
{
- extern const char *Txt_students_with_no_group;
+ extern const char *Txt_users_with_no_group;
unsigned NumGrpThisType;
unsigned NumGrpSel;
struct ListCodGrps LstGrpsIBelong;
bool IBelongToThisGroup;
struct Group *Grp;
+ Rol_Role_t Role;
/***** Write heading *****/
Grp_WriteGrpHead (GrpTyp);
@@ -2071,20 +2080,24 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp)
"");
/* Group name = students with no group */
- fprintf (Gbl.F.Out,"
"
+ fprintf (Gbl.F.Out,"
"
""
"
",
- -(GrpTyp->GrpTypCod),Txt_students_with_no_group);
+ -(GrpTyp->GrpTypCod),Txt_users_with_no_group);
/* Number of students who don't belong to any group of this type */
- fprintf (Gbl.F.Out,"
"
- "%u"
- "
",
- Grp_CountNumStdsInNoGrpsOfType (GrpTyp->GrpTypCod));
+ for (Role = Rol_TCH;
+ Role >= Rol_STD;
+ Role--)
+ fprintf (Gbl.F.Out,"
"
+ "%u"
+ "
",
+ Grp_CountNumUsrsInNoGrpsOfType (Role,GrpTyp->GrpTypCod));
- /* Last column */
+ /* Last void columns for max. students and vacants */
fprintf (Gbl.F.Out,"
",
- Txt_Group,
Txt_Max_BR_students,
- Txt_Students_ABBREVIATION,
Txt_Vacants);
}
@@ -2154,6 +2171,7 @@ static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight)
extern const char *Txt_Group_X_open;
extern const char *Txt_Group_X_closed;
int Vacant;
+ Rol_Role_t Role;
/***** Write icon to show if group is open or closed *****/
sprintf (Gbl.Title,Grp->Open ? Txt_Group_X_open :
@@ -2184,6 +2202,20 @@ static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight)
Grp->GrpCod,
Grp->GrpName);
+ /***** Current number of users in this group *****/
+ for (Role = Rol_TCH;
+ Role >= Rol_STD;
+ Role--)
+ {
+ fprintf (Gbl.F.Out,"
"
+ "%d"
+ "
",
+ Grp->NumUsrs[Role]);
+ }
+
/***** Max. number of students in this group *****/
fprintf (Gbl.F.Out,"
");
- /***** Current number of students in this group *****/
- fprintf (Gbl.F.Out,"
"
- "%d"
- "
",
- Grp->NumStudents);
-
/***** Vacants in this group *****/
fprintf (Gbl.F.Out,"
",
Grp_MAX_CHARS_GROUP_NAME,Gbl.CurrentCrs.Grps.GrpName);
+ /***** Current number of users in this group *****/
+ for (Role = Rol_TCH;
+ Role >= Rol_STD;
+ Role--)
+ fprintf (Gbl.F.Out,"
"
+ "0"
+ "
");
+
/***** Maximum number of students *****/
fprintf (Gbl.F.Out,"
"
""
- "
");
-
- /***** Current number of students in this group *****/
- fprintf (Gbl.F.Out,"
"
- "0" // It's a new group ==> 0 students
- "
"
- "");
+ ""
+ "");
/***** Send button and end frame *****/
Lay_EndRoundFrameTableWithButton (Lay_CREATE_BUTTON,Txt_Create_group);
@@ -2600,6 +2625,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
unsigned long NumRows;
struct GroupType *GrpTyp;
struct Group *Grp;
+ Rol_Role_t Role;
/***** First we get the list of group types *****/
Grp_GetListGrpTypesInThisCrs (WhichGroupTypes);
@@ -2640,9 +2666,14 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
Str_Copy (Grp->GrpName,row[1],
Grp_MAX_BYTES_GROUP_NAME);
- /* Get max number of students of group (row[2]) and number of current students */
+ /* Get max number of students of group (row[2]) */
Grp->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[2]);
- Grp->NumStudents = Grp_CountNumStdsInGrp (Grp->GrpCod);
+
+ /* Get number of current users in group */
+ for (Role = Rol_TCH;
+ Role >= Rol_STD;
+ Role--)
+ Grp->NumUsrs[Role] = Grp_CountNumUsrsInGrp (Role,Grp->GrpCod);
/* Get whether group is open ('Y') or closed ('N') (row[3]) */
Grp->Open = (row[3][0] == 'Y');
@@ -2938,10 +2969,10 @@ bool Grp_CheckIfGroupBelongsToCourse (long GrpCod,long CrsCod)
}
/*****************************************************************************/
-/******************** Count number of students in a group ********************/
+/********************* Count number of users in a group **********************/
/*****************************************************************************/
-unsigned Grp_CountNumStdsInGrp (long GrpCod)
+unsigned Grp_CountNumUsrsInGrp (Rol_Role_t Role,long GrpCod)
{
char Query[512];
@@ -2954,23 +2985,23 @@ unsigned Grp_CountNumStdsInGrp (long GrpCod)
" AND crs_grp_types.CrsCod=crs_usr.CrsCod"
" AND crs_grp_usr.UsrCod=crs_usr.UsrCod"
" AND crs_usr.Role=%u",
- GrpCod,(unsigned) Rol_STD);
+ GrpCod,(unsigned) Role);
return (unsigned) DB_QueryCOUNT (Query,
- "can not get number of students in a group");
+ "can not get number of users in a group");
}
/*****************************************************************************/
-/** Count # of students of current course not belonging to groups of a type **/
+/*** Count # of users of current course not belonging to groups of a type ****/
/*****************************************************************************/
-static unsigned Grp_CountNumStdsInNoGrpsOfType (long GrpTypCod)
+static unsigned Grp_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod)
{
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
- unsigned NumStds;
+ unsigned NumUsrs;
- /***** Get number of students not belonging to groups of a type from database ******/
+ /***** Get number of users not belonging to groups of a type ******/
sprintf (Query,"SELECT COUNT(UsrCod) FROM crs_usr"
" WHERE CrsCod=%ld AND Role=%u"
" AND UsrCod NOT IN"
@@ -2978,18 +3009,20 @@ static unsigned Grp_CountNumStdsInNoGrpsOfType (long GrpTypCod)
" FROM crs_grp,crs_grp_usr"
" WHERE crs_grp.GrpTypCod=%ld"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod)",
- Gbl.CurrentCrs.Crs.CrsCod,(unsigned) Rol_STD,GrpTypCod);
- DB_QuerySELECT (Query,&mysql_res,"can not get the number of students not belonging to groups of a type");
+ Gbl.CurrentCrs.Crs.CrsCod,(unsigned) Role,GrpTypCod);
+ DB_QuerySELECT (Query,&mysql_res,"can not get the number of users"
+ " not belonging to groups of a type");
- /***** Get the number of students (row[0]) *****/
+ /***** Get the number of users (row[0]) *****/
row = mysql_fetch_row (mysql_res);
- if (sscanf (row[0],"%u",&NumStds) != 1)
- Lay_ShowErrorAndExit ("Error when getting the number of students not belonging to groups of a type.");
+ if (sscanf (row[0],"%u",&NumUsrs) != 1)
+ Lay_ShowErrorAndExit ("Error when getting the number of users"
+ " not belonging to groups of a type.");
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
- return NumStds;
+ return NumUsrs;
}
/*****************************************************************************/
@@ -3053,12 +3086,13 @@ bool Grp_GetIfIBelongToGrp (long GrpCod)
/**** and I don't belong to any of these groups as student *****/
/*****************************************************************************/
-unsigned Grp_NumGrpTypesMandatIDontBelong (void)
+unsigned Grp_NumGrpTypesMandatIDontBelongAsStd (void)
{
char Query[4096];
unsigned NumGrpTypes;
- /***** Get the number of types of groups with mandatory enrolment which I don't belong to, from database *****/
+ /***** Get the number of types of groups with mandatory enrolment
+ which I don't belong to as student, from database *****/
sprintf (Query,"SELECT COUNT(DISTINCT GrpTypCod) FROM"
" (SELECT crs_grp_types.GrpTypCod AS GrpTypCod,"
"COUNT(*) AS NumStudents,"
@@ -3086,7 +3120,9 @@ unsigned Grp_NumGrpTypesMandatIDontBelong (void)
(unsigned) Rol_STD,
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
- NumGrpTypes = DB_QueryCOUNT (Query,"can not get the number of types of group of mandatory registration to which you don't belong to");
+ NumGrpTypes = DB_QueryCOUNT (Query,"can not get the number of types of group"
+ " of mandatory registration"
+ " to which you don't belong to");
return NumGrpTypes;
}
@@ -3586,7 +3622,7 @@ static void Grp_AskConfirmRemGrp (void)
Grp_GetDataOfGroupByCod (&GrpDat);
/***** Count number of students in group *****/
- NumStds = Grp_CountNumStdsInGrp (Gbl.CurrentCrs.Grps.GrpCod);
+ NumStds = Grp_CountNumUsrsInGrp (Rol_STD,Gbl.CurrentCrs.Grps.GrpCod);
/***** Show the form to edit group types again *****/
Grp_ReqEditGroupsInternal0 ();
@@ -4149,9 +4185,7 @@ void Grp_ChangeMaxStdsGrp (void)
static void Grp_WriteMaxStdsGrp (unsigned MaxStudents)
{
- if (MaxStudents > Grp_MAX_STUDENTS_IN_A_GROUP)
- fprintf (Gbl.F.Out,"-");
- else
+ if (MaxStudents <= Grp_MAX_STUDENTS_IN_A_GROUP)
fprintf (Gbl.F.Out,"%u",MaxStudents);
}
diff --git a/swad_group.h b/swad_group.h
index e2910ffb..7339fe17 100644
--- a/swad_group.h
+++ b/swad_group.h
@@ -73,8 +73,8 @@ struct Group
{
long GrpCod; // Code of group
char GrpName[Grp_MAX_BYTES_GROUP_NAME + 1]; // Name of group
+ unsigned NumUsrs[Rol_NUM_ROLES]; // Number of users in the group
unsigned MaxStudents;
- unsigned NumStudents; // Number of students in the group
bool Open; // Group is open?
bool FileZones; // Group has file zones?
bool ShowFileZone; // Show file zone of this group?
@@ -165,9 +165,9 @@ unsigned long Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res);
void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat);
bool Grp_CheckIfGroupExists (long GrpCod);
bool Grp_CheckIfGroupBelongsToCourse (long GrpCod,long CrsCod);
-unsigned Grp_CountNumStdsInGrp (long GrpCod);
+unsigned Grp_CountNumUsrsInGrp (Rol_Role_t Role,long GrpCod);
bool Grp_GetIfIBelongToGrp (long GrpCod);
-unsigned Grp_NumGrpTypesMandatIDontBelong (void);
+unsigned Grp_NumGrpTypesMandatIDontBelongAsStd (void);
void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps);
void Grp_GetNamesGrpsStdBelongsTo (long GrpTypCod,long UsrCod,char *GrpNames);
void Grp_RecFormNewGrpTyp (void);
diff --git a/swad_indicator.c b/swad_indicator.c
index a99ab4b9..8ee21d8b 100644
--- a/swad_indicator.c
+++ b/swad_indicator.c
@@ -677,8 +677,7 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat
extern const char *Txt_Course;
extern const char *Txt_Institutional_BR_code;
extern const char *Txt_Web_page_of_the_course;
- extern const char *Txt_Teachers_ABBREVIATION;
- extern const char *Txt_Students_ABBREVIATION;
+ extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
extern const char *Txt_Indicators;
extern const char *Txt_No_INDEX;
extern const char *Txt_Syllabus_of_the_course;
@@ -930,8 +929,8 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat
Txt_Course,
Txt_Institutional_BR_code,
Txt_Web_page_of_the_course,
- Txt_Teachers_ABBREVIATION,
- Txt_Students_ABBREVIATION,
+ Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH],
+ Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD],
Txt_Indicators,
Txt_No_INDEX,
diff --git a/swad_institution.c b/swad_institution.c
index f7213df9..9e5958e6 100644
--- a/swad_institution.c
+++ b/swad_institution.c
@@ -828,8 +828,7 @@ static void Ins_PutHeadInstitutionsForSeeing (bool OrderSelectable)
{
extern const char *Txt_INSTITUTIONS_HELP_ORDER[2];
extern const char *Txt_INSTITUTIONS_ORDER[2];
- extern const char *Txt_Teachers_ABBREVIATION;
- extern const char *Txt_Students_ABBREVIATION;
+ extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
extern const char *Txt_Centres_ABBREVIATION;
extern const char *Txt_Degrees_ABBREVIATION;
extern const char *Txt_Courses_ABBREVIATION;
@@ -885,7 +884,8 @@ static void Ins_PutHeadInstitutionsForSeeing (bool OrderSelectable)
Txt_Degrees_ABBREVIATION,
Txt_Courses_ABBREVIATION,
Txt_Departments_ABBREVIATION,
- Txt_Teachers_ABBREVIATION,Txt_Students_ABBREVIATION);
+ Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH],
+ Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]);
}
/*****************************************************************************/
@@ -2240,8 +2240,7 @@ static void Ins_PutHeadInstitutionsForEdition (void)
extern const char *Txt_WWW;
extern const char *Txt_Users;
extern const char *Txt_Centres_ABBREVIATION;
- extern const char *Txt_Teachers_ABBREVIATION;
- extern const char *Txt_Students_ABBREVIATION;
+ extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
extern const char *Txt_Requester;
fprintf (Gbl.F.Out,"