2021-06-17 13:55:45 +02:00
|
|
|
|
// swad_group.h: types of groups and groups
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
#ifndef _SWAD_GRP
|
|
|
|
|
#define _SWAD_GRP
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance in Spanish),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2022-09-21 10:46:14 +02:00
|
|
|
|
Copyright (C) 1999-2022 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "swad_info.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_room.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_user.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public constants ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#define Grp_MAX_CHARS_GROUP_TYPE_NAME (128 - 1) // 127
|
|
|
|
|
#define Grp_MAX_BYTES_GROUP_TYPE_NAME ((Grp_MAX_CHARS_GROUP_TYPE_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
2017-03-07 11:03:05 +01:00
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#define Grp_MAX_CHARS_GROUP_NAME (128 - 1) // 127
|
|
|
|
|
#define Grp_MAX_BYTES_GROUP_NAME ((Grp_MAX_CHARS_GROUP_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
#define Grp_MAX_STUDENTS_IN_A_GROUP 10000 // If max of students in a group is greater than this, it is considered infinite
|
2017-01-29 21:41:08 +01:00
|
|
|
|
#define Grp_NUM_STUDENTS_NOT_LIMITED INT_MAX // This number can be stored in database as an integer...
|
|
|
|
|
// ...and means that a group has no limit of students
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Public types ********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-06-18 18:39:21 +02:00
|
|
|
|
#define Grp_NUM_WHICH_GROUP_TYPES 2
|
2014-12-01 23:55:08 +01:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Grp_ONLY_GROUP_TYPES_WITH_GROUPS,
|
|
|
|
|
Grp_ALL_GROUP_TYPES,
|
|
|
|
|
} Grp_WhichGroupTypes_t;
|
|
|
|
|
|
|
|
|
|
// Related with groups
|
|
|
|
|
struct GroupData
|
|
|
|
|
{
|
2019-01-04 11:59:31 +01:00
|
|
|
|
long GrpCod; // Group code
|
|
|
|
|
long GrpTypCod; // Group type code
|
|
|
|
|
long CrsCod; // Course code
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char GrpTypName[Grp_MAX_BYTES_GROUP_TYPE_NAME + 1];
|
|
|
|
|
char GrpName[Grp_MAX_BYTES_GROUP_NAME + 1];
|
2019-01-07 17:00:04 +01:00
|
|
|
|
struct
|
|
|
|
|
{
|
2020-04-14 17:15:17 +02:00
|
|
|
|
long RooCod; // Room code
|
|
|
|
|
char ShrtName[Roo_MAX_BYTES_SHRT_NAME + 1]; // Room short name
|
|
|
|
|
} Room;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned MaxStudents;
|
|
|
|
|
int Vacant;
|
|
|
|
|
bool Open; // Group is open?
|
|
|
|
|
bool FileZones; // Group has file zones?
|
2017-03-30 11:20:06 +02:00
|
|
|
|
bool MultipleEnrolment;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
2017-01-29 12:42:19 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct Group
|
|
|
|
|
{
|
|
|
|
|
long GrpCod; // Code of group
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char GrpName[Grp_MAX_BYTES_GROUP_NAME + 1]; // Name of group
|
2019-01-04 23:15:00 +01:00
|
|
|
|
struct
|
|
|
|
|
{
|
2020-04-14 17:15:17 +02:00
|
|
|
|
long RooCod; // Room code
|
|
|
|
|
char ShrtName[Roo_MAX_BYTES_SHRT_NAME + 1]; // Room short name
|
|
|
|
|
} Room;
|
2017-05-30 21:43:05 +02:00
|
|
|
|
unsigned NumUsrs[Rol_NUM_ROLES]; // Number of users in the group
|
2019-01-04 11:59:31 +01:00
|
|
|
|
unsigned MaxStudents; // Maximum number of students in the group
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool Open; // Group is open?
|
|
|
|
|
bool FileZones; // Group has file zones?
|
|
|
|
|
bool ShowFileZone; // Show file zone of this group?
|
|
|
|
|
};
|
2017-01-29 12:42:19 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct GroupType
|
|
|
|
|
{
|
|
|
|
|
long GrpTypCod; // Code of type of group
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char GrpTypName[Grp_MAX_BYTES_GROUP_TYPE_NAME + 1]; // Name of type of group
|
2017-03-30 11:20:06 +02:00
|
|
|
|
bool MandatoryEnrolment; // Enrolment is mandatory?
|
|
|
|
|
bool MultipleEnrolment; // Enrolment is multiple?
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool MustBeOpened; // Groups must be opened?
|
2015-10-26 20:02:07 +01:00
|
|
|
|
time_t OpenTimeUTC; // Open groups automatically in this date-time. If == 0, don't open.
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumGrps; // Number of groups of this type
|
|
|
|
|
struct Group *LstGrps; // List of groups of this type
|
|
|
|
|
};
|
2017-01-29 12:42:19 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct GroupTypes
|
|
|
|
|
{
|
|
|
|
|
struct GroupType *LstGrpTypes; // List of types of group
|
2021-06-28 12:54:09 +02:00
|
|
|
|
unsigned NumGrpTypes; // Number of types of group
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumGrpsTotal; // Number of groups of any type
|
|
|
|
|
int NestedCalls; // Number of nested calls to the function that allocates memory for this list
|
|
|
|
|
};
|
2017-01-29 12:42:19 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct ListCodGrps
|
|
|
|
|
{
|
2017-01-19 20:55:31 +01:00
|
|
|
|
long *GrpCods;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumGrps;
|
|
|
|
|
int NestedCalls; // Number of nested calls to the function that allocates memory for this list
|
|
|
|
|
};
|
2017-01-29 12:42:19 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct ListGrpsAlreadySelec
|
|
|
|
|
{
|
|
|
|
|
long GrpTypCod;
|
|
|
|
|
bool AlreadySelected;
|
|
|
|
|
};
|
2017-01-29 12:42:19 +01:00
|
|
|
|
|
2017-01-29 21:41:08 +01:00
|
|
|
|
#define Grp_NUM_WHICH_GROUPS 2
|
2014-12-01 23:55:08 +01:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2019-09-29 17:33:39 +02:00
|
|
|
|
Grp_MY_GROUPS,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Grp_ALL_GROUPS,
|
|
|
|
|
} Grp_WhichGroups_t;
|
2017-01-29 12:42:19 +01:00
|
|
|
|
#define Grp_WHICH_GROUPS_DEFAULT Grp_ALL_GROUPS
|
|
|
|
|
|
2020-05-06 01:43:48 +02:00
|
|
|
|
#define Grp_NUM_ASSOCIATIONS_TO_GROUPS 5
|
2014-12-01 23:55:08 +01:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Grp_ASSIGNMENT,
|
2021-03-20 14:46:34 +01:00
|
|
|
|
Grp_ATT_EVENT,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Grp_SURVEY,
|
2020-05-06 01:43:48 +02:00
|
|
|
|
Grp_EXA_EVENT,
|
2019-05-28 15:06:53 +02:00
|
|
|
|
Grp_MATCH,
|
2020-05-06 01:43:48 +02:00
|
|
|
|
} Grp_WhichIsAssociatedToGrp_t;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-10 19:14:08 +02:00
|
|
|
|
struct Grp_Groups
|
|
|
|
|
{
|
|
|
|
|
unsigned NumGrps;
|
|
|
|
|
struct GroupTypes GrpTypes;
|
|
|
|
|
struct GroupType GrpTyp;
|
|
|
|
|
long GrpCod; // Group to be edited, removed...
|
|
|
|
|
char GrpName[Grp_MAX_BYTES_GROUP_NAME + 1];
|
2020-04-14 17:15:17 +02:00
|
|
|
|
long RooCod;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
unsigned MaxStudents;
|
|
|
|
|
bool Open;
|
|
|
|
|
bool FileZones;
|
|
|
|
|
struct ListCodGrps LstGrpsSel;
|
|
|
|
|
Grp_WhichGroups_t WhichGrps; // Show my groups or all groups
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Public prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Grp_WriteNamesOfSelectedGrps (void);
|
|
|
|
|
void Grp_ReqEditGroups (void);
|
2016-11-25 03:21:02 +01:00
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
void Grp_ShowFormToSelectSeveralGroups (void (*FuncParams) (void *Args),void *Args,
|
2019-04-11 09:55:35 +02:00
|
|
|
|
Grp_WhichGroups_t GroupsSelectableByStdsOrNETs);
|
2016-11-25 03:21:02 +01:00
|
|
|
|
void Grp_PutParamsCodGrps (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Grp_GetParCodsSeveralGrpsToShowUsrs (void);
|
2017-01-19 20:55:31 +01:00
|
|
|
|
void Grp_GetParCodsSeveralGrps (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Grp_FreeListCodSelectedGrps (void);
|
|
|
|
|
void Grp_ChangeMyGrpsAndShowChanges (void);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
void Grp_ChangeMyGrps (Cns_QuietOrVerbose_t QuietOrVerbose);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Grp_ChangeOtherUsrGrps (void);
|
|
|
|
|
bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
void Grp_ChangeGrpsOtherUsrAtomically (struct ListCodGrps *LstGrpsUsrWants);
|
2017-06-20 01:58:16 +02:00
|
|
|
|
bool Grp_CheckIfSelectionGrpsSingleEnrolmentIsValid (Rol_Role_t Role,struct ListCodGrps *LstGrps);
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Grp_RegisterUsrIntoGroups (struct Usr_Data *UsrDat,struct ListCodGrps *LstGrps);
|
|
|
|
|
unsigned Grp_RemoveUsrFromGroups (struct Usr_Data *UsrDat,struct ListCodGrps *LstGrps);
|
2017-06-20 14:43:26 +02:00
|
|
|
|
void Grp_RemUsrFromAllGrpsInCrs (long UsrCod,long CrsCod);
|
|
|
|
|
void Grp_RemUsrFromAllGrps (long UsrCod);
|
2020-11-25 01:50:13 +01:00
|
|
|
|
void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp,
|
|
|
|
|
Grp_WhichIsAssociatedToGrp_t WhichIsAssociatedToGrp,
|
|
|
|
|
long Cod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
void Grp_ReqRegisterInGrps (void);
|
2017-05-22 12:23:08 +02:00
|
|
|
|
void Grp_ShowLstGrpsToChgMyGrps (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Grp_ShowLstGrpsToChgOtherUsrsGrps (long UsrCod);
|
|
|
|
|
|
2021-11-08 19:16:51 +01:00
|
|
|
|
void Grp_GetListGrpTypesInCurrentCrs (Grp_WhichGroupTypes_t WhichGroupTypes);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Grp_FreeListGrpTypesAndGrps (void);
|
|
|
|
|
void Grp_OpenGroupsAutomatically (void);
|
|
|
|
|
void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes);
|
|
|
|
|
void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat);
|
2017-06-20 14:43:26 +02:00
|
|
|
|
|
|
|
|
|
void Grp_FlushCacheIBelongToGrp (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool Grp_GetIfIBelongToGrp (long GrpCod);
|
2017-06-20 14:43:26 +02:00
|
|
|
|
void Grp_FlushCacheUsrSharesAnyOfMyGrpsInCurrentCrs (void);
|
2022-09-24 18:30:26 +02:00
|
|
|
|
bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct Usr_Data *UsrDat);
|
2017-06-20 14:43:26 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps);
|
2021-06-25 20:05:58 +02:00
|
|
|
|
void Grp_GetNamesGrpsUsrBelongsTo (long UsrCod,long GrpTypCod,char *GroupNames);
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Grp_ReceiveFormNewGrpTyp (void);
|
|
|
|
|
void Grp_ReceiveFormNewGrp (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Grp_ReqRemGroupType (void);
|
|
|
|
|
void Grp_ReqRemGroup (void);
|
|
|
|
|
void Grp_RemoveGroupType (void);
|
|
|
|
|
void Grp_RemoveGroup (void);
|
|
|
|
|
void Grp_OpenGroup (void);
|
|
|
|
|
void Grp_CloseGroup (void);
|
|
|
|
|
void Grp_EnableFileZonesGrp (void);
|
|
|
|
|
void Grp_DisableFileZonesGrp (void);
|
2019-01-04 22:46:46 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Grp_ChangeGroupType (void);
|
2020-04-14 17:15:17 +02:00
|
|
|
|
void Grp_ChangeGroupRoom (void);
|
2019-01-04 22:46:46 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Grp_ChangeMandatGrpTyp (void);
|
|
|
|
|
void Grp_ChangeMultiGrpTyp (void);
|
|
|
|
|
void Grp_ChangeOpenTimeGrpTyp (void);
|
|
|
|
|
void Grp_ChangeMaxStdsGrp (void);
|
|
|
|
|
unsigned Grp_ConvertToNumMaxStdsGrp (const char *StrMaxStudents);
|
|
|
|
|
void Grp_RenameGroupType (void);
|
|
|
|
|
void Grp_RenameGroup (void);
|
2020-10-13 22:34:31 +02:00
|
|
|
|
void Grp_PutParamGrpCod (void *GrpCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted);
|
|
|
|
|
void Grp_FreeListCodGrp (struct ListCodGrps *LstGrps);
|
|
|
|
|
void Grp_PutParamAllGroups (void);
|
|
|
|
|
|
2020-03-27 14:56:54 +01:00
|
|
|
|
void Grp_PutParamWhichGroups (void *WhichGrps);
|
2016-12-04 20:12:56 +01:00
|
|
|
|
void Grp_PutParamWhichGrpsOnlyMyGrps (void);
|
|
|
|
|
void Grp_PutParamWhichGrpsAllGrps (void);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
void Grp_ShowFormToSelWhichGrps (Act_Action_t Action,
|
|
|
|
|
void (*FuncParams) (void *Args),void *Args);
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t Grp_GetParamWhichGroups (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-27 00:30:06 +02:00
|
|
|
|
void Grp_DB_RemoveCrsGrps (long CrsCod);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#endif
|