From c9f70dcafb1b246dd02935ba00a0835d267c9e18 Mon Sep 17 00:00:00 2001 From: acanas Date: Sun, 29 Oct 2023 20:34:03 +0100 Subject: [PATCH] Version 23.41.2: Oct 29, 2023 Code refactoring in class photo. --- swad_assignment.c | 2 +- swad_attendance.c | 2 +- swad_calendar.c | 2 +- swad_changelog.h | 4 +++- swad_enrolment.c | 2 +- swad_exam_print.c | 2 +- swad_exam_result.c | 2 +- swad_global.c | 2 +- swad_global.h | 1 - swad_group.c | 20 ++++++++++---------- swad_group.h | 1 + swad_info.c | 8 ++++---- swad_layout.c | 4 ++-- swad_layout.h | 2 +- swad_match_result.c | 2 +- swad_project.c | 2 +- swad_test.c | 2 +- swad_test_print.c | 4 ++-- swad_timetable.c | 2 +- swad_user.c | 22 +++++++++++----------- swad_user_database.c | 4 ++-- 21 files changed, 47 insertions(+), 45 deletions(-) diff --git a/swad_assignment.c b/swad_assignment.c index 281a64b4..2ce60cc2 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -387,7 +387,7 @@ void Asg_PrintOneAssignment (void) Asg_GetAssignmentDataByCod (&Assignments.Asg); /***** Write header *****/ - Lay_WriteHeaderClassPhoto (Vie_PRINT,false); + Lay_WriteHeaderClassPhoto (Vie_PRINT); /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (2); diff --git a/swad_attendance.c b/swad_attendance.c index 2c96d86a..132d3af7 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -2469,7 +2469,7 @@ static void Att_GetListSelectedAttCods (struct Att_Events *Events) { /***** Set which events will be marked as selected by default *****/ if (!Gbl.Crs.Grps.NumGrps || // Course has no groups - Gbl.Usrs.ClassPhoto.AllGroups) // All groups selected + Gbl.Crs.Grps.AllGrps) // All groups selected /* Set all events as selected */ for (NumAttEvent = 0; NumAttEvent < Events->Num; diff --git a/swad_calendar.c b/swad_calendar.c index 650b7a1d..c9e37933 100644 --- a/swad_calendar.c +++ b/swad_calendar.c @@ -267,7 +267,7 @@ static void Cal_DrawCalendar (Act_Action_t ActionSeeCalendar, Box_NOT_CLOSABLE); /***** Write header *****/ - Lay_WriteHeaderClassPhoto (ViewType,false); + Lay_WriteHeaderClassPhoto (ViewType); /***** Preference selector to change first day of week *****/ if (ViewType == Vie_VIEW) diff --git a/swad_changelog.h b/swad_changelog.h index a2532a16..ed4ac3c2 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -633,10 +633,12 @@ Me sale este error, no s "can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod') */ -#define Log_PLATFORM_VERSION "SWAD 23.41 (2023-10-29)" +#define Log_PLATFORM_VERSION "SWAD 23.41.2 (2023-10-29)" #define CSS_FILE "swad23.35.1.css" #define JS_FILE "swad22.49.js" /* + Version 23.41.2: Oct 29, 2023 Code refactoring in class photo. (335361 lines) + Version 23.41.1: Oct 29, 2023 Code refactoring in view/edit/print. (335361 lines) Version 23.41: Oct 29, 2023 Code refactoring in view/edit/print. (335359 lines) Version 23.40: Oct 28, 2023 Code refactoring in view/edit. (335273 lines) Version 23.39: Oct 27, 2023 Code refactoring in contracted/expanded and rubrics. (335209 lines) diff --git a/swad_enrolment.c b/swad_enrolment.c index 698a1b9f..35c52b08 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -1778,7 +1778,7 @@ unsigned Enr_RemAllStdsInCrs (struct Hie_Node *Crs) unsigned NumUsr; /***** Get list of students in current course *****/ - Gbl.Usrs.ClassPhoto.AllGroups = true; // Get all students of the current course + Gbl.Crs.Grps.AllGrps = true; // Get all students of the current course Usr_GetListUsrs (Hie_CRS,Rol_STD); NumStdsInCrs = Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs; diff --git a/swad_exam_print.c b/swad_exam_print.c index 0dd9bb96..bd80ac70 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -581,7 +581,7 @@ static void ExaPrn_ShowExamPrintToFillIt (struct Exa_Exams *Exams, /***** Heading *****/ /* Institution, degree and course */ - Lay_WriteHeaderClassPhoto (Vie_VIEW,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW); /***** Show user and time *****/ HTM_TABLE_BeginWideMarginPadding (10); diff --git a/swad_exam_result.c b/swad_exam_result.c index 1e041766..6811f5b6 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -1348,7 +1348,7 @@ static void ExaRes_ShowExamResult (const struct Exa_Exam *Exam, Hlp_ASSESSMENT_Exams_results,Box_NOT_CLOSABLE); /***** Header *****/ - Lay_WriteHeaderClassPhoto (Vie_VIEW,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW); /***** Check user data *****/ /* Get data of the user who answered the exam print */ diff --git a/swad_global.c b/swad_global.c index 51689b18..7341d937 100644 --- a/swad_global.c +++ b/swad_global.c @@ -190,7 +190,7 @@ void Gbl_InitializeGlobals (void) Gbl.Usrs.Listing.RecsPerPag = Rec_DEF_RECORDS_PER_PAGE; Gbl.Usrs.Listing.WithPhotos = Usr_LIST_WITH_PHOTOS_DEF; - Gbl.Usrs.ClassPhoto.AllGroups = true; + Gbl.Crs.Grps.AllGrps = true; Gbl.Usrs.ClassPhoto.Cols = Usr_CLASS_PHOTO_COLS_DEF; Gbl.Scope.Current = Hie_CRS; diff --git a/swad_global.h b/swad_global.h index b6b220d1..c2c8ea64 100644 --- a/swad_global.h +++ b/swad_global.h @@ -157,7 +157,6 @@ struct Globals struct { unsigned Cols; - bool AllGroups; } ClassPhoto; struct { diff --git a/swad_group.c b/swad_group.c index 6d0bc106..143be4dc 100644 --- a/swad_group.c +++ b/swad_group.c @@ -433,9 +433,9 @@ static void Grp_PutCheckboxAllGrps (Grp_WhichGroups_t GroupsSelectableByStdsOrNE HTM_LABEL_Begin ("class=\"FORM_IN_%s\"",The_GetSuffix ()); HTM_INPUT_CHECKBOX ("AllGroups",HTM_DONT_SUBMIT_ON_CHANGE, "value=\"Y\"%s", - ICanSelUnselGroup ? (Gbl.Usrs.ClassPhoto.AllGroups ? " checked=\"checked\"" - " onclick=\"togglecheckChildren(this,'GrpCods')\"" : - " onclick=\"togglecheckChildren(this,'GrpCods')\"") : + ICanSelUnselGroup ? (Gbl.Crs.Grps.AllGrps ? " checked=\"checked\"" + " onclick=\"togglecheckChildren(this,'GrpCods')\"" : + " onclick=\"togglecheckChildren(this,'GrpCods')\"") : " disabled=\"disabled\""); HTM_TxtF (" %s",Txt_All_groups); HTM_LABEL_End (); @@ -456,11 +456,11 @@ void Grp_PutParsCodGrps (void) /***** Write the boolean parameter that indicates if all groups must be listed *****/ Par_PutParChar ("AllGroups", - Gbl.Usrs.ClassPhoto.AllGroups ? 'Y' : - 'N'); + Gbl.Crs.Grps.AllGrps ? 'Y' : + 'N'); /***** Write the parameter with the list of group codes to show *****/ - if (!Gbl.Usrs.ClassPhoto.AllGroups && + if (!Gbl.Crs.Grps.AllGrps && Gbl.Crs.Grps.LstGrpsSel.NumGrps) { MaxLengthGrpCods = Gbl.Crs.Grps.LstGrpsSel.NumGrps * (Cns_MAX_DECIMAL_DIGITS_LONG + 1) - 1; @@ -498,7 +498,7 @@ void Grp_GetParCodsSeveralGrpsToShowUsrs (void) return; /***** Get boolean parameter that indicates if all groups must be listed *****/ - Gbl.Usrs.ClassPhoto.AllGroups = Par_GetParBool ("AllGroups"); + Gbl.Crs.Grps.AllGrps = Par_GetParBool ("AllGroups"); /***** Get parameter with list of groups selected *****/ Grp_GetParCodsSeveralGrps (); @@ -532,7 +532,7 @@ void Grp_GetParCodsSeveralGrpsToShowUsrs (void) /***** If no groups selected ==> show all groups *****/ if (!Gbl.Crs.Grps.LstGrpsSel.NumGrps) - Gbl.Usrs.ClassPhoto.AllGroups = true; + Gbl.Crs.Grps.AllGrps = true; } /*****************************************************************************/ @@ -2146,7 +2146,7 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp, } /* This group should be checked? */ - if (Gbl.Usrs.ClassPhoto.AllGroups) + if (Gbl.Crs.Grps.AllGrps) Checked = true; else for (NumGrpSel = 0, Checked = false; @@ -2186,7 +2186,7 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp, ICanSelUnselGroup = (Gbl.Usrs.Me.Role.Logged >= Rol_STD); if (ICanSelUnselGroup) { - if (Gbl.Usrs.ClassPhoto.AllGroups) + if (Gbl.Crs.Grps.AllGrps) Checked = true; else for (NumGrpSel = 0, Checked = false; diff --git a/swad_group.h b/swad_group.h index 3d2ebbc1..5b7877e7 100644 --- a/swad_group.h +++ b/swad_group.h @@ -154,6 +154,7 @@ struct Grp_Groups unsigned MaxStudents; bool Open; bool FileZones; + bool AllGrps; // All groups selected? struct ListCodGrps LstGrpsSel; Grp_WhichGroups_t WhichGrps; // Show my groups or all groups }; diff --git a/swad_info.c b/swad_info.c index da9afc44..02d5bee1 100644 --- a/swad_info.c +++ b/swad_info.c @@ -1441,7 +1441,7 @@ static bool Inf_CheckAndShowPlainTxt (void) if (Gbl.Crs.Info.Type == Inf_INTRODUCTION || Gbl.Crs.Info.Type == Inf_TEACHING_GUIDE) - Lay_WriteHeaderClassPhoto (Vie_VIEW,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW); HTM_DIV_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); @@ -1531,7 +1531,7 @@ static bool Inf_CheckAndShowRichTxt (void) if (Gbl.Crs.Info.Type == Inf_INTRODUCTION || Gbl.Crs.Info.Type == Inf_TEACHING_GUIDE) - Lay_WriteHeaderClassPhoto (Vie_VIEW,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW); HTM_DIV_Begin ("id=\"crs_info\" class=\"LM CRS_INFO_%s\"", The_GetSuffix ()); @@ -1664,7 +1664,7 @@ void Inf_EditPlainTxtInfo (void) if (Gbl.Crs.Info.Type == Inf_INTRODUCTION || Gbl.Crs.Info.Type == Inf_TEACHING_GUIDE) - Lay_WriteHeaderClassPhoto (Vie_VIEW,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW); /***** Get info text from database *****/ Inf_GetInfoTxtFromDB (Gbl.Hierarchy.Node[Hie_CRS].HieCod,Gbl.Crs.Info.Type, @@ -1732,7 +1732,7 @@ void Inf_EditRichTxtInfo (void) if (Gbl.Crs.Info.Type == Inf_INTRODUCTION || Gbl.Crs.Info.Type == Inf_TEACHING_GUIDE) - Lay_WriteHeaderClassPhoto (Vie_VIEW,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW); /***** Get info text from database *****/ Inf_GetInfoTxtFromDB (Gbl.Hierarchy.Node[Hie_CRS].HieCod,Gbl.Crs.Info.Type, diff --git a/swad_layout.c b/swad_layout.c index be776c27..f35ba982 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1462,7 +1462,7 @@ static void Lay_WriteFootFromHTMLFile (void) /****** Write header and footer of the class photo or academic calendar ******/ /*****************************************************************************/ -void Lay_WriteHeaderClassPhoto (Vie_ViewType_t ViewType,bool DrawingClassPhoto) +void Lay_WriteHeaderClassPhoto (Vie_ViewType_t ViewType) { struct Hie_Node Hie[Hie_NUM_LEVELS]; @@ -1532,7 +1532,7 @@ void Lay_WriteHeaderClassPhoto (Vie_ViewType_t ViewType,bool DrawingClassPhoto) if (Hie[Hie_CRS].HieCod > 0) { HTM_Txt (Hie[Hie_CRS].FullName); - if (DrawingClassPhoto && !Gbl.Usrs.ClassPhoto.AllGroups) + if (!Gbl.Crs.Grps.AllGrps) { HTM_BR (); Grp_WriteNamesOfSelectedGrps (); diff --git a/swad_layout.h b/swad_layout.h index 69d26f1c..e1c09b47 100644 --- a/swad_layout.h +++ b/swad_layout.h @@ -68,7 +68,7 @@ void Lay_WriteAboutZone (void); void Lay_RefreshNotifsAndConnected (void); void Lay_RefreshLastClicks (void); -void Lay_WriteHeaderClassPhoto (Vie_ViewType_t ViewType,bool DrawingClassPhoto); +void Lay_WriteHeaderClassPhoto (Vie_ViewType_t ViewType); void Lay_AdvertisementMobile (void); diff --git a/swad_match_result.c b/swad_match_result.c index 44395b96..3a9cd43a 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -1097,7 +1097,7 @@ void MchRes_ShowOneMchResult (void) Box_BoxBegin (NULL,Match.Title, NULL,NULL, Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE); - Lay_WriteHeaderClassPhoto (Vie_VIEW,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW); /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (10); diff --git a/swad_project.c b/swad_project.c index 0d73e180..42653faa 100644 --- a/swad_project.c +++ b/swad_project.c @@ -1413,7 +1413,7 @@ void Prj_PrintOneProject (void) Prj_GetProjectDataByCod (&Projects.Prj); /***** Write header *****/ - Lay_WriteHeaderClassPhoto (Vie_PRINT,false); + Lay_WriteHeaderClassPhoto (Vie_PRINT); /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (2); diff --git a/swad_test.c b/swad_test.c index 903f3bf0..a42bdb94 100644 --- a/swad_test.c +++ b/swad_test.c @@ -347,7 +347,7 @@ void Tst_AssessTest (void) Box_BoxBegin (NULL,Txt_Result, NULL,NULL, Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); - Lay_WriteHeaderClassPhoto (Vie_VIEW,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW); /***** Header *****/ if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) diff --git a/swad_test_print.c b/swad_test_print.c index 0054f699..35ddb5ad 100644 --- a/swad_test_print.c +++ b/swad_test_print.c @@ -218,7 +218,7 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print, Box_BoxBegin (NULL,Txt_Test, NULL,NULL, Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); - Lay_WriteHeaderClassPhoto (Vie_VIEW,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW); if (Print->NumQsts.All) { @@ -2236,7 +2236,7 @@ void TstPrn_ShowOnePrint (void) Box_BoxBegin (NULL,Txt_Result, NULL,NULL, Hlp_ASSESSMENT_Tests_results,Box_NOT_CLOSABLE); - Lay_WriteHeaderClassPhoto (Vie_VIEW,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW); /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (10); diff --git a/swad_timetable.c b/swad_timetable.c index 25684a70..af00c71d 100644 --- a/swad_timetable.c +++ b/swad_timetable.c @@ -371,7 +371,7 @@ void Tmt_ShowClassTimeTable (void) /***** Begin time table drawing *****/ if (Timetable.Type == Tmt_COURSE_TIMETABLE) - Lay_WriteHeaderClassPhoto (ViewType,false); + Lay_WriteHeaderClassPhoto (ViewType); switch (ViewType) { diff --git a/swad_user.c b/swad_user.c index 7f697ecc..5cd3b196 100644 --- a/swad_user.c +++ b/swad_user.c @@ -4103,7 +4103,7 @@ static void Usr_ListMainDataStds (bool PutCheckBoxToSelectUsr) Err_NotEnoughMemoryExit (); /***** Begin table with list of students *****/ - if (!Gbl.Usrs.ClassPhoto.AllGroups) + if (!Gbl.Crs.Grps.AllGrps) { HTM_TR_Begin (NULL); HTM_TD_Begin ("colspan=\"%u\" class=\"TIT CM\"", @@ -4422,7 +4422,7 @@ void Usr_ListAllDataStds (void) /***** Begin table with list of students *****/ HTM_TABLE_BeginWide (); - if (!Gbl.Usrs.ClassPhoto.AllGroups) + if (!Gbl.Crs.Grps.AllGrps) { HTM_TR_Begin (NULL); HTM_TD_Begin ("colspan=\"%u\" class=\"TIT CM\"",NumColsTotal); @@ -5082,7 +5082,7 @@ void Usr_SeeGuests (void) /***** Draw a class photo with guests *****/ if (Gbl.Usrs.Me.ListType == Set_USR_LIST_AS_CLASS_PHOTO) - Lay_WriteHeaderClassPhoto (Vie_VIEW,true); + Lay_WriteHeaderClassPhoto (Vie_VIEW); /* Set options allowed */ PutForm = Usr_SetOptionsListUsrsAllowed (Rol_GST,ICanChooseOption); @@ -5232,7 +5232,7 @@ void Usr_SeeStudents (void) /***** Draw a class photo with students of the course *****/ if (Gbl.Usrs.Me.ListType == Set_USR_LIST_AS_CLASS_PHOTO) - Lay_WriteHeaderClassPhoto (Vie_VIEW,true); + Lay_WriteHeaderClassPhoto (Vie_VIEW); /* Set options allowed */ PutForm = Usr_SetOptionsListUsrsAllowed (Rol_STD,ICanChooseOption); @@ -5398,7 +5398,7 @@ void Usr_SeeTeachers (void) /***** Draw a class photo with teachers of the course *****/ if (Gbl.Usrs.Me.ListType == Set_USR_LIST_AS_CLASS_PHOTO) - Lay_WriteHeaderClassPhoto (Vie_VIEW,true); + Lay_WriteHeaderClassPhoto (Vie_VIEW); /* Set options allowed */ PutForm = Usr_SetOptionsListUsrsAllowed (Rol_TCH,ICanChooseOption); @@ -5928,7 +5928,7 @@ void Usr_SeeGstClassPhotoPrn (void) if (Gbl.Usrs.LstUsrs[Rol_GST].NumUsrs) { /***** Draw the guests' class photo *****/ - Lay_WriteHeaderClassPhoto (Vie_PRINT,true); + Lay_WriteHeaderClassPhoto (Vie_PRINT); HTM_TABLE_BeginWide (); Usr_DrawClassPhoto (Usr_CLASS_PHOTO_PRN, Rol_GST,&Gbl.Usrs.Selected,false); @@ -5966,7 +5966,7 @@ void Usr_SeeStdClassPhotoPrn (void) if (Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs) { /***** Draw the students' class photo *****/ - Lay_WriteHeaderClassPhoto (Vie_PRINT,true); + Lay_WriteHeaderClassPhoto (Vie_PRINT); HTM_TABLE_BeginWide (); Usr_DrawClassPhoto (Usr_CLASS_PHOTO_PRN, Rol_STD,&Gbl.Usrs.Selected,false); @@ -6028,7 +6028,7 @@ void Usr_SeeTchClassPhotoPrn (void) if (NumUsrs) { /***** Draw the teachers' class photo *****/ - Lay_WriteHeaderClassPhoto (Vie_PRINT,true); + Lay_WriteHeaderClassPhoto (Vie_PRINT); HTM_TABLE_BeginWide (); /* List teachers and non-editing teachers */ @@ -6240,7 +6240,7 @@ void Usr_ShowWarningNoUsersFound (Rol_Role_t Role) extern const char *Txt_Register_students; extern const char *Txt_Register_teacher; - if (Gbl.Usrs.ClassPhoto.AllGroups && // All groups selected + if (Gbl.Crs.Grps.AllGrps && // All groups selected Role == Rol_STD && // No students found Gbl.Usrs.Me.Role.Logged == Rol_TCH) // Course selected and I am logged as teacher /***** Show alert and button to enrol students *****/ @@ -6249,8 +6249,8 @@ void Usr_ShowWarningNoUsersFound (Rol_Role_t Role) Btn_CREATE_BUTTON,Txt_Register_students, Ale_WARNING,Txt_No_users_found[Rol_STD]); - else if (Gbl.Usrs.ClassPhoto.AllGroups && // All groups selected - Role == Rol_TCH && // No teachers found + else if (Gbl.Crs.Grps.AllGrps && // All groups selected + Role == Rol_TCH && // No teachers found Gbl.Hierarchy.Level == Hie_CRS && // Course selected Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) // I am an administrator /***** Show alert and button to enrol students *****/ diff --git a/swad_user_database.c b/swad_user_database.c index 34a172ba..4efe1654 100644 --- a/swad_user_database.c +++ b/swad_user_database.c @@ -512,7 +512,7 @@ void Usr_DB_BuildQueryToGetUsrsLstCrs (char **Query,Rol_Role_t Role) */ /***** If there are no groups selected, don't do anything *****/ - if (!Gbl.Usrs.ClassPhoto.AllGroups && + if (!Gbl.Crs.Grps.AllGrps && !Gbl.Crs.Grps.LstGrpsSel.NumGrps) { *Query = NULL; @@ -553,7 +553,7 @@ void Usr_DB_BuildQueryToGetUsrsLstCrs (char **Query,Rol_Role_t Role) (unsigned) Role); /***** Select users in selected groups *****/ - if (!Gbl.Usrs.ClassPhoto.AllGroups) + if (!Gbl.Crs.Grps.AllGrps) { /***** Get list of groups types in current course *****/ Grp_GetListGrpTypesInCurrentCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS);