From 0ae606cf545dbe28de14f191120a0e0449ea8265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 7 Nov 2019 01:13:21 +0100 Subject: [PATCH] Version19.54.10 --- swad_changelog.h | 3 +- swad_group.c | 136 ++++++++++++++++----------------------------- swad_holiday.c | 52 ++++++++--------- swad_institution.c | 37 ++++++------ 4 files changed, 90 insertions(+), 138 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 42c05d117..b47328c9e 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -490,7 +490,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.54.9 (2019-11-07)" +#define Log_PLATFORM_VERSION "SWAD 19.54.10 (2019-11-07)" #define CSS_FILE "swad19.47.css" #define JS_FILE "swad19.39.js" /* @@ -498,6 +498,7 @@ ps2pdf source.ps destination.pdf // TODO: Impedir la creación y edición de proyectos si no son editables. // TODO: Importante: filtrar proyectos por usuarios (igual que en trabajos o en asistencia) + Version 19.54.10: Nov 07, 2019 Code refactoring in HTML select options. (245888 lines) Version 19.54.9: Nov 07, 2019 Code refactoring in HTML select options. Fixed bug in dates form. (245936 lines) Version 19.54.8: Nov 06, 2019 Fixed bug in groups open time. (245925 lines) diff --git a/swad_group.c b/swad_group.c index ac357686c..48671c8f6 100644 --- a/swad_group.c +++ b/swad_group.c @@ -1326,16 +1326,12 @@ static void Grp_ListGroupTypesForEdition (void) HTM_SELECT_Begin (true, "name=\"MandatoryEnrolment\"" " style=\"width:150px;\""); - fprintf (Gbl.F.Out,"" - "", - Txt_It_is_mandatory_to_choose_a_group); + HTM_OPTION (HTM_Type_STRING,"N", + !Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MandatoryEnrolment,false, + "%s",Txt_It_is_optional_to_choose_a_group); + HTM_OPTION (HTM_Type_STRING,"Y", + Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MandatoryEnrolment,false, + "%s",Txt_It_is_mandatory_to_choose_a_group); HTM_SELECT_End (); Frm_EndForm (); HTM_TD_End (); @@ -1347,16 +1343,12 @@ static void Grp_ListGroupTypesForEdition (void) HTM_SELECT_Begin (true, "name=\"MultipleEnrolment\"" " style=\"width:150px;\""); - fprintf (Gbl.F.Out,"" - "", - Txt_A_student_can_belong_to_several_groups); + HTM_OPTION (HTM_Type_STRING,"N", + !Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MultipleEnrolment,false, + "%s",Txt_A_student_can_only_belong_to_one_group); + HTM_OPTION (HTM_Type_STRING,"Y", + Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MultipleEnrolment,false, + "%s",Txt_A_student_can_belong_to_several_groups); HTM_SELECT_End (); Frm_EndForm (); HTM_TD_End (); @@ -1555,10 +1547,9 @@ static void Grp_ListGroupsForEdition (void) NumTipGrpAux++) { GrpTypAux = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumTipGrpAux]; - fprintf (Gbl.F.Out,"",GrpTypAux->GrpTypName); + HTM_OPTION (HTM_Type_LONG,&GrpTypAux->GrpTypCod, + GrpTypAux->GrpTypCod == GrpTyp->GrpTypCod,false, + "%s",GrpTypAux->GrpTypName); } /* End selector */ @@ -1584,31 +1575,22 @@ static void Grp_ListGroupsForEdition (void) "name=\"ClaCod\" style=\"width:100px;\""); /* Option for no assigned classroom */ - fprintf (Gbl.F.Out,"", - Txt_No_assigned_classroom); + HTM_OPTION (HTM_Type_STRING,"-1", + Grp->Classroom.ClaCod < 0,false, + "%s",Txt_No_assigned_classroom); /* Option for another classroom */ - fprintf (Gbl.F.Out,"", - Txt_Another_classroom); + HTM_OPTION (HTM_Type_STRING,"0", + Grp->Classroom.ClaCod == 0,false, + "%s",Txt_Another_classroom); /* Options for classrooms */ for (NumCla = 0; NumCla < Gbl.Classrooms.Num; NumCla++) - { - fprintf (Gbl.F.Out,"", - Gbl.Classrooms.Lst[NumCla].ShrtName); - } + HTM_OPTION (HTM_Type_LONG,&Gbl.Classrooms.Lst[NumCla].ClaCod, + Gbl.Classrooms.Lst[NumCla].ClaCod == Grp->Classroom.ClaCod,false, + "%s",Gbl.Classrooms.Lst[NumCla].ShrtName); /* End selector */ HTM_SELECT_End (); @@ -2502,16 +2484,12 @@ static void Grp_PutFormToCreateGroupType (void) HTM_TD_Begin ("class=\"CM\""); HTM_SELECT_Begin (false, "name=\"MandatoryEnrolment\" style=\"width:150px;\""); - fprintf (Gbl.F.Out,"" - "", - Txt_It_is_mandatory_to_choose_a_group); + HTM_OPTION (HTM_Type_STRING,"N", + !Gbl.Crs.Grps.GrpTyp.MandatoryEnrolment,false, + "%s",Txt_It_is_optional_to_choose_a_group); + HTM_OPTION (HTM_Type_STRING,"Y", + Gbl.Crs.Grps.GrpTyp.MandatoryEnrolment,false, + "%s",Txt_It_is_mandatory_to_choose_a_group); HTM_SELECT_End (); HTM_TD_End (); @@ -2519,16 +2497,12 @@ static void Grp_PutFormToCreateGroupType (void) HTM_TD_Begin ("class=\"CM\""); HTM_SELECT_Begin (false, "name=\"MultipleEnrolment\" style=\"width:150px;\""); - fprintf (Gbl.F.Out,"" - "", - Txt_A_student_can_belong_to_several_groups); + HTM_OPTION (HTM_Type_STRING,"N", + !Gbl.Crs.Grps.GrpTyp.MultipleEnrolment,false, + "%s",Txt_A_student_can_only_belong_to_one_group); + HTM_OPTION (HTM_Type_STRING,"Y", + Gbl.Crs.Grps.GrpTyp.MultipleEnrolment,false, + "%s",Txt_A_student_can_belong_to_several_groups); HTM_SELECT_End (); HTM_TD_End (); @@ -2629,15 +2603,10 @@ static void Grp_PutFormToCreateGroup (void) for (NumGrpTyp = 0; NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; NumGrpTyp++) - { - fprintf (Gbl.F.Out,"", - Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName); - } + HTM_OPTION (HTM_Type_LONG,&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod, + Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod == + Gbl.Crs.Grps.GrpTyp.GrpTypCod,false, + "%s",Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName); /* End selector */ HTM_SELECT_End (); @@ -2656,31 +2625,20 @@ static void Grp_PutFormToCreateGroup (void) "name=\"ClaCod\" style=\"width:100px;\""); /* Option for no assigned classroom */ - fprintf (Gbl.F.Out,"", - Txt_No_assigned_classroom); + HTM_OPTION (HTM_Type_STRING,"-1",Gbl.Crs.Grps.ClaCod < 0,false, + "%s",Txt_No_assigned_classroom); /* Option for another classroom */ - fprintf (Gbl.F.Out,"", - Txt_Another_classroom); + HTM_OPTION (HTM_Type_STRING,"0",Gbl.Crs.Grps.ClaCod == 0,false, + "%s",Txt_Another_classroom); /* Options for classrooms */ for (NumCla = 0; NumCla < Gbl.Classrooms.Num; NumCla++) - { - fprintf (Gbl.F.Out,"", - Gbl.Classrooms.Lst[NumCla].ShrtName); - } + HTM_OPTION (HTM_Type_LONG,&Gbl.Classrooms.Lst[NumCla].ClaCod, + Gbl.Classrooms.Lst[NumCla].ClaCod == Gbl.Crs.Grps.ClaCod,false, + "%s",Gbl.Classrooms.Lst[NumCla].ShrtName); /* End selector */ HTM_SELECT_End (); diff --git a/swad_holiday.c b/swad_holiday.c index bc13d76ce..7225bf217 100644 --- a/swad_holiday.c +++ b/swad_holiday.c @@ -551,6 +551,7 @@ static void Hld_ListHolidaysForEdition (void) unsigned NumPlc; struct Holiday *Hld; Hld_HolidayType_t HolidayType; + unsigned HolidayTypeUnsigned; /***** Begin box and table *****/ Box_StartBoxTable (NULL,Txt_Holidays,Cal_PutIconToSeeCalendar, @@ -587,18 +588,14 @@ static void Hld_ListHolidaysForEdition (void) Hld_PutParamHldCod (Hld->HldCod); HTM_SELECT_Begin (true, "name=\"PlcCod\" class=\"PLC_COD\""); - fprintf (Gbl.F.Out,"",Txt_All_places); + HTM_OPTION (HTM_Type_STRING,"-1",Hld->PlcCod <= 0,false, + "%s",Txt_All_places); for (NumPlc = 0; NumPlc < Gbl.Plcs.Num; NumPlc++) - fprintf (Gbl.F.Out,"", - Gbl.Plcs.Lst[NumPlc].PlcCod, - Gbl.Plcs.Lst[NumPlc].PlcCod == Hld->PlcCod ? " selected=\"selected\"" : - "", - Gbl.Plcs.Lst[NumPlc].ShrtName); + HTM_OPTION (HTM_Type_LONG,&Gbl.Plcs.Lst[NumPlc].PlcCod, + Gbl.Plcs.Lst[NumPlc].PlcCod == Hld->PlcCod,false, + "%s",Gbl.Plcs.Lst[NumPlc].ShrtName); HTM_SELECT_End (); Frm_EndForm (); HTM_TD_End (); @@ -612,11 +609,12 @@ static void Hld_ListHolidaysForEdition (void) for (HolidayType = (Hld_HolidayType_t) 0; HolidayType < Hld_NUM_TYPES_HOLIDAY; HolidayType++) - fprintf (Gbl.F.Out,"", - (unsigned) HolidayType, - HolidayType == Hld->HldTyp ? " selected=\"selected\"" : - "", - Txt_HOLIDAY_TYPES[HolidayType]); + { + HolidayTypeUnsigned = (unsigned) HolidayType; + HTM_OPTION (HTM_Type_UNSIGNED,&HolidayTypeUnsigned, + HolidayType == Hld->HldTyp,false, + "%s",Txt_HOLIDAY_TYPES[HolidayType]); + } HTM_SELECT_End (); Frm_EndForm (); HTM_TD_End (); @@ -961,6 +959,7 @@ static void Hld_PutFormToCreateHoliday (void) extern const char *Txt_Create_holiday; unsigned NumPlc; Hld_HolidayType_t HolidayType; + unsigned HolidayTypeUnsigned; /***** Begin form *****/ Frm_StartForm (ActNewHld); @@ -986,18 +985,14 @@ static void Hld_PutFormToCreateHoliday (void) HTM_TD_Begin ("class=\"CM\""); HTM_SELECT_Begin (false, "name=\"PlcCod\" class=\"PLC_COD\""); - fprintf (Gbl.F.Out,"",Txt_All_places); + HTM_OPTION (HTM_Type_STRING,"-1",Hld_EditingHld->PlcCod <= 0,false, + "%s",Txt_All_places); for (NumPlc = 0; NumPlc < Gbl.Plcs.Num; NumPlc++) - fprintf (Gbl.F.Out,"", - Gbl.Plcs.Lst[NumPlc].PlcCod, - Gbl.Plcs.Lst[NumPlc].PlcCod == Hld_EditingHld->PlcCod ? " selected=\"selected\"" : - "", - Gbl.Plcs.Lst[NumPlc].ShrtName); + HTM_OPTION (HTM_Type_LONG,&Gbl.Plcs.Lst[NumPlc].PlcCod, + Gbl.Plcs.Lst[NumPlc].PlcCod == Hld_EditingHld->PlcCod,false, + "%s",Gbl.Plcs.Lst[NumPlc].ShrtName); HTM_SELECT_End (); HTM_TD_End (); @@ -1008,11 +1003,12 @@ static void Hld_PutFormToCreateHoliday (void) for (HolidayType = (Hld_HolidayType_t) 0; HolidayType < Hld_NUM_TYPES_HOLIDAY; HolidayType++) - fprintf (Gbl.F.Out,"", - (unsigned) HolidayType, - HolidayType == Hld_EditingHld->HldTyp ? " selected=\"selected\"" : - "", - Txt_HOLIDAY_TYPES[HolidayType]); + { + HolidayTypeUnsigned = (unsigned) HolidayType; + HTM_OPTION (HTM_Type_UNSIGNED,&HolidayTypeUnsigned, + HolidayType == Hld_EditingHld->HldTyp,false, + "%s",Txt_HOLIDAY_TYPES[HolidayType]); + } HTM_SELECT_End (); HTM_TD_End (); diff --git a/swad_institution.c b/swad_institution.c index 47de1e1a5..92dca3692 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -375,11 +375,9 @@ static void Ins_Configuration (bool PrintView) for (NumCty = 0; NumCty < Gbl.Hierarchy.Sys.Ctys.Num; NumCty++) - fprintf (Gbl.F.Out,"", - Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod, - Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod == Gbl.Hierarchy.Cty.CtyCod ? " selected=\"selected\"" : - "", - Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]); + HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod, + Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod == Gbl.Hierarchy.Cty.CtyCod,false, + "%s",Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]); HTM_SELECT_End (); Frm_EndForm (); @@ -1377,11 +1375,9 @@ void Ins_WriteSelectorOfInstitution (void) HTM_SELECT_Begin (false, "id=\"ins\" name=\"ins\" class=\"HIE_SEL\"" " disabled=\"disabled\""); - fprintf (Gbl.F.Out,"", - Txt_Institution); + HTM_OPTION (HTM_Type_STRING,"", + Gbl.Hierarchy.Ins.InsCod < 0,true, + "[%s]",Txt_Institution); if (Gbl.Hierarchy.Cty.CtyCod > 0) { @@ -1407,10 +1403,10 @@ void Ins_WriteSelectorOfInstitution (void) Lay_ShowErrorAndExit ("Wrong code of institution."); /* Write option */ - fprintf (Gbl.F.Out,"",row[1]); + HTM_OPTION (HTM_Type_LONG,&InsCod, + Gbl.Hierarchy.Ins.InsCod > 0 && + InsCod == Gbl.Hierarchy.Ins.InsCod,false, + "%s",row[1]); } /***** Free structure that stores the query result *****/ @@ -1435,6 +1431,7 @@ static void Ins_ListInstitutionsForEdition (void) struct UsrData UsrDat; bool ICanEdit; Ins_StatusTxt_t StatusTxt; + unsigned StatusUnsigned; /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&UsrDat); @@ -1564,12 +1561,12 @@ static void Ins_ListInstitutionsForEdition (void) Ins_PutParamOtherInsCod (Ins->InsCod); HTM_SELECT_Begin (true, "name=\"Status\" class=\"INPUT_STATUS\""); - fprintf (Gbl.F.Out,"" - "", - (unsigned) Ins_GetStatusBitsFromStatusTxt (Ins_STATUS_PENDING), - Txt_INSTITUTION_STATUS[Ins_STATUS_PENDING], - (unsigned) Ins_GetStatusBitsFromStatusTxt (Ins_STATUS_ACTIVE), - Txt_INSTITUTION_STATUS[Ins_STATUS_ACTIVE]); + StatusUnsigned = (unsigned) Ins_GetStatusBitsFromStatusTxt (Ins_STATUS_PENDING); + HTM_OPTION (HTM_Type_UNSIGNED,&StatusUnsigned,true,false, + "%s",Txt_INSTITUTION_STATUS[Ins_STATUS_PENDING]); + StatusUnsigned = (unsigned) Ins_GetStatusBitsFromStatusTxt (Ins_STATUS_ACTIVE); + HTM_OPTION (HTM_Type_UNSIGNED,&StatusUnsigned,true,false, + "%s",Txt_INSTITUTION_STATUS[Ins_STATUS_ACTIVE]); HTM_SELECT_End (); Frm_EndForm (); }