diff --git a/swad_account.c b/swad_account.c index 91ac89fd4..d5ff22b74 100644 --- a/swad_account.c +++ b/swad_account.c @@ -736,7 +736,7 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount) char PathRelUsr[PATH_MAX + 1]; unsigned NumID; - /***** Check if user's code is initialized *****/ + /***** Trivial check: user's code should be <= 0 *****/ if (UsrDat->UsrCod > 0) Lay_ShowErrorAndExit ("Can not create new user."); diff --git a/swad_agenda.c b/swad_agenda.c index 979738794..d22c40363 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -1178,7 +1178,7 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda, NumEvent++) /* Get next event code */ if ((Agenda->LstAgdCods[NumEvent] = DB_GetNextCode (mysql_res)) < 0) - Lay_ShowErrorAndExit ("Error: wrong event code."); + Lay_WrongEventExit (); } /***** Free structure that stores the query result *****/ @@ -1326,8 +1326,8 @@ void Agd_AskRemEvent (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of event is missing."); + if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) + Lay_WrongEventExit (); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1362,8 +1362,8 @@ void Agd_RemoveEvent (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of event is missing."); + if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) + Lay_WrongEventExit (); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1401,8 +1401,8 @@ void Agd_HideEvent (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of event is missing."); + if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) + Lay_WrongEventExit (); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1437,8 +1437,8 @@ void Agd_UnhideEvent (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of event is missing."); + if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) + Lay_WrongEventExit (); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1474,8 +1474,8 @@ void Agd_MakeEventPrivate (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of event is missing."); + if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) + Lay_WrongEventExit (); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1515,8 +1515,8 @@ void Agd_MakeEventPublic (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get event code *****/ - if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of event is missing."); + if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0) + Lay_WrongEventExit (); /***** Get data of the event from database *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; diff --git a/swad_attendance.c b/swad_attendance.c index 5d13e2d61..07b3d29b1 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -720,7 +720,7 @@ static void Att_GetListAttEvents (struct Att_Events *Events, { /* Get next attendance event code */ if ((Events->Lst[NumAttEvent].AttCod = DB_GetNextCode (mysql_res)) < 0) - Lay_ShowErrorAndExit ("Error: wrong attendance event code."); + Lay_WrongEventExit (); } } @@ -739,10 +739,10 @@ static void Att_GetDataOfAttEventByCodAndCheckCrs (struct Att_Event *Event) if (Att_GetDataOfAttEventByCod (Event)) { if (Event->CrsCod != Gbl.Hierarchy.Crs.CrsCod) - Lay_ShowErrorAndExit ("Attendance event does not belong to current course."); + Lay_WrongEventExit (); } else // Attendance event not found - Lay_ShowErrorAndExit ("Error when getting attendance event."); + Lay_WrongEventExit (); } /*****************************************************************************/ @@ -919,8 +919,8 @@ void Att_AskRemAttEvent (void) Events.CurrentPage = Pag_GetParamPagNum (Pag_ATT_EVENTS); /***** Get attendance event code *****/ - if ((Event.AttCod = Att_GetParamAttCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of attendance event is missing."); + if ((Event.AttCod = Att_GetParamAttCod ()) < 0) + Lay_WrongEventExit (); /***** Get data of the attendance event from database *****/ Att_GetDataOfAttEventByCodAndCheckCrs (&Event); @@ -954,8 +954,8 @@ void Att_GetAndRemAttEvent (void) struct Att_Event Event; /***** Get attendance event code *****/ - if ((Event.AttCod = Att_GetParamAttCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of attendance event is missing."); + if ((Event.AttCod = Att_GetParamAttCod ()) < 0) + Lay_WrongEventExit (); /***** Get data of the attendance event from database *****/ // Inside this function, the course is checked to be the current one @@ -997,8 +997,8 @@ void Att_HideAttEvent (void) struct Att_Event Event; /***** Get attendance event code *****/ - if ((Event.AttCod = Att_GetParamAttCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of attendance event is missing."); + if ((Event.AttCod = Att_GetParamAttCod ()) < 0) + Lay_WrongEventExit (); /***** Get data of the attendance event from database *****/ Att_GetDataOfAttEventByCodAndCheckCrs (&Event); @@ -1025,8 +1025,8 @@ void Att_ShowAttEvent (void) struct Att_Event Event; /***** Get attendance event code *****/ - if ((Event.AttCod = Att_GetParamAttCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of attendance event is missing."); + if ((Event.AttCod = Att_GetParamAttCod ()) < 0) + Lay_WrongEventExit (); /***** Get data of the attendance event from database *****/ Att_GetDataOfAttEventByCodAndCheckCrs (&Event); @@ -1861,8 +1861,8 @@ void Att_SeeOneAttEvent (void) Att_ResetEvents (&Events); /***** Get attendance event code *****/ - if ((Events.AttCod = Att_GetParamAttCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of attendance event is missing."); + if ((Events.AttCod = Att_GetParamAttCod ()) < 0) + Lay_WrongEventExit (); /***** Show event *****/ Att_ShowEvent (&Events); @@ -2306,8 +2306,8 @@ void Att_RegisterMeAsStdInAttEvent (void) Att_ResetEvents (&Events); /***** Get attendance event code *****/ - if ((Event.AttCod = Att_GetParamAttCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of attendance event is missing."); + if ((Event.AttCod = Att_GetParamAttCod ()) < 0) + Lay_WrongEventExit (); Att_GetDataOfAttEventByCodAndCheckCrs (&Event); // This checks that event belong to current course if (Event.Open) @@ -2371,8 +2371,8 @@ void Att_RegisterStudentsInAttEvent (void) Att_ResetEvents (&Events); /***** Get attendance event code *****/ - if ((Event.AttCod = Att_GetParamAttCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of attendance event is missing."); + if ((Event.AttCod = Att_GetParamAttCod ()) < 0) + Lay_WrongEventExit (); Att_GetDataOfAttEventByCodAndCheckCrs (&Event); // This checks that event belong to current course /***** Get groups selected *****/ diff --git a/swad_center.c b/swad_center.c index e5d27a459..6d860634e 100644 --- a/swad_center.c +++ b/swad_center.c @@ -750,7 +750,7 @@ static void Ctr_GetDataOfCenterFromRow (struct Ctr_Center *Ctr,MYSQL_ROW row) { /***** Get center code (row[0]) *****/ if ((Ctr->CtrCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) - Lay_ShowErrorAndExit ("Wrong code of center."); + Lay_WrongCenterExit (); /***** Get institution code (row[1]) *****/ Ctr->InsCod = Str_ConvertStrCodToLongCod (row[1]); @@ -881,7 +881,7 @@ void Ctr_WriteSelectorOfCenter (void) /* Get center code (row[0]) */ if ((CtrCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of center."); + Lay_WrongCenterExit (); /* Write option */ HTM_OPTION (HTM_Type_LONG,&CtrCod, @@ -1185,7 +1185,7 @@ long Ctr_GetAndCheckParamOtherCtrCod (long MinCodAllowed) /***** Get and check parameter with code of center *****/ if ((CtrCod = Par_GetParToLong ("OthCtrCod")) < MinCodAllowed) - Lay_ShowErrorAndExit ("Code of center is missing or invalid."); + Lay_WrongCenterExit (); return CtrCod; } @@ -2283,7 +2283,7 @@ static void Ctr_EditingCenterConstructor (void) { /***** Pointer must be NULL *****/ if (Ctr_EditingCtr != NULL) - Lay_ShowErrorAndExit ("Error initializing center."); + Lay_WrongCenterExit (); /***** Allocate memory for center *****/ if ((Ctr_EditingCtr = malloc (sizeof (*Ctr_EditingCtr))) == NULL) diff --git a/swad_changelog.h b/swad_changelog.h index b22ea026c..063ba38b6 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 (2021-04-24)" +#define Log_PLATFORM_VERSION "SWAD 20.67.1 (2021-04-24)" #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.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. Fixed bug getting my courses. (309123 lines) diff --git a/swad_chat.c b/swad_chat.c index 8f211687e..1991a279d 100644 --- a/swad_chat.c +++ b/swad_chat.c @@ -176,7 +176,7 @@ void Cht_ShowListOfAvailableChatRooms (void) /* Get data of this degree */ Deg.DegCod = Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod; if (!Deg_GetDataOfDegreeByCod (&Deg)) - Lay_ShowErrorAndExit ("Degree not found."); + Lay_WrongDegreeExit (); /* Link to the room of this degree */ IsLastItemInLevel[1] = (NumMyDeg == Gbl.Usrs.Me.MyDegs.Num - 1); diff --git a/swad_country.c b/swad_country.c index c86e4db72..a58028751 100644 --- a/swad_country.c +++ b/swad_country.c @@ -786,7 +786,7 @@ void Cty_GetBasicListOfCountries (void) /* Get numerical country code (row[0]) */ if ((Cty->CtyCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of country."); + Lay_WrongCountrExit (); /* Get Alpha-2 country code (row[1]) */ Str_Copy (Cty->Alpha2,row[1],sizeof (Cty->Alpha2) - 1); @@ -912,7 +912,7 @@ void Cty_GetFullListOfCountries (void) /* Get numerical country code (row[0]) */ if ((Cty->CtyCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of country."); + Lay_WrongCountrExit (); /* Get Alpha-2 country code (row[1]) */ Str_Copy (Cty->Alpha2,row[1],sizeof (Cty->Alpha2) - 1); @@ -981,7 +981,7 @@ void Cty_WriteSelectorOfCountry (void) /* Get country code (row[0]) */ if ((CtyCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of country."); + Lay_WrongCountrExit (); /* Write option */ HTM_OPTION (HTM_Type_LONG,&CtyCod, @@ -1302,7 +1302,7 @@ long Cty_GetAndCheckParamOtherCtyCod (long MinCodAllowed) /***** Get and check parameter with code of country *****/ if ((CtyCod = Cty_GetParamOtherCtyCod ()) < MinCodAllowed) - Lay_ShowErrorAndExit ("Code of country is missing or invalid."); + Lay_WrongCountrExit (); return CtyCod; } @@ -2119,7 +2119,7 @@ static void Cty_EditingCountryConstructor (void) /***** Pointer must be NULL *****/ if (Cty_EditingCty != NULL) - Lay_ShowErrorAndExit ("Error initializing country."); + Lay_WrongCountrExit (); /***** Allocate memory for country *****/ if ((Cty_EditingCty = malloc (sizeof (*Cty_EditingCty))) == NULL) diff --git a/swad_course.c b/swad_course.c index c0b49cd38..e52547363 100644 --- a/swad_course.c +++ b/swad_course.c @@ -215,7 +215,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) /***** Get data of this institution *****/ Hie.Cty.CtyCod = Str_ConvertStrCodToLongCod (row[0]); if (!Cty_GetDataOfCountryByCod (&Hie.Cty)) - Lay_ShowErrorAndExit ("Country not found."); + Lay_WrongCountrExit (); /***** Write link to country *****/ Highlight = (Gbl.Hierarchy.Ins.InsCod <= 0 && @@ -249,7 +249,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) /***** Get data of this institution *****/ Hie.Ins.InsCod = Str_ConvertStrCodToLongCod (row[0]); if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins)) - Lay_ShowErrorAndExit ("Institution not found."); + Lay_WrongInstitExit (); /***** Write link to institution *****/ Highlight = (Gbl.Hierarchy.Ctr.CtrCod <= 0 && @@ -283,7 +283,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) /***** Get data of this center *****/ Hie.Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[0]); if (!Ctr_GetDataOfCenterByCod (&Hie.Ctr)) - Lay_ShowErrorAndExit ("Center not found."); + Lay_WrongCenterExit (); /***** Write link to center *****/ Highlight = (Gbl.Hierarchy.Level == Hie_Lvl_CTR && @@ -317,7 +317,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) /***** Get data of this degree *****/ Hie.Deg.DegCod = Str_ConvertStrCodToLongCod (row[0]); if (!Deg_GetDataOfDegreeByCod (&Hie.Deg)) - Lay_ShowErrorAndExit ("Degree not found."); + Lay_WrongDegreeExit (); /***** Write link to degree *****/ Highlight = (Gbl.Hierarchy.Level == Hie_Lvl_DEG && @@ -351,7 +351,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) /***** Get data of this course *****/ Hie.Crs.CrsCod = Str_ConvertStrCodToLongCod (row[0]); if (!Crs_GetDataOfCourseByCod (&Hie.Crs)) - Lay_ShowErrorAndExit ("Course not found."); + Lay_WrongCourseExit (); /***** Write link to course *****/ Highlight = (Gbl.Hierarchy.Level == Hie_Lvl_CRS && @@ -711,7 +711,7 @@ void Crs_WriteSelectorOfCourse (void) /* Get course code (row[0]) */ if ((CrsCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong course."); + Lay_WrongCourseExit (); /* Write option */ HTM_OPTION (HTM_Type_LONG,&CrsCod, @@ -1833,7 +1833,7 @@ static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row) { /***** Get course code (row[0]) *****/ if ((Crs->CrsCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of course."); + Lay_WrongCourseExit (); /***** Get code of degree (row[1]) *****/ Crs->DegCod = Str_ConvertStrCodToLongCod (row[1]); @@ -2619,7 +2619,7 @@ static long Crs_GetAndCheckParamOtherCrsCod (long MinCodAllowed) /***** Get and check parameter with code of course *****/ if ((CrsCod = Par_GetParToLong ("OthCrsCod")) < MinCodAllowed) - Lay_ShowErrorAndExit ("Code of course is missing or invalid."); + Lay_WrongCourseExit (); return CrsCod; } @@ -2826,13 +2826,13 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA /***** Get degree code (row[0]) *****/ if ((Deg.DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of degree."); + Lay_WrongDegreeExit (); if (!Deg_GetDataOfDegreeByCod (&Deg)) - Lay_ShowErrorAndExit ("Degree not found."); + Lay_WrongDegreeExit (); /***** Get course code (row[1]) *****/ if ((CrsCod = Str_ConvertStrCodToLongCod (row[1])) < 0) - Lay_ShowErrorAndExit ("Wrong code of course."); + Lay_WrongCourseExit (); /***** Get number of teachers and students in this course *****/ NumStds = Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,CrsCod,1 << Rol_STD); @@ -3071,7 +3071,7 @@ static void Crs_EditingCourseConstructor (void) { /***** Pointer must be NULL *****/ if (Crs_EditingCrs != NULL) - Lay_ShowErrorAndExit ("Error initializing course."); + Lay_WrongCourseExit (); /***** Allocate memory for course *****/ if ((Crs_EditingCrs = malloc (sizeof (*Crs_EditingCrs))) == NULL) diff --git a/swad_degree.c b/swad_degree.c index 2c8163000..1b5bd7b4d 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -296,7 +296,7 @@ void Deg_WriteSelectorOfDegree (void) /* Get degree code (row[0]) */ if ((DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong degree."); + Lay_WrongDegreeExit (); /* Write option */ HTM_OPTION (HTM_Type_LONG,&DegCod, @@ -1339,7 +1339,7 @@ long Deg_GetAndCheckParamOtherDegCod (long MinCodAllowed) /***** Get and check parameter with code of degree *****/ if ((DegCod = Par_GetParToLong ("OthDegCod")) < MinCodAllowed) - Lay_ShowErrorAndExit ("Code of degree is missing or invalid."); + Lay_WrongDegreeExit (); return DegCod; } @@ -1404,7 +1404,7 @@ static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row) { /***** Get degree code (row[0]) *****/ if ((Deg->DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of degree."); + Lay_WrongDegreeExit (); /***** Get center code (row[1]) *****/ Deg->CtrCod = Str_ConvertStrCodToLongCod (row[1]); @@ -1512,7 +1512,7 @@ void Deg_RemoveDegreeCompletely (long DegCod) { /* Get next course */ if ((CrsCod = DB_GetNextCode (mysql_res)) < 0) - Lay_ShowErrorAndExit ("Wrong code of course."); + Lay_WrongCourseExit (); /* Remove course */ Crs_RemoveCourseCompletely (CrsCod); @@ -2197,7 +2197,7 @@ static void Deg_EditingDegreeConstructor (void) { /***** Pointer must be NULL *****/ if (Deg_EditingDeg != NULL) - Lay_ShowErrorAndExit ("Error initializing degree."); + Lay_WrongDegreeExit (); /***** Allocate memory for degree *****/ if ((Deg_EditingDeg = malloc (sizeof (*Deg_EditingDeg))) == NULL) diff --git a/swad_degree_type.c b/swad_degree_type.c index 5e390b3ed..0bffb4da5 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -921,7 +921,7 @@ static void DT_RemoveDegreeTypeCompletely (long DegTypCod) { /* Get next degree */ if ((DegCod = DB_GetNextCode (mysql_res)) < 0) - Lay_ShowErrorAndExit ("Wrong code of degree."); + Lay_WrongDegreeExit (); /* Remove degree */ Deg_RemoveDegreeCompletely (DegCod); diff --git a/swad_department.c b/swad_department.c index 26a090975..d4419c449 100644 --- a/swad_department.c +++ b/swad_department.c @@ -395,7 +395,7 @@ static void Dpt_GetListDepartments (struct Dpt_Departments *Departments,long Ins /* Get institution code (row[1]) */ if ((Dpt->InsCod = Str_ConvertStrCodToLongCod (row[1])) < 0) - Lay_ShowErrorAndExit ("Wrong code of institution."); + Lay_WrongInstitExit (); /* Get short name (row[2]), full name (row[3]) and URL (row[4]) of the department */ diff --git a/swad_enrolment.c b/swad_enrolment.c index 9a077310a..9df1192bd 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -4348,7 +4348,7 @@ static void Enr_AskIfRemAdm (bool ItsMe,Hie_Lvl_Level_t Scope, Txt_Remove_USER_as_an_administrator); } else - Lay_ShowErrorAndExit ("User doesn't exist."); + Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission (); } /*****************************************************************************/ diff --git a/swad_exam.c b/swad_exam.c index 0017d7f97..871c9ae15 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -863,7 +863,7 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder) /* Get next exam code (row[0]) */ row = mysql_fetch_row (mysql_res); if ((Exams->Lst[NumExam].ExaCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) - Lay_ShowErrorAndExit ("Error: wrong exam code."); + Lay_WrongExamExit (); } } @@ -1130,8 +1130,8 @@ void Exa_RemoveExam (void) Exa_ResetExam (&Exam); /***** Get exam code *****/ - if ((Exam.ExaCod = Exa_GetParamExamCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of exam is missing."); + if ((Exam.ExaCod = Exa_GetParamExamCod ()) <= 0) + Lay_WrongExamExit (); /***** Get data of the exam from database *****/ Exa_GetDataOfExamByCod (&Exam); diff --git a/swad_exam_print.c b/swad_exam_print.c index bbbccb63b..335e4bdb3 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -635,11 +635,11 @@ void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print) /* Get question code (row[0]) */ if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /* Get set code (row[1]) */ if ((Print->PrintedQuestions[NumQst].SetCod = Str_ConvertStrCodToLongCod (row[1])) < 0) - Lay_ShowErrorAndExit ("Wrong code of set."); + Lay_WrongSetExit (); /* Get score (row[2]) */ Str_SetDecimalPointToUS (); // To get the decimal point as a dot diff --git a/swad_exam_session.c b/swad_exam_session.c index 5a3f6ab8c..c16bee1ec 100644 --- a/swad_exam_session.c +++ b/swad_exam_session.c @@ -870,11 +870,11 @@ static void ExaSes_GetSessionDataFromRow (MYSQL_RES *mysql_res, /***** Get session data *****/ /* Code of the session (row[0]) */ if ((Session->SesCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) - Lay_ShowErrorAndExit ("Wrong code of exam session."); + Lay_WrongExamSessionExit (); /* Code of the exam (row[1]) */ if ((Session->ExaCod = Str_ConvertStrCodToLongCod (row[1])) <= 0) - Lay_ShowErrorAndExit ("Wrong code of exam."); + Lay_WrongExamExit (); /* Get whether the session is hidden (row[2]) */ Session->Hidden = (row[2][0] == 'Y'); diff --git a/swad_exam_set.c b/swad_exam_set.c index cbc5f6bee..4829b0c2a 100644 --- a/swad_exam_set.c +++ b/swad_exam_set.c @@ -785,7 +785,7 @@ static unsigned ExaSet_GetSetIndFromSetCod (long ExaCod,long SetCod) " WHERE SetCod=%u" " AND ExaCod=%ld", // Extra check SetCod,ExaCod)) - Lay_ShowErrorAndExit ("Error: wrong set code."); + Lay_WrongSetExit (); /***** Get set code (row[0]) *****/ row = mysql_fetch_row (mysql_res); @@ -814,7 +814,7 @@ static long ExaSet_GetSetCodFromSetInd (long ExaCod,unsigned SetInd) ExaCod, SetInd); if (SetCod <= 0) - Lay_ShowErrorAndExit ("Error: wrong set index."); + Lay_WrongSetExit (); return SetCod; } @@ -1323,7 +1323,7 @@ Tst_AnswerType_t ExaSet_GetQstAnswerTypeFromDB (long QstCod) " FROM exa_set_questions" " WHERE QstCod=%ld", QstCod)) - Lay_ShowErrorAndExit ("Question does not exist."); + Lay_WrongQuestionExit (); /* Get type of answer */ row = mysql_fetch_row (mysql_res); @@ -1464,7 +1464,7 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question) DB_FreeMySQLResult (&mysql_res); if (!QuestionExists) - Lay_ShowErrorAndExit ("Wrong question."); + Lay_WrongQuestionExit (); } /*****************************************************************************/ @@ -1596,7 +1596,7 @@ void ExaSet_AddQstsToSet (void) /* Get next code */ Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG); if (sscanf (LongStr,"%ld",&QstCod) != 1) - Lay_ShowErrorAndExit ("Wrong question code."); + Lay_WrongQuestionExit (); ExaSet_CopyQstFromBankToExamSet (&Set,QstCod); } @@ -2008,7 +2008,7 @@ void ExaSet_RemoveQstFromSet (void) QstCod, Set.SetCod); if (!mysql_affected_rows (&Gbl.mysql)) - Lay_ShowErrorAndExit ("The question to be removed does not exist."); + Lay_WrongQuestionExit (); /***** Write message *****/ Ale_ShowAlert (Ale_SUCCESS,Txt_Question_removed); diff --git a/swad_figure.c b/swad_figure.c index 2030b8528..69a4a8208 100644 --- a/swad_figure.c +++ b/swad_figure.c @@ -1577,7 +1577,7 @@ static unsigned Fig_GetInsAndStat (struct Ins_Instit *Ins,MYSQL_RES *mysql_res) /***** Get data of this institution (row[0]) *****/ Ins->InsCod = Str_ConvertStrCodToLongCod (row[0]); if (!Ins_GetDataOfInstitutionByCod (Ins)) - Lay_ShowErrorAndExit ("Institution not found."); + Lay_WrongInstitExit (); /***** Get statistic (row[1]) *****/ if (sscanf (row[1],"%u",&NumberThisRow) != 1) diff --git a/swad_forum.c b/swad_forum.c index 7736dace9..5a3aba9ed 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -2215,13 +2215,13 @@ void For_SetForumName (const struct For_Forum *Forum, case For_FORUM_INSTIT_USRS: Hie.Ins.InsCod = Forum->Location; if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins)) - Lay_ShowErrorAndExit ("Institution not found."); + Lay_WrongInstitExit (); Str_Copy (ForumName,Hie.Ins.ShrtName,For_MAX_BYTES_FORUM_NAME); break; case For_FORUM_INSTIT_TCHS: Hie.Ins.InsCod = Forum->Location; if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins)) - Lay_ShowErrorAndExit ("Institution not found."); + Lay_WrongInstitExit (); snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s", Hie.Ins.ShrtName, UseHTMLEntities ? Txt_only_teachers : @@ -2230,13 +2230,13 @@ void For_SetForumName (const struct For_Forum *Forum, case For_FORUM_CENTER_USRS: Hie.Ctr.CtrCod = Forum->Location; if (!Ctr_GetDataOfCenterByCod (&Hie.Ctr)) - Lay_ShowErrorAndExit ("Center not found."); + Lay_WrongCenterExit (); Str_Copy (ForumName,Hie.Ctr.ShrtName,For_MAX_BYTES_FORUM_NAME); break; case For_FORUM_CENTER_TCHS: Hie.Ctr.CtrCod = Forum->Location; if (!Ctr_GetDataOfCenterByCod (&Hie.Ctr)) - Lay_ShowErrorAndExit ("Center not found."); + Lay_WrongCenterExit (); snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s", Hie.Ctr.ShrtName, UseHTMLEntities ? Txt_only_teachers : @@ -2245,13 +2245,13 @@ void For_SetForumName (const struct For_Forum *Forum, case For_FORUM_DEGREE_USRS: Hie.Deg.DegCod = Forum->Location; if (!Deg_GetDataOfDegreeByCod (&Hie.Deg)) - Lay_ShowErrorAndExit ("Degree not found."); + Lay_WrongDegreeExit (); Str_Copy (ForumName,Hie.Deg.ShrtName,For_MAX_BYTES_FORUM_NAME); break; case For_FORUM_DEGREE_TCHS: Hie.Deg.DegCod = Forum->Location; if (!Deg_GetDataOfDegreeByCod (&Hie.Deg)) - Lay_ShowErrorAndExit ("Degree not found."); + Lay_WrongDegreeExit (); snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s", Hie.Deg.ShrtName, UseHTMLEntities ? Txt_only_teachers : @@ -2260,13 +2260,13 @@ void For_SetForumName (const struct For_Forum *Forum, case For_FORUM_COURSE_USRS: Hie.Crs.CrsCod = Forum->Location; if (!Crs_GetDataOfCourseByCod (&Hie.Crs)) - Lay_ShowErrorAndExit ("Course not found."); + Lay_WrongCourseExit (); Str_Copy (ForumName,Hie.Crs.ShrtName,For_MAX_BYTES_FORUM_NAME); break; case For_FORUM_COURSE_TCHS: Hie.Crs.CrsCod = Forum->Location; if (!Crs_GetDataOfCourseByCod (&Hie.Crs)) - Lay_ShowErrorAndExit ("Course not found."); + Lay_WrongCourseExit (); snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s", Hie.Crs.ShrtName, UseHTMLEntities ? Txt_only_teachers : diff --git a/swad_game.c b/swad_game.c index 5511c7974..7fe671dc1 100644 --- a/swad_game.c +++ b/swad_game.c @@ -469,7 +469,7 @@ void Gam_SeeOneGame (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Gam_GetDataOfGameByCod (&Game); /***** Show game *****/ @@ -929,7 +929,7 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder) /* Get next game code (row[0]) */ row = mysql_fetch_row (mysql_res); if ((Games->Lst[NumGame].GamCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) - Lay_ShowErrorAndExit ("Error: wrong game code."); + Lay_WrongGameExit (); } } @@ -1154,7 +1154,7 @@ void Gam_AskRemGame (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); /***** Get data of the game from database *****/ Gam_GetDataOfGameByCod (&Game); @@ -1190,8 +1190,8 @@ void Gam_RemoveGame (void) Gam_ResetGame (&Game); /***** Get game code *****/ - if ((Game.GamCod = Gam_GetParamGameCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of game is missing."); + if ((Game.GamCod = Gam_GetParamGameCod ()) <= 0) + Lay_WrongGameExit (); /***** Get data of the game from database *****/ Gam_GetDataOfGameByCod (&Game); @@ -1273,7 +1273,7 @@ void Gam_HideGame (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); /***** Get data of the game from database *****/ Gam_GetDataOfGameByCod (&Game); @@ -1308,7 +1308,7 @@ void Gam_UnhideGame (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); /***** Get data of the game from database *****/ Gam_GetDataOfGameByCod (&Game); @@ -1366,7 +1366,7 @@ void Gam_ListGame (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); /***** Get game data *****/ Gam_GetDataOfGameByCod (&Game); @@ -1738,7 +1738,7 @@ void Gam_ReqSelectQstsToAddToGame (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ @@ -1772,7 +1772,7 @@ void Gam_ListQstsToAddToGame (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ @@ -2170,7 +2170,7 @@ void Gam_AddQstsToGame (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ @@ -2196,7 +2196,7 @@ void Gam_AddQstsToGame (void) /* Get next code */ Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG); if (sscanf (LongStr,"%ld",&QstCod) != 1) - Lay_ShowErrorAndExit ("Wrong question code."); + Lay_WrongQuestionExit (); /* Check if question is already present in game */ if (Gam_GetQstIndFromQstCod (Game.GamCod,QstCod) == 0) // This question is not yet in this game @@ -2283,7 +2283,7 @@ void Gam_RequestRemoveQstFromGame (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ @@ -2327,7 +2327,7 @@ void Gam_RemoveQstFromGame (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ @@ -2349,7 +2349,7 @@ void Gam_RemoveQstFromGame (void) Game.GamCod, QstInd); if (!mysql_affected_rows (&Gbl.mysql)) - Lay_ShowErrorAndExit ("The question to be removed does not exist."); + Lay_WrongQuestionExit (); /* Change index of questions greater than this */ DB_QueryUPDATE ("can not update indexes of questions in table of answers", @@ -2398,7 +2398,7 @@ void Gam_MoveUpQst (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ @@ -2449,7 +2449,7 @@ void Gam_MoveDownQst (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ @@ -2599,7 +2599,7 @@ void Gam_RequestNewMatch (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Gam_GetDataOfGameByCod (&Game); /***** Show game *****/ diff --git a/swad_group.c b/swad_group.c index f54ffe195..7f312dfe1 100644 --- a/swad_group.c +++ b/swad_group.c @@ -3219,7 +3219,7 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat) /* Get the code of the course (row[1]) */ if ((GrpDat->CrsCod = Str_ConvertStrCodToLongCod (row[1])) <= 0) - Lay_ShowErrorAndExit ("Wrong code of course."); + Lay_WrongCourseExit (); /* Get the name of the group type (row[2]) */ Str_Copy (GrpDat->GrpTypName,row[2],sizeof (GrpDat->GrpTypName) - 1); diff --git a/swad_indicator.c b/swad_indicator.c index 7baff7299..a2d3c2e15 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -723,7 +723,7 @@ static void Ind_GetNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 /* Get course code (row[2]) */ if ((CrsCod = Str_ConvertStrCodToLongCod (row[2])) < 0) - Lay_ShowErrorAndExit ("Wrong code of course."); + Lay_WrongCourseExit (); /* Get stored number of indicators of this course */ NumIndicators = Ind_GetAndUpdateNumIndicatorsCrs (CrsCod); @@ -991,7 +991,7 @@ static void Ind_ShowTableOfCoursesWithIndicators (const struct Ind_Indicators *I /* Get course code (row[2]) */ if ((CrsCod = Str_ConvertStrCodToLongCod (row[2])) < 0) - Lay_ShowErrorAndExit ("Wrong code of course."); + Lay_WrongCourseExit (); /* Get stored number of indicators of this course */ NumIndicators = Ind_GetAndUpdateNumIndicatorsCrs (CrsCod); diff --git a/swad_institution.c b/swad_institution.c index e127a0b91..7c8e9760f 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -835,7 +835,7 @@ static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row) { /***** Get institution code (row[0]) *****/ if ((Ins->InsCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of institution."); + Lay_WrongInstitExit (); /***** Get country code (row[1]) *****/ Ins->CtyCod = Str_ConvertStrCodToLongCod (row[1]); @@ -1030,7 +1030,7 @@ void Ins_WriteSelectorOfInstitution (void) /* Get institution code (row[0]) */ if ((InsCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of institution."); + Lay_WrongInstitExit (); /* Write option */ HTM_OPTION (HTM_Type_LONG,&InsCod, @@ -1314,7 +1314,7 @@ long Ins_GetAndCheckParamOtherInsCod (long MinCodAllowed) /***** Get and check parameter with code of institution *****/ if ((InsCod = Ins_GetParamOtherInsCod ()) < MinCodAllowed) - Lay_ShowErrorAndExit ("Code of institution is missing or invalid."); + Lay_WrongInstitExit (); return InsCod; } @@ -2174,7 +2174,7 @@ static void Ins_EditingInstitutionConstructor (void) { /***** Pointer must be NULL *****/ if (Ins_EditingIns != NULL) - Lay_ShowErrorAndExit ("Error initializing institution."); + Lay_WrongInstitExit (); /***** Allocate memory for institution *****/ if ((Ins_EditingIns = malloc (sizeof (*Ins_EditingIns))) == NULL) diff --git a/swad_layout.c b/swad_layout.c index 1bfbc88fe..d2e06eb54 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1387,6 +1387,36 @@ void Lay_WrongScopeExit (void) Lay_ShowErrorAndExit ("Wrong scope."); } +/*****************************************************************************/ +/********* Write error message and exit *********/ +/********* when wrong country, institution, center, degree or course *********/ +/*****************************************************************************/ + +void Lay_WrongCountrExit (void) + { + Lay_ShowErrorAndExit ("Wrong country."); + } + +void Lay_WrongInstitExit (void) + { + Lay_ShowErrorAndExit ("Wrong institution."); + } + +void Lay_WrongCenterExit (void) + { + Lay_ShowErrorAndExit ("Wrong center."); + } + +void Lay_WrongDegreeExit (void) + { + Lay_ShowErrorAndExit ("Wrong degree."); + } + +void Lay_WrongCourseExit (void) + { + Lay_ShowErrorAndExit ("Wrong course."); + } + /*****************************************************************************/ /************* Write error message and exit when wrong order *****************/ /*****************************************************************************/ @@ -1441,6 +1471,15 @@ void Lay_WrongSetExit (void) Lay_ShowErrorAndExit ("Wrong set of questions."); } +/*****************************************************************************/ +/************* Write error message and exit when wrong question **************/ +/*****************************************************************************/ + +void Lay_WrongQuestionExit (void) + { + Lay_ShowErrorAndExit ("Wrong question."); + } + /*****************************************************************************/ /*********** Write error message and exit when wrong exam session ************/ /*****************************************************************************/ @@ -1450,6 +1489,20 @@ void Lay_WrongExamSessionExit (void) Lay_ShowErrorAndExit ("Wrong exam session."); } +/*****************************************************************************/ +/************ Write error message and exit when wrong game/match *************/ +/*****************************************************************************/ + +void Lay_WrongGameExit (void) + { + Lay_ShowErrorAndExit ("Wrong game."); + } + +void Lay_WrongMatchExit (void) + { + Lay_ShowErrorAndExit ("Wrong match."); + } + /*****************************************************************************/ /*** Write error message and exit when wrong parameter "who" (which users) ***/ /*****************************************************************************/ @@ -1459,6 +1512,15 @@ void Lay_WrongWhoExit (void) Lay_ShowErrorAndExit ("Wrong parameter who."); } +/*****************************************************************************/ +/**************** Write error message and exit when wrong event **************/ +/*****************************************************************************/ + +void Lay_WrongEventExit (void) + { + Lay_ShowErrorAndExit ("Wrong event."); + } + /*****************************************************************************/ /************ Write error message and exit when user does not exists *********/ /*****************************************************************************/ diff --git a/swad_layout.h b/swad_layout.h index d964affaf..4ef32ef75 100644 --- a/swad_layout.h +++ b/swad_layout.h @@ -71,14 +71,23 @@ void Lay_PutContextualCheckbox (Act_Action_t NextAction, void Lay_NotEnoughMemoryExit (void); void Lay_WrongScopeExit (void); +void Lay_WrongCountrExit (void); +void Lay_WrongInstitExit (void); +void Lay_WrongCenterExit (void); +void Lay_WrongDegreeExit (void); +void Lay_WrongCourseExit (void); void Lay_WrongOrderExit (void); void Lay_WrongTypeOfViewExit (void); void Lay_WrongProjectExit (void); void Lay_WrongCallForExamExit (void); void Lay_WrongExamExit (void); void Lay_WrongSetExit (void); +void Lay_WrongQuestionExit (void); void Lay_WrongExamSessionExit (void); +void Lay_WrongGameExit (void); +void Lay_WrongMatchExit (void); void Lay_WrongWhoExit (void); +void Lay_WrongEventExit (void); void Lay_WrongUserExit (void); void Lay_NoPermissionExit (void); void Lay_ShowErrorAndExit (const char *Txt); diff --git a/swad_match.c b/swad_match.c index 91bcaa6e2..49d68ee7e 100644 --- a/swad_match.c +++ b/swad_match.c @@ -1014,11 +1014,11 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res, /***** Get match data *****/ /* Code of the match (row[0]) */ if ((Match->MchCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) - Lay_ShowErrorAndExit ("Wrong code of match."); + Lay_WrongMatchExit (); /* Code of the game (row[1]) */ if ((Match->GamCod = Str_ConvertStrCodToLongCod (row[1])) <= 0) - Lay_ShowErrorAndExit ("Wrong code of game."); + Lay_WrongGameExit (); /* Get match teacher (row[2]) */ Match->UsrCod = Str_ConvertStrCodToLongCod (row[2]); @@ -1409,20 +1409,20 @@ void Mch_GetAndCheckParameters (struct Gam_Games *Games, /***** Get parameters *****/ /* Get parameters of game */ if ((Game->GamCod = Gam_GetParams (Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Grp_GetParamWhichGroups (); Gam_GetDataOfGameByCod (Game); /* Get match code */ if ((Match->MchCod = Mch_GetParamMchCod ()) <= 0) - Lay_ShowErrorAndExit ("Code of match is missing."); + Lay_WrongMatchExit (); Mch_GetDataOfMatchByCod (Match); /***** Ensure parameters are correct *****/ if (Game->GamCod != Match->GamCod) - Lay_ShowErrorAndExit ("Wrong game code."); + Lay_WrongGameExit (); if (Game->CrsCod != Gbl.Hierarchy.Crs.CrsCod) - Lay_ShowErrorAndExit ("Match does not belong to this course."); + Lay_WrongGameExit (); /***** Initialize context *****/ Games->GamCod = Game->GamCod; @@ -1624,8 +1624,8 @@ void Mch_CreateNewMatch (void) /***** Get form parameters *****/ /* Get match code */ - if ((GamCod = Gam_GetParamGameCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of game is missing."); + if ((GamCod = Gam_GetParamGameCod ()) < 0) + Lay_WrongGameExit (); /* Get match title */ Par_GetParToText ("Title",Title,Mch_MAX_BYTES_TITLE); @@ -1830,7 +1830,7 @@ static void Mch_CreateIndexes (long GamCod,long MchCod) /* Get question code (row[0]) */ if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /* Get question index (row[1]) */ if ((LongNum = Str_ConvertStrCodToLongCod (row[1])) < 0) @@ -3921,7 +3921,7 @@ void Mch_GetMatchBeingPlayed (void) /***** Get match code ****/ if ((MchCodBeingPlayed = Mch_GetParamMchCod ()) <= 0) - Lay_ShowErrorAndExit ("Code of match is missing."); + Lay_WrongMatchExit (); Mch_SetMchCodBeingPlayed (MchCodBeingPlayed); } @@ -4314,11 +4314,11 @@ void Mch_GetMatchQuestionsFromDB (struct MchPrn_Print *Print) /* Get question code (row[0]) */ if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /* Get question index (row[1]) */ if ((LongNum = Str_ConvertStrCodToLongCod (row[1])) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); QstInd = (unsigned) LongNum; /* Get indexes for this question (row[2]) */ diff --git a/swad_match_result.c b/swad_match_result.c index d9f27a0a9..2d7e8f3a8 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -169,7 +169,7 @@ void MchRes_ShowMyMchResultsInGam (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Gam_GetDataOfGameByCod (&Game); /***** Game begin *****/ @@ -219,9 +219,9 @@ void MchRes_ShowMyMchResultsInMch (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); if ((Match.MchCod = Mch_GetParamMchCod ()) <= 0) - Lay_ShowErrorAndExit ("Code of match is missing."); + Lay_WrongMatchExit (); Gam_GetDataOfGameByCod (&Game); Mch_GetDataOfMatchByCod (&Match); @@ -373,7 +373,7 @@ void MchRes_ShowAllMchResultsInGam (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); Gam_GetDataOfGameByCod (&Game); /***** Game begin *****/ @@ -462,9 +462,9 @@ void MchRes_ShowAllMchResultsInMch (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) - Lay_ShowErrorAndExit ("Code of game is missing."); + Lay_WrongGameExit (); if ((Match.MchCod = Mch_GetParamMchCod ()) <= 0) - Lay_ShowErrorAndExit ("Code of match is missing."); + Lay_WrongMatchExit (); Gam_GetDataOfGameByCod (&Game); Mch_GetDataOfMatchByCod (&Match); @@ -883,7 +883,7 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games, /* Get match code */ MchPrn_ResetPrint (&Print); if ((Print.MchCod = DB_GetNextCode (mysql_res)) < 0) - Lay_ShowErrorAndExit ("Wrong code of match."); + Lay_WrongMatchExit (); /* Get match result data */ Print.UsrCod = UsrDat->UsrCod; diff --git a/swad_photo.c b/swad_photo.c index 54516c1c9..24f749d99 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -2135,7 +2135,7 @@ static void Pho_ShowOrPrintClassPhotoDegrees (struct Pho_DegPhotos *DegPhotos, { /***** Get next degree *****/ if ((Deg.DegCod = DB_GetNextCode (mysql_res)) < 0) - Lay_ShowErrorAndExit ("Wrong code of degree."); + Lay_WrongDegreeExit (); /* Get data of degree */ Deg_GetDataOfDegreeByCod (&Deg); @@ -2232,7 +2232,7 @@ static void Pho_ShowOrPrintListDegrees (struct Pho_DegPhotos *DegPhotos, /* Get degree code (row[0]) */ if ((Deg.DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of degree."); + Lay_WrongDegreeExit (); /* Get data of degree */ Deg_GetDataOfDegreeByCod (&Deg); diff --git a/swad_survey.c b/swad_survey.c index 2f47c2d8b..e9041ed1c 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -1282,7 +1282,7 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy) /* Get survey scope (row[1]) */ if ((Svy->Scope = Sco_GetScopeFromDBStr (row[1])) == Hie_Lvl_UNK) - Lay_ShowErrorAndExit ("Wrong survey scope."); + Lay_WrongScopeExit (); /* Get code of the country, institution, center, degree or course (row[2]) */ Svy->Cod = Str_ConvertStrCodToLongCod (row[2]); @@ -1320,7 +1320,7 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy) switch (Svy->Scope) { case Hie_Lvl_UNK: // Unknown - Lay_ShowErrorAndExit ("Wrong survey scope."); + Lay_WrongScopeExit (); break; case Hie_Lvl_SYS: // System Svy->Status.IBelongToScope = Gbl.Usrs.Me.Logged; @@ -2226,41 +2226,41 @@ void Svy_ReceiveFormSurvey (void) { case Hie_Lvl_SYS: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM) - Lay_ShowErrorAndExit ("Wrong survey scope."); + Lay_WrongScopeExit (); NewSvy.Scope = Hie_Lvl_SYS; NewSvy.Cod = -1L; break; case Hie_Lvl_CTY: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM) - Lay_ShowErrorAndExit ("Wrong survey scope."); + Lay_WrongScopeExit (); NewSvy.Scope = Hie_Lvl_CTY; NewSvy.Cod = Gbl.Hierarchy.Cty.CtyCod; break; case Hie_Lvl_INS: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_INS_ADM) - Lay_ShowErrorAndExit ("Wrong survey scope."); + Lay_WrongScopeExit (); NewSvy.Scope = Hie_Lvl_INS; NewSvy.Cod = Gbl.Hierarchy.Ins.InsCod; break; case Hie_Lvl_CTR: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_CTR_ADM) - Lay_ShowErrorAndExit ("Wrong survey scope."); + Lay_WrongScopeExit (); NewSvy.Scope = Hie_Lvl_CTR; NewSvy.Cod = Gbl.Hierarchy.Ctr.CtrCod; break; case Hie_Lvl_DEG: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_DEG_ADM) - Lay_ShowErrorAndExit ("Wrong survey scope."); + Lay_WrongScopeExit (); NewSvy.Scope = Hie_Lvl_DEG; NewSvy.Cod = Gbl.Hierarchy.Deg.DegCod; break; case Hie_Lvl_CRS: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_TCH) - Lay_ShowErrorAndExit ("Wrong survey scope."); + Lay_WrongScopeExit (); NewSvy.Scope = Hie_Lvl_CRS; NewSvy.Cod = Gbl.Hierarchy.Crs.CrsCod; break; @@ -3700,7 +3700,7 @@ void Svy_RequestRemoveQst (void) /* Get question code */ if ((SvyQst.QstCod = Svy_GetParamQstCod ()) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /* Get question index */ SvyQst.QstInd = Svy_GetQstIndFromQstCod (SvyQst.QstCod); @@ -3742,7 +3742,7 @@ void Svy_RemoveQst (void) /* Get question code */ if ((SvyQst.QstCod = Svy_GetParamQstCod ()) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /* Get question index */ SvyQst.QstInd = Svy_GetQstIndFromQstCod (SvyQst.QstCod); @@ -3757,7 +3757,7 @@ void Svy_RemoveQst (void) " WHERE QstCod=%ld", SvyQst.QstCod); if (!mysql_affected_rows (&Gbl.mysql)) - Lay_ShowErrorAndExit ("The question to be removed does not exist."); + Lay_WrongQuestionExit (); /* Change index of questions greater than this */ DB_QueryUPDATE ("can not update indexes of questions", @@ -3844,7 +3844,7 @@ static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod) { /* Get next question */ if ((QstCod = DB_GetNextCode (mysql_res)) <= 0) - Lay_ShowErrorAndExit ("Error: wrong question code."); + Lay_WrongQuestionExit (); /* Get possible parameter with the user's answer */ snprintf (ParamName,sizeof (ParamName),"Ans%010u",(unsigned) QstCod); diff --git a/swad_test.c b/swad_test.c index 7cf651cab..69f7fc3eb 100644 --- a/swad_test.c +++ b/swad_test.c @@ -2169,7 +2169,7 @@ static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test, /***** Get question code (row[0]) *****/ row = mysql_fetch_row (mysql_res); if ((Test->Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /***** Write question row *****/ Tst_WriteQuestionListing (Test,NumQst); @@ -2432,7 +2432,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exam /* Get question code (row[0]) */ row = mysql_fetch_row (mysql_res); if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /* Write question row */ Tst_WriteQuestionRowForSelection (NumQst,&Question); @@ -2517,7 +2517,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam /* Get question code (row[0]) */ row = mysql_fetch_row (mysql_res); if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /* Write question row */ Tst_WriteQuestionRowForSelection (NumQst,&Question); @@ -3148,7 +3148,7 @@ unsigned Tst_CountNumQuestionsInList (const char *ListQuestions) { Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG); if (sscanf (LongStr,"%ld",&QstCod) != 1) - Lay_ShowErrorAndExit ("Wrong question code."); + Lay_WrongQuestionExit (); NumQuestions++; } return NumQuestions; @@ -4530,7 +4530,7 @@ bool Tst_CheckIfQuestionExistsInDB (struct Tst_Question *Question) { /* Get question code */ if ((Question->QstCod = DB_GetNextCode (mysql_res_qst)) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /* Get answers from this question */ NumOptsExistingQstInDB = @@ -4714,7 +4714,7 @@ void Tst_RemoveSelectedQsts (void) /* Get question code (row[0]) */ row = mysql_fetch_row (mysql_res); if ((QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /* Remove test question from database */ Tst_RemoveOneQstFromDB (Gbl.Hierarchy.Crs.CrsCod,QstCod); @@ -4759,7 +4759,7 @@ void Tst_RequestRemoveOneQst (void) /* Get the question code */ Test.Question.QstCod = Tst_GetParamQstCod (); if (Test.Question.QstCod <= 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /* Get a parameter that indicates whether it's necessary to continue listing the rest of questions */ @@ -4820,7 +4820,7 @@ void Tst_RemoveOneQst (void) /***** Get the question code *****/ QstCod = Tst_GetParamQstCod (); if (QstCod <= 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /***** Get a parameter that indicates whether it's necessary to continue listing the rest of questions ******/ @@ -4862,7 +4862,7 @@ static void Tst_RemoveOneQstFromDB (long CrsCod,long QstCod) CrsCod); if (!mysql_affected_rows (&Gbl.mysql)) - Lay_ShowErrorAndExit ("Wrong question."); + Lay_WrongQuestionExit (); } /*****************************************************************************/ @@ -4883,7 +4883,7 @@ void Tst_ChangeShuffleQst (void) /***** Get the question code *****/ Test.Question.QstCod = Tst_GetParamQstCod (); if (Test.Question.QstCod <= 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /***** Get a parameter that indicates whether it's necessary to continue listing the rest of questions ******/ EditingOnlyThisQst = Par_GetParToBool ("OnlyThisQst"); diff --git a/swad_test_print.c b/swad_test_print.c index 7b67647f5..a7d1db6a0 100644 --- a/swad_test_print.c +++ b/swad_test_print.c @@ -309,7 +309,7 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print, /* Show question */ if (!Tst_GetQstDataFromDB (&Question)) // Question exists - Lay_ShowErrorAndExit ("Wrong question."); + Lay_WrongQuestionExit (); /* Write question and answers */ TstPrn_WriteQstAndAnsToFill (&Print->PrintedQuestions[NumQst],NumQst,&Question); @@ -2782,7 +2782,7 @@ void TstPrn_GetPrintQuestionsFromDB (struct TstPrn_Print *Print) /* Get question code (row[0]) */ if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + Lay_WrongQuestionExit (); /* Get score (row[1]) */ Str_SetDecimalPointToUS (); // To get the decimal point as a dot