diff --git a/swad_assignment.c b/swad_assignment.c index e0c0fb52..a1a5f387 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -742,8 +742,8 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments) NumAsg++) { /* Get next assignment code */ - if ((Assignments->LstAsgCods[NumAsg] = DB_GetNextCode (mysql_res)) < 0) - Lay_ShowErrorAndExit ("Error: wrong assignment code."); + if ((Assignments->LstAsgCods[NumAsg] = DB_GetNextCode (mysql_res)) <= 0) + Lay_WrongAssignmentExit (); } } else @@ -1033,8 +1033,8 @@ void Asg_ReqRemAssignment (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get assignment code *****/ - if ((Asg.AsgCod = Asg_GetParamAsgCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of assignment is missing."); + if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0) + Lay_WrongAssignmentExit (); /***** Get data of the assignment from database *****/ Asg_GetDataOfAssignmentByCod (&Asg); @@ -1070,8 +1070,8 @@ void Asg_RemoveAssignment (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get assignment code *****/ - if ((Asg.AsgCod = Asg_GetParamAsgCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of assignment is missing."); + if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0) + Lay_WrongAssignmentExit (); /***** Get data of the assignment from database *****/ Asg_GetDataOfAssignmentByCod (&Asg); // Inside this function, the course is checked to be the current one @@ -1120,8 +1120,8 @@ void Asg_HideAssignment (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get assignment code *****/ - if ((Asg.AsgCod = Asg_GetParamAsgCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of assignment is missing."); + if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0) + Lay_WrongAssignmentExit (); /***** Get data of the assignment from database *****/ Asg_GetDataOfAssignmentByCod (&Asg); @@ -1157,8 +1157,8 @@ void Asg_ShowAssignment (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get assignment code *****/ - if ((Asg.AsgCod = Asg_GetParamAsgCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of assignment is missing."); + if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0) + Lay_WrongAssignmentExit (); /***** Get data of the assignment from database *****/ Asg_GetDataOfAssignmentByCod (&Asg); diff --git a/swad_banner.c b/swad_banner.c index f77fc4b9..2a8c4966 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -324,8 +324,8 @@ static void Ban_GetListBanners (struct Ban_Banners *Banners, row = mysql_fetch_row (*mysql_res); /* Get banner code (row[0]) */ - if ((Ban->BanCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of banner."); + if ((Ban->BanCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongBannerExit (); /* Get if banner is hidden (row[1]) */ Ban->Hidden = (row[1][0] == 'Y'); @@ -572,8 +572,8 @@ void Ban_RemoveBanner (void) Ban_ResetBanner (&Ban); /***** Get banner code *****/ - if ((Ban.BanCod = Ban_GetParamBanCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of banner is missing."); + if ((Ban.BanCod = Ban_GetParamBanCod ()) <= 0) + Lay_WrongBannerExit (); /***** Get data of the banner from database *****/ Ban_GetDataOfBannerByCod (&Ban); @@ -636,8 +636,8 @@ void Ban_HideBanner (void) static void Ban_ShowOrHideBanner (struct Ban_Banner *Ban,bool Hide) { /***** Get banner code *****/ - if ((Ban->BanCod = Ban_GetParamBanCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of banner is missing."); + if ((Ban->BanCod = Ban_GetParamBanCod ()) <= 0) + Lay_WrongBannerExit (); /***** Get data of the banner from database *****/ Ban_GetDataOfBannerByCod (Ban); @@ -723,8 +723,8 @@ static void Ban_RenameBanner (struct Ban_Banner *Ban, /***** Get parameters from form *****/ /* Get the code of the banner */ - if ((Ban->BanCod = Ban_GetParamBanCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of banner is missing."); + if ((Ban->BanCod = Ban_GetParamBanCod ()) <= 0) + Lay_WrongBannerExit (); /* Get the new name for the banner */ Par_GetParToText (ParamName,NewBanName,MaxBytes); @@ -815,8 +815,8 @@ void Ban_ChangeBannerImg (void) /***** Get parameters from form *****/ /* Get the code of the banner */ - if ((Ban.BanCod = Ban_GetParamBanCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of banner is missing."); + if ((Ban.BanCod = Ban_GetParamBanCod ()) <= 0) + Lay_WrongBannerExit (); /* Get the new WWW for the banner */ Par_GetParToText ("Img",NewImg,Ban_MAX_BYTES_IMAGE); @@ -866,8 +866,8 @@ void Ban_ChangeBannerWWW (void) /***** Get parameters from form *****/ /* Get the code of the banner */ - if ((Ban.BanCod = Ban_GetParamBanCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of banner is missing."); + if ((Ban.BanCod = Ban_GetParamBanCod ()) <= 0) + Lay_WrongBannerExit (); /* Get the new WWW for the banner */ Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW); @@ -1155,8 +1155,8 @@ void Ban_ClickOnBanner (void) struct Ban_Banner Ban; /***** Get banner code *****/ - if ((Ban.BanCod = Ban_GetParamBanCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of banner is missing."); + if ((Ban.BanCod = Ban_GetParamBanCod ()) <= 0) + Lay_WrongBannerExit (); /***** Get data of the banner from database *****/ Ban_GetDataOfBannerByCod (&Ban); diff --git a/swad_building.c b/swad_building.c index ee314fcf..a9d6b71c 100644 --- a/swad_building.c +++ b/swad_building.c @@ -368,8 +368,8 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings, row = mysql_fetch_row (mysql_res); /* Get building code (row[0]) */ - if ((Building->BldCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of building."); + if ((Building->BldCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongBuildingExit (); /* Get the short name of the building (row[1]) */ Str_Copy (Building->ShrtName,row[1],sizeof (Building->ShrtName) - 1); @@ -551,8 +551,8 @@ void Bld_RemoveBuilding (void) Bld_EditingBuildingConstructor (); /***** Get building code *****/ - if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of building is missing."); + if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) <= 0) + Lay_WrongBuildingExit (); /***** Get data of the building from database *****/ Bld_GetDataOfBuildingByCod (Bld_EditingBuilding); @@ -648,8 +648,8 @@ static void Bld_RenameBuilding (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Get parameters from form *****/ /* Get the code of the building */ - if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of building is missing."); + if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) <= 0) + Lay_WrongBuildingExit (); /* Get the new name for the building */ Par_GetParToText (ParamName,NewClaName,MaxBytes); @@ -741,8 +741,8 @@ void Bld_ChangeBuildingLocation (void) /***** Get parameters from form *****/ /* Get the code of the building */ - if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of building is missing."); + if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) <= 0) + Lay_WrongBuildingExit (); /* Get the new location for the building */ Par_GetParToText ("Location",NewLocation,Bld_MAX_BYTES_LOCATION); @@ -942,7 +942,7 @@ static void Bld_EditingBuildingConstructor (void) { /***** Pointer must be NULL *****/ if (Bld_EditingBuilding != NULL) - Lay_ShowErrorAndExit ("Error initializing building."); + Lay_WrongBuildingExit (); /***** Allocate memory for building *****/ if ((Bld_EditingBuilding = malloc (sizeof (*Bld_EditingBuilding))) == NULL) diff --git a/swad_changelog.h b/swad_changelog.h index 063ba38b..2d19c007 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -600,13 +600,14 @@ TODO: Salvador Romero Cort TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria. */ -#define Log_PLATFORM_VERSION "SWAD 20.67.1 (2021-04-24)" +#define Log_PLATFORM_VERSION "SWAD 20.67.2 (2021-04-25)" #define CSS_FILE "swad20.45.css" #define JS_FILE "swad20.6.2.js" /* TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams + Version 20.67.2: Apr 25, 2021 Code refactoring in error messages. (309482 lines) Version 20.67.1: Apr 24, 2021 Code refactoring in error messages. (309415 lines) Version 20.67: Apr 24, 2021 Bug fixing and code optimizations related to user's roles. (309356 lines) Version 20.66.5: Apr 23, 2021 Including missing head files. diff --git a/swad_degree.c b/swad_degree.c index 1b5bd7b4..8dc5662d 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -904,7 +904,7 @@ static void Deg_ListOneDegreeForSeeing (struct Deg_Degree *Deg,unsigned NumDeg) /***** Get data of type of degree of this degree *****/ DegTyp.DegTypCod = Deg->DegTypCod; if (!DT_GetDataOfDegreeTypeByCod (&DegTyp)) - Lay_ShowErrorAndExit ("Code of type of degree not found."); + Lay_WrongDegTypExit (); if (Deg->Status & Deg_STATUS_BIT_PENDING) { diff --git a/swad_degree_type.c b/swad_degree_type.c index 0bffb4da..89f82eb5 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -718,8 +718,8 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order) row = mysql_fetch_row (mysql_res); /* Get degree type code (row[0]) */ - if ((Gbl.DegTypes.Lst[NumTyp].DegTypCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of type of degree."); + if ((Gbl.DegTypes.Lst[NumTyp].DegTypCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongDegTypExit (); /* Get degree type name (row[1]) */ Str_Copy (Gbl.DegTypes.Lst[NumTyp].DegTypName,row[1], @@ -804,7 +804,7 @@ void DT_RemoveDegreeType (void) /***** Get data of the degree type from database *****/ if (!DT_GetDataOfDegreeTypeByCod (DT_EditingDegTyp)) - Lay_ShowErrorAndExit ("Code of type of degree not found."); + Lay_WrongDegTypExit (); /***** Check if this degree type has degrees *****/ if (DT_EditingDegTyp->NumDegs) // Degree type has degrees => don't remove @@ -842,7 +842,7 @@ long DT_GetAndCheckParamOtherDegTypCod (long MinCodAllowed) /***** Get and check parameter with code of degree type *****/ if ((DegTypCod = Par_GetParToLong ("OthDegTypCod")) < MinCodAllowed) - Lay_ShowErrorAndExit ("Code of degree type is missing or invalid."); + Lay_WrongDegTypExit (); return DegTypCod; } @@ -960,7 +960,7 @@ void DT_RenameDegreeType (void) /***** Get from the database the old name of the degree type *****/ if (!DT_GetDataOfDegreeTypeByCod (DT_EditingDegTyp)) - Lay_ShowErrorAndExit ("Code of type of degree not found."); + Lay_WrongDegTypExit (); /***** Check if new name is empty *****/ if (NewNameDegTyp[0]) @@ -1045,7 +1045,7 @@ static void DT_EditingDegreeTypeConstructor (void) { /***** Pointer must be NULL *****/ if (DT_EditingDegTyp != NULL) - Lay_ShowErrorAndExit ("Error initializing degree type."); + Lay_WrongDegTypExit (); /***** Allocate memory for degree type *****/ if ((DT_EditingDegTyp = malloc (sizeof (*DT_EditingDegTyp))) == NULL) diff --git a/swad_exam.c b/swad_exam.c index 871c9ae1..fe4a1885 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -1745,9 +1745,8 @@ unsigned Exa_GetParamQstInd (void) { long QstInd; - QstInd = Par_GetParToLong ("QstInd"); - if (QstInd < 0) - Lay_ShowErrorAndExit ("Wrong question index."); + if ((QstInd = Par_GetParToLong ("QstInd")) <= 0) + Lay_WrongQuestionIndexExit (); return (unsigned) QstInd; } @@ -1769,7 +1768,7 @@ long Exa_GetQstCodFromQstInd (long ExaCod,unsigned QstInd) ExaCod, QstInd); if (QstCod <= 0) - Lay_ShowErrorAndExit ("Error: wrong question index."); + Lay_WrongQuestionIndexExit (); return QstCod; } diff --git a/swad_exam_print.c b/swad_exam_print.c index 335e4bdb..878bd751 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -556,7 +556,7 @@ static void ExaPrn_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *Printed else ErrorInIndex = true; if (ErrorInIndex) - Lay_ShowErrorAndExit ("Wrong index of answer."); + Lay_WrongAnswerIndexExit (); if (NumOpt == 0) snprintf (StrInd,sizeof (StrInd),"%u",Index); diff --git a/swad_exam_set.c b/swad_exam_set.c index 4829b0c2..dc67bb2c 100644 --- a/swad_exam_set.c +++ b/swad_exam_set.c @@ -1414,7 +1414,7 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question) break; case Tst_ANS_FLOAT: if (Question->Answer.NumOptions != 2) - Lay_ShowErrorAndExit ("Wrong answer."); + Lay_WrongAnswerExit (); Question->Answer.FloatingPoint[NumOpt] = Str_GetDoubleFromStr (row[1]); break; case Tst_ANS_TRUE_FALSE: @@ -1426,7 +1426,7 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question) case Tst_ANS_TEXT: /* Check number of options */ if (Question->Answer.NumOptions > Tst_MAX_OPTIONS_PER_QUESTION) - Lay_ShowErrorAndExit ("Wrong answer."); + Lay_WrongAnswerExit (); /* Allocate space for text and feedback */ if (!Tst_AllocateTextChoiceAnswer (Question,NumOpt)) diff --git a/swad_game.c b/swad_game.c index 7fe671dc..b4d82f63 100644 --- a/swad_game.c +++ b/swad_game.c @@ -1801,9 +1801,8 @@ unsigned Gam_GetParamQstInd (void) { long QstInd; - QstInd = Par_GetParToLong ("QstInd"); - if (QstInd < 0) - Lay_ShowErrorAndExit ("Wrong question index."); + if ((QstInd = Par_GetParToLong ("QstInd")) <= 0) + Lay_WrongQuestionIndexExit (); return (unsigned) QstInd; } @@ -1859,7 +1858,7 @@ long Gam_GetQstCodFromQstInd (long GamCod,unsigned QstInd) GamCod, QstInd); if (QstCod <= 0) - Lay_ShowErrorAndExit ("Error: wrong question index."); + Lay_WrongQuestionIndexExit (); return QstCod; } @@ -2414,7 +2413,7 @@ void Gam_MoveUpQst (void) /* Indexes of questions to be exchanged */ QstIndTop = Gam_GetPrevQuestionIndexInGame (Game.GamCod,QstIndBottom); if (!QstIndTop) - Lay_ShowErrorAndExit ("Wrong index of question."); + Lay_WrongQuestionIndexExit (); /* Exchange questions */ Gam_ExchangeQuestions (Game.GamCod,QstIndTop,QstIndBottom); @@ -2468,7 +2467,7 @@ void Gam_MoveDownQst (void) /* Indexes of questions to be exchanged */ QstIndBottom = Gam_GetNextQuestionIndexInGame (Game.GamCod,QstIndTop); if (!QstIndBottom) - Lay_ShowErrorAndExit ("Wrong index of question."); + Lay_WrongQuestionIndexExit (); /* Exchange questions */ Gam_ExchangeQuestions (Game.GamCod,QstIndTop,QstIndBottom); diff --git a/swad_group.c b/swad_group.c index 7f312dfe..2fb03477 100644 --- a/swad_group.c +++ b/swad_group.c @@ -2840,8 +2840,8 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes) row = mysql_fetch_row (mysql_res); /* Get group type code (row[0]) */ - if ((Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong type of group."); + if ((Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongGrpTypExit (); /* Get group type name (row[1]) */ Str_Copy (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName,row[1], @@ -2972,8 +2972,8 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes) row = mysql_fetch_row (mysql_res); /* Get group code (row[0]) */ - if ((Grp->GrpCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of group."); + if ((Grp->GrpCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongGroupExit (); /* Get group name (row[1]) */ Str_Copy (Grp->GrpName,row[1],sizeof (Grp->GrpName) - 1); @@ -3123,7 +3123,7 @@ static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp) " WHERE CrsCod=%ld" " AND GrpTypCod=%ld", Gbl.Hierarchy.Crs.CrsCod,GrpTyp->GrpTypCod) != 1) - Lay_ShowErrorAndExit ("Error when getting type of group."); + Lay_WrongGrpTypExit (); /***** Get some data of group type *****/ row = mysql_fetch_row (mysql_res); @@ -3215,7 +3215,7 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat) /* Get the code of the group type (row[0]) */ if ((GrpDat->GrpTypCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) - Lay_ShowErrorAndExit ("Wrong code of type of group."); + Lay_WrongGrpTypExit (); /* Get the code of the course (row[1]) */ if ((GrpDat->CrsCod = Str_ConvertStrCodToLongCod (row[1])) <= 0) @@ -3270,7 +3270,7 @@ static long Grp_GetTypeOfGroupOfAGroup (long GrpCod) " WHERE GrpCod=%ld", GrpCod); if (GrpTypCod <= 0) - Lay_ShowErrorAndExit ("Error when getting group."); + Lay_WrongGrpTypExit (); return GrpTypCod; } @@ -3649,8 +3649,8 @@ static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod, NumGrp < LstGrps->NumGrps; NumGrp++) /* Get the code of group (row[0]) */ - if ((LstGrps->GrpCods[NumGrp] = DB_GetNextCode (mysql_res)) < 0) - Lay_ShowErrorAndExit ("Wrong code of group."); + if ((LstGrps->GrpCods[NumGrp] = DB_GetNextCode (mysql_res)) <= 0) + Lay_WrongGroupExit (); } /***** Free structure that stores the query result *****/ @@ -3694,8 +3694,8 @@ void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps) NumGrp < LstGrps->NumGrps; NumGrp++) /* Get the code of group */ - if ((LstGrps->GrpCods[NumGrp] = DB_GetNextCode (mysql_res)) < 0) - Lay_ShowErrorAndExit ("Wrong code of group."); + if ((LstGrps->GrpCods[NumGrp] = DB_GetNextCode (mysql_res)) <= 0) + Lay_WrongGroupExit (); } /***** Free structure that stores the query result *****/ @@ -3991,8 +3991,8 @@ void Grp_ReqRemGroupType (void) unsigned NumGrps; /***** Get the code of the group type *****/ - if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) < 0) - Lay_ShowErrorAndExit ("Code of group is missing."); + if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) + Lay_WrongGrpTypExit (); /***** Check if this group type has groups *****/ if ((NumGrps = Grp_CountNumGrpsInThisCrsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod))) // Group type has groups ==> Ask for confirmation @@ -4008,8 +4008,8 @@ void Grp_ReqRemGroupType (void) void Grp_ReqRemGroup (void) { /***** Get group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of group is missing."); + if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) + Lay_WrongGroupExit (); /***** Confirm removing *****/ Grp_AskConfirmRemGrp (); @@ -4105,8 +4105,8 @@ 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) - Lay_ShowErrorAndExit ("Code of type of group is missing."); + if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) + Lay_WrongGrpTypExit (); /***** Remove group type and its groups *****/ Grp_RemoveGroupTypeCompletely (); @@ -4119,8 +4119,8 @@ void Grp_RemoveGroupType (void) void Grp_RemoveGroup (void) { /***** Get param with group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of group is missing."); + if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) + Lay_WrongGroupExit (); /***** Remove group *****/ Grp_RemoveGroupCompletely (); @@ -4261,8 +4261,8 @@ void Grp_OpenGroup (void) char AlertTxt[256 + Grp_MAX_BYTES_GROUP_NAME]; /***** Get group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1) - Lay_ShowErrorAndExit ("Code of group is missing."); + if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) + Lay_WrongGroupExit (); /***** Get group data from database *****/ GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod; @@ -4296,8 +4296,8 @@ void Grp_CloseGroup (void) char AlertTxt[256 + Grp_MAX_BYTES_GROUP_NAME]; /***** Get group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1) - Lay_ShowErrorAndExit ("Code of group is missing."); + if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) + Lay_WrongGroupExit (); /***** Get group data from database *****/ GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod; @@ -4331,8 +4331,8 @@ void Grp_EnableFileZonesGrp (void) char AlertTxt[256 + Grp_MAX_BYTES_GROUP_NAME]; /***** Get group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1) - Lay_ShowErrorAndExit ("Code of group is missing."); + if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) + Lay_WrongGroupExit (); /***** Get group data from database *****/ GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod; @@ -4367,8 +4367,8 @@ void Grp_DisableFileZonesGrp (void) char AlertTxt[256 + Grp_MAX_BYTES_GROUP_NAME]; /***** Get group code *****/ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1) - Lay_ShowErrorAndExit ("Code of group is missing."); + if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) + Lay_WrongGroupExit (); /***** Get group data from database *****/ GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod; @@ -4407,8 +4407,8 @@ void Grp_ChangeGroupType (void) /***** Get parameters from form *****/ /* Get group code */ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of group is missing."); + if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) + Lay_WrongGroupExit (); /* Get the new group type */ NewGrpTypCod = Grp_GetParamGrpTypCod (); @@ -4461,8 +4461,8 @@ void Grp_ChangeGroupRoom (void) /***** Get parameters from form *****/ /* Get group code */ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of group is missing."); + if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) + Lay_WrongGroupExit (); /* Get the new room */ NewRooCod = Roo_GetParamRooCod (); @@ -4506,8 +4506,8 @@ 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) - Lay_ShowErrorAndExit ("Code of type of group is missing."); + if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) + Lay_WrongGrpTypExit (); /* Get the new type of enrolment (mandatory or voluntaria) of this type of group */ NewMandatoryEnrolment = Par_GetParToBool ("MandatoryEnrolment"); @@ -4564,8 +4564,8 @@ 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) - Lay_ShowErrorAndExit ("Code of type of group is missing."); + if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) + Lay_WrongGrpTypExit (); /* Get the new type of enrolment (single or multiple) of this type of group */ NewMultipleEnrolment = Par_GetParToBool ("MultipleEnrolment"); @@ -4616,8 +4616,8 @@ 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) - Lay_ShowErrorAndExit ("Code of type of group is missing."); + if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) + Lay_WrongGrpTypExit (); /***** Get from the database the data of this type of group *****/ Grp_GetDataOfGroupTypeByCod (&Gbl.Crs.Grps.GrpTyp); @@ -4662,8 +4662,8 @@ void Grp_ChangeMaxStdsGrp (void) /***** Get parameters of the form *****/ /* Get group code */ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1) - Lay_ShowErrorAndExit ("Code of group is missing."); + if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) + Lay_WrongGroupExit (); /* Get the new maximum number of students of the group */ NewMaxStds = (unsigned) @@ -4757,8 +4757,8 @@ void Grp_RenameGroupType (void) /***** Get parameters from form *****/ /* Get the code of the group type */ - if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) < 0) - Lay_ShowErrorAndExit ("Code of type of group is missing."); + if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0) + Lay_WrongGrpTypExit (); /* Get the new name for the group type */ Par_GetParToText ("GrpTypName",NewNameGrpTyp,Grp_MAX_BYTES_GROUP_TYPE_NAME); @@ -4836,8 +4836,8 @@ void Grp_RenameGroup (void) /***** Get parameters from form *****/ /* Get the code of the group */ - if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of group is missing."); + if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0) + Lay_WrongGroupExit (); /* Get the new name for the group */ Par_GetParToText ("GrpName",NewNameGrp,Grp_MAX_BYTES_GROUP_NAME); diff --git a/swad_layout.c b/swad_layout.c index d2e06eb5..f56d4f73 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1407,6 +1407,11 @@ void Lay_WrongCenterExit (void) Lay_ShowErrorAndExit ("Wrong center."); } +void Lay_WrongDegTypExit (void) + { + Lay_ShowErrorAndExit ("Wrong degree type."); + } + void Lay_WrongDegreeExit (void) { Lay_ShowErrorAndExit ("Wrong degree."); @@ -1426,6 +1431,20 @@ void Lay_WrongOrderExit (void) Lay_ShowErrorAndExit ("Wrong order."); } +/*****************************************************************************/ +/********* Write error message and exit when wrong group type/group **********/ +/*****************************************************************************/ + +void Lay_WrongGrpTypExit (void) + { + Lay_ShowErrorAndExit ("Wrong group type."); + } + +void Lay_WrongGroupExit (void) + { + Lay_ShowErrorAndExit ("Wrong group."); + } + /*****************************************************************************/ /************* Write error message and exit when wrong order *****************/ /*****************************************************************************/ @@ -1435,6 +1454,33 @@ void Lay_WrongTypeOfViewExit (void) Lay_ShowErrorAndExit ("Wrong type of view."); } +/*****************************************************************************/ +/************* Write error message and exit when wrong banner ****************/ +/*****************************************************************************/ + +void Lay_WrongBannerExit (void) + { + Lay_ShowErrorAndExit ("Wrong banner."); + } + +/*****************************************************************************/ +/************ Write error message and exit when wrong building ***************/ +/*****************************************************************************/ + +void Lay_WrongBuildingExit (void) + { + Lay_ShowErrorAndExit ("Wrong building."); + } + +/*****************************************************************************/ +/*********** Write error message and exit when wrong assignment **************/ +/*****************************************************************************/ + +void Lay_WrongAssignmentExit (void) + { + Lay_ShowErrorAndExit ("Wrong assignment."); + } + /*****************************************************************************/ /************* Write error message and exit when wrong project ***************/ /*****************************************************************************/ @@ -1480,6 +1526,25 @@ void Lay_WrongQuestionExit (void) Lay_ShowErrorAndExit ("Wrong question."); } +void Lay_WrongQuestionIndexExit (void) + { + Lay_ShowErrorAndExit ("Wrong question index."); + } + +/*****************************************************************************/ +/************** Write error message and exit when wrong answer ***************/ +/*****************************************************************************/ + +void Lay_WrongAnswerExit (void) + { + Lay_ShowErrorAndExit ("Wrong answer."); + } + +void Lay_WrongAnswerIndexExit (void) + { + Lay_ShowErrorAndExit ("Wrong answer index."); + } + /*****************************************************************************/ /*********** Write error message and exit when wrong exam session ************/ /*****************************************************************************/ @@ -1503,6 +1568,15 @@ void Lay_WrongMatchExit (void) Lay_ShowErrorAndExit ("Wrong match."); } +/*****************************************************************************/ +/************** Write error message and exit when wrong survey ***************/ +/*****************************************************************************/ + +void Lay_WrongSurveyExit (void) + { + Lay_ShowErrorAndExit ("Wrong survey."); + } + /*****************************************************************************/ /*** Write error message and exit when wrong parameter "who" (which users) ***/ /*****************************************************************************/ diff --git a/swad_layout.h b/swad_layout.h index 4ef32ef7..6f554067 100644 --- a/swad_layout.h +++ b/swad_layout.h @@ -74,18 +74,28 @@ void Lay_WrongScopeExit (void); void Lay_WrongCountrExit (void); void Lay_WrongInstitExit (void); void Lay_WrongCenterExit (void); +void Lay_WrongDegTypExit (void); void Lay_WrongDegreeExit (void); void Lay_WrongCourseExit (void); void Lay_WrongOrderExit (void); +void Lay_WrongGrpTypExit (void); +void Lay_WrongGroupExit (void); void Lay_WrongTypeOfViewExit (void); +void Lay_WrongBannerExit (void); +void Lay_WrongBuildingExit (void); +void Lay_WrongAssignmentExit (void); void Lay_WrongProjectExit (void); void Lay_WrongCallForExamExit (void); void Lay_WrongExamExit (void); void Lay_WrongSetExit (void); void Lay_WrongQuestionExit (void); +void Lay_WrongQuestionIndexExit (void); +void Lay_WrongAnswerExit (void); +void Lay_WrongAnswerIndexExit (void); void Lay_WrongExamSessionExit (void); void Lay_WrongGameExit (void); void Lay_WrongMatchExit (void); +void Lay_WrongSurveyExit (void); void Lay_WrongWhoExit (void); void Lay_WrongEventExit (void); void Lay_WrongUserExit (void); diff --git a/swad_survey.c b/swad_survey.c index e9041ed1..3285d5fc 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -433,8 +433,8 @@ void Svy_SeeOneSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Svy.SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /***** Show survey *****/ Svy_ShowOneSurvey (&Surveys,Svy.SvyCod,true); @@ -650,7 +650,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, switch (Svy.Scope) { case Hie_Lvl_UNK: // Unknown - Lay_ShowErrorAndExit ("Wrong survey scope."); + Lay_WrongScopeExit (); break; case Hie_Lvl_SYS: // System HTM_Txt (Cfg_PLATFORM_SHORT_NAME); @@ -1068,7 +1068,7 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys) NumSvy++) /* Get next survey code */ if ((Surveys->LstSvyCods[NumSvy] = DB_GetNextCode (mysql_res)) < 0) - Lay_ShowErrorAndExit ("Error: wrong survey code."); + Lay_WrongSurveyExit (); } else Surveys->Num = 0; @@ -1573,8 +1573,8 @@ void Svy_AskRemSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Svy.SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Svy); @@ -1612,8 +1612,8 @@ void Svy_RemoveSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Svy.SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Svy); @@ -1680,8 +1680,8 @@ void Svy_AskResetSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Svy.SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Svy); @@ -1733,8 +1733,8 @@ void Svy_ResetSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Svy.SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Svy); @@ -1782,8 +1782,8 @@ void Svy_HideSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Svy.SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Svy); @@ -1819,8 +1819,8 @@ void Svy_UnhideSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Svy.SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Svy); @@ -2685,8 +2685,8 @@ void Svy_RequestEditQuestion (void) Txt[0] = '\0'; /***** Get survey code *****/ - if ((SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /* Get the question code */ SvyQst.QstCod = Svy_GetParamQstCod (); @@ -2747,7 +2747,7 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys, /* Get question index inside survey (row[0]) */ if (sscanf (row[0],"%u",&(SvyQst->QstInd)) != 1) - Lay_ShowErrorAndExit ("Error: wrong question index."); + Lay_WrongQuestionIndexExit (); /* Get the type of answer (row[1]) */ SvyQst->AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[1]); @@ -3083,8 +3083,8 @@ void Svy_ReceiveQst (void) /***** Get parameters from form *****/ /* Get survey code */ - if ((SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /* Get question code */ SvyQst.QstCod = Svy_GetParamQstCod (); @@ -3363,47 +3363,47 @@ static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys, /* row[0] holds the code of the question */ if (sscanf (row[0],"%ld",&(SvyQst.QstCod)) != 1) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); HTM_TR_Begin (NULL); - if (Svy->Status.ICanEdit) - { - HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); + if (Svy->Status.ICanEdit) + { + HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); - /* Initialize context */ - Surveys->SvyCod = Svy->SvyCod; - Surveys->QstCod = SvyQst.QstCod; + /* Initialize context */ + Surveys->SvyCod = Svy->SvyCod; + Surveys->QstCod = SvyQst.QstCod; - /* Write icon to remove the question */ - Ico_PutContextualIconToRemove (ActReqRemSvyQst,NULL, - Svy_PutParamsToEditQuestion,Surveys); + /* Write icon to remove the question */ + Ico_PutContextualIconToRemove (ActReqRemSvyQst,NULL, + Svy_PutParamsToEditQuestion,Surveys); - /* Write icon to edit the question */ - Ico_PutContextualIconToEdit (ActEdiOneSvyQst,NULL, - Svy_PutParamsToEditQuestion,Surveys); + /* Write icon to edit the question */ + Ico_PutContextualIconToEdit (ActEdiOneSvyQst,NULL, + Svy_PutParamsToEditQuestion,Surveys); - HTM_TD_End (); - } + HTM_TD_End (); + } - /* Write index of question inside survey (row[1]) */ - if (sscanf (row[1],"%u",&(SvyQst.QstInd)) != 1) - Lay_ShowErrorAndExit ("Error: wrong question index."); - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - HTM_Unsigned (SvyQst.QstInd + 1); - HTM_TD_End (); + /* Write index of question inside survey (row[1]) */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + if (sscanf (row[1],"%u",&(SvyQst.QstInd)) != 1) + Lay_WrongQuestionIndexExit (); + HTM_Unsigned (SvyQst.QstInd + 1); + HTM_TD_End (); - /* Write the question type (row[2]) */ - SvyQst.AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[2]); - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - HTM_Txt (Txt_SURVEY_STR_ANSWER_TYPES[SvyQst.AnswerType]); - HTM_TD_End (); + /* Write the question type (row[2]) */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + SvyQst.AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[2]); + HTM_Txt (Txt_SURVEY_STR_ANSWER_TYPES[SvyQst.AnswerType]); + HTM_TD_End (); - /* Write the stem (row[3]) and the answers of this question */ - HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd); - Svy_WriteQstStem (row[3]); - Svy_WriteAnswersOfAQst (Svy,&SvyQst,PutFormAnswerSurvey); - HTM_TD_End (); + /* Write the stem (row[3]) and the answers of this question */ + HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd); + Svy_WriteQstStem (row[3]); + Svy_WriteAnswersOfAQst (Svy,&SvyQst,PutFormAnswerSurvey); + HTM_TD_End (); HTM_TR_End (); } @@ -3695,8 +3695,8 @@ void Svy_RequestRemoveQst (void) /***** Get parameters from form *****/ /* Get survey code */ - if ((SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /* Get question code */ if ((SvyQst.QstCod = Svy_GetParamQstCod ()) < 0) @@ -3737,11 +3737,11 @@ void Svy_RemoveQst (void) /***** Get parameters from form *****/ /* Get survey code */ - if ((SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /* Get question code */ - if ((SvyQst.QstCod = Svy_GetParamQstCod ()) < 0) + if ((SvyQst.QstCod = Svy_GetParamQstCod ()) <= 0) Lay_WrongQuestionExit (); /* Get question index */ @@ -3790,8 +3790,8 @@ void Svy_ReceiveSurveyAnswers (void) Svy_ResetSurveys (&Surveys); /***** Get survey code *****/ - if ((Svy.SvyCod = Svy_GetParamSvyCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of survey is missing."); + if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) + Lay_WrongSurveyExit (); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Svy);