Version 16.121

This commit is contained in:
Antonio Cañas Vargas 2017-01-19 20:55:31 +01:00
parent 796c3c8039
commit 9f87096859
11 changed files with 120 additions and 160 deletions

View File

@ -1401,7 +1401,7 @@ void Asg_RecFormAssignment (void)
if (NewAssignmentIsCorrect) if (NewAssignmentIsCorrect)
{ {
/* Get groups for this assignments */ /* Get groups for this assignments */
Grp_GetParCodsSeveralGrpsToEditAsgAttOrSvy (); Grp_GetParCodsSeveralGrps ();
if (ItsANewAssignment) if (ItsANewAssignment)
{ {
@ -1600,7 +1600,7 @@ static void Asg_CreateGrps (long AsgCod)
{ {
/* Create group */ /* Create group */
sprintf (Query,"INSERT INTO asg_grp (AsgCod,GrpCod) VALUES ('%ld','%ld')", sprintf (Query,"INSERT INTO asg_grp (AsgCod,GrpCod) VALUES ('%ld','%ld')",
AsgCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrpSel]); AsgCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
DB_QueryINSERT (Query,"can not associate a group to an assignment"); DB_QueryINSERT (Query,"can not associate a group to an assignment");
} }
} }

View File

@ -1338,7 +1338,7 @@ void Att_RecFormAttEvent (void)
if (ReceivedAttEventIsCorrect) if (ReceivedAttEventIsCorrect)
{ {
/* Get groups for this attendance events */ /* Get groups for this attendance events */
Grp_GetParCodsSeveralGrpsToEditAsgAttOrSvy (); Grp_GetParCodsSeveralGrps ();
if (ItsANewAttEvent) if (ItsANewAttEvent)
{ {
@ -1520,7 +1520,7 @@ static void Att_CreateGrps (long AttCod)
{ {
/* Create group */ /* Create group */
sprintf (Query,"INSERT INTO att_grp (AttCod,GrpCod) VALUES ('%ld','%ld')", sprintf (Query,"INSERT INTO att_grp (AttCod,GrpCod) VALUES ('%ld','%ld')",
AttCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrpSel]); AttCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
DB_QueryINSERT (Query,"can not associate a group to an attendance event"); DB_QueryINSERT (Query,"can not associate a group to an attendance event");
} }
} }
@ -2980,7 +2980,7 @@ static void Att_GetListSelectedAttCods (char **StrAttCodsSelected)
NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps && NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps &&
!Gbl.AttEvents.Lst[NumAttEvent].Selected; !Gbl.AttEvents.Lst[NumAttEvent].Selected;
NumGrpSel++) NumGrpSel++)
if (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrpSel] == GrpCodInThisEvent) if (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel] == GrpCodInThisEvent)
Gbl.AttEvents.Lst[NumAttEvent].Selected = true; Gbl.AttEvents.Lst[NumAttEvent].Selected = true;
} }
else // This event is not associated to groups else // This event is not associated to groups

View File

@ -193,13 +193,15 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.120.2 (2017-01-19)" #define Log_PLATFORM_VERSION "SWAD 16.121 (2017-01-19)"
#define CSS_FILE "swad16.119.4.css" #define CSS_FILE "swad16.119.4.css"
#define JS_FILE "swad16.119.3.js" #define JS_FILE "swad16.119.3.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // 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 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
/* /*
Version 16.121: Jan 19, 2017 Fixed bug in groups selection, reported by Eva Martínez Ortigosa.
Code refactoring in groups selected. (211915 lines)
Version 16.120.2: Jan 19, 2017 Changed the question to confirm user's enrollment. (211954 lines) Version 16.120.2: Jan 19, 2017 Changed the question to confirm user's enrollment. (211954 lines)
Version 16.120.1: Jan 19, 2017 From now on, a teacher A can enroll another user B as a teacher in their courses, although user B is not yet a teacher in any course. (? lines) Version 16.120.1: Jan 19, 2017 From now on, a teacher A can enroll another user B as a teacher in their courses, although user B is not yet a teacher in any course. (? lines)
Version 16.120: Jan 19, 2017 Fixed bug when limiting length of links. (211934 lines) Version 16.120: Jan 19, 2017 Fixed bug when limiting length of links. (211934 lines)

View File

@ -1359,7 +1359,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS); Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS);
/***** Get the list of groups to which register/remove students *****/ /***** Get the list of groups to which register/remove students *****/
LstGrps.GrpCod = NULL; // Initialized to avoid bug reported by Coverity LstGrps.GrpCods = NULL; // Initialized to avoid bug reported by Coverity
LstGrps.NumGrps = 0; // Initialized to avoid bug reported by Coverity LstGrps.NumGrps = 0; // Initialized to avoid bug reported by Coverity
Grp_GetLstCodsGrpWanted (&LstGrps); Grp_GetLstCodsGrpWanted (&LstGrps);

View File

@ -3318,7 +3318,7 @@ static void Brw_FormToChangeCrsGrpZone (void)
NumGrp++) NumGrp++)
{ {
/* Get next group */ /* Get next group */
GrpDat.GrpCod = LstMyGrps.GrpCod[NumGrp]; GrpDat.GrpCod = LstMyGrps.GrpCods[NumGrp];
Grp_GetDataOfGroupByCod (&GrpDat); Grp_GetDataOfGroupByCod (&GrpDat);
/* Select this group */ /* Select this group */

View File

@ -324,7 +324,7 @@ void Gbl_InitializeGlobals (void)
Gbl.CurrentCrs.Grps.GrpName[0] = '\0'; Gbl.CurrentCrs.Grps.GrpName[0] = '\0';
Gbl.CurrentCrs.Grps.MaxStudents = INT_MAX; Gbl.CurrentCrs.Grps.MaxStudents = INT_MAX;
Gbl.CurrentCrs.Grps.Open = false; Gbl.CurrentCrs.Grps.Open = false;
Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod = NULL; Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods = NULL;
Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = 0; Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = 0;
Gbl.CurrentCrs.Grps.LstGrpsSel.NestedCalls = 0; Gbl.CurrentCrs.Grps.LstGrpsSel.NestedCalls = 0;

View File

@ -61,6 +61,7 @@ extern struct Globals Gbl;
static void Grp_EditGroupTypes (void); static void Grp_EditGroupTypes (void);
static void Grp_EditGroups (void); static void Grp_EditGroups (void);
static void Grp_ConstructorListGrpAlreadySelec (struct ListGrpsAlreadySelec **AlreadyExistsGroupOfType); static void Grp_ConstructorListGrpAlreadySelec (struct ListGrpsAlreadySelec **AlreadyExistsGroupOfType);
static void Grp_DestructorListGrpAlreadySelec (struct ListGrpsAlreadySelec **AlreadyExistsGroupOfType); static void Grp_DestructorListGrpAlreadySelec (struct ListGrpsAlreadySelec **AlreadyExistsGroupOfType);
static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod); static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod);
@ -126,7 +127,7 @@ void Grp_WriteNamesOfSelectedGrps (void)
NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps; NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps;
NumGrpSel++) NumGrpSel++)
{ {
if ((GrpCod = Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrpSel]) >= 0) if ((GrpCod = Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]) >= 0)
{ {
GrpDat.GrpCod = GrpCod; GrpDat.GrpCod = GrpCod;
Grp_GetDataOfGroupByCod (&GrpDat); Grp_GetDataOfGroupByCod (&GrpDat);
@ -242,8 +243,6 @@ void Grp_ShowFormToSelectSeveralGroups (Act_Action_t NextAction)
(Gbl.Usrs.Me.LoggedRole == Rol_TEACHER || (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM);
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">");
/***** Start frame *****/ /***** Start frame *****/
Lay_StartRoundFrame (NULL,Txt_Groups, Lay_StartRoundFrame (NULL,Txt_Groups,
ICanEdit ? Grp_PutIconToEditGroups : ICanEdit ? Grp_PutIconToEditGroups :
@ -304,7 +303,6 @@ void Grp_ShowFormToSelectSeveralGroups (Act_Action_t NextAction)
/***** End frame *****/ /***** End frame *****/
Lay_EndRoundFrame (); Lay_EndRoundFrame ();
fprintf (Gbl.F.Out,"</div>");
} }
} }
@ -332,7 +330,7 @@ void Grp_PutParamsCodGrps (void)
{ {
if (NumGrpSel) if (NumGrpSel)
fprintf (Gbl.F.Out,"%c",Par_SEPARATOR_PARAM_MULTIPLE); fprintf (Gbl.F.Out,"%c",Par_SEPARATOR_PARAM_MULTIPLE);
fprintf (Gbl.F.Out,"%ld",Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrpSel]); fprintf (Gbl.F.Out,"%ld",Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
} }
fprintf (Gbl.F.Out,"\" />"); fprintf (Gbl.F.Out,"\" />");
} }
@ -341,85 +339,47 @@ void Grp_PutParamsCodGrps (void)
/*****************************************************************************/ /*****************************************************************************/
/**************** Get parameters related to groups selected ******************/ /**************** Get parameters related to groups selected ******************/
/*****************************************************************************/ /*****************************************************************************/
// Returns number of groups in current course
// TODO: Grp_GetParCodsSeveralGrpsToEditAsgAttOrSvy is very similar to Grp_GetParCodsSeveralGrpsToShowUsrs ==> merge code
void Grp_GetParCodsSeveralGrpsToShowUsrs (void) void Grp_GetParCodsSeveralGrpsToShowUsrs (void)
{ {
char YN[1+1]; char YN[1+1];
unsigned long MaxSizeLstGrpCods;
char *LstCodGrps;
struct ListCodGrps LstGrpsIBelong; struct ListCodGrps LstGrpsIBelong;
const char *Ptr;
char LongStr[1+10+1];
unsigned NumGrp; unsigned NumGrp;
if (++Gbl.CurrentCrs.Grps.LstGrpsSel.NestedCalls > 1) // If list is created yet, there's nothing to do if (++Gbl.CurrentCrs.Grps.LstGrpsSel.NestedCalls > 1) // If list is created yet, there's nothing to do
return; return;
/***** Set default for number of groups selected by me *****/
Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = 0;
/***** Get boolean parameter that indicates if all groups must be listed *****/ /***** Get boolean parameter that indicates if all groups must be listed *****/
Par_GetParToText ("AllGroups",YN,1); Par_GetParToText ("AllGroups",YN,1);
Gbl.Usrs.ClassPhoto.AllGroups = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); Gbl.Usrs.ClassPhoto.AllGroups = (Str_ConvertToUpperLetter (YN[0]) == 'Y');
if (Gbl.CurrentCrs.Grps.NumGrps) /***** Get parameter with list of groups selected *****/
Grp_GetParCodsSeveralGrps ();
if (Gbl.CurrentCrs.Grps.NumGrps && // This course has groups and...
!Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps) // ...I haven't selected any group
{ {
/***** Allocate memory for the list of group codes *****/ /***** I I haven't selected any group, show by default the groups I belong to *****/
MaxSizeLstGrpCods = ((1+10+1) * Gbl.CurrentCrs.Grps.NumGrps) - 1; /* Get list of groups of all types in current course I belong to */
if ((LstCodGrps = (char *) malloc (MaxSizeLstGrpCods + 1)) == NULL) Grp_GetLstCodGrpsUsrBelongs (Gbl.CurrentCrs.Crs.CrsCod,-1L,
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups."); Gbl.Usrs.Me.UsrDat.UsrCod,&LstGrpsIBelong);
/***** Get parameter with list of groups to list *****/ if (LstGrpsIBelong.NumGrps)
Par_GetParMultiToText ("GrpCods",LstCodGrps,MaxSizeLstGrpCods); {
/* Allocate space for list of selected groups */
if ((Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods = (long *) calloc (LstGrpsIBelong.NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
if (LstCodGrps[0]) /* Fill list of selected groups with list of groups I belong to */
{ for (NumGrp = 0;
/***** Count number of groups selected from LstCodGrps *****/ NumGrp < LstGrpsIBelong.NumGrps;
for (Ptr = LstCodGrps, NumGrp = 0; NumGrp++)
*Ptr; Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrp] = LstGrpsIBelong.GrpCods[NumGrp];
NumGrp++) Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = LstGrpsIBelong.NumGrps;
Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,1+10); }
Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = NumGrp;
}
if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps) // If I have selected groups... /* Free list of groups I belong to */
{ Grp_FreeListCodGrp (&LstGrpsIBelong);
/***** Create a list of groups selected from LstCodGrps *****/
if ((Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod = (long *) calloc (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
for (Ptr = LstCodGrps, NumGrp = 0;
*Ptr;
NumGrp++)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,1+10);
Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrp] = Str_ConvertStrCodToLongCod (LongStr);
}
}
else // If I haven't selected any group...
{
/***** I I haven't selected any group, show by default the groups I belong to *****/
if (Gbl.CurrentCrs.Grps.NumGrps)
{
Grp_GetLstCodGrpsUsrBelongs (Gbl.CurrentCrs.Crs.CrsCod,-1L,
Gbl.Usrs.Me.UsrDat.UsrCod,&LstGrpsIBelong);
if (LstGrpsIBelong.NumGrps)
{
if ((Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod = (long *) calloc (LstGrpsIBelong.NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
for (NumGrp = 0;
NumGrp < LstGrpsIBelong.NumGrps;
NumGrp++)
Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrp] = LstGrpsIBelong.GrpCod[NumGrp];
Grp_FreeListCodGrp (&LstGrpsIBelong);
Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = LstGrpsIBelong.NumGrps;
}
}
}
/***** Free memory used for the list of groups to show *****/
free ((void *) LstCodGrps);
} }
/***** If no groups selected ==> show all groups *****/ /***** If no groups selected ==> show all groups *****/
@ -428,57 +388,55 @@ void Grp_GetParCodsSeveralGrpsToShowUsrs (void)
} }
/*****************************************************************************/ /*****************************************************************************/
/***************** Get parameters related to groups selected *****************/ /**************** Get parameter with list of groups selected *****************/
/*****************************************************************************/ /*****************************************************************************/
// TODO: Grp_GetParCodsSeveralGrpsToEditAsgAttOrSvy is very similar to Grp_GetParCodsSeveralGrpsToShowUsrs ==> merge code
void Grp_GetParCodsSeveralGrpsToEditAsgAttOrSvy (void) void Grp_GetParCodsSeveralGrps (void)
{ {
unsigned long MaxSizeLstGrpCods; char *ParamLstCodGrps;
char *LstCodGrps;
const char *Ptr; const char *Ptr;
char LongStr[1+10+1]; char LongStr[1 + 10 + 1];
unsigned NumGrp; unsigned NumGrp;
unsigned long MaxSizeLstGrpCods = ((1 + 10 + 1) * Gbl.CurrentCrs.Grps.NumGrps) - 1;
/***** Set default for number of groups selected by me *****/ /***** Reset number of groups selected *****/
Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = 0; Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = 0;
if (Gbl.CurrentCrs.Grps.NumGrps) if (Gbl.CurrentCrs.Grps.NumGrps) // If course has groups
{ {
/***** Allocate memory for the list of group codes *****/ /***** Allocate memory for the list of group codes selected *****/
MaxSizeLstGrpCods = ((1+10+1) * Gbl.CurrentCrs.Grps.NumGrps) - 1; if ((ParamLstCodGrps = (char *) malloc (MaxSizeLstGrpCods + 1)) == NULL)
if ((LstCodGrps = (char *) malloc (MaxSizeLstGrpCods + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
/***** Get parameter with list of groups to list *****/ /***** Get parameter with list of groups to list *****/
Par_GetParMultiToText ("GrpCods",LstCodGrps,MaxSizeLstGrpCods); Par_GetParMultiToText ("GrpCods",ParamLstCodGrps,MaxSizeLstGrpCods);
if (LstCodGrps[0]) if (ParamLstCodGrps[0])
{ {
/***** Count number of groups selected from LstCodGrps *****/ /***** Count number of groups selected from LstCodGrps *****/
for (Ptr = LstCodGrps, NumGrp = 0; for (Ptr = ParamLstCodGrps, NumGrp = 0;
*Ptr; *Ptr;
NumGrp++) NumGrp++)
Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,1+10); Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,1+10);
Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = NumGrp; Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = NumGrp;
}
if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps) // If I have selected groups... if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps) // If I have selected groups...
{ {
/***** Create a list of groups selected from LstCodGrps *****/ /***** Create a list of groups selected from LstCodGrps *****/
if ((Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod = (long *) calloc (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps,sizeof (long))) == NULL) if ((Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods = (long *) calloc (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups."); Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
for (Ptr = LstCodGrps, NumGrp = 0; for (Ptr = ParamLstCodGrps, NumGrp = 0;
*Ptr; *Ptr;
NumGrp++) NumGrp++)
{ {
Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,1+10); Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,1+10);
Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrp] = Str_ConvertStrCodToLongCod (LongStr); Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrp] = Str_ConvertStrCodToLongCod (LongStr);
} }
} }
}
/***** Free memory used for the list of groups to show *****/ /***** Free memory used for the list of groups to show *****/
free ((void *) LstCodGrps); free ((void *) ParamLstCodGrps);
} }
} }
@ -490,10 +448,10 @@ void Grp_FreeListCodSelectedGrps (void)
{ {
if (Gbl.CurrentCrs.Grps.LstGrpsSel.NestedCalls > 0) if (Gbl.CurrentCrs.Grps.LstGrpsSel.NestedCalls > 0)
if (--Gbl.CurrentCrs.Grps.LstGrpsSel.NestedCalls == 0) if (--Gbl.CurrentCrs.Grps.LstGrpsSel.NestedCalls == 0)
if (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod) if (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods)
{ {
free ((void *) Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod); free ((void *) Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods);
Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod = NULL; Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods = NULL;
Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = 0; Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = 0;
} }
} }
@ -527,7 +485,7 @@ void Grp_ChangeMyGrps (void)
Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS); Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS);
/***** Get the group codes which I want to join to *****/ /***** Get the group codes which I want to join to *****/
LstGrpsIWant.GrpCod = NULL; // Initialized to avoid bug reported by Coverity LstGrpsIWant.GrpCods = NULL; // Initialized to avoid bug reported by Coverity
LstGrpsIWant.NumGrps = 0; // Initialized to avoid bug reported by Coverity LstGrpsIWant.NumGrps = 0; // Initialized to avoid bug reported by Coverity
Grp_GetLstCodsGrpWanted (&LstGrpsIWant); Grp_GetLstCodsGrpWanted (&LstGrpsIWant);
@ -577,7 +535,7 @@ void Grp_ChangeOtherUsrGrps (void)
Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS); Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS);
/***** Get the list of groups to which register this user *****/ /***** Get the list of groups to which register this user *****/
LstGrpsUsrWants.GrpCod = NULL; // Initialized to avoid bug reported by Coverity LstGrpsUsrWants.GrpCods = NULL; // Initialized to avoid bug reported by Coverity
LstGrpsUsrWants.NumGrps = 0; // Initialized to avoid bug reported by Coverity LstGrpsUsrWants.NumGrps = 0; // Initialized to avoid bug reported by Coverity
Grp_GetLstCodsGrpWanted (&LstGrpsUsrWants); Grp_GetLstCodsGrpWanted (&LstGrpsUsrWants);
@ -650,7 +608,7 @@ bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant)
for (NumGrpIWant = 0, RemoveMeFromThisGrp = true; for (NumGrpIWant = 0, RemoveMeFromThisGrp = true;
NumGrpIWant < LstGrpsIWant->NumGrps && RemoveMeFromThisGrp; NumGrpIWant < LstGrpsIWant->NumGrps && RemoveMeFromThisGrp;
NumGrpIWant++) NumGrpIWant++)
if (LstGrpsIBelong.GrpCod[NumGrpIBelong] == LstGrpsIWant->GrpCod[NumGrpIWant]) if (LstGrpsIBelong.GrpCods[NumGrpIBelong] == LstGrpsIWant->GrpCods[NumGrpIWant])
RemoveMeFromThisGrp = false; RemoveMeFromThisGrp = false;
if (RemoveMeFromThisGrp) if (RemoveMeFromThisGrp)
/* Check if the group is closed */ /* Check if the group is closed */
@ -662,7 +620,7 @@ bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant)
for (NumGrpThisType = 0; for (NumGrpThisType = 0;
NumGrpThisType < GrpTyp->NumGrps && !ITryToLeaveAClosedGroup; NumGrpThisType < GrpTyp->NumGrps && !ITryToLeaveAClosedGroup;
NumGrpThisType++) NumGrpThisType++)
if ((GrpTyp->LstGrps[NumGrpThisType]).GrpCod == LstGrpsIBelong.GrpCod[NumGrpIBelong]) if ((GrpTyp->LstGrps[NumGrpThisType]).GrpCod == LstGrpsIBelong.GrpCods[NumGrpIBelong])
if (!((GrpTyp->LstGrps[NumGrpThisType]).Open)) if (!((GrpTyp->LstGrps[NumGrpThisType]).Open))
ITryToLeaveAClosedGroup = true; ITryToLeaveAClosedGroup = true;
} }
@ -680,7 +638,7 @@ bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant)
for (NumGrpIBelong = 0, RegisterMeInThisGrp = true; for (NumGrpIBelong = 0, RegisterMeInThisGrp = true;
NumGrpIBelong < LstGrpsIBelong.NumGrps && RegisterMeInThisGrp; NumGrpIBelong < LstGrpsIBelong.NumGrps && RegisterMeInThisGrp;
NumGrpIBelong++) NumGrpIBelong++)
if (LstGrpsIWant->GrpCod[NumGrpIWant] == LstGrpsIBelong.GrpCod[NumGrpIBelong]) if (LstGrpsIWant->GrpCods[NumGrpIWant] == LstGrpsIBelong.GrpCods[NumGrpIBelong])
RegisterMeInThisGrp = false; RegisterMeInThisGrp = false;
if (RegisterMeInThisGrp) if (RegisterMeInThisGrp)
/* Check if the group is closed or full */ /* Check if the group is closed or full */
@ -696,7 +654,7 @@ bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant)
!ITryToRegisterInAClosedGroup && !ITryToRegisterInAClosedGroup &&
!ITryToRegisterInFullGroup; !ITryToRegisterInFullGroup;
NumGrpThisType++) NumGrpThisType++)
if ((GrpTyp->LstGrps[NumGrpThisType]).GrpCod == LstGrpsIWant->GrpCod[NumGrpIWant]) if ((GrpTyp->LstGrps[NumGrpThisType]).GrpCod == LstGrpsIWant->GrpCods[NumGrpIWant])
{ {
/* Check if the group is closed */ /* Check if the group is closed */
if (!((GrpTyp->LstGrps[NumGrpThisType]).Open)) if (!((GrpTyp->LstGrps[NumGrpThisType]).Open))
@ -722,10 +680,10 @@ bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant)
for (NumGrpIWant = 0, RemoveMeFromThisGrp = true; for (NumGrpIWant = 0, RemoveMeFromThisGrp = true;
NumGrpIWant < LstGrpsIWant->NumGrps && RemoveMeFromThisGrp; NumGrpIWant < LstGrpsIWant->NumGrps && RemoveMeFromThisGrp;
NumGrpIWant++) NumGrpIWant++)
if (LstGrpsIBelong.GrpCod[NumGrpIBelong] == LstGrpsIWant->GrpCod[NumGrpIWant]) if (LstGrpsIBelong.GrpCods[NumGrpIBelong] == LstGrpsIWant->GrpCods[NumGrpIWant])
RemoveMeFromThisGrp = false; RemoveMeFromThisGrp = false;
if (RemoveMeFromThisGrp) if (RemoveMeFromThisGrp)
Grp_RemoveUsrFromGroup (Gbl.Usrs.Me.UsrDat.UsrCod,LstGrpsIBelong.GrpCod[NumGrpIBelong]); Grp_RemoveUsrFromGroup (Gbl.Usrs.Me.UsrDat.UsrCod,LstGrpsIBelong.GrpCods[NumGrpIBelong]);
} }
/***** Go across the list of groups that I want to register in, adding those groups that are not present in the list of groups I belong to *****/ /***** Go across the list of groups that I want to register in, adding those groups that are not present in the list of groups I belong to *****/
@ -736,10 +694,10 @@ bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant)
for (NumGrpIBelong = 0, RegisterMeInThisGrp = true; for (NumGrpIBelong = 0, RegisterMeInThisGrp = true;
NumGrpIBelong < LstGrpsIBelong.NumGrps && RegisterMeInThisGrp; NumGrpIBelong < LstGrpsIBelong.NumGrps && RegisterMeInThisGrp;
NumGrpIBelong++) NumGrpIBelong++)
if (LstGrpsIWant->GrpCod[NumGrpIWant] == LstGrpsIBelong.GrpCod[NumGrpIBelong]) if (LstGrpsIWant->GrpCods[NumGrpIWant] == LstGrpsIBelong.GrpCods[NumGrpIBelong])
RegisterMeInThisGrp = false; RegisterMeInThisGrp = false;
if (RegisterMeInThisGrp) if (RegisterMeInThisGrp)
Grp_AddUsrToGroup (&Gbl.Usrs.Me.UsrDat,LstGrpsIWant->GrpCod[NumGrpIWant]); Grp_AddUsrToGroup (&Gbl.Usrs.Me.UsrDat,LstGrpsIWant->GrpCods[NumGrpIWant]);
} }
ChangesMade = true; ChangesMade = true;
@ -798,10 +756,10 @@ bool Grp_ChangeGrpsOtherUsrAtomically (struct ListCodGrps *LstGrpsUsrWants)
for (NumGrpUsrWants = 0, RemoveUsrFromThisGrp = true; for (NumGrpUsrWants = 0, RemoveUsrFromThisGrp = true;
NumGrpUsrWants < LstGrpsUsrWants->NumGrps && RemoveUsrFromThisGrp; NumGrpUsrWants < LstGrpsUsrWants->NumGrps && RemoveUsrFromThisGrp;
NumGrpUsrWants++) NumGrpUsrWants++)
if (LstGrpsUsrBelongs.GrpCod[NumGrpUsrBelongs] == LstGrpsUsrWants->GrpCod[NumGrpUsrWants]) if (LstGrpsUsrBelongs.GrpCods[NumGrpUsrBelongs] == LstGrpsUsrWants->GrpCods[NumGrpUsrWants])
RemoveUsrFromThisGrp = false; RemoveUsrFromThisGrp = false;
if (RemoveUsrFromThisGrp) if (RemoveUsrFromThisGrp)
Grp_RemoveUsrFromGroup (Gbl.Usrs.Other.UsrDat.UsrCod,LstGrpsUsrBelongs.GrpCod[NumGrpUsrBelongs]); Grp_RemoveUsrFromGroup (Gbl.Usrs.Other.UsrDat.UsrCod,LstGrpsUsrBelongs.GrpCods[NumGrpUsrBelongs]);
} }
/***** Go across the list of groups that user wants to register in, adding those groups that are not present in the list of groups user belongs to *****/ /***** Go across the list of groups that user wants to register in, adding those groups that are not present in the list of groups user belongs to *****/
@ -812,10 +770,10 @@ bool Grp_ChangeGrpsOtherUsrAtomically (struct ListCodGrps *LstGrpsUsrWants)
for (NumGrpUsrBelongs = 0, RegisterUsrInThisGrp = true; for (NumGrpUsrBelongs = 0, RegisterUsrInThisGrp = true;
NumGrpUsrBelongs < LstGrpsUsrBelongs.NumGrps && RegisterUsrInThisGrp; NumGrpUsrBelongs < LstGrpsUsrBelongs.NumGrps && RegisterUsrInThisGrp;
NumGrpUsrBelongs++) NumGrpUsrBelongs++)
if (LstGrpsUsrWants->GrpCod[NumGrpUsrWants] == LstGrpsUsrBelongs.GrpCod[NumGrpUsrBelongs]) if (LstGrpsUsrWants->GrpCods[NumGrpUsrWants] == LstGrpsUsrBelongs.GrpCods[NumGrpUsrBelongs])
RegisterUsrInThisGrp = false; RegisterUsrInThisGrp = false;
if (RegisterUsrInThisGrp) if (RegisterUsrInThisGrp)
Grp_AddUsrToGroup (&Gbl.Usrs.Other.UsrDat,LstGrpsUsrWants->GrpCod[NumGrpUsrWants]); Grp_AddUsrToGroup (&Gbl.Usrs.Other.UsrDat,LstGrpsUsrWants->GrpCods[NumGrpUsrWants]);
} }
ChangesMade = true; ChangesMade = true;
@ -859,7 +817,7 @@ bool Grp_CheckIfSelectionGrpsIsValid (struct ListCodGrps *LstGrps)
SelectionValid && NumCodGrp < LstGrps->NumGrps; SelectionValid && NumCodGrp < LstGrps->NumGrps;
NumCodGrp++) NumCodGrp++)
{ {
GrpTypCod = Grp_GetTypeOfGroupOfAGroup (LstGrps->GrpCod[NumCodGrp]); GrpTypCod = Grp_GetTypeOfGroupOfAGroup (LstGrps->GrpCods[NumCodGrp]);
if (!Grp_GetMultipleEnrollmentOfAGroupType (GrpTypCod)) if (!Grp_GetMultipleEnrollmentOfAGroupType (GrpTypCod))
for (NumGrpTyp = 0; for (NumGrpTyp = 0;
NumGrpTyp < Gbl.CurrentCrs.Grps.GrpTypes.Num; NumGrpTyp < Gbl.CurrentCrs.Grps.GrpTypes.Num;
@ -938,7 +896,7 @@ void Grp_RegisterUsrIntoGroups (struct UsrData *UsrDat,struct ListCodGrps *LstGr
/***** Query in the database the group codes of any group of this type the student belongs to *****/ /***** Query in the database the group codes of any group of this type the student belongs to *****/
LstGrpsHeBelongs.NumGrps = 0; // Initialized to avoid bug reported by Coverity LstGrpsHeBelongs.NumGrps = 0; // Initialized to avoid bug reported by Coverity
LstGrpsHeBelongs.GrpCod = NULL; // Initialized to avoid bug reported by Coverity LstGrpsHeBelongs.GrpCods = NULL; // Initialized to avoid bug reported by Coverity
Grp_GetLstCodGrpsUsrBelongs (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod, Grp_GetLstCodGrpsUsrBelongs (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod,
UsrDat->UsrCod,&LstGrpsHeBelongs); UsrDat->UsrCod,&LstGrpsHeBelongs);
@ -951,7 +909,7 @@ void Grp_RegisterUsrIntoGroups (struct UsrData *UsrDat,struct ListCodGrps *LstGr
for (NumGrpThisType = 0; for (NumGrpThisType = 0;
NumGrpThisType < Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps; NumGrpThisType < Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps;
NumGrpThisType++) NumGrpThisType++)
if (LstGrps->GrpCod[NumGrpSel] == Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].LstGrps[NumGrpThisType].GrpCod) if (LstGrps->GrpCods[NumGrpSel] == Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].LstGrps[NumGrpThisType].GrpCod)
{ // The selected group is of this type { // The selected group is of this type
AlreadyRegisteredInGrp = false; AlreadyRegisteredInGrp = false;
@ -959,13 +917,13 @@ void Grp_RegisterUsrIntoGroups (struct UsrData *UsrDat,struct ListCodGrps *LstGr
for (NumGrpHeBelongs = 0; for (NumGrpHeBelongs = 0;
NumGrpHeBelongs < LstGrpsHeBelongs.NumGrps; NumGrpHeBelongs < LstGrpsHeBelongs.NumGrps;
NumGrpHeBelongs++) NumGrpHeBelongs++)
if (LstGrps->GrpCod[NumGrpSel] == LstGrpsHeBelongs.GrpCod[NumGrpHeBelongs]) if (LstGrps->GrpCods[NumGrpSel] == LstGrpsHeBelongs.GrpCods[NumGrpHeBelongs])
AlreadyRegisteredInGrp = true; AlreadyRegisteredInGrp = true;
else if (!MultipleEnrollment) // If the type of group is of single enrollment else if (!MultipleEnrollment) // If the type of group is of single enrollment
{ {
/* If the enrollment is single and the group to which the user belongs is different from the selected ==> /* If the enrollment is single and the group to which the user belongs is different from the selected ==>
remove user from the group to which he belongs */ remove user from the group to which he belongs */
Grp_RemoveUsrFromGroup (UsrDat->UsrCod,LstGrpsHeBelongs.GrpCod[NumGrpHeBelongs]); Grp_RemoveUsrFromGroup (UsrDat->UsrCod,LstGrpsHeBelongs.GrpCods[NumGrpHeBelongs]);
sprintf (Gbl.Message,Txt_THE_USER_X_has_been_removed_from_the_group_of_type_Y_to_which_it_belonged, sprintf (Gbl.Message,Txt_THE_USER_X_has_been_removed_from_the_group_of_type_Y_to_which_it_belonged,
UsrDat->FullName,Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName); UsrDat->FullName,Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
@ -973,7 +931,7 @@ void Grp_RegisterUsrIntoGroups (struct UsrData *UsrDat,struct ListCodGrps *LstGr
if (!AlreadyRegisteredInGrp) // If the user does not belong to the selected group if (!AlreadyRegisteredInGrp) // If the user does not belong to the selected group
{ {
Grp_AddUsrToGroup (UsrDat,LstGrps->GrpCod[NumGrpSel]); Grp_AddUsrToGroup (UsrDat,LstGrps->GrpCods[NumGrpSel]);
sprintf (Gbl.Message,Txt_THE_USER_X_has_been_enrolled_in_the_group_of_type_Y_Z, sprintf (Gbl.Message,Txt_THE_USER_X_has_been_enrolled_in_the_group_of_type_Y_Z,
UsrDat->FullName,Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName, UsrDat->FullName,Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName,
Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].LstGrps[NumGrpThisType].GrpName); Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].LstGrps[NumGrpThisType].GrpName);
@ -1015,9 +973,9 @@ unsigned Grp_RemoveUsrFromGroups (struct UsrData *UsrDat,struct ListCodGrps *Lst
NumGrpHeBelongs < LstGrpsHeBelongs.NumGrps; NumGrpHeBelongs < LstGrpsHeBelongs.NumGrps;
NumGrpHeBelongs++) NumGrpHeBelongs++)
/* If the user belongs to a selected group from which he must be removed */ /* If the user belongs to a selected group from which he must be removed */
if (LstGrpsHeBelongs.GrpCod[NumGrpHeBelongs] == LstGrps->GrpCod[NumGrpSel]) if (LstGrpsHeBelongs.GrpCods[NumGrpHeBelongs] == LstGrps->GrpCods[NumGrpSel])
{ {
Grp_RemoveUsrFromGroup (UsrDat->UsrCod,LstGrpsHeBelongs.GrpCod[NumGrpHeBelongs]); Grp_RemoveUsrFromGroup (UsrDat->UsrCod,LstGrpsHeBelongs.GrpCods[NumGrpHeBelongs]);
NumGrpsHeIsRemoved++; NumGrpsHeIsRemoved++;
} }
@ -1893,7 +1851,7 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp)
for (NumGrpSel = 0; for (NumGrpSel = 0;
NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps; NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps;
NumGrpSel++) NumGrpSel++)
if (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrpSel] == Grp->GrpCod) if (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel] == Grp->GrpCod)
{ {
fprintf (Gbl.F.Out," checked=\"checked\""); fprintf (Gbl.F.Out," checked=\"checked\"");
break; break;
@ -1923,7 +1881,7 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp)
for (NumGrpSel = 0; for (NumGrpSel = 0;
NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps; NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps;
NumGrpSel++) NumGrpSel++)
if (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrpSel] == -(GrpTyp->GrpTypCod)) if (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel] == -(GrpTyp->GrpTypCod))
{ {
fprintf (Gbl.F.Out," checked=\"checked\""); fprintf (Gbl.F.Out," checked=\"checked\"");
break; break;
@ -2997,7 +2955,7 @@ static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,
if (LstGrps->NumGrps) if (LstGrps->NumGrps)
{ {
/***** Create a list of groups the user belongs to *****/ /***** Create a list of groups the user belongs to *****/
if ((LstGrps->GrpCod = (long *) calloc (LstGrps->NumGrps,sizeof (long))) == NULL) if ((LstGrps->GrpCods = (long *) calloc (LstGrps->NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store codes of groups a user belongs to."); Lay_ShowErrorAndExit ("Not enough memory to store codes of groups a user belongs to.");
for (NumGrp = 0; for (NumGrp = 0;
NumGrp < LstGrps->NumGrps; NumGrp < LstGrps->NumGrps;
@ -3006,7 +2964,7 @@ static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the code of group (row[0]) */ /* Get the code of group (row[0]) */
if ((LstGrps->GrpCod[NumGrp] = Str_ConvertStrCodToLongCod (row[0])) < 0) if ((LstGrps->GrpCods[NumGrp] = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of group."); Lay_ShowErrorAndExit ("Wrong code of group.");
} }
} }
@ -3041,7 +2999,7 @@ void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps)
if (LstGrps->NumGrps) if (LstGrps->NumGrps)
{ {
/***** Create a list of groups I belong to *****/ /***** Create a list of groups I belong to *****/
if ((LstGrps->GrpCod = (long *) calloc (LstGrps->NumGrps,sizeof (long))) == NULL) if ((LstGrps->GrpCods = (long *) calloc (LstGrps->NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store codes of groups I belongs to."); Lay_ShowErrorAndExit ("Not enough memory to store codes of groups I belongs to.");
for (NumGrp = 0; for (NumGrp = 0;
NumGrp < LstGrps->NumGrps; NumGrp < LstGrps->NumGrps;
@ -3050,7 +3008,7 @@ void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the code of group (row[0]) */ /* Get the code of group (row[0]) */
if ((LstGrps->GrpCod[NumGrp] = Str_ConvertStrCodToLongCod (row[0])) < 0) if ((LstGrps->GrpCods[NumGrp] = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of group."); Lay_ShowErrorAndExit ("Wrong code of group.");
} }
} }
@ -3070,7 +3028,7 @@ static bool Grp_CheckIfGrpIsInList (long GrpCod,struct ListCodGrps *LstGrps)
for (NumGrp = 0; for (NumGrp = 0;
NumGrp < LstGrps->NumGrps; NumGrp < LstGrps->NumGrps;
NumGrp++) NumGrp++)
if (GrpCod == LstGrps->GrpCod[NumGrp]) if (GrpCod == LstGrps->GrpCods[NumGrp])
return true; return true;
return false; return false;
} }
@ -4191,7 +4149,7 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
with all the groups selected (of all the types) *****/ with all the groups selected (of all the types) *****/
if (LstGrpsWanted->NumGrps) if (LstGrpsWanted->NumGrps)
{ {
if ((LstGrpsWanted->GrpCod = (long *) calloc (LstGrpsWanted->NumGrps,sizeof (long))) == NULL) if ((LstGrpsWanted->GrpCods = (long *) calloc (LstGrpsWanted->NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enoguh memory to store codes of groups in which a user wants to be enrolled."); Lay_ShowErrorAndExit ("Not enoguh memory to store codes of groups in which a user wants to be enrolled.");
/***** Get the groups *****/ /***** Get the groups *****/
@ -4205,7 +4163,7 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
NumGrpWanted++) NumGrpWanted++)
{ {
Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,1+10); Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,1+10);
LstGrpsWanted->GrpCod[NumGrpWanted] = Str_ConvertStrCodToLongCod (LongStr); LstGrpsWanted->GrpCods[NumGrpWanted] = Str_ConvertStrCodToLongCod (LongStr);
} }
/* Free memory used by the list of group codes of this type */ /* Free memory used by the list of group codes of this type */
free ((void *) LstStrCodGrps[NumGrpTyp]); free ((void *) LstStrCodGrps[NumGrpTyp]);
@ -4222,9 +4180,9 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
void Grp_FreeListCodGrp (struct ListCodGrps *LstGrps) void Grp_FreeListCodGrp (struct ListCodGrps *LstGrps)
{ {
if (LstGrps->NumGrps && LstGrps->GrpCod) if (LstGrps->NumGrps && LstGrps->GrpCods)
free ((void *) LstGrps->GrpCod); free ((void *) LstGrps->GrpCods);
LstGrps->GrpCod = NULL; LstGrps->GrpCods = NULL;
LstGrps->NumGrps = 0; LstGrps->NumGrps = 0;
} }

View File

@ -93,7 +93,7 @@ struct GroupTypes
}; };
struct ListCodGrps struct ListCodGrps
{ {
long *GrpCod; long *GrpCods;
unsigned NumGrps; unsigned NumGrps;
int NestedCalls; // Number of nested calls to the function that allocates memory for this list int NestedCalls; // Number of nested calls to the function that allocates memory for this list
}; };
@ -124,7 +124,7 @@ void Grp_ReqEditGroups (void);
void Grp_ShowFormToSelectSeveralGroups (Act_Action_t NextAction); void Grp_ShowFormToSelectSeveralGroups (Act_Action_t NextAction);
void Grp_PutParamsCodGrps (void); void Grp_PutParamsCodGrps (void);
void Grp_GetParCodsSeveralGrpsToShowUsrs (void); void Grp_GetParCodsSeveralGrpsToShowUsrs (void);
void Grp_GetParCodsSeveralGrpsToEditAsgAttOrSvy (void); void Grp_GetParCodsSeveralGrps (void);
void Grp_FreeListCodSelectedGrps (void); void Grp_FreeListCodSelectedGrps (void);
void Grp_ChangeMyGrpsAndShowChanges (void); void Grp_ChangeMyGrpsAndShowChanges (void);
void Grp_ChangeMyGrps (void); void Grp_ChangeMyGrps (void);

View File

@ -2219,7 +2219,7 @@ void Svy_RecFormSurvey (void)
if (NewSurveyIsCorrect) if (NewSurveyIsCorrect)
{ {
/* Get groups for this surveys */ /* Get groups for this surveys */
Grp_GetParCodsSeveralGrpsToEditAsgAttOrSvy (); Grp_GetParCodsSeveralGrps ();
if (ItsANewSurvey) if (ItsANewSurvey)
Svy_CreateSurvey (&NewSvy,Txt); // Add new survey to database Svy_CreateSurvey (&NewSvy,Txt); // Add new survey to database
@ -2423,7 +2423,7 @@ static void Svy_CreateGrps (long SvyCod)
{ {
/* Create group */ /* Create group */
sprintf (Query,"INSERT INTO svy_grp (SvyCod,GrpCod) VALUES ('%ld','%ld')", sprintf (Query,"INSERT INTO svy_grp (SvyCod,GrpCod) VALUES ('%ld','%ld')",
SvyCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrpSel]); SvyCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
DB_QueryINSERT (Query,"can not associate a group to a survey"); DB_QueryINSERT (Query,"can not associate a group to a survey");
} }
} }

View File

@ -3872,7 +3872,7 @@ static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,
for (NumGrpSel = 0; for (NumGrpSel = 0;
NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps; NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps;
NumGrpSel++) NumGrpSel++)
if ((GrpCod = Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrpSel]) > 0) if ((GrpCod = Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]) > 0)
NumPositiveCods++; NumPositiveCods++;
else else
for (NumGrpTyp = 0; for (NumGrpTyp = 0;
@ -3893,7 +3893,7 @@ static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,
for (NumGrpSel = 0; for (NumGrpSel = 0;
NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps; NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps;
NumGrpSel++) NumGrpSel++)
if ((GrpCod = Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrpSel]) > 0) if ((GrpCod = Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]) > 0)
{ {
Str_Concat (Query,NumPositiveCods ? " OR GrpCod='" : Str_Concat (Query,NumPositiveCods ? " OR GrpCod='" :
" GrpCod='", " GrpCod='",

View File

@ -1897,7 +1897,7 @@ int swad__sendMyGroups (struct soap *soap,
/***** Get the group codes which I want to join to *****/ /***** Get the group codes which I want to join to *****/
LstGrpsIWant.NumGrps = 0; LstGrpsIWant.NumGrps = 0;
LstGrpsIWant.GrpCod = NULL; LstGrpsIWant.GrpCods = NULL;
if (myGroups[0]) if (myGroups[0])
{ {
@ -1911,7 +1911,7 @@ int swad__sendMyGroups (struct soap *soap,
if (LstGrpsIWant.NumGrps) // If I have selected groups... if (LstGrpsIWant.NumGrps) // If I have selected groups...
{ {
/***** Create a list of groups selected from myGroups *****/ /***** Create a list of groups selected from myGroups *****/
if ((LstGrpsIWant.GrpCod = (long *) calloc (LstGrpsIWant.NumGrps,sizeof (long))) == NULL) if ((LstGrpsIWant.GrpCods = (long *) calloc (LstGrpsIWant.NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups."); Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
for (NumGrp = 0, Ptr = myGroups; for (NumGrp = 0, Ptr = myGroups;
*Ptr; *Ptr;
@ -1919,7 +1919,7 @@ int swad__sendMyGroups (struct soap *soap,
{ {
/* Find next string in text until comma (leading and trailing spaces are removed) */ /* Find next string in text until comma (leading and trailing spaces are removed) */
Str_GetNextStringUntilComma (&Ptr,LongStr,1+10); Str_GetNextStringUntilComma (&Ptr,LongStr,1+10);
LstGrpsIWant.GrpCod[NumGrp] = Str_ConvertStrCodToLongCod (LongStr); LstGrpsIWant.GrpCods[NumGrp] = Str_ConvertStrCodToLongCod (LongStr);
} }
} }
} }
@ -2465,7 +2465,7 @@ static void Svc_GetLstGrpsSel (const char *Groups)
// Here NestedCalls is always 0 // Here NestedCalls is always 0
Gbl.CurrentCrs.Grps.LstGrpsSel.NestedCalls++; Gbl.CurrentCrs.Grps.LstGrpsSel.NestedCalls++;
// Here NestedCalls is always 1 // Here NestedCalls is always 1
if ((Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod = (long *) calloc (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps,sizeof (long))) == NULL) if ((Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods = (long *) calloc (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups."); Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
for (Ptr = Groups, NumGrp = 0; for (Ptr = Groups, NumGrp = 0;
@ -2473,8 +2473,8 @@ static void Svc_GetLstGrpsSel (const char *Groups)
) )
{ {
Str_GetNextStringUntilComma (&Ptr,LongStr,1+10); Str_GetNextStringUntilComma (&Ptr,LongStr,1+10);
Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrp] = Str_ConvertStrCodToLongCod (LongStr); Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrp] = Str_ConvertStrCodToLongCod (LongStr);
if (Grp_CheckIfGroupBelongsToCourse (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCod[NumGrp],Gbl.CurrentCrs.Crs.CrsCod)) if (Grp_CheckIfGroupBelongsToCourse (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrp],Gbl.CurrentCrs.Crs.CrsCod))
NumGrp++; NumGrp++;
} }
Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = NumGrp; // Update number of groups Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps = NumGrp; // Update number of groups