Version 23.41.2: Oct 29, 2023 Code refactoring in class photo.

This commit is contained in:
acanas 2023-10-29 20:34:03 +01:00
parent 362c522791
commit c9f70dcafb
21 changed files with 47 additions and 45 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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 */

View File

@ -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;

View File

@ -157,7 +157,6 @@ struct Globals
struct
{
unsigned Cols;
bool AllGroups;
} ClassPhoto;
struct
{

View File

@ -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 ("&nbsp;%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;

View File

@ -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
};

View File

@ -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,

View File

@ -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 ();

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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])

View File

@ -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);

View File

@ -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)
{

View File

@ -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 *****/

View File

@ -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);