diff --git a/swad_HTML.c b/swad_HTML.c index f5abb3d9..f274791c 100644 --- a/swad_HTML.c +++ b/swad_HTML.c @@ -833,6 +833,44 @@ void HTM_INPUT_TEXT (const char *Name,unsigned MaxLength,const char *Value,bool fprintf (Gbl.F.Out," />"); } +void HTM_INPUT_SEARCH (const char *Name,unsigned MaxLength,const char *Value,bool SubmitOnChange, + const char *fmt,...) + { + va_list ap; + int NumBytesPrinted; + char *Attr; + + fprintf (Gbl.F.Out,""); + } + void HTM_INPUT_TEL (const char *Name,const char *Value,bool SubmitOnChange, const char *fmt,...) { @@ -1030,6 +1068,41 @@ void HTM_INPUT_RADIO (const char *Name,bool SubmitOnClick, fprintf (Gbl.F.Out," />"); } +void HTM_INPUT_CHECKBOX (const char *Name,bool SubmitOnChange, + const char *fmt,...) + { + va_list ap; + int NumBytesPrinted; + char *Attr; + + fprintf (Gbl.F.Out,""); + } + /*****************************************************************************/ /********************************* Text areas ********************************/ /*****************************************************************************/ diff --git a/swad_HTML.h b/swad_HTML.h index a22925ca..d82f6531 100644 --- a/swad_HTML.h +++ b/swad_HTML.h @@ -91,6 +91,8 @@ void HTM_LABEL_End (void); void HTM_INPUT_TEXT (const char *Name,unsigned MaxLength,const char *Value,bool SubmitOnChange, const char *fmt,...); +void HTM_INPUT_SEARCH (const char *Name,unsigned MaxLength,const char *Value,bool SubmitOnChange, + const char *fmt,...); void HTM_INPUT_TEL (const char *Name,const char *Value,bool SubmitOnChange, const char *fmt,...); void HTM_INPUT_EMAIL (const char *Name,unsigned MaxLength,const char *Value, @@ -105,6 +107,8 @@ void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder, void HTM_INPUT_NUMBER (const char *Name,long Min,long Max,long Value,bool Disabled); void HTM_INPUT_RADIO (const char *Name,bool SubmitOnClick, const char *fmt,...); +void HTM_INPUT_CHECKBOX (const char *Name,bool SubmitOnChange, + const char *fmt,...); void HTM_TEXTAREA_Begin (const char *fmt,...); void HTM_TEXTAREA_End (void); diff --git a/swad_assignment.c b/swad_assignment.c index e53a7ca9..70a8b268 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -1266,11 +1266,10 @@ static void Asg_ShowLstGrpsToEditAssignment (long AsgCod) HTM_TD_Begin ("colspan=\"7\" class=\"DAT LM\""); HTM_LABEL_Begin (NULL); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("WholeCrs",false, + "id=\"WholeCrs\" value=\"Y\"%s" + " onclick=\"uncheckChildren(this,'GrpCods')\"", + Asg_CheckIfAsgIsAssociatedToGrps (AsgCod) ? "" : " checked=\"checked\""); fprintf (Gbl.F.Out,"%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); HTM_TD_End (); diff --git a/swad_attendance.c b/swad_attendance.c index c7c95453..d968b883 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -1214,11 +1214,10 @@ static void Att_ShowLstGrpsToEditAttEvent (long AttCod) HTM_TD_Begin ("colspan=\"7\" class=\"DAT LM\""); HTM_LABEL_Begin (NULL); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("WholeCrs",false, + "id=\"WholeCrs\" value=\"Y\"%s" + " onclick=\"uncheckChildren(this,'GrpCods')\"", + Att_CheckIfAttEventIsAssociatedToGrps (AttCod) ? "" : " checked=\"checked\""); fprintf (Gbl.F.Out,"%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); HTM_TD_End (); @@ -2089,14 +2088,11 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr, /***** Checkbox to select user *****/ HTM_TD_Begin ("class=\"CT COLOR%u\"",Gbl.RowEvenOdd); - fprintf (Gbl.F.Out,"EncryptedUsrCod); - if (Present) // This student has attended to the event? - fprintf (Gbl.F.Out," checked=\"checked\""); - if (!ICanChangeStdAttendance) - fprintf (Gbl.F.Out," disabled=\"disabled\""); - fprintf (Gbl.F.Out," />"); + HTM_INPUT_CHECKBOX ("UsrCodStd",false, + "id=\"Std%u\" value=\"%s\"%s%s", + NumUsr,UsrDat->EncryptedUsrCod, + Present ? " checked=\"checked\"" : "", + ICanChangeStdAttendance ? "" : " disabled=\"disabled\""); HTM_TD_End (); /***** Write number of student in the list *****/ @@ -3128,13 +3124,10 @@ static void Att_ListEventsToSelect (Att_TypeOfView_t TypeOfView) HTM_TR_Begin (NULL); HTM_TD_Begin ("class=\"DAT CT COLOR%u\"",Gbl.RowEvenOdd); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("AttCods",false, + "id=\"Att%u\" value=\"%ld\"%s", + NumAttEvent,Gbl.AttEvents.Lst[NumAttEvent].AttCod, + Gbl.AttEvents.Lst[NumAttEvent].Selected ? " checked=\"checked\"" : ""); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); diff --git a/swad_changelog.h b/swad_changelog.h index 58ef2bc6..8d7b2e42 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -487,7 +487,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.51.17 (2019-11-04)" +#define Log_PLATFORM_VERSION "SWAD 19.51.18 (2019-11-04)" #define CSS_FILE "swad19.47.css" #define JS_FILE "swad19.39.js" /* @@ -495,6 +495,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.51.18: Nov 04, 2019 Code refactoring in HTML inputs. (245912 lines) Version 19.51.17: Nov 04, 2019 Code refactoring in HTML inputs. (245887 lines) Version 19.51.16: Nov 04, 2019 Code refactoring in HTML inputs. (245893 lines) Version 19.51.15: Nov 04, 2019 Code refactoring in HTML inputs. (245874 lines) diff --git a/swad_cookie.c b/swad_cookie.c index f38ec825..6460e38a 100644 --- a/swad_cookie.c +++ b/swad_cookie.c @@ -81,13 +81,11 @@ void Coo_EditMyPrefsOnCookies (void) "DAT"); /* Check box */ HTM_LABEL_Begin (NULL); - fprintf (Gbl.F.Out,"", - Gbl.Form.Id); - fprintf (Gbl.F.Out,"%s",Txt_Accept_third_party_cookies_to_view_multimedia_content_from_other_websites); + HTM_INPUT_CHECKBOX ("cookies",true, + "value=\"Y\"%s", + Gbl.Usrs.Me.UsrDat.Prefs.AcceptThirdPartyCookies ? " checked=\"checked\"" : ""); + fprintf (Gbl.F.Out,"%s", + Txt_Accept_third_party_cookies_to_view_multimedia_content_from_other_websites); HTM_LABEL_End (); /* End container */ diff --git a/swad_group.c b/swad_group.c index b36323b6..2f69a17a 100644 --- a/swad_group.c +++ b/swad_group.c @@ -454,18 +454,13 @@ static void Grp_PutCheckboxAllGrps (Grp_WhichGroups_t GroupsSelectableByStdsOrNE } HTM_DIV_Begin ("class=\"CONTEXT_OPT\""); - fprintf (Gbl.F.Out,""); - HTM_LABEL_Begin ("for=\"AllGroups\" class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_INPUT_CHECKBOX ("AllGroups",false, + "value=\"Y\"%s", + ICanSelUnselGroup ? (Gbl.Usrs.ClassPhoto.AllGroups ? " checked=\"checked\"" + " onclick=\"togglecheckChildren(this,'GrpCods')\"" : + " onclick=\"togglecheckChildren(this,'GrpCods')\"") : + " disabled=\"disabled\""); fprintf (Gbl.F.Out," %s",Txt_All_groups); HTM_LABEL_End (); HTM_DIV_End (); @@ -1714,19 +1709,8 @@ void Grp_ListGrpsToEditAsgAttSvyMch (struct GroupType *GrpTyp,long Cod, Grp = &(GrpTyp->LstGrps[NumGrpThisType]); IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong); - /* Put checkbox to select the group */ - HTM_TR_Begin (NULL); - - if (IBelongToThisGroup) - HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); - else - HTM_TD_Begin ("class=\"LM\""); - fprintf (Gbl.F.Out,"GrpCod, - Grp->GrpCod); + AssociatedToGrp = false; if (Cod > 0) // Cod == -1L means new assignment or survey - { switch (Grp_AsgAttOrSvy) { case Grp_ASSIGNMENT: @@ -1742,13 +1726,21 @@ void Grp_ListGrpsToEditAsgAttSvyMch (struct GroupType *GrpTyp,long Cod, AssociatedToGrp = Gam_CheckIfMatchIsAssociatedToGrp (Cod,Grp->GrpCod); break; } - if (AssociatedToGrp) - fprintf (Gbl.F.Out," checked=\"checked\""); - } - if (!(IBelongToThisGroup || - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) - fprintf (Gbl.F.Out," disabled=\"disabled\""); - fprintf (Gbl.F.Out," onclick=\"uncheckParent(this,'WholeCrs')\" />"); + + /* Put checkbox to select the group */ + HTM_TR_Begin (NULL); + + if (IBelongToThisGroup) + HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); + else + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_CHECKBOX ("GrpCods",false, + "id=\"Grp%ld\" value=\"%ld\"%s%s" + " onclick=\"uncheckParent(this,'WholeCrs')\"", + Grp->GrpCod,Grp->GrpCod, + AssociatedToGrp ? " checked=\"checked\"" : "", + (IBelongToThisGroup || + Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? "" : " disabled=\"disabled\""); HTM_TD_End (); Grp_WriteRowGrp (Grp,IBelongToThisGroup); @@ -2002,14 +1994,6 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp, Grp = &(GrpTyp->LstGrps[NumGrpThisType]); IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong); - /* Put radio item or checkbox to select the group */ - HTM_TR_Begin (NULL); - - if (IBelongToThisGroup) - HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); - else - HTM_TD_Begin ("class=\"LM\""); - /* Selection disabled? */ if (ICanChangeMySelectionForThisGrpTyp) // I can change my selection for this group type { @@ -2029,6 +2013,14 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp, else // I can not change my selection for this group type ICanChangeMySelectionForThisGrp = false; + /* Put radio item or checkbox to select the group */ + HTM_TR_Begin (NULL); + + if (IBelongToThisGroup) + HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); + else + HTM_TD_Begin ("class=\"LM\""); + snprintf (StrGrpCod,sizeof (StrGrpCod), "GrpCod%ld", GrpTyp->GrpTypCod); @@ -2057,22 +2049,14 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp, GrpTyp->GrpTypCod,GrpTyp->NumGrps); } else - { /* Put a checkbox item */ - fprintf (Gbl.F.Out,"GrpCod,GrpTyp->GrpTypCod,Grp->GrpCod); - - /* Group checked? */ - if (IBelongToThisGroup) - fprintf (Gbl.F.Out," checked=\"checked\""); // Group selected - - if (!ICanChangeMySelectionForThisGrp) // I can not change my selection for this group - fprintf (Gbl.F.Out,IBelongToThisGroup ? " readonly" : // I can not unregister (disabled does not work because the value is not submitted) - " disabled=\"disabled\""); // I can not register - - fprintf (Gbl.F.Out," />"); - } + HTM_INPUT_CHECKBOX (StrGrpCod,false, + "id=\"Grp%ld\" value=\"%ld\"%s%s", + Grp->GrpCod,Grp->GrpCod, + IBelongToThisGroup ? " checked=\"checked\"" : "", + ICanChangeMySelectionForThisGrp ? "" : + IBelongToThisGroup ? " readonly" : // I can not unregister (disabled does not work because the value is not submitted) + " disabled=\"disabled\""); // I can not register HTM_TD_End (); @@ -2132,6 +2116,7 @@ static void Grp_ListGrpsToAddOrRemUsrs (struct GroupType *GrpTyp,long UsrCod) unsigned NumGrpThisType; bool UsrBelongsToThisGroup; struct Group *Grp; + char StrGrpCod[32]; /***** Write heading *****/ Grp_WriteGrpHead (GrpTyp); @@ -2162,12 +2147,13 @@ static void Grp_ListGrpsToAddOrRemUsrs (struct GroupType *GrpTyp,long UsrCod) /* Put checkbox to select the group */ // Always checkbox, not radio, because the role in the form may be teacher, // so if he/she is registered as teacher, he/she can belong to several groups - fprintf (Gbl.F.Out,"GrpCod,GrpTyp->GrpTypCod,Grp->GrpCod); - if (UsrBelongsToThisGroup) - fprintf (Gbl.F.Out," checked=\"checked\""); - fprintf (Gbl.F.Out," />"); + snprintf (StrGrpCod,sizeof (StrGrpCod), + "GrpCod%ld", + GrpTyp->GrpTypCod); + HTM_INPUT_CHECKBOX (StrGrpCod,false, + "id=\"Grp%ld\" value=\"%ld\"%s%s", + Grp->GrpCod,Grp->GrpCod, + UsrBelongsToThisGroup ? " checked=\"checked\"" : ""); // I can not register /* End cell for checkbox */ HTM_TD_End (); @@ -2197,6 +2183,7 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp, struct ListCodGrps LstGrpsIBelong; bool IBelongToThisGroup; bool ICanSelUnselGroup; + bool Checked; struct Group *Grp; Rol_Role_t Role; @@ -2241,6 +2228,19 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp, break; } + /* This group should be checked? */ + if (Gbl.Usrs.ClassPhoto.AllGroups) + Checked = true; + else + for (NumGrpSel = 0, Checked = false; + NumGrpSel < Gbl.Crs.Grps.LstGrpsSel.NumGrps; + NumGrpSel++) + if (Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrpSel] == Grp->GrpCod) + { + Checked = true; + break; + } + /* Put checkbox to select the group */ HTM_TR_Begin (NULL); @@ -2248,26 +2248,12 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp, HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); else HTM_TD_Begin ("class=\"LM\""); - fprintf (Gbl.F.Out,"GrpCod, - Grp->GrpCod); - if (Gbl.Usrs.ClassPhoto.AllGroups) - fprintf (Gbl.F.Out," checked=\"checked\""); - else - for (NumGrpSel = 0; - NumGrpSel < Gbl.Crs.Grps.LstGrpsSel.NumGrps; - NumGrpSel++) - if (Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrpSel] == Grp->GrpCod) - { - fprintf (Gbl.F.Out," checked=\"checked\""); - break; - } - if (ICanSelUnselGroup) - fprintf (Gbl.F.Out," onclick=\"checkParent(this,'AllGroups')\""); - else - fprintf (Gbl.F.Out," disabled=\"disabled\""); - fprintf (Gbl.F.Out," />"); + HTM_INPUT_CHECKBOX ("GrpCods",false, + "id=\"Grp%ld\" value=\"%ld\"%s%s", + Grp->GrpCod,Grp->GrpCod, + Checked ? " checked=\"checked\"" : "", + ICanSelUnselGroup ? " onclick=\"checkParent(this,'AllGroups')\"" : + " disabled=\"disabled\""); HTM_TD_End (); Grp_WriteRowGrp (Grp,IBelongToThisGroup); @@ -2282,30 +2268,34 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp, /* To get the students who don't belong to a type of group, use group code -(GrpTyp->GrpTypCod) */ /* Write checkbox to select the group */ ICanSelUnselGroup = (Gbl.Usrs.Me.Role.Logged >= Rol_STD); - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"LM\""); - fprintf (Gbl.F.Out,"GrpTypCod), - -(GrpTyp->GrpTypCod)); if (ICanSelUnselGroup) { if (Gbl.Usrs.ClassPhoto.AllGroups) - fprintf (Gbl.F.Out," checked=\"checked\""); + Checked = true; else - for (NumGrpSel = 0; + for (NumGrpSel = 0, Checked = false; NumGrpSel < Gbl.Crs.Grps.LstGrpsSel.NumGrps; NumGrpSel++) if (Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrpSel] == -(GrpTyp->GrpTypCod)) { - fprintf (Gbl.F.Out," checked=\"checked\""); + Checked = true; break; } } else + { + Checked = false; fprintf (Gbl.F.Out," disabled=\"disabled\""); - fprintf (Gbl.F.Out," onclick=\"checkParent(this,'AllGroups')\" />"); + } + + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_CHECKBOX ("GrpCods",false, + "id=\"Grp%ld\" value=\"%ld\"%s%s onclick=\"checkParent(this,'AllGroups')\"", + -(GrpTyp->GrpTypCod),-(GrpTyp->GrpTypCod), + ICanSelUnselGroup ? (Checked ? " checked=\"checked\"" : "") : + " disabled=\"disabled\""); HTM_TD_End (); /* Column closed/open */ diff --git a/swad_indicator.c b/swad_indicator.c index a1cb6532..6bdfb8fe 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -667,14 +667,10 @@ static void Ind_ShowNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 if (PutForm) { HTM_TD_Begin ("class=\"%s\"",Class); - fprintf (Gbl.F.Out,"", - Gbl.Form.Id); + HTM_INPUT_CHECKBOX ("Indicators",true, + "id=\"Indicators%u\" value=\"%u\"%s", + Ind,Ind, + Gbl.Stat.IndicatorsSelected[Ind] ? " checked=\"checked\"" : ""); HTM_TD_End (); } diff --git a/swad_layout.c b/swad_layout.c index 6a5e00bf..294b4c38 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1269,16 +1269,10 @@ void Lay_PutContextualCheckbox (Act_Action_t NextAction, HTM_LABEL_Begin (NULL); /****** Checkbox *****/ - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX (CheckboxName,true, + "value=\"Y\"%s%s", + Checked ? " checked=\"checked\"" : "", + Disabled ? " disabled=\"disabled\"" : ""); /***** Text *****/ if (Text) diff --git a/swad_match.c b/swad_match.c index 2a1f950f..afc2fb85 100644 --- a/swad_match.c +++ b/swad_match.c @@ -1263,10 +1263,9 @@ static void Mch_ShowLstGrpsToCreateMatch (void) HTM_TR_Begin (NULL); HTM_TD_Begin ("colspan=\"7\" class=\"DAT LM\""); HTM_LABEL_Begin (NULL); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("WholeCrs",true, + "id=\"WholeCrs\" value=\"Y\" checked=\"checked\"" + " onclick=\"uncheckChildren(this,'GrpCods')\""); fprintf (Gbl.F.Out,"%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); HTM_TD_End (); diff --git a/swad_message.c b/swad_message.c index f24e3048..99b62a3c 100644 --- a/swad_message.c +++ b/swad_message.c @@ -2662,9 +2662,9 @@ void Msg_ShowFormToFilterMsgs (void) HTM_TD_Begin ("class=\"LM\""); HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); fprintf (Gbl.F.Out,"%s: ",TxtFromTo[Gbl.Msg.TypeOfMessages]); - fprintf (Gbl.F.Out,"", - Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME * 3,Gbl.Msg.FilterFromTo); + HTM_INPUT_SEARCH ("FilterFromTo",Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME * 3, + Gbl.Msg.FilterFromTo,false, + "size=\"20\""); HTM_LABEL_End (); HTM_TD_End (); @@ -2672,9 +2672,9 @@ void Msg_ShowFormToFilterMsgs (void) HTM_TD_Begin ("class=\"LM\""); HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); fprintf (Gbl.F.Out,"%s: ",Txt_MSG_Content); - fprintf (Gbl.F.Out,"", - Msg_MAX_CHARS_FILTER_CONTENT,Gbl.Msg.FilterContent); + HTM_INPUT_SEARCH ("FilterContent",Msg_MAX_CHARS_FILTER_CONTENT, + Gbl.Msg.FilterContent,false, + "size=\"20\""); HTM_LABEL_End (); HTM_TD_End (); @@ -2695,11 +2695,9 @@ static void Msg_ShowFormToShowOnlyUnreadMessages (void) /***** Put checkbox to select whether to show only unread (received) messages *****/ HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("OnlyUnreadMsgs",false, + "value=\"Y\"%s", + Gbl.Msg.ShowOnlyUnreadMsgs ? " checked=\"checked\"" : ""); fprintf (Gbl.F.Out,"%s",Txt_only_unread_messages); HTM_LABEL_End (); } diff --git a/swad_notification.c b/swad_notification.c index ea9867f8..2b95029d 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -1941,19 +1941,17 @@ void Ntf_PutFormChangeNotifSentByEMail (void) HTM_TD_End (); HTM_TD_Begin ("class=\"CM\""); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX (Ntf_ParamNotifMeAboutNotifyEvents[NotifyEvent],false, + "value=\"Y\"%s", + (Gbl.Usrs.Me.UsrDat.NtfEvents.CreateNotif & + (1 << NotifyEvent)) ? " checked=\"checked\"" : ""); HTM_TD_End (); HTM_TD_Begin ("class=\"CM\""); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX (Ntf_ParamEmailMeAboutNotifyEvents[NotifyEvent],false, + "value=\"Y\"%s", + (Gbl.Usrs.Me.UsrDat.NtfEvents.SendEmail & + (1 << NotifyEvent)) ? " checked=\"checked\"" : ""); HTM_TD_End (); HTM_TR_End (); diff --git a/swad_password.c b/swad_password.c index eb64b29f..1fdfe37f 100644 --- a/swad_password.c +++ b/swad_password.c @@ -863,7 +863,8 @@ void Pwd_AskForConfirmationOnDangerousAction (void) /***** Checkbox *****/ HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("Consent",false, + "value=\"Y\""); fprintf (Gbl.F.Out,"%s",Txt_I_understand_that_this_action_can_not_be_undone); HTM_LABEL_End (); diff --git a/swad_project.c b/swad_project.c index d772eddb..024ec9ef 100644 --- a/swad_project.c +++ b/swad_project.c @@ -3758,11 +3758,9 @@ void Prj_ShowFormConfig (void) HTM_TD_Begin ("class=\"LT\""); HTM_LABEL_Begin (NULL); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("Editable",false, + "id=\"Editable\" value=\"Y\"%s", + Gbl.Prjs.Config.Editable ? " checked=\"checked\"" : ""); fprintf (Gbl.F.Out,"%s",Txt_Editable_by_non_editing_teachers); HTM_LABEL_End (); HTM_TD_End (); diff --git a/swad_role.c b/swad_role.c index 6c9b4bc7..1bcdf8f4 100644 --- a/swad_role.c +++ b/swad_role.c @@ -547,20 +547,11 @@ void Rol_WriteSelectorRoles (unsigned RolesAllowed,unsigned RolesSelected, if ((RolesAllowed & (1 << Role))) { HTM_LABEL_Begin (NULL); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("Role",SendOnChange, + "value=\"%u\"%s%s", + (unsigned) Role, + (RolesSelected & (1 << Role)) ? " checked=\"checked\"" : "", + Disabled ? " disabled=\"disabled\"" : ""); fprintf (Gbl.F.Out,"%s",Txt_ROLES_PLURAL_abc[Role][Usr_SEX_UNKNOWN]); HTM_LABEL_End (); fprintf (Gbl.F.Out,"
"); diff --git a/swad_survey.c b/swad_survey.c index cb84c90b..0a28bad0 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -2091,11 +2091,9 @@ static void Svy_ShowLstGrpsToEditSurvey (long SvyCod) HTM_TD_Begin ("colspan=\"7\" class=\"DAT LM\""); HTM_LABEL_Begin (NULL); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("WholeCrs",false, + "id=\"WholeCrs\" value=\"Y\"%s onclick=\"uncheckChildren(this,'GrpCods')\"", + Svy_CheckIfSvyIsAssociatedToGrps (SvyCod) ? "" : " checked=\"checked\""); fprintf (Gbl.F.Out,"%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); HTM_TD_End (); @@ -3404,6 +3402,7 @@ static void Svy_WriteAnswersOfAQst (struct Survey *Svy, MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NumUsrsThisAnswer; + char StrAns[32]; /***** Get answers of this question *****/ NumAnswers = Svy_GetAnswersQst (SvyQst->QstCod,&mysql_res); // Result: AnsInd,NumUsrs,Answer @@ -3445,17 +3444,21 @@ static void Svy_WriteAnswersOfAQst (struct Survey *Svy, { /* Write selector to choice this answer */ HTM_TD_Begin ("class=\"LT\""); - fprintf (Gbl.F.Out,"QstCod); if (SvyQst->AnswerType == Svy_ANS_UNIQUE_CHOICE) - fprintf (Gbl.F.Out,"radio\"" - " onclick=\"selectUnselectRadio(this,this.form.Ans%010u,%u)\"", - (unsigned) SvyQst->QstCod,NumAnswers); + HTM_INPUT_RADIO (StrAns,false, + "id=\"Ans%010u_%010u\" value=\"%u\"" + " onclick=\"selectUnselectRadio(this,this.form.Ans%010u,%u)\"", + (unsigned) SvyQst->QstCod,NumAns,NumAns, + NumAns, + (unsigned) SvyQst->QstCod,NumAnswers); else // SvyQst->AnswerType == Svy_ANS_MULTIPLE_CHOICE - fprintf (Gbl.F.Out,"checkbox\""); - fprintf (Gbl.F.Out," id=\"Ans%010u_%010u\" name=\"Ans%010u\"" - " value=\"%u\" />", - (unsigned) SvyQst->QstCod,NumAns,(unsigned) SvyQst->QstCod, - NumAns); + HTM_INPUT_CHECKBOX (StrAns,false, + "id=\"Ans%010u_%010u\" value=\"%u\"", + (unsigned) SvyQst->QstCod,NumAns,NumAns, + NumAns); HTM_TD_End (); } diff --git a/swad_test.c b/swad_test.c index 97259fe4..84523fd8 100644 --- a/swad_test.c +++ b/swad_test.c @@ -468,10 +468,9 @@ void Tst_ShowNewTest (void) /***** Test result will be saved? *****/ HTM_DIV_Begin ("class=\"CM\""); HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("Save",false, + "value=\"Y\"%s", + Gbl.Test.AllowTeachers ? " checked=\"checked\"" : ""); fprintf (Gbl.F.Out," %s",Txt_Allow_teachers_to_consult_this_test); HTM_LABEL_End (); HTM_DIV_End (); @@ -1667,6 +1666,7 @@ static void Tst_ShowFormSelTags (unsigned long NumRows,MYSQL_RES *mysql_res, unsigned long NumRow; MYSQL_ROW row; bool TagHidden = false; + bool Checked; const char *Ptr; char TagText[Tst_MAX_BYTES_TAG + 1]; /* @@ -1694,10 +1694,9 @@ static void Tst_ShowFormSelTags (unsigned long NumRows,MYSQL_RES *mysql_res, HTM_TD_Begin ("class=\"LM\""); HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("AllTags",false, + "value=\"Y\"%s onclick=\"togglecheckChildren(this,'ChkTag');\"", + Gbl.Test.Tags.All ? " checked=\"checked\"" : ""); fprintf (Gbl.F.Out," %s",Txt_All_tags); HTM_LABEL_End (); HTM_TD_End (); @@ -1725,10 +1724,7 @@ static void Tst_ShowFormSelTags (unsigned long NumRows,MYSQL_RES *mysql_res, HTM_TD_End (); } - HTM_TD_Begin ("class=\"LM\""); - HTM_LABEL_Begin ("class=\"DAT\""); - fprintf (Gbl.F.Out,""); + + HTM_TD_Begin ("class=\"LM\""); + HTM_LABEL_Begin ("class=\"DAT\""); + HTM_INPUT_CHECKBOX ("ChkTag",false, + "value=\"%s\"%s onclick=\"checkParent(this,'AllTags');\"", + row[1], + Checked ? " checked=\"checked\"" : ""); fprintf (Gbl.F.Out," %s",row[1]); HTM_LABEL_End (); HTM_TD_End (); @@ -2297,6 +2302,7 @@ static void Tst_ShowFormAnswerTypes (unsigned NumCols) extern const char *Txt_All_types_of_answers; extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES]; Tst_AnswerType_t AnsType; + bool Checked; char UnsignedStr[10 + 1]; const char *Ptr; @@ -2318,10 +2324,9 @@ static void Tst_ShowFormAnswerTypes (unsigned NumCols) HTM_TD_Begin ("class=\"LM\""); HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("AllAnsTypes",false, + "value=\"Y\"%s onclick=\"togglecheckChildren(this,'AnswerType');\"", + Gbl.Test.AllAnsTypes ? " checked=\"checked\"" : ""); fprintf (Gbl.F.Out," %s",Txt_All_types_of_answers); HTM_LABEL_End (); HTM_TD_End (); @@ -2335,18 +2340,23 @@ static void Tst_ShowFormAnswerTypes (unsigned NumCols) { HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"LM\""); - HTM_LABEL_Begin ("class=\"DAT\""); - fprintf (Gbl.F.Out,""); + HTM_TD_Begin ("class=\"LM\""); + HTM_LABEL_Begin ("class=\"DAT\""); + HTM_INPUT_CHECKBOX ("AnswerType",false, + "value=\"%u\"%s onclick=\"checkParent(this,'AllAnsTypes');\"", + (unsigned) AnsType, + Checked ? " checked=\"checked\"" : ""); fprintf (Gbl.F.Out," %s",Txt_TST_STR_ANSWER_TYPES[AnsType]); HTM_LABEL_End (); HTM_TD_End (); @@ -2931,11 +2941,9 @@ static void Tst_ListOneOrMoreQuestionsForEdition (unsigned long NumRows, if (NumRows == 1) Par_PutHiddenParamChar ("OnlyThisQst",'Y'); // If editing only one question, don't edit others Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Gbl.Test.SelectedOrder); - fprintf (Gbl.F.Out,"", - Gbl.Form.Id); + HTM_INPUT_CHECKBOX ("Shuffle",true, + "value=\"Y\"%s", + row[3][0] == 'Y' ? " checked=\"checked\"" : ""); Frm_EndForm (); } HTM_TD_End (); @@ -3099,9 +3107,9 @@ static void Tst_ListOneOrMoreQuestionsForSelection (unsigned long NumRows, HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); /* Write checkbox to select the question */ - fprintf (Gbl.F.Out,"", - Gbl.Test.QstCod); + HTM_INPUT_CHECKBOX ("QstCods",false, + "value=\"%ld\"", + Gbl.Test.QstCod); /* Write number of question */ HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); @@ -3138,12 +3146,9 @@ static void Tst_ListOneOrMoreQuestionsForSelection (unsigned long NumRows, /* Write if shuffle is enabled (row[3]) */ HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - - fprintf (Gbl.F.Out,""); - + HTM_INPUT_CHECKBOX ("Shuffle",false, + "value=\"Y\"%s disabled=\"disabled\"", + row[3][0] == 'Y' ? " checked=\"checked\"" : ""); HTM_TD_End (); /* Write stem (row[4]) */ @@ -3640,6 +3645,7 @@ static void Tst_WriteChoiceAnsViewTest (unsigned NumQst,long QstCod,bool Shuffle unsigned Index; bool ErrorInIndex = false; char ParamName[3 + 6 + 1]; + char StrAns[32]; /***** Get answers of a question from database *****/ Gbl.Test.Answer.NumOptions = Tst_GetAnswersQst (QstCod,&mysql_res,Shuffle); @@ -3698,16 +3704,21 @@ static void Tst_WriteChoiceAnsViewTest (unsigned NumQst,long QstCod,bool Shuffle "Ind%06u", NumQst); Par_PutHiddenParamUnsigned (NULL,ParamName,Index); - fprintf (Gbl.F.Out,"", - NumQst,NumOpt, - NumQst,Index); + HTM_INPUT_CHECKBOX (StrAns,false, + "id=\"Ans%06u_%u\" value=\"%u\"", + NumQst,NumOpt, + Index); HTM_TD_End (); HTM_TD_Begin ("class=\"LT\""); @@ -5237,13 +5248,11 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1], HTM_TD_Begin ("class=\"LT\""); HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("Shuffle",false, + "value=\"Y\"%s%s", + Gbl.Test.Shuffle ? " checked=\"checked\"" : "", + Gbl.Test.AnswerType != Tst_ANS_UNIQUE_CHOICE && + Gbl.Test.AnswerType != Tst_ANS_MULTIPLE_CHOICE ? " disabled=\"disabled\"" : ""); fprintf (Gbl.F.Out,"%s",Txt_Shuffle); HTM_LABEL_End (); HTM_TD_End (); @@ -5287,13 +5296,11 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1], Gbl.Test.AnswerType == Tst_ANS_UNIQUE_CHOICE ? "" : " disabled=\"disabled\""); /* Checkbox for multiple choice answers */ - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX ("AnsMulti",false, + "value=\"%u\"%s%s", + NumOpt, + Gbl.Test.Answer.Options[NumOpt].Correct ? " checked=\"checked\"" : "", + Gbl.Test.AnswerType == Tst_ANS_MULTIPLE_CHOICE ? "" : " disabled=\"disabled\""); HTM_TD_End (); diff --git a/swad_user.c b/swad_user.c index bf1178a4..960838ee 100644 --- a/swad_user.c +++ b/swad_user.c @@ -6294,11 +6294,9 @@ void Usr_PutCheckboxToSelectAllUsers (Rol_Role_t Role) HTM_LABEL_Begin (NULL); if (Usr_NameSelUnsel[Role] && Usr_ParamUsrCod[Role]) - fprintf (Gbl.F.Out,"", - Usr_NameSelUnsel[Role], - Usr_ParamUsrCod[Role]); + HTM_INPUT_CHECKBOX (Usr_NameSelUnsel[Role],false, + "value=\"\" onclick=\"togglecheckChildren(this,'%s')\"", + Usr_ParamUsrCod[Role]); else Rol_WrongRoleExit (); Sex = Usr_GetSexOfUsrsLst (Role); @@ -6369,14 +6367,11 @@ static void Usr_PutCheckboxToSelectUser (Rol_Role_t Role, CheckboxChecked = Usr_FindUsrCodInListOfSelectedUsrs (EncryptedUsrCod); /***** Check box *****/ - fprintf (Gbl.F.Out,""); + HTM_INPUT_CHECKBOX (Usr_ParamUsrCod[Role],false, + "value=\"%s\"%s onclick=\"checkParent(this,'%s')\"", + EncryptedUsrCod, + CheckboxChecked ? " checked=\"checked\"" : "", + Usr_NameSelUnsel[Role]); } else Rol_WrongRoleExit (); @@ -6395,12 +6390,9 @@ static void Usr_PutCheckboxListWithPhotos (void) /***** Put checkbox to select whether list users with photos *****/ HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - fprintf (Gbl.F.Out,"", - Gbl.Form.Id); + HTM_INPUT_CHECKBOX ("WithPhotos",true, + "value=\"Y\"%s", + Gbl.Usrs.Listing.WithPhotos ? " checked=\"checked\"" : ""); fprintf (Gbl.F.Out,"%s",Txt_Display_photos); HTM_LABEL_End (); }