From de0052714649f75660286367d2cd8e33fa875843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Tue, 6 Jun 2017 20:27:46 +0200 Subject: [PATCH] Version 16.235.3 --- swad_changelog.h | 5 ++- swad_group.c | 107 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 95 insertions(+), 17 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 0ca73176b..79fd7b308 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -242,14 +242,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.235.2 (2017-06-04)" +#define Log_PLATFORM_VERSION "SWAD 16.235.3 (2017-06-04)" #define CSS_FILE "swad16.235.1.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.235.2: Jun 04, 2017 Non-editing teacher can access and edit works of students. (221032 lines) + Version 16.235.3: Jun 04, 2017 Non-editing teachers can not select/unselect groups to which they don't belong. (221107 lines) + Version 16.235.2: Jun 04, 2017 Non-editing teachers can access and edit works of students. (221032 lines) Version 16.235.1: Jun 04, 2017 Limited length of connected users at right column. (221027 lines) Version 16.235: Jun 04, 2017 Fixed bug in notifications about enrolment as a non-editing teacher. Fixed bugs and code refactoring related to users enrolment. (221018 lines) diff --git a/swad_group.c b/swad_group.c index 1fdc51032..d77b81a2b 100644 --- a/swad_group.c +++ b/swad_group.c @@ -419,15 +419,40 @@ static void Grp_PutCheckboxAllGrps (void) { extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *Txt_All_groups; + bool ICanSelUnselGroup; + + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_NET: + ICanSelUnselGroup = false; + break; + case Rol_STD: + case Rol_TCH: + case Rol_DEG_ADM: + case Rol_CTR_ADM: + case Rol_INS_ADM: + case Rol_SYS_ADM: + ICanSelUnselGroup = true; + break; + default: + ICanSelUnselGroup = false; + break; + } fprintf (Gbl.F.Out,"
" "" "
", @@ -2007,6 +2032,7 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp) unsigned NumGrpSel; struct ListCodGrps LstGrpsIBelong; bool IBelongToThisGroup; + bool ICanSelUnselGroup; struct Group *Grp; Rol_Role_t Role; @@ -2017,14 +2043,39 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp) Grp_GetLstCodGrpsUsrBelongs (Gbl.CurrentCrs.Crs.CrsCod,GrpTyp->GrpTypCod, Gbl.Usrs.Me.UsrDat.UsrCod,&LstGrpsIBelong); - /***** List the groups *****/ + /***** List the groups of this type *****/ for (NumGrpThisType = 0; NumGrpThisType < GrpTyp->NumGrps; NumGrpThisType++) { + /* Pointer to group */ Grp = &(GrpTyp->LstGrps[NumGrpThisType]); + + /* Check if I belong to his group */ IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong); + /* Check if I can select / unselect this group */ + if (IBelongToThisGroup) + ICanSelUnselGroup = true; + else + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_NET: + ICanSelUnselGroup = IBelongToThisGroup; + break; + case Rol_STD: + case Rol_TCH: + case Rol_DEG_ADM: + case Rol_CTR_ADM: + case Rol_INS_ADM: + case Rol_SYS_ADM: + ICanSelUnselGroup = true; + break; + default: + ICanSelUnselGroup = false; + break; + } + /* Put checkbox to select the group */ fprintf (Gbl.F.Out,"" ""); + if (ICanSelUnselGroup) + fprintf (Gbl.F.Out," onclick=\"checkParent(this,'AllGroups')\""); + else + fprintf (Gbl.F.Out," disabled=\"disabled\""); + fprintf (Gbl.F.Out," />"); Grp_WriteRowGrp (Grp,IBelongToThisGroup); @@ -2059,23 +2114,45 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp) /***** Write rows to select the students who don't belong to any group *****/ /* To get the students who don't belong to a type of group, use group code -(GrpTyp->GrpTypCod) */ /* Write checkbox to select the group */ + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_NET: + ICanSelUnselGroup = false; + break; + case Rol_STD: + case Rol_TCH: + case Rol_DEG_ADM: + case Rol_CTR_ADM: + case Rol_INS_ADM: + case Rol_SYS_ADM: + ICanSelUnselGroup = true; + break; + default: + ICanSelUnselGroup = false; + break; + } fprintf (Gbl.F.Out,"" "" "GrpTypCod), -(GrpTyp->GrpTypCod)); - if (Gbl.Usrs.ClassPhoto.AllGroups) - fprintf (Gbl.F.Out," checked=\"checked\""); + if (ICanSelUnselGroup) + { + if (Gbl.Usrs.ClassPhoto.AllGroups) + fprintf (Gbl.F.Out," checked=\"checked\""); + else + for (NumGrpSel = 0; + NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps; + NumGrpSel++) + if (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel] == -(GrpTyp->GrpTypCod)) + { + fprintf (Gbl.F.Out," checked=\"checked\""); + break; + } + } else - for (NumGrpSel = 0; - NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps; - NumGrpSel++) - if (Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel] == -(GrpTyp->GrpTypCod)) - { - fprintf (Gbl.F.Out," checked=\"checked\""); - break; - } + fprintf (Gbl.F.Out," disabled=\"disabled\""); fprintf (Gbl.F.Out," onclick=\"checkParent(this,'AllGroups')\" />" "");