diff --git a/swad_agenda.c b/swad_agenda.c index 3e9796b2..ceb85cd7 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -1156,16 +1156,6 @@ static void Agd_FreeListEvents (struct Agd_Agenda *Agenda) } } -/*****************************************************************************/ -/******************** Get parameter with code of event ***********************/ -/*****************************************************************************/ - -long Agd_GetParamAgdCod (void) - { - /***** Get code of event *****/ - return Par_GetParToLong ("AgdCod"); - } - /*****************************************************************************/ /************** Ask for confirmation of removing of an event *****************/ /*****************************************************************************/ @@ -1184,8 +1174,7 @@ void Agd_AskRemEvent (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) - Err_WrongEventExit (); + AgdEvent.AgdCod = Par_GetAndCheckParCode (Par_AgdCod); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1220,8 +1209,7 @@ void Agd_RemoveEvent (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) - Err_WrongEventExit (); + AgdEvent.AgdCod = Par_GetAndCheckParCode (Par_AgdCod); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1254,8 +1242,7 @@ void Agd_HideEvent (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) - Err_WrongEventExit (); + AgdEvent.AgdCod = Par_GetAndCheckParCode (Par_AgdCod); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1284,8 +1271,7 @@ void Agd_UnhideEvent (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) - Err_WrongEventExit (); + AgdEvent.AgdCod = Par_GetAndCheckParCode (Par_AgdCod); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1315,8 +1301,7 @@ void Agd_MakeEventPrivate (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) - Err_WrongEventExit (); + AgdEvent.AgdCod = Par_GetAndCheckParCode (Par_AgdCod); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1350,8 +1335,7 @@ void Agd_MakeEventPublic (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) - Err_WrongEventExit (); + AgdEvent.AgdCod = Par_GetAndCheckParCode (Par_AgdCod); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1400,7 +1384,7 @@ void Agd_RequestCreatOrEditEvent (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get the code of the event *****/ - ItsANewEvent = ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) <= 0); + ItsANewEvent = ((AgdEvent.AgdCod = Par_GetParCode (Par_AgdCod)) <= 0); /***** Get from the database the data of the event *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1546,7 +1530,7 @@ void Agd_ReceiveFormEvent (void) AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; /***** Get the code of the event *****/ - ItsANewEvent = ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) <= 0); + ItsANewEvent = ((AgdEvent.AgdCod = Par_GetParCode (Par_AgdCod)) <= 0); /***** Get start/end date-times *****/ AgdEvent.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); diff --git a/swad_agenda.h b/swad_agenda.h index be87a535..d0be7695 100644 --- a/swad_agenda.h +++ b/swad_agenda.h @@ -121,8 +121,6 @@ void Agd_PutParamsMyAgenda (unsigned Past__FutureEvents, long AgdCodToEdit); void Agd_PutHiddenParamEventsOrder (Dat_StartEndTime_t SelectedOrder); -long Agd_GetParamAgdCod (void); - void Agd_AskRemEvent (void); void Agd_RemoveEvent (void); diff --git a/swad_announcement.c b/swad_announcement.c index 010f654c..15eead15 100644 --- a/swad_announcement.c +++ b/swad_announcement.c @@ -57,7 +57,6 @@ static void Ann_DrawAnAnnouncement (long AnnCod,Ann_Status_t Status, bool ShowAllAnnouncements, bool ICanEdit); static void Ann_PutParams (void *AnnCod); -static long Ann_GetParamAnnCod (void); static void Ann_PutSubjectMessage (const char *Field,const char *Label, unsigned Rows); @@ -308,21 +307,6 @@ static void Ann_PutParams (void *AnnCod) Par_PutHiddenParamLong (NULL,"AnnCod",*((long *) AnnCod)); } -/*****************************************************************************/ -/************** Get parameter with the code of an announcement ***************/ -/*****************************************************************************/ - -static long Ann_GetParamAnnCod (void) - { - long AnnCod; - - /***** Get announcement code *****/ - if ((AnnCod = Par_GetParToLong ("AnnCod")) <= 0) - Err_WrongAnnouncementExit (); - - return AnnCod; - } - /*****************************************************************************/ /***************** Show form to create a new announcement ********************/ /*****************************************************************************/ @@ -444,7 +428,7 @@ void Ann_HideActiveAnnouncement (void) long AnnCod; /***** Get the code of the global announcement to hide *****/ - AnnCod = Ann_GetParamAnnCod (); + AnnCod = Par_GetAndCheckParCode (Par_AnnCod); /***** Set global announcement as hidden *****/ Ann_DB_HideAnnouncement (AnnCod); @@ -459,7 +443,7 @@ void Ann_RevealHiddenAnnouncement (void) long AnnCod; /***** Get the code of the global announcement to show *****/ - AnnCod = Ann_GetParamAnnCod (); + AnnCod = Par_GetAndCheckParCode (Par_AnnCod); /***** Set global announcement as not hidden *****/ Ann_DB_UnhideAnnouncement (AnnCod); @@ -475,7 +459,7 @@ void Ann_RemoveAnnouncement (void) long AnnCod; /***** Get the code of the global announcement *****/ - AnnCod = Ann_GetParamAnnCod (); + AnnCod = Par_GetAndCheckParCode (Par_AnnCod); /***** Remove users who have seen the announcement *****/ Ann_DB_RemoveUsrsWhoSawAnnouncement (AnnCod); @@ -499,7 +483,7 @@ void Ann_MarkAnnouncementAsSeen (void) long AnnCod; /***** Get the code of the global announcement *****/ - AnnCod = Ann_GetParamAnnCod (); + AnnCod = Par_GetAndCheckParCode (Par_AnnCod); /***** Mark announcement as seen *****/ Ann_DB_MarkAnnouncementAsSeenByMe (AnnCod); diff --git a/swad_assignment.c b/swad_assignment.c index a55fa983..ebb2330c 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -382,7 +382,7 @@ void Asg_SeeOneAssignment (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get the code of the assignment *****/ - Assignments.Asg.AsgCod = Asg_GetParamAsgCod (); + Assignments.Asg.AsgCod = Par_GetAndCheckParCode (Par_AsgCod); /***** Show selected assignment in a box *****/ Asg_ShowOneAssignmentInBox (&Assignments); @@ -403,7 +403,7 @@ void Asg_PrintOneAssignment (void) Asg_ResetAssignments (&Assignments); /***** Get the code of the assignment *****/ - Assignments.Asg.AsgCod = Asg_GetParamAsgCod (); + Assignments.Asg.AsgCod = Par_GetAndCheckParCode (Par_AsgCod); /***** Write header *****/ Lay_WriteHeaderClassPhoto (true,false, @@ -1014,16 +1014,6 @@ void Asg_PutParamAsgCod (long AsgCod) Par_PutHiddenParamLong (NULL,"AsgCod",AsgCod); } -/*****************************************************************************/ -/****************** Get parameter with code of assignment ********************/ -/*****************************************************************************/ - -long Asg_GetParamAsgCod (void) - { - /***** Get code of assignment *****/ - return Par_GetParToLong ("AsgCod"); - } - /*****************************************************************************/ /************* Ask for confirmation of removing an assignment ****************/ /*****************************************************************************/ @@ -1043,8 +1033,7 @@ void Asg_ReqRemAssignment (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get assignment code *****/ - if ((Assignments.Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0) - Err_WrongAssignmentExit (); + Assignments.Asg.AsgCod = Par_GetAndCheckParCode (Par_AsgCod); /***** Get data of the assignment from database *****/ Asg_GetDataOfAssignmentByCod (&Assignments.Asg); @@ -1078,8 +1067,7 @@ void Asg_RemoveAssignment (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get assignment code *****/ - if ((Assignments.Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0) - Err_WrongAssignmentExit (); + Assignments.Asg.AsgCod = Par_GetAndCheckParCode (Par_AsgCod); /***** Get data of the assignment from database *****/ Asg_GetDataOfAssignmentByCod (&Assignments.Asg); // Inside this function, the course is checked to be the current one @@ -1122,8 +1110,7 @@ void Asg_HideAssignment (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get assignment code *****/ - if ((Assignments.Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0) - Err_WrongAssignmentExit (); + Assignments.Asg.AsgCod = Par_GetAndCheckParCode (Par_AsgCod); /***** Get data of the assignment from database *****/ Asg_GetDataOfAssignmentByCod (&Assignments.Asg); @@ -1152,8 +1139,7 @@ void Asg_UnhideAssignment (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get assignment code *****/ - if ((Assignments.Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0) - Err_WrongAssignmentExit (); + Assignments.Asg.AsgCod = Par_GetAndCheckParCode (Par_AsgCod); /***** Get data of the assignment from database *****/ Asg_GetDataOfAssignmentByCod (&Assignments.Asg); @@ -1204,7 +1190,7 @@ void Asg_RequestCreatOrEditAsg (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get the code of the assignment *****/ - ItsANewAssignment = ((Assignments.Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0); + ItsANewAssignment = ((Assignments.Asg.AsgCod = Par_GetParCode (Par_AsgCod)) <= 0); /***** Get from the database the data of the assignment *****/ if (ItsANewAssignment) @@ -1422,8 +1408,7 @@ void Asg_ReceiveFormAssignment (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get the code of the assignment *****/ - Assignments.Asg.AsgCod = Asg_GetParamAsgCod (); - ItsANewAssignment = (Assignments.Asg.AsgCod < 0); + ItsANewAssignment = ((Assignments.Asg.AsgCod = Par_GetParCode (Par_AsgCod)) <= 0); if (ItsANewAssignment) { diff --git a/swad_assignment.h b/swad_assignment.h index d7e1fdcf..914a8bf3 100644 --- a/swad_assignment.h +++ b/swad_assignment.h @@ -99,7 +99,6 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], long AsgCod,bool GetContent); void Asg_PutParamAsgCod (long AsgCod); -long Asg_GetParamAsgCod (void); void Asg_ReqRemAssignment (void); void Asg_RemoveAssignment (void); void Asg_HideAssignment (void); diff --git a/swad_assignment_resource.c b/swad_assignment_resource.c index 66769c7e..9f55a9fc 100644 --- a/swad_assignment_resource.c +++ b/swad_assignment_resource.c @@ -33,6 +33,7 @@ #include "swad_error.h" #include "swad_form.h" #include "swad_pagination.h" +#include "swad_parameter.h" #include "swad_program_database.h" /*****************************************************************************/ @@ -54,7 +55,7 @@ void AsgRsc_GetLinkToAssignment (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get assignment code *****/ - Assignments.Asg.AsgCod = Asg_GetParamAsgCod (); + Assignments.Asg.AsgCod = Par_GetAndCheckParCode (Par_AsgCod); /***** Get assignment title *****/ AsgRsc_GetTitleFromAsgCod (Assignments.Asg.AsgCod,Title,sizeof (Title) - 1); diff --git a/swad_attendance.c b/swad_attendance.c index 36f866b4..7f418451 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -829,15 +829,6 @@ void Att_PutParamAttCod (long AttCod) Par_PutHiddenParamLong (NULL,"AttCod",AttCod); } -/*****************************************************************************/ -/*************** Get parameter with code of attendance event *****************/ -/*****************************************************************************/ - -long Att_GetParamAttCod (void) - { - return Par_GetParToLong ("AttCod"); - } - /*****************************************************************************/ /********* Ask for confirmation of removing of an attendance event ***********/ /*****************************************************************************/ @@ -857,8 +848,7 @@ void Att_AskRemAttEvent (void) Events.CurrentPage = Pag_GetParamPagNum (Pag_ATT_EVENTS); /***** Get attendance event code *****/ - if ((Events.Event.AttCod = Att_GetParamAttCod ()) < 0) - Err_WrongEventExit (); + Events.Event.AttCod = Par_GetAndCheckParCode (Par_AttCod); /***** Get data of the attendance event from database *****/ Att_GetDataOfAttEventByCodAndCheckCrs (&Events.Event); @@ -884,8 +874,7 @@ void Att_GetAndRemAttEvent (void) struct Att_Event Event; /***** Get attendance event code *****/ - if ((Event.AttCod = Att_GetParamAttCod ()) < 0) - Err_WrongEventExit (); + Event.AttCod = Par_GetAndCheckParCode (Par_AttCod); /***** Get data of the attendance event from database *****/ // Inside this function, the course is checked to be the current one @@ -927,8 +916,7 @@ void Att_HideAttEvent (void) struct Att_Event Event; /***** Get attendance event code *****/ - if ((Event.AttCod = Att_GetParamAttCod ()) < 0) - Err_WrongEventExit (); + Event.AttCod = Par_GetAndCheckParCode (Par_AttCod); /***** Get data of the attendance event from database *****/ Att_GetDataOfAttEventByCodAndCheckCrs (&Event); @@ -949,8 +937,7 @@ void Att_UnhideAttEvent (void) struct Att_Event Event; /***** Get attendance event code *****/ - if ((Event.AttCod = Att_GetParamAttCod ()) < 0) - Err_WrongEventExit (); + Event.AttCod = Par_GetAndCheckParCode (Par_AttCod); /***** Get data of the attendance event from database *****/ Att_GetDataOfAttEventByCodAndCheckCrs (&Event); @@ -998,8 +985,7 @@ void Att_RequestCreatOrEditAttEvent (void) Events.CurrentPage = Pag_GetParamPagNum (Pag_ATT_EVENTS); /***** Get the code of the attendance event *****/ - Events.Event.AttCod = Att_GetParamAttCod (); - ItsANewAttEvent = (Events.Event.AttCod <= 0); + ItsANewAttEvent = ((Events.Event.AttCod = Par_GetParCode (Par_AttCod)) <= 0); /***** Get from the database the data of the attendance event *****/ if (ItsANewAttEvent) @@ -1206,7 +1192,7 @@ void Att_ReceiveFormAttEvent (void) char Description[Cns_MAX_BYTES_TEXT + 1]; /***** Get the code of the attendance event *****/ - ItsANewAttEvent = ((ReceivedAtt.AttCod = Att_GetParamAttCod ()) <= 0); + ItsANewAttEvent = ((ReceivedAtt.AttCod = Par_GetParCode (Par_AttCod)) <= 0); if (!ItsANewAttEvent) { @@ -1466,8 +1452,7 @@ void Att_SeeOneAttEvent (void) Att_ResetEvents (&Events); /***** Get attendance event code *****/ - if ((Events.Event.AttCod = Att_GetParamAttCod ()) < 0) - Err_WrongEventExit (); + Events.Event.AttCod = Par_GetAndCheckParCode (Par_AttCod); /***** Show event *****/ Att_ShowEvent (&Events); @@ -1957,8 +1942,7 @@ void Att_RegisterMeAsStdInAttEvent (void) Att_ResetEvents (&Events); /***** Get attendance event code *****/ - if ((Events.Event.AttCod = Att_GetParamAttCod ()) < 0) - Err_WrongEventExit (); + Events.Event.AttCod = Par_GetAndCheckParCode (Par_AttCod); Att_GetDataOfAttEventByCodAndCheckCrs (&Events.Event); // This checks that event belong to current course if (Events.Event.Open) @@ -2021,8 +2005,7 @@ void Att_RegisterStudentsInAttEvent (void) Att_ResetEvents (&Events); /***** Get attendance event code *****/ - if ((Events.Event.AttCod = Att_GetParamAttCod ()) < 0) - Err_WrongEventExit (); + Events.Event.AttCod = Par_GetAndCheckParCode (Par_AttCod); Att_GetDataOfAttEventByCodAndCheckCrs (&Events.Event); // This checks that event belong to current course /***** Get groups selected *****/ diff --git a/swad_attendance.h b/swad_attendance.h index 350cab08..d821fa6c 100644 --- a/swad_attendance.h +++ b/swad_attendance.h @@ -91,7 +91,6 @@ void Att_RequestCreatOrEditAttEvent (void); bool Att_GetDataOfAttEventByCod (struct Att_Event *Event); void Att_PutParamAttCod (long AttCod); -long Att_GetParamAttCod (void); void Att_AskRemAttEvent (void); void Att_GetAndRemAttEvent (void); diff --git a/swad_attendance_resource.c b/swad_attendance_resource.c index 27880c28..f4162f30 100644 --- a/swad_attendance_resource.c +++ b/swad_attendance_resource.c @@ -31,6 +31,7 @@ #include "swad_attendance_resource.h" #include "swad_error.h" #include "swad_form.h" +#include "swad_parameter.h" #include "swad_program_database.h" /*****************************************************************************/ @@ -44,7 +45,7 @@ void AttRsc_GetLinkToEvent (void) char Title[Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE + 1]; /***** Get attendance event code *****/ - AttCod = Att_GetParamAttCod (); + AttCod = Par_GetAndCheckParCode (Par_AttCod); /***** Get attendance event title *****/ AttRsc_GetTitleFromAttCod (AttCod,Title,sizeof (Title) - 1); diff --git a/swad_banner.c b/swad_banner.c index 65df6374..81b23211 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -517,16 +517,6 @@ static void Ban_PutParamBanCod (long BanCod) Par_PutHiddenParamLong (NULL,"BanCod",BanCod); } -/*****************************************************************************/ -/******************** Get parameter with code of banner **********************/ -/*****************************************************************************/ - -long Ban_GetParamBanCod (void) - { - /***** Get code of banner *****/ - return Par_GetParToLong ("BanCod"); - } - /*****************************************************************************/ /******************************* Remove a banner *****************************/ /*****************************************************************************/ @@ -540,8 +530,7 @@ void Ban_RemoveBanner (void) Ban_ResetBanner (Ban); /***** Get banner code *****/ - if ((Ban->BanCod = Ban_GetParamBanCod ()) <= 0) - Err_WrongBannerExit (); + Ban->BanCod = Par_GetAndCheckParCode (Par_BanCod); /***** Get data of the banner from database *****/ Ban_GetDataOfBannerByCod (Ban); @@ -592,8 +581,7 @@ void Ban_HideBanner (void) static void Ban_ShowOrHideBanner (struct Ban_Banner *Ban,bool Hide) { /***** Get banner code *****/ - if ((Ban->BanCod = Ban_GetParamBanCod ()) <= 0) - Err_WrongBannerExit (); + Ban->BanCod = Par_GetAndCheckParCode (Par_BanCod); /***** Get data of the banner from database *****/ Ban_GetDataOfBannerByCod (Ban); @@ -667,8 +655,7 @@ static void Ban_RenameBanner (struct Ban_Banner *Ban, /***** Get parameters from form *****/ /* Get the code of the banner */ - if ((Ban->BanCod = Ban_GetParamBanCod ()) <= 0) - Err_WrongBannerExit (); + Ban->BanCod = Par_GetAndCheckParCode (Par_BanCod); /* Get the new name for the banner */ Par_GetParToText (ParamName,NewBanName,MaxBytes); @@ -726,8 +713,7 @@ void Ban_ChangeBannerImg (void) /***** Get parameters from form *****/ /* Get the code of the banner */ - if ((Ban->BanCod = Ban_GetParamBanCod ()) <= 0) - Err_WrongBannerExit (); + Ban->BanCod = Par_GetAndCheckParCode (Par_BanCod); /* Get the new WWW for the banner */ Par_GetParToText ("Img",NewImg,Ban_MAX_BYTES_IMAGE); @@ -769,8 +755,7 @@ void Ban_ChangeBannerWWW (void) /***** Get parameters from form *****/ /* Get the code of the banner */ - if ((Ban->BanCod = Ban_GetParamBanCod ()) <= 0) - Err_WrongBannerExit (); + Ban->BanCod = Par_GetAndCheckParCode (Par_BanCod); /* Get the new WWW for the banner */ Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW); @@ -1030,8 +1015,7 @@ void Ban_ClickOnBanner (void) struct Ban_Banner Ban; /***** Get banner code *****/ - if ((Ban.BanCod = Ban_GetParamBanCod ()) <= 0) - Err_WrongBannerExit (); + Ban.BanCod = Par_GetAndCheckParCode (Par_BanCod); /***** Get data of the banner from database *****/ Ban_GetDataOfBannerByCod (&Ban); diff --git a/swad_browser.c b/swad_browser.c index 643c8749..27069ac9 100644 --- a/swad_browser.c +++ b/swad_browser.c @@ -1978,7 +1978,7 @@ static long Brw_GetGrpSettings (void) { long GrpCod; - if ((GrpCod = Par_GetParToLong ("GrpCod")) > 0) + if ((GrpCod = Par_GetParCode (Par_GrpCod)) > 0) return GrpCod; else /***** Try to get group code from database *****/ @@ -2085,16 +2085,6 @@ void Brw_PutHiddenParamFilCod (long FilCod) Par_PutHiddenParamLong (NULL,"FilCod",FilCod); } -/*****************************************************************************/ -/********************* Get parameter with code of file ***********************/ -/*****************************************************************************/ - -long Brw_GetParamFilCod (void) - { - /***** Get code of file *****/ - return Par_GetParToLong ("FilCod"); - } - /*****************************************************************************/ /**************** Write parameters related with file browser *****************/ /*****************************************************************************/ @@ -7489,7 +7479,7 @@ void Brw_ShowFileMetadata (void) Brw_GetParAndInitFileBrowser (); /***** Get file metadata *****/ - FileMetadata.FilCod = Brw_GetParamFilCod (); + FileMetadata.FilCod = Par_GetAndCheckParCode (Par_FilCod); Brw_GetFileMetadataByCod (&FileMetadata); Found = Brw_GetFileTypeSizeAndDate (&FileMetadata); @@ -8299,7 +8289,7 @@ void Brw_ChgFileMetadata (void) Brw_GetParAndInitFileBrowser (); /***** Get file metadata *****/ - FileMetadata.FilCod = Brw_GetParamFilCod (); + FileMetadata.FilCod = Par_GetAndCheckParCode (Par_FilCod); Brw_GetFileMetadataByCod (&FileMetadata); Found = Brw_GetFileTypeSizeAndDate (&FileMetadata); diff --git a/swad_browser.h b/swad_browser.h index ef701582..6ccb4262 100644 --- a/swad_browser.h +++ b/swad_browser.h @@ -182,7 +182,6 @@ struct Brw_FileMetadata void Brw_GetParAndInitFileBrowser (void); void Brw_PutHiddenParamFilCod (long FilCod); -long Brw_GetParamFilCod (void); void Brw_InitializeFileBrowser (void); bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName); bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName, diff --git a/swad_browser_resource.c b/swad_browser_resource.c index 8ba8fd48..530d9e1c 100644 --- a/swad_browser_resource.c +++ b/swad_browser_resource.c @@ -32,6 +32,7 @@ #include "swad_error.h" #include "swad_form.h" #include "swad_global.h" +#include "swad_parameter.h" #include "swad_program.h" #include "swad_program_database.h" #include "swad_program_resource.h" @@ -57,7 +58,7 @@ void BrwRsc_GetLinkToFile (void) Brw_GetParAndInitFileBrowser (); /***** Get file code *****/ - FilCod = Brw_GetParamFilCod (); + FilCod = Par_GetAndCheckParCode (Par_FilCod); /***** Get file title *****/ switch (Gbl.Action.Act) diff --git a/swad_building.c b/swad_building.c index d39b53de..10a2555d 100644 --- a/swad_building.c +++ b/swad_building.c @@ -492,16 +492,6 @@ static void Bld_PutParamBldCod (void *BldCod) Par_PutHiddenParamLong (NULL,"BldCod",*((long *) BldCod)); } -/*****************************************************************************/ -/******************** Get parameter with code of building ********************/ -/*****************************************************************************/ - -long Bld_GetParamBldCod (void) - { - /***** Get code of building *****/ - return Par_GetParToLong ("BldCod"); - } - /*****************************************************************************/ /****************************** Remove a building ****************************/ /*****************************************************************************/ @@ -514,8 +504,7 @@ void Bld_RemoveBuilding (void) Bld_EditingBuildingConstructor (); /***** Get building code *****/ - if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) <= 0) - Err_WrongBuildingExit (); + Bld_EditingBuilding->BldCod = Par_GetAndCheckParCode (Par_BldCod); /***** Get data of the building from database *****/ Bld_GetDataOfBuildingByCod (Bld_EditingBuilding); @@ -591,8 +580,7 @@ static void Bld_RenameBuilding (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Get parameters from form *****/ /* Get the code of the building */ - if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) <= 0) - Err_WrongBuildingExit (); + Bld_EditingBuilding->BldCod = Par_GetAndCheckParCode (Par_BldCod); /* Get the new name for the building */ Par_GetParToText (ParamName,NewClaName,MaxBytes); @@ -649,8 +637,7 @@ void Bld_ChangeBuildingLocation (void) /***** Get parameters from form *****/ /* Get the code of the building */ - if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) <= 0) - Err_WrongBuildingExit (); + Bld_EditingBuilding->BldCod = Par_GetAndCheckParCode (Par_BldCod); /* Get the new location for the building */ Par_GetParToText ("Location",NewLocation,Bld_MAX_BYTES_LOCATION); diff --git a/swad_building.h b/swad_building.h index 254d5a49..e9e8319b 100644 --- a/swad_building.h +++ b/swad_building.h @@ -90,7 +90,6 @@ void Bld_FreeListBuildings (struct Bld_Buildings *Buildings); void Bld_GetListBuildingsInThisCtr (void); void Bld_GetDataOfBuildingByCod (struct Bld_Building *Roo); -long Bld_GetParamBldCod (void); void Bld_RemoveBuilding (void); void Bld_RenameBuildingShort (void); diff --git a/swad_call_for_exam.c b/swad_call_for_exam.c index cf1ed341..757dc747 100644 --- a/swad_call_for_exam.c +++ b/swad_call_for_exam.c @@ -169,7 +169,7 @@ static long Cfe_GetParamsCallsForExams (struct Cfe_CallsForExams *CallsForExams) long ExaCod; /***** Get the code of the call for exam *****/ - ExaCod = Cfe_GetParamExaCod (); + ExaCod = Par_GetAndCheckParCode (Par_ExaCod); /***** Get the name of the course (it is allowed to be different from the official name of the course) *****/ Par_GetParToText ("CrsName",CallsForExams->CallForExam.CrsFullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME); @@ -379,8 +379,7 @@ void Cfe_PrintCallForExam (void) Cfe_AllocMemCallForExam (&CallsForExams); /***** Get the code of the call for exam *****/ - if ((ExaCod = Cfe_GetParamExaCod ()) <= 0) - Err_WrongCallForExamExit (); + ExaCod = Par_GetAndCheckParCode (Par_ExaCod); /***** Read call for exam from the database *****/ Cfe_GetDataCallForExamFromDB (&CallsForExams,ExaCod); @@ -407,8 +406,7 @@ void Cfe_ReqRemoveCallForExam (void) Cfe_ResetCallsForExams (&CallsForExams); /***** Get the code of the call for exam *****/ - if ((ExaCod = Cfe_GetParamExaCod ()) <= 0) - Err_WrongCallForExamExit (); + ExaCod = Par_GetAndCheckParCode (Par_ExaCod); /***** Show question and button to remove call for exam *****/ /* Begin alert */ @@ -442,8 +440,7 @@ void Cfe_RemoveCallForExam1 (void) Cfe_ResetCallsForExams (CallsForExams); /***** Get the code of the call for exam *****/ - if ((ExaCod = Cfe_GetParamExaCod ()) <= 0) - Err_WrongCallForExamExit (); + ExaCod = Par_GetAndCheckParCode (Par_ExaCod); /***** Mark the call for exam as deleted in the database *****/ Cfe_DB_MarkACallForExamAsDeleted (ExaCod); @@ -484,8 +481,7 @@ void Cfe_HideCallForExam (void) Cfe_ResetCallsForExams (CallsForExams); /***** Get the code of the call for exam *****/ - if ((ExaCod = Cfe_GetParamExaCod ()) <= 0) - Err_WrongCallForExamExit (); + ExaCod = Par_GetAndCheckParCode (Par_ExaCod); /***** Mark the call for exam as hidden in the database *****/ Cfe_DB_HideCallForExam (ExaCod); @@ -509,8 +505,7 @@ void Cfe_UnhideCallForExam (void) Cfe_ResetCallsForExams (CallsForExams); /***** Get the code of the call for exam *****/ - if ((ExaCod = Cfe_GetParamExaCod ()) <= 0) - Err_WrongCallForExamExit (); + ExaCod = Par_GetAndCheckParCode (Par_ExaCod); /***** Mark the call for exam as visible in the database *****/ Cfe_DB_UnhideCallForExam (ExaCod); @@ -592,7 +587,7 @@ static void Cfe_GetExaCodToHighlight (struct Cfe_CallsForExams *CallsForExams) { /***** Get the call for exam code of the call for exam to highlight *****/ - CallsForExams->HighlightExaCod = Cfe_GetParamExaCod (); + CallsForExams->HighlightExaCod = Par_GetParCode (Par_ExaCod); } /*****************************************************************************/ @@ -1562,16 +1557,6 @@ void Cfe_PutHiddenParamExaCod (long ExaCod) Par_PutHiddenParamLong (NULL,"ExaCod",ExaCod); } -/*****************************************************************************/ -/************ Get parameter with the code of a call for exam *****************/ -/*****************************************************************************/ - -long Cfe_GetParamExaCod (void) - { - /* Get notice code */ - return Par_GetParToLong ("ExaCod"); - } - /*****************************************************************************/ /************** Get summary and content about a call for exam ****************/ /*****************************************************************************/ diff --git a/swad_call_for_exam.h b/swad_call_for_exam.h index 368afe30..3df3aa5b 100644 --- a/swad_call_for_exam.h +++ b/swad_call_for_exam.h @@ -132,7 +132,6 @@ void Cfe_CreateListCallsForExams (struct Cfe_CallsForExams *CallsForExams); bool Cfe_CheckIfICanEditCallsForExams (void); void Cfe_PutHiddenParamExaCod (long ExaCod); -long Cfe_GetParamExaCod (void); void Cfe_GetSummaryAndContentCallForExam (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, diff --git a/swad_call_for_exam_resource.c b/swad_call_for_exam_resource.c index 50bf73fb..b26aa99c 100644 --- a/swad_call_for_exam_resource.c +++ b/swad_call_for_exam_resource.c @@ -31,6 +31,7 @@ #include "swad_call_for_exam_resource.h" #include "swad_error.h" #include "swad_form.h" +#include "swad_parameter.h" #include "swad_program_database.h" /*****************************************************************************/ @@ -45,7 +46,7 @@ void Cfe_GetLinkToCallForExam (void) char Title[Cfe_MAX_BYTES_SESSION_AND_DATE]; /***** Get the code of the call for exam *****/ - ExaCod = Cfe_GetParamExaCod (); + ExaCod = Par_GetAndCheckParCode (Par_ExaCod); /***** Get session and date of the exam *****/ CfeRsc_GetTitleFromExaCod (ExaCod,Title,sizeof (Title) - 1); diff --git a/swad_center.c b/swad_center.c index b07fb470..786f1bdc 100644 --- a/swad_center.c +++ b/swad_center.c @@ -961,21 +961,6 @@ void Ctr_PutParamCtrCod (long CtrCod) Par_PutHiddenParamLong (NULL,"ctr",CtrCod); } -/*****************************************************************************/ -/****************** Get parameter with code of other center ******************/ -/*****************************************************************************/ - -long Ctr_GetAndCheckParamOtherCtrCod (long MinCodAllowed) - { - long CtrCod; - - /***** Get and check parameter with code of center *****/ - if ((CtrCod = Par_GetParToLong ("OthCtrCod")) < MinCodAllowed) - Err_WrongCenterExit (); - - return CtrCod; - } - /*****************************************************************************/ /******************************* Remove a center *****************************/ /*****************************************************************************/ diff --git a/swad_center.h b/swad_center.h index 2319a952..0577544a 100644 --- a/swad_center.h +++ b/swad_center.h @@ -94,7 +94,6 @@ bool Ctr_GetDataOfCenterByCod (struct Ctr_Center *Ctr); void Ctr_FreeListCenters (void); void Ctr_WriteSelectorOfCenter (void); void Ctr_PutParamCtrCod (long CtrCod); -long Ctr_GetAndCheckParamOtherCtrCod (long MinCodAllowed); void Ctr_RemoveCenter (void); void Ctr_ChangeCtrPlc (void); void Ctr_RenameCenterShort (void); diff --git a/swad_center_config.c b/swad_center_config.c index 3ffb0108..cbd1cffc 100644 --- a/swad_center_config.c +++ b/swad_center_config.c @@ -1006,7 +1006,7 @@ void CtrCfg_ChangeCtrIns (void) struct Ins_Instit NewIns; /***** Get parameter with institution code *****/ - NewIns.InsCod = Ins_GetAndCheckParamOtherInsCod (1); + NewIns.InsCod = Par_GetAndCheckParCode (Par_OthInsCod); /***** Check if institution has changed *****/ if (NewIns.InsCod != Gbl.Hierarchy.Ctr.InsCod) diff --git a/swad_changelog.h b/swad_changelog.h index 5e7fc63e..6a2d5981 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -629,10 +629,12 @@ TODO: Emilce Barrera Mesa: Podr TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen. */ -#define Log_PLATFORM_VERSION "SWAD 22.66.3 (2023-03-04)" +#define Log_PLATFORM_VERSION "SWAD 22.67 (2023-03-04)" #define CSS_FILE "swad22.57.1.css" #define JS_FILE "swad22.49.js" /* + Version 22.67: Mar 04, 2023 Code refactoring in parameters. Not finished. (337245 lines) + Version 22.66.4: Mar 04, 2023 Fixed issues in exams. (337245 lines) Version 22.66.3: Mar 04, 2023 New action to edit a new rubric criterion. Not finished. (337198 lines) Version 22.66.2: Mar 03, 2023 Fixed bugs in figures. (337128 lines) Version 22.66.1: Mar 02, 2023 Rubric removal. (337126 lines) diff --git a/swad_country.c b/swad_country.c index 09acb8f4..1855b2b2 100644 --- a/swad_country.c +++ b/swad_country.c @@ -80,7 +80,6 @@ static void Cty_PutIconToViewCountries (void); static void Cty_ListCountriesForEdition (void); static void Cty_PutParamOtherCtyCod (void *CtyCod); -static long Cty_GetParamOtherCtyCod (void); static void Cty_UpdateCtyName (long CtyCod,const char *FieldName,const char *NewCtyName); @@ -1184,27 +1183,6 @@ static void Cty_PutParamOtherCtyCod (void *CtyCod) Par_PutHiddenParamLong (NULL,"OthCtyCod",*((long *) CtyCod)); } -/*****************************************************************************/ -/******************* Get parameter with code of country **********************/ -/*****************************************************************************/ - -long Cty_GetAndCheckParamOtherCtyCod (long MinCodAllowed) - { - long CtyCod; - - /***** Get and check parameter with code of country *****/ - if ((CtyCod = Cty_GetParamOtherCtyCod ()) < MinCodAllowed) - Err_WrongCountrExit (); - - return CtyCod; - } - -static long Cty_GetParamOtherCtyCod (void) - { - /***** Get code of country *****/ - return Par_GetParToLong ("OthCtyCod"); - } - /*****************************************************************************/ /****************************** Remove a country *****************************/ /*****************************************************************************/ @@ -1218,7 +1196,7 @@ void Cty_RemoveCountry (void) Cty_EditingCountryConstructor (); /***** Get country code *****/ - Cty_EditingCty->CtyCod = Cty_GetAndCheckParamOtherCtyCod (0); + Cty_EditingCty->CtyCod = Par_GetAndCheckParCode (Par_OthCtyCod); /***** Get data of the country from database *****/ Cty_GetDataOfCountryByCod (Cty_EditingCty); @@ -1279,7 +1257,7 @@ void Cty_RenameCountry (void) Cty_EditingCountryConstructor (); /***** Get the code of the country *****/ - Cty_EditingCty->CtyCod = Cty_GetAndCheckParamOtherCtyCod (0); + Cty_EditingCty->CtyCod = Par_GetAndCheckParCode (Par_OthCtyCod); /***** Get the lenguage *****/ Language = Lan_GetParamLanguage (); @@ -1358,7 +1336,7 @@ void Cty_ChangeCtyWWW (void) Cty_EditingCountryConstructor (); /***** Get the code of the country *****/ - Cty_EditingCty->CtyCod = Cty_GetAndCheckParamOtherCtyCod (0); + Cty_EditingCty->CtyCod = Par_GetAndCheckParCode (Par_OthCtyCod); /***** Get the lenguage *****/ Language = Lan_GetParamLanguage (); @@ -1587,7 +1565,7 @@ void Cty_ReceiveFormNewCountry (void) /***** Get parameters from form *****/ /* Get numeric country code */ - if ((Cty_EditingCty->CtyCod = Cty_GetParamOtherCtyCod ()) < 0) + if ((Cty_EditingCty->CtyCod = Par_GetParCode (Par_OthCtyCod)) < 0) { Ale_CreateAlert (Ale_WARNING,NULL, Txt_You_must_specify_the_numerical_code_of_the_new_country); diff --git a/swad_country.h b/swad_country.h index a626afcd..caff3552 100644 --- a/swad_country.h +++ b/swad_country.h @@ -104,7 +104,6 @@ void Cty_FlushCacheCountryName (void); void Cty_GetCountryName (long CtyCod,Lan_Language_t Language, char CtyName[Cty_MAX_BYTES_NAME + 1]); void Cty_PutParamCtyCod (long CtyCod); -long Cty_GetAndCheckParamOtherCtyCod (long MinCodAllowed); void Cty_RemoveCountry (void); void Cty_RenameCountry (void); void Cty_ChangeCtyWWW (void); diff --git a/swad_course_config.c b/swad_course_config.c index 409fa91b..8592b5e6 100644 --- a/swad_course_config.c +++ b/swad_course_config.c @@ -472,7 +472,7 @@ void CrsCfg_ChangeCrsDeg (void) struct Deg_Degree NewDeg; /***** Get parameter with degree code *****/ - NewDeg.DegCod = Deg_GetAndCheckParamOtherDegCod (1L); + NewDeg.DegCod = Par_GetAndCheckParCode (Par_OthDegCod); /***** Check if degree has changed *****/ if (NewDeg.DegCod != Gbl.Hierarchy.Crs.DegCod) diff --git a/swad_degree.c b/swad_degree.c index ae75fbdb..c6b13c47 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -1176,21 +1176,6 @@ void Deg_PutParamDegCod (long DegCod) Par_PutHiddenParamLong (NULL,"deg",DegCod); } -/*****************************************************************************/ -/********************* Get parameter with code of degree *********************/ -/*****************************************************************************/ - -long Deg_GetAndCheckParamOtherDegCod (long MinCodAllowed) - { - long DegCod; - - /***** Get and check parameter with code of degree *****/ - if ((DegCod = Par_GetParToLong ("OthDegCod")) < MinCodAllowed) - Err_WrongDegreeExit (); - - return DegCod; - } - /*****************************************************************************/ /********************* Get data of a degree from its code ********************/ /*****************************************************************************/ diff --git a/swad_degree.h b/swad_degree.h index 8ea562ee..57ceefc0 100644 --- a/swad_degree.h +++ b/swad_degree.h @@ -93,7 +93,6 @@ void Deg_ReceiveFormNewDeg (void); void Deg_RemoveDegree (void); void Deg_PutParamDegCod (long DegCod); -long Deg_GetAndCheckParamOtherDegCod (long MinCodAllowed); bool Deg_GetDataOfDegreeByCod (struct Deg_Degree *Deg); void Deg_RemoveDegreeCompletely (long DegCod); diff --git a/swad_degree_config.c b/swad_degree_config.c index f203dd50..a2501a25 100644 --- a/swad_degree_config.c +++ b/swad_degree_config.c @@ -360,7 +360,7 @@ void DegCfg_ChangeDegCtr (void) struct Ctr_Center NewCtr; /***** Get parameter with center code *****/ - NewCtr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod (1); + NewCtr.CtrCod = Par_GetAndCheckParCode (Par_OthCtrCod); /***** Check if center has changed *****/ if (NewCtr.CtrCod != Gbl.Hierarchy.Deg.CtrCod) diff --git a/swad_department.c b/swad_department.c index aa7fc952..ab365a8c 100644 --- a/swad_department.c +++ b/swad_department.c @@ -626,7 +626,7 @@ void Dpt_ChangeDepartIns (void) Dpt_EditingDpt->DptCod = Dpt_GetAndCheckParamDptCod (1); /* Get parameter with institution code */ - NewInsCod = Ins_GetAndCheckParamOtherInsCod (1); + NewInsCod = Par_GetAndCheckParCode (Par_OthInsCod); /***** Get data of the department from database *****/ Dpt_GetDataOfDepartmentByCod (Dpt_EditingDpt); @@ -919,7 +919,7 @@ void Dpt_ReceiveFormNewDpt (void) /***** Get parameters from form *****/ /* Get institution */ - Dpt_EditingDpt->InsCod = Ins_GetAndCheckParamOtherInsCod (1); + Dpt_EditingDpt->InsCod = Par_GetAndCheckParCode (Par_OthInsCod); /* Get department short name */ Par_GetParToText ("ShortName",Dpt_EditingDpt->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); diff --git a/swad_error.c b/swad_error.c index aadb1b50..9a419030 100644 --- a/swad_error.c +++ b/swad_error.c @@ -473,6 +473,15 @@ void Err_WrongWhoExit (void) Err_ShowErrorAndExit ("Wrong parameter who."); } +/*****************************************************************************/ +/**************** Write error message and exit when wrong code ***************/ +/*****************************************************************************/ + +void Err_WrongCodeExit (void) + { + Err_ShowErrorAndExit ("Wrong code."); + } + /*****************************************************************************/ /**************** Write error message and exit when wrong event **************/ /*****************************************************************************/ diff --git a/swad_error.h b/swad_error.h index 35813265..822f68da 100644 --- a/swad_error.h +++ b/swad_error.h @@ -82,6 +82,7 @@ void Err_WrongCriterionExit (void); void Err_WrongCriterionIndexExit (void); void Err_WrongSurveyExit (void); void Err_WrongWhoExit (void); +void Err_WrongCodeExit (void); void Err_WrongEventExit (void); void Err_WrongAnnouncementExit (void); void Err_WrongNoticeExit (void); diff --git a/swad_exam_set.c b/swad_exam_set.c index 2b0bfe42..e9051ed6 100644 --- a/swad_exam_set.c +++ b/swad_exam_set.c @@ -662,7 +662,7 @@ static void ExaSet_ListSetQuestions (struct Exa_Exams *Exams, bool ICanEditQuestions = Exa_CheckIfEditable (&Exams->Exam); /***** Begin box *****/ - Box_BoxBegin (NULL,Txt_Questions, + Box_BoxBegin ("100%",Txt_Questions, ICanEditQuestions ? ExaSet_PutIconToAddNewQuestions : NULL, ICanEditQuestions ? Exams : @@ -970,7 +970,7 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, else Ico_PutIconRemovalNotAllowed (); - /* Put icon to cancel the question */ + /* Put icon to validate/invalidate the question */ Lay_PutContextualLinkOnlyIcon (ValInv[Question.Validity].NextAction,Anchor, ExaSet_PutParamsOneQst,Exams, ValInv[Question.Validity].Icon, diff --git a/swad_group.c b/swad_group.c index 76134a06..0157af7b 100644 --- a/swad_group.c +++ b/swad_group.c @@ -143,8 +143,6 @@ static void Grp_RemoveGroupTypeCompletely (void); static void Grp_RemoveGroupCompletely (void); static void Grp_WriteMaxStds (char Str[Cns_MAX_DECIMAL_DIGITS_UINT + 1],unsigned MaxStudents); -static long Grp_GetParamGrpTypCod (void); -static long Grp_GetParamGrpCod (void); static void Grp_PutParamGrpTypCod (void *GrpTypCod); /*****************************************************************************/ @@ -3297,7 +3295,7 @@ void Grp_ReceiveFormNewGrp (void) char AlertTxt[256 + Grp_MAX_BYTES_GROUP_NAME]; /***** Get parameters from form *****/ - if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) > 0) // Group type valid + if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Par_GetParCode (Par_GrpTypCod)) > 0) // Group type valid { /* Get group name */ Par_GetParToText ("GrpName",Gbl.Crs.Grps.GrpName, @@ -3362,8 +3360,7 @@ void Grp_ReqRemGroupType (void) unsigned NumGrps; /***** Get the code of the group type *****/ - if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) - Err_WrongGrpTypExit (); + Gbl.Crs.Grps.GrpTyp.GrpTypCod = Par_GetAndCheckParCode (Par_GrpTypCod); /***** Check if this group type has groups *****/ if ((NumGrps = Grp_DB_CountNumGrpsInThisCrsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod))) // Group type has groups ==> Ask for confirmation @@ -3379,8 +3376,7 @@ void Grp_ReqRemGroupType (void) void Grp_ReqRemGroup (void) { /***** Get group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) - Err_WrongGroupExit (); + Gbl.Crs.Grps.GrpCod = Par_GetAndCheckParCode (Par_GrpCod); /***** Confirm removing *****/ Grp_AskConfirmRemGrp (); @@ -3476,8 +3472,7 @@ static void Grp_AskConfirmRemGrp (void) void Grp_RemoveGroupType (void) { /***** Get param with code of group type *****/ - if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) - Err_WrongGrpTypExit (); + Gbl.Crs.Grps.GrpTyp.GrpTypCod = Par_GetAndCheckParCode (Par_GrpTypCod); /***** Remove group type and its groups *****/ Grp_RemoveGroupTypeCompletely (); @@ -3490,8 +3485,7 @@ void Grp_RemoveGroupType (void) void Grp_RemoveGroup (void) { /***** Get param with group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) - Err_WrongGroupExit (); + Gbl.Crs.Grps.GrpCod = Par_GetAndCheckParCode (Par_GrpCod); /***** Remove group *****/ Grp_RemoveGroupCompletely (); @@ -3609,8 +3603,7 @@ void Grp_OpenGroup (void) char AlertTxt[256 + Grp_MAX_BYTES_GROUP_NAME]; /***** Get group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) - Err_WrongGroupExit (); + Gbl.Crs.Grps.GrpCod = Par_GetAndCheckParCode (Par_GrpCod); /***** Get group data from database *****/ GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod; @@ -3640,8 +3633,7 @@ void Grp_CloseGroup (void) char AlertTxt[256 + Grp_MAX_BYTES_GROUP_NAME]; /***** Get group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) - Err_WrongGroupExit (); + Gbl.Crs.Grps.GrpCod = Par_GetAndCheckParCode (Par_GrpCod); /***** Get group data from database *****/ GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod; @@ -3671,8 +3663,7 @@ void Grp_EnableFileZonesGrp (void) char AlertTxt[256 + Grp_MAX_BYTES_GROUP_NAME]; /***** Get group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) - Err_WrongGroupExit (); + Gbl.Crs.Grps.GrpCod = Par_GetAndCheckParCode (Par_GrpCod); /***** Get group data from database *****/ GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod; @@ -3703,8 +3694,7 @@ void Grp_DisableFileZonesGrp (void) char AlertTxt[256 + Grp_MAX_BYTES_GROUP_NAME]; /***** Get group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) - Err_WrongGroupExit (); + Gbl.Crs.Grps.GrpCod = Par_GetAndCheckParCode (Par_GrpCod); /***** Get group data from database *****/ GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod; @@ -3739,11 +3729,10 @@ void Grp_ChangeGroupType (void) /***** Get parameters from form *****/ /* Get group code */ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) - Err_WrongGroupExit (); + Gbl.Crs.Grps.GrpCod = Par_GetAndCheckParCode (Par_GrpCod); /* Get the new group type */ - NewGrpTypCod = Grp_GetParamGrpTypCod (); + NewGrpTypCod = Par_GetAndCheckParCode (Par_GrpTypCod); /* Get from the database the type and the name of the group */ GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod; @@ -3789,8 +3778,7 @@ void Grp_ChangeGroupRoom (void) /***** Get parameters from form *****/ /* Get group code */ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) - Err_WrongGroupExit (); + Gbl.Crs.Grps.GrpCod = Par_GetAndCheckParCode (Par_GrpCod); /* Get the new room */ NewRooCod = Roo_GetParamRooCod (); @@ -3829,8 +3817,7 @@ void Grp_ChangeMandatGrpTyp (void) /***** Get parameters of the form *****/ /* Get the código of type of group */ - if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) - Err_WrongGrpTypExit (); + Gbl.Crs.Grps.GrpTyp.GrpTypCod = Par_GetAndCheckParCode (Par_GrpTypCod); /* Get the new type of enrolment (mandatory or voluntaria) of this type of group */ NewMandatoryEnrolment = Par_GetParToBool ("MandatoryEnrolment"); @@ -3883,8 +3870,7 @@ void Grp_ChangeMultiGrpTyp (void) /***** Get parameters from the form *****/ /* Get the code of type of group */ - if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) - Err_WrongGrpTypExit (); + Gbl.Crs.Grps.GrpTyp.GrpTypCod = Par_GetAndCheckParCode (Par_GrpTypCod); /* Get the new type of enrolment (single or multiple) of this type of group */ NewMultipleEnrolment = Par_GetParToBool ("MultipleEnrolment"); @@ -3930,8 +3916,7 @@ void Grp_ChangeOpenTimeGrpTyp (void) extern const char *Txt_The_date_time_of_opening_of_groups_has_changed; /***** Get the code of type of group *****/ - if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) - Err_WrongGrpTypExit (); + Gbl.Crs.Grps.GrpTyp.GrpTypCod = Par_GetAndCheckParCode (Par_GrpTypCod); /***** Get from the database the data of this type of group *****/ Grp_GetDataOfGroupTypeByCod (&Gbl.Crs.Grps.GrpTyp); @@ -3970,8 +3955,7 @@ void Grp_ChangeMaxStdsGrp (void) /***** Get parameters of the form *****/ /* Get group code */ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) - Err_WrongGroupExit (); + Gbl.Crs.Grps.GrpCod = Par_GetAndCheckParCode (Par_GrpCod); /* Get the new maximum number of students of the group */ NewMaxStds = (unsigned) @@ -4059,8 +4043,7 @@ void Grp_RenameGroupType (void) /***** Get parameters from form *****/ /* Get the code of the group type */ - if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) - Err_WrongGrpTypExit (); + Gbl.Crs.Grps.GrpTyp.GrpTypCod = Par_GetAndCheckParCode (Par_GrpTypCod); /* Get the new name for the group type */ Par_GetParToText ("GrpTypName",NewNameGrpTyp,Grp_MAX_BYTES_GROUP_TYPE_NAME); @@ -4132,8 +4115,7 @@ void Grp_RenameGroup (void) /***** Get parameters from form *****/ /* Get the code of the group */ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) - Err_WrongGroupExit (); + Gbl.Crs.Grps.GrpCod = Par_GetAndCheckParCode (Par_GrpCod); /* Get the new name for the group */ Par_GetParToText ("GrpName",NewNameGrp,Grp_MAX_BYTES_GROUP_NAME); @@ -4188,26 +4170,6 @@ void Grp_RenameGroup (void) AlertType,AlertTxt); } -/*****************************************************************************/ -/******************* Get parameter with code of group type *******************/ -/*****************************************************************************/ - -static long Grp_GetParamGrpTypCod (void) - { - /***** Get code of group type *****/ - return Par_GetParToLong ("GrpTypCod"); - } - -/*****************************************************************************/ -/*********************** Get parameter with group code ***********************/ -/*****************************************************************************/ - -static long Grp_GetParamGrpCod (void) - { - /***** Get group code *****/ - return Par_GetParToLong ("GrpCod"); - } - /*****************************************************************************/ /****************** Write parameter with code of group type ******************/ /*****************************************************************************/ diff --git a/swad_institution.c b/swad_institution.c index c5b460ab..d9a4ee18 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -1116,21 +1116,6 @@ void Ins_PutParamInsCod (long InsCod) Par_PutHiddenParamLong (NULL,"ins",InsCod); } -/*****************************************************************************/ -/******************* Get parameter with code of institution ******************/ -/*****************************************************************************/ - -long Ins_GetAndCheckParamOtherInsCod (long MinCodAllowed) - { - long InsCod; - - /***** Get and check parameter with code of institution *****/ - if ((InsCod = Par_GetParToLong ("OthInsCod")) < MinCodAllowed) - Err_WrongInstitExit (); - - return InsCod; - } - /*****************************************************************************/ /**************************** Remove a institution ***************************/ /*****************************************************************************/ diff --git a/swad_institution.h b/swad_institution.h index 917fc3b0..5875ae17 100644 --- a/swad_institution.h +++ b/swad_institution.h @@ -93,7 +93,6 @@ void Ins_FreeListInstitutions (void); void Ins_WriteSelectorOfInstitution (void); void Ins_PutParamCurrentInsCod (void *InsCod); void Ins_PutParamInsCod (long InsCod); -long Ins_GetAndCheckParamOtherInsCod (long MinCodAllowed); void Ins_RemoveInstitution (void); void Ins_RenameInsShort (void); void Ins_RenameInsFull (void); diff --git a/swad_institution_config.c b/swad_institution_config.c index 8bef204c..3532de02 100644 --- a/swad_institution_config.c +++ b/swad_institution_config.c @@ -539,7 +539,7 @@ void InsCfg_ChangeInsCty (void) struct Cty_Countr NewCty; /***** Get the new country code for the institution *****/ - NewCty.CtyCod = Cty_GetAndCheckParamOtherCtyCod (0); + NewCty.CtyCod = Par_GetAndCheckParCode (Par_OthCtyCod); /***** Check if country has changed *****/ if (NewCty.CtyCod != Gbl.Hierarchy.Ins.CtyCod) diff --git a/swad_parameter.c b/swad_parameter.c index b7a543c1..b3a0fad7 100644 --- a/swad_parameter.c +++ b/swad_parameter.c @@ -946,6 +946,49 @@ long Par_GetParToLong (const char *ParamName) return Str_ConvertStrCodToLongCod (LongStr); } +/*****************************************************************************/ +/******************** Get the value of a code parameter **********************/ +/*****************************************************************************/ + +long Par_GetAndCheckParCode (Par_Code_t ParamCode) + { + return Par_GetAndCheckParCodeMin (ParamCode,1); + } + +long Par_GetAndCheckParCodeMin (Par_Code_t ParamCode,long MinCodAllowed) + { + long Cod; + + /***** Get code and check that is a valid code (>= minimum) *****/ + if ((Cod = Par_GetParCode (ParamCode)) < MinCodAllowed) + Err_WrongCodeExit (); + + return Cod; + } + +long Par_GetParCode (Par_Code_t ParamCode) + { + static const char *Par_CodeStr[] = + { + [Par_AgdCod] = "AgdCod", + [Par_AnnCod] = "AnnCod", + [Par_AsgCod] = "AsgCod", + [Par_AttCod] = "AttCod", + [Par_BanCod] = "BanCod", + [Par_BldCod] = "BldCod", + [Par_ExaCod] = "ExaCod", + [Par_FilCod] = "FilCod", + [Par_GrpCod] = "GrpCod", + [Par_GrpTypCod] = "GrpTypCod", + [Par_OthCtrCod] = "OthCtrCod", + [Par_OthCtyCod] = "OthCtyCod", + [Par_OthDegCod] = "OthDegCod", + [Par_OthInsCod] = "OthInsCod", + }; + + return Par_GetParToLong (Par_CodeStr[ParamCode]); + } + /*****************************************************************************/ /************************** Get a boolean parameter **************************/ /*****************************************************************************/ diff --git a/swad_parameter.h b/swad_parameter.h index cc27e67b..62bdbbbb 100644 --- a/swad_parameter.h +++ b/swad_parameter.h @@ -63,6 +63,24 @@ typedef enum Par_PARAM_MULTIPLE, } Par_ParamType_t; // Parameter is present only one time / multiple times +typedef enum + { + Par_AgdCod, + Par_AnnCod, + Par_AsgCod, + Par_AttCod, + Par_BanCod, + Par_BldCod, + Par_ExaCod, + Par_FilCod, + Par_GrpCod, + Par_GrpTypCod, + Par_OthCtrCod, + Par_OthCtyCod, + Par_OthDegCod, + Par_OthInsCod, + } Par_Code_t; + /*****************************************************************************/ /***************************** Public prototypes *****************************/ /*****************************************************************************/ @@ -85,6 +103,9 @@ unsigned long Par_GetParToUnsignedLong (const char *ParamName, unsigned long Max, unsigned long Default); long Par_GetParToLong (const char *ParamName); +long Par_GetAndCheckParCode (Par_Code_t ParamCode); +long Par_GetAndCheckParCodeMin (Par_Code_t ParamCode,long MinCodAllowed); +long Par_GetParCode (Par_Code_t ParamCode); bool Par_GetParToBool (const char *ParamName); unsigned Par_GetParToHTML (const char *ParamName,char *ParamValue,size_t MaxBytes); unsigned Par_GetParMultiToText (const char *ParamName,char *ParamValue,size_t MaxBytes); diff --git a/swad_photo.c b/swad_photo.c index 5cde838d..1ac05ab9 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -1410,11 +1410,8 @@ void Pho_CalcPhotoDegree (void) Fil_CreateDirIfNotExists (Cfg_PATH_PHOTO_TMP_PRIVATE); /***** Get the degree which photo will be computed *****/ - DegCod = Deg_GetAndCheckParamOtherDegCod (-1L); // Parameter may be omitted - // (when selecting classphoto/list) - - if (DegCod > 0) - { + if ((DegCod = Par_GetParCode (Par_OthDegCod)) > 0) // Parameter may be omitted + { // (when selecting classphoto/list) /***** Prevent the computing of an average photo too recently updated *****/ if (Pho_GetTimeAvgPhotoWasComputed (DegCod) >= Dat_GetStartExecutionTimeUTC () - Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO) diff --git a/swad_record.c b/swad_record.c index c253bd42..b1c78388 100644 --- a/swad_record.c +++ b/swad_record.c @@ -3987,7 +3987,7 @@ void Rec_ChgCountryOfMyInstitution (void) unsigned NumInss; /***** Get country code of my institution *****/ - Gbl.Usrs.Me.UsrDat.InsCtyCod = Cty_GetAndCheckParamOtherCtyCod (0); + Gbl.Usrs.Me.UsrDat.InsCtyCod = Par_GetAndCheckParCode (Par_OthCtyCod); /***** When country changes, the institution, center and department must be reset *****/ NumInss = Ins_GetNumInssInCty (Gbl.Usrs.Me.UsrDat.InsCtyCod); @@ -4023,7 +4023,7 @@ void Rec_UpdateMyInstitution (void) /***** Get my institution *****/ /* Get institution code */ - Ins.InsCod = Ins_GetAndCheckParamOtherInsCod (0); // 0 (another institution) is allowed here + Ins.InsCod = Par_GetAndCheckParCodeMin (Par_OthInsCod,0); // 0 (another institution) is allowed here /* Get country of institution */ if (Ins.InsCod > 0) @@ -4059,7 +4059,7 @@ void Rec_UpdateMyCenter (void) /***** Get my center *****/ /* Get center code */ - Ctr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod (0); // 0 (another center) is allowed here + Ctr.CtrCod = Par_GetAndCheckParCodeMin (Par_OthCtrCod,0); // 0 (another center) is allowed here /* Get institution of center */ if (Ctr.CtrCod > 0) diff --git a/swad_room.c b/swad_room.c index 4a3ff75d..64e23c31 100644 --- a/swad_room.c +++ b/swad_room.c @@ -937,7 +937,7 @@ void Roo_ChangeBuilding (void) Err_WrongRoomExit (); /* Get room building */ - NewBldCod = Bld_GetParamBldCod (); + NewBldCod = Par_GetAndCheckParCode (Par_BldCod); /***** Get data of the room from database *****/ Roo_GetDataOfRoomByCod (Roo_EditingRoom); @@ -1386,7 +1386,7 @@ void Roo_ReceiveFormNewRoom (void) /***** Get parameters from form *****/ /* Get room building, floor and type */ - Roo_EditingRoom->BldCod = Bld_GetParamBldCod (); + Roo_EditingRoom->BldCod = Par_GetAndCheckParCode (Par_BldCod); Roo_EditingRoom->Floor = Roo_GetParamFloor (); Roo_EditingRoom->Type = Roo_GetParamType (); diff --git a/swad_text_action.c b/swad_text_action.c index 322605c5..9534f105 100644 --- a/swad_text_action.c +++ b/swad_text_action.c @@ -12296,6 +12296,52 @@ const char *Txt_Actions[ActLst_NUM_ACTIONS] = "Remove exam question" // Precisa de tradução #elif L==10 // tr "Remove exam question" // Çeviri lazim! +#endif + , + [ActValSetQst] = +#if L==1 // ca + "Validar pregunta d'examen" +#elif L==2 // de + "Prüfungsfrage validieren" +#elif L==3 // en + "Validate exam question" +#elif L==4 // es + "Validar pregunta de examen" +#elif L==5 // fr + "Valider question d'examen" +#elif L==6 // gn + "Validar pregunta de examen" // Okoteve traducción +#elif L==7 // it + "Validare domanda d'esame" +#elif L==8 // pl + "Potwierdź pytanie egzaminacyjne" +#elif L==9 // pt + "Validar pergunta do exame" +#elif L==10 // tr + "Sınav sorusunu doğrula" +#endif + , + [ActInvSetQst] = +#if L==1 // ca + "Invalidar pregunta d'examen" +#elif L==2 // de + "Prüfungsfrage ungültig machen" +#elif L==3 // en + "Invalidate exam question" +#elif L==4 // es + "Invalidar pregunta de examen" +#elif L==5 // fr + "Invalider question d'examen" +#elif L==6 // gn + "Invalidar pregunta de examen" // Okoteve traducción +#elif L==7 // it + "Invalidare domanda d'esame" +#elif L==8 // pl + "Unieważnij pytanie egzaminacyjne" +#elif L==9 // pt + "Invalidar pergunta do exame" +#elif L==10 // tr + "Geçersiz sınav sorusu" #endif , [ActReqNewExaSes] =